UpDown button refactoring

This commit is contained in:
drcrazy 2019-08-28 15:40:42 +03:00
parent 0d68f794ae
commit 2518c32c54
3 changed files with 22 additions and 16 deletions

View file

@ -30,6 +30,7 @@ import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonUpDown;
import reborncore.client.gui.builder.widget.GuiButtonUpDown.UpDownButtonType;
import reborncore.common.network.NetworkManager;
import reborncore.common.powerSystem.PowerSystem;
import techreborn.packets.ServerboundPackets;
@ -46,10 +47,10 @@ public class GuiAESU extends GuiBase<BuiltContainer> {
@Override
public void init() {
addButton(new GuiButtonUpDown(left + 121, top + 79, this, b -> onClick(256)));
addButton(new GuiButtonUpDown(left + 121 + 12, top + 79, this, b -> onClick(64)));
addButton(new GuiButtonUpDown(left + 121 + 24, top + 79, this, b -> onClick(-64)));
addButton(new GuiButtonUpDown(left + 121 + 36, top + 79, this, b -> onClick(-256)));
addButton(new GuiButtonUpDown(left + 121, top + 79, this, b -> onClick(256), UpDownButtonType.FASTFORWARD));
addButton(new GuiButtonUpDown(left + 121 + 12, top + 79, this, b -> onClick(64), UpDownButtonType.FORWARD));
addButton(new GuiButtonUpDown(left + 121 + 24, top + 79, this, b -> onClick(-64), UpDownButtonType.REWIND));
addButton(new GuiButtonUpDown(left + 121 + 36, top + 79, this, b -> onClick(-256), UpDownButtonType.FASTREWIND));
}
@Override
@ -61,7 +62,6 @@ public class GuiAESU extends GuiBase<BuiltContainer> {
this.drawSlot(98, 45, layer);
this.drawArmourSlots(8, 18, layer);
this.builder.drawEnergyOutput(this, 155, 61, this.blockEntity.getCurrentOutput(), layer);
this.builder.drawUpDownButtons(this, 121, 79, layer);
}
@Override

View file

@ -28,6 +28,7 @@ import net.minecraft.entity.player.PlayerEntity;
import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonUpDown;
import reborncore.client.gui.builder.widget.GuiButtonUpDown.UpDownButtonType;
import reborncore.common.network.NetworkManager;
import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity;
import techreborn.packets.ServerboundPackets;
@ -41,6 +42,13 @@ public class GuiChunkLoader extends GuiBase<BuiltContainer> {
this.blockEntity = blockEntity;
}
public void init() {
addButton(new GuiButtonUpDown(left + 64, top + 40, this, b -> onClick(5), UpDownButtonType.FASTFORWARD));
addButton(new GuiButtonUpDown(left + 64 + 12, top + 40, this, b -> onClick(1), UpDownButtonType.FORWARD));
addButton(new GuiButtonUpDown(left + 64 + 24, top + 40, this, b -> onClick(-1), UpDownButtonType.REWIND));
addButton(new GuiButtonUpDown(left + 64 + 36, top + 40, this, b -> onClick(-5), UpDownButtonType.FASTREWIND));
}
@Override
protected void drawBackground(float partialTicks, int mouseX, int mouseY) {
super.drawBackground(partialTicks, mouseX, mouseY);
@ -48,7 +56,6 @@ public class GuiChunkLoader extends GuiBase<BuiltContainer> {
// Battery slot
drawSlot(8, 72, layer);
builder.drawUpDownButtons(this, 64, 40, layer);
if (GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE) {
return;
}
@ -62,10 +69,6 @@ public class GuiChunkLoader extends GuiBase<BuiltContainer> {
final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND;
builder.drawMultiEnergyBar(this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
addButton(new GuiButtonUpDown(left + 64, top + 40, this, b -> onClick(5)));
addButton(new GuiButtonUpDown(left + 64 + 12, top + 40, this, b -> onClick(1)));
addButton(new GuiButtonUpDown(left + 64 + 24, top + 40, this, b -> onClick(-1)));
addButton(new GuiButtonUpDown(left + 64 + 36, top + 40, this, b -> onClick(-5)));
}
public void onClick(int amount){

View file

@ -34,6 +34,7 @@ import reborncore.client.containerBuilder.builder.BuiltContainer;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.client.gui.builder.widget.GuiButtonUpDown;
import reborncore.client.gui.builder.widget.GuiButtonUpDown.UpDownButtonType;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockRenderEvent;
@ -57,6 +58,14 @@ public class GuiFusionReactor extends GuiBase<BuiltContainer> {
this.blockEntity = blockEntity;
}
@Override
public void init() {
addButton(new GuiButtonUpDown(left + 121, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(5), UpDownButtonType.FASTFORWARD));
addButton(new GuiButtonUpDown(left + 121 + 12, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(1), UpDownButtonType.FORWARD));
addButton(new GuiButtonUpDown(left + 121 + 24, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(-5), UpDownButtonType.REWIND));
addButton(new GuiButtonUpDown(left + 121 + 36, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(-1), UpDownButtonType.FASTREWIND));
}
@Override
protected void drawBackground(final float partialTicks, final int mouseX, final int mouseY) {
super.drawBackground(partialTicks, mouseX, mouseY);
@ -101,15 +110,9 @@ public class GuiFusionReactor extends GuiBase<BuiltContainer> {
}
}
builder.drawUpDownButtons(this, 121, 79, layer);
drawString("Size: " + blockEntity.size, 83, 81, 0xFFFFFF, layer);
drawString("" + blockEntity.getPowerMultiplier() + "x", 10, 81, 0xFFFFFF, layer);
addButton(new GuiButtonUpDown(left + 121, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(5)));
addButton(new GuiButtonUpDown(left + 121 + 12, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(1)));
addButton(new GuiButtonUpDown(left + 121 + 24, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(-5)));
addButton(new GuiButtonUpDown(left + 121 + 36, top + 79, this, (ButtonWidget buttonWidget) -> sendSizeChange(-1)));
builder.drawMultiEnergyBar(this, 9, 19, (int) this.blockEntity.getEnergy(), (int) this.blockEntity.getMaxPower(), mouseX, mouseY, 0, layer);
}