Skip to content

Commit 0dfce00

Browse files
committed
add hpca grid to screen
1 parent 11edc7a commit 0dfce00

File tree

6 files changed

+84
-0
lines changed

6 files changed

+84
-0
lines changed

src/main/java/gregtech/api/capability/IHPCAComponentHatch.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package gregtech.api.capability;
22

33
import gregtech.api.gui.resources.TextureArea;
4+
import gregtech.api.mui.GTGuiTextures;
5+
6+
import com.cleanroommc.modularui.drawable.UITexture;
47

58
public interface IHPCAComponentHatch {
69

@@ -46,5 +49,13 @@ default void setDamaged(boolean damaged) {}
4649
/**
4750
* The icon for this component in the HPCA's UI. Should be a 13x13 px sprite.
4851
*/
52+
@Deprecated
4953
TextureArea getComponentIcon();
54+
55+
/**
56+
* The icon for this component in the HPCA's UI. Should be a 13x13 px sprite.
57+
*/
58+
default UITexture getComponentIcon2() {
59+
return GTGuiTextures.HPCA_ICON_EMPTY_COMPONENT;
60+
}
5061
}

src/main/java/gregtech/api/mui/GTGuiTextures.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,25 @@ public static class IDs {
174174
.canApplyTheme()
175175
.build();
176176

177+
// HPCA Component icons
178+
public static final UITexture BLANK_TRANSPARENT = fullImage("textures/gui/base/blank_transparent.png");
179+
public static final UITexture HPCA_COMPONENT_OUTLINE = fullImage("textures/gui/widget/hpca/component_outline.png");
180+
public static final UITexture HPCA_ICON_EMPTY_COMPONENT = fullImage("textures/gui/widget/hpca/empty_component.png");
181+
public static final UITexture HPCA_ICON_ADVANCED_COMPUTATION_COMPONENT = fullImage(
182+
"textures/gui/widget/hpca/advanced_computation_component.png");
183+
public static final UITexture HPCA_ICON_BRIDGE_COMPONENT = fullImage(
184+
"textures/gui/widget/hpca/bridge_component.png");
185+
public static final UITexture HPCA_ICON_COMPUTATION_COMPONENT = fullImage(
186+
"textures/gui/widget/hpca/computation_component.png");
187+
public static final UITexture HPCA_ICON_ACTIVE_COOLER_COMPONENT = fullImage(
188+
"textures/gui/widget/hpca/active_cooler_component.png");
189+
public static final UITexture HPCA_ICON_HEAT_SINK_COMPONENT = fullImage(
190+
"textures/gui/widget/hpca/heat_sink_component.png");
191+
public static final UITexture HPCA_ICON_DAMAGED_ADVANCED_COMPUTATION_COMPONENT = fullImage(
192+
"textures/gui/widget/hpca/damaged_advanced_computation_component.png");
193+
public static final UITexture HPCA_ICON_DAMAGED_COMPUTATION_COMPONENT = fullImage(
194+
"textures/gui/widget/hpca/damaged_computation_component.png");
195+
177196
public static final UITexture[] BUTTON_BLACKLIST = slice("textures/gui/widget/button_blacklist.png",
178197
16, 32, 16, 16, true);
179198
public static final UITexture[] BUTTON_IGNORE_DAMAGE = slice("textures/gui/widget/button_filter_damage.png",

src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityHPCA.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@
5757
import codechicken.lib.vec.Matrix4;
5858
import com.cleanroommc.modularui.api.drawable.IDrawable;
5959
import com.cleanroommc.modularui.api.drawable.IKey;
60+
import com.cleanroommc.modularui.drawable.DynamicDrawable;
61+
import com.cleanroommc.modularui.drawable.UITexture;
6062
import com.cleanroommc.modularui.value.sync.DoubleSyncValue;
6163
import com.cleanroommc.modularui.value.sync.IntSyncValue;
6264
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
6365
import com.cleanroommc.modularui.widgets.ProgressWidget;
66+
import com.cleanroommc.modularui.widgets.layout.Grid;
6467
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
6568
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
6669
import org.jetbrains.annotations.NotNull;
@@ -455,6 +458,20 @@ protected void addErrorText(List<ITextComponent> textList) {
455458
}
456459
}
457460

461+
@Override
462+
protected MultiblockUIFactory createUIFactory() {
463+
return super.createUIFactory()
464+
.addScreenChildren(iWidgets -> iWidgets.add(new Grid()
465+
.coverChildren()
466+
.leftRel(0.5f)
467+
.bottom(4)
468+
.minElementMargin(1)
469+
.mapTo(3, 9, value -> new DynamicDrawable(() -> hpcaHandler.getComponentTexture2(value))
470+
.asWidget()
471+
// could add tooltips here showing the name of the component
472+
.size(18))));
473+
}
474+
458475
@Override
459476
protected void configureDisplayText(MultiblockUIFactory.Builder builder) {
460477
builder.setWorkingStatus(true, hpcaHandler.getAllocatedCWUt() > 0)
@@ -1018,13 +1035,21 @@ public void addErrors2(List<IDrawable> richText) {
10181035
}
10191036
}
10201037

1038+
@Deprecated
10211039
public TextureArea getComponentTexture(int index) {
10221040
if (components.size() <= index) {
10231041
return GuiTextures.BLANK_TRANSPARENT;
10241042
}
10251043
return components.get(index).getComponentIcon();
10261044
}
10271045

1046+
public UITexture getComponentTexture2(int index) {
1047+
if (components.size() <= index) {
1048+
return GTGuiTextures.BLANK_TRANSPARENT;
1049+
}
1050+
return components.get(index).getComponentIcon2();
1051+
}
1052+
10281053
public void tryGatherClientComponents(World world, BlockPos pos, EnumFacing frontFacing,
10291054
EnumFacing upwardsFacing, boolean flip) {
10301055
EnumFacing relativeUp = RelativeDirection.UP.getRelativeFacing(frontFacing, upwardsFacing, flip);

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/hpca/MetaTileEntityHPCABridge.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
import gregtech.api.gui.resources.TextureArea;
66
import gregtech.api.metatileentity.MetaTileEntity;
77
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
8+
import gregtech.api.mui.GTGuiTextures;
89
import gregtech.client.renderer.texture.Textures;
910
import gregtech.client.renderer.texture.cube.SimpleOverlayRenderer;
1011

1112
import net.minecraft.util.ResourceLocation;
1213

14+
import com.cleanroommc.modularui.drawable.UITexture;
15+
1316
public class MetaTileEntityHPCABridge extends MetaTileEntityHPCAComponent {
1417

1518
public MetaTileEntityHPCABridge(ResourceLocation metaTileEntityId) {
@@ -41,6 +44,11 @@ public TextureArea getComponentIcon() {
4144
return GuiTextures.HPCA_ICON_BRIDGE_COMPONENT;
4245
}
4346

47+
@Override
48+
public UITexture getComponentIcon2() {
49+
return GTGuiTextures.HPCA_ICON_BRIDGE_COMPONENT;
50+
}
51+
4452
@Override
4553
public SimpleOverlayRenderer getFrontActiveOverlay() {
4654
return Textures.HPCA_BRIDGE_ACTIVE_OVERLAY;

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/hpca/MetaTileEntityHPCAComputation.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
import gregtech.api.gui.resources.TextureArea;
77
import gregtech.api.metatileentity.MetaTileEntity;
88
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
9+
import gregtech.api.mui.GTGuiTextures;
910
import gregtech.client.renderer.texture.Textures;
1011
import gregtech.client.renderer.texture.cube.SimpleOverlayRenderer;
1112

1213
import net.minecraft.util.ResourceLocation;
1314

15+
import com.cleanroommc.modularui.drawable.UITexture;
16+
1417
public class MetaTileEntityHPCAComputation extends MetaTileEntityHPCAComponent implements IHPCAComputationProvider {
1518

1619
private final boolean advanced;
@@ -46,6 +49,16 @@ public TextureArea getComponentIcon() {
4649
GuiTextures.HPCA_ICON_COMPUTATION_COMPONENT;
4750
}
4851

52+
@Override
53+
public UITexture getComponentIcon2() {
54+
if (isDamaged()) {
55+
return advanced ? GTGuiTextures.HPCA_ICON_DAMAGED_ADVANCED_COMPUTATION_COMPONENT :
56+
GTGuiTextures.HPCA_ICON_DAMAGED_COMPUTATION_COMPONENT;
57+
}
58+
return advanced ? GTGuiTextures.HPCA_ICON_ADVANCED_COMPUTATION_COMPONENT :
59+
GTGuiTextures.HPCA_ICON_COMPUTATION_COMPONENT;
60+
}
61+
4962
@Override
5063
public SimpleOverlayRenderer getFrontActiveOverlay() {
5164
if (isDamaged())

src/main/java/gregtech/common/metatileentities/multi/multiblockpart/hpca/MetaTileEntityHPCACooler.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
import gregtech.api.gui.resources.TextureArea;
77
import gregtech.api.metatileentity.MetaTileEntity;
88
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
9+
import gregtech.api.mui.GTGuiTextures;
910
import gregtech.client.renderer.texture.Textures;
1011
import gregtech.client.renderer.texture.cube.SimpleOverlayRenderer;
1112

1213
import net.minecraft.util.ResourceLocation;
1314

15+
import com.cleanroommc.modularui.drawable.UITexture;
16+
1417
public class MetaTileEntityHPCACooler extends MetaTileEntityHPCAComponent implements IHPCACoolantProvider {
1518

1619
private final boolean advanced;
@@ -40,6 +43,11 @@ public TextureArea getComponentIcon() {
4043
return advanced ? GuiTextures.HPCA_ICON_ACTIVE_COOLER_COMPONENT : GuiTextures.HPCA_ICON_HEAT_SINK_COMPONENT;
4144
}
4245

46+
@Override
47+
public UITexture getComponentIcon2() {
48+
return advanced ? GTGuiTextures.HPCA_ICON_ACTIVE_COOLER_COMPONENT : GTGuiTextures.HPCA_ICON_HEAT_SINK_COMPONENT;
49+
}
50+
4351
@Override
4452
public SimpleOverlayRenderer getFrontActiveOverlay() {
4553
return advanced ? Textures.HPCA_ACTIVE_COOLER_ACTIVE_OVERLAY : getFrontOverlay();

0 commit comments

Comments
 (0)