Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void createCoverUIRows(Flow column, SidedPosGuiData data, PanelSyncManage
GTMuiCoverUtil.addTransferModeRow(column, transferMode);

column.child(
GTMuiWidgets.createIntInputWithBucketMode(transferSize, transferBucketMode, () -> maxFluidTransferRate)
GTMuiWidgets.createIntInputWithBucketMode(transferSize, transferBucketMode, () -> Integer.MAX_VALUE)
.setEnabledIf($ -> shouldShowTransferSize()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,8 @@ public static ParentWidget<?> createIntInputWithBucketMode(IntSyncValue intSyncV
EnumSyncValue<BucketMode> bucketModeSyncValue,
IntSupplier maxMB) {
StringSyncValue formattedValue = new StringSyncValue(
() -> String.valueOf(intSyncValue.getValue()),
(v) -> intSyncValue.setValue(Integer.parseInt(v), true,
() -> formattedBucketValue(intSyncValue.getIntValue(), bucketModeSyncValue.getValue()),
(v) -> intSyncValue.setValue(bucketsFromFormattedValue(v, bucketModeSyncValue.getValue()), true,
true))
.allowC2S();

Expand Down Expand Up @@ -630,6 +630,20 @@ public boolean onMouseScrolled(double delta) {
.stateOverlay(1, BucketMode.MILLI_BUCKET.icon.asIcon().size(16)));
}

public static String formattedBucketValue(int millibuckets, BucketMode bucketMode) {
if (bucketMode == BucketMode.MILLI_BUCKET) return String.valueOf(millibuckets);
StringBuilder buckets = new StringBuilder(String.format("%04d", millibuckets));
buckets.insert(buckets.length() - 3, '.');
return buckets.toString();
}

public static int bucketsFromFormattedValue(String uiInput, BucketMode bucketMode) {
if (bucketMode == BucketMode.MILLI_BUCKET) return Integer.parseInt(uiInput);
if (!uiInput.contains(".")) return Integer.parseInt(uiInput) * 1000;
String[] splitInput = uiInput.split("\\.");
return (Integer.parseInt(splitInput[0]) * 1000) + Integer.parseInt(splitInput[1]);
}

public static SlotGroupWidget verticalPlayerInventory(SlotGroupWidget.SlotConsumer slotConsumer) {
SlotGroupWidget slotGroupWidget = new SlotGroupWidget();
slotGroupWidget.coverChildren();
Expand Down
Loading