1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-30 17:17:55 +00:00

Use a separate region for the bottom pocket computer border

This is definitely not a good solution, but it's probably the best we
can do right now given resizable computers are a thing.

Fixes #775, closes #776
This commit is contained in:
Jonathan Coates
2021-05-16 18:40:18 +01:00
committed by Jummit
parent c16aa5f247
commit 6029defb20
5 changed files with 22 additions and 23 deletions

View File

@@ -38,7 +38,10 @@ public class ComputerBorderRenderer {
private static final int CORNER_LEFT_X = BORDER; private static final int CORNER_LEFT_X = BORDER;
private static final int CORNER_RIGHT_X = 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 BORDER_RIGHT_X = 36;
private static final int GAP = 4; private static final int LIGHT_BORDER_Y = 56;
private static final int LIGHT_CORNER_Y = 80;
public static final int LIGHT_HEIGHT = 8;
private static final float TEX_SCALE = 1 / 256.0f; private static final float TEX_SCALE = 1 / 256.0f;
static { static {
@@ -89,15 +92,16 @@ public class ComputerBorderRenderer {
} }
public static void render(Matrix4f transform, VertexConsumer buffer, int x, int y, int z, int width, int height, float r, float g, float b) { public static void render(Matrix4f transform, VertexConsumer 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); render( transform, buffer, x, y, z, width, height, false, r, g, b );
} }
public static void render(Matrix4f transform, VertexConsumer buffer, int x, int y, int z, int width, int height, int borderHeight, float r, float g, public static void render( Matrix4f transform, VertexConsumer buffer, int x, int y, int z, int width, int height, boolean withLight, float r, float g, float b )
float b) { {
new ComputerBorderRenderer(transform, buffer, z, r, g, b).doRender(x, y, width, height, borderHeight); new ComputerBorderRenderer( transform, buffer, z, r, g, b ).doRender( x, y, width, height, withLight );
} }
public void doRender(int x, int y, int width, int height, int bottomHeight) { public void doRender( int x, int y, int width, int height, boolean withLight )
{
int endX = x + width; int endX = x + width;
int endY = y + height; int endY = y + height;
@@ -112,24 +116,17 @@ public class ComputerBorderRenderer {
// Bottom bar. We allow for drawing a stretched version, which allows for additional elements (such as the // Bottom bar. We allow for drawing a stretched version, which allows for additional elements (such as the
// pocket computer's lights). // pocket computer's lights).
if (bottomHeight <= 0) { if( withLight )
{
renderTexture( x, endY, 0, LIGHT_BORDER_Y, endX - x, BORDER + LIGHT_HEIGHT, BORDER, BORDER + LIGHT_HEIGHT );
renderTexture( x - BORDER, endY, CORNER_LEFT_X, LIGHT_CORNER_Y, BORDER, BORDER + LIGHT_HEIGHT );
renderTexture( endX, endY, CORNER_RIGHT_X, LIGHT_CORNER_Y, BORDER, BORDER + LIGHT_HEIGHT );
}
else
{
this.renderLine(x, endY, 0, BORDER, endX - x, BORDER); this.renderLine(x, endY, 0, BORDER, endX - x, BORDER);
this.renderCorner(x - BORDER, endY, CORNER_LEFT_X, CORNER_BOTTOM_Y); this.renderCorner(x - BORDER, endY, CORNER_LEFT_X, CORNER_BOTTOM_Y);
this.renderCorner(endX, endY, CORNER_RIGHT_X, CORNER_BOTTOM_Y); this.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.
this.renderTexture(x - BORDER, endY, CORNER_LEFT_X, CORNER_BOTTOM_Y, BORDER, BORDER / 2);
this.renderTexture(x, endY, 0, BORDER, width, BORDER / 2, BORDER, BORDER / 2);
this.renderTexture(endX, endY, CORNER_RIGHT_X, CORNER_BOTTOM_Y, BORDER, BORDER / 2);
this.renderTexture(x - BORDER, endY + BORDER / 2, CORNER_LEFT_X, CORNER_BOTTOM_Y + GAP, BORDER, bottomHeight, BORDER, GAP);
this.renderTexture(x, endY + BORDER / 2, 0, BORDER + GAP, width, bottomHeight, BORDER, GAP);
this.renderTexture(endX, endY + BORDER / 2, CORNER_RIGHT_X, CORNER_BOTTOM_Y + GAP, BORDER, bottomHeight, BORDER, GAP);
this.renderTexture(x - BORDER, endY + bottomHeight + BORDER / 2, CORNER_LEFT_X, CORNER_BOTTOM_Y + BORDER / 2, BORDER, BORDER / 2);
this.renderTexture(x, endY + bottomHeight + BORDER / 2, 0, BORDER + BORDER / 2, width, BORDER / 2);
this.renderTexture(endX, endY + bottomHeight + BORDER / 2, CORNER_RIGHT_X, CORNER_BOTTOM_Y + BORDER / 2, BORDER, BORDER / 2);
} }
} }

View File

@@ -6,6 +6,7 @@
package dan200.computercraft.client.render; package dan200.computercraft.client.render;
import static dan200.computercraft.client.render.ComputerBorderRenderer.*;
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT;
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH; import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH;
import static dan200.computercraft.client.render.ComputerBorderRenderer.BORDER; import static dan200.computercraft.client.render.ComputerBorderRenderer.BORDER;
@@ -31,12 +32,13 @@ import net.minecraft.client.util.math.Vector3f;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Matrix4f; import net.minecraft.util.math.Matrix4f;
import static dan200.computercraft.client.render.ComputerBorderRenderer.*;
/** /**
* Emulates map rendering for pocket computers. * Emulates map rendering for pocket computers.
*/ */
public final class ItemPocketRenderer extends ItemMapLikeRenderer { public final class ItemPocketRenderer extends ItemMapLikeRenderer {
public static final ItemPocketRenderer INSTANCE = new ItemPocketRenderer(); public static final ItemPocketRenderer INSTANCE = new ItemPocketRenderer();
private static final int LIGHT_HEIGHT = 8;
private ItemPocketRenderer() { private ItemPocketRenderer() {
} }
@@ -108,7 +110,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer {
BufferBuilder buffer = tessellator.getBuffer(); BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR_TEXTURE); buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_COLOR_TEXTURE);
ComputerBorderRenderer.render(transform, buffer, 0, 0, 0, width, height, LIGHT_HEIGHT, r, g, b); ComputerBorderRenderer.render(transform, buffer, 0, 0, 0, width, height, true, r, g, b);
tessellator.draw(); tessellator.draw();
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

After

Width:  |  Height:  |  Size: 347 B