From 6029defb2074be06eb73e5d970af81a2d3b8d12c Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Sun, 16 May 2021 18:40:18 +0100 Subject: [PATCH] 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 --- .../client/render/ComputerBorderRenderer.java | 39 ++++++++---------- .../client/render/ItemPocketRenderer.java | 6 ++- .../textures/gui/corners_advanced.png | Bin 1158 -> 2333 bytes .../textures/gui/corners_colour.png | Bin 1285 -> 352 bytes .../textures/gui/corners_normal.png | Bin 426 -> 347 bytes 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java index 31450a69d..8efd22185 100644 --- a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java @@ -38,7 +38,10 @@ public class ComputerBorderRenderer { 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 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; 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) { - 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, - float b) { - new ComputerBorderRenderer(transform, buffer, z, r, g, b).doRender(x, y, width, height, borderHeight); + 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 ) + { + 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 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 // 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.renderCorner(x - BORDER, endY, CORNER_LEFT_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); } } diff --git a/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java index c3c310431..754f9684f 100644 --- a/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java +++ b/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java @@ -6,6 +6,7 @@ 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_WIDTH; 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.util.math.Matrix4f; +import static dan200.computercraft.client.render.ComputerBorderRenderer.*; + /** * Emulates map rendering for pocket computers. */ public final class ItemPocketRenderer extends ItemMapLikeRenderer { public static final ItemPocketRenderer INSTANCE = new ItemPocketRenderer(); - private static final int LIGHT_HEIGHT = 8; private ItemPocketRenderer() { } @@ -108,7 +110,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer { BufferBuilder buffer = tessellator.getBuffer(); 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(); } diff --git a/src/main/resources/assets/computercraft/textures/gui/corners_advanced.png b/src/main/resources/assets/computercraft/textures/gui/corners_advanced.png index 81fc8da0551e38e81ed86628ea8f5b2227b09f2d..f4e8032a1cbd2824459ef9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ft/textures/gui/corners_colour.png index 23507a1867fa4e60c95bdbbb1a2c6ae7f9ec02d6..ab658e68641e0d9446dcff2fae06a8f28b5f1bd3 100644 GIT binary patch delta 337 zcmZqWdcZV6qMn7Bfq`LN%+^o_1_tQ>pAc6?76u4VR#tARX=-X}I(qczg9i`(fBBy! zQc%diz`$4%znz*y^W2n`3sinW`hI$T(B&J!>_a+}@S>nvs5h=VZ?WRZ=A4B@lzLzW<0tyZd4IdizCD=0l zll-W@Z#m27r*&RE+!nqE8ReOv@^)$qc0T)B;p1@Yd4rkSf{luhus|UdPDwwQ{#U-p R(Q5@r+|$+1Wt~$(695EreR%)? literal 1285 zcmeAS@N?(olHy`uVBq!ia0y~yU}OMc4mJh`hM1xiX&_#4kh>GZx^prw85kH?(j9#r z85lP9bN@+XWnf_7EbxddW?21s-)CXsHD*fc_#4N-z#viL z8c`CQpH@C>lAo@rWc@z-+hnKhP- z2HfvI{QFmDwD}p!0UaAg18#qYGlzs3Hh+L}-xt`(`KMi*6VGY}mioN9 z1!)D#b2da))QR5E*~84hz;L19pHjk~>j$>htIJsbv#a}gDdDH&AV;H*q}bsHiNN2b{0Zxy(PvDoPvehb zNNC4R{)%Ii0J)cCGrKL5LEPtW-@ZMq$lv(+ci;KV-z1MsJOBT;Vngn+gR#O5n?KK= ze*E|4-tThr)888R)YkKExM;B>o4KIu-|w~GK2Bp|=r`fZ^JaMG$nc<%h2an!nXx>$ z{y+R)JHr8HPKFk$ptlMP<$rB9WHT`&j-o*r0@fT18>TWi%%BUp@v|c?K0cg3*OIYe eucgdCrZ8^yi=l?bQyCZ-7(8A5T-G@yGywpcCwv9~ diff --git a/src/main/resources/assets/computercraft/textures/gui/corners_normal.png b/src/main/resources/assets/computercraft/textures/gui/corners_normal.png index be4cd974b0ef253eb9446a03ee89ae89805add07..8b1e9f676adcc4c1c4f2f667b776632b0288100f 100644 GIT binary patch delta 282 zcmZ3*e4A;43b$f_Plzi67)%V5t}mYByn=y&fw3gWFPOpM*^M*?28I`&E{-7;x8B~| z%X`Q`pdm0gg>%`WMkU*u3SCDO7DzWJ&78#a>GG1Vicj})?o-x(PP|brov0%fupBnOJUg&1JpNCwOuF{YOi;2!4E}%|2(^|AunE1C^W-`kEPx zZ%y(Kp0D;hpyANa&>_+Gq+y?J)q&(qTr3H=O_WO)7e2h}hz9{@*U|^6A@Ck8cfB|J?<&cn&sHmvDd-onadi3AFe_b*! zJsB7nm`Z~Df*BYYr~F+9vMR~j-GyB&vEwxZ10%bqi(^Q|t+&@V@*Z*!U^yUe;vm^F z&EbUQy91kC6y3rZ8e`1_+qfcB(hm2l{n-6Ce|f