2017-05-07 00:18:59 +00:00
|
|
|
/*
|
2017-05-01 13:32:39 +00:00
|
|
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
2021-01-06 17:13:40 +00:00
|
|
|
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
|
2017-05-01 13:32:39 +00:00
|
|
|
* Send enquiries to dratcliffe@gmail.com
|
|
|
|
*/
|
|
|
|
package dan200.computercraft.client.gui;
|
|
|
|
|
2020-01-22 11:14:30 +00:00
|
|
|
import com.mojang.blaze3d.systems.RenderSystem;
|
2017-05-01 13:32:39 +00:00
|
|
|
import dan200.computercraft.ComputerCraft;
|
2021-06-06 18:32:52 +00:00
|
|
|
import dan200.computercraft.client.gui.widgets.ComputerSidebar;
|
2017-05-01 13:32:39 +00:00
|
|
|
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
|
2021-06-06 18:32:52 +00:00
|
|
|
import dan200.computercraft.client.render.ComputerBorderRenderer;
|
2017-05-01 13:32:39 +00:00
|
|
|
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
|
|
|
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
2019-06-08 12:36:31 +00:00
|
|
|
import net.minecraft.entity.player.PlayerInventory;
|
2017-05-01 13:32:39 +00:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2019-06-08 12:36:31 +00:00
|
|
|
import net.minecraft.util.text.ITextComponent;
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2021-06-06 18:32:52 +00:00
|
|
|
import static dan200.computercraft.shared.turtle.inventory.ContainerTurtle.*;
|
|
|
|
|
2021-06-19 13:18:12 +00:00
|
|
|
public class GuiTurtle extends ComputerScreenBase<ContainerTurtle>
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2021-01-15 16:35:49 +00:00
|
|
|
private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/turtle_normal.png" );
|
|
|
|
private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/turtle_advanced.png" );
|
2018-12-23 16:55:25 +00:00
|
|
|
|
2021-06-19 13:18:12 +00:00
|
|
|
private static final int TEX_WIDTH = 254;
|
|
|
|
private static final int TEX_HEIGHT = 217;
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2021-01-15 16:35:49 +00:00
|
|
|
private final ComputerFamily family;
|
2018-12-23 16:55:25 +00:00
|
|
|
|
2019-06-09 07:58:49 +00:00
|
|
|
public GuiTurtle( ContainerTurtle container, PlayerInventory player, ITextComponent title )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2021-06-19 13:18:12 +00:00
|
|
|
super( container, player, title, BORDER );
|
2021-01-15 16:35:49 +00:00
|
|
|
family = container.getFamily();
|
2018-12-23 16:55:25 +00:00
|
|
|
|
2021-06-19 13:18:12 +00:00
|
|
|
imageWidth = TEX_WIDTH + ComputerSidebar.WIDTH;
|
|
|
|
imageHeight = TEX_HEIGHT;
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-06-19 13:18:12 +00:00
|
|
|
protected WidgetTerminal createTerminal()
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2021-06-19 13:18:12 +00:00
|
|
|
return new WidgetTerminal(
|
2021-06-06 18:32:52 +00:00
|
|
|
computer, leftPos + BORDER + ComputerSidebar.WIDTH, topPos + BORDER,
|
|
|
|
ComputerCraft.turtleTermWidth, ComputerCraft.turtleTermHeight
|
2021-06-19 13:18:12 +00:00
|
|
|
);
|
2019-06-21 19:31:28 +00:00
|
|
|
}
|
|
|
|
|
2017-05-01 14:48:44 +00:00
|
|
|
@Override
|
2021-01-09 19:22:58 +00:00
|
|
|
protected void renderBg( float partialTicks, int mouseX, int mouseY )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2021-01-15 16:35:49 +00:00
|
|
|
boolean advanced = family == ComputerFamily.ADVANCED;
|
2018-12-23 16:55:25 +00:00
|
|
|
|
2020-01-22 11:14:30 +00:00
|
|
|
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
2021-01-09 19:22:58 +00:00
|
|
|
minecraft.getTextureManager().bind( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL );
|
2021-06-19 13:18:12 +00:00
|
|
|
blit( leftPos + ComputerSidebar.WIDTH, topPos, 0, 0, TEX_WIDTH, TEX_HEIGHT );
|
2021-06-06 18:32:52 +00:00
|
|
|
|
|
|
|
minecraft.getTextureManager().bind( advanced ? ComputerBorderRenderer.BACKGROUND_ADVANCED : ComputerBorderRenderer.BACKGROUND_NORMAL );
|
2021-06-19 13:18:12 +00:00
|
|
|
ComputerSidebar.renderBackground( leftPos, topPos + sidebarYOffset );
|
2018-12-23 16:55:25 +00:00
|
|
|
|
2021-06-19 13:18:12 +00:00
|
|
|
int slot = getMenu().getSelectedSlot();
|
2021-06-06 18:32:52 +00:00
|
|
|
if( slot >= 0 )
|
|
|
|
{
|
|
|
|
RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
|
|
|
int slotX = slot % 4;
|
|
|
|
int slotY = slot / 4;
|
|
|
|
blit(
|
|
|
|
leftPos + TURTLE_START_X - 2 + slotX * 18, topPos + PLAYER_START_Y - 2 + slotY * 18,
|
|
|
|
0, 217, 24, 24
|
|
|
|
);
|
|
|
|
}
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
}
|