Skip to content

Commit

Permalink
Update MUI2 dep to RC2 (#2622)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghzdude authored Jan 6, 2025
1 parent 9646d3a commit d5b4f11
Show file tree
Hide file tree
Showing 49 changed files with 1,590 additions and 755 deletions.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
dependencies {
// Published dependencies
api("codechicken:codechickenlib:3.2.3.358")
api("com.cleanroommc:modularui:2.5.0-rc1") { transitive = false }
api("com.cleanroommc:modularui:2.5.0-rc2") { transitive = false }
api("com.cleanroommc:groovyscript:1.2.0-hotfix1") { transitive = false }
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.700")
api("appeng:ae2-uel:v0.56.4") { transitive = false }
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/gregtech/api/cover/CoverWithUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.screen.ModularScreen;
import com.cleanroommc.modularui.utils.Alignment;
import com.cleanroommc.modularui.utils.Color;
import com.cleanroommc.modularui.utils.MouseData;
import com.cleanroommc.modularui.value.BoolValue;
import com.cleanroommc.modularui.value.sync.EnumSyncValue;
import com.cleanroommc.modularui.value.sync.IntSyncValue;
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
import com.cleanroommc.modularui.widget.ParentWidget;
import com.cleanroommc.modularui.widgets.ToggleButton;
import com.cleanroommc.modularui.widgets.layout.Row;
import com.cleanroommc.modularui.widgets.layout.Flow;
import org.jetbrains.annotations.ApiStatus;

public interface CoverWithUI extends Cover, IUIHolder, IGuiHolder<SidedPosGuiData> {
Expand Down Expand Up @@ -98,12 +99,14 @@ default void markAsDirty() {
/**
* Create the Title bar widget for a Cover.
*/
static Row createTitleRow(ItemStack stack) {
return new Row()
static Flow createTitleRow(ItemStack stack) {
return Flow.row()
.pos(4, 4)
.height(16).coverChildrenWidth()
.child(new ItemDrawable(stack).asWidget().size(16).marginRight(4))
.child(IKey.str(stack.getDisplayName()).color(UI_TITLE_COLOR).asWidget().heightRel(1.0f));
.child(IKey.str(stack.getDisplayName())
.color(UI_TITLE_COLOR)
.asWidget().heightRel(1.0f));
}

/**
Expand Down Expand Up @@ -135,6 +138,7 @@ default IKey createAdjustOverlay(boolean increment) {
scale = 0.5f;
}
return IKey.str(builder.toString())
.color(Color.WHITE.main)
.scale(scale);
}

Expand Down Expand Up @@ -204,8 +208,8 @@ private BoolValue.Dynamic boolValueOf(EnumSyncValue<T> syncValue, T value) {
return new BoolValue.Dynamic(() -> syncValue.getValue() == value, $ -> syncValue.setValue(value));
}

public Row build() {
var row = new Row().marginBottom(2).coverChildrenHeight().widthRel(1f);
public Flow build() {
var row = Flow.row().marginBottom(2).coverChildrenHeight().widthRel(1f);
if (this.enumValue != null && this.syncValue != null) {
for (var enumVal : enumValue.getEnumConstants()) {
var button = new ToggleButton().size(18).marginRight(2)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/gregtech/api/mui/GTGuiTextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public static class IDs {

public static final UITexture[] BUTTON_MATCH_ALL = slice("textures/gui/widget/ore_filter/button_match_all.png",
16, 32, 16, 16, true);
public static final UITexture BUTTON_LOCK = fullImage("textures/gui/widget/button_lock.png");

public static final UITexture OREDICT_ERROR = fullImage("textures/gui/widget/ore_filter/error.png");
public static final UITexture OREDICT_INFO = fullImage("textures/gui/widget/ore_filter/info.png");
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/gregtech/api/mui/GTGuiTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.cleanroommc.modularui.api.ITheme;
import com.cleanroommc.modularui.api.IThemeApi;
import com.cleanroommc.modularui.drawable.UITexture;
import com.cleanroommc.modularui.screen.Tooltip;
import com.cleanroommc.modularui.screen.RichTooltip;
import com.cleanroommc.modularui.theme.ReloadThemeEvent;
import com.cleanroommc.modularui.utils.JsonBuilder;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -108,7 +108,7 @@ public static void onReloadThemes(ReloadThemeEvent.Pre event) {
public static Builder templateBuilder(String themeId) {
Builder builder = new Builder(themeId);
builder.openCloseAnimation(0);
builder.tooltipPos(Tooltip.Pos.NEXT_TO_MOUSE);
builder.tooltipPos(RichTooltip.Pos.NEXT_TO_MOUSE);
builder.smoothProgressBar(true);
return builder;
}
Expand Down Expand Up @@ -163,7 +163,7 @@ public Builder smoothProgressBar(boolean smoothBar) {
}

/** Set the tooltip pos for this theme. Overrides global cfg. */
public Builder tooltipPos(Tooltip.Pos tooltipPos) {
public Builder tooltipPos(RichTooltip.Pos tooltipPos) {
theme.elementBuilder.add(b -> b.add("tooltipPos", tooltipPos.name()));
return this;
}
Expand Down
45 changes: 40 additions & 5 deletions src/main/java/gregtech/api/mui/GTGuis.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import net.minecraft.item.ItemStack;

import com.cleanroommc.modularui.api.widget.Interactable;
import com.cleanroommc.modularui.factory.GuiManager;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.utils.Alignment;
Expand All @@ -19,6 +18,8 @@

public class GTGuis {

public static final int DEFAULT_WIDTH = 176, DEFAULT_HIEGHT = 166;

@ApiStatus.Internal
public static void registerFactories() {
GuiManager.registerFactory(MetaTileEntityGuiFactory.INSTANCE);
Expand All @@ -39,9 +40,35 @@ public static ModularPanel createPanel(Cover cover, int width, int height) {
}

public static ModularPanel createPanel(ItemStack stack, int width, int height) {
MetaItem<?>.MetaValueItem valueItem = ((MetaItem<?>) stack.getItem()).getItem(stack);
if (valueItem == null) throw new IllegalArgumentException("Item must be a meta item!");
return createPanel(valueItem.unlocalizedName, width, height);
String locale;
if (stack.getItem() instanceof MetaItem<?>metaItem) {
var valueItem = metaItem.getItem(stack);
if (valueItem == null) throw new IllegalArgumentException("Item must be a meta item!");
locale = valueItem.unlocalizedName;
} else {
locale = stack.getTranslationKey();
}
return createPanel(locale, width, height);
}

public static ModularPanel createPanel(String name) {
return ModularPanel.defaultPanel(name, DEFAULT_WIDTH, DEFAULT_HIEGHT);
}

public static ModularPanel defaultPanel(MetaTileEntity mte) {
return createPanel(mte.metaTileEntityId.getPath());
}

public static ModularPanel defaultPanel(Cover cover) {
return createPanel(cover.getDefinition().getResourceLocation().getPath());
}

public static ModularPanel defaultPanel(ItemStack stack) {
return createPanel(stack, DEFAULT_WIDTH, DEFAULT_HIEGHT);
}

public static ModularPanel defaultPanel(MetaItem<?>.MetaValueItem valueItem) {
return createPanel(valueItem.unlocalizedName);
}

public static ModularPanel createPopupPanel(String name, int width, int height) {
Expand All @@ -53,6 +80,15 @@ public static ModularPanel createPopupPanel(String name, int width, int height,
return new PopupPanel(name, width, height, disableBelow, closeOnOutsideClick);
}

public static ModularPanel defaultPopupPanel(String name) {
return defaultPopupPanel(name, false, false);
}

public static ModularPanel defaultPopupPanel(String name, boolean disableBelow,
boolean closeOnOutsideClick) {
return new PopupPanel(name, DEFAULT_WIDTH, DEFAULT_HIEGHT, disableBelow, closeOnOutsideClick);
}

private static class PopupPanel extends ModularPanel {

private final boolean disableBelow;
Expand All @@ -67,7 +103,6 @@ public PopupPanel(@NotNull String name, int width, int height, boolean disableBe
.onMousePressed(mouseButton -> {
if (mouseButton == 0 || mouseButton == 1) {
this.closeIfOpen(true);
Interactable.playButtonClickSound();
return true;
}
return false;
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/gregtech/api/mui/StateOverlay.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package gregtech.api.mui;

import com.cleanroommc.modularui.api.drawable.IDrawable;
import com.cleanroommc.modularui.widgets.ToggleButton;

import java.util.function.Consumer;

public interface StateOverlay {

StateOverlay overlay(boolean selected, IDrawable... overlay);

StateOverlay hoverOverlay(boolean selected, IDrawable... overlay);

static ToggleButton cast(ToggleButton button, Consumer<StateOverlay> function) {
function.accept((StateOverlay) button);
return button;
}

static ToggleButton create(Consumer<StateOverlay> function) {
return cast(new ToggleButton(), function);
}
}
8 changes: 8 additions & 0 deletions src/main/java/gregtech/api/mui/UnboxFix.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package gregtech.api.mui;

public interface UnboxFix {

void gregTech$useDefaultTextColor(boolean b);

void gregTech$useDefaultShadow(boolean b);
}
150 changes: 0 additions & 150 deletions src/main/java/gregtech/api/mui/sync/FixedFluidSlotSH.java

This file was deleted.

Loading

0 comments on commit d5b4f11

Please sign in to comment.