MCPcopy Create free account
hub / github.com/5zig/The-5zig-Mod / GuiSettings

Class GuiSettings

The 5zig Mod/src/eu/the5zig/mod/gui/GuiSettings.java:21–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19import java.util.Map;
20
21public class GuiSettings extends Gui {
22
23 private final String category;
24
25 private IGuiList buttonList;
26 private List<ButtonRow> buttons = Lists.newArrayList();
27 private HashMap<IButton, ConfigItem> configItems = Maps.newHashMap();
28
29 private long lastMouseMoved;
30 private int lastMouseX, lastMouseY;
31
32 public GuiSettings(Gui lastScreen, String category) {
33 super(lastScreen);
34 this.category = category;
35 }
36
37 @Override
38 public void initGui() {
39 addButton(The5zigMod.getVars().createButton(200, getWidth() / 2 - 100, getHeight() - 27, The5zigMod.getVars().translate("gui.done")));
40
41 buttonList = The5zigMod.getVars().createGuiList(null, getWidth(), getHeight(), 32, getHeight() - 32, 0, getWidth(), buttons);
42 buttonList.setDrawSelection(false);
43 buttonList.setRowWidth(310);
44 buttonList.setBottomPadding(2);
45 buttonList.setScrollX(getWidth() / 2 + 160);
46 addGuiList(buttonList);
47
48 buttons.clear();
49 configItems.clear();
50 List<ConfigItem> items = The5zigMod.getConfig().getItems(category);
51 for (int i = 0, itemsSize = items.size(); i < itemsSize; i++) {
52 IButton button1 = getButton(items.get(i), i);
53 if (button1 != null) {
54 button1.setEnabled(!items.get(i).isRestricted());
55 configItems.put(button1, items.get(i));
56 }
57 i++;
58 IButton button2 = i >= itemsSize ? null : getButton(items.get(i), i);
59 if (button2 != null) {
60 button2.setEnabled(!items.get(i).isRestricted());
61 configItems.put(button2, items.get(i));
62 }
63
64 buttons.add(new ButtonRow(button1, button2));
65 }
66
67 if ("main".equals(category)) {
68 addButton(The5zigMod.getVars().createButton(0xacdc, 2, 6, 80, 20,
69 I18n.translate("config.main.plugins", The5zigMod.getAPI().getPluginManager().getPlugins().size())));
70 addButton(The5zigMod.getVars().createButton(999, getWidth() - 52, 6, 50, 20, I18n.translate("config.main.credits")));
71 addButton(The5zigMod.getVars().createButton(0xcafe, getWidth() - 104, 6, 50, 20, I18n.translate("gui.search")));
72 }
73 }
74
75 private IButton getButton(ConfigItem item, int id) {
76 return getButton(item, id, getWidth());
77 }
78

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected