Skip to content

Commit 4165a5a

Browse files
committed
Fix certain slots not having an overlay due to the theme not being a WidgetSlotTheme
1 parent 8e25a8a commit 4165a5a

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

src/main/java/gregtech/client/utils/RenderUtil.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import com.cleanroommc.modularui.integration.jei.JeiGhostIngredientSlot;
3434
import com.cleanroommc.modularui.integration.jei.ModularUIJeiPlugin;
3535
import com.cleanroommc.modularui.theme.WidgetSlotTheme;
36+
import com.cleanroommc.modularui.theme.WidgetTheme;
37+
import com.cleanroommc.modularui.utils.Color;
3638
import org.jetbrains.annotations.NotNull;
3739
import org.jetbrains.annotations.Nullable;
3840
import org.lwjgl.opengl.GL11;
@@ -744,22 +746,25 @@ public static boolean handleJeiGhostOverlay(@NotNull IWidget slot) {
744746
*
745747
* @param slot the slot to draw the overlay above
746748
*/
747-
public static void drawSlotOverlay(@NotNull IWidget slot, @NotNull WidgetSlotTheme slotTheme) {
749+
public static void drawSlotOverlay(@NotNull IWidget slot, int overlayColor) {
748750
GlStateManager.colorMask(true, true, true, false);
749-
GuiDraw.drawRect(1, 1, slot.getArea().w() - 2, slot.getArea().h() - 2, slotTheme.getSlotHoverColor());
751+
GuiDraw.drawRect(1, 1, slot.getArea().w() - 2, slot.getArea().h() - 2, overlayColor);
750752
GlStateManager.colorMask(true, true, true, true);
751753
}
752754

755+
private static final int defaultSlotHoverColor = Color.withAlpha(Color.WHITE.main, 0x60);
756+
753757
/**
754758
* Handles drawing the green JEI overlay when dragging an item, and if no item is being dragged, the overlay when
755759
* mousing over the slot.
756760
*
757-
* @param slot the slot to draw the overlay above
758-
* @param slotTheme the theme to get the slot overlay color from
761+
* @param slot the slot to draw the overlay above
762+
* @param widgetTheme the theme to attempt to get the slot overlay color from
759763
*/
760-
public static void handleSlotOverlays(@NotNull IWidget slot, @NotNull WidgetSlotTheme slotTheme) {
764+
public static void handleSlotOverlay(@NotNull IWidget slot, @NotNull WidgetTheme widgetTheme) {
761765
if (!handleJeiGhostOverlay(slot) && slot.isHovering()) {
762-
drawSlotOverlay(slot, slotTheme);
766+
drawSlotOverlay(slot, widgetTheme instanceof WidgetSlotTheme slotTheme ? slotTheme.getSlotHoverColor() :
767+
defaultSlotHoverColor);
763768
}
764769
}
765770
}

src/main/java/gregtech/common/mui/widget/GTFluidSlot.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void draw(ModularGuiContext context, WidgetSlotTheme widgetTheme) {
115115
this.textRenderer.draw(amount);
116116
}
117117

118-
RenderUtil.handleSlotOverlays(this, widgetTheme);
118+
RenderUtil.handleSlotOverlay(this, widgetTheme);
119119
}
120120

121121
@Override

src/main/java/gregtech/common/mui/widget/workbench/CraftingInputSlot.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import com.cleanroommc.modularui.network.NetworkUtils;
1717
import com.cleanroommc.modularui.screen.RichTooltip;
1818
import com.cleanroommc.modularui.screen.viewport.ModularGuiContext;
19-
import com.cleanroommc.modularui.theme.WidgetSlotTheme;
2019
import com.cleanroommc.modularui.theme.WidgetTheme;
2120
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
2221
import com.cleanroommc.modularui.value.sync.SyncHandler;
@@ -111,9 +110,7 @@ public void draw(ModularGuiContext context, WidgetTheme widgetTheme) {
111110
RenderUtil.renderItem(itemstack, 1, 1, 16, 16);
112111
}
113112

114-
if (widgetTheme instanceof WidgetSlotTheme slotTheme) {
115-
RenderUtil.handleSlotOverlays(this, slotTheme);
116-
}
113+
RenderUtil.handleSlotOverlay(this, widgetTheme);
117114
}
118115

119116
@Override

src/main/java/gregtech/common/mui/widget/workbench/CraftingOutputSlot.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.cleanroommc.modularui.network.NetworkUtils;
2222
import com.cleanroommc.modularui.screen.RichTooltip;
2323
import com.cleanroommc.modularui.screen.viewport.ModularGuiContext;
24-
import com.cleanroommc.modularui.theme.WidgetSlotTheme;
2524
import com.cleanroommc.modularui.theme.WidgetTheme;
2625
import com.cleanroommc.modularui.utils.MouseData;
2726
import com.cleanroommc.modularui.value.sync.IntSyncValue;
@@ -74,12 +73,8 @@ public boolean isValidSyncHandler(SyncHandler syncHandler) {
7473
public void draw(ModularGuiContext context, WidgetTheme widgetTheme) {
7574
ItemStack itemstack = this.syncHandler.getOutputStack();
7675
if (itemstack.isEmpty()) return;
77-
7876
RenderUtil.renderItem(itemstack, 1, 1, 16, 16);
79-
80-
if (isHovering() && widgetTheme instanceof WidgetSlotTheme slotTheme) {
81-
RenderUtil.drawSlotOverlay(this, slotTheme);
82-
}
77+
RenderUtil.handleSlotOverlay(this, widgetTheme);
8378
}
8479

8580
@Override

src/main/java/gregtech/common/mui/widget/workbench/RecipeMemorySlot.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import com.cleanroommc.modularui.integration.jei.JeiIngredientProvider;
1414
import com.cleanroommc.modularui.screen.RichTooltip;
1515
import com.cleanroommc.modularui.screen.viewport.ModularGuiContext;
16-
import com.cleanroommc.modularui.theme.WidgetSlotTheme;
1716
import com.cleanroommc.modularui.theme.WidgetTheme;
1817
import com.cleanroommc.modularui.utils.MouseData;
1918
import com.cleanroommc.modularui.widget.Widget;
@@ -61,9 +60,7 @@ public void draw(ModularGuiContext context, WidgetTheme widgetTheme) {
6160
GlStateManager.enableDepth();
6261
}
6362

64-
if (isHovering() && widgetTheme instanceof WidgetSlotTheme slotTheme) {
65-
RenderUtil.drawSlotOverlay(this, slotTheme);
66-
}
63+
RenderUtil.handleSlotOverlay(this, widgetTheme);
6764
}
6865

6966
@Override

0 commit comments

Comments
 (0)