Skip to content

Commit 21340e9

Browse files
authored
Merge pull request #10 from Omega172/Dev
Menu functions now, but still needs improvement, and added example images.
2 parents 1ad0748 + f479338 commit 21340e9

9 files changed

Lines changed: 233 additions & 37 deletions

File tree

Images/console.png

31.5 KB
Loading

Images/menu.png

29.3 KB
Loading

Internal/Features/ExampleFeature/ExampleFeature.cpp

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,11 @@ bool ExampleFeature::SetupMenu()
2424
{ "EXAMPLE_COLORPICKER"Hashed, "Przykładowy próbnik kolorów" }
2525
});
2626

27-
GuiSection->SetCallback([]() {
28-
ImGuiContext* pContext = ImGui::GetCurrentContext();
29-
30-
ImVec2 vec2Size = (Framework::menu->m_stStyle.vec2Size / ImVec2{ 3.f, 2.f }) - pContext->Style.ItemSpacing;
31-
ImVec2 vec2MaxSize = ImGui::GetContentRegionAvail();
32-
33-
if (vec2Size.x > vec2MaxSize.x)
34-
vec2Size.x = vec2MaxSize.x;
35-
36-
if (vec2Size.y > vec2MaxSize.y)
37-
vec2Size.y = vec2MaxSize.y;
38-
39-
return vec2Size;
40-
});
41-
42-
GuiSection->AddElement(GuiCheckbox.get());
43-
GuiCheckbox->AddElement(GuiEnabledText.get());
44-
GuiCheckbox->AddElement(GuiEnabledSlider.get());
45-
GuiSection->AddElement(GuiColorPickerLabel.get());
46-
GuiSection->AddElement(GuiColorPicker.get());
47-
4827
return true;
4928
}
5029

5130
void ExampleFeature::HandleMenu()
5231
{
53-
if (!GuiSection->HasParent())
54-
Framework::menu->AddElement(GuiSection.get());
55-
56-
GuiCheckbox->SetChildrenVisible(GuiCheckbox->GetValue());
32+
if (!m_pBodyGroup->HasParent())
33+
Framework::menu->GetChild("HEADER_GROUP")->GetChild("BODY")->AddElement(m_pBodyGroup.get());
5734
}

Internal/Features/ExampleFeature/ExampleFeature.h

Lines changed: 85 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,94 @@
22
#include "pch.h"
33
#include "Includes.h"
44

