|
4 | 4 | import com.gregtechceu.gtceu.api.blockentity.BlockEntityCreationInfo; |
5 | 5 | import com.gregtechceu.gtceu.api.capability.recipe.IO; |
6 | 6 | import com.gregtechceu.gtceu.api.capability.recipe.ItemRecipeCapability; |
7 | | -import com.gregtechceu.gtceu.api.gui.GuiTextures; |
8 | | -import com.gregtechceu.gtceu.api.gui.UITemplate; |
9 | | -import com.gregtechceu.gtceu.api.gui.widget.SlotWidget; |
10 | 7 | import com.gregtechceu.gtceu.api.machine.TickableSubscription; |
11 | | -import com.gregtechceu.gtceu.api.machine.feature.IUIMachine; |
| 8 | +import com.gregtechceu.gtceu.api.machine.feature.IMuiMachine; |
12 | 9 | import com.gregtechceu.gtceu.api.machine.feature.multiblock.IFluidRenderMulti; |
13 | 10 | import com.gregtechceu.gtceu.api.machine.trait.NotifiableItemStackHandler; |
14 | 11 | import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; |
| 12 | +import com.gregtechceu.gtceu.api.mui.base.ITheme; |
| 13 | +import com.gregtechceu.gtceu.api.mui.drawable.UITexture; |
| 14 | +import com.gregtechceu.gtceu.api.mui.factory.PosGuiData; |
| 15 | +import com.gregtechceu.gtceu.api.mui.theme.ThemeAPI; |
| 16 | +import com.gregtechceu.gtceu.api.mui.value.sync.ItemSlotSyncHandler; |
| 17 | +import com.gregtechceu.gtceu.api.mui.value.sync.PanelSyncManager; |
| 18 | +import com.gregtechceu.gtceu.api.mui.widgets.ProgressWidget; |
| 19 | +import com.gregtechceu.gtceu.api.mui.widgets.SlotGroupWidget; |
| 20 | +import com.gregtechceu.gtceu.api.mui.widgets.slot.ItemSlot; |
| 21 | +import com.gregtechceu.gtceu.api.mui.widgets.slot.ModularSlot; |
| 22 | +import com.gregtechceu.gtceu.api.mui.widgets.slot.SlotGroup; |
15 | 23 | import com.gregtechceu.gtceu.api.pattern.util.RelativeDirection; |
16 | 24 | import com.gregtechceu.gtceu.api.sync_system.annotations.RerenderOnChanged; |
17 | 25 | import com.gregtechceu.gtceu.api.sync_system.annotations.SyncToClient; |
| 26 | +import com.gregtechceu.gtceu.client.mui.screen.ModularPanel; |
| 27 | +import com.gregtechceu.gtceu.client.mui.screen.UISettings; |
| 28 | +import com.gregtechceu.gtceu.common.data.mui.GTMuiWidgets; |
| 29 | +import com.gregtechceu.gtceu.common.mui.GTGuiTextures; |
18 | 30 | import com.gregtechceu.gtceu.config.ConfigHolder; |
19 | 31 | import com.gregtechceu.gtceu.utils.GTUtil; |
20 | 32 |
|
21 | | -import com.lowdragmc.lowdraglib.gui.modular.ModularUI; |
22 | | -import com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup; |
23 | | -import com.lowdragmc.lowdraglib.gui.widget.LabelWidget; |
24 | | -import com.lowdragmc.lowdraglib.gui.widget.ProgressWidget; |
25 | | - |
26 | 33 | import net.minecraft.MethodsReturnNonnullByDefault; |
27 | 34 | import net.minecraft.core.BlockPos; |
28 | 35 | import net.minecraft.core.Direction; |
29 | 36 | import net.minecraft.core.particles.ParticleTypes; |
30 | 37 | import net.minecraft.sounds.SoundEvents; |
31 | 38 | import net.minecraft.sounds.SoundSource; |
32 | 39 | import net.minecraft.util.RandomSource; |
33 | | -import net.minecraft.world.entity.player.Player; |
34 | 40 | import net.minecraft.world.level.block.state.BlockState; |
35 | 41 | import net.minecraft.world.phys.AABB; |
36 | 42 | import net.minecraftforge.api.distmarker.Dist; |
|
39 | 45 | import lombok.Getter; |
40 | 46 | import org.jetbrains.annotations.NotNull; |
41 | 47 |
|
| 48 | +import java.util.Arrays; |
42 | 49 | import java.util.Collections; |
43 | 50 | import java.util.HashSet; |
44 | 51 | import java.util.Set; |
|
47 | 54 |
|
48 | 55 | @ParametersAreNonnullByDefault |
49 | 56 | @MethodsReturnNonnullByDefault |
50 | | -public class PrimitiveBlastFurnaceMachine extends PrimitiveWorkableMachine implements IUIMachine, IFluidRenderMulti { |
| 57 | +public class PrimitiveBlastFurnaceMachine extends PrimitiveWorkableMachine implements IMuiMachine, IFluidRenderMulti { |
51 | 58 |
|
52 | 59 | private TickableSubscription hurtSubscription; |
53 | 60 |
|
@@ -146,32 +153,65 @@ public void clientTick() { |
146 | 153 | } |
147 | 154 |
|
148 | 155 | @Override |
149 | | - public ModularUI createUI(Player entityPlayer) { |
150 | | - return new ModularUI(176, 166, this, entityPlayer) |
151 | | - .background(GuiTextures.PRIMITIVE_BACKGROUND) |
152 | | - .widget(new LabelWidget(5, 5, getBlockState().getBlock().getDescriptionId())) |
153 | | - .widget(new SlotWidget(importItems.storage, 0, 52, 20, true, true) |
154 | | - .setBackgroundTexture( |
155 | | - new GuiTextureGroup(GuiTextures.PRIMITIVE_SLOT, GuiTextures.PRIMITIVE_INGOT_OVERLAY))) |
156 | | - .widget(new SlotWidget(importItems.storage, 1, 52, 38, true, true) |
157 | | - .setBackgroundTexture( |
158 | | - new GuiTextureGroup(GuiTextures.PRIMITIVE_SLOT, GuiTextures.PRIMITIVE_DUST_OVERLAY))) |
159 | | - .widget(new SlotWidget(importItems.storage, 2, 52, 56, true, true) |
160 | | - .setBackgroundTexture( |
161 | | - new GuiTextureGroup(GuiTextures.PRIMITIVE_SLOT, GuiTextures.PRIMITIVE_FURNACE_OVERLAY))) |
162 | | - .widget(new ProgressWidget(recipeLogic::getProgressPercent, 77, 39, 20, 15, |
163 | | - GuiTextures.PRIMITIVE_BLAST_FURNACE_PROGRESS_BAR)) |
164 | | - .widget(new SlotWidget(exportItems.storage, 0, 104, 38, true, false) |
165 | | - .setBackgroundTexture( |
166 | | - new GuiTextureGroup(GuiTextures.PRIMITIVE_SLOT, GuiTextures.PRIMITIVE_INGOT_OVERLAY))) |
167 | | - .widget(new SlotWidget(exportItems.storage, 1, 122, 38, true, false) |
168 | | - .setBackgroundTexture( |
169 | | - new GuiTextureGroup(GuiTextures.PRIMITIVE_SLOT, GuiTextures.PRIMITIVE_DUST_OVERLAY))) |
170 | | - .widget(new SlotWidget(exportItems.storage, 2, 140, 38, true, false) |
171 | | - .setBackgroundTexture( |
172 | | - new GuiTextureGroup(GuiTextures.PRIMITIVE_SLOT, GuiTextures.PRIMITIVE_DUST_OVERLAY))) |
173 | | - .widget(UITemplate.bindPlayerInventory(entityPlayer.getInventory(), |
174 | | - GuiTextures.PRIMITIVE_SLOT, 7, 84, true)); |
| 156 | + public ModularPanel buildUI(PosGuiData data, PanelSyncManager syncManager, UISettings settings) { |
| 157 | + ITheme theme = ThemeAPI.INSTANCE.getTheme(getDefinition().getThemeId()); |
| 158 | + return new ModularPanel(this.getDefinition().getName()) |
| 159 | + .size(176, 166) |
| 160 | + // Top half of the screen |
| 161 | + .child(createImportItemSlot(syncManager, theme).margin(52, 16)) |
| 162 | + .child(new ProgressWidget().progress(recipeLogic::getProgressPercent).size(20, 15) |
| 163 | + .texture(GTGuiTextures.PRIMITIVE_BLAST_FURNACE_PROGRESS_BAR, 0).margin(77, 35)) |
| 164 | + .child(createExportItemSlot(syncManager, theme).margin(104, 0, 34, 0)) |
| 165 | + |
| 166 | + .child(GTMuiWidgets.createTitleBar(getDefinition(), 176, (UITexture) theme.getPanelTheme().getTheme() |
| 167 | + .getBackground())) |
| 168 | + .child(SlotGroupWidget |
| 169 | + .playerInventory(false).left(7) |
| 170 | + .bottom(7)); |
| 171 | + } |
| 172 | + |
| 173 | + private SlotGroupWidget createImportItemSlot(PanelSyncManager syncManager, ITheme theme) { |
| 174 | + int size = importItems.storage.getSlots(); |
| 175 | + SlotGroup slotGroup = new SlotGroup("import", size); |
| 176 | + String[] matrix = new String[size]; |
| 177 | + char key = 'I'; |
| 178 | + Arrays.fill(matrix, String.valueOf(key)); |
| 179 | + return SlotGroupWidget.builder() |
| 180 | + .matrix(matrix) |
| 181 | + .key(key, i -> { |
| 182 | + ModularSlot slot = new ModularSlot(importItems.storage, i); |
| 183 | + ItemSlotSyncHandler syncHandler = new ItemSlotSyncHandler(slot.slotGroup(slotGroup)); |
| 184 | + syncManager.syncValue("import", i, syncHandler); |
| 185 | + return new ItemSlot() |
| 186 | + .syncHandler("import", i) |
| 187 | + .background(theme.getItemSlotTheme().getTheme().getBackground(), |
| 188 | + (i == 0) ? GTGuiTextures.PRIMITIVE_INGOT_OVERLAY : (i == 1) ? |
| 189 | + GTGuiTextures.PRIMITIVE_DUST_OVERLAY : |
| 190 | + GTGuiTextures.PRIMITIVE_FURNACE_OVERLAY); |
| 191 | + }) |
| 192 | + .build(); |
| 193 | + } |
| 194 | + |
| 195 | + private SlotGroupWidget createExportItemSlot(PanelSyncManager syncManager, ITheme theme) { |
| 196 | + int size = exportItems.storage.getSlots(); |
| 197 | + SlotGroup slotGroup = new SlotGroup("export", size); |
| 198 | + String[] matrix = new String[1]; |
| 199 | + char key = 'I'; |
| 200 | + matrix[0] = String.valueOf(key).repeat(size); |
| 201 | + return SlotGroupWidget.builder() |
| 202 | + .matrix(matrix) |
| 203 | + .key(key, i -> { |
| 204 | + ModularSlot slot = new ModularSlot(exportItems.storage, i); |
| 205 | + slot.accessibility(false, true); |
| 206 | + ItemSlotSyncHandler syncHandler = new ItemSlotSyncHandler(slot.slotGroup(slotGroup)); |
| 207 | + syncManager.syncValue("export", i, syncHandler); |
| 208 | + return new ItemSlot() |
| 209 | + .syncHandler("export", i) |
| 210 | + .background(theme.getItemSlotTheme().getTheme().getBackground(), |
| 211 | + (i == 0) ? GTGuiTextures.PRIMITIVE_INGOT_OVERLAY : |
| 212 | + GTGuiTextures.PRIMITIVE_DUST_OVERLAY); |
| 213 | + }) |
| 214 | + .build(); |
175 | 215 | } |
176 | 216 |
|
177 | 217 | @Override |
|
0 commit comments