Skip to content

Commit

Permalink
update synchandlers after creation
Browse files Browse the repository at this point in the history
(part two)
  • Loading branch information
ghzdude committed Jan 18, 2024
1 parent 31d6e51 commit 7f9323c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/main/java/gregtech/common/covers/CoverConveyor.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gregtech.common.covers;

import com.cleanroommc.modularui.value.sync.StringSyncValue;

import gregtech.api.GTValues;
import gregtech.api.capability.GregtechDataCodes;
import gregtech.api.capability.GregtechTileCapabilities;
Expand Down Expand Up @@ -544,9 +546,13 @@ protected ParentWidget<Column> createUI(ModularPanel mainPanel, GuiSyncManager g
this::getConveyorMode, this::setConveyorMode);

IntSyncValue throughput = new IntSyncValue(this::getTransferRate, this::setTransferRate);
throughput.updateCacheFromSource(true);

StringSyncValue formattedThroughput = new StringSyncValue(throughput::getStringValue, throughput::setStringValue);

guiSyncManager.syncValue("manual_io", manualIOmode);
guiSyncManager.syncValue("conveyor_mode", conveyorMode);
guiSyncManager.syncValue("throughput", throughput);

return new Column().top(24).margin(7, 0)
.widthRel(1f).coverChildrenHeight()
Expand All @@ -555,7 +561,6 @@ protected ParentWidget<Column> createUI(ModularPanel mainPanel, GuiSyncManager g
.child(new ButtonWidget<>()
.left(0).width(18)
.onMousePressed(mouseButton -> {
throughput.updateCacheFromSource(false);
int val = throughput.getValue() - getIncrementValue(MouseData.create(mouseButton));
throughput.setValue(val, true, true);
Interactable.playButtonClickSound();
Expand All @@ -566,17 +571,11 @@ protected ParentWidget<Column> createUI(ModularPanel mainPanel, GuiSyncManager g
.left(18).right(18)
.setTextColor(Color.WHITE.darker(1))
.setNumbers(1, maxItemTransferRate)
.value(throughput)
.background(GTGuiTextures.DISPLAY)
.onUpdateListener(w -> {
if (throughput.updateCacheFromSource(false)) {
w.setText(throughput.getStringValue());
}
}))
.value(formattedThroughput)
.background(GTGuiTextures.DISPLAY))
.child(new ButtonWidget<>()
.right(0).width(18)
.onMousePressed(mouseButton -> {
throughput.updateCacheFromSource(false);
int val = throughput.getValue() + getIncrementValue(MouseData.create(mouseButton));
throughput.setValue(val, true, true);
Interactable.playButtonClickSound();
Expand Down

0 comments on commit 7f9323c

Please sign in to comment.