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

Class GuiModuleItems

The 5zig Mod/src/eu/the5zig/mod/gui/GuiModuleItems.java:28–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26import java.util.Locale;
27
28public class GuiModuleItems extends Gui implements Clickable<ActiveModuleItem> {
29
30 private static final int START_INDEX = 500;
31
32 private final Module module;
33
34 private IGuiList<ActiveModuleItem> guiListItems;
35 private int itemIndex;
36 private List<ButtonRow> buttons = Lists.newArrayList();
37 private HashMap<IButton, ConfigItem> buttonMap = Maps.newHashMap();
38
39 private long lastMouseMoved;
40 private int lastMouseX, lastMouseY;
41
42 public GuiModuleItems(Gui lastScreen, Module module) {
43 super(lastScreen);
44 this.module = module;
45 }
46
47 @Override
48 public void initGui() {
49 addBottomDoneButton();
50 guiListItems = The5zigMod.getVars().createGuiList(this, getWidth(), getHeight(), 32, getHeight() - 48 - 22, getWidth() / 2 - 180, getWidth() / 2 - 10, module.getItems());
51 guiListItems.setRowWidth(160);
52 guiListItems.setLeftbound(true);
53 guiListItems.setDrawSelection(true);
54 guiListItems.setScrollX(getWidth() / 2 - 15);
55 guiListItems.setHeaderPadding(The5zigMod.getVars().getFontHeight());
56 guiListItems.setHeader(I18n.translate("modules.settings.item.list.items"));
57
58 IGuiList guiListSettings = The5zigMod.getVars().createGuiList(null, getWidth(), getHeight(), 32, getHeight() - 50 - 90, getWidth() / 2 + 10, getWidth() / 2 + 180, buttons);
59 guiListSettings.setDrawSelection(false);
60 guiListSettings.setLeftbound(true);
61 guiListSettings.setRowWidth(160);
62 guiListSettings.setScrollX(getWidth() / 2 + 175);
63 guiListSettings.setHeaderPadding(The5zigMod.getVars().getFontHeight());
64 guiListSettings.setHeader(I18n.translate("modules.settings.item.list.settings"));
65 addGuiList(guiListSettings);
66 addGuiList(guiListItems);
67
68 guiListItems.setSelectedId(itemIndex);
69 guiListItems.onSelect(guiListItems.getSelectedId(), guiListItems.getSelectedRow(), true);
70
71 addButton(The5zigMod.getVars().createButton(1, getWidth() / 2 - 180, getHeight() - 48 - 20, 145, 20, I18n.translate("modules.settings.item.add")));
72 addButton(The5zigMod.getVars().createButton(2, getWidth() / 2 - 30, getHeight() - 48 - 20, 20, 20, "-"));
73
74 addButton(The5zigMod.getVars().createButton(10, getWidth() / 2 + 10, getHeight() - 48 - 90, 83, 20, I18n.translate("modules.settings.item.color") + ": " +
75 (guiListItems.getSelectedRow() == null || guiListItems.getSelectedRow().getHandle().getProperties().getFormatting() == null ? I18n.translate("modules.settings.default") :
76 I18n.translate("modules.settings.custom"))));
77 addButton(The5zigMod.getVars().createButton(11, getWidth() / 2 + 97, getHeight() - 48 - 90, 83, 20, I18n.translate("modules.settings.item.prefix") + ": " +
78 The5zigMod.toBoolean(guiListItems.getSelectedRow() == null || guiListItems.getSelectedRow().getHandle().getProperties().isShowPrefix())));
79 addButton(The5zigMod.getVars().createButton(12, getWidth() / 2 + 10, getHeight() - 48 - 68, 83, 20, I18n.translate("modules.move_up")));
80 addButton(The5zigMod.getVars().createButton(13, getWidth() / 2 + 97, getHeight() - 48 - 68, 83, 20, I18n.translate("modules.move_down")));
81 }
82
83 @Override
84 protected void actionPerformed(IButton button) {
85 if (button.getId() == 1) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected