Skip to content

Commit 35e9c64

Browse files
committed
make popup panel class public
make fields not final and set in builder methods
1 parent 5c5567d commit 35e9c64

File tree

1 file changed

+46
-32
lines changed

1 file changed

+46
-32
lines changed

src/main/java/gregtech/api/mui/GTGuis.java

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -72,47 +72,37 @@ public static ModularPanel defaultPanel(MetaItem<?>.MetaValueItem valueItem) {
7272
return createPanel(valueItem.unlocalizedName);
7373
}
7474

75-
public static ModularPanel createPopupPanel(String name, int width, int height) {
76-
return new PopupPanel(name, width, height);
75+
public static PopupPanel createPopupPanel(String name, int width, int height) {
76+
return defaultPopupPanel(name)
77+
.size(width, height);
7778
}
7879

79-
public static ModularPanel createPopupPanel(String name, int width, int height, boolean deleteCachedPanel) {
80-
return new PopupPanel(name, width, height, false, false, deleteCachedPanel);
80+
public static PopupPanel createPopupPanel(String name, int width, int height, boolean deleteCachedPanel) {
81+
return createPopupPanel(name, width, height)
82+
.deleteCachedPanel(deleteCachedPanel);
8183
}
8284

83-
public static ModularPanel defaultPopupPanel(String name) {
85+
public static PopupPanel defaultPopupPanel(String name) {
8486
return new PopupPanel(name);
8587
}
8688

87-
public static ModularPanel defaultPopupPanel(String name, boolean disableBelow,
88-
boolean closeOnOutsideClick, boolean deleteCachedPanel) {
89-
return new PopupPanel(name, DEFAULT_WIDTH, DEFAULT_HIEGHT, disableBelow, closeOnOutsideClick,
90-
deleteCachedPanel);
89+
public static PopupPanel defaultPopupPanel(String name, boolean disableBelow,
90+
boolean closeOnOutsideClick, boolean deleteCachedPanel) {
91+
return defaultPopupPanel(name)
92+
.disablePanelsBelow(disableBelow)
93+
.closeOnOutOfBoundsClick(closeOnOutsideClick)
94+
.deleteCachedPanel(deleteCachedPanel);
9195
}
9296

93-
private static class PopupPanel extends ModularPanel {
97+
public static class PopupPanel extends ModularPanel {
9498

95-
private final boolean disableBelow;
96-
private final boolean closeOnOutsideClick;
97-
private final boolean deleteCachedPanel;
99+
private boolean disableBelow;
100+
private boolean closeOnOutsideClick;
101+
private boolean deleteCachedPanel;
98102

99-
public PopupPanel(@NotNull String name) {
100-
this(name, DEFAULT_WIDTH, DEFAULT_HIEGHT);
101-
}
102-
103-
public PopupPanel(@NotNull String name, int width, int height) {
104-
this(name, width, height, false, false);
105-
}
106-
107-
public PopupPanel(@NotNull String name, int width, int height, boolean disableBelow,
108-
boolean closeOnOutsideClick) {
109-
this(name, width, height, disableBelow, closeOnOutsideClick, false);
110-
}
111-
112-
public PopupPanel(@NotNull String name, int width, int height, boolean disableBelow,
113-
boolean closeOnOutsideClick, boolean deleteCachedPanel) {
103+
private PopupPanel(@NotNull String name) {
114104
super(name);
115-
size(width, height).align(Alignment.Center);
105+
align(Alignment.Center);
116106
background(GTGuiTextures.BACKGROUND_POPUP);
117107
child(ButtonWidget.panelCloseButton().top(5).right(5)
118108
.onMousePressed(mouseButton -> {
@@ -122,9 +112,6 @@ public PopupPanel(@NotNull String name, int width, int height, boolean disableBe
122112
}
123113
return false;
124114
}));
125-
this.disableBelow = disableBelow;
126-
this.closeOnOutsideClick = closeOnOutsideClick;
127-
this.deleteCachedPanel = deleteCachedPanel;
128115
}
129116

130117
@Override
@@ -135,6 +122,33 @@ public void onClose() {
135122
}
136123
}
137124

125+
public PopupPanel disablePanelsBelow(boolean disableBelow) {
126+
this.disableBelow = disableBelow;
127+
return this;
128+
}
129+
130+
public PopupPanel closeOnOutOfBoundsClick(boolean closeOnOutsideClick) {
131+
this.closeOnOutsideClick = closeOnOutsideClick;
132+
return this;
133+
}
134+
135+
public PopupPanel deleteCachedPanel(boolean deleteCachedPanel) {
136+
this.deleteCachedPanel = deleteCachedPanel;
137+
return this;
138+
}
139+
140+
@Override
141+
public PopupPanel size(int w, int h) {
142+
super.size(w, h);
143+
return this;
144+
}
145+
146+
@Override
147+
public PopupPanel size(int val) {
148+
super.size(val);
149+
return this;
150+
}
151+
138152
@Override
139153
public boolean disablePanelsBelow() {
140154
return disableBelow;

0 commit comments

Comments
 (0)