mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-02-09 07:30:04 +00:00
Add configuration options to control terminal sizes (#475)
This allows for configuring the size of computers and pocket computers, as well as the max size of monitors. There's several limitations with the current implementation, but it's still "good enough" for an initial release: - Turtles cannot be resized. - GUIs do not scale themselves, so "large" sizes will not render within the default resolution.
This commit is contained in:
parent
08181f72d4
commit
514db30fb1
@ -9,7 +9,7 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.google.code.gson:gson:2.8.1'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:3.0.169'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:3.0.179'
|
||||
classpath 'net.sf.proguard:proguard-gradle:6.1.0beta2'
|
||||
classpath 'org.ajoberstar.grgit:grgit-gradle:3.0.0'
|
||||
}
|
||||
|
@ -93,14 +93,17 @@ public final class ComputerCraft
|
||||
|
||||
public static boolean genericPeripheral = false;
|
||||
|
||||
public static final int terminalWidth_computer = 51;
|
||||
public static final int terminalHeight_computer = 19;
|
||||
public static int computerTermWidth = 51;
|
||||
public static int computerTermHeight = 19;
|
||||
|
||||
public static final int terminalWidth_turtle = 39;
|
||||
public static final int terminalHeight_turtle = 13;
|
||||
public static final int turtleTermWidth = 39;
|
||||
public static final int turtleTermHeight = 13;
|
||||
|
||||
public static final int terminalWidth_pocketComputer = 26;
|
||||
public static final int terminalHeight_pocketComputer = 20;
|
||||
public static int pocketTermWidth = 26;
|
||||
public static int pocketTermHeight = 20;
|
||||
|
||||
public static int monitorWidth = 8;
|
||||
public static int monitorHeight = 6;
|
||||
|
||||
public static final class TurtleUpgrades
|
||||
{
|
||||
|
@ -9,6 +9,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
|
||||
import dan200.computercraft.client.gui.widgets.WidgetWrapper;
|
||||
import dan200.computercraft.client.render.ComputerBorderRenderer;
|
||||
import dan200.computercraft.shared.computer.core.ClientComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.inventory.ContainerComputer;
|
||||
@ -17,21 +18,18 @@ import dan200.computercraft.shared.computer.inventory.ContainerViewComputer;
|
||||
import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import static dan200.computercraft.client.render.ComputerBorderRenderer.BORDER;
|
||||
import static dan200.computercraft.client.render.ComputerBorderRenderer.MARGIN;
|
||||
|
||||
public final class GuiComputer<T extends ContainerComputerBase> extends ContainerScreen<T>
|
||||
{
|
||||
public static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_normal.png" );
|
||||
public static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_advanced.png" );
|
||||
public static final ResourceLocation BACKGROUND_COMMAND = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_command.png" );
|
||||
public static final ResourceLocation BACKGROUND_COLOUR = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_colour.png" );
|
||||
|
||||
private final ComputerFamily m_family;
|
||||
private final ClientComputer m_computer;
|
||||
private final int m_termWidth;
|
||||
private final int m_termHeight;
|
||||
private final ComputerFamily family;
|
||||
private final ClientComputer computer;
|
||||
private final int termWidth;
|
||||
private final int termHeight;
|
||||
|
||||
private WidgetTerminal terminal;
|
||||
private WidgetWrapper terminalWrapper;
|
||||
@ -41,10 +39,10 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
||||
)
|
||||
{
|
||||
super( container, player, title );
|
||||
m_family = container.getFamily();
|
||||
m_computer = (ClientComputer) container.getComputer();
|
||||
m_termWidth = termWidth;
|
||||
m_termHeight = termHeight;
|
||||
family = container.getFamily();
|
||||
computer = (ClientComputer) container.getComputer();
|
||||
this.termWidth = termWidth;
|
||||
this.termHeight = termHeight;
|
||||
terminal = null;
|
||||
}
|
||||
|
||||
@ -52,7 +50,7 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
||||
{
|
||||
return new GuiComputer<>(
|
||||
container, inventory, component,
|
||||
ComputerCraft.terminalWidth_computer, ComputerCraft.terminalHeight_computer
|
||||
ComputerCraft.computerTermWidth, ComputerCraft.computerTermHeight
|
||||
);
|
||||
}
|
||||
|
||||
@ -60,7 +58,7 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
||||
{
|
||||
return new GuiComputer<>(
|
||||
container, inventory, component,
|
||||
ComputerCraft.terminalWidth_pocketComputer, ComputerCraft.terminalHeight_pocketComputer
|
||||
ComputerCraft.pocketTermWidth, ComputerCraft.pocketTermHeight
|
||||
);
|
||||
}
|
||||
|
||||
@ -78,16 +76,16 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
||||
{
|
||||
minecraft.keyboardListener.enableRepeatEvents( true );
|
||||
|
||||
int termPxWidth = m_termWidth * FixedWidthFontRenderer.FONT_WIDTH;
|
||||
int termPxHeight = m_termHeight * FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
int termPxWidth = termWidth * FixedWidthFontRenderer.FONT_WIDTH;
|
||||
int termPxHeight = termHeight * FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
|
||||
xSize = termPxWidth + 4 + 24;
|
||||
ySize = termPxHeight + 4 + 24;
|
||||
xSize = termPxWidth + MARGIN * 2 + BORDER * 2;
|
||||
ySize = termPxHeight + MARGIN * 2 + BORDER * 2;
|
||||
|
||||
super.init();
|
||||
|
||||
terminal = new WidgetTerminal( minecraft, () -> m_computer, m_termWidth, m_termHeight, 2, 2, 2, 2 );
|
||||
terminalWrapper = new WidgetWrapper( terminal, 2 + 12 + guiLeft, 2 + 12 + guiTop, termPxWidth, termPxHeight );
|
||||
terminal = new WidgetTerminal( minecraft, () -> computer, termWidth, termHeight, MARGIN, MARGIN, MARGIN, MARGIN );
|
||||
terminalWrapper = new WidgetWrapper( terminal, MARGIN + BORDER + guiLeft, MARGIN + BORDER + guiTop, termPxWidth, termPxHeight );
|
||||
|
||||
children.add( terminalWrapper );
|
||||
setFocused( terminalWrapper );
|
||||
@ -124,41 +122,16 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
|
||||
@Override
|
||||
public void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY )
|
||||
{
|
||||
// Work out where to draw
|
||||
int startX = terminalWrapper.getX() - 2;
|
||||
int startY = terminalWrapper.getY() - 2;
|
||||
int endX = startX + terminalWrapper.getWidth() + 4;
|
||||
int endY = startY + terminalWrapper.getHeight() + 4;
|
||||
|
||||
// Draw terminal
|
||||
terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() );
|
||||
|
||||
// Draw a border around the terminal
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
switch( m_family )
|
||||
{
|
||||
case NORMAL:
|
||||
default:
|
||||
minecraft.getTextureManager().bindTexture( BACKGROUND_NORMAL );
|
||||
break;
|
||||
case ADVANCED:
|
||||
minecraft.getTextureManager().bindTexture( BACKGROUND_ADVANCED );
|
||||
break;
|
||||
case COMMAND:
|
||||
minecraft.getTextureManager().bindTexture( BACKGROUND_COMMAND );
|
||||
break;
|
||||
}
|
||||
|
||||
blit( startX - 12, startY - 12, 12, 28, 12, 12 );
|
||||
blit( startX - 12, endY, 12, 40, 12, 12 );
|
||||
blit( endX, startY - 12, 24, 28, 12, 12 );
|
||||
blit( endX, endY, 24, 40, 12, 12 );
|
||||
|
||||
blit( startX, startY - 12, 0, 0, endX - startX, 12 );
|
||||
blit( startX, endY, 0, 12, endX - startX, 12 );
|
||||
|
||||
blit( startX - 12, startY, 0, 28, 12, endY - startY );
|
||||
blit( endX, startY, 36, 28, 12, endY - startY );
|
||||
RenderSystem.color4f( 1, 1, 1, 1 );
|
||||
minecraft.getTextureManager().bindTexture( ComputerBorderRenderer.getTexture( family ) );
|
||||
ComputerBorderRenderer.render(
|
||||
terminalWrapper.getX() - MARGIN, terminalWrapper.getY() - MARGIN, getBlitOffset(),
|
||||
terminalWrapper.getWidth() + MARGIN * 2, terminalWrapper.getHeight() + MARGIN * 2
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,13 +49,13 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
|
||||
super.init();
|
||||
minecraft.keyboardListener.enableRepeatEvents( true );
|
||||
|
||||
int termPxWidth = ComputerCraft.terminalWidth_turtle * FixedWidthFontRenderer.FONT_WIDTH;
|
||||
int termPxHeight = ComputerCraft.terminalHeight_turtle * FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
int termPxWidth = ComputerCraft.turtleTermWidth * FixedWidthFontRenderer.FONT_WIDTH;
|
||||
int termPxHeight = ComputerCraft.turtleTermHeight * FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
|
||||
terminal = new WidgetTerminal(
|
||||
minecraft, () -> m_computer,
|
||||
ComputerCraft.terminalWidth_turtle,
|
||||
ComputerCraft.terminalHeight_turtle,
|
||||
ComputerCraft.turtleTermWidth,
|
||||
ComputerCraft.turtleTermHeight,
|
||||
2, 2, 2, 2
|
||||
);
|
||||
terminalWrapper = new WidgetWrapper( terminal, 2 + 8 + guiLeft, 2 + 8 + guiTop, termPxWidth, termPxHeight );
|
||||
|
@ -0,0 +1,175 @@
|
||||
/*
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.render;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ComputerBorderRenderer
|
||||
{
|
||||
public static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_normal.png" );
|
||||
public static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_advanced.png" );
|
||||
public static final ResourceLocation BACKGROUND_COMMAND = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_command.png" );
|
||||
public static final ResourceLocation BACKGROUND_COLOUR = new ResourceLocation( ComputerCraft.MOD_ID, "textures/gui/corners_colour.png" );
|
||||
|
||||
private static final Matrix4f IDENTITY = new Matrix4f();
|
||||
|
||||
static
|
||||
{
|
||||
IDENTITY.setIdentity();
|
||||
}
|
||||
|
||||
/**
|
||||
* The margin between the terminal and its border.
|
||||
*/
|
||||
public static final int MARGIN = 2;
|
||||
|
||||
/**
|
||||
* The width of the terminal border.
|
||||
*/
|
||||
public static final int BORDER = 12;
|
||||
|
||||
private static final int CORNER_TOP_Y = 28;
|
||||
private static final int CORNER_BOTTOM_Y = CORNER_TOP_Y + BORDER;
|
||||
private static final int CORNER_LEFT_X = BORDER;
|
||||
private static final int CORNER_RIGHT_X = CORNER_LEFT_X + BORDER;
|
||||
private static final int BORDER_RIGHT_X = 36;
|
||||
private static final int GAP = 4;
|
||||
|
||||
private static final float TEX_SCALE = 1 / 256.0f;
|
||||
|
||||
private final Matrix4f transform;
|
||||
private final IVertexBuilder builder;
|
||||
private final int z;
|
||||
private final float r, g, b;
|
||||
|
||||
public ComputerBorderRenderer( Matrix4f transform, IVertexBuilder builder, int z, float r, float g, float b )
|
||||
{
|
||||
this.transform = transform;
|
||||
this.builder = builder;
|
||||
this.z = z;
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
|
||||
@Nonnull
|
||||
public static ResourceLocation getTexture( @Nonnull ComputerFamily family )
|
||||
{
|
||||
switch( family )
|
||||
{
|
||||
case NORMAL:
|
||||
default:
|
||||
return BACKGROUND_NORMAL;
|
||||
case ADVANCED:
|
||||
return BACKGROUND_ADVANCED;
|
||||
case COMMAND:
|
||||
return BACKGROUND_COMMAND;
|
||||
}
|
||||
}
|
||||
|
||||
public static void render( int x, int y, int z, int width, int height )
|
||||
{
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX );
|
||||
|
||||
render( IDENTITY, buffer, x, y, z, width, height );
|
||||
|
||||
RenderSystem.enableAlphaTest();
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
public static void render( Matrix4f transform, IVertexBuilder buffer, int x, int y, int z, int width, int height )
|
||||
{
|
||||
render( transform, buffer, x, y, z, width, height, 1, 1, 1 );
|
||||
}
|
||||
|
||||
public static void render( Matrix4f transform, IVertexBuilder buffer, int x, int y, int z, int width, int height, float r, float g, float b )
|
||||
{
|
||||
render( transform, buffer, x, y, z, width, height, 0, r, g, b );
|
||||
}
|
||||
|
||||
public static void render( Matrix4f transform, IVertexBuilder buffer, int x, int y, int z, int width, int height, int borderHeight, float r, float g, float b )
|
||||
{
|
||||
new ComputerBorderRenderer( transform, buffer, z, r, g, b ).doRender( x, y, width, height, borderHeight );
|
||||
}
|
||||
|
||||
public void doRender( int x, int y, int width, int height, int bottomHeight )
|
||||
{
|
||||
int endX = x + width;
|
||||
int endY = y + height;
|
||||
|
||||
// Vertical bars
|
||||
renderLine( x - BORDER, y, 0, CORNER_TOP_Y, BORDER, endY - y );
|
||||
renderLine( endX, y, BORDER_RIGHT_X, CORNER_TOP_Y, BORDER, endY - y );
|
||||
|
||||
// Top bar
|
||||
renderLine( x, y - BORDER, 0, 0, endX - x, BORDER );
|
||||
renderCorner( x - BORDER, y - BORDER, CORNER_LEFT_X, CORNER_TOP_Y );
|
||||
renderCorner( endX, y - BORDER, CORNER_RIGHT_X, CORNER_TOP_Y );
|
||||
|
||||
// Bottom bar. We allow for drawing a stretched version, which allows for additional elements (such as the
|
||||
// pocket computer's lights).
|
||||
if( bottomHeight <= 0 )
|
||||
{
|
||||
renderLine( x, endY, 0, BORDER, endX - x, BORDER );
|
||||
renderCorner( x - BORDER, endY, CORNER_LEFT_X, CORNER_BOTTOM_Y );
|
||||
renderCorner( endX, endY, CORNER_RIGHT_X, CORNER_BOTTOM_Y );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Bottom left, middle, right. We do this in three portions: the top inner corners, an extended region for
|
||||
// lights, and then the bottom outer corners.
|
||||
renderTexture( x - BORDER, endY, CORNER_LEFT_X, CORNER_BOTTOM_Y, BORDER, BORDER / 2 );
|
||||
renderTexture( x, endY, 0, BORDER, width, BORDER / 2, BORDER, BORDER / 2 );
|
||||
renderTexture( endX, endY, CORNER_RIGHT_X, CORNER_BOTTOM_Y, BORDER, BORDER / 2 );
|
||||
|
||||
renderTexture( x - BORDER, endY + BORDER / 2, CORNER_LEFT_X, CORNER_BOTTOM_Y + GAP, BORDER, bottomHeight, BORDER, GAP );
|
||||
renderTexture( x, endY + BORDER / 2, 0, BORDER + GAP, width, bottomHeight, BORDER, GAP );
|
||||
renderTexture( endX, endY + BORDER / 2, CORNER_RIGHT_X, CORNER_BOTTOM_Y + GAP, BORDER, bottomHeight, BORDER, GAP );
|
||||
|
||||
renderTexture( x - BORDER, endY + bottomHeight + BORDER / 2, CORNER_LEFT_X, CORNER_BOTTOM_Y + BORDER / 2, BORDER, BORDER / 2 );
|
||||
renderTexture( x, endY + bottomHeight + BORDER / 2, 0, BORDER + BORDER / 2, width, BORDER / 2 );
|
||||
renderTexture( endX, endY + bottomHeight + BORDER / 2, CORNER_RIGHT_X, CORNER_BOTTOM_Y + BORDER / 2, BORDER, BORDER / 2 );
|
||||
}
|
||||
}
|
||||
|
||||
private void renderCorner( int x, int y, int u, int v )
|
||||
{
|
||||
renderTexture( x, y, u, v, BORDER, BORDER, BORDER, BORDER );
|
||||
}
|
||||
|
||||
private void renderLine( int x, int y, int u, int v, int width, int height )
|
||||
{
|
||||
renderTexture( x, y, u, v, width, height, BORDER, BORDER );
|
||||
}
|
||||
|
||||
private void renderTexture( int x, int y, int u, int v, int width, int height )
|
||||
{
|
||||
renderTexture( x, y, u, v, width, height, width, height );
|
||||
}
|
||||
|
||||
private void renderTexture( int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight )
|
||||
{
|
||||
builder.pos( transform, x, y + height, z ).color( r, g, b, 1.0f ).tex( u * TEX_SCALE, (v + textureHeight) * TEX_SCALE ).endVertex();
|
||||
builder.pos( transform, x + width, y + height, z ).color( r, g, b, 1.0f ).tex( (u + textureWidth) * TEX_SCALE, (v + textureHeight) * TEX_SCALE ).endVertex();
|
||||
builder.pos( transform, x + width, y, z ).color( r, g, b, 1.0f ).tex( (u + textureWidth) * TEX_SCALE, v * TEX_SCALE ).endVertex();
|
||||
builder.pos( transform, x, y, z ).color( r, g, b, 1.0f ).tex( u * TEX_SCALE, v * TEX_SCALE ).endVertex();
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ package dan200.computercraft.client.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
@ -27,7 +26,8 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH;
|
||||
import static dan200.computercraft.client.gui.GuiComputer.*;
|
||||
import static dan200.computercraft.client.render.ComputerBorderRenderer.BORDER;
|
||||
import static dan200.computercraft.client.render.ComputerBorderRenderer.MARGIN;
|
||||
|
||||
/**
|
||||
* Emulates map rendering for pocket computers.
|
||||
@ -35,8 +35,6 @@ import static dan200.computercraft.client.gui.GuiComputer.*;
|
||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
|
||||
public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
||||
{
|
||||
private static final int MARGIN = 2;
|
||||
private static final int FRAME = 12;
|
||||
private static final int LIGHT_HEIGHT = 8;
|
||||
|
||||
private static final ItemPocketRenderer INSTANCE = new ItemPocketRenderer();
|
||||
@ -67,8 +65,8 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
||||
int termWidth, termHeight;
|
||||
if( terminal == null )
|
||||
{
|
||||
termWidth = ComputerCraft.terminalWidth_pocketComputer;
|
||||
termHeight = ComputerCraft.terminalHeight_pocketComputer;
|
||||
termWidth = ComputerCraft.pocketTermWidth;
|
||||
termHeight = ComputerCraft.pocketTermHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -86,7 +84,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
||||
transform.rotate( Vector3f.ZP.rotationDegrees( 180f ) );
|
||||
transform.scale( 0.5f, 0.5f, 0.5f );
|
||||
|
||||
float scale = 0.75f / Math.max( width + FRAME * 2, height + FRAME * 2 + LIGHT_HEIGHT );
|
||||
float scale = 0.75f / Math.max( width + BORDER * 2, height + BORDER * 2 + LIGHT_HEIGHT );
|
||||
transform.scale( scale, scale, 0 );
|
||||
transform.translate( -0.5 * width, -0.5 * height, 0 );
|
||||
|
||||
@ -117,10 +115,8 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
||||
|
||||
private static void renderFrame( Matrix4f transform, ComputerFamily family, int colour, int width, int height )
|
||||
{
|
||||
Minecraft.getInstance().getTextureManager().bindTexture( colour != -1
|
||||
? BACKGROUND_COLOUR
|
||||
: family == ComputerFamily.NORMAL ? BACKGROUND_NORMAL : BACKGROUND_ADVANCED
|
||||
);
|
||||
Minecraft.getInstance().getTextureManager()
|
||||
.bindTexture( colour != -1 ? ComputerBorderRenderer.BACKGROUND_COLOUR : ComputerBorderRenderer.getTexture( family ) );
|
||||
|
||||
float r = ((colour >>> 16) & 0xFF) / 255.0f;
|
||||
float g = ((colour >>> 8) & 0xFF) / 255.0f;
|
||||
@ -130,28 +126,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR_TEX );
|
||||
|
||||
// Top left, middle, right
|
||||
renderTexture( transform, buffer, -FRAME, -FRAME, 12, 28, FRAME, FRAME, r, g, b );
|
||||
renderTexture( transform, buffer, 0, -FRAME, 0, 0, width, FRAME, r, g, b );
|
||||
renderTexture( transform, buffer, width, -FRAME, 24, 28, FRAME, FRAME, r, g, b );
|
||||
|
||||
// Left and bright border
|
||||
renderTexture( transform, buffer, -FRAME, 0, 0, 28, FRAME, height, r, g, b );
|
||||
renderTexture( transform, buffer, width, 0, 36, 28, FRAME, height, r, g, b );
|
||||
|
||||
// Bottom left, middle, right. We do this in three portions: the top inner corners, an extended region for
|
||||
// lights, and then the bottom outer corners.
|
||||
renderTexture( transform, buffer, -FRAME, height, 12, 40, FRAME, FRAME / 2, r, g, b );
|
||||
renderTexture( transform, buffer, 0, height, 0, 12, width, FRAME / 2, r, g, b );
|
||||
renderTexture( transform, buffer, width, height, 24, 40, FRAME, FRAME / 2, r, g, b );
|
||||
|
||||
renderTexture( transform, buffer, -FRAME, height + FRAME / 2, 12, 44, FRAME, LIGHT_HEIGHT, FRAME, 4, r, g, b );
|
||||
renderTexture( transform, buffer, 0, height + FRAME / 2, 0, 16, width, LIGHT_HEIGHT, FRAME, 4, r, g, b );
|
||||
renderTexture( transform, buffer, width, height + FRAME / 2, 24, 44, FRAME, LIGHT_HEIGHT, FRAME, 4, r, g, b );
|
||||
|
||||
renderTexture( transform, buffer, -FRAME, height + LIGHT_HEIGHT + FRAME / 2, 12, 40 + FRAME / 2, FRAME, FRAME / 2, r, g, b );
|
||||
renderTexture( transform, buffer, 0, height + LIGHT_HEIGHT + FRAME / 2, 0, 12 + FRAME / 2, width, FRAME / 2, r, g, b );
|
||||
renderTexture( transform, buffer, width, height + LIGHT_HEIGHT + FRAME / 2, 24, 40 + FRAME / 2, FRAME, FRAME / 2, r, g, b );
|
||||
ComputerBorderRenderer.render( transform, buffer, 0, 0, 0, width, height, LIGHT_HEIGHT, r, g, b );
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
@ -168,26 +143,12 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR );
|
||||
buffer.pos( transform, width - LIGHT_HEIGHT * 2, height + LIGHT_HEIGHT + FRAME / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.pos( transform, width, height + LIGHT_HEIGHT + FRAME / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.pos( transform, width, height + FRAME / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.pos( transform, width - LIGHT_HEIGHT * 2, height + FRAME / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.pos( transform, width - LIGHT_HEIGHT * 2, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.pos( transform, width, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.pos( transform, width, height + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.pos( transform, width - LIGHT_HEIGHT * 2, height + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
|
||||
tessellator.draw();
|
||||
RenderSystem.enableTexture();
|
||||
}
|
||||
|
||||
private static void renderTexture( Matrix4f transform, IVertexBuilder builder, int x, int y, int textureX, int textureY, int width, int height, float r, float g, float b )
|
||||
{
|
||||
renderTexture( transform, builder, x, y, textureX, textureY, width, height, width, height, r, g, b );
|
||||
}
|
||||
|
||||
private static void renderTexture( Matrix4f transform, IVertexBuilder builder, int x, int y, int textureX, int textureY, int width, int height, int textureWidth, int textureHeight, float r, float g, float b )
|
||||
{
|
||||
float scale = 1 / 255.0f;
|
||||
builder.pos( transform, x, y + height, 0 ).color( r, g, b, 1.0f ).tex( textureX * scale, (textureY + textureHeight) * scale ).endVertex();
|
||||
builder.pos( transform, x + width, y + height, 0 ).color( r, g, b, 1.0f ).tex( (textureX + textureWidth) * scale, (textureY + textureHeight) * scale ).endVertex();
|
||||
builder.pos( transform, x + width, y, 0 ).color( r, g, b, 1.0f ).tex( (textureX + textureWidth) * scale, textureY * scale ).endVertex();
|
||||
builder.pos( transform, x, y, 0 ).color( r, g, b, 1.0f ).tex( textureX * scale, textureY * scale ).endVertex();
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,6 @@
|
||||
package dan200.computercraft.client.render;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import dan200.computercraft.client.gui.GuiComputer;
|
||||
import dan200.computercraft.shared.turtle.core.TurtlePlayer;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
@ -27,7 +26,7 @@ public class TurtlePlayerRenderer extends EntityRenderer<TurtlePlayer>
|
||||
@Override
|
||||
public ResourceLocation getEntityTexture( @Nonnull TurtlePlayer entity )
|
||||
{
|
||||
return GuiComputer.BACKGROUND_NORMAL;
|
||||
return ComputerBorderRenderer.BACKGROUND_NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,6 +73,15 @@ public final class Config
|
||||
private static final ConfigValue<Boolean> turtlesCanPush;
|
||||
private static final ConfigValue<List<? extends String>> turtleDisabledActions;
|
||||
|
||||
private static final ConfigValue<Integer> computerTermWidth;
|
||||
private static final ConfigValue<Integer> computerTermHeight;
|
||||
|
||||
private static final ConfigValue<Integer> pocketTermWidth;
|
||||
private static final ConfigValue<Integer> pocketTermHeight;
|
||||
|
||||
private static final ConfigValue<Integer> monitorWidth;
|
||||
private static final ConfigValue<Integer> monitorHeight;
|
||||
|
||||
private static final ConfigValue<Boolean> genericPeripheral;
|
||||
|
||||
private static final ConfigValue<MonitorRenderer> monitorRenderer;
|
||||
@ -262,6 +271,28 @@ public final class Config
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
{
|
||||
builder.comment( "Configure the size of various computer's terminals.\n" +
|
||||
"Larger terminals require more bandwidth, so use with care." ).push( "term_sizes" );
|
||||
|
||||
builder.comment( "Terminal size of computers" ).push( "computer" );
|
||||
computerTermWidth = builder.defineInRange( "width", ComputerCraft.computerTermWidth, 1, 255 );
|
||||
computerTermHeight = builder.defineInRange( "height", ComputerCraft.computerTermHeight, 1, 255 );
|
||||
builder.pop();
|
||||
|
||||
builder.comment( "Terminal size of pocket computers" ).push( "pocket_computer" );
|
||||
pocketTermWidth = builder.defineInRange( "width", ComputerCraft.pocketTermWidth, 1, 255 );
|
||||
pocketTermHeight = builder.defineInRange( "height", ComputerCraft.pocketTermHeight, 1, 255 );
|
||||
builder.pop();
|
||||
|
||||
builder.comment( "Maximum size of monitors (in blocks)" ).push( "monitor" );
|
||||
monitorWidth = builder.defineInRange( "width", ComputerCraft.monitorWidth, 1, 32 );
|
||||
monitorHeight = builder.defineInRange( "height", ComputerCraft.monitorHeight, 1, 32 );
|
||||
builder.pop();
|
||||
|
||||
builder.pop();
|
||||
}
|
||||
|
||||
{
|
||||
builder.comment( "Options for various experimental features. These are not guaranteed to be stable, and may change or be removed across versions." );
|
||||
builder.push( "experimental" );
|
||||
@ -335,6 +366,15 @@ public final class Config
|
||||
ComputerCraft.turtleDisabledActions.clear();
|
||||
for( String value : turtleDisabledActions.get() ) ComputerCraft.turtleDisabledActions.add( getAction( value ) );
|
||||
|
||||
// Terminal size
|
||||
ComputerCraft.computerTermWidth = computerTermWidth.get();
|
||||
ComputerCraft.computerTermHeight = computerTermHeight.get();
|
||||
ComputerCraft.pocketTermWidth = pocketTermWidth.get();
|
||||
ComputerCraft.pocketTermHeight = pocketTermHeight.get();
|
||||
ComputerCraft.monitorWidth = monitorWidth.get();
|
||||
ComputerCraft.monitorHeight = monitorHeight.get();
|
||||
|
||||
// Experimental
|
||||
ComputerCraft.genericPeripheral = genericPeripheral.get();
|
||||
|
||||
// Client
|
||||
|
@ -43,8 +43,8 @@ public class TileComputer extends TileComputerBase
|
||||
ComputerFamily family = getFamily();
|
||||
ServerComputer computer = new ServerComputer(
|
||||
getWorld(), id, label, instanceID, family,
|
||||
ComputerCraft.terminalWidth_computer,
|
||||
ComputerCraft.terminalHeight_computer
|
||||
ComputerCraft.computerTermWidth,
|
||||
ComputerCraft.computerTermHeight
|
||||
);
|
||||
computer.setPosition( getPos() );
|
||||
return computer;
|
||||
|
@ -41,9 +41,6 @@ public class TileMonitor extends TileGeneric
|
||||
public static final double RENDER_MARGIN = 0.5 / 16.0;
|
||||
public static final double RENDER_PIXEL_SCALE = 1.0 / 64.0;
|
||||
|
||||
private static final int MAX_WIDTH = 8;
|
||||
private static final int MAX_HEIGHT = 6;
|
||||
|
||||
private static final String NBT_X = "XIndex";
|
||||
private static final String NBT_Y = "YIndex";
|
||||
private static final String NBT_WIDTH = "Width";
|
||||
@ -473,7 +470,7 @@ public class TileMonitor extends TileGeneric
|
||||
if( left == null || left.m_yIndex != 0 || left.m_height != m_height ) return false;
|
||||
|
||||
int width = left.m_width + m_width;
|
||||
if( width > MAX_WIDTH ) return false;
|
||||
if( width > ComputerCraft.monitorWidth ) return false;
|
||||
|
||||
TileMonitor origin = left.getOrigin();
|
||||
if( origin != null ) origin.resize( width, m_height );
|
||||
@ -487,7 +484,7 @@ public class TileMonitor extends TileGeneric
|
||||
if( right == null || right.m_yIndex != 0 || right.m_height != m_height ) return false;
|
||||
|
||||
int width = m_width + right.m_width;
|
||||
if( width > MAX_WIDTH ) return false;
|
||||
if( width > ComputerCraft.monitorWidth ) return false;
|
||||
|
||||
TileMonitor origin = getOrigin();
|
||||
if( origin != null ) origin.resize( width, m_height );
|
||||
@ -501,7 +498,7 @@ public class TileMonitor extends TileGeneric
|
||||
if( above == null || above.m_xIndex != 0 || above.m_width != m_width ) return false;
|
||||
|
||||
int height = above.m_height + m_height;
|
||||
if( height > MAX_HEIGHT ) return false;
|
||||
if( height > ComputerCraft.monitorHeight ) return false;
|
||||
|
||||
TileMonitor origin = getOrigin();
|
||||
if( origin != null ) origin.resize( m_width, height );
|
||||
@ -515,7 +512,7 @@ public class TileMonitor extends TileGeneric
|
||||
if( below == null || below.m_xIndex != 0 || below.m_width != m_width ) return false;
|
||||
|
||||
int height = m_height + below.m_height;
|
||||
if( height > MAX_HEIGHT ) return false;
|
||||
if( height > ComputerCraft.monitorHeight ) return false;
|
||||
|
||||
TileMonitor origin = below.getOrigin();
|
||||
if( origin != null ) origin.resize( m_width, height );
|
||||
|
@ -41,7 +41,7 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces
|
||||
|
||||
public PocketServerComputer( World world, int computerID, String label, int instanceID, ComputerFamily family )
|
||||
{
|
||||
super( world, computerID, label, instanceID, family, ComputerCraft.terminalWidth_pocketComputer, ComputerCraft.terminalHeight_pocketComputer );
|
||||
super( world, computerID, label, instanceID, family, ComputerCraft.pocketTermWidth, ComputerCraft.pocketTermHeight );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -87,7 +87,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
{
|
||||
ServerComputer computer = new ServerComputer(
|
||||
getWorld(), id, label, instanceID, getFamily(),
|
||||
ComputerCraft.terminalWidth_turtle, ComputerCraft.terminalHeight_turtle
|
||||
ComputerCraft.turtleTermWidth, ComputerCraft.turtleTermHeight
|
||||
);
|
||||
computer.setPosition( getPos() );
|
||||
computer.addAPI( new TurtleAPI( computer.getAPIEnvironment(), getAccess() ) );
|
||||
|
@ -45,7 +45,7 @@ public class ComputerBootstrap
|
||||
ComputerCraft.logComputerErrors = true;
|
||||
ComputerCraft.maxMainComputerTime = ComputerCraft.maxMainGlobalTime = Integer.MAX_VALUE;
|
||||
|
||||
Terminal term = new Terminal( ComputerCraft.terminalWidth_computer, ComputerCraft.terminalHeight_computer );
|
||||
Terminal term = new Terminal( ComputerCraft.computerTermWidth, ComputerCraft.computerTermHeight );
|
||||
final Computer computer = new Computer( new BasicEnvironment( mount ), term, 0 );
|
||||
|
||||
AssertApi api = new AssertApi();
|
||||
|
Loading…
x
Reference in New Issue
Block a user