Skip to content

Commit

Permalink
textbox!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Melvin1663 committed Aug 4, 2024
1 parent 0017006 commit 8a55962
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 48 deletions.
13 changes: 3 additions & 10 deletions src/Client/GUI/Engine/Elements/Control/TextBox/TextBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ std::string FlarialGUI::TextBoxVisual(int index, std::string &text, int limit, f
}

if (FlarialGUI::TextBoxes[index].isActive) {
if (FlarialGUI::TextBoxes[index].isAt1)
FlarialGUI::lerp(FlarialGUI::TextBoxes[index].cursorOpac, -1.0f, 0.05f * FlarialGUI::frameFactor);
if (FlarialGUI::TextBoxes[index].isAt1) FlarialGUI::lerp(FlarialGUI::TextBoxes[index].cursorOpac, -1.0f, 0.05f * FlarialGUI::frameFactor);
else FlarialGUI::lerp(FlarialGUI::TextBoxes[index].cursorOpac, 2.0f, 0.05f * FlarialGUI::frameFactor);
} else FlarialGUI::TextBoxes[index].cursorOpac = 0;

Expand All @@ -65,6 +64,8 @@ std::string FlarialGUI::TextBoxVisual(int index, std::string &text, int limit, f
const float textWidth = Constraints::RelativeConstraint(0.12, "height", true);
const float percHeight = Constraints::RelativeConstraint(0.035, "height", true);

y -= percHeight / 2.0f;

if (isAdditionalY) UnSetIsInAdditionalYMode();

text = FlarialGUI::TextBox(index, text, limit, x, y, Constraints::SpacingConstraint(1.55, textWidth), percHeight);
Expand All @@ -85,14 +86,6 @@ std::string FlarialGUI::TextBoxVisual(int index, std::string &text, int limit, f
Constraints::SpacingConstraint(1.55, textWidth), percHeight,
DWRITE_TEXT_ALIGNMENT_LEADING, textSize, DWRITE_FONT_WEIGHT_NORMAL);



//IDWriteTextFormat* textFormat;
//FlarialGUI::writeFactory->CreateTextFormat(LClient::settings.getSettingByName<std::string>("fontname")->value, NULL, DWRITE_FONT_WEIGHT_REGULAR, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, Constraints::FontScaler(textSize), L"", &textFormat);

// textFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR); !!!
//textLayout->Release();

D2D1_COLOR_F cursorCol = colors_primary2_rgb ? rgbColor : colors_primary2;
cursorCol.a = o_colors_primary2;

Expand Down
22 changes: 0 additions & 22 deletions src/Client/GUI/Engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,28 +130,6 @@ std::unordered_map<int, float> FlarialGUI::additionalY;
//std::unordered_map<std::string, winrt::com_ptr<ID2D1GradientStopCollection>> FlarialGUI::gradientStopCache;
LRUCache<uint64_t, winrt::com_ptr<ID2D1LinearGradientBrush>> FlarialGUI::gradientBrushCache(300);

/*
float b_o_colors_text = o_colors_text;
float b_o_colors_enabled = o_colors_enabled;
float b_o_colors_disabled = o_colors_disabled;
float b_o_colors_primary1 = o_colors_primary1;
float b_o_colors_primary2 = o_colors_primary2;
float b_o_colors_primary3 = o_colors_primary3;
float b_o_colors_primary4 = o_colors_primary4;
float b_o_colors_secondary1 = o_colors_secondary1;
float b_o_colors_secondary2 = o_colors_secondary2;
float b_o_colors_secondary3 = o_colors_secondary3;
float b_o_colors_secondary4 = o_colors_secondary4;
float b_o_colors_secondary5 = o_colors_secondary5;
float b_o_colors_secondary6 = o_colors_secondary6;
float b_o_colors_secondary7 = o_colors_secondary7;
float b_o_colors_secondary8 = o_colors_secondary8;
float b_o_colors_mod1 = o_colors_mod1;
float b_o_colors_mod2 = o_colors_mod2;
float b_o_colors_mod3 = o_colors_mod3;
float b_o_colors_mod4 = o_colors_mod4;
*/

float b_o_colors_text;
float b_o_colors_enabled;
float b_o_colors_disabled;
Expand Down
3 changes: 1 addition & 2 deletions src/Client/GUI/Engine/Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ namespace FlarialGUI {

void NotifyHeartbeat();

std::string
TextBoxVisual(int index, std::string &text, int limit, float x, float y, const std::string &real = "Text Format");
std::string TextBoxVisual(int index, std::string& text, int limit, float x, float y, const std::string& real = "");

winrt::com_ptr<ID2D1SolidColorBrush> getBrush(D2D1_COLOR_F color);

Expand Down
11 changes: 5 additions & 6 deletions src/Client/Module/Modules/ComboCounter/ComboCounter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ class ComboCounter : public Module {
Constraints::RelativeConstraint(1.0f, "height"));

this->addHeader("Module UI");

this->addSlider("UI Scale", "", this->settings.getSettingByName<float>("uiscale")->value, 2.0f);

this->addToggle("Border", "im just trolling", settings.getSettingByName<bool>("border")->value);

this->addToggle("Border", "", settings.getSettingByName<bool>("border")->value);
this->addConditionalSlider(settings.getSettingByName<bool>("border")->value, "Border Width", "", settings.getSettingByName<float>("borderWidth")->value, 4.0f);

this->addToggle("NO MORE TROLLING.....", "", settings.getSettingByName<bool>("reversepaddingx")->value);
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();

Expand Down
24 changes: 18 additions & 6 deletions src/Client/Module/Modules/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,33 @@ void Module::addHeader(std::string text) {
padding += Constraints::RelativeConstraint(0.055f, "height", true);
}

void Module::addConditionalSlider(bool condition, std::string text, std::string subtext, float& startingPoint, float maxVal, float minVal, bool zerosafe) {
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);

Module::addElementText(text, subtext);

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

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));

