|
3 | 3 | import com.gregtechceu.gtceu.api.GTValues; |
4 | 4 | import com.gregtechceu.gtceu.api.blockentity.BlockEntityCreationInfo; |
5 | 5 | import com.gregtechceu.gtceu.api.capability.IEnergyContainer; |
6 | | -import com.gregtechceu.gtceu.api.capability.IParallelHatch; |
7 | 6 | import com.gregtechceu.gtceu.api.capability.recipe.EURecipeCapability; |
8 | 7 | import com.gregtechceu.gtceu.api.capability.recipe.IO; |
9 | 8 | import com.gregtechceu.gtceu.api.capability.recipe.IRecipeHandler; |
10 | | -import com.gregtechceu.gtceu.api.gui.GuiTextures; |
11 | 9 | import com.gregtechceu.gtceu.api.gui.fancy.*; |
12 | | -import com.gregtechceu.gtceu.api.machine.feature.IFancyUIMachine; |
| 10 | +import com.gregtechceu.gtceu.api.machine.feature.IMuiMachine; |
13 | 11 | import com.gregtechceu.gtceu.api.machine.feature.IOverclockMachine; |
14 | 12 | import com.gregtechceu.gtceu.api.machine.feature.ITieredMachine; |
15 | | -import com.gregtechceu.gtceu.api.machine.feature.IVoidable; |
16 | | -import com.gregtechceu.gtceu.api.machine.feature.multiblock.IDisplayUIMachine; |
17 | | -import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiPart; |
18 | 13 | import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; |
19 | 14 | import com.gregtechceu.gtceu.api.misc.EnergyContainerList; |
20 | | -import com.gregtechceu.gtceu.api.recipe.modifier.RecipeModifierList; |
| 15 | +import com.gregtechceu.gtceu.api.mui.factory.PosGuiData; |
| 16 | +import com.gregtechceu.gtceu.api.mui.value.sync.PanelSyncManager; |
| 17 | +import com.gregtechceu.gtceu.api.mui.widget.ParentWidget; |
| 18 | +import com.gregtechceu.gtceu.api.mui.widgets.SlotGroupWidget; |
| 19 | +import com.gregtechceu.gtceu.api.mui.widgets.layout.Column; |
| 20 | +import com.gregtechceu.gtceu.api.mui.widgets.layout.Row; |
21 | 21 | import com.gregtechceu.gtceu.api.sync_system.annotations.SaveField; |
22 | | -import com.gregtechceu.gtceu.common.data.GTRecipeModifiers; |
| 22 | +import com.gregtechceu.gtceu.client.mui.screen.ModularPanel; |
| 23 | +import com.gregtechceu.gtceu.client.mui.screen.UISettings; |
| 24 | +import com.gregtechceu.gtceu.common.data.mui.GTMuiWidgets; |
| 25 | +import com.gregtechceu.gtceu.common.data.mui.GTMultiblockPanelUtil; |
| 26 | +import com.gregtechceu.gtceu.common.mui.GTGuiTextures; |
| 27 | +import com.gregtechceu.gtceu.common.mui.GTGuis; |
23 | 28 | import com.gregtechceu.gtceu.utils.GTUtil; |
24 | 29 |
|
25 | | -import com.lowdragmc.lowdraglib.gui.modular.ModularUI; |
26 | 30 | import com.lowdragmc.lowdraglib.gui.widget.*; |
27 | 31 |
|
28 | 32 | import net.minecraft.MethodsReturnNonnullByDefault; |
29 | | -import net.minecraft.network.chat.Component; |
30 | | -import net.minecraft.world.entity.player.Player; |
31 | 33 |
|
32 | 34 | import lombok.Getter; |
33 | 35 |
|
34 | 36 | import java.util.ArrayList; |
35 | | -import java.util.Arrays; |
36 | 37 | import java.util.List; |
37 | | -import java.util.Objects; |
38 | 38 | import java.util.function.Function; |
39 | 39 |
|
40 | 40 | import javax.annotation.ParametersAreNonnullByDefault; |
41 | 41 |
|
42 | 42 | @ParametersAreNonnullByDefault |
43 | 43 | @MethodsReturnNonnullByDefault |
44 | | -public class WorkableElectricMultiblockMachine extends WorkableMultiblockMachine implements IFancyUIMachine, |
45 | | - IDisplayUIMachine, ITieredMachine, IOverclockMachine { |
| 44 | +public class WorkableElectricMultiblockMachine extends WorkableMultiblockMachine |
| 45 | + implements IMuiMachine, ITieredMachine, IOverclockMachine { |
46 | 46 |
|
47 | 47 | // runtime |
48 | 48 | protected EnergyContainerList energyContainer; |
@@ -93,92 +93,120 @@ public void setBatchEnabled(boolean batch) { |
93 | 93 | ////////////////////////////////////// |
94 | 94 | // ********** GUI ***********// |
95 | 95 | ////////////////////////////////////// |
96 | | - |
97 | 96 | @Override |
98 | | - public void addDisplayText(List<Component> textList) { |
99 | | - int numParallels; |
100 | | - int subtickParallels; |
101 | | - int batchParallels; |
102 | | - int totalRuns; |
103 | | - boolean exact = false; |
104 | | - if (recipeLogic.isActive() && recipeLogic.getLastRecipe() != null) { |
105 | | - numParallels = recipeLogic.getLastRecipe().parallels; |
106 | | - subtickParallels = recipeLogic.getLastRecipe().subtickParallels; |
107 | | - batchParallels = recipeLogic.getLastRecipe().batchParallels; |
108 | | - totalRuns = recipeLogic.getLastRecipe().getTotalRuns(); |
109 | | - exact = true; |
110 | | - } else { |
111 | | - numParallels = getParallelHatch() |
112 | | - .map(IParallelHatch::getCurrentParallel) |
113 | | - .orElse(0); |
114 | | - subtickParallels = 0; |
115 | | - batchParallels = 0; |
116 | | - totalRuns = 0; |
117 | | - } |
118 | | - |
119 | | - MultiblockDisplayText.builder(textList, isFormed()) |
120 | | - .setWorkingStatus(recipeLogic.isWorkingEnabled(), recipeLogic.isActive()) |
121 | | - .addEnergyUsageLine(energyContainer) |
122 | | - .addEnergyTierLine(tier) |
123 | | - .addMachineModeLine(getRecipeType(), getRecipeTypes().length > 1) |
124 | | - .addTotalRunsLine(totalRuns) |
125 | | - .addParallelsLine(numParallels, exact) |
126 | | - .addSubtickParallelsLine(subtickParallels) |
127 | | - .addBatchModeLine(isBatchEnabled(), batchParallels) |
128 | | - .addWorkingStatusLine() |
129 | | - .addProgressLine(recipeLogic) |
130 | | - .addOutputLines(recipeLogic.getLastRecipe()); |
131 | | - getDefinition().getAdditionalDisplay().accept(this, textList); |
132 | | - IDisplayUIMachine.super.addDisplayText(textList); |
| 97 | + public ModularPanel buildUI(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { |
| 98 | + var panel = GTGuis.createPanel(this, 176, 164); |
| 99 | + |
| 100 | + var panelUtil = new GTMultiblockPanelUtil(this); |
| 101 | + |
| 102 | + panel.child(GTMuiWidgets.createTitleBar(this.getDefinition(), 176)) |
| 103 | + .child(new ParentWidget<>() |
| 104 | + .widthRel(0.95f) |
| 105 | + .heightRel(.45f) |
| 106 | + .margin(4, 0) |
| 107 | + .left(3).top(5) |
| 108 | + .child(new Row() |
| 109 | + .child(panelUtil.getMainTextPanel(syncManager, 170, 70)))) |
| 110 | + .child(new Column() |
| 111 | + .coverChildren() |
| 112 | + .leftRel(1.0f) |
| 113 | + .reverseLayout(true) |
| 114 | + .bottom(16) |
| 115 | + .padding(0, 8, 4, 4) |
| 116 | + .childPadding(2) |
| 117 | + .background(GTGuiTextures.BACKGROUND.getSubArea(0.25f, 0f, 1.0f, 1.0f)) |
| 118 | + .child(GTMuiWidgets.createPowerButton(this, syncManager)) |
| 119 | + .child(GTMuiWidgets.createVoidingButton(this, syncManager))) |
| 120 | + .child(SlotGroupWidget.playerInventory(false).left(7).bottom(7)); |
| 121 | + |
| 122 | + return panel; |
133 | 123 | } |
134 | 124 |
|
135 | | - @Override |
136 | | - public Widget createUIWidget() { |
137 | | - var group = new WidgetGroup(0, 0, 182 + 8, 117 + 8); |
138 | | - group.addWidget(new DraggableScrollableWidgetGroup(4, 4, 182, 117).setBackground(getScreenTexture()) |
139 | | - .addWidget(new LabelWidget(4, 5, self().getBlockState().getBlock().getDescriptionId())) |
140 | | - .addWidget(new ComponentPanelWidget(4, 17, this::addDisplayText) |
141 | | - .textSupplier(this.getLevel().isClientSide ? null : this::addDisplayText) |
142 | | - .setMaxWidthLimit(200) |
143 | | - .clickHandler(this::handleDisplayClick))); |
144 | | - group.setBackground(GuiTextures.BACKGROUND_INVERSE); |
145 | | - return group; |
146 | | - } |
147 | | - |
148 | | - @Override |
149 | | - public ModularUI createUI(Player entityPlayer) { |
150 | | - return new ModularUI(198, 208, this, entityPlayer).widget(new FancyMachineUIWidget(this, 198, 208)); |
151 | | - } |
152 | | - |
153 | | - @Override |
154 | | - public List<IFancyUIProvider> getSubTabs() { |
155 | | - return getParts().stream().filter(Objects::nonNull).map(IFancyUIProvider.class::cast).toList(); |
156 | | - } |
157 | | - |
158 | | - @Override |
159 | | - public void attachConfigurators(ConfiguratorPanel configuratorPanel) { |
160 | | - IVoidable.attachConfigurators(configuratorPanel, this); |
161 | | - if (getDefinition().getRecipeModifier() instanceof RecipeModifierList list && Arrays.stream(list.getModifiers()) |
162 | | - .anyMatch(modifier -> modifier == GTRecipeModifiers.BATCH_MODE)) { |
163 | | - configuratorPanel.attachConfigurators(new IFancyConfiguratorButton.Toggle( |
164 | | - GuiTextures.BUTTON_BATCH.getSubTexture(0, 0, 1, 0.5), |
165 | | - GuiTextures.BUTTON_BATCH.getSubTexture(0, 0.5, 1, 0.5), |
166 | | - this::isBatchEnabled, |
167 | | - (cd, p) -> setBatchEnabled(p)) |
168 | | - .setTooltipsSupplier( |
169 | | - p -> List.of( |
170 | | - Component.translatable("gtceu.machine.batch_" + (p ? "enabled" : "disabled"))))); |
171 | | - } |
172 | | - |
173 | | - IFancyUIMachine.super.attachConfigurators(configuratorPanel); |
174 | | - } |
175 | | - |
176 | | - @Override |
177 | | - public void attachTooltips(TooltipsPanel tooltipsPanel) { |
178 | | - for (IMultiPart part : getParts()) { |
179 | | - part.attachFancyTooltipsToController(this, tooltipsPanel); |
180 | | - } |
181 | | - } |
| 125 | + // @Override |
| 126 | + // public void addDisplayText(List<Component> textList) { |
| 127 | + // int numParallels; |
| 128 | + // int subtickParallels; |
| 129 | + // int batchParallels; |
| 130 | + // int totalRuns; |
| 131 | + // boolean exact = false; |
| 132 | + // if (recipeLogic.isActive() && recipeLogic.getLastRecipe() != null) { |
| 133 | + // numParallels = recipeLogic.getLastRecipe().parallels; |
| 134 | + // subtickParallels = recipeLogic.getLastRecipe().subtickParallels; |
| 135 | + // batchParallels = recipeLogic.getLastRecipe().batchParallels; |
| 136 | + // totalRuns = recipeLogic.getLastRecipe().getTotalRuns(); |
| 137 | + // exact = true; |
| 138 | + // } else { |
| 139 | + // numParallels = getParallelHatch() |
| 140 | + // .map(IParallelHatch::getCurrentParallel) |
| 141 | + // .orElse(0); |
| 142 | + // subtickParallels = 0; |
| 143 | + // batchParallels = 0; |
| 144 | + // totalRuns = 0; |
| 145 | + // } |
| 146 | + // |
| 147 | + // MultiblockDisplayText.builder(textList, isFormed()) |
| 148 | + // .setWorkingStatus(recipeLogic.isWorkingEnabled(), recipeLogic.isActive()) |
| 149 | + // .addEnergyUsageLine(energyContainer) |
| 150 | + // .addEnergyTierLine(tier) |
| 151 | + // .addMachineModeLine(getRecipeType(), getRecipeTypes().length > 1) |
| 152 | + // .addTotalRunsLine(totalRuns) |
| 153 | + // .addParallelsLine(numParallels, exact) |
| 154 | + // .addSubtickParallelsLine(subtickParallels) |
| 155 | + // .addBatchModeLine(isBatchEnabled(), batchParallels) |
| 156 | + // .addWorkingStatusLine() |
| 157 | + // .addProgressLine(recipeLogic.getProgress(), recipeLogic.getMaxProgress(), |
| 158 | + // recipeLogic.getProgressPercent()) |
| 159 | + // .addOutputLines(recipeLogic.getLastRecipe()); |
| 160 | + // getDefinition().getAdditionalDisplay().accept(this, textList); |
| 161 | + // IDisplayUIMachine.super.addDisplayText(textList); |
| 162 | + // } |
| 163 | + |
| 164 | + // @Override |
| 165 | + // public Widget createUIWidget() { |
| 166 | + // var group = new WidgetGroup(0, 0, 182 + 8, 117 + 8); |
| 167 | + // group.addWidget(new DraggableScrollableWidgetGroup(4, 4, 182, 117).setBackground(getScreenTexture()) |
| 168 | + // .addWidget(new LabelWidget(4, 5, self().getBlockState().getBlock().getDescriptionId())) |
| 169 | + // .addWidget(new ComponentPanelWidget(4, 17, this::addDisplayText) |
| 170 | + // .textSupplier(this.getLevel().isClientSide ? null : this::addDisplayText) |
| 171 | + // .setMaxWidthLimit(200) |
| 172 | + // .clickHandler(this::handleDisplayClick))); |
| 173 | + // group.setBackground(GuiTextures.BACKGROUND_INVERSE); |
| 174 | + // return group; |
| 175 | + // } |
| 176 | + // |
| 177 | + // @Override |
| 178 | + // public ModularUI createUI(Player entityPlayer) { |
| 179 | + // return new ModularUI(198, 208, this, entityPlayer).widget(new FancyMachineUIWidget(this, 198, 208)); |
| 180 | + // } |
| 181 | + // |
| 182 | + // @Override |
| 183 | + // public List<IFancyUIProvider> getSubTabs() { |
| 184 | + // return getParts().stream().filter(Objects::nonNull).map(IFancyUIProvider.class::cast).toList(); |
| 185 | + // } |
| 186 | + // |
| 187 | + // @Override |
| 188 | + // public void attachConfigurators(ConfiguratorPanel configuratorPanel) { |
| 189 | + // if (getDefinition().getRecipeModifier() instanceof RecipeModifierList list && Arrays.stream(list.getModifiers()) |
| 190 | + // .anyMatch(modifier -> modifier == GTRecipeModifiers.BATCH_MODE)) { |
| 191 | + // configuratorPanel.attachConfigurators(new IFancyConfiguratorButton.Toggle( |
| 192 | + // GuiTextures.BUTTON_BATCH.getSubTexture(0, 0, 1, 0.5), |
| 193 | + // GuiTextures.BUTTON_BATCH.getSubTexture(0, 0.5, 1, 0.5), |
| 194 | + // this::isBatchEnabled, |
| 195 | + // (cd, p) -> setBatchEnabled(p)) |
| 196 | + // .setTooltipsSupplier( |
| 197 | + // p -> List.of( |
| 198 | + // Component.translatable("gtceu.machine.batch_" + (p ? "enabled" : "disabled"))))); |
| 199 | + // } |
| 200 | + // |
| 201 | + // IFancyUIMachine.super.attachConfigurators(configuratorPanel); |
| 202 | + // } |
| 203 | + // |
| 204 | + // @Override |
| 205 | + // public void attachTooltips(TooltipsPanel tooltipsPanel) { |
| 206 | + // for (IMultiPart part : getParts()) { |
| 207 | + // part.attachFancyTooltipsToController(this, tooltipsPanel); |
| 208 | + // } |
| 209 | + // } |
182 | 210 |
|
183 | 211 | ////////////////////////////////////// |
184 | 212 | // ******** OVERCLOCK *********// |
|
0 commit comments