Skip to content

Commit

Permalink
improve draw slightly
Browse files Browse the repository at this point in the history
fix defaults for StyledTextMixin
  • Loading branch information
ghzdude committed Nov 27, 2024
1 parent f529281 commit 3aaada1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/main/java/gregtech/common/mui/widget/GTFluidSlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public void drawBackground(ModularGuiContext context, WidgetTheme widgetTheme) {

@Override
public void draw(ModularGuiContext context, WidgetTheme widgetTheme) {
if (widgetTheme instanceof WidgetSlotTheme slotTheme) {
draw(context, slotTheme);
}
}

public void draw(ModularGuiContext context, WidgetSlotTheme widgetTheme) {
FluidStack content = this.syncHandler.getFluid();
if (content == null && this.syncHandler.canLockFluid())
content = this.syncHandler.getLockedFluid();
Expand All @@ -121,7 +127,7 @@ public void draw(ModularGuiContext context, WidgetTheme widgetTheme) {

if (isHovering()) {
GlStateManager.colorMask(true, true, true, false);
GuiDraw.drawRect(1, 1, getArea().w() - 2, getArea().h() - 2, getSlotHoverColor());
GuiDraw.drawRect(1, 1, getArea().w() - 2, getArea().h() - 2, widgetTheme.getSlotHoverColor());
GlStateManager.colorMask(true, true, true, true);
}
}
Expand Down Expand Up @@ -167,14 +173,6 @@ protected WidgetTheme getWidgetThemeInternal(ITheme theme) {
return theme.getFluidSlotTheme();
}

public int getSlotHoverColor() {
WidgetTheme theme = getWidgetTheme(getContext().getTheme());
if (theme instanceof WidgetSlotTheme slotTheme) {
return slotTheme.getSlotHoverColor();
}
return ITheme.getDefault().getFluidSlotTheme().getSlotHoverColor();
}

public static void addIngotMolFluidTooltip(FluidStack fluidStack, RichTooltip tooltip) {
// Add tooltip showing how many "ingot moles" (increments of 144) this fluid is if shift is held
if (TooltipHelper.isShiftDown() && fluidStack.amount > GTValues.L) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/gregtech/mixins/mui2/StyledTextMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = StyledText.class, remap = false)
public abstract class StyledTextMixin implements UnboxFix {
Expand Down Expand Up @@ -52,6 +54,16 @@ public abstract class StyledTextMixin implements UnboxFix {
gregTech$defaultShadow = b;
}

@Inject(method = "color", at = @At("HEAD"))
private void setDefault(int color, CallbackInfoReturnable<StyledText> cir) {
gregTech$useDefaultTextColor(false);
}

@Inject(method = "shadow", at = @At("HEAD"))
private void setDefault(boolean shadow, CallbackInfoReturnable<StyledText> cir) {
gregTech$useDefaultShadow(false);
}

/**
* @author GTCEu - Ghzdude
* @reason Implement <a href="https://github.com/CleanroomMC/ModularUI/pull/86">MUI2 PR#86</a>
Expand Down

0 comments on commit 3aaada1

Please sign in to comment.