Skip to content

Commit 4b57778

Browse files
committed
directly return panel
1 parent 1af23ad commit 4b57778

1 file changed

Lines changed: 79 additions & 80 deletions

File tree

src/main/java/gregtech/common/metatileentities/storage/MetaTileEntityCreativeEnergy.java

Lines changed: 79 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ public <T> T getCapability(Capability<T> capability, EnumFacing side) {
122122
@Override
123123
public @NotNull ModularPanel buildUI(MetaTileEntityGuiData guiData, PanelSyncManager panelSyncManager,
124124
UISettings settings) {
125-
ModularPanel panel = GTGuis.createPanel(this, 176, 140);
126-
127125
DoubleSyncValue tierSync = SyncHandlers.doubleNumber(() -> setTier, val -> {
128126
setTier = (int) val;
129127
voltage = GTValues.V[setTier];
@@ -147,87 +145,88 @@ public <T> T getCapability(Capability<T> capability, EnumFacing side) {
147145
}
148146
});
149147

150-
panel.child(Flow.column()
151-
.margin(7)
152-
.crossAxisAlignment(Alignment.CrossAxis.START)
153-
.childPadding(4)
154-
.child(new SliderWidget()
155-
.widthRel(1.0f)
156-
.sliderWidth(30)
157-
.bounds(0, GTValues.V.length - 1)
158-
.stopper(1)
159-
.value(tierSync)
160-
.background(new Rectangle()
161-
.setColor(Color.GREY.darker(1))
162-
.asIcon()
163-
.margin(8, 0)
164-
.height(4))
165-
.stopperTexture(GuiTextures.BUTTON_CLEAN.asIcon()
166-
.size(2, 8))
167-
.sliderTexture(IDrawable.of(GuiTextures.BUTTON_CLEAN,
168-
IKey.dynamic(() -> GTValues.VNF[(int) tierSync.getDoubleValue()]))))
169-
.child(IKey.lang("gregtech.creative.energy.voltage")
170-
.asWidget())
171-
.child(new TextFieldWidget()
172-
.widthRel(1.0f)
173-
.height(16)
174-
.value(voltageSync)
175-
.setNumbersLong(() -> 0L, () -> Long.MAX_VALUE)
176-
.setMaxLength(19)
177-
.background(GTGuiTextures.DISPLAY))
178-
.child(IKey.lang("gregtech.creative.energy.amperage")
179-
.asWidget())
180-
.child(Flow.row()
181-
.widthRel(1.0f)
182-
.coverChildrenHeight()
183-
.child(new ButtonWidget<>()
184-
.size(20)
185-
.onMousePressed(mouse -> {
186-
long amps = ampSync.getLongValue();
187-
if (amps > 0) {
188-
ampSync.setLongValue(amps - 1);
189-
}
190-
return true;
191-
})
192-
.overlay(IKey.str("-"))
193-
.addTooltipLine(IKey.lang("gregtech.creative.energy.amps_minus")))
148+
return GTGuis.createPanel(this, 176, 140)
149+
.child(Flow.column()
150+
.margin(7)
151+
.crossAxisAlignment(Alignment.CrossAxis.START)
152+
.childPadding(4)
153+
.child(new SliderWidget()
154+
.widthRel(1.0f)
155+
.sliderWidth(30)
156+
.bounds(0, GTValues.V.length - 1)
157+
.stopper(1)
158+
.value(tierSync)
159+
.background(new Rectangle()
160+
.setColor(Color.GREY.darker(1))
161+
.asIcon()
162+
.margin(8, 0)
163+
.height(4))
164+
.stopperTexture(GuiTextures.BUTTON_CLEAN.asIcon()
165+
.size(2, 8))
166+
.sliderTexture(IDrawable.of(GuiTextures.BUTTON_CLEAN,
167+
IKey.dynamic(() -> GTValues.VNF[(int) tierSync.getDoubleValue()]))))
168+
.child(IKey.lang("gregtech.creative.energy.voltage")
169+
.asWidget())
194170
.child(new TextFieldWidget()
195-
.height(20)
196-
.expanded()
197-
.margin(4, 0)
198-
.value(ampSync)
171+
.widthRel(1.0f)
172+
.height(16)
173+
.value(voltageSync)
199174
.setNumbersLong(() -> 0L, () -> Long.MAX_VALUE)
200-
.setMaxLength(10)
175+
.setMaxLength(19)
201176
.background(GTGuiTextures.DISPLAY))
202-
.child(new ButtonWidget<>()
203-
.size(20)
204-
.onMousePressed(mouse -> {
205-
long amps = ampSync.getLongValue();
206-
if (amps < Long.MAX_VALUE) {
207-
ampSync.setLongValue(amps + 1);
208-
}
209-
return true;
210-
})
211-
.overlay(IKey.str("+"))
212-
.addTooltipLine(IKey.lang("gregtech.creative.energy.amps_plus"))))
213-
.child(IKey.lang("gregtech.creative.energy.io",
214-
() -> new Object[] { TextFormattingUtil.formatNumbers(lastEnergyIOPerSec) })
215-
.asWidget())
216-
.child(Flow.row()
217-
.coverChildrenHeight()
218-
.child(new ToggleButton()
219-
.size(77, 20)
220-
.value(activeSync)
221-
.overlay(IKey.lang(() -> activeSync.getBoolValue() ? "gregtech.creative.activity.on" :
222-
"gregtech.creative.activity.off")))
223-
.child(new ToggleButton()
224-
.size(77, 20)
225-
.align(Alignment.CenterRight)
226-
.value(sourceSync)
227-
.overlay(IKey.lang(() -> sourceSync.getBoolValue() ? "gregtech.creative.energy.source" :
228-
"gregtech.creative.energy.sink")))));
229-
230-
return panel;
177+
.child(IKey.lang("gregtech.creative.energy.amperage")
178+
.asWidget())
179+
.child(Flow.row()
180+
.widthRel(1.0f)
181+
.coverChildrenHeight()
182+
.child(new ButtonWidget<>()
183+
.size(20)
184+
.onMousePressed(mouse -> {
185+
long amps = ampSync.getLongValue();
186+
if (amps > 0) {
187+
ampSync.setLongValue(amps - 1);
188+
}
189+
return true;
190+
})
191+
.overlay(IKey.str("-"))
192+
.addTooltipLine(IKey.lang("gregtech.creative.energy.amps_minus")))
193+
.child(new TextFieldWidget()
194+
.height(20)
195+
.expanded()
196+
.margin(4, 0)
197+
.value(ampSync)
198+
.setNumbersLong(() -> 0L, () -> Long.MAX_VALUE)
199+
.setMaxLength(10)
200+
.background(GTGuiTextures.DISPLAY))
201+
.child(new ButtonWidget<>()
202+
.size(20)
203+
.onMousePressed(mouse -> {
204+
long amps = ampSync.getLongValue();
205+
if (amps < Long.MAX_VALUE) {
206+
ampSync.setLongValue(amps + 1);
207+
}
208+
return true;
209+
})
210+
.overlay(IKey.str("+"))
211+
.addTooltipLine(IKey.lang("gregtech.creative.energy.amps_plus"))))
212+
.child(IKey.lang("gregtech.creative.energy.io",
213+
() -> new Object[] { TextFormattingUtil.formatNumbers(lastEnergyIOPerSec) })
214+
.asWidget())
215+
.child(Flow.row()
216+
.coverChildrenHeight()
217+
.child(new ToggleButton()
218+
.size(77, 20)
219+
.value(activeSync)
220+
.overlay(IKey.lang(() -> activeSync.getBoolValue() ?
221+
"gregtech.creative.activity.on" :
222+
"gregtech.creative.activity.off")))
223+
.child(new ToggleButton()
224+
.size(77, 20)
225+
.align(Alignment.CenterRight)
226+
.value(sourceSync)
227+
.overlay(IKey.lang(() -> sourceSync.getBoolValue() ?
228+
"gregtech.creative.energy.source" :
229+
"gregtech.creative.energy.sink")))));
231230
}
232231

233232
public void setActive(boolean active) {

0 commit comments

Comments
 (0)