5+
class ExampleBodyGroup : public ElementBase
6+
{
7+
protected:
8+
uint8_t m_iPageId;
9+
uint8_t m_iSubPageId;
10+
11+
public:
12+
ExampleBodyGroup(std::string sUnique, Style_t stStyle = {}, uint8_t iPageId = 0, uint8_t iSubPageId = 0)
13+
{
14+
m_sUnique = sUnique;
15+
m_stStyle = stStyle;
16+
m_iPageId = iPageId;
17+
m_iSubPageId = iSubPageId;
18+
};
19+
20+
constexpr EElementType GetType() const override
21+
{
22+
return EElementType::BodyGroup;
23+
};
24+
25+
void Render() override
26+
{
27+
if (!m_stStyle.bVisible)
28+
return;
29+
30+
if (m_iPageId != eCurrentPage || m_iSubPageId != eCurrentSubPage)
31+
return;
32+
33+
float fGroupWidth = (ImGui::GetWindowWidth() - 10.0f - 10.0f * 2) / 2;
34+
float fGroupHeight = (ImGui::GetWindowHeight() - 10.0f - 10.0f * 2) / 2;
35+
36+
ImGui::BeginGroup();
37+
{
38+
ImGui::BeginChild("group1", ImVec2(fGroupWidth, fGroupHeight), ImGuiChildFlags_Border);
39+
{
40+
ImGui::TextDisabled("GROUP1");
41+
42+
static bool bEnabled = true;
43+
static bool bDisabled = false;
44+
ImAdd::SmallCheckbox("Enabled", &bEnabled);
45+
ImAdd::SmallCheckbox("Disabled", &bDisabled);
46+
47+
ImGui::SameLine(ImGui::GetWindowWidth() - 10.0f - ImGui::GetFontSize() * 2);
48+
static ImVec4 v4Color = ImVec4(1, 1, 0, 0.5f);
49+
ImAdd::ColorEdit4("##Color Picker", (float*)&v4Color);
50+
}
51+
ImGui::EndChild();
52+
ImGui::BeginChild("group2", ImVec2(fGroupWidth, 0), ImGuiChildFlags_Border);
53+
{
54+
ImGui::TextDisabled("GROUP2");
55+
56+
static bool bEnabled = true;
57+
static bool bDisabled = false;
58+
ImAdd::Togglebutton("Enabled", &bEnabled);
59+
ImAdd::Togglebutton("Disabled", &bDisabled);
60+
}
61+
ImGui::EndChild();
62+
}
63+
ImGui::EndGroup();
64+
ImGui::SameLine();
65+
ImGui::BeginChild("group3", ImVec2(0, 0), ImGuiChildFlags_Border);
66+
{
67+
ImGui::TextDisabled("GROUP3");
68+
69+
static int iCombo = 0;
70+
ImAdd::Combo("Combo", &iCombo, "Item 1\0Item 2\0Item 3\0", -0.1f);
71+
72+
static char inputText[32] = "";
73+
ImAdd::InputText("Text Input", "Write something here...", inputText, IM_ARRAYSIZE(inputText), -0.1f);
74+
75+
static int iSlider = 8;
76+
static float fSlider = 3;
77+
ImAdd::SliderInt("Slider Int", &iSlider, 0, 10, -0.1f);
78+
ImAdd::SliderFloat("Slider Float", &fSlider, 0, 10, -0.1f);
79+
80+
ImGui::Separator();
81+
82+
ImAdd::Button("Button", ImVec2(-0.1f, 0));
83+
ImAdd::AcentButton("Acent button", ImVec2(-0.1f, 0));
84+
}
85+
ImGui::EndChild();
86+
}
87+
};
88+
589
class ExampleFeature : public BaseFeature
690
{
791
private:
8-
std::unique_ptr<Child> GuiSection = std::make_unique<Child>("EXAMPLE_FEATURE", "EXAMPLE_FEATURE"Hashed, ElementBase::Style_t{
9-
.iFlags = ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY }, ImGuiWindowFlags_HorizontalScrollbar);
10-
std::unique_ptr<Checkbox> GuiCheckbox = std::make_unique<Checkbox>("CHECKBOX", "EXAMPLE_FEATURE"Hashed);
11-
std::unique_ptr<Text> GuiEnabledText = std::make_unique<Text>("CHECKBOX_ENABLED_TEXT", "EXAMPLE_FEATURE_HW"Hashed);
12-
std::unique_ptr<SliderInt> GuiEnabledSlider = std::make_unique<SliderInt>("CHECKBOX_ENABLED_SLIDER", "EXAMPLE_FEATURE_SLIDER"Hashed);
13-
std::unique_ptr<Text> GuiColorPickerLabel = std::make_unique<Text>("EXAMPLE_COLORPICKER_LABEL", "EXAMPLE_COLORPICKER"Hashed);
14-
std::unique_ptr<ColorPicker> GuiColorPicker = std::make_unique<ColorPicker>("EXAMPLE_COLORPICKER", "EXAMPLE_COLORPICKER"Hashed, ElementBase::Style_t{
15-
.iFlags = ImGuiColorEditFlags_NoInputs});
92+
std::unique_ptr<ExampleBodyGroup> m_pBodyGroup = std::make_unique<ExampleBodyGroup>("EXAMPLE_BODY_GROUP", ElementBase::Style_t(), ElementBase::EPage::Developer, 0);
1693

1794
public:
1895
bool SetupMenu();

Internal/GUI/GUI.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ void GUI::Render()
106106
GuiSidebar->AddElement(GuiStyle.get());
107107
GuiSidebar->AddElement(GuiSettings.get());
108108
GuiSidebar->AddElement(GuiConfig.get());
109+
110+
GuiHeaderGroup->AddElement(GuiBody.get());
109111
});
110112

111113
/*
@@ -119,6 +121,7 @@ void GUI::Render()
119121

120122
if (!GuiSidebar->HasParent()) {
121123
Framework::menu->AddElement(GuiSidebar.get());
124+
Framework::menu->AddElement(GuiHeaderGroup.get());
122125
}
123126

124127
for (auto& pFeature : Framework::g_vecFeatures)

Internal/GUI/GUI.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ namespace GUI
3636
.vec2Size = ImVec2(-0.1f, 0) }, ICON_FA_GEAR, ElementBase::EPage::Settings);
3737
inline std::unique_ptr<RadioButtonIcon> GuiConfig = std::make_unique<RadioButtonIcon>(std::string("CONFIG_BUTTON"), "CONFIG_BUTTON"Hashed, ElementBase::Style_t{
3838
.vec2Size = ImVec2(-0.1f, 0) }, ICON_FA_FLOPPY_DISK, ElementBase::EPage::Config);
39+
40+
inline std::vector<ElementBase::Header_t> HeaderGroupHeaders = {
41+
{ ElementBase::EPage::Developer, { "MAIN"Hashed, "EXAMPLE"Hashed, "EXAMPLE2"Hashed } }
42+
};
43+
inline std::unique_ptr<HeaderGroup> GuiHeaderGroup = std::make_unique<HeaderGroup>(std::string("HEADER_GROUP"), "HEADER_GROUP"Hashed, ElementBase::Style_t{
44+
.vec2Size = ImVec2(-0.1f, 0), }, HeaderGroupHeaders);
45+
46+
inline std::unique_ptr<Body> GuiBody = std::make_unique<Body>(std::string("BODY"), ElementBase::Style_t{
47+
.vec2Size = ImVec2(-0.1f, 0), });
48+
3949
/*
4050
inline std::unique_ptr<Child> GuiCheat = std::make_unique<Child>(std::string("CHEAT"), "CHEAT"Hashed, ElementBase::Style_t{
4151
.iFlags = ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY }, ImGuiWindowFlags_HorizontalScrollbar);

Internal/GUI/Menu/Menu.h

Lines changed: 124 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class ElementBase
1616
InputText,
1717
Menu,
1818
RadioButtonIcon,
19+
HeaderGroup,
20+
Body,
21+
BodyGroup,
1922
SliderFloat,
2023
SliderInt,
2124
SeperatorText,
@@ -53,6 +56,12 @@ class ElementBase
5356
Config
5457
};
5558

59+
typedef struct Header_t
60+
{
61+
uint8_t m_iParentPageID;
62+
std::vector<size_t> m_ullLocalizedNameHashes;
63+
} Header_t;
64+
5665
protected:
5766
// used to display a custom or unlocalized name for elements like buttons
5867
bool m_bUnlocalizedName = false;
@@ -65,6 +74,9 @@ class ElementBase
6574
ElementBase* m_pParent = nullptr;
6675
std::vector<ElementBase*> m_Children;
6776

77+
inline static uint8_t eCurrentPage = ElementBase::EPage::Developer;
78+
inline static uint8_t eCurrentSubPage = 0;
79+
6880
inline void SameLine()
6981
{
7082
switch (m_stStyle.eSameLine)
@@ -277,8 +289,6 @@ class ElementBase
277289
};
278290
};
279291

280-
static uint8_t eCurrentPage = ElementBase::EPage::Developer;
281-
282292
template<typename T>
283293
class ElementInput : public ElementBase
284294
{
@@ -1246,6 +1256,117 @@ class RadioButtonIcon : public ElementBase
12461256

12471257
SameLine();
12481258

1249-
ImAdd::RadioButtonIcon(GetName().c_str(), m_sIcon, GetName().c_str(), &eCurrentPage, m_iPageId, m_stStyle.vec2Size);
1259+
if (ImAdd::RadioButtonIcon(GetName().c_str(), m_sIcon, GetName().c_str(), &eCurrentPage, m_iPageId, m_stStyle.vec2Size)) {
1260+
eCurrentPage = m_iPageId;
1261+
}
1262+
};
1263+
};
1264+
1265+
class HeaderGroup : public ElementBase
1266+
{
1267+
protected:
1268+
std::vector<Header_t> m_Headers;
1269+
1270+
public:
1271+
HeaderGroup(std::string sUnique, size_t ullLocalizedNameHash, Style_t stStyle = {}, std::vector<Header_t> Headers = {})
1272+
{
1273+
m_sUnique = sUnique;
1274+
m_ullLocalizedNameHash = ullLocalizedNameHash;
1275+
m_stStyle = stStyle;
1276+
m_Headers = Headers;
1277+
};
1278+
1279+
HeaderGroup(std::string sUnique, std::string sUnlocalizedName, Style_t stStyle = {}, std::vector<Header_t> Headers = {})
1280+
{
1281+
m_sUnique = sUnique;
1282+
m_bUnlocalizedName = true;
1283+
m_sUnlocalizedName = sUnlocalizedName;
1284+
m_stStyle = stStyle;
1285+
m_Headers = Headers;
1286+
};
1287+
1288+
constexpr EElementType GetType() const override
1289+
{
1290+
return EElementType::HeaderGroup;
1291+
};
1292+
1293+
void Render() override
1294+
{
1295+
if (!m_stStyle.bVisible)
1296+
return;
1297+
1298+
ImGui::SameLine(160);
1299+
ImGui::BeginChild(m_sUnique.c_str(), ImVec2(0, ImGui::GetFrameHeight() + 10.0f * 2), ImGuiChildFlags_Border, ImGuiWindowFlags_NoBackground);
1300+
{
1301+
for (auto Header : m_Headers)
1302+
{
1303+
if (Header.m_iParentPageID != eCurrentPage)
1304+
continue;
1305+
1306+
for (int i = 0; i < Header.m_ullLocalizedNameHashes.size(); i++) {
1307+
uint8_t test;
1308+
if (ImAdd::RadioButton(Localization::Get(Header.m_ullLocalizedNameHashes[i]).c_str(), &test, i)) {
1309+
eCurrentSubPage = i;
1310+
}
1311+
ImGui::SameLine();
1312+
}
1313+
}
1314+
ImGui::NewLine();
1315+
1316+
// Search bar
1317+
/*
1318+
ImGui::SameLine(ImGui::GetWindowWidth() - 160 - 10.0f - 10.0f - 1);
1319+
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 6);
1320+
{
1321+
ImGui::BeginGroup();
1322+
{
1323+
if (1 > 0)
1324+
{
1325+
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(NULL, 3));
1326+
{
1327+
ImAdd::VSeparator(1);
1328+
}
1329+
ImGui::PopStyleVar();
1330+
ImGui::SameLine();
1331+
}
1332+
static char cSearch[32] = "";
1333+
ImAdd::InputText("##Search", "Search", cSearch, IM_ARRAYSIZE(cSearch), 160);
1334+
}
1335+
ImGui::EndGroup();
1336+
}
1337+
ImGui::PopStyleVar();
1338+
*/
1339+
}
1340+
ImGui::EndChild();
1341+
RenderChildren();
1342+
}
1343+
};
1344+
1345+
class Body : public ElementBase
1346+
{
1347+
public:
1348+
Body(std::string sUnique, Style_t stStyle = {})
1349+
{
1350+
m_sUnique = sUnique;
1351+
m_stStyle = stStyle;
1352+
};
1353+
1354+
constexpr EElementType GetType() const override
1355+
{
1356+
return EElementType::Body;
12501357
};
1358+
1359+
void Render() override
1360+
{
1361+
if (!m_stStyle.bVisible)
1362+
return;
1363+
1364+
ImGui::SetCursorPosX(160);
1365+
ImGui::SetCursorPosY(ImGui::GetFrameHeight() + 10.0f * 2);
1366+
ImGui::BeginChild(m_sUnique.c_str(), ImVec2(0, ImGui::GetWindowHeight() - ImGui::GetFrameHeight() - (ImGui::GetFrameHeight() + 10.0f * 2)), ImGuiChildFlags_Border, ImGuiWindowFlags_NoBackground);
1367+
{
1368+
RenderChildren();
1369+
}
1370+
ImGui::EndChild();
1371+
}
12511372
};

Internal/Localization/Locales/English.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,9 @@ Locale_t localeEnglish{
2323
{ "STYLE_BUTTON"Hashed, "Style" },
2424
{ "SETTINGS_BUTTON"Hashed, "Settings" },
2525
{ "CONFIG_BUTTON"Hashed, "Config" },
26+
27+
{ "MAIN"Hashed, "Main" },
28+
{ "EXAMPLE"Hashed, "Example" },
29+
{ "EXAMPLE2"Hashed, "Example2" }
2630
}),
2731
};

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# IMPORTANT
2-
The framework is in a weird spot right now so the menu builder is kinda fucked, while we are redesigning it it will be finished SoonTM
2+
The menu overhall is nearing completion but it is still in a weird spot and is not as simple to implement as I would like it to be but it works!
33

44
# OmegaWare Cheat Framework
55
![Logo](Images/NewLogo.png)
6+
<br><br>Menu Design:<br>
7+
![Menu](Images/menu.png)
8+
<br><br>Console Appearence:<br>
9+
![Menu](Images/console.png)
610

711
<div align="center">
812

0 commit comments

Comments
 (0)