Skip to content

Commit

Permalink
smoother conditional sliders
Browse files Browse the repository at this point in the history
  • Loading branch information
Melvin1663 committed Aug 4, 2024
1 parent 4ca2d4e commit 0017006
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 9 deletions.
5 changes: 0 additions & 5 deletions src/Client/GUI/Engine/Elements/Control/Slider/Slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
#define o_colors_secondary7 clickgui->settings.getSettingByName<float>("o_colors_secondary7")->value
#define colors_secondary7_rgb clickgui->settings.getSettingByName<bool>("colors_secondary7_rgb")->value

//void FlarialGUI::Slider(bool troll, int index, float x, float y, float& startingPoint, const float maxValue, const float minValue, const bool zerosafe) {
//float yes = Slider(index, x, y, (float)startingPoint, maxValue, minValue, zerosafe);
// startingPoint = yes;
//}

float FlarialGUI::Slider(int index, float x, float y, float& startingPoint, const float maxValue, const float minValue, const bool zerosafe) {
D2D1_COLOR_F color = colors_primary1_rgb ? rgbColor : colors_primary1;
D2D1_COLOR_F disabledColor = colors_primary3_rgb ? rgbColor : colors_primary3;
Expand Down
150 changes: 150 additions & 0 deletions src/Client/GUI/Engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
#define o_colors_text clickgui->settings.getSettingByName<float>("o_colors_text")->value
#define colors_text_rgb clickgui->settings.getSettingByName<bool>("colors_text_rgb")->value

#define colors_enabled HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_enabled")->value)
#define o_colors_enabled clickgui->settings.getSettingByName<float>("o_colors_enabled")->value
#define colors_enabled_rgb clickgui->settings.getSettingByName<bool>("colors_enabled_rgb")->value

#define colors_disabled HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_disabled")->value)
#define o_colors_disabled clickgui->settings.getSettingByName<float>("o_colors_disabled")->value
#define colors_disabled_rgb clickgui->settings.getSettingByName<bool>("colors_disabled_rgb")->value

#define colors_primary1 HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_primary1")->value)
#define o_colors_primary1 clickgui->settings.getSettingByName<float>("o_colors_primary1")->value
#define colors_primary1_rgb clickgui->settings.getSettingByName<bool>("colors_primary1_rgb")->value
Expand All @@ -58,10 +66,46 @@
#define o_colors_secondary2 clickgui->settings.getSettingByName<float>("o_colors_secondary2")->value
#define colors_secondary2_rgb clickgui->settings.getSettingByName<bool>("colors_secondary2_rgb")->value

#define colors_secondary3 FlarialGUI::HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_secondary4")->value)
#define o_colors_secondary3 clickgui->settings.getSettingByName<float>("o_colors_secondary3")->value
#define colors_secondary3_rgb clickgui->settings.getSettingByName<bool>("colors_secondary4_rgb")->value

#define colors_secondary4 FlarialGUI::HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_secondary3")->value)
#define o_colors_secondary4 clickgui->settings.getSettingByName<float>("o_colors_secondary4")->value
#define colors_secondary4_rgb clickgui->settings.getSettingByName<bool>("colors_secondary3_rgb")->value

#define colors_secondary5 FlarialGUI::HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_secondary5")->value)
#define o_colors_secondary5 clickgui->settings.getSettingByName<float>("o_colors_secondary5")->value
#define colors_secondary5_rgb clickgui->settings.getSettingByName<bool>("colors_secondary5_rgb")->value

#define colors_secondary6 FlarialGUI::HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_secondary6")->value)
#define o_colors_secondary6 clickgui->settings.getSettingByName<float>("o_colors_secondary6")->value
#define colors_secondary6_rgb clickgui->settings.getSettingByName<bool>("colors_secondary6_rgb")->value

#define colors_secondary7 FlarialGUI::HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_secondary7")->value)
#define o_colors_secondary7 clickgui->settings.getSettingByName<float>("o_colors_secondary7")->value
#define colors_secondary7_rgb clickgui->settings.getSettingByName<bool>("colors_secondary7_rgb")->value

#define colors_secondary8 FlarialGUI::HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_secondary8")->value)
#define o_colors_secondary8 clickgui->settings.getSettingByName<float>("o_colors_secondary8")->value
#define colors_secondary8_rgb clickgui->settings.getSettingByName<bool>("colors_secondary8_rgb")->value

#define colors_mod1 FlarialGUI::HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_mod1")->value)
#define o_colors_mod1 clickgui->settings.getSettingByName<float>("o_colors_mod1")->value
#define colors_mod1_rgb clickgui->settings.getSettingByName<bool>("colors_mod1_rgb")->value

#define colors_mod2 FlarialGUI::HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_mod2")->value)
#define o_colors_mod2 clickgui->settings.getSettingByName<float>("o_colors_mod2")->value
#define colors_mod2_rgb clickgui->settings.getSettingByName<bool>("colors_mod2_rgb")->value

#define colors_mod3 FlarialGUI::HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_mod3")->value)
#define o_colors_mod3 clickgui->settings.getSettingByName<float>("o_colors_mod3")->value
#define colors_mod3_rgb clickgui->settings.getSettingByName<bool>("colors_mod3_rgb")->value

#define colors_mod4 FlarialGUI::HexToColorF(clickgui->settings.getSettingByName<std::string>("colors_mod4")->value)
#define o_colors_mod4 clickgui->settings.getSettingByName<float>("o_colors_mod4")->value
#define colors_mod4_rgb clickgui->settings.getSettingByName<bool>("colors_mod4_rgb")->value

std::map<std::string, ID2D1Bitmap *> ImagesClass::eimages;
std::map<int, ID2D1Bitmap *> ImagesClass::images;

Expand All @@ -86,6 +130,112 @@ 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;
float b_o_colors_primary1;
float b_o_colors_primary2;
float b_o_colors_primary3;
float b_o_colors_primary4;
float b_o_colors_secondary1;
float b_o_colors_secondary2;
float b_o_colors_secondary3;
float b_o_colors_secondary4;
float b_o_colors_secondary5;
float b_o_colors_secondary6;
float b_o_colors_secondary7;
float b_o_colors_secondary8;
float b_o_colors_mod1;
float b_o_colors_mod2;
float b_o_colors_mod3;
float b_o_colors_mod4;

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

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

void FlarialGUI::ResetOverrideAlphaValues() {
o_colors_text = b_o_colors_text;
o_colors_enabled = b_o_colors_enabled;
o_colors_disabled = b_o_colors_disabled;
o_colors_primary1 = b_o_colors_primary1;
o_colors_primary2 = b_o_colors_primary2;
o_colors_primary3 = b_o_colors_primary3;
o_colors_primary4 = b_o_colors_primary4;
o_colors_secondary1 = b_o_colors_secondary1;
o_colors_secondary2 = b_o_colors_secondary2;
o_colors_secondary3 = b_o_colors_secondary3;
o_colors_secondary4 = b_o_colors_secondary4;
o_colors_secondary5 = b_o_colors_secondary5;
o_colors_secondary6 = b_o_colors_secondary6;
o_colors_secondary7 = b_o_colors_secondary7;
o_colors_secondary8 = b_o_colors_secondary8;
o_colors_mod1 = b_o_colors_mod1;
o_colors_mod2 = b_o_colors_mod2;
o_colors_mod3 = b_o_colors_mod3;
o_colors_mod4 = b_o_colors_mod4;
}

UINT32 ColorValueToUInt(const D3DCOLORVALUE &color) {
auto r = static_cast<uint8_t>(color.r * 255.0f);
auto g = static_cast<uint8_t>(color.g * 255.0f);
Expand Down
4 changes: 4 additions & 0 deletions src/Client/GUI/Engine/Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,8 @@ namespace FlarialGUI {
const float imageHeight);

ImColor D2DColorToImColor(D2D1_COLOR_F color);

void OverrideAlphaValues(float percent);

void ResetOverrideAlphaValues();
}
2 changes: 1 addition & 1 deletion src/Client/Module/Modules/ClickGUI/ClickGUIRenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class ClickGUIRenderer : public Listener {

}

Blur::RenderBlur(event.RTV, 3, realBlurAmount/4);
//Blur::RenderBlur(event.RTV, 3, realBlurAmount/4);

float baseHeight = Constraints::RelativeConstraint(baseHeightReal);

Expand Down
2 changes: 1 addition & 1 deletion src/Client/Module/Modules/ComboCounter/ComboCounter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ComboCounter : public Module {
this->addToggle("Border", "im just trolling", 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->extraPadding();
Expand Down
8 changes: 6 additions & 2 deletions src/Client/Module/Modules/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ void Module::addHeader(std::string text) {
}

void Module::addConditionalSlider(bool condition, std::string text, std::string subtext, float& startingPoint, 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);
Expand All @@ -227,10 +230,11 @@ void Module::addConditionalSlider(bool condition, std::string text, std::string
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];
if (conditionalSliderAnims[sliderIndex] < Constraints::RelativeConstraint(0.045f, "height", true)) Module::addSlider(text, subtext, startingPoint, maxVal, minVal, zerosafe);
else padding += Constraints::RelativeConstraint(0.05f, "height", true);
Module::addSlider(text, subtext, startingPoint, maxVal, minVal, zerosafe);
}
}

FlarialGUI::ResetOverrideAlphaValues();
}

void Module::addElementText(std::string text, std::string subtext) {
Expand Down

0 comments on commit 0017006

Please sign in to comment.