Improvements to the usability of the number entry widgets (Priority, Level Emitter, Craft Amount): (#4737)
- Fixed tab order - Introduced focus state for corner buttons - Allowed the player to enter any text, but add validation that only persist it if it is a valid number - Enter will now confirm these dialogs and return to the previous dialog - The text field is automatically focused and its contents are selected
This commit is contained in:
@@ -13,8 +13,6 @@ import appeng.client.gui.implementations.NumberEntryWidget;
|
||||
import appeng.client.gui.implementations.UpgradeableScreen;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
import appeng.fluids.client.gui.widgets.FluidSlotWidget;
|
||||
import appeng.fluids.container.FluidLevelEmitterContainer;
|
||||
|
||||
@@ -31,17 +29,24 @@ public class FluidLevelEmitterScreen extends UpgradeableScreen<FluidLevelEmitter
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.level = new NumberEntryWidget(this, 20, 17, 138, 62, NumberEntryType.LEVEL_FLUID_VOLUME,
|
||||
this::onLevelChange);
|
||||
this.level = new NumberEntryWidget(this, 20, 17, 138, 62, NumberEntryType.LEVEL_FLUID_VOLUME);
|
||||
this.level.setTextFieldBounds(25, 44, 75);
|
||||
container.setTextField(this.level);
|
||||
this.level.addButtons(children::add, this::addButton);
|
||||
this.level.setValue(container.getReportingValue());
|
||||
this.level.setOnChange(this::saveReportingValue);
|
||||
this.level.setOnConfirm(this::closeScreen);
|
||||
|
||||
this.changeFocus(true);
|
||||
|
||||
final int y = 40;
|
||||
final int x = 80 + 57;
|
||||
this.guiSlots.add(new FluidSlotWidget(this.container.getFluidConfigInventory(), 0, 0, x, y));
|
||||
}
|
||||
|
||||
private void saveReportingValue() {
|
||||
this.level.getLongValue().ifPresent(container::setReportingValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.redstoneMode = new ServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28,
|
||||
@@ -82,8 +87,4 @@ public class FluidLevelEmitterScreen extends UpgradeableScreen<FluidLevelEmitter
|
||||
protected void handleButtonVisibility() {
|
||||
}
|
||||
|
||||
private void onLevelChange(long level) {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("FluidLevelEmitter.Value", String.valueOf(level)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user