|
1 | 1 | package gregtech.client.utils; |
2 | 2 |
|
3 | 3 | import gregtech.api.gui.resources.TextureArea; |
4 | | -import gregtech.api.util.Mods; |
| 4 | +import gregtech.api.util.JEIUtil; |
5 | 5 |
|
6 | 6 | import net.minecraft.client.Minecraft; |
7 | 7 | import net.minecraft.client.gui.FontRenderer; |
|
29 | 29 | import codechicken.lib.vec.Matrix4; |
30 | 30 | import com.cleanroommc.modularui.api.MCHelper; |
31 | 31 | import com.cleanroommc.modularui.api.widget.IWidget; |
| 32 | +import com.cleanroommc.modularui.drawable.GuiDraw; |
32 | 33 | import com.cleanroommc.modularui.integration.jei.JeiGhostIngredientSlot; |
33 | | -import com.cleanroommc.modularui.integration.jei.ModularUIJeiPlugin; |
| 34 | +import com.cleanroommc.modularui.theme.WidgetSlotTheme; |
| 35 | +import com.cleanroommc.modularui.theme.WidgetTheme; |
| 36 | +import com.cleanroommc.modularui.utils.Color; |
34 | 37 | import org.jetbrains.annotations.NotNull; |
35 | 38 | import org.jetbrains.annotations.Nullable; |
36 | 39 | import org.lwjgl.opengl.GL11; |
|
43 | 46 | public class RenderUtil { |
44 | 47 |
|
45 | 48 | private static final Deque<int[]> scissorFrameStack = new ArrayDeque<>(); |
| 49 | + public static final int defaultSlotHoverColor = Color.withAlpha(Color.WHITE.main, 0x60); |
46 | 50 |
|
47 | 51 | public static void useScissor(int x, int y, int width, int height, Runnable codeBlock) { |
48 | 52 | pushScissorFrame(x, y, width, height); |
@@ -716,14 +720,39 @@ public void put(int element, float @NotNull... data) { |
716 | 720 | return getTextureMap().getMissingSprite(); |
717 | 721 | } |
718 | 722 |
|
719 | | - public static void handleJeiGhostHighlight(IWidget slot) { |
720 | | - if (!Mods.JustEnoughItems.isModLoaded()) return; |
721 | | - if (!(slot instanceof JeiGhostIngredientSlot<?>ingredientSlot)) return; |
722 | | - if (ModularUIJeiPlugin.hasDraggingGhostIngredient() || |
723 | | - ModularUIJeiPlugin.hoveringOverIngredient(ingredientSlot)) { |
724 | | - GlStateManager.colorMask(true, true, true, false); |
725 | | - ingredientSlot.drawHighlight(slot.getArea(), slot.isHovering()); |
726 | | - GlStateManager.colorMask(true, true, true, true); |
| 723 | + public static void drawSlotOverlay(@NotNull IWidget slot, int overlayColor) { |
| 724 | + GlStateManager.colorMask(true, true, true, false); |
| 725 | + GuiDraw.drawRect(1, 1, slot.getArea().w() - 2, slot.getArea().h() - 2, overlayColor); |
| 726 | + GlStateManager.colorMask(true, true, true, true); |
| 727 | + } |
| 728 | + |
| 729 | + public static void drawSlotOverlay(@NotNull IWidget slot, WidgetTheme widgetTheme) { |
| 730 | + drawSlotOverlay(slot, widgetTheme instanceof WidgetSlotTheme slotTheme ? slotTheme.getSlotHoverColor() : |
| 731 | + defaultSlotHoverColor); |
| 732 | + } |
| 733 | + |
| 734 | + public static void handleSlotOverlay(@NotNull IWidget slot, @NotNull WidgetTheme widgetTheme) { |
| 735 | + if (slot.isHovering()) { |
| 736 | + drawSlotOverlay(slot, widgetTheme); |
| 737 | + } |
| 738 | + } |
| 739 | + |
| 740 | + public static < |
| 741 | + T extends IWidget & JeiGhostIngredientSlot<?>> void drawJEIGhostSlotOverlay(@NotNull T jeiGhostIngredientSlot) { |
| 742 | + GlStateManager.colorMask(true, true, true, false); |
| 743 | + jeiGhostIngredientSlot.drawHighlight(jeiGhostIngredientSlot.getArea(), jeiGhostIngredientSlot.isHovering()); |
| 744 | + GlStateManager.colorMask(true, true, true, true); |
| 745 | + } |
| 746 | + |
| 747 | + public static < |
| 748 | + T extends IWidget & JeiGhostIngredientSlot<?>> boolean handleJEIGhostSlotOverlay(@NotNull T jeiGhostIngredientSlot, |
| 749 | + @NotNull WidgetTheme widgetTheme) { |
| 750 | + if (JEIUtil.hoveringOverIngredient(jeiGhostIngredientSlot)) { |
| 751 | + drawJEIGhostSlotOverlay(jeiGhostIngredientSlot); |
| 752 | + return true; |
727 | 753 | } |
| 754 | + |
| 755 | + handleSlotOverlay(jeiGhostIngredientSlot, widgetTheme); |
| 756 | + return false; |
728 | 757 | } |
729 | 758 | } |
0 commit comments