Formatting fixes

This commit is contained in:
Sebastian Hartte
2020-07-19 23:50:47 +02:00
parent 4322910614
commit 8d92a51e4f
8 changed files with 25 additions and 31 deletions
@@ -1,10 +1,7 @@
package appeng.client.gui; package appeng.client.gui;
public enum NumberEntryType { public enum NumberEntryType {
CRAFT_ITEM_COUNT(Long.class), CRAFT_ITEM_COUNT(Long.class), PRIORITY(Long.class), LEVEL_ITEM_COUNT(Long.class), LEVEL_FLUID_VOLUME(Long.class);
PRIORITY(Long.class),
LEVEL_ITEM_COUNT(Long.class),
LEVEL_FLUID_VOLUME(Long.class);
private final Class<? extends Number> inputType; private final Class<? extends Number> inputType;
@@ -45,7 +45,8 @@ public class CraftAmountScreen extends AEBaseScreen<CraftAmountContainer> {
public void init() { public void init() {
super.init(); super.init();
this.amountToCraft = new NumberEntryWidget(this, 20, 30, 138, 62, NumberEntryType.CRAFT_ITEM_COUNT, value -> {}); this.amountToCraft = new NumberEntryWidget(this, 20, 30, 138, 62, NumberEntryType.CRAFT_ITEM_COUNT, value -> {
});
this.amountToCraft.setValue(1); this.amountToCraft.setValue(1);
this.amountToCraft.setTextFieldBounds(62, 57, 50); this.amountToCraft.setTextFieldBounds(62, 57, 50);
this.amountToCraft.setMinValue(1); this.amountToCraft.setMinValue(1);
@@ -49,7 +49,8 @@ public class LevelEmitterScreen extends UpgradeableScreen<LevelEmitterContainer>
public void init() { public void init() {
super.init(); super.init();
this.level = new NumberEntryWidget(this, 20, 17, 138, 62, NumberEntryType.LEVEL_ITEM_COUNT, this::onLevelChange); this.level = new NumberEntryWidget(this, 20, 17, 138, 62, NumberEntryType.LEVEL_ITEM_COUNT,
this::onLevelChange);
this.level.setTextFieldBounds(25, 44, 75); this.level.setTextFieldBounds(25, 44, 75);
this.level.addButtons(children::add, this::addButton); this.level.addButtons(children::add, this::addButton);
container.setTextField(this.level); container.setTextField(this.level);
@@ -13,8 +13,8 @@ import java.util.function.Consumer;
import java.util.function.LongConsumer; import java.util.function.LongConsumer;
/** /**
* A utility widget that consists of a text-field to enter a number with attached buttons to * A utility widget that consists of a text-field to enter a number with
* increment/decrement the number in fixed intervals. * attached buttons to increment/decrement the number in fixed intervals.
*/ */
public class NumberEntryWidget implements ITickingWidget { public class NumberEntryWidget implements ITickingWidget {
@@ -34,8 +34,7 @@ public class NumberEntryWidget implements ITickingWidget {
private Button minus100; private Button minus100;
private Button minus1000; private Button minus1000;
public NumberEntryWidget(AEBaseScreen<?> parent, int x, int y, int width, int height, public NumberEntryWidget(AEBaseScreen<?> parent, int x, int y, int width, int height, NumberEntryType type,
NumberEntryType type,
LongConsumer changeListener) { LongConsumer changeListener) {
this.parent = parent; this.parent = parent;
this.x = x; this.x = x;
@@ -87,24 +86,17 @@ public class NumberEntryWidget implements ITickingWidget {
int top = parent.getGuiTop() + y; int top = parent.getGuiTop() + y;
addButton.accept(this.plus1 = new Button(left, top, 22, 20, "+" + a, btn -> addQty(a))); addButton.accept(this.plus1 = new Button(left, top, 22, 20, "+" + a, btn -> addQty(a)));
addButton.accept( addButton.accept(this.plus10 = new Button(left + 28, top, 28, 20, "+" + b, btn -> addQty(b)));
this.plus10 = new Button(left + 28, top, 28, 20, "+" + b, btn -> addQty(b))); addButton.accept(this.plus100 = new Button(left + 62, top, 32, 20, "+" + c, btn -> addQty(c)));
addButton.accept( addButton.accept(this.plus1000 = new Button(left + 100, top, 38, 20, "+" + d, btn -> addQty(d)));
this.plus100 = new Button(left + 62, top, 32, 20, "+" + c, btn -> addQty(c)));
addButton.accept(
this.plus1000 = new Button(left + 100, top, 38, 20, "+" + d, btn -> addQty(d)));
// Placing this here will give a sensible tab order // Placing this here will give a sensible tab order
addChildren.accept(this.level); addChildren.accept(this.level);
addButton.accept( addButton.accept(this.minus1 = new Button(left, top + 42, 22, 20, "-" + a, btn -> addQty(-a)));
this.minus1 = new Button(left, top + 42, 22, 20, "-" + a, btn -> addQty(-a))); addButton.accept(this.minus10 = new Button(left + 28, top + 42, 28, 20, "-" + b, btn -> addQty(-b)));
addButton.accept( addButton.accept(this.minus100 = new Button(left + 62, top + 42, 32, 20, "-" + c, btn -> addQty(-c)));
this.minus10 = new Button(left + 28, top + 42, 28, 20, "-" + b, btn -> addQty(-b))); addButton.accept(this.minus1000 = new Button(left + 100, top + 42, 38, 20, "-" + d, btn -> addQty(-d)));
addButton.accept(
this.minus100 = new Button(left + 62, top + 42, 32, 20, "-" + c, btn -> addQty(-c)));
addButton.accept(
this.minus1000 = new Button(left + 100, top + 42, 38, 20, "-" + d, btn -> addQty(-d)));
} }
private void addQty(final long i) { private void addQty(final long i) {
@@ -52,7 +52,8 @@ public class PriorityScreen extends AEBaseScreen<PriorityContainer> {
} }
private void onPriorityChange(long priority) { private void onPriorityChange(long priority) {
NetworkHandler.instance().sendToServer(new ConfigValuePacket("PriorityHost.Priority", String.valueOf(priority))); NetworkHandler.instance()
.sendToServer(new ConfigValuePacket("PriorityHost.Priority", String.valueOf(priority)));
} }
@Override @Override
@@ -3,8 +3,8 @@ package appeng.client.gui.widgets;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
/** /**
* Indicates that a widget (anything that is in the {@link Screen#children()} list) should receive callbacks every * Indicates that a widget (anything that is in the {@link Screen#children()}
* tick. * list) should receive callbacks every tick.
*/ */
public interface ITickingWidget { public interface ITickingWidget {
@@ -128,7 +128,8 @@ public class NumberBox extends TextFieldWidget {
return true; return true;
} }
// Swallow key presses for numbers because they would otherwise trigger the hotbar swapping unintentionally // Swallow key presses for numbers because they would otherwise trigger the
// hotbar swapping unintentionally
return isFocused() && p_keyPressed_1_ >= '0' && p_keyPressed_1_ <= '9'; return isFocused() && p_keyPressed_1_ >= '0' && p_keyPressed_1_ <= '9';
} }
@@ -28,7 +28,8 @@ public class FluidLevelEmitterScreen extends UpgradeableScreen<FluidLevelEmitter
public void init() { public void init() {
super.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::onLevelChange);
this.level.setTextFieldBounds(25, 44, 75); this.level.setTextFieldBounds(25, 44, 75);
container.setTextField(this.level); container.setTextField(this.level);
this.level.addButtons(children::add, this::addButton); this.level.addButtons(children::add, this::addButton);