Skip to content

Commit d5b4f11

Browse files
authored
Update MUI2 dep to RC2 (#2622)
1 parent 9646d3a commit d5b4f11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1590
-755
lines changed

dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
dependencies {
4141
// Published dependencies
4242
api("codechicken:codechickenlib:3.2.3.358")
43-
api("com.cleanroommc:modularui:2.5.0-rc1") { transitive = false }
43+
api("com.cleanroommc:modularui:2.5.0-rc2") { transitive = false }
4444
api("com.cleanroommc:groovyscript:1.2.0-hotfix1") { transitive = false }
4545
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.700")
4646
api("appeng:ae2-uel:v0.56.4") { transitive = false }

src/main/java/gregtech/api/cover/CoverWithUI.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222
import com.cleanroommc.modularui.screen.ModularPanel;
2323
import com.cleanroommc.modularui.screen.ModularScreen;
2424
import com.cleanroommc.modularui.utils.Alignment;
25+
import com.cleanroommc.modularui.utils.Color;
2526
import com.cleanroommc.modularui.utils.MouseData;
2627
import com.cleanroommc.modularui.value.BoolValue;
2728
import com.cleanroommc.modularui.value.sync.EnumSyncValue;
2829
import com.cleanroommc.modularui.value.sync.IntSyncValue;
2930
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
3031
import com.cleanroommc.modularui.widget.ParentWidget;
3132
import com.cleanroommc.modularui.widgets.ToggleButton;
32-
import com.cleanroommc.modularui.widgets.layout.Row;
33+
import com.cleanroommc.modularui.widgets.layout.Flow;
3334
import org.jetbrains.annotations.ApiStatus;
3435

3536
public interface CoverWithUI extends Cover, IUIHolder, IGuiHolder<SidedPosGuiData> {
@@ -98,12 +99,14 @@ default void markAsDirty() {
9899
/**
99100
* Create the Title bar widget for a Cover.
100101
*/
101-
static Row createTitleRow(ItemStack stack) {
102-
return new Row()
102+
static Flow createTitleRow(ItemStack stack) {
103+
return Flow.row()
103104
.pos(4, 4)
104105
.height(16).coverChildrenWidth()
105106
.child(new ItemDrawable(stack).asWidget().size(16).marginRight(4))
106-
.child(IKey.str(stack.getDisplayName()).color(UI_TITLE_COLOR).asWidget().heightRel(1.0f));
107+
.child(IKey.str(stack.getDisplayName())
108+
.color(UI_TITLE_COLOR)
109+
.asWidget().heightRel(1.0f));
107110
}
108111

109112
/**
@@ -135,6 +138,7 @@ default IKey createAdjustOverlay(boolean increment) {
135138
scale = 0.5f;
136139
}
137140
return IKey.str(builder.toString())
141+
.color(Color.WHITE.main)
138142
.scale(scale);
139143
}
140144

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

207-
public Row build() {
208-
var row = new Row().marginBottom(2).coverChildrenHeight().widthRel(1f);
211+
public Flow build() {
212+
var row = Flow.row().marginBottom(2).coverChildrenHeight().widthRel(1f);
209213
if (this.enumValue != null && this.syncValue != null) {
210214
for (var enumVal : enumValue.getEnumConstants()) {
211215
var button = new ToggleButton().size(18).marginRight(2)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public static class IDs {
167167

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

171172
public static final UITexture OREDICT_ERROR = fullImage("textures/gui/widget/ore_filter/error.png");
172173
public static final UITexture OREDICT_INFO = fullImage("textures/gui/widget/ore_filter/info.png");

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import com.cleanroommc.modularui.api.ITheme;
1010
import com.cleanroommc.modularui.api.IThemeApi;
1111
import com.cleanroommc.modularui.drawable.UITexture;
12-
import com.cleanroommc.modularui.screen.Tooltip;
12+
import com.cleanroommc.modularui.screen.RichTooltip;
1313
import com.cleanroommc.modularui.theme.ReloadThemeEvent;
1414
import com.cleanroommc.modularui.utils.JsonBuilder;
1515
import org.jetbrains.annotations.Nullable;
@@ -108,7 +108,7 @@ public static void onReloadThemes(ReloadThemeEvent.Pre event) {
108108
public static Builder templateBuilder(String themeId) {
109109
Builder builder = new Builder(themeId);
110110
builder.openCloseAnimation(0);
111-
builder.tooltipPos(Tooltip.Pos.NEXT_TO_MOUSE);
111+
builder.tooltipPos(RichTooltip.Pos.NEXT_TO_MOUSE);
112112
builder.smoothProgressBar(true);
113113
return builder;
114114
}
@@ -163,7 +163,7 @@ public Builder smoothProgressBar(boolean smoothBar) {
163163
}
164164

165165
/** Set the tooltip pos for this theme. Overrides global cfg. */
166-
public Builder tooltipPos(Tooltip.Pos tooltipPos) {
166+
public Builder tooltipPos(RichTooltip.Pos tooltipPos) {
167167
theme.elementBuilder.add(b -> b.add("tooltipPos", tooltipPos.name()));
168168
return this;
169169
}

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

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
import net.minecraft.item.ItemStack;
1111

12-
import com.cleanroommc.modularui.api.widget.Interactable;
1312
import com.cleanroommc.modularui.factory.GuiManager;
1413
import com.cleanroommc.modularui.screen.ModularPanel;
1514
import com.cleanroommc.modularui.utils.Alignment;
@@ -19,6 +18,8 @@
1918

2019
public class GTGuis {
2120

21+
public static final int DEFAULT_WIDTH = 176, DEFAULT_HIEGHT = 166;
22+
2223
@ApiStatus.Internal
2324
public static void registerFactories() {
2425
GuiManager.registerFactory(MetaTileEntityGuiFactory.INSTANCE);
@@ -39,9 +40,35 @@ public static ModularPanel createPanel(Cover cover, int width, int height) {
3940
}
4041

4142
public static ModularPanel createPanel(ItemStack stack, int width, int height) {
42-
MetaItem<?>.MetaValueItem valueItem = ((MetaItem<?>) stack.getItem()).getItem(stack);
43-
if (valueItem == null) throw new IllegalArgumentException("Item must be a meta item!");
44-
return createPanel(valueItem.unlocalizedName, width, height);
43+
String locale;
44+
if (stack.getItem() instanceof MetaItem<?>metaItem) {
45+
var valueItem = metaItem.getItem(stack);
46+
if (valueItem == null) throw new IllegalArgumentException("Item must be a meta item!");
47+
locale = valueItem.unlocalizedName;
48+
} else {
49+
locale = stack.getTranslationKey();
50+
}
51+
return createPanel(locale, width, height);
52+
}
53+
54+
public static ModularPanel createPanel(String name) {
55+
return ModularPanel.defaultPanel(name, DEFAULT_WIDTH, DEFAULT_HIEGHT);
56+
}
57+
58+
public static ModularPanel defaultPanel(MetaTileEntity mte) {
59+
return createPanel(mte.metaTileEntityId.getPath());
60+
}
61+
62+
public static ModularPanel defaultPanel(Cover cover) {
63+
return createPanel(cover.getDefinition().getResourceLocation().getPath());
64+
}
65+
66+
public static ModularPanel defaultPanel(ItemStack stack) {
67+
return createPanel(stack, DEFAULT_WIDTH, DEFAULT_HIEGHT);
68+
}
69+
70+
public static ModularPanel defaultPanel(MetaItem<?>.MetaValueItem valueItem) {
71+
return createPanel(valueItem.unlocalizedName);
4572
}
4673

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

83+
public static ModularPanel defaultPopupPanel(String name) {
84+
return defaultPopupPanel(name, false, false);
85+
}
86+
87+
public static ModularPanel defaultPopupPanel(String name, boolean disableBelow,
88+
boolean closeOnOutsideClick) {
89+
return new PopupPanel(name, DEFAULT_WIDTH, DEFAULT_HIEGHT, disableBelow, closeOnOutsideClick);
90+
}
91+
5692
private static class PopupPanel extends ModularPanel {
5793

5894
private final boolean disableBelow;
@@ -67,7 +103,6 @@ public PopupPanel(@NotNull String name, int width, int height, boolean disableBe
67103
.onMousePressed(mouseButton -> {
68104
if (mouseButton == 0 || mouseButton == 1) {
69105
this.closeIfOpen(true);
70-
Interactable.playButtonClickSound();
71106
return true;
72107
}
73108
return false;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package gregtech.api.mui;
2+
3+
import com.cleanroommc.modularui.api.drawable.IDrawable;
4+
import com.cleanroommc.modularui.widgets.ToggleButton;
5+
6+
import java.util.function.Consumer;
7+
8+
public interface StateOverlay {
9+
10+
StateOverlay overlay(boolean selected, IDrawable... overlay);
11+
12+
StateOverlay hoverOverlay(boolean selected, IDrawable... overlay);
13+
14+
static ToggleButton cast(ToggleButton button, Consumer<StateOverlay> function) {
15+
function.accept((StateOverlay) button);
16+
return button;
17+
}
18+
19+
static ToggleButton create(Consumer<StateOverlay> function) {
20+
return cast(new ToggleButton(), function);
21+
}
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package gregtech.api.mui;
2+
3+
public interface UnboxFix {
4+
5+
void gregTech$useDefaultTextColor(boolean b);
6+
7+
void gregTech$useDefaultShadow(boolean b);
8+
}

src/main/java/gregtech/api/mui/sync/FixedFluidSlotSH.java

Lines changed: 0 additions & 150 deletions
This file was deleted.

0 commit comments

Comments
 (0)