-
Notifications
You must be signed in to change notification settings - Fork 204
Port Covers to Mui2 Part 2 #2700
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
Changes from all commits
fb7b8b1
f615a18
c2bc860
b20cfc2
21df8e7
cb10a24
f56fc49
68eda2e
411052d
2fecca8
fe5707b
7d4b255
9d57591
e82a5eb
54df137
76e71ee
90a4e1f
599f22d
8a3d514
603ea75
8487d25
8047f88
6b76e4b
778996a
7b4f75d
7447983
80eec6c
4fa7784
0f1bfb3
c869979
f92b357
93a29cc
afbfeef
ac69d8f
733d825
bb6a4ce
9f39747
e2e8b82
78b200b
2fe7a4e
8dd76cb
6d7cf81
d2aa861
93d5038
8dd1b37
bf5ede2
c52eaad
099672b
5a1f596
a87782c
34b9bda
564d328
52cdca5
3f4db58
9ae8103
1caad4e
354908b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,5 @@ | ||
| package gregtech.api.cover; | ||
|
|
||
| import gregtech.api.gui.IUIHolder; | ||
| import gregtech.api.gui.ModularUI; | ||
| import gregtech.api.mui.GTGuiTextures; | ||
| import gregtech.api.mui.GTGuiTheme; | ||
| import gregtech.api.mui.GregTechGuiScreen; | ||
|
|
@@ -17,6 +15,7 @@ | |
| import com.cleanroommc.modularui.api.IGuiHolder; | ||
| import com.cleanroommc.modularui.api.drawable.IDrawable; | ||
| import com.cleanroommc.modularui.api.drawable.IKey; | ||
| import com.cleanroommc.modularui.drawable.DynamicDrawable; | ||
| import com.cleanroommc.modularui.drawable.ItemDrawable; | ||
| import com.cleanroommc.modularui.factory.SidedPosGuiData; | ||
| import com.cleanroommc.modularui.screen.ModularPanel; | ||
|
|
@@ -30,30 +29,36 @@ | |
| import com.cleanroommc.modularui.value.sync.IntSyncValue; | ||
| import com.cleanroommc.modularui.value.sync.PanelSyncManager; | ||
| import com.cleanroommc.modularui.widget.ParentWidget; | ||
| import com.cleanroommc.modularui.widget.Widget; | ||
| import com.cleanroommc.modularui.widgets.ToggleButton; | ||
| import com.cleanroommc.modularui.widgets.layout.Flow; | ||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| import java.util.function.BooleanSupplier; | ||
| import java.util.function.Supplier; | ||
|
|
||
| public interface CoverWithUI extends Cover, IUIHolder, IGuiHolder<SidedPosGuiData> { | ||
| public interface CoverWithUI extends Cover, IGuiHolder<SidedPosGuiData>, gregtech.api.gui.IUIHolder { | ||
|
|
||
| @ApiStatus.Experimental | ||
| default boolean usesMui2() { | ||
ghzdude marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return false; | ||
| // this is gonna cause problems if implementing classes expect this to be false | ||
| // all of our covers use mui2 though | ||
| return true; | ||
| } | ||
|
|
||
| default void openUI(EntityPlayerMP player) { | ||
| if (usesMui2()) { | ||
| CoverGuiFactory.open(player, this); | ||
| } else { | ||
| // todo remove in 2.10 | ||
| CoverUIFactory.INSTANCE.openUI(this, player); | ||
| } | ||
| } | ||
|
|
||
| @Deprecated | ||
| default ModularUI createUI(EntityPlayer player) { | ||
| @ApiStatus.ScheduledForRemoval(inVersion = "2.10") | ||
| default gregtech.api.gui.ModularUI createUI(EntityPlayer player) { | ||
| return null; | ||
| } | ||
|
|
||
|
|
@@ -104,11 +109,22 @@ default void markAsDirty() { | |
| * Create the Title bar widget for a Cover. | ||
| */ | ||
| static Flow createTitleRow(ItemStack stack) { | ||
| return createTitleRow(() -> stack); | ||
| } | ||
|
|
||
| /** | ||
| * Create the Title bar widget for a Cover. | ||
| */ | ||
| static Flow createTitleRow(Supplier<ItemStack> stack) { | ||
| ItemDrawable itemDrawable = new ItemDrawable(); | ||
| return Flow.row() | ||
| .pos(4, 4) | ||
| .height(16).coverChildrenWidth() | ||
| .child(new ItemDrawable(stack).asWidget().size(16).marginRight(4)) | ||
| .child(IKey.str(stack.getDisplayName()) | ||
| .child(new Widget<>() | ||
| .overlay(new DynamicDrawable(() -> itemDrawable.setItem(stack.get()))) | ||
| .size(16) | ||
| .marginRight(4)) | ||
| .child(IKey.dynamic(() -> stack.get().getDisplayName()) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the name need to be dynamic? The only case I can think of for this is changing langs, but you have to close the UI to do that so the UI would get rebuilt with the correct lang even if it was not dynamic right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was part of my attempts to fix the filter popup panel before settling with the current solution since the panel is only built once, it needs to update based on what's in the filter slot, therefore it needs a supplier i could revert this change, though i'd probably add it back later in a different pr |
||
| .color(UI_TITLE_COLOR) | ||
| .asWidget().heightRel(1.0f)); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.