diff options
author | Martin Robertz <dream-master@gmx.net> | 2022-12-29 19:26:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-29 19:26:38 +0100 |
commit | 70587f1332126e762303431306f68d9f28ce79a4 (patch) | |
tree | b5410c6aa5cd9386301ebde4fec3c4aaa6641803 /src | |
parent | f458a638b79aced25d25b8885fa02fc4ace592ce (diff) | |
parent | 51e20f8cb3a06ca7afbf3dfddfb8140900ab6370 (diff) | |
download | GT5-Unofficial-70587f1332126e762303431306f68d9f28ce79a4.tar.gz GT5-Unofficial-70587f1332126e762303431306f68d9f28ce79a4.tar.bz2 GT5-Unofficial-70587f1332126e762303431306f68d9f28ce79a4.zip |
Merge pull request #124 from GTNewHorizons/feature/multiblock-gui-button-adder-exposure
Expose button adder methods on multiblock GUI
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java | 179 |
1 files changed, 97 insertions, 82 deletions
diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java index d4990878ee..b9da45c5d9 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -2933,7 +2933,89 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt drawTexts(screenElements, inventorySlot); builder.widget(screenElements.setPos(7, 8)); - Widget powerPassButton = new ButtonWidget() + Widget powerPassButton = createPowerPassButton(); + builder.widget(powerPassButton) + .widget(new FakeSyncWidget.BooleanSyncer(() -> ePowerPass, val -> ePowerPass = val)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> ePowerPassCover, val -> ePowerPassCover = val)); + Widget safeVoidButton = createSafeVoidButton(); + builder.widget(safeVoidButton) + .widget(new FakeSyncWidget.BooleanSyncer(() -> eSafeVoid, val -> eSafeVoid = val)); + Widget powerSwitchButton = createPowerSwitchButton(); + builder.widget(powerSwitchButton) + .widget(new FakeSyncWidget.BooleanSyncer( + () -> getBaseMetaTileEntity().isAllowedToWork(), val -> { + if (val) getBaseMetaTileEntity().enableWorking(); + else getBaseMetaTileEntity().disableWorking(); + })); + + builder.widget( + new DrawableWidget() { + @Override + public void draw(float partialTicks) { + super.draw(partialTicks); + LEDCounter = (byte) ((1 + LEDCounter) % 6); + } + }.setDrawable(TecTechUITextures.PICTURE_PARAMETER_BLANK) + .setPos(5, doesBindPlayerInventory() ? 96 : 176) + .setSize(166, 12)); + for (int hatch = 0; hatch < 10; hatch++) { + for (int param = 0; param < 2; param++) { + addParameterLED(builder, hatch, param, true); + addParameterLED(builder, hatch, param, false); + } + } + + if (doesBindPlayerInventory()) { + builder.widget(new DrawableWidget() + .setDrawable(TecTechUITextures.PICTURE_UNCERTAINTY_MONITOR_MULTIMACHINE) + .setPos(173, 96) + .setSize(18, 18)); + for (int i = 0; i < 9; i++) { + final int index = i; + builder.widget(new DrawableWidget() + .setDrawable(() -> { + UITexture valid = TecTechUITextures.PICTURE_UNCERTAINTY_VALID[index]; + UITexture invalid = TecTechUITextures.PICTURE_UNCERTAINTY_INVALID[index]; + switch (eCertainMode) { + case 1: // ooo oxo ooo + if (index == 4) return eCertainStatus == 0 ? valid : invalid; + break; + case 2: // ooo xox ooo + if (index == 3) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 5) return (eCertainStatus & 2) == 0 ? valid : invalid; + break; + case 3: // oxo xox oxo + if (index == 1) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 3) return (eCertainStatus & 2) == 0 ? valid : invalid; + if (index == 5) return (eCertainStatus & 4) == 0 ? valid : invalid; + if (index == 7) return (eCertainStatus & 8) == 0 ? valid : invalid; + break; + case 4: // xox ooo xox + if (index == 0) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 2) return (eCertainStatus & 2) == 0 ? valid : invalid; + if (index == 6) return (eCertainStatus & 4) == 0 ? valid : invalid; + if (index == 8) return (eCertainStatus & 8) == 0 ? valid : invalid; + break; + case 5: // xox oxo xox + if (index == 0) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 2) return (eCertainStatus & 2) == 0 ? valid : invalid; + if (index == 4) return (eCertainStatus & 4) == 0 ? valid : invalid; + if (index == 6) return (eCertainStatus & 8) == 0 ? valid : invalid; + if (index == 8) return (eCertainStatus & 16) == 0 ? valid : invalid; + break; + } + return null; + }) + .setPos(174 + (index % 3) * 6, 97 + (index / 3) * 6) + .setSize(4, 4)); + } + builder.widget(new FakeSyncWidget.ByteSyncer(() -> eCertainMode, val -> eCertainMode = val)) + .widget(new FakeSyncWidget.ByteSyncer(() -> eCertainStatus, val -> eCertainStatus = val)); + } + } + + protected ButtonWidget createPowerPassButton() { + Widget button = new ButtonWidget() .setOnClick((clickData, widget) -> { if (isPowerPassButtonEnabled() || ePowerPassCover) { TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); @@ -2965,12 +3047,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt .setPos(174, doesBindPlayerInventory() ? 116 : 140) .setSize(16, 16); if (isPowerPassButtonEnabled()) { - powerPassButton.addTooltip("Power Pass").setTooltipShowUpDelay(TOOLTIP_DELAY); + button.addTooltip("Power Pass").setTooltipShowUpDelay(TOOLTIP_DELAY); } - builder.widget(powerPassButton) - .widget(new FakeSyncWidget.BooleanSyncer(() -> ePowerPass, val -> ePowerPass = val)) - .widget(new FakeSyncWidget.BooleanSyncer(() -> ePowerPassCover, val -> ePowerPassCover = val)); - Widget safeVoidButton = new ButtonWidget() + return (ButtonWidget) button; + } + + protected ButtonWidget createSafeVoidButton() { + Widget button = new ButtonWidget() .setOnClick((clickData, widget) -> { if (isSafeVoidButtonEnabled()) { TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); @@ -2995,11 +3078,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt .setPos(174, doesBindPlayerInventory() ? 132 : 156) .setSize(16, 16); if (isSafeVoidButtonEnabled()) { - safeVoidButton.addTooltip("Safe Void").setTooltipShowUpDelay(TOOLTIP_DELAY); + button.addTooltip("Safe Void").setTooltipShowUpDelay(TOOLTIP_DELAY); } - builder.widget(safeVoidButton) - .widget(new FakeSyncWidget.BooleanSyncer(() -> eSafeVoid, val -> eSafeVoid = val)); - Widget powerSwitchButton = new ButtonWidget() + return (ButtonWidget) button; + } + + protected ButtonWidget createPowerSwitchButton() { + Widget button = new ButtonWidget() .setOnClick((clickData, widget) -> { if (isAllowedToWorkButtonEnabled()) { TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); @@ -3028,79 +3113,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt .setPos(174, doesBindPlayerInventory() ? 148 : 172) .setSize(16, 16); if (isAllowedToWorkButtonEnabled()) { - powerSwitchButton.addTooltip("Power Switch").setTooltipShowUpDelay(TOOLTIP_DELAY); - } - builder.widget(powerSwitchButton) - .widget(new FakeSyncWidget.BooleanSyncer( - () -> getBaseMetaTileEntity().isAllowedToWork(), val -> { - if (val) getBaseMetaTileEntity().enableWorking(); - else getBaseMetaTileEntity().disableWorking(); - })); - - builder.widget( - new DrawableWidget() { - @Override - public void draw(float partialTicks) { - super.draw(partialTicks); - LEDCounter = (byte) ((1 + LEDCounter) % 6); - } - }.setDrawable(TecTechUITextures.PICTURE_PARAMETER_BLANK) - .setPos(5, doesBindPlayerInventory() ? 96 : 176) - .setSize(166, 12)); - for (int hatch = 0; hatch < 10; hatch++) { - for (int param = 0; param < 2; param++) { - addParameterLED(builder, hatch, param, true); - addParameterLED(builder, hatch, param, false); - } - } - - if (doesBindPlayerInventory()) { - builder.widget(new DrawableWidget() - .setDrawable(TecTechUITextures.PICTURE_UNCERTAINTY_MONITOR_MULTIMACHINE) - .setPos(173, 96) - .setSize(18, 18)); - for (int i = 0; i < 9; i++) { - final int index = i; - builder.widget(new DrawableWidget() - .setDrawable(() -> { - UITexture valid = TecTechUITextures.PICTURE_UNCERTAINTY_VALID[index]; - UITexture invalid = TecTechUITextures.PICTURE_UNCERTAINTY_INVALID[index]; - switch (eCertainMode) { - case 1: // ooo oxo ooo - if (index == 4) return eCertainStatus == 0 ? valid : invalid; - break; - case 2: // ooo xox ooo - if (index == 3) return (eCertainStatus & 1) == 0 ? valid : invalid; - if (index == 5) return (eCertainStatus & 2) == 0 ? valid : invalid; - break; - case 3: // oxo xox oxo - if (index == 1) return (eCertainStatus & 1) == 0 ? valid : invalid; - if (index == 3) return (eCertainStatus & 2) == 0 ? valid : invalid; - if (index == 5) return (eCertainStatus & 4) == 0 ? valid : invalid; - if (index == 7) return (eCertainStatus & 8) == 0 ? valid : invalid; - break; - case 4: // xox ooo xox - if (index == 0) return (eCertainStatus & 1) == 0 ? valid : invalid; - if (index == 2) return (eCertainStatus & 2) == 0 ? valid : invalid; - if (index == 6) return (eCertainStatus & 4) == 0 ? valid : invalid; - if (index == 8) return (eCertainStatus & 8) == 0 ? valid : invalid; - break; - case 5: // xox oxo xox - if (index == 0) return (eCertainStatus & 1) == 0 ? valid : invalid; - if (index == 2) return (eCertainStatus & 2) == 0 ? valid : invalid; - if (index == 4) return (eCertainStatus & 4) == 0 ? valid : invalid; - if (index == 6) return (eCertainStatus & 8) == 0 ? valid : invalid; - if (index == 8) return (eCertainStatus & 16) == 0 ? valid : invalid; - break; - } - return null; - }) - .setPos(174 + (index % 3) * 6, 97 + (index / 3) * 6) - .setSize(4, 4)); - } - builder.widget(new FakeSyncWidget.ByteSyncer(() -> eCertainMode, val -> eCertainMode = val)) - .widget(new FakeSyncWidget.ByteSyncer(() -> eCertainStatus, val -> eCertainStatus = val)); + button.addTooltip("Power Switch").setTooltipShowUpDelay(TOOLTIP_DELAY); } + return (ButtonWidget) button; } private void addParameterLED(ModularWindow.Builder builder, int hatch, int param, boolean input) { |