Centralized UI sprite and texture definitions.
This commit is contained in:
@@ -2,9 +2,7 @@ package li.cil.oc2.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import li.cil.oc2.api.API;
|
||||
import li.cil.oc2.client.gui.widget.ImageButton;
|
||||
import li.cil.oc2.client.gui.widget.Sprite;
|
||||
import li.cil.oc2.common.Constants;
|
||||
import li.cil.oc2.common.item.Items;
|
||||
import li.cil.oc2.common.network.Network;
|
||||
@@ -13,7 +11,6 @@ import li.cil.oc2.common.tileentity.BusCableTileEntity;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
@@ -21,14 +18,6 @@ import org.lwjgl.glfw.GLFW;
|
||||
import static li.cil.oc2.common.util.TranslationUtils.text;
|
||||
|
||||
public final class BusInterfaceScreen extends Screen {
|
||||
private static final ResourceLocation BACKGROUND_LOCATION = new ResourceLocation(API.MOD_ID, "textures/gui/screen/bus_interface.png");
|
||||
|
||||
private static final Sprite BACKGROUND = new Sprite(BACKGROUND_LOCATION, 256, 240, 30, 0, 0);
|
||||
private static final Sprite CONFIRM_BASE = new Sprite(BACKGROUND_LOCATION, 256, 12, 12, 5, 35);
|
||||
private static final Sprite CONFIRM_PRESSED = new Sprite(BACKGROUND_LOCATION, 256, 12, 12, 20, 35);
|
||||
private static final Sprite CANCEL_BASE = new Sprite(BACKGROUND_LOCATION, 256, 12, 12, 5, 50);
|
||||
private static final Sprite CANCEL_PRESSED = new Sprite(BACKGROUND_LOCATION, 256, 12, 12, 20, 50);
|
||||
|
||||
private static final int TEXT_LEFT = 9;
|
||||
private static final int TEXT_TOP = 11;
|
||||
private static final int CONFIRM_LEFT = 206;
|
||||
@@ -59,8 +48,8 @@ public final class BusInterfaceScreen extends Screen {
|
||||
|
||||
getMinecraft().keyboardHandler.setSendRepeatsToGui(true);
|
||||
|
||||
left = (width - BACKGROUND.width) / 2;
|
||||
top = (height - BACKGROUND.height) / 2;
|
||||
left = (width - Sprites.BUS_INTERFACE_SCREEN.width) / 2;
|
||||
top = (height - Sprites.BUS_INTERFACE_SCREEN.height) / 2;
|
||||
|
||||
nameField = new TextFieldWidget(font, left + TEXT_LEFT, top + TEXT_TOP, 192, 12, text("{mod}.gui.bus_interface_name"));
|
||||
nameField.setCanLoseFocus(false);
|
||||
@@ -74,11 +63,11 @@ public final class BusInterfaceScreen extends Screen {
|
||||
addButton(new ImageButton(
|
||||
this,
|
||||
left + CONFIRM_LEFT, top + CONFIRM_TOP,
|
||||
CONFIRM_BASE.width, CONFIRM_BASE.height,
|
||||
Sprites.CONFIRM_BASE.width, Sprites.CONFIRM_BASE.height,
|
||||
new TranslationTextComponent(Constants.TOOLTIP_CONFIRM),
|
||||
null,
|
||||
CONFIRM_BASE,
|
||||
CONFIRM_PRESSED
|
||||
Sprites.CONFIRM_BASE,
|
||||
Sprites.CONFIRM_PRESSED
|
||||
) {
|
||||
@Override
|
||||
public void onPress() {
|
||||
@@ -90,11 +79,11 @@ public final class BusInterfaceScreen extends Screen {
|
||||
addButton(new ImageButton(
|
||||
this,
|
||||
left + CANCEL_LEFT, top + CANCEL_TOP,
|
||||
CANCEL_BASE.width, CANCEL_BASE.height,
|
||||
Sprites.CANCEL_BASE.width, Sprites.CANCEL_BASE.height,
|
||||
new TranslationTextComponent(Constants.TOOLTIP_CANCEL),
|
||||
null,
|
||||
CANCEL_BASE,
|
||||
CANCEL_PRESSED
|
||||
Sprites.CANCEL_BASE,
|
||||
Sprites.CANCEL_PRESSED
|
||||
) {
|
||||
@Override
|
||||
public void onPress() {
|
||||
@@ -137,7 +126,7 @@ public final class BusInterfaceScreen extends Screen {
|
||||
@Override
|
||||
public void render(final MatrixStack matrixStack, final int mouseX, final int mouseY, final float partialTicks) {
|
||||
renderBackground(matrixStack);
|
||||
BACKGROUND.draw(matrixStack, left, top);
|
||||
Sprites.BUS_INTERFACE_SCREEN.draw(matrixStack, left, top);
|
||||
|
||||
super.render(matrixStack, mouseX, mouseY, partialTicks);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user