|
7 | 7 | import gregtech.api.gui.GuiTextures; |
8 | 8 | import gregtech.api.gui.ModularUI; |
9 | 9 | import gregtech.api.gui.resources.TextureArea; |
10 | | -import gregtech.api.gui.widgets.FluidContainerSlotWidget; |
11 | | -import gregtech.api.gui.widgets.ProgressWidget; |
12 | | -import gregtech.api.gui.widgets.ProgressWidget.MoveType; |
13 | | -import gregtech.api.gui.widgets.TankWidget; |
14 | 10 | import gregtech.api.items.itemhandlers.GTItemStackHandler; |
15 | 11 | import gregtech.api.metatileentity.IDataInfoProvider; |
16 | 12 | import gregtech.api.metatileentity.MetaTileEntity; |
| 13 | +import gregtech.api.mui.GTGuiTextures; |
| 14 | +import gregtech.api.mui.GTGuiTheme; |
| 15 | +import gregtech.api.mui.GTGuis; |
17 | 16 | import gregtech.api.unification.material.Materials; |
18 | 17 | import gregtech.api.util.GTTransferUtils; |
19 | 18 | import gregtech.api.util.GTUtility; |
|
23 | 22 | import gregtech.client.renderer.texture.Textures; |
24 | 23 | import gregtech.client.renderer.texture.cube.SimpleSidedCubeRenderer; |
25 | 24 | import gregtech.common.ConfigHolder; |
| 25 | +import gregtech.common.mui.widget.GTFluidSlot; |
26 | 26 | import gregtech.core.sound.GTSoundEvents; |
27 | 27 |
|
28 | 28 | import net.minecraft.client.renderer.texture.TextureAtlasSprite; |
|
47 | 47 | import codechicken.lib.render.pipeline.ColourMultiplier; |
48 | 48 | import codechicken.lib.render.pipeline.IVertexOperation; |
49 | 49 | import codechicken.lib.vec.Matrix4; |
| 50 | +import com.cleanroommc.modularui.api.drawable.IDrawable; |
| 51 | +import com.cleanroommc.modularui.api.drawable.IKey; |
| 52 | +import com.cleanroommc.modularui.drawable.UITexture; |
| 53 | +import com.cleanroommc.modularui.factory.PosGuiData; |
| 54 | +import com.cleanroommc.modularui.screen.ModularPanel; |
| 55 | +import com.cleanroommc.modularui.value.sync.DoubleSyncValue; |
| 56 | +import com.cleanroommc.modularui.value.sync.PanelSyncManager; |
| 57 | +import com.cleanroommc.modularui.widget.Widget; |
| 58 | +import com.cleanroommc.modularui.widgets.ItemSlot; |
| 59 | +import com.cleanroommc.modularui.widgets.ProgressWidget; |
| 60 | +import com.cleanroommc.modularui.widgets.slot.ModularSlot; |
50 | 61 | import org.apache.commons.lang3.ArrayUtils; |
51 | 62 | import org.apache.commons.lang3.tuple.Pair; |
52 | 63 | import org.jetbrains.annotations.NotNull; |
@@ -331,20 +342,91 @@ protected TextureArea getGuiTexture(String pathTemplate) { |
331 | 342 | type, STRING_SUBSTITUTION_PATTERN.matcher(pathTemplate).replaceAll(Matcher.quoteReplacement(type)))); |
332 | 343 | } |
333 | 344 |
|
| 345 | + @Override |
| 346 | + public boolean usesMui2() { |
| 347 | + return true; |
| 348 | + } |
| 349 | + |
| 350 | + @Override |
| 351 | + public ModularPanel buildUI(PosGuiData guiData, PanelSyncManager guiSyncManager) { |
| 352 | + return GTGuis.defaultPanel(this) |
| 353 | + .child(IKey.lang(getMetaFullName()).asWidget().pos(5, 5)) |
| 354 | + .child(new ProgressWidget() |
| 355 | + .texture(getEmptyBarDrawable(), GTGuiTextures.PROGRESS_BAR_BOILER_HEAT, -1) |
| 356 | + .direction(ProgressWidget.Direction.UP) |
| 357 | + .debugName("temp") |
| 358 | + .value(new DoubleSyncValue(this::getTemperaturePercent)) |
| 359 | + .pos(96, 26) |
| 360 | + .size(10, 54)) |
| 361 | + .child(new GTFluidSlot() |
| 362 | + .debugName("water") |
| 363 | + .background(getEmptyBarDrawable()) |
| 364 | + .syncHandler(GTFluidSlot.sync(waterFluidTank) |
| 365 | + .showAmount(false) |
| 366 | + .accessibility(false, false)) |
| 367 | + .pos(83, 26) |
| 368 | + .size(10, 54)) |
| 369 | + .child(new GTFluidSlot() |
| 370 | + .debugName("steam") |
| 371 | + .background(getEmptyBarDrawable()) |
| 372 | + .syncHandler(GTFluidSlot.sync(steamFluidTank) |
| 373 | + .showAmount(false) |
| 374 | + .accessibility(false, false)) |
| 375 | + .pos(70, 26) |
| 376 | + .size(10, 54)) |
| 377 | + .child(new ItemSlot() |
| 378 | + .debugName("fluid in") |
| 379 | + .background(getSlotBackground(false)) |
| 380 | + .slot(new ModularSlot(containerInventory, 0) |
| 381 | + .singletonSlotGroup()) |
| 382 | + .pos(43, 26)) |
| 383 | + .child(new ItemSlot() |
| 384 | + .debugName("fluid out") |
| 385 | + .background(getSlotBackground(true)) |
| 386 | + .slot(new ModularSlot(containerInventory, 1) |
| 387 | + .accessibility(false, true)) |
| 388 | + .pos(43, 62)) |
| 389 | + .child(new Widget<>() |
| 390 | + .pos(43, 44) |
| 391 | + .size(18) |
| 392 | + .background(isHighPressure ? GTGuiTextures.CANISTER_OVERLAY_STEEL : |
| 393 | + GTGuiTextures.CANISTER_OVERLAY_BRONZE)) |
| 394 | + .bindPlayerInventory(); |
| 395 | + } |
| 396 | + |
| 397 | + @Override |
| 398 | + public GTGuiTheme getUITheme() { |
| 399 | + return isHighPressure ? GTGuiTheme.STEEL : GTGuiTheme.BRONZE; |
| 400 | + } |
| 401 | + |
| 402 | + protected UITexture getEmptyBarDrawable() { |
| 403 | + return isHighPressure ? GTGuiTextures.PROGRESS_BAR_BOILER_EMPTY_STEEL : |
| 404 | + GTGuiTextures.PROGRESS_BAR_BOILER_EMPTY_BRONZE; |
| 405 | + } |
| 406 | + |
| 407 | + protected IDrawable getSlotBackground(boolean output) { |
| 408 | + UITexture base = isHighPressure ? GTGuiTextures.SLOT_STEEL : GTGuiTextures.SLOT_BRONZE; |
| 409 | + UITexture overlay; |
| 410 | + if (isHighPressure) |
| 411 | + overlay = output ? GTGuiTextures.OUT_SLOT_OVERLAY_STEEL : GTGuiTextures.IN_SLOT_OVERLAY_STEEL; |
| 412 | + else overlay = output ? GTGuiTextures.OUT_SLOT_OVERLAY_BRONZE : GTGuiTextures.IN_SLOT_OVERLAY_BRONZE; |
| 413 | + return IDrawable.of(base, overlay); |
| 414 | + } |
| 415 | + |
334 | 416 | public ModularUI.Builder createUITemplate(EntityPlayer player) { |
335 | 417 | return ModularUI.builder(GuiTextures.BACKGROUND_STEAM.get(isHighPressure), 176, 166) |
336 | 418 | .label(6, 6, getMetaFullName()).shouldColor(false) |
337 | | - .widget(new ProgressWidget(this::getTemperaturePercent, 96, 26, 10, 54) |
| 419 | + .widget(new gregtech.api.gui.widgets.ProgressWidget(this::getTemperaturePercent, 96, 26, 10, 54) |
338 | 420 | .setProgressBar(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure), |
339 | 421 | GuiTextures.PROGRESS_BAR_BOILER_HEAT, |
340 | | - MoveType.VERTICAL)) |
| 422 | + gregtech.api.gui.widgets.ProgressWidget.MoveType.VERTICAL)) |
341 | 423 |
|
342 | | - .widget(new TankWidget(waterFluidTank, 83, 26, 10, 54) |
| 424 | + .widget(new gregtech.api.gui.widgets.TankWidget(waterFluidTank, 83, 26, 10, 54) |
343 | 425 | .setBackgroundTexture(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure))) |
344 | | - .widget(new TankWidget(steamFluidTank, 70, 26, 10, 54) |
| 426 | + .widget(new gregtech.api.gui.widgets.TankWidget(steamFluidTank, 70, 26, 10, 54) |
345 | 427 | .setBackgroundTexture(GuiTextures.PROGRESS_BAR_BOILER_EMPTY.get(isHighPressure))) |
346 | 428 |
|
347 | | - .widget(new FluidContainerSlotWidget(containerInventory, 0, 43, 26, true) |
| 429 | + .widget(new gregtech.api.gui.widgets.FluidContainerSlotWidget(containerInventory, 0, 43, 26, true) |
348 | 430 | .setBackgroundTexture(GuiTextures.SLOT_STEAM.get(isHighPressure), |
349 | 431 | GuiTextures.IN_SLOT_OVERLAY_STEAM.get(isHighPressure))) |
350 | 432 | .slot(containerInventory, 1, 43, 62, true, false, |
|
0 commit comments