if (condition) {
padding -= conditionalSliderAnims[sliderIndex];
FlarialGUI::lerp(conditionalSliderAnims[sliderIndex], 0.0f, 0.25f * FlarialGUI::frameFactor);
Module::addSlider(text, subtext, startingPoint, maxVal, minVal, zerosafe);
Module::addSlider(text, subtext, value, maxVal, minVal, zerosafe);
}
else {
FlarialGUI::lerp(conditionalSliderAnims[sliderIndex], Constraints::RelativeConstraint(0.05f, "height", true), 0.25f * FlarialGUI::frameFactor);
if (conditionalSliderAnims[sliderIndex] < Constraints::RelativeConstraint(0.0499f, "height", true)) {
padding -= conditionalSliderAnims[sliderIndex];
Module::addSlider(text, subtext, startingPoint, maxVal, minVal, zerosafe);
Module::addSlider(text, subtext, value, maxVal, minVal, zerosafe);
}
}

Expand Down Expand Up @@ -258,12 +271,11 @@ void Module::addElementText(std::string text, std::string subtext) {
if (!subtext.empty()) FlarialGUI::FlarialTextWithFont(x, subtextY, FlarialGUI::to_wide(subtext).c_str(), 200, 0, DWRITE_TEXT_ALIGNMENT_LEADING, fontSize2, DWRITE_FONT_WEIGHT_MEDIUM, FlarialGUI::HexToColorF("473b3d"), false);
}

void Module::addSlider(std::string text, std::string subtext, float& startingPoint, float maxVal, float minVal, bool zerosafe) {
float x = Constraints::PercentageConstraint(0.019, "left");
void Module::addSlider(std::string text, std::string subtext, float& value, float maxVal, float minVal, bool zerosafe) {
float elementX = Constraints::PercentageConstraint(0.33f, "right");
float y = Constraints::PercentageConstraint(0.10, "top") + padding;

FlarialGUI::Slider(sliderIndex, elementX, y, startingPoint, maxVal, minVal, zerosafe);
FlarialGUI::Slider(sliderIndex, elementX, y, value, maxVal, minVal, zerosafe);

Module::addElementText(text, subtext);

Expand Down
5 changes: 3 additions & 2 deletions src/Client/Module/Modules/Module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ class Module {
void extraPadding();
void addElementText(std::string text, std::string subtext = "");
void addHeader(std::string text);
void addConditionalSlider(bool condition, std::string text, std::string subtext, float& startingPoint, float maxVal = 100.0f, float minVal = 0.0f, bool zerosafe = true);
void addSlider(std::string text, std::string subtext, float& startingPoint, float maxVal = 100.0f, float minVal = 0.0f, bool zerosafe = true);
void addConditionalSlider(bool condition, std::string text, std::string subtext, float& value, float maxVal = 100.0f, float minVal = 0.0f, bool zerosafe = true);
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);
virtual void loadDefaults();
void saveSettings() const;
void loadSettings();
Expand Down

0 comments on commit 8a55962

Please sign in to comment.