Skip to content

Commit

Permalink
dropdowns idk
Browse files Browse the repository at this point in the history
  • Loading branch information
Melvin1663 committed Aug 4, 2024
1 parent 8a55962 commit f1915c1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/Client/GUI/Engine/Elements/Control/Dropdown/Dropdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ std::string FlarialGUI::Dropdown(int index, float x, float y, const std::vector<
const bool isAdditionalY = shouldAdditionalY;
const float textWidth = Constraints::RelativeConstraint(0.12, "height", true);
const float percHeight = Constraints::RelativeConstraint(0.035, "height", true);

y -= percHeight / 2.0f;

float childHeights = Constraints::RelativeConstraint(0.030, "height", true);
float maxHeight = ((float)options.size() - 1.0f) * childHeights + 2.0f;
float addYVal = maxHeight + Constraints::SpacingConstraint(0.05, textWidth);
Expand Down
8 changes: 3 additions & 5 deletions src/Client/GUI/Engine/Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ namespace FlarialGUI {

void LoadImageFromFile(const wchar_t *filename, ID2D1Bitmap **bitmap);

void FlarialText(float x, float y, const wchar_t *text, float width, float height,
DWRITE_TEXT_ALIGNMENT alignment);
void FlarialText(float x, float y, const wchar_t *text, float width, float height,DWRITE_TEXT_ALIGNMENT alignment);

void SetScrollView(float x, float y, float width, float height);

Expand Down Expand Up @@ -223,7 +222,7 @@ namespace FlarialGUI {

bool Toggle(int index, float x, float y, bool isEnabled, bool rgb);

float Slider(int index, float x, float y, float& startingPoint, float maxValue = 100.0f, float minValue = 0.0f, bool zerosafe = true);
float Slider(int index, float x, float y, float& value, float maxValue = 100.0f, float minValue = 0.0f, bool zerosafe = true);

void Circle(float x, float y, const D2D1_COLOR_F &color, float radius);

Expand All @@ -241,8 +240,7 @@ namespace FlarialGUI {

std::string ColorFToHex(const D2D1_COLOR_F &color);

void
RoundedHollowRect(float x, float y, float borderWidth, D2D_COLOR_F color, float width,
void RoundedHollowRect(float x, float y, float borderWidth, D2D_COLOR_F color, float width,
float height, float radiusX,
float radiusY);

Expand Down
6 changes: 3 additions & 3 deletions src/Client/Module/Modules/ComboCounter/ComboCounter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ class ComboCounter : public Module {
this->addConditionalSlider(settings.getSettingByName<bool>("border")->value, "Border Width", "", settings.getSettingByName<float>("borderWidth")->value, 4.0f);
this->addSlider("Rounding", "", this->settings.getSettingByName<float>("rounding")->value);
this->addToggle("Translucency", "", this->settings.getSettingByName<bool>("BlurEffect")->value);
this->addTextBox("Text Format", "", settings.getSettingByName<std::string>("text")->value);


this->extraPadding();

this->addHeader("Text");
this->addTextBox("Text Format", "", settings.getSettingByName<std::string>("text")->value);
this->addSlider("Text Scale", "", this->settings.getSettingByName<float>("textscale")->value, 2.00f);
this->addDropdown("Text Alignment", "", std::vector<std::string>{"Left", "Center", "Right"}, this->settings.getSettingByName<std::string>("textalignment")->value);

this->resetPadding();

Expand Down
15 changes: 13 additions & 2 deletions src/Client/Module/Modules/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,29 @@ void Module::addHeader(std::string text) {
}

void Module::addTextBox(std::string text, std::string subtext, std::string& value) {
float x = Constraints::PercentageConstraint(0.019, "left");
float elementX = Constraints::PercentageConstraint(0.285f, "right");
float y = Constraints::PercentageConstraint(0.10, "top") + padding;

FlarialGUI::TextBoxVisual(textboxIndex, settings.getSettingByName<std::string>("text")->value, 16, elementX , y);
FlarialGUI::TextBoxVisual(textboxIndex, value, 16, elementX , y);

Module::addElementText(text, subtext);

padding += Constraints::RelativeConstraint(0.05f, "height", true);
textboxIndex++;
}

void Module::addDropdown(std::string text, std::string subtext, const std::vector<std::string>& options, std::string& value) {
float elementX = Constraints::PercentageConstraint(0.285f, "right");
float y = Constraints::PercentageConstraint(0.10, "top") + padding;

FlarialGUI::Dropdown(dropdownIndex, elementX, y, options, value, "");

Module::addElementText(text, subtext);

padding += Constraints::RelativeConstraint(0.05f, "height", true);
dropdownIndex++;
}

void Module::addConditionalSlider(bool condition, std::string text, std::string subtext, float& value, float maxVal, float minVal, bool zerosafe) {

FlarialGUI::OverrideAlphaValues((Constraints::RelativeConstraint(0.05f, "height", true) - conditionalSliderAnims[sliderIndex]) / Constraints::RelativeConstraint(0.05f, "height", true));
Expand Down
1 change: 1 addition & 0 deletions src/Client/Module/Modules/Module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Module {
void addSlider(std::string text, std::string subtext, float& value, float maxVal = 100.0f, float minVal = 0.0f, bool zerosafe = true);
void addToggle(std::string text, std::string subtext, bool& value);
void addTextBox(std::string text, std::string subtext, std::string& value);
void addDropdown(std::string text, std::string subtext, const std::vector<std::string>& options, std::string& value);
virtual void loadDefaults();
void saveSettings() const;
void loadSettings();
Expand Down

0 comments on commit f1915c1

Please sign in to comment.