From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.Client/SlideButton.cpp | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Minecraft.Client/SlideButton.cpp (limited to 'Minecraft.Client/SlideButton.cpp') 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 -- cgit v1.2.3