diff --git a/example-src/example.cpp b/example-src/example.cpp index fece8df..04bd3ae 100644 --- a/example-src/example.cpp +++ b/example-src/example.cpp @@ -60,44 +60,36 @@ public: : CBaseWindow(parent, "root_test") { this->always_visible = false; this->hover = false; - SetMaxSize(1270, 1000); - SetPositionMode(PositionMode::FLOATING); + this->SetMaxSize(1270, 1000); + this->SetPositionMode(PositionMode::FLOATING); - auto* titlebar = new CTitleBar(this, "Test uwu~"); - AddChild(titlebar); + this->Add("Test uwu~"); // this->visible = true; - AddChild(new CTextLabel("button_label", this, "Button widget:")); - AddChild(new CBaseButton("button", this, "I'm Clickable!", [this](CBaseButton*) { + this->Add("button_label", "Button widget:"); + this->Add("button", "I'm Clickable!", [this](CBaseButton*) { std::cout << "Hey hey I was pressed!" << std::endl; this->button_clicked = !this->button_clicked; - })); + }); - AddChild(new CTextLabel("checkbox_label", this, "Checkbox widget:")); - AddChild(new CCheckbox("checkbox", this, false)); + this->Add("checkbox_label", "Checkbox widget:"); + this->Add("checkbox", false); - AddChild(new CTextLabel("slider_label", this, "Slider widget:")); - auto* slider = new CSlider("slider", this); - slider->SetStep(0.1f); - AddChild(slider); + this->Add("slider_label", "Slider widget:"); + this->Add("slider")->SetStep(0.1f); - AddChild(new CTextLabel("dropdown_label", this, "Dropdown widget:")); - auto dropdown = new CDropdown("dropdown", this); + this->Add("dropdown_label", "Dropdown widget:"); + auto* dropdown = this->Add("dropdown"); dropdown->AddValue("Im the cutest princess!"); dropdown->AddValue("No I am, hmp!"); dropdown->AddValue("*doomguy noises*"); dropdown->SetSize(150, 16); - AddChild(dropdown); - AddChild(new CTextLabel("text_input_label", this, "Text input widget:")); - auto* text_input = new CTextInput("text_input", this); - text_input->SetValue("You can edit me!"); - AddChild(text_input); + this->Add("text_input_label", "Text input widget:"); + this->Add("text_input")->SetValue("You can edit me!"); - AddChild(new CTextLabel("key_input_label", this, "Key widget:")); - auto key_input = new CKeyInput("key_input"); - key_input->SetSize(78, 10); - AddChild(key_input); + this->Add("key_input_label", "Key widget:"); + this->Add("key_input")->SetSize(78, 10); } virtual void Update() override { this->CBaseWindow::Update(); @@ -149,10 +141,9 @@ int main() { glez::end(); xoverlay_draw_end(); } + auto bounds = input::GetBounds(); - auto test_window = new TestWindow(canvas); - - canvas->AddChild(test_window); + auto test_window = canvas->Add(); using namespace menu::ncc; // auto* list_menu = List::FromString(menu_list); @@ -167,29 +158,26 @@ int main() { list_menu->SetMaxSize(1000, 1000); list_menu->Show(); canvas->AddChild(list_menu); + list_menu->SetOffset((bounds.first - 912) / 4, (bounds.second - 410) / 3); - auto* tabbedmenu = new CMenuWindow("menu_window", canvas); + auto* tabbedmenu = canvas->Add("menu_window"); tabbedmenu->SetMaxSize(912, 410); tabbedmenu->AddTab("aimbot", "Main"); CMenuContainer* tab = tabbedmenu->GetTab("aimbot"); - tab->AddChild(new CTextLabel("label", tab, "This is a bool!", true)); - tab->AddChild(new CCVarContainer(tab, &text)); + tab->Add("label", "This is a bool!", true); + tab->Add(&text); tabbedmenu->AddTab("esp", "Sub"); tabbedmenu->AddTab("esp2", "Sub2"); tabbedmenu->AddTab("esp3", "Sub3"); + tabbedmenu->SetOffset((bounds.first - 912) / 2, (bounds.second - 410) / 2); - // tabbedmenu->SetOffset((draw::width - 912) / 2, (draw::height - 410) / 2); - canvas->AddChild(tabbedmenu); - - auto* logo = new ncc::Logo(canvas); - logo->SetOffset(500, 25); - canvas->AddChild(logo); + canvas->Add()->SetOffset(500, 25); canvas->AddChild(new ncc::Background()); - for (auto& i : ui::BaseVar::GetList()) - printf("ui::BaseVar: %s\n", i->command_name.c_str()); + /*for (auto& i : ui::BaseVar::GetList()) + printf("ui::BaseVar: %s\n", i->command_name.c_str());*/ xoverlay_show(); while (1) { input::RefreshInput(); diff --git a/include/libpdraw/gui/tabbedmenu/menuwindow.hpp b/include/libpdraw/gui/tabbedmenu/menuwindow.hpp index ccbe2a5..24060a2 100644 --- a/include/libpdraw/gui/tabbedmenu/menuwindow.hpp +++ b/include/libpdraw/gui/tabbedmenu/menuwindow.hpp @@ -27,7 +27,9 @@ class CTitleBar; class CMenuWindow : public CBaseWindow { public: - CMenuWindow(std::string name, IWidget* parent); + CMenuWindow(IWidget* parent, std::string name); + CMenuWindow(std::string name, IWidget* parent) + : CMenuWindow(parent, name) { } void AddElements(); diff --git a/include/libpdraw/gui/widgets/basebutton.hpp b/include/libpdraw/gui/widgets/basebutton.hpp index f0ef9a6..0a61ed2 100644 --- a/include/libpdraw/gui/widgets/basebutton.hpp +++ b/include/libpdraw/gui/widgets/basebutton.hpp @@ -32,9 +32,11 @@ typedef std::function ButtonCallbackFn_t; class CBaseButton : public CTextLabel { public: - CBaseButton(std::string name = "unnamed", IWidget* parent = nullptr, std::string text = "", ButtonCallbackFn_t callback = nullptr); + CBaseButton(IWidget* parent, std::string name = "unnamed", std::string text = "", ButtonCallbackFn_t callback = nullptr); + CBaseButton(std::string name = "unnamed", IWidget* parent = nullptr, std::string text = "", ButtonCallbackFn_t callback = nullptr) + : CBaseButton(parent, name, text, callback) { } - virtual void Draw(int x, int y); + virtual void Draw(int x, int y) override; virtual void OnMousePress() override; void SetCallback(ButtonCallbackFn_t callback); diff --git a/include/libpdraw/gui/widgets/checkbox.hpp b/include/libpdraw/gui/widgets/checkbox.hpp index b5cf100..4a83134 100644 --- a/include/libpdraw/gui/widgets/checkbox.hpp +++ b/include/libpdraw/gui/widgets/checkbox.hpp @@ -27,7 +27,9 @@ typedef std::function CheckboxCallbackFn_t; class CCheckbox : public CBaseWidget { public: - CCheckbox(std::string name = "unnamed", IWidget* parent = nullptr, bool checked = false); + CCheckbox(IWidget* parent, std::string name = "unnamed", bool checked = false); + CCheckbox(std::string name = "unnamed", IWidget* parent = nullptr, bool checked = false) + : CCheckbox(parent, name, checked) { } void SetWidth(int width); inline bool Value() { return this->checked; } diff --git a/include/libpdraw/gui/widgets/dropdown.hpp b/include/libpdraw/gui/widgets/dropdown.hpp index 197f516..05845d4 100644 --- a/include/libpdraw/gui/widgets/dropdown.hpp +++ b/include/libpdraw/gui/widgets/dropdown.hpp @@ -28,7 +28,9 @@ typedef std::function DropdownCallbackFn_t; class CDropdown : public CBaseButton { public: - CDropdown(std::string name = "unnamed", IWidget* parent = nullptr); + CDropdown(IWidget* parent = nullptr, std::string name = "unnamed"); + CDropdown(std::string name = "unnamed", IWidget* parent = nullptr) + : CDropdown(parent, name) { } ~CDropdown(); void AddValue(std::string); diff --git a/include/libpdraw/gui/widgets/keyinput.hpp b/include/libpdraw/gui/widgets/keyinput.hpp index c50fb84..18908f3 100644 --- a/include/libpdraw/gui/widgets/keyinput.hpp +++ b/include/libpdraw/gui/widgets/keyinput.hpp @@ -27,7 +27,9 @@ typedef std::function KeyInputCallbackFn_t; class CKeyInput : public CBaseWidget { public: - CKeyInput(std::string name = "unnamed", IWidget* parent = nullptr); + CKeyInput(IWidget* parent, std::string name = "unnamed"); + CKeyInput(std::string name = "unnamed", IWidget* parent = nullptr) + : CKeyInput(parent, name) { } CatKey Value(); void SetValue(int value); diff --git a/include/libpdraw/gui/widgets/slider.hpp b/include/libpdraw/gui/widgets/slider.hpp index 43edf17..f472763 100644 --- a/include/libpdraw/gui/widgets/slider.hpp +++ b/include/libpdraw/gui/widgets/slider.hpp @@ -27,7 +27,9 @@ typedef std::function SliderCallbackFn_t; class CSlider : public CBaseWidget { public: - CSlider(std::string name = "", IWidget* parent = nullptr); + CSlider(IWidget* parent, std::string name = ""); + CSlider(std::string name = "", IWidget* parent = nullptr) + : CSlider(parent, name) { } void Setup(float min, float max); void SetStep(float step); diff --git a/include/libpdraw/gui/widgets/textinput.hpp b/include/libpdraw/gui/widgets/textinput.hpp index fab772f..a77f660 100644 --- a/include/libpdraw/gui/widgets/textinput.hpp +++ b/include/libpdraw/gui/widgets/textinput.hpp @@ -27,7 +27,9 @@ typedef std::function TextInputCall class CTextInput : public CBaseWidget { public: - CTextInput(std::string name = "unnamed", IWidget* parent = nullptr); + CTextInput(IWidget* parent, std::string name = "unnamed"); + CTextInput(std::string name = "unnamed", IWidget* parent = nullptr) + : CTextInput(parent, name) { } virtual void OnKeyPress(CatKey key, bool repeat); virtual void Draw(int x, int y); diff --git a/include/libpdraw/gui/widgets/textlabel.hpp b/include/libpdraw/gui/widgets/textlabel.hpp index 30acf9d..aa71cf4 100644 --- a/include/libpdraw/gui/widgets/textlabel.hpp +++ b/include/libpdraw/gui/widgets/textlabel.hpp @@ -23,7 +23,9 @@ class CTextLabel : public CBaseWidget { public: - CTextLabel(std::string name, IWidget* parent, std::string text = "", bool centered = false); + CTextLabel(IWidget* parent, std::string name, std::string text = "", bool centered = false); + CTextLabel(std::string name, IWidget* parent, std::string text = "", bool centered = false) + : CTextLabel(parent, name, text, centered) { } CTextLabel(std::string name = "unnamed", bool centered = false); void SetText(std::string text); diff --git a/src/gui/tabbedmenu/menuwindow.cpp b/src/gui/tabbedmenu/menuwindow.cpp index af08eec..147a39b 100644 --- a/src/gui/tabbedmenu/menuwindow.cpp +++ b/src/gui/tabbedmenu/menuwindow.cpp @@ -14,7 +14,7 @@ #include "gui/widgets/titlebar.hpp" -CMenuWindow::CMenuWindow(std::string name, IWidget* parent) +CMenuWindow::CMenuWindow(IWidget* parent, std::string name) : CBaseWindow(parent, name) { m_pList = new CMenuList("list", this); AddChild(m_pList); diff --git a/src/gui/widgets/basebutton.cpp b/src/gui/widgets/basebutton.cpp index b72a90c..e061322 100644 --- a/src/gui/widgets/basebutton.cpp +++ b/src/gui/widgets/basebutton.cpp @@ -23,7 +23,7 @@ #include "gui/canvas.hpp" -CBaseButton::CBaseButton(std::string name, IWidget* parent, std::string text, ButtonCallbackFn_t callback) +CBaseButton::CBaseButton(IWidget* parent, std::string name, std::string text, ButtonCallbackFn_t callback) : CTextLabel(name, parent, text) { SetPadding(BUTTON_PADDING_W, BUTTON_PADDING_H); SetText(text); diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index bd69e0c..0412803 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -23,7 +23,7 @@ #include "gui/widgets/checkbox.hpp" -CCheckbox::CCheckbox(std::string name, IWidget* parent, bool checked) +CCheckbox::CCheckbox(IWidget* parent, std::string name, bool checked) : CBaseWidget(name, parent) { SetWidth(16); SetValue(checked); diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 821cc04..da1f23c 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -23,7 +23,7 @@ #include "gui/widgets/dropdown.hpp" #include "gui/widgets/dropdownlist.hpp" -CDropdown::CDropdown(std::string name, IWidget* parent) +CDropdown::CDropdown(IWidget* parent, std::string name) : CBaseButton(name, parent) { list = new CDropdownList(name + "_list", this); this->GetCanvas()->AddChild(list); diff --git a/src/gui/widgets/keyinput.cpp b/src/gui/widgets/keyinput.cpp index 6eaa3da..01b6049 100644 --- a/src/gui/widgets/keyinput.cpp +++ b/src/gui/widgets/keyinput.cpp @@ -23,7 +23,7 @@ #include "gui/widgets/keyinput.hpp" -CKeyInput::CKeyInput(std::string name, IWidget* parent) +CKeyInput::CKeyInput(IWidget* parent, std::string name) : CBaseWidget(name, parent) { this->value = 0; this->capturing = false; diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index dd24302..56dac64 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -24,7 +24,7 @@ #include "gui/widgets/slider.hpp" -CSlider::CSlider(std::string name, IWidget* parent) +CSlider::CSlider(IWidget* parent, std::string name) : CBaseWidget(name, parent) { Setup(0.0f, 1.0f); SetSize(80, 16); diff --git a/src/gui/widgets/textinput.cpp b/src/gui/widgets/textinput.cpp index a091b16..26dc0ff 100644 --- a/src/gui/widgets/textinput.cpp +++ b/src/gui/widgets/textinput.cpp @@ -23,7 +23,7 @@ #include "gui/widgets/textinput.hpp" -CTextInput::CTextInput(std::string name, IWidget* parent) +CTextInput::CTextInput(IWidget* parent, std::string name) : CBaseWidget(name, parent) { this->value = ""; this->focus = false; diff --git a/src/gui/widgets/textlabel.cpp b/src/gui/widgets/textlabel.cpp index 0a4f1f2..f73b722 100644 --- a/src/gui/widgets/textlabel.cpp +++ b/src/gui/widgets/textlabel.cpp @@ -60,7 +60,7 @@ static std::string WordWrap(std::string& in, int max, glez::font& font) { return result.str(); } -CTextLabel::CTextLabel(std::string name, IWidget* parent, std::string text, bool centered) +CTextLabel::CTextLabel(IWidget* parent, std::string name, std::string text, bool centered) : CBaseWidget(name, parent) { this->max_size.first = 50; this->SetPadding(3, 3);