|
7 | 7 | import gregtech.api.capability.impl.ItemHandlerList; |
8 | 8 | import gregtech.api.capability.impl.miner.MultiblockMinerLogic; |
9 | 9 | import gregtech.api.gui.GuiTextures; |
10 | | -import gregtech.api.gui.ModularUI; |
11 | 10 | import gregtech.api.gui.Widget; |
12 | | -import gregtech.api.gui.widgets.AdvancedTextWidget; |
13 | 11 | import gregtech.api.gui.widgets.ImageCycleButtonWidget; |
14 | 12 | import gregtech.api.items.itemhandlers.GTItemStackHandler; |
15 | 13 | import gregtech.api.metatileentity.IDataInfoProvider; |
16 | 14 | import gregtech.api.metatileentity.MetaTileEntity; |
17 | 15 | import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; |
18 | 16 | import gregtech.api.metatileentity.multiblock.IMultiblockPart; |
19 | 17 | import gregtech.api.metatileentity.multiblock.MultiblockAbility; |
20 | | -import gregtech.api.metatileentity.multiblock.MultiblockDisplayText; |
21 | 18 | import gregtech.api.metatileentity.multiblock.MultiblockWithDisplayBase; |
| 19 | +import gregtech.api.metatileentity.multiblock.ui.MultiblockUIFactory; |
| 20 | +import gregtech.api.mui.GTGuiTextures; |
22 | 21 | import gregtech.api.pattern.BlockPattern; |
23 | 22 | import gregtech.api.pattern.FactoryBlockPattern; |
24 | 23 | import gregtech.api.pattern.PatternMatchContext; |
|
27 | 26 | import gregtech.api.unification.material.Material; |
28 | 27 | import gregtech.api.unification.material.Materials; |
29 | 28 | import gregtech.api.util.GTUtility; |
30 | | -import gregtech.api.util.TextComponentUtil; |
| 29 | +import gregtech.api.util.KeyUtil; |
31 | 30 | import gregtech.client.renderer.ICubeRenderer; |
32 | 31 | import gregtech.client.renderer.texture.Textures; |
33 | 32 | import gregtech.common.blocks.BlockMetalCasing; |
|
57 | 56 | import codechicken.lib.render.CCRenderState; |
58 | 57 | import codechicken.lib.render.pipeline.IVertexOperation; |
59 | 58 | import codechicken.lib.vec.Matrix4; |
| 59 | +import com.cleanroommc.modularui.api.drawable.IKey; |
| 60 | +import com.cleanroommc.modularui.value.sync.IntSyncValue; |
| 61 | +import com.cleanroommc.modularui.widgets.CycleButtonWidget; |
60 | 62 | import com.google.common.collect.Lists; |
61 | 63 | import org.jetbrains.annotations.NotNull; |
62 | 64 | import org.jetbrains.annotations.Nullable; |
@@ -232,79 +234,75 @@ public void addToolUsages(ItemStack stack, @Nullable World world, List<String> t |
232 | 234 | } |
233 | 235 |
|
234 | 236 | @Override |
235 | | - protected void addDisplayText(List<ITextComponent> textList) { |
236 | | - super.addDisplayText(textList); |
| 237 | + protected MultiblockUIFactory createUIFactory() { |
| 238 | + return super.createUIFactory() |
| 239 | + .createFlexButton((posGuiData, panelSyncManager) -> { |
| 240 | + IntSyncValue buttonSync = new IntSyncValue(this::getCurrentMode, this::setCurrentMode); |
237 | 241 |
|
238 | | - if (this.isStructureFormed()) { |
239 | | - if (energyContainer != null && energyContainer.getEnergyCapacity() > 0) { |
240 | | - int energyContainer = getEnergyTier(); |
241 | | - long maxVoltage = GTValues.V[energyContainer]; |
242 | | - String voltageName = GTValues.VNF[energyContainer]; |
243 | | - textList.add(new TextComponentTranslation("gregtech.multiblock.max_energy_per_tick", maxVoltage, |
244 | | - voltageName)); |
245 | | - } |
246 | | - |
247 | | - int workingAreaChunks = this.minerLogic.getCurrentRadius() * 2 / CHUNK_LENGTH; |
248 | | - int workingArea = getWorkingArea(minerLogic.getCurrentRadius()); |
249 | | - textList.add(new TextComponentTranslation("gregtech.machine.miner.startx", |
250 | | - this.minerLogic.getX().get() == Integer.MAX_VALUE ? 0 : this.minerLogic.getX().get())); |
251 | | - textList.add(new TextComponentTranslation("gregtech.machine.miner.starty", |
252 | | - this.minerLogic.getY().get() == Integer.MAX_VALUE ? 0 : this.minerLogic.getY().get())); |
253 | | - textList.add(new TextComponentTranslation("gregtech.machine.miner.startz", |
254 | | - this.minerLogic.getZ().get() == Integer.MAX_VALUE ? 0 : this.minerLogic.getZ().get())); |
255 | | - if (this.minerLogic.isChunkMode()) { |
256 | | - textList.add(new TextComponentTranslation("gregtech.machine.miner.working_area_chunks", |
257 | | - workingAreaChunks, workingAreaChunks)); |
258 | | - } else { |
259 | | - textList.add( |
260 | | - new TextComponentTranslation("gregtech.machine.miner.working_area", workingArea, workingArea)); |
261 | | - } |
262 | | - if (this.minerLogic.isDone()) |
263 | | - textList.add(new TextComponentTranslation("gregtech.machine.miner.done") |
264 | | - .setStyle(new Style().setColor(TextFormatting.GREEN))); |
265 | | - else if (this.minerLogic.isWorking()) |
266 | | - textList.add(new TextComponentTranslation("gregtech.machine.miner.working") |
267 | | - .setStyle(new Style().setColor(TextFormatting.GOLD))); |
268 | | - else if (!this.isWorkingEnabled()) |
269 | | - textList.add(new TextComponentTranslation("gregtech.multiblock.work_paused")); |
270 | | - } |
271 | | - } |
272 | | - |
273 | | - private void addDisplayText2(List<ITextComponent> textList) { |
274 | | - if (this.isStructureFormed()) { |
275 | | - ITextComponent mCoords = new TextComponentString(" ") |
276 | | - .appendSibling(new TextComponentTranslation("gregtech.machine.miner.minex", |
277 | | - this.minerLogic.getMineX().get())) |
278 | | - .appendText("\n ") |
279 | | - .appendSibling(new TextComponentTranslation("gregtech.machine.miner.miney", |
280 | | - this.minerLogic.getMineY().get())) |
281 | | - .appendText("\n ") |
282 | | - .appendSibling(new TextComponentTranslation("gregtech.machine.miner.minez", |
283 | | - this.minerLogic.getMineZ().get())); |
284 | | - textList.add(mCoords); |
285 | | - } |
| 242 | + return new CycleButtonWidget() |
| 243 | + .stateCount(4) |
| 244 | + .value(buttonSync) |
| 245 | + .addTooltip(0, IKey.lang("gregtech.multiblock.miner.neither_mode")) |
| 246 | + .addTooltip(1, IKey.lang("gregtech.multiblock.miner.chunk_mode")) |
| 247 | + .addTooltip(2, IKey.lang("gregtech.multiblock.miner.silk_touch_mode")) |
| 248 | + .addTooltip(3, IKey.lang("gregtech.multiblock.miner.both_modes")) |
| 249 | + .stateBackground(0, GTGuiTextures.BUTTON_MINER_MODES[0]) |
| 250 | + .stateBackground(1, GTGuiTextures.BUTTON_MINER_MODES[1]) |
| 251 | + .stateBackground(2, GTGuiTextures.BUTTON_MINER_MODES[2]) |
| 252 | + .stateBackground(3, GTGuiTextures.BUTTON_MINER_MODES[3]); |
| 253 | + }); |
286 | 254 | } |
287 | 255 |
|
288 | 256 | @Override |
289 | | - protected void addWarningText(List<ITextComponent> textList) { |
290 | | - MultiblockDisplayText.builder(textList, isStructureFormed(), false) |
291 | | - .addLowPowerLine(isStructureFormed() && !drainEnergy(true)) |
292 | | - .addCustom(tl -> { |
293 | | - if (isStructureFormed() && isInventoryFull) { |
294 | | - tl.add(TextComponentUtil.translationWithColor( |
295 | | - TextFormatting.YELLOW, |
296 | | - "gregtech.machine.miner.invfull")); |
| 257 | + protected void configureDisplayText(MultiblockUIFactory.Builder builder) { |
| 258 | + builder.setWorkingStatus(minerLogic.isWorkingEnabled(), minerLogic.isActive()) |
| 259 | + .addEnergyUsageLine(energyContainer) |
| 260 | + .addCustom(list -> { |
| 261 | + if (isStructureFormed()) { |
| 262 | + int workingAreaChunks = this.minerLogic.getCurrentRadius() * 2 / CHUNK_LENGTH; |
| 263 | + int workingArea = getWorkingArea(minerLogic.getCurrentRadius()); |
| 264 | + |
| 265 | + list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.machine.miner.mining_at")); |
| 266 | + list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.machine.miner.mining_pos", |
| 267 | + minerLogic.getX().get(), minerLogic.getY().get(), minerLogic.getZ().get())); |
| 268 | + |
| 269 | + if (minerLogic.isChunkMode()) { |
| 270 | + list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.machine.miner.working_area_chunks", |
| 271 | + workingAreaChunks, |
| 272 | + workingAreaChunks)); |
| 273 | + } else { |
| 274 | + list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.machine.miner.working_area", |
| 275 | + workingArea, workingArea)); |
| 276 | + } |
| 277 | + |
| 278 | + if (minerLogic.isDone()) { |
| 279 | + list.add(KeyUtil.lang(TextFormatting.GREEN, "gregtech.machine.miner.done")); |
| 280 | + } else if (minerLogic.isWorking()) { |
| 281 | + list.add(KeyUtil.lang(TextFormatting.GOLD, "gregtech.machine.miner.working")); |
| 282 | + } else if (!isWorkingEnabled()) { |
| 283 | + list.add(KeyUtil.lang(TextFormatting.GRAY, "gregtech.multiblock.work_paused")); |
| 284 | + } |
297 | 285 | } |
298 | 286 | }); |
299 | 287 | } |
300 | 288 |
|
301 | 289 | @Override |
302 | | - protected void addErrorText(List<ITextComponent> textList) { |
303 | | - super.addErrorText(textList); |
304 | | - if (isStructureFormed() && !drainFluid(true)) { |
305 | | - textList.add(TextComponentUtil.translationWithColor(TextFormatting.RED, |
306 | | - "gregtech.machine.miner.multi.needsfluid")); |
307 | | - } |
| 290 | + protected void configureErrorText(MultiblockUIFactory.Builder builder) { |
| 291 | + builder.addCustom(list -> { |
| 292 | + if (isStructureFormed() && !drainFluid(false)) { |
| 293 | + list.add(KeyUtil.lang(TextFormatting.RED, "gregtech.machine.miner.multi.needsfluid")); |
| 294 | + } |
| 295 | + }); |
| 296 | + } |
| 297 | + |
| 298 | + @Override |
| 299 | + protected void configureWarningText(MultiblockUIFactory.Builder builder) { |
| 300 | + builder.addLowPowerLine(!drainEnergy(true)); |
| 301 | + builder.addCustom(list -> { |
| 302 | + if (isStructureFormed() && isInventoryFull) { |
| 303 | + list.add(KeyUtil.lang(TextFormatting.YELLOW, "gregtech.machine.miner.invfull")); |
| 304 | + } |
| 305 | + }); |
308 | 306 | } |
309 | 307 |
|
310 | 308 | public IBlockState getCasingState() { |
@@ -383,14 +381,6 @@ public long getMaxVoltage() { |
383 | 381 | return GTValues.V[GTUtility.getTierByVoltage(energyContainer.getInputVoltage())]; |
384 | 382 | } |
385 | 383 |
|
386 | | - @Override |
387 | | - protected ModularUI.Builder createUITemplate(EntityPlayer entityPlayer) { |
388 | | - ModularUI.Builder builder = super.createUITemplate(entityPlayer); |
389 | | - builder.widget(new AdvancedTextWidget(63, 31, this::addDisplayText2, 0xFFFFFF) |
390 | | - .setMaxWidthLimit(68).setClickHandler(this::handleDisplayClick)); |
391 | | - return builder; |
392 | | - } |
393 | | - |
394 | 384 | // used for UI |
395 | 385 | private int getCurrentMode() { |
396 | 386 | // 0 -> not chunk mode, not silk touch mode |
|
0 commit comments