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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
package me.Danker.gui.alerts;
import me.Danker.features.Alerts;
import me.Danker.handlers.TextRenderer;
import me.Danker.utils.RenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraftforge.fml.client.config.GuiCheckBox;
import java.io.IOException;
public class AlertAddGui extends GuiScreen {
private boolean editing;
private Alerts.Alert base = null;
private int id;
private GuiButton cancel;
private String mode = "Contains";
private String location = "Skyblock";
private GuiButton startsWith;
private GuiButton contains;
private GuiButton endsWith;
private GuiButton everywhere;
private GuiButton skyblock;
private GuiButton dungeons;
private GuiTextField message;
private GuiTextField alert;
private GuiCheckBox desktop;
private GuiCheckBox toggled;
private GuiButton add;
public AlertAddGui() {}
public AlertAddGui(Alerts.Alert alert, int id) {
editing = true;
base = alert;
this.id = id;
}
@Override
public boolean doesGuiPauseGame() {
return false;
}
@Override
public void initGui() {
super.initGui();
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
int height = sr.getScaledHeight();
int width = sr.getScaledWidth();
cancel = new GuiButton(0, 2, height - 30, 100, 20, "Cancel");
startsWith = new GuiButton(0, width / 2 - 200, (int) (height * 0.2), 120, 20, "Starts With");
contains = new GuiButton(0, width / 2 - 60, (int) (height * 0.2), 120, 20, "Contains");
endsWith = new GuiButton(0, width / 2 + 80, (int) (height * 0.2), 120, 20, "Ends With");
everywhere = new GuiButton(0, width / 2 - 200, (int) (height * 0.3), 120, 20, "Everywhere");
skyblock = new GuiButton(0, width / 2 - 60, (int) (height * 0.3), 120, 20, "Skyblock");
dungeons = new GuiButton(0, width / 2 + 80, (int) (height * 0.3), 120, 20, "Dungeons");
message = new GuiTextField(0, this.fontRendererObj, width / 2 - 100, (int) (height * 0.4), 200, 20);
alert = new GuiTextField(0, this.fontRendererObj, width / 2 - 100, (int) (height * 0.5), 200, 20);
desktop = new GuiCheckBox(0, width / 2 - 58, (int) (height * 0.6), "Desktop Notification", false);
toggled = new GuiCheckBox(0, width / 2 - 26, (int) (height * 0.65), "Toggled", true);
add = new GuiButton(0, width / 2 - 25, (int) (height * 0.8), 50, 20, "Add");
if (editing) {
mode = base.mode;
location = base.location;
message.setText(base.message);
alert.setText(base.alert);
desktop.setIsChecked(base.desktop);
toggled.setIsChecked(base.toggled);
}
message.setVisible(true);
message.setEnabled(true);
alert.setVisible(true);
alert.setEnabled(true);
this.buttonList.add(cancel);
this.buttonList.add(startsWith);
this.buttonList.add(contains);
this.buttonList.add(endsWith);
this.buttonList.add(everywhere);
this.buttonList.add(skyblock);
this.buttonList.add(dungeons);
this.buttonList.add(desktop);
this.buttonList.add(toggled);
this.buttonList.add(add);
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
message.drawTextBox();
alert.drawTextBox();
RenderUtils.drawCenteredText("Mode: " + mode, width, (int) (height * 0.1), 1D);
RenderUtils.drawCenteredText("Location: " + location, width, (int) (height * 0.15), 1D);
new TextRenderer(mc, "Trigger:", width / 2 - 145, (int) (height * 0.42), 1D);
new TextRenderer(mc, "Alert Text:", width / 2 - 158, (int) (height * 0.52), 1D);
}
@Override
public void actionPerformed(GuiButton button) {
if (button == cancel) {
mc.displayGuiScreen(new AlertsGui(1));
} else if (button == startsWith) {
mode = "Starts With";
} else if (button == contains) {
mode = "Contains";
} else if (button == endsWith) {
mode = "Ends With";
} else if (button == everywhere) {
location = "Everywhere";
} else if (button == skyblock) {
location = "Skyblock";
} else if (button == dungeons) {
location = "Dungeons";
} else if (button == add) {
Alerts.Alert newAlert = new Alerts.Alert(mode, location, message.getText(), alert.getText(), desktop.isChecked(), toggled.isChecked());
if (editing) {
Alerts.alerts.set(id, newAlert);
} else {
Alerts.alerts.add(newAlert);
}
Alerts.saveToFile();
mc.displayGuiScreen(new AlertsGui(1));
}
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
message.mouseClicked(mouseX, mouseY, mouseButton);
alert.mouseClicked(mouseX, mouseY, mouseButton);
}
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
message.textboxKeyTyped(typedChar, keyCode);
alert.textboxKeyTyped(typedChar, keyCode);
}
}
|