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

Port Filters and some Covers to MUI + Filter Rework #2345

Merged
merged 260 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
260 commits
Select commit Hold shift + click to select a range
8981198
make panel creation in each filter instead of in the container
ghzdude Dec 31, 2023
4da2560
simplify filter panel creation
ghzdude Dec 31, 2023
21393d4
remove `sync()`
ghzdude Dec 31, 2023
159ba4d
fix simple item filters
ghzdude Dec 31, 2023
b2d7165
remove unused methods
ghzdude Dec 31, 2023
3027825
add PhantomItemSlot for the filter slot
ghzdude Dec 31, 2023
de77ca4
sync item filter stack
ghzdude Dec 31, 2023
bf2e34d
remap more methods to container
ghzdude Dec 31, 2023
5964f8f
more work and ui positioning
ghzdude Dec 31, 2023
ee75f4e
add ignore nbt and meta
ghzdude Dec 31, 2023
f7b2632
add method for slicing images
ghzdude Jan 1, 2024
9ebe3b7
flip tooltip states
ghzdude Jan 1, 2024
c11f62b
add buttons for conveyor mode
ghzdude Jan 1, 2024
26f39c5
add manual io gui overlay ?
ghzdude Jan 1, 2024
2c0bf12
improve manual io overlays
ghzdude Jan 2, 2024
998c6f8
fix issues with setting transfer rate in ui
ghzdude Jan 2, 2024
c6120ba
why you no position right ???
ghzdude Jan 2, 2024
c986d8c
make item filter text dynamic and center right
ghzdude Jan 2, 2024
d78f41e
move text to center right
ghzdude Jan 2, 2024
af95425
move and rename manual io overlay
ghzdude Jan 3, 2024
8f0abeb
add overlay for amount adjustment
ghzdude Jan 3, 2024
312fc41
add an int supplier to filter container
ghzdude Jan 3, 2024
bf932b1
add stack sizer to conveyor
ghzdude Jan 3, 2024
52d0af2
begin work on porting robot arm
ghzdude Jan 3, 2024
8dcf3c7
fix item filters as cover for now
ghzdude Jan 3, 2024
ac9cdd3
move construction of UI to `createUI()`
ghzdude Jan 3, 2024
d566ca8
flip string builder calls
ghzdude Jan 3, 2024
edc5d9a
add sync value for transfer stack size when blacklist
ghzdude Jan 3, 2024
235a839
try cache supplier value
ghzdude Jan 3, 2024
a7a95e5
rename variable
ghzdude Jan 3, 2024
ac4290d
add tooltip for filter stack count
ghzdude Jan 3, 2024
c6e27cf
set keep exact max stack size to int max
ghzdude Jan 3, 2024
527e819
improve ItemFilterContainer
ghzdude Jan 5, 2024
156c28c
add methods to FilterTypeRegistry
ghzdude Jan 11, 2024
aad52e2
use new methods in ItemFilterContainer
ghzdude Jan 11, 2024
f2ac6b1
fix CoverItemFilter with changes to filter system
ghzdude Jan 12, 2024
5ef8ccc
move filter data to subclass BaseFilterReader
ghzdude Jan 12, 2024
b4880bc
work of filter ui
ghzdude Jan 12, 2024
3fcee69
go back to phantom item slot
ghzdude Jan 12, 2024
558b726
update OreDictionaryItemFilter with filter reader
ghzdude Jan 12, 2024
62aaf9a
update SmartItemFilter with filter reader
ghzdude Jan 12, 2024
31f56be
wait that's not right
ghzdude Jan 12, 2024
9785f0e
rename ui creation
ghzdude Jan 12, 2024
0888049
add method for creating normal panel
ghzdude Jan 12, 2024
bbb4ec6
implement gui for cover item filter
ghzdude Jan 12, 2024
4dea5cc
add ui managers to item filters
ghzdude Jan 12, 2024
79f9fa4
set default stack sizer to return 1
ghzdude Jan 12, 2024
370fa61
more work on ui
ghzdude Jan 12, 2024
7e1a01d
buttons not adaptable enough
ghzdude Jan 12, 2024
8b184ad
create ui for SmartItemFilter
ghzdude Jan 12, 2024
d19d4bd
make filter registry not null
ghzdude Jan 12, 2024
4fd433e
make SmartFilterUIManager work
ghzdude Jan 12, 2024
9253730
widget position and some improvements
ghzdude Jan 12, 2024
cbf9a9d
make `createTitleRow()` in CoverWithUI public and static
ghzdude Jan 12, 2024
ec18df7
filter ui is 2/3 complete
ghzdude Jan 12, 2024
b49f96f
the oredict filter works now
ghzdude Jan 14, 2024
32172a2
add ore glob status
ghzdude Jan 14, 2024
1737831
add oredict images as gui textures
ghzdude Jan 14, 2024
2b6410c
fix lang
ghzdude Jan 14, 2024
eff7b1f
more work on ui (again)
ghzdude Jan 14, 2024
0a07a66
make title filter match other instances
ghzdude Jan 14, 2024
7ee2211
rework filter logic again
ghzdude Jan 14, 2024
6ffd5d5
try and read old nbt
ghzdude Jan 14, 2024
8a5b908
begin work on deprecating fluid filter wrapper
ghzdude Jan 14, 2024
106d74a
move base filter reader to new class
ghzdude Jan 14, 2024
c61915e
begin work on porting fluid filter to mui
ghzdude Jan 14, 2024
441708c
rename readers
ghzdude Jan 14, 2024
b0206c6
remove nbt write
ghzdude Jan 15, 2024
87e0ff1
fix fluid sync handler
ghzdude Jan 15, 2024
049fcc6
temporarily comment out nbt read/write
ghzdude Jan 15, 2024
b266a80
implement ui for fluid filter as cover, item
ghzdude Jan 15, 2024
46da40a
forgor
ghzdude Jan 15, 2024
5ad3e4c
change return to widget
ghzdude Jan 15, 2024
4e1fd83
more work on fluid filters
ghzdude Jan 15, 2024
868476d
all filters are now ported
ghzdude Jan 15, 2024
ea5b224
use Color instead of EnumDyeColor
ghzdude Jan 15, 2024
a4cf4c2
remove unused methods
ghzdude Jan 15, 2024
c462ee0
todo
ghzdude Jan 15, 2024
fe74917
use better check for shift
ghzdude Jan 15, 2024
5e6000a
add margin
ghzdude Jan 15, 2024
ebed385
more margin
ghzdude Jan 15, 2024
ea0c6f7
move common methods to CoverWithUI
ghzdude Jan 15, 2024
08cd23d
add more methods to CoverWithUI
ghzdude Jan 16, 2024
8423853
try and make fluid filter container similar to item container
ghzdude Jan 16, 2024
ff86052
make enum row creation into a builder
ghzdude Jan 16, 2024
14547f8
even more filter refactoring
ghzdude Jan 16, 2024
9fc7d52
more fixes from changes
ghzdude Jan 16, 2024
1efc372
more work on filters
ghzdude Jan 17, 2024
21a3db4
fix typo
ghzdude Jan 17, 2024
9ba301f
try fix fluid slot SH more
ghzdude Jan 17, 2024
216d5df
add bucket mode
ghzdude Jan 17, 2024
97a1766
use int instead of object
ghzdude Jan 17, 2024
444164d
use throughput as string
ghzdude Jan 17, 2024
6317422
classes affected by rename
ghzdude Jan 17, 2024
9efdd24
forgor bucket only methods
ghzdude Jan 17, 2024
52cbf66
i think fluid filters are done now?
ghzdude Jan 17, 2024
6f98718
shit
ghzdude Jan 17, 2024
e017159
add null check for lang
ghzdude Jan 18, 2024
e7b3304
set number to avoid number format exception
ghzdude Jan 18, 2024
b0a6c53
update synchandlers after creation
ghzdude Jan 18, 2024
2af4b8c
update synchandlers after creation
ghzdude Jan 18, 2024
ec0524d
small fixes for filter container
ghzdude Jan 18, 2024
b682296
add overlay for transfer modes
ghzdude Jan 18, 2024
1a204b3
move blacklist check to here
ghzdude Jan 18, 2024
98dc36d
add method to set size for overlays
ghzdude Jan 18, 2024
fb9656e
comment out old mui code (remove later)
ghzdude Jan 18, 2024
669ccb5
use lang for new ui
ghzdude Jan 18, 2024
d7a19ca
use text as bucket mode overlay
ghzdude Jan 18, 2024
c89deed
redundant locale keys
ghzdude Jan 18, 2024
b924e3b
match mui 2.4.1
ghzdude Jan 18, 2024
853c7a4
split ui creation behind if checks
ghzdude Jan 18, 2024
3cba0f1
work on porting item voiding covers
ghzdude Jan 18, 2024
632cfd2
add method for lang
ghzdude Jan 18, 2024
17d89a5
port item voiding + advanced covers
ghzdude Jan 18, 2024
d0b294c
fix missing space
ghzdude Jan 18, 2024
02b2b53
add methods for get/set transfer rate as string
ghzdude Jan 18, 2024
eed7d84
make sure button is set on init
ghzdude Jan 18, 2024
8b3be56
sync voiding mode
ghzdude Jan 18, 2024
4a4556a
properly handle stack when filter is blacklist
ghzdude Jan 19, 2024
fad7f3c
adjust height
ghzdude Jan 19, 2024
58f8ebb
set text field on init
ghzdude Jan 19, 2024
6132b6b
try fix weird throughput and bucket mode issues
ghzdude Jan 19, 2024
7601409
begin work on porting CoverEnderFluidLink
ghzdude Jan 19, 2024
5f4c943
CoverEnderFluidLink fully ported
ghzdude Jan 19, 2024
c78293e
use the right method, silly
ghzdude Jan 19, 2024
6ab019c
undo changes to PhantomFluidWidget
ghzdude Jan 19, 2024
421e444
mark classes as deprecated
ghzdude Jan 19, 2024
21bfc7f
fix lang issues with detector covers
ghzdude Jan 19, 2024
4355592
fix NPE crash
ghzdude Jan 19, 2024
70c44dc
remove onMatched
ghzdude Jan 19, 2024
c19ab81
sbobless
ghzdude Jan 19, 2024
dd06276
update MUI to 2.4.2
ghzdude Jan 19, 2024
d62cd69
remove commented out code
ghzdude Jan 20, 2024
9e3ffd6
flip backgrounds
ghzdude Jan 20, 2024
d371f92
remove IFilterMode and use IStringSerializable instead
ghzdude Jan 20, 2024
96db397
add separate icons for fluid transfer overlays
ghzdude Jan 20, 2024
1646082
yeet error panel
ghzdude Jan 20, 2024
9af2347
yeet old mui methods
ghzdude Jan 20, 2024
164609c
fix filters being voided on configuration
ghzdude Jan 20, 2024
d5bccab
add tooltip explanation for new behavior
ghzdude Jan 20, 2024
3950f65
flip background for SmartItemFilter
ghzdude Jan 20, 2024
14e6eb4
fix npe with oredict filter sync handler
ghzdude Jan 20, 2024
036ddd2
spopless
ghzdude Jan 20, 2024
05e2720
add shapeless recipe to clear filter nbt
ghzdude Jan 20, 2024
19fa182
add lang for item filter behavior
ghzdude Jan 22, 2024
018a9be
i did not mean to commit that
ghzdude Jan 22, 2024
91cb4a9
remove PhantomItemSlot.java, it's not necessary
ghzdude Jan 22, 2024
9a59590
add distribution mode for conveyors and robot arms
ghzdude Jan 22, 2024
3c9cabd
fix distribution appearing on item voiding covers
ghzdude Jan 22, 2024
ca5b580
actually set the filter correctly for filter covers
ghzdude Jan 22, 2024
1825014
sync value
ghzdude Jan 22, 2024
9581ea5
remove deprecated methods
ghzdude Jan 22, 2024
f4a9cb5
add voiding mode overlay
ghzdude Jan 22, 2024
76eae6e
sboblss
ghzdude Jan 22, 2024
df24355
remove bucket only
ghzdude Jan 27, 2024
df7b392
rename variable to be generic
ghzdude Jan 27, 2024
201ba20
move call to the correct place
ghzdude Jan 27, 2024
6cc4ae1
use `readByte` for small enums
ghzdude Jan 28, 2024
21baa01
log exception instead of throwing
ghzdude Jan 28, 2024
35accbc
missed `readByte()`
ghzdude Jan 28, 2024
2792699
add nullability annotations
ghzdude Jan 28, 2024
48fa469
add static final VALUES field
ghzdude Jan 28, 2024
e997258
more replacements with `writeByte()`
ghzdude Jan 28, 2024
708a096
more annotations
ghzdude Jan 28, 2024
261c82a
move stack reading to super into own method
ghzdude Jan 28, 2024
adc55f4
add deprecation comments for FilterTypeRegistry
ghzdude Jan 28, 2024
beb96c8
add deprecation comments for filter wrappers
ghzdude Jan 28, 2024
6f968c5
explain warning suppression
ghzdude Jan 28, 2024
8479de0
make class final and fields private final
ghzdude Jan 28, 2024
9e53f80
make methods static
ghzdude Jan 28, 2024
09152da
more deprecation comments
ghzdude Jan 28, 2024
21468c2
remove commented code
ghzdude Jan 28, 2024
1d14828
add todos
ghzdude Jan 28, 2024
e9ed14c
add nullability annotation to parameters
ghzdude Jan 28, 2024
3f6b23d
sbobless
ghzdude Jan 28, 2024
e3e995f
remove commented out code
ghzdude Jan 28, 2024
c969be3
make methods final
ghzdude Jan 28, 2024
1f6828f
more deprecation comments
ghzdude Jan 28, 2024
9aab563
sorry, permission to yeet filter wrappers granted
ghzdude Jan 29, 2024
3fee186
remove unused methods
ghzdude Jan 29, 2024
a980142
sptls pls
ghzdude Jan 29, 2024
12a659b
make default values net set nbt
ghzdude Jan 29, 2024
50eba08
properly handle reading legacy nbt
ghzdude Feb 4, 2024
fc333f8
fix filter not de/serializing properly as a cover
ghzdude Feb 4, 2024
bf5ecb2
mark dirty in more places
ghzdude Feb 4, 2024
6f1ddfc
sblss
ghzdude Feb 4, 2024
7691700
use `readByte()` in more places
ghzdude Feb 4, 2024
53ecc10
move count up to SimpleItemFilter
ghzdude Feb 5, 2024
5ba493d
add default impl for reading sync data
ghzdude Feb 5, 2024
829be79
pulled filter readers into their own classes
ghzdude Feb 6, 2024
9b8db59
spotless
ghzdude Feb 6, 2024
bac82c7
remove whitelist method
ghzdude Feb 6, 2024
9316afd
remove unused method
ghzdude Feb 6, 2024
fda9e70
pull filter related methods into FilterSlotHandler
ghzdude Feb 6, 2024
c189152
remove FilterSlotHandler and make the container a handler
ghzdude Feb 6, 2024
573c2c6
update usages to reflect changes
ghzdude Feb 6, 2024
7ad80d7
sync filter mode
ghzdude Feb 6, 2024
14792e5
sbobles pls
ghzdude Feb 6, 2024
8bc348a
rework FilterTypeRegistry to not use reflection
ghzdude Feb 6, 2024
92a0408
fix some issues with the registry
ghzdude Feb 6, 2024
d9a5ab8
oh boy another filter refactor
ghzdude Feb 7, 2024
e860675
fix trying to read an empty stack
ghzdude Feb 7, 2024
6a31ea9
rework FilterTypeRegistry to map to stacks instead if int ids
ghzdude Feb 8, 2024
69bb4da
sptoless
ghzdude Feb 8, 2024
64ed64c
use new methods
ghzdude Feb 8, 2024
6ea9da5
remove unneeded methods
ghzdude Feb 8, 2024
28e1cae
move default interface methods into base filter reader
ghzdude Feb 8, 2024
35e37d9
return stack form of coverable view instead of filter stack
ghzdude Feb 8, 2024
ae62f3b
no need to recompile on construction
ghzdude Feb 8, 2024
b5e4d93
properly handle insert and extract
ghzdude Feb 8, 2024
ac05117
fix issues with global limit slider
ghzdude Feb 8, 2024
f4ab6ea
spotless
ghzdude Feb 8, 2024
099e505
recompile oredict filter on instantiation
ghzdude Feb 10, 2024
8649dc1
move method from iface into BaseFilter
ghzdude Feb 10, 2024
d6f18a8
:waaaaah:
ghzdude Feb 11, 2024
7563d6d
add filter mode overlays
ghzdude Feb 11, 2024
9726849
add lang to item/fluid filters as covers
ghzdude Feb 11, 2024
11e8fb1
address reviews
ghzdude Feb 11, 2024
d3100d7
sbobless
ghzdude Feb 11, 2024
85e7dfc
use cycle button widget instead of toggle
ghzdude Feb 11, 2024
924ae73
also do item stack limit as 1
ghzdude Feb 11, 2024
da3835c
internal slot does not need glob
ghzdude Feb 11, 2024
700a7de
set match all for slots
ghzdude Feb 11, 2024
9cab06f
make "Conveyor Mode" into "IO Mode"
ghzdude Feb 12, 2024
59361be
sync transfer mode on set
ghzdude Feb 12, 2024
7d03926
use change listener instead of update
ghzdude Feb 18, 2024
2cfce25
mui 2.4.3 :lets:
ghzdude Mar 3, 2024
757acbb
address reviews
ghzdude Mar 3, 2024
63472eb
address reviews part 2
ghzdude Mar 3, 2024
62031ef
add icon for filter settings
ghzdude Mar 4, 2024
7ec7a75
forgor fluid container
ghzdude Mar 4, 2024
60899a1
rename filter settings
ghzdude Mar 4, 2024
c51a6b2
only show controls tooltip for robot arm or adv item voiding cover
ghzdude Mar 7, 2024
86076c8
fix an issue with global transfer limit slider
ghzdude Mar 7, 2024
1dcd18e
:servernotforrendering:
ghzdude Mar 7, 2024
e4976f3
try and cache the highlighted string
ghzdude Mar 7, 2024
f6f58fc
don't set fluid tag with an empty tag
ghzdude Mar 7, 2024
9a50a6f
ah shit, here we go again
ghzdude Mar 7, 2024
c4d0d4d
remove todo
ghzdude Mar 7, 2024
a0534e7
try to make failing to get a filter less aggressive
ghzdude Mar 20, 2024
9c54559
deprecate FilterTypeRegistry completey and add filters as a metaitem …
ghzdude Mar 23, 2024
91b9209
yeet FilterTypeRegistry.java
ghzdude Mar 23, 2024
bdfa1da
small change
ghzdude Mar 24, 2024
6335a05
fix legacy nbt reading for filter as cover
ghzdude Mar 25, 2024
0654d1b
read blacklist correctly
ghzdude Mar 27, 2024
bed55db
The Great NBT re-reading of 2024
ghzdude Mar 28, 2024
14a6af7
remove deprecated method
ghzdude Mar 30, 2024
ec86c14
sbobls
ghzdude Mar 30, 2024
4117298
change lang keys
ghzdude Mar 30, 2024
77c795a
save bucket mode
ghzdude Mar 30, 2024
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.4.1") { transitive = false }
api("com.cleanroommc:modularui:2.4.3") { transitive = false }
api("com.cleanroommc:groovyscript:0.8.0") { transitive = false }
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.684")
api rfg.deobf("curse.maven:ae2-extended-life-570458:4402048") // AE2UEL 0.55.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public static int assignId() {
public static final int UPDATE_AUTO_OUTPUT_FLUIDS = assignId();
public static final int UPDATE_IS_VOIDING = assignId();

// Robotic Arm
public static final int UPDATE_TRANSFER_MODE = assignId();

// Drum
public static final int UPDATE_AUTO_OUTPUT = assignId();

Expand Down
122 changes: 118 additions & 4 deletions src/main/java/gregtech/api/cover/CoverWithUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,33 @@

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;
import gregtech.api.mui.factory.CoverGuiFactory;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IStringSerializable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

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.ItemDrawable;
import com.cleanroommc.modularui.factory.SidedPosGuiData;
import com.cleanroommc.modularui.screen.ModularPanel;
import com.cleanroommc.modularui.screen.ModularScreen;
import com.cleanroommc.modularui.utils.Alignment;
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.GuiSyncManager;
import com.cleanroommc.modularui.value.sync.IntSyncValue;
import com.cleanroommc.modularui.widget.ParentWidget;
import com.cleanroommc.modularui.widgets.ToggleButton;
import com.cleanroommc.modularui.widgets.layout.Row;
import org.jetbrains.annotations.ApiStatus;

Expand Down Expand Up @@ -92,13 +98,12 @@ default void markAsDirty() {
/**
* Create the Title bar widget for a Cover.
*/
default Row createTitleRow() {
ItemStack item = getDefinition().getDropItemStack();
static Row createTitleRow(ItemStack stack) {
return new Row()
.pos(4, 4)
.height(16).coverChildrenWidth()
.child(new ItemDrawable(getDefinition().getDropItemStack()).asWidget().size(16).marginRight(4))
.child(IKey.str(item.getDisplayName()).color(UI_TITLE_COLOR).asWidget().heightRel(1.0f));
.child(new ItemDrawable(stack).asWidget().size(16).marginRight(4))
.child(IKey.str(stack.getDisplayName()).color(UI_TITLE_COLOR).asWidget().heightRel(1.0f));
}

/**
Expand All @@ -108,6 +113,31 @@ default ParentWidget<?> createSettingsRow() {
return new ParentWidget<>().height(16).widthRel(1.0f).marginBottom(2);
}

default int getIncrementValue(MouseData data) {
int adjust = 1;
if (data.shift) adjust *= 4;
if (data.ctrl) adjust *= 16;
if (data.alt) adjust *= 64;
return adjust;
}

default IKey createAdjustOverlay(boolean increment) {
final StringBuilder builder = new StringBuilder();
builder.append(increment ? '+' : '-');
builder.append(getIncrementValue(MouseData.create(-1)));

float scale = 1f;
if (builder.length() == 3) {
scale = 0.8f;
} else if (builder.length() == 4) {
scale = 0.6f;
} else if (builder.length() > 4) {
scale = 0.5f;
}
return IKey.str(builder.toString())
.scale(scale);
}

/**
* Get a BoolValue for use with toggle buttons which are "linked together,"
* meaning only one of them can be pressed at a time.
Expand All @@ -123,4 +153,88 @@ default <T extends Enum<T>> BoolValue.Dynamic boolValueOf(EnumSyncValue<T> syncV
default BoolValue.Dynamic boolValueOf(IntSyncValue syncValue, int value) {
return new BoolValue.Dynamic(() -> syncValue.getValue() == value, $ -> syncValue.setValue(value));
}

class EnumRowBuilder<T extends Enum<T>> {

private EnumSyncValue<T> syncValue;
private final Class<T> enumValue;
private String lang;
private IDrawable[] background;
private IDrawable selectedBackground;
private IDrawable[] overlay;

public EnumRowBuilder(Class<T> enumValue) {
this.enumValue = enumValue;
}

public EnumRowBuilder<T> value(EnumSyncValue<T> syncValue) {
this.syncValue = syncValue;
return this;
}

public EnumRowBuilder<T> lang(String lang) {
this.lang = lang;
return this;
}

public EnumRowBuilder<T> background(IDrawable... background) {
this.background = background;
return this;
}

public EnumRowBuilder<T> selectedBackground(IDrawable selectedBackground) {
this.selectedBackground = selectedBackground;
return this;
}

public EnumRowBuilder<T> overlay(IDrawable... overlay) {
this.overlay = overlay;
return this;
}

public EnumRowBuilder<T> overlay(int size, IDrawable... overlay) {
this.overlay = new IDrawable[overlay.length];
for (int i = 0; i < overlay.length; i++) {
this.overlay[i] = overlay[i].asIcon().size(size);
}
return this;
}

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);
if (this.enumValue != null && this.syncValue != null) {
for (var enumVal : enumValue.getEnumConstants()) {
var button = new ToggleButton().size(18).marginRight(2)
.value(boolValueOf(this.syncValue, enumVal));

if (this.background != null && this.background.length > 0)
button.background(this.background);
else
button.background(GTGuiTextures.MC_BUTTON);

if (this.selectedBackground != null)
button.selectedBackground(this.selectedBackground);
else
button.selectedBackground(GTGuiTextures.MC_BUTTON_DISABLED);

if (this.overlay != null)
button.overlay(this.overlay[enumVal.ordinal()]);

if (enumVal instanceof IStringSerializable serializable) {
button.addTooltipLine(IKey.lang(serializable.getName()));
}
row.child(button);
}
}

if (this.lang != null && !this.lang.isEmpty())
row.child(IKey.lang(this.lang).asWidget().align(Alignment.CenterRight).height(18));

return row;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import gregtech.api.gui.ingredient.IGhostIngredientTarget;
import gregtech.api.gui.ingredient.IIngredientSlot;
import gregtech.api.gui.resources.IGuiTexture;
import gregtech.api.util.*;
import gregtech.api.util.GTLog;
import gregtech.api.util.LocalizationUtils;
import gregtech.api.util.Position;
import gregtech.api.util.Size;
import gregtech.api.util.TextFormattingUtil;
import gregtech.client.utils.RenderUtil;
import gregtech.client.utils.TooltipHelper;

Expand Down
14 changes: 12 additions & 2 deletions src/main/java/gregtech/api/items/metaitem/MetaItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import gregtech.api.util.Mods;
import gregtech.client.utils.ToolChargeBarRenderer;
import gregtech.common.ConfigHolder;
import gregtech.common.covers.filter.IFilter;
import gregtech.common.creativetab.GTCreativeTabs;

import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -781,6 +782,7 @@ public MetaItem<T> getMetaItem() {
private final List<IItemBehaviour> behaviours = new ArrayList<>();
private IItemUseManager useManager;
private ItemUIFactory uiManager;
private IFilter.Factory filterBehavior;
private IItemColorProvider colorProvider;
private IItemDurabilityManager durabilityManager;
private IEnchantabilityHelper enchantabilityHelper;
Expand Down Expand Up @@ -908,9 +910,12 @@ protected void addItemComponentsInternal(IItemComponent... stats) {
if (itemComponent instanceof IFoodBehavior) {
this.useManager = new FoodUseManager((IFoodBehavior) itemComponent);
}
if (itemComponent instanceof ItemUIFactory)
if (itemComponent instanceof ItemUIFactory) {
this.uiManager = (ItemUIFactory) itemComponent;

}
if (itemComponent instanceof IFilter.Factory) {
this.filterBehavior = (IFilter.Factory) itemComponent;
}
if (itemComponent instanceof IItemColorProvider) {
this.colorProvider = (IItemColorProvider) itemComponent;
}
Expand Down Expand Up @@ -956,6 +961,11 @@ public ItemUIFactory getUIManager() {
return uiManager;
}

@Nullable
public IFilter.Factory getFilterFactory() {
return filterBehavior;
}

@Nullable
public IItemColorProvider getColorProvider() {
return colorProvider;
Expand Down
83 changes: 80 additions & 3 deletions src/main/java/gregtech/api/mui/GTGuiTextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* while MUI port is still ongoing. When MUI port is done, this annotation will be removed.
*/
// TODO ^
@SuppressWarnings("unused")
@ApiStatus.Experimental
public class GTGuiTextures {

Expand Down Expand Up @@ -153,6 +154,56 @@ public static class IDs {
.canApplyTheme()
.build();

public static final UITexture[] BUTTON_BLACKLIST = slice("textures/gui/widget/button_blacklist.png",
16, 32, 16, 16, true);
public static final UITexture[] BUTTON_IGNORE_DAMAGE = slice("textures/gui/widget/button_filter_damage.png",
16, 32, 16, 16, true);
public static final UITexture[] BUTTON_IGNORE_NBT = slice("textures/gui/widget/button_filter_nbt.png",
16, 32, 16, 16, true);

public static final UITexture[] BUTTON_CASE_SENSITIVE = slice(
"textures/gui/widget/ore_filter/button_case_sensitive.png",
16, 32, 16, 16, true);

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 OREDICT_ERROR = fullImage("textures/gui/widget/ore_filter/error.png");
public static final UITexture OREDICT_INFO = fullImage("textures/gui/widget/ore_filter/info.png");
public static final UITexture OREDICT_MATCH = fullImage("textures/gui/widget/ore_filter/match.png");
public static final UITexture OREDICT_NO_MATCH = fullImage("textures/gui/widget/ore_filter/no_match.png");
public static final UITexture OREDICT_SUCCESS = fullImage("textures/gui/widget/ore_filter/success.png");
public static final UITexture OREDICT_WAITING = fullImage("textures/gui/widget/ore_filter/waiting.png");
public static final UITexture OREDICT_WARN = fullImage("textures/gui/widget/ore_filter/warn.png");

public static final UITexture[] MANUAL_IO_OVERLAY = slice("textures/gui/overlay/manual_io_overlay.png",
18, 18 * 3, 18, 18, true);
public static final UITexture[] CONVEYOR_MODE_OVERLAY = slice("textures/gui/overlay/conveyor_mode_overlay.png",
18, 18 * 2, 18, 18, true);

public static final UITexture[] TRANSFER_MODE_OVERLAY = slice("textures/gui/overlay/transfer_mode_overlay.png",
18, 18 * 3, 18, 18, true);

public static final UITexture[] FLUID_TRANSFER_MODE_OVERLAY = slice(
"textures/gui/overlay/fluid_transfer_mode_overlay.png",
18, 18 * 3, 18, 18, true);

public static final UITexture[] DISTRIBUTION_MODE_OVERLAY = slice(
"textures/gui/widget/button_distribution_mode.png",
16, 48, 16, 16, true);

public static final UITexture[] VOIDING_MODE_OVERLAY = slice(
"textures/gui/overlay/voiding_mode_overlay.png",
16, 32, 16, 16, true);

public static final UITexture[] FILTER_MODE_OVERLAY = slice(
"textures/gui/overlay/filter_mode_overlay.png",
16, 48, 16, 16, true);

public static final UITexture[] PRIVATE_MODE_BUTTON = slice(
"textures/gui/widget/button_public_private.png",
18, 36, 18, 18, true);

// todo bronze/steel/primitive fluid slots?

// SLOT OVERLAYS
Expand Down Expand Up @@ -205,6 +256,9 @@ public static class IDs {
public static final UITexture EXTRACTOR_OVERLAY_STEEL = fullImage(
"textures/gui/overlay/extractor_overlay_steel.png");
public static final UITexture FILTER_SLOT_OVERLAY = fullImage("textures/gui/overlay/filter_slot_overlay.png", true);
public static final UITexture FILTER_SETTINGS_OVERLAY = fullImage(
"textures/gui/overlay/filter_settings_overlay.png",
true);
public static final UITexture FURNACE_OVERLAY_1 = fullImage("textures/gui/overlay/furnace_overlay_1.png", true);
public static final UITexture FURNACE_OVERLAY_2 = fullImage("textures/gui/overlay/furnace_overlay_2.png", true);
public static final UITexture FURNACE_OVERLAY_BRONZE = fullImage("textures/gui/overlay/furnace_overlay_bronze.png");
Expand Down Expand Up @@ -265,7 +319,7 @@ public static class IDs {
public static final UITexture BUTTON = new UITexture.Builder()
.location(GTValues.MODID, "textures/gui/widget/button.png")
.imageSize(18, 18)
.adaptable(1)
.adaptable(2)
.name(IDs.STANDARD_BUTTON)
.canApplyTheme()
.build();
Expand All @@ -274,13 +328,13 @@ public static class IDs {
.location("modularui", "gui/widgets/mc_button.png") // todo
.imageSize(16, 32)
.uv(0.0f, 0.0f, 1.0f, 0.5f)
.adaptable(1)
.adaptable(2)
.build();

public static final UITexture MC_BUTTON_DISABLED = new UITexture.Builder()
.location("modularui", "gui/widgets/mc_button_disabled.png") // todo
.imageSize(16, 16)
.adaptable(1)
.adaptable(2)
.build();

// BUTTON OVERLAYS
Expand Down Expand Up @@ -453,6 +507,29 @@ private static UITexture fullImage(String path, boolean canApplyTheme) {
return UITexture.fullImage(GTValues.MODID, path, canApplyTheme);
}

@SuppressWarnings("SameParameterValue")
private static UITexture[] slice(String path, int imageWidth, int imageHeight, int sliceWidth, int sliceHeight,
boolean canApplyTheme) {
if (imageWidth % sliceWidth != 0 || imageHeight % sliceHeight != 0)
throw new IllegalArgumentException("Slice height and slice width must divide the image evenly!");

int countX = imageWidth / sliceWidth;
int countY = imageHeight / sliceHeight;
UITexture[] slices = new UITexture[countX * countY];

for (int indexX = 0; indexX < countX; indexX++) {
for (int indexY = 0; indexY < countY; indexY++) {
slices[(indexX * countX) + indexY] = UITexture.builder()
.location(GTValues.MODID, path)
.canApplyTheme(canApplyTheme)
.imageSize(imageWidth, imageHeight)
.uv(indexX * sliceWidth, indexY * sliceHeight, sliceWidth, sliceHeight)
.build();
}
}
return slices;
}

private static UITexture progressBar(String path) {
return progressBar(path, 20, 40, false);
}
Expand Down
Loading
Loading