Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MUI2 dep to RC2 #2622

Merged
merged 63 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
55fd4f6
initial work to compile
ghzdude Sep 19, 2024
e7994aa
put out fires for now
ghzdude Sep 19, 2024
86850f7
rework ender covers to fit new version
ghzdude Sep 19, 2024
7f8d5db
pass in gui data instead of main panel
ghzdude Sep 19, 2024
99f2bc3
fix issues in GTFluidSlot
ghzdude Sep 19, 2024
d1222e7
move multi fluid hatches to mui2
ghzdude Sep 19, 2024
a5fd9f3
add more panel method overloads
ghzdude Sep 19, 2024
7ab5acf
add methods to GTFluidSlot
ghzdude Sep 19, 2024
f8dab58
fix ghost circuit slot tooltip
ghzdude Sep 19, 2024
153904c
add formatting methods for amount and fluid name
ghzdude Sep 20, 2024
08ab148
forgor to remove
ghzdude Sep 20, 2024
2a7392c
remove old ui
ghzdude Sep 21, 2024
1b429f6
improve GTGuis methods
ghzdude Sep 21, 2024
af7728e
fix issues with GTFluidSlot and cell behavior
ghzdude Sep 22, 2024
459be0c
spotless
ghzdude Sep 22, 2024
3c3f029
move FixedFluidSlotSH logic into GTFluidSyncHandler
ghzdude Oct 27, 2024
372f033
try to implement locking fluid to GTFluidSyncHandler
ghzdude Oct 28, 2024
f53ef3e
locking works now
ghzdude Oct 28, 2024
8104b03
simplify accessibility
ghzdude Oct 29, 2024
a2f7b93
no longer necessary
ghzdude Oct 29, 2024
cf0d22b
delete old mui code
ghzdude Oct 29, 2024
2288ed8
mixin to mui2 to fix various issues
ghzdude Nov 6, 2024
46c0a2a
more mixins, and actually apply them
ghzdude Nov 6, 2024
20c653b
don't remap, fix tests (grr)
ghzdude Nov 7, 2024
20f2490
fix dragging in certain conditions
ghzdude Nov 7, 2024
cc1ca09
update enderlink
ghzdude Nov 8, 2024
0617a14
simplify mixin
ghzdude Nov 8, 2024
d9adc0c
improve ui and fix entry settings
ghzdude Nov 8, 2024
bab658e
use fallback theme
ghzdude Nov 8, 2024
e62670d
fix check
ghzdude Nov 8, 2024
2326536
improve lock check
ghzdude Nov 11, 2024
c4b2c16
improve StateOverlay + mixin
ghzdude Nov 11, 2024
96d49ee
properly fix unboxing issue
ghzdude Nov 11, 2024
9b6cc8c
actually fix tooltip
ghzdude Nov 11, 2024
c80861e
improve draw slightly
ghzdude Nov 11, 2024
0e23ea4
switch to proper method
ghzdude Dec 6, 2024
17da4f7
properly fix draggable issue
ghzdude Dec 6, 2024
481e6af
fix locking button and tooltip
ghzdude Dec 6, 2024
f590473
fix fluid display
ghzdude Dec 6, 2024
1ebef64
allow draining from fluid slot
ghzdude Dec 6, 2024
565f4c1
fix show amount for regulator and voiding cover
ghzdude Dec 6, 2024
0fb21ad
set fluid amounts properly
ghzdude Dec 6, 2024
a31f28d
remove unused method
ghzdude Dec 6, 2024
007c4f0
make adjust overlay easier to see
ghzdude Dec 6, 2024
51dd868
spotless
ghzdude Dec 7, 2024
57441f5
simplify fluid display for hatch
ghzdude Dec 7, 2024
4398469
fix fluid locking
ghzdude Dec 8, 2024
ff78db4
null instead of empty string
ghzdude Dec 8, 2024
d4d70ac
mixin to stop jei "delete" tooltip
ghzdude Dec 8, 2024
3cf345f
add shift click to set and close panel
ghzdude Dec 9, 2024
2420dc3
spotless
ghzdude Dec 9, 2024
dd89b43
initialize locked fluid value
ghzdude Dec 18, 2024
1293915
sike, no need to initialize
ghzdude Dec 18, 2024
ef437b8
sync scroll to client
ghzdude Dec 19, 2024
fa8380b
rename and fix scroll sync
ghzdude Dec 19, 2024
03a2212
simplify absent compute
ghzdude Dec 28, 2024
7ab32ca
fix scrolling while over jei elements
ghzdude Dec 29, 2024
97405ab
add amount desc for fluid slots
ghzdude Dec 29, 2024
4fa7eb4
allow insert for import hatches
ghzdude Dec 29, 2024
fa2a854
draw calls are client only
ghzdude Dec 29, 2024
db29fe1
pass in defaults correctly
ghzdude Dec 31, 2024
0b532bf
properly fix lock flickering
ghzdude Jan 6, 2025
69df09a
sync locked handler fill to client
ghzdude Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
ghzdude marked this conversation as resolved.
Show resolved Hide resolved
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
Loading