the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "SlideButton.h"
3
4SlideButton::SlideButton(int id, int x, int y, const Options::Option *option, const wstring& msg, float value) : Button(id, x, y, 150, 20, msg)
5{
6 this->sliding = false; //4J added
7 this->option = option;
8 this->value = value;
9}
10
11int SlideButton::getYImage(bool hovered)
12{
13 return 0;
14}
15
16void SlideButton::renderBg(Minecraft *minecraft, int xm, int ym)
17{
18 if (!visible) return;
19 if (sliding)
20 {
21 value = (xm - (x + 4)) / (float) (w - 8);
22 if (value < 0) value = 0;
23 if (value > 1) value = 1;
24 minecraft->options->set(option, value);
25 msg = minecraft->options->getMessage(option);
26 }
27 glColor4f(1, 1, 1, 1);
28 blit(x + (int) (value * (w - 8)), y, 0, 46 + 1 * 20, 4, 20);
29 blit(x + (int) (value * (w - 8)) + 4, y, 196, 46 + 1 * 20, 4, 20);
30}
31
32bool SlideButton::clicked(Minecraft *minecraft, int mx, int my)
33{
34 if (Button::clicked(minecraft, mx, my))
35 {
36 value = (mx - (x + 4)) / (float) (w - 8);
37 if (value < 0) value = 0;
38 if (value > 1) value = 1;
39 minecraft->options->set(option, value);
40 msg = minecraft->options->getMessage(option);
41 sliding = true;
42 return true;
43 }
44
45 return false;
46}
47
48void SlideButton::released(int mx, int my)
49{
50 sliding = false;
51}