diff --git a/Images/console.png b/Images/console.png new file mode 100644 index 0000000..3abcf3d Binary files /dev/null and b/Images/console.png differ diff --git a/Images/menu.png b/Images/menu.png new file mode 100644 index 0000000..843d1ad Binary files /dev/null and b/Images/menu.png differ diff --git a/Internal/Features/ExampleFeature/ExampleFeature.cpp b/Internal/Features/ExampleFeature/ExampleFeature.cpp index d2dbdc8..1d1b5ce 100644 --- a/Internal/Features/ExampleFeature/ExampleFeature.cpp +++ b/Internal/Features/ExampleFeature/ExampleFeature.cpp @@ -24,34 +24,11 @@ bool ExampleFeature::SetupMenu() { "EXAMPLE_COLORPICKER"Hashed, "Przykładowy próbnik kolorów" } }); - GuiSection->SetCallback([]() { - ImGuiContext* pContext = ImGui::GetCurrentContext(); - - ImVec2 vec2Size = (Framework::menu->m_stStyle.vec2Size / ImVec2{ 3.f, 2.f }) - pContext->Style.ItemSpacing; - ImVec2 vec2MaxSize = ImGui::GetContentRegionAvail(); - - if (vec2Size.x > vec2MaxSize.x) - vec2Size.x = vec2MaxSize.x; - - if (vec2Size.y > vec2MaxSize.y) - vec2Size.y = vec2MaxSize.y; - - return vec2Size; - }); - - GuiSection->AddElement(GuiCheckbox.get()); - GuiCheckbox->AddElement(GuiEnabledText.get()); - GuiCheckbox->AddElement(GuiEnabledSlider.get()); - GuiSection->AddElement(GuiColorPickerLabel.get()); - GuiSection->AddElement(GuiColorPicker.get()); - return true; } void ExampleFeature::HandleMenu() { - if (!GuiSection->HasParent()) - Framework::menu->AddElement(GuiSection.get()); - - GuiCheckbox->SetChildrenVisible(GuiCheckbox->GetValue()); + if (!m_pBodyGroup->HasParent()) + Framework::menu->GetChild("HEADER_GROUP")->GetChild("BODY")->AddElement(m_pBodyGroup.get()); } \ No newline at end of file diff --git a/Internal/Features/ExampleFeature/ExampleFeature.h b/Internal/Features/ExampleFeature/ExampleFeature.h index cde06a0..d26dcdd 100644 --- a/Internal/Features/ExampleFeature/ExampleFeature.h +++ b/Internal/Features/ExampleFeature/ExampleFeature.h @@ -2,17 +2,94 @@ #include "pch.h" #include "Includes.h" +class ExampleBodyGroup : public ElementBase +{ +protected: + uint8_t m_iPageId; + uint8_t m_iSubPageId; + +public: + ExampleBodyGroup(std::string sUnique, Style_t stStyle = {}, uint8_t iPageId = 0, uint8_t iSubPageId = 0) + { + m_sUnique = sUnique; + m_stStyle = stStyle; + m_iPageId = iPageId; + m_iSubPageId = iSubPageId; + }; + + constexpr EElementType GetType() const override + { + return EElementType::BodyGroup; + }; + + void Render() override + { + if (!m_stStyle.bVisible) + return; + + if (m_iPageId != eCurrentPage || m_iSubPageId != eCurrentSubPage) + return; + + float fGroupWidth = (ImGui::GetWindowWidth() - 10.0f - 10.0f * 2) / 2; + float fGroupHeight = (ImGui::GetWindowHeight() - 10.0f - 10.0f * 2) / 2; + + ImGui::BeginGroup(); + { + ImGui::BeginChild("group1", ImVec2(fGroupWidth, fGroupHeight), ImGuiChildFlags_Border); + { + ImGui::TextDisabled("GROUP1"); + + static bool bEnabled = true; + static bool bDisabled = false; + ImAdd::SmallCheckbox("Enabled", &bEnabled); + ImAdd::SmallCheckbox("Disabled", &bDisabled); + + ImGui::SameLine(ImGui::GetWindowWidth() - 10.0f - ImGui::GetFontSize() * 2); + static ImVec4 v4Color = ImVec4(1, 1, 0, 0.5f); + ImAdd::ColorEdit4("##Color Picker", (float*)&v4Color); + } + ImGui::EndChild(); + ImGui::BeginChild("group2", ImVec2(fGroupWidth, 0), ImGuiChildFlags_Border); + { + ImGui::TextDisabled("GROUP2"); + + static bool bEnabled = true; + static bool bDisabled = false; + ImAdd::Togglebutton("Enabled", &bEnabled); + ImAdd::Togglebutton("Disabled", &bDisabled); + } + ImGui::EndChild(); + } + ImGui::EndGroup(); + ImGui::SameLine(); + ImGui::BeginChild("group3", ImVec2(0, 0), ImGuiChildFlags_Border); + { + ImGui::TextDisabled("GROUP3"); + + static int iCombo = 0; + ImAdd::Combo("Combo", &iCombo, "Item 1\0Item 2\0Item 3\0", -0.1f); + + static char inputText[32] = ""; + ImAdd::InputText("Text Input", "Write something here...", inputText, IM_ARRAYSIZE(inputText), -0.1f); + + static int iSlider = 8; + static float fSlider = 3; + ImAdd::SliderInt("Slider Int", &iSlider, 0, 10, -0.1f); + ImAdd::SliderFloat("Slider Float", &fSlider, 0, 10, -0.1f); + + ImGui::Separator(); + + ImAdd::Button("Button", ImVec2(-0.1f, 0)); + ImAdd::AcentButton("Acent button", ImVec2(-0.1f, 0)); + } + ImGui::EndChild(); + } +}; + class ExampleFeature : public BaseFeature { private: - std::unique_ptr GuiSection = std::make_unique("EXAMPLE_FEATURE", "EXAMPLE_FEATURE"Hashed, ElementBase::Style_t{ - .iFlags = ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY }, ImGuiWindowFlags_HorizontalScrollbar); - std::unique_ptr GuiCheckbox = std::make_unique("CHECKBOX", "EXAMPLE_FEATURE"Hashed); - std::unique_ptr GuiEnabledText = std::make_unique("CHECKBOX_ENABLED_TEXT", "EXAMPLE_FEATURE_HW"Hashed); - std::unique_ptr GuiEnabledSlider = std::make_unique("CHECKBOX_ENABLED_SLIDER", "EXAMPLE_FEATURE_SLIDER"Hashed); - std::unique_ptr GuiColorPickerLabel = std::make_unique("EXAMPLE_COLORPICKER_LABEL", "EXAMPLE_COLORPICKER"Hashed); - std::unique_ptr GuiColorPicker = std::make_unique("EXAMPLE_COLORPICKER", "EXAMPLE_COLORPICKER"Hashed, ElementBase::Style_t{ - .iFlags = ImGuiColorEditFlags_NoInputs}); + std::unique_ptr m_pBodyGroup = std::make_unique("EXAMPLE_BODY_GROUP", ElementBase::Style_t(), ElementBase::EPage::Developer, 0); public: bool SetupMenu(); diff --git a/Internal/GUI/GUI.cpp b/Internal/GUI/GUI.cpp index 1957306..f98beac 100644 --- a/Internal/GUI/GUI.cpp +++ b/Internal/GUI/GUI.cpp @@ -106,6 +106,8 @@ void GUI::Render() GuiSidebar->AddElement(GuiStyle.get()); GuiSidebar->AddElement(GuiSettings.get()); GuiSidebar->AddElement(GuiConfig.get()); + + GuiHeaderGroup->AddElement(GuiBody.get()); }); /* @@ -119,6 +121,7 @@ void GUI::Render() if (!GuiSidebar->HasParent()) { Framework::menu->AddElement(GuiSidebar.get()); + Framework::menu->AddElement(GuiHeaderGroup.get()); } for (auto& pFeature : Framework::g_vecFeatures) diff --git a/Internal/GUI/GUI.h b/Internal/GUI/GUI.h index c32a3d5..7a5b287 100644 --- a/Internal/GUI/GUI.h +++ b/Internal/GUI/GUI.h @@ -36,6 +36,16 @@ namespace GUI .vec2Size = ImVec2(-0.1f, 0) }, ICON_FA_GEAR, ElementBase::EPage::Settings); inline std::unique_ptr GuiConfig = std::make_unique(std::string("CONFIG_BUTTON"), "CONFIG_BUTTON"Hashed, ElementBase::Style_t{ .vec2Size = ImVec2(-0.1f, 0) }, ICON_FA_FLOPPY_DISK, ElementBase::EPage::Config); + + inline std::vector HeaderGroupHeaders = { + { ElementBase::EPage::Developer, { "MAIN"Hashed, "EXAMPLE"Hashed, "EXAMPLE2"Hashed } } + }; + inline std::unique_ptr GuiHeaderGroup = std::make_unique(std::string("HEADER_GROUP"), "HEADER_GROUP"Hashed, ElementBase::Style_t{ + .vec2Size = ImVec2(-0.1f, 0), }, HeaderGroupHeaders); + + inline std::unique_ptr GuiBody = std::make_unique(std::string("BODY"), ElementBase::Style_t{ + .vec2Size = ImVec2(-0.1f, 0), }); + /* inline std::unique_ptr GuiCheat = std::make_unique(std::string("CHEAT"), "CHEAT"Hashed, ElementBase::Style_t{ .iFlags = ImGuiChildFlags_Border | ImGuiChildFlags_AutoResizeX | ImGuiChildFlags_AutoResizeY }, ImGuiWindowFlags_HorizontalScrollbar); diff --git a/Internal/GUI/Menu/Menu.h b/Internal/GUI/Menu/Menu.h index 7eea596..904ac74 100644 --- a/Internal/GUI/Menu/Menu.h +++ b/Internal/GUI/Menu/Menu.h @@ -16,6 +16,9 @@ class ElementBase InputText, Menu, RadioButtonIcon, + HeaderGroup, + Body, + BodyGroup, SliderFloat, SliderInt, SeperatorText, @@ -53,6 +56,12 @@ class ElementBase Config }; + typedef struct Header_t + { + uint8_t m_iParentPageID; + std::vector m_ullLocalizedNameHashes; + } Header_t; + protected: // used to display a custom or unlocalized name for elements like buttons bool m_bUnlocalizedName = false; @@ -65,6 +74,9 @@ class ElementBase ElementBase* m_pParent = nullptr; std::vector m_Children; + inline static uint8_t eCurrentPage = ElementBase::EPage::Developer; + inline static uint8_t eCurrentSubPage = 0; + inline void SameLine() { switch (m_stStyle.eSameLine) @@ -277,8 +289,6 @@ class ElementBase }; }; -static uint8_t eCurrentPage = ElementBase::EPage::Developer; - template class ElementInput : public ElementBase { @@ -1246,6 +1256,117 @@ class RadioButtonIcon : public ElementBase SameLine(); - ImAdd::RadioButtonIcon(GetName().c_str(), m_sIcon, GetName().c_str(), &eCurrentPage, m_iPageId, m_stStyle.vec2Size); + if (ImAdd::RadioButtonIcon(GetName().c_str(), m_sIcon, GetName().c_str(), &eCurrentPage, m_iPageId, m_stStyle.vec2Size)) { + eCurrentPage = m_iPageId; + } + }; +}; + +class HeaderGroup : public ElementBase +{ +protected: + std::vector m_Headers; + +public: + HeaderGroup(std::string sUnique, size_t ullLocalizedNameHash, Style_t stStyle = {}, std::vector Headers = {}) + { + m_sUnique = sUnique; + m_ullLocalizedNameHash = ullLocalizedNameHash; + m_stStyle = stStyle; + m_Headers = Headers; + }; + + HeaderGroup(std::string sUnique, std::string sUnlocalizedName, Style_t stStyle = {}, std::vector Headers = {}) + { + m_sUnique = sUnique; + m_bUnlocalizedName = true; + m_sUnlocalizedName = sUnlocalizedName; + m_stStyle = stStyle; + m_Headers = Headers; + }; + + constexpr EElementType GetType() const override + { + return EElementType::HeaderGroup; + }; + + void Render() override + { + if (!m_stStyle.bVisible) + return; + + ImGui::SameLine(160); + ImGui::BeginChild(m_sUnique.c_str(), ImVec2(0, ImGui::GetFrameHeight() + 10.0f * 2), ImGuiChildFlags_Border, ImGuiWindowFlags_NoBackground); + { + for (auto Header : m_Headers) + { + if (Header.m_iParentPageID != eCurrentPage) + continue; + + for (int i = 0; i < Header.m_ullLocalizedNameHashes.size(); i++) { + uint8_t test; + if (ImAdd::RadioButton(Localization::Get(Header.m_ullLocalizedNameHashes[i]).c_str(), &test, i)) { + eCurrentSubPage = i; + } + ImGui::SameLine(); + } + } + ImGui::NewLine(); + + // Search bar + /* + ImGui::SameLine(ImGui::GetWindowWidth() - 160 - 10.0f - 10.0f - 1); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 6); + { + ImGui::BeginGroup(); + { + if (1 > 0) + { + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(NULL, 3)); + { + ImAdd::VSeparator(1); + } + ImGui::PopStyleVar(); + ImGui::SameLine(); + } + static char cSearch[32] = ""; + ImAdd::InputText("##Search", "Search", cSearch, IM_ARRAYSIZE(cSearch), 160); + } + ImGui::EndGroup(); + } + ImGui::PopStyleVar(); + */ + } + ImGui::EndChild(); + RenderChildren(); + } +}; + +class Body : public ElementBase +{ +public: + Body(std::string sUnique, Style_t stStyle = {}) + { + m_sUnique = sUnique; + m_stStyle = stStyle; + }; + + constexpr EElementType GetType() const override + { + return EElementType::Body; }; + + void Render() override + { + if (!m_stStyle.bVisible) + return; + + ImGui::SetCursorPosX(160); + ImGui::SetCursorPosY(ImGui::GetFrameHeight() + 10.0f * 2); + ImGui::BeginChild(m_sUnique.c_str(), ImVec2(0, ImGui::GetWindowHeight() - ImGui::GetFrameHeight() - (ImGui::GetFrameHeight() + 10.0f * 2)), ImGuiChildFlags_Border, ImGuiWindowFlags_NoBackground); + { + RenderChildren(); + } + ImGui::EndChild(); + } }; \ No newline at end of file diff --git a/Internal/Localization/Locales/English.h b/Internal/Localization/Locales/English.h index 383927c..5bd83e6 100644 --- a/Internal/Localization/Locales/English.h +++ b/Internal/Localization/Locales/English.h @@ -23,5 +23,9 @@ Locale_t localeEnglish{ { "STYLE_BUTTON"Hashed, "Style" }, { "SETTINGS_BUTTON"Hashed, "Settings" }, { "CONFIG_BUTTON"Hashed, "Config" }, + + { "MAIN"Hashed, "Main" }, + { "EXAMPLE"Hashed, "Example" }, + { "EXAMPLE2"Hashed, "Example2" } }), }; diff --git a/README.md b/README.md index 2f5b356..1e266ab 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ # IMPORTANT -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 +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! # OmegaWare Cheat Framework ![Logo](Images/NewLogo.png) +

Menu Design:
+![Menu](Images/menu.png) +

Console Appearence:
+![Menu](Images/console.png)