1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
package me.Danker.gui.alerts;
import me.Danker.commands.ToggleCommand;
import me.Danker.features.Alerts;
import me.Danker.gui.DankerGui;
import me.Danker.gui.buttons.FeatureButton;
import me.Danker.handlers.ConfigHandler;
import me.Danker.handlers.TextRenderer;
import me.Danker.utils.Utils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import java.util.ArrayList;
import java.util.List;
public class AlertsGui extends GuiScreen {
private final int page;
private final List<GuiButton> allButtons = new ArrayList<>();
private GuiButton goBack;
private GuiButton backPage;
private GuiButton nextPage;
private GuiButton add;
private GuiButton alerts;
public AlertsGui(int page) {
this.page = page;
}
@Override
public void initGui() {
super.initGui();
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
int height = sr.getScaledHeight();
int width = sr.getScaledWidth();
goBack = new GuiButton(0, 2, height - 30, 100, 20, "Go Back");
backPage = new GuiButton(0, width / 2 - 100, (int) (height * 0.8), 80, 20, "< Back");
nextPage = new GuiButton(0, width / 2 + 20, (int) (height * 0.8), 80, 20, "Next >");
alerts = new FeatureButton("Alerts: " + Utils.getColouredBoolean(ToggleCommand.alerts), "Sends custom alert when a message is recieved");
add = new GuiButton(0, 0, 0, "Add Alert");
allButtons.clear();
allButtons.add(alerts);
allButtons.add(add);
for (int i = 0; i < Alerts.alerts.size(); i++) {
Alerts.Alert alert = Alerts.alerts.get(i);
GuiButton button = new GuiButton(i, 0, 0, alert.alert + " >");
allButtons.add(button);
}
reInit();
}
public void reInit() {
this.buttonList.clear();
for (int i = (page - 1) * 7, iteration = 0; iteration < 7 && i < allButtons.size(); i++, iteration++) {
GuiButton button = allButtons.get(i);
button.xPosition = width / 2 - 100;
button.yPosition = (int) (height * (0.1 * (iteration + 1)));
this.buttonList.add(button);
}
if (page > 1) this.buttonList.add(backPage);
if (page < Math.ceil(allButtons.size() / 7D)) this.buttonList.add(nextPage);
this.buttonList.add(goBack);
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
String pageText = "Page: " + page + "/" + (int) Math.ceil(allButtons.size() / 7D);
int pageWidth = mc.fontRendererObj.getStringWidth(pageText);
new TextRenderer(mc, pageText, width / 2 - pageWidth / 2, 10, 1D);
}
@Override
public void actionPerformed(GuiButton button) {
if (button == goBack) {
mc.displayGuiScreen(new DankerGui(1, ""));
} else if (button == nextPage) {
mc.displayGuiScreen(new AlertsGui(page + 1));
} else if (button == backPage) {
mc.displayGuiScreen(new AlertsGui(page - 1));
} else if (button == add) {
mc.displayGuiScreen(new AlertAddGui());
} else if (button == alerts) {
ToggleCommand.alerts = !ToggleCommand.alerts;
ConfigHandler.writeBooleanConfig("toggles", "Alerts", ToggleCommand.alerts);
alerts.displayString = "Alerts: " + Utils.getColouredBoolean(ToggleCommand.alerts);
} else {
mc.displayGuiScreen(new AlertActionGui(button.id));
}
}
}
|