diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.Client/SlideButton.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.Client/SlideButton.cpp')
| -rw-r--r-- | Minecraft.Client/SlideButton.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Minecraft.Client/SlideButton.cpp b/Minecraft.Client/SlideButton.cpp new file mode 100644 index 00000000..0da24515 --- /dev/null +++ b/Minecraft.Client/SlideButton.cpp @@ -0,0 +1,51 @@ +#include "stdafx.h" +#include "SlideButton.h" + +SlideButton::SlideButton(int id, int x, int y, const Options::Option *option, const wstring& msg, float value) : Button(id, x, y, 150, 20, msg) +{ + this->sliding = false; //4J added + this->option = option; + this->value = value; +} + +int SlideButton::getYImage(bool hovered) +{ + return 0; +} + +void SlideButton::renderBg(Minecraft *minecraft, int xm, int ym) +{ + if (!visible) return; + if (sliding) + { + value = (xm - (x + 4)) / (float) (w - 8); + if (value < 0) value = 0; + if (value > 1) value = 1; + minecraft->options->set(option, value); + msg = minecraft->options->getMessage(option); + } + glColor4f(1, 1, 1, 1); + blit(x + (int) (value * (w - 8)), y, 0, 46 + 1 * 20, 4, 20); + blit(x + (int) (value * (w - 8)) + 4, y, 196, 46 + 1 * 20, 4, 20); +} + +bool SlideButton::clicked(Minecraft *minecraft, int mx, int my) +{ + if (Button::clicked(minecraft, mx, my)) + { + value = (mx - (x + 4)) / (float) (w - 8); + if (value < 0) value = 0; + if (value > 1) value = 1; + minecraft->options->set(option, value); + msg = minecraft->options->getMessage(option); + sliding = true; + return true; + } + + return false; +} + +void SlideButton::released(int mx, int my) +{ + sliding = false; +}
\ No newline at end of file |
