|
1 | 1 | package top.hendrixshen.magiclib.impl.malilib.config.gui.widget;
|
2 | 2 |
|
3 | 3 | import fi.dy.masa.malilib.gui.GuiTextFieldGeneric;
|
4 |
| -import fi.dy.masa.malilib.gui.MaLiLibIcons; |
5 | 4 | import fi.dy.masa.malilib.gui.button.ButtonBase;
|
6 | 5 | import fi.dy.masa.malilib.gui.button.ButtonGeneric;
|
7 | 6 | import fi.dy.masa.malilib.gui.button.IButtonActionListener;
|
8 | 7 | import fi.dy.masa.malilib.gui.widgets.WidgetConfigOptionBase;
|
9 | 8 | import fi.dy.masa.malilib.render.RenderUtils;
|
10 | 9 | import lombok.AllArgsConstructor;
|
11 |
| -import lombok.Getter; |
12 | 10 | import net.minecraft.core.Vec3i;
|
13 |
| -import top.hendrixshen.magiclib.api.i18n.I18n; |
14 | 11 | import top.hendrixshen.magiclib.api.malilib.config.option.ConfigVec3iList;
|
| 12 | +import top.hendrixshen.magiclib.impl.malilib.config.gui.button.ListEditEntryButtonType; |
15 | 13 |
|
16 | 14 | import java.util.Collections;
|
17 | 15 | import java.util.List;
|
@@ -49,31 +47,31 @@ public WidgetVec3iListEditEntry(int x, int y, int width, int height, int listInd
|
49 | 47 | this.vec3iEntry = new WidgetVec3iEntry(x, y, vec3iWidth, height, initialValue, defaultValue);
|
50 | 48 | this.vec3iEntry.getTextFields().forEach(this.parent::addTextField);
|
51 | 49 | x += vec3iWidth + 2;
|
52 |
| - this.addListActionButton(x, iy, ButtonType.ADD); |
| 50 | + this.addListActionButton(x, iy, ListEditEntryButtonType.ADD); |
53 | 51 | x += 18;
|
54 |
| - this.addListActionButton(x, iy, ButtonType.REMOVE); |
| 52 | + this.addListActionButton(x, iy, ListEditEntryButtonType.REMOVE); |
55 | 53 | x += 18;
|
56 | 54 |
|
57 | 55 | if (this.canBeMoved(true)) {
|
58 |
| - this.addListActionButton(x, iy, ButtonType.MOVE_DOWN); |
| 56 | + this.addListActionButton(x, iy, ListEditEntryButtonType.MOVE_DOWN); |
59 | 57 | }
|
60 | 58 |
|
61 | 59 | x += 18;
|
62 | 60 |
|
63 | 61 | if (this.canBeMoved(false)) {
|
64 |
| - this.addListActionButton(x, iy, ButtonType.MOVE_UP); |
| 62 | + this.addListActionButton(x, iy, ListEditEntryButtonType.MOVE_UP); |
65 | 63 | }
|
66 | 64 | } else {
|
67 | 65 | this.vec3iEntry = null;
|
68 |
| - this.addListActionButton(x, y + 3, ButtonType.ADD); |
| 66 | + this.addListActionButton(x, y + 3, ListEditEntryButtonType.ADD); |
69 | 67 | }
|
70 | 68 | }
|
71 | 69 |
|
72 | 70 | protected boolean isDummy() {
|
73 | 71 | return this.listIndex < 0;
|
74 | 72 | }
|
75 | 73 |
|
76 |
| - protected void addListActionButton(int x, int y, ButtonType type) { |
| 74 | + protected void addListActionButton(int x, int y, ListEditEntryButtonType type) { |
77 | 75 | ButtonGeneric button = new ButtonGeneric(x, y, type.getIcon(), type.getDisplayName());
|
78 | 76 | ListenerListActions listener = new ListenerListActions(type, this);
|
79 | 77 | this.addButton(button, listener);
|
@@ -237,34 +235,18 @@ protected boolean onCharTypedImpl(char charIn, int modifiers) {
|
237 | 235 | return this.vec3iEntry.onCharTypedImpl(charIn, modifiers);
|
238 | 236 | }
|
239 | 237 |
|
240 |
| - @AllArgsConstructor |
241 |
| - private enum ButtonType { |
242 |
| - ADD(MaLiLibIcons.PLUS, "malilib.gui.button.hovertext.add"), |
243 |
| - REMOVE(MaLiLibIcons.MINUS, "malilib.gui.button.hovertext.remove"), |
244 |
| - MOVE_UP(MaLiLibIcons.ARROW_UP, "malilib.gui.button.hovertext.move_up"), |
245 |
| - MOVE_DOWN(MaLiLibIcons.ARROW_DOWN, "malilib.gui.button.hovertext.move_down"); |
246 |
| - |
247 |
| - @Getter |
248 |
| - private final MaLiLibIcons icon; |
249 |
| - private final String hoverTextTrKey; |
250 |
| - |
251 |
| - public String getDisplayName() { |
252 |
| - return I18n.tr(this.hoverTextTrKey); |
253 |
| - } |
254 |
| - } |
255 |
| - |
256 | 238 | @AllArgsConstructor
|
257 | 239 | private static class ListenerListActions implements IButtonActionListener {
|
258 |
| - private final WidgetVec3iListEditEntry.ButtonType type; |
| 240 | + private final ListEditEntryButtonType type; |
259 | 241 | private final WidgetVec3iListEditEntry parent;
|
260 | 242 |
|
261 | 243 | public void actionPerformedWithButton(ButtonBase button, int mouseButton) {
|
262 |
| - if (this.type == WidgetVec3iListEditEntry.ButtonType.ADD) { |
| 244 | + if (this.type == ListEditEntryButtonType.ADD) { |
263 | 245 | this.parent.insertEntryBefore();
|
264 |
| - } else if (this.type == WidgetVec3iListEditEntry.ButtonType.REMOVE) { |
| 246 | + } else if (this.type == ListEditEntryButtonType.REMOVE) { |
265 | 247 | this.parent.removeEntry();
|
266 | 248 | } else {
|
267 |
| - this.parent.moveEntry(this.type == WidgetVec3iListEditEntry.ButtonType.MOVE_DOWN); |
| 249 | + this.parent.moveEntry(this.type == ListEditEntryButtonType.MOVE_DOWN); |
268 | 250 | }
|
269 | 251 | }
|
270 | 252 | }
|
|
0 commit comments