GuiPanelSettings.java
4.2 KB
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
155
156
157
/*
* This file is part of LiteLoader.
* Copyright (C) 2012-16 Adam Mummery-Smith
* All Rights Reserved.
*/
package com.mumfrey.liteloader.client.gui;
import org.lwjgl.input.Keyboard;
import com.mumfrey.liteloader.core.LiteLoader;
import com.mumfrey.liteloader.interfaces.PanelManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
class GuiPanelSettings extends GuiPanel
{
private GuiLiteLoaderPanel parentScreen;
private GuiCheckbox chkShowTab, chkNoHide, chkForceUpdate;
private boolean hide;
private String[] helpText = new String[5];
GuiPanelSettings(GuiLiteLoaderPanel parentScreen, Minecraft minecraft)
{
super(minecraft);
this.parentScreen = parentScreen;
this.helpText[0] = I18n.format("gui.settings.showtab.help1");
this.helpText[1] = I18n.format("gui.settings.showtab.help2");
this.helpText[2] = I18n.format("gui.settings.notabhide.help1");
this.helpText[3] = I18n.format("gui.settings.forceupdate.help1");
this.helpText[4] = I18n.format("gui.settings.forceupdate.help2");
}
@Override
public void close()
{
this.hide = true;
}
@Override
boolean isCloseRequested()
{
boolean hide = this.hide;
this.hide = false;
return hide;
}
@Override
void setSize(int width, int height)
{
super.setSize(width, height);
this.controls.add(new GuiButton(-1, this.width - 99 - MARGIN, this.height - BOTTOM + 9, 100, 20, I18n.format("gui.done")));
this.controls.add(this.chkShowTab = new GuiCheckbox(0, 34, 90, I18n.format("gui.settings.showtab.label")));
this.controls.add(this.chkNoHide = new GuiCheckbox(1, 34, 128, I18n.format("gui.settings.notabhide.label")));
this.controls.add(this.chkForceUpdate = new GuiCheckbox(2, 34, 158, I18n.format("gui.settings.forceupdate.label")));
this.updateCheckBoxes();
}
private void updateCheckBoxes()
{
PanelManager<?> panelManager = LiteLoader.getModPanelManager();
this.chkShowTab.checked = panelManager.isTabVisible();
this.chkNoHide.checked = panelManager.isTabAlwaysExpanded();
this.chkForceUpdate.checked = panelManager.isForceUpdateEnabled();
}
private void updateSettings()
{
PanelManager<?> panelManager = LiteLoader.getModPanelManager();
panelManager.setTabVisible(this.chkShowTab.checked);
panelManager.setTabAlwaysExpanded(this.chkNoHide.checked);
panelManager.setForceUpdateEnabled(this.chkForceUpdate.checked);
}
@Override
void draw(int mouseX, int mouseY, float partialTicks)
{
this.parentScreen.drawInfoPanel(mouseX, mouseY, partialTicks, 0, 38);
FontRenderer fontRenderer = this.mc.fontRendererObj;
int brandColour = this.parentScreen.getBrandColour();
fontRenderer.drawString(this.helpText[0], 50, 104, brandColour);
fontRenderer.drawString(this.helpText[1], 50, 114, brandColour);
fontRenderer.drawString(this.helpText[2], 50, 142, brandColour);
fontRenderer.drawString(this.helpText[3], 50, 172, brandColour);
fontRenderer.drawString(this.helpText[4], 50, 182, brandColour);
super.draw(mouseX, mouseY, partialTicks);
}
@Override
void actionPerformed(GuiButton control)
{
if (control.id == -1)
{
this.close();
return;
}
if (control instanceof GuiCheckbox)
{
((GuiCheckbox)control).checked = !((GuiCheckbox)control).checked;
this.updateSettings();
}
}
@Override
void keyPressed(char keyChar, int keyCode)
{
if (keyCode == Keyboard.KEY_ESCAPE)
{
this.close();
}
}
@Override
void onTick()
{
}
@Override
void onHidden()
{
}
@Override
void onShown()
{
}
@Override
void mouseMoved(int mouseX, int mouseY)
{
}
@Override
void mouseReleased(int mouseX, int mouseY, int mouseButton)
{
}
@Override
void mouseWheelScrolled(int mouseWheelDelta)
{
}
}