|
2 | 2 |
|
3 | 3 | import dan200.computercraft.ComputerCraft; |
4 | 4 | import dan200.computercraft.client.gui.FixedWidthFontRenderer; |
5 | | -import dan200.computercraft.client.gui.GuiPrintout; |
6 | 5 | import dan200.computercraft.core.terminal.TextBuffer; |
7 | 6 | import dan200.computercraft.shared.util.Palette; |
8 | 7 | import net.minecraft.client.Minecraft; |
9 | 8 | import net.minecraft.client.renderer.BufferBuilder; |
10 | 9 | import net.minecraft.client.renderer.GlStateManager; |
11 | 10 | import net.minecraft.client.renderer.Tessellator; |
12 | 11 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats; |
| 12 | +import net.minecraft.util.ResourceLocation; |
13 | 13 | import org.lwjgl.opengl.GL11; |
14 | 14 |
|
15 | 15 | import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; |
16 | 16 | import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE; |
17 | 17 |
|
18 | 18 | public class PrintoutRenderer |
19 | 19 | { |
20 | | - private static final double SIZE = 256.0; |
| 20 | + private static final ResourceLocation BG = new ResourceLocation( "computercraft", "textures/gui/printout.png" ); |
| 21 | + private static final double BG_SIZE = 256.0; |
21 | 22 |
|
22 | 23 | /** |
23 | 24 | * Width of a page |
24 | 25 | */ |
25 | | - private static final int X_SIZE = 172; |
| 26 | + public static final int X_SIZE = 172; |
26 | 27 |
|
27 | 28 | /** |
28 | 29 | * Height of a page |
29 | 30 | */ |
30 | | - private static final int Y_SIZE = 209; |
| 31 | + public static final int Y_SIZE = 209; |
31 | 32 |
|
32 | 33 | /** |
33 | 34 | * Padding between the left and right of a page and the text |
@@ -75,7 +76,7 @@ public static void drawText( int x, int y, int start, String[] text, String[] co |
75 | 76 | public static void drawBorder( double x, double y, double z, int page, int pages, boolean isBook ) |
76 | 77 | { |
77 | 78 | GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f ); |
78 | | - Minecraft.getMinecraft().getTextureManager().bindTexture( GuiPrintout.BACKGROUND ); |
| 79 | + Minecraft.getMinecraft().getTextureManager().bindTexture( BG ); |
79 | 80 |
|
80 | 81 | Tessellator tessellator = Tessellator.getInstance(); |
81 | 82 | BufferBuilder buffer = tessellator.getBuffer(); |
@@ -140,18 +141,18 @@ public static void drawBorder( double x, double y, double z, int page, int pages |
140 | 141 |
|
141 | 142 | private static void drawTexture( BufferBuilder buffer, double x, double y, double z, double u, double v, double width, double height ) |
142 | 143 | { |
143 | | - buffer.pos( x, y + height, z ).tex( u / SIZE, (v + height) / SIZE ).endVertex(); |
144 | | - buffer.pos( x + width, y + height, z ).tex( (u + width) / SIZE, (v + height) / SIZE ).endVertex(); |
145 | | - buffer.pos( x + width, y, z ).tex( (u + width) / SIZE, v / SIZE ).endVertex(); |
146 | | - buffer.pos( x, y, z ).tex( u / SIZE, v / SIZE ).endVertex(); |
| 144 | + buffer.pos( x, y + height, z ).tex( u / BG_SIZE, (v + height) / BG_SIZE ).endVertex(); |
| 145 | + buffer.pos( x + width, y + height, z ).tex( (u + width) / BG_SIZE, (v + height) / BG_SIZE ).endVertex(); |
| 146 | + buffer.pos( x + width, y, z ).tex( (u + width) / BG_SIZE, v / BG_SIZE ).endVertex(); |
| 147 | + buffer.pos( x, y, z ).tex( u / BG_SIZE, v / BG_SIZE ).endVertex(); |
147 | 148 | } |
148 | 149 |
|
149 | 150 | private static void drawTexture( BufferBuilder buffer, double x, double y, double z, double width, double height, double u, double v, double tWidth, double tHeight ) |
150 | 151 | { |
151 | | - buffer.pos( x, y + height, z ).tex( u / SIZE, (v + tHeight) / SIZE ).endVertex(); |
152 | | - buffer.pos( x + width, y + height, z ).tex( (u + tWidth) / SIZE, (v + tHeight) / SIZE ).endVertex(); |
153 | | - buffer.pos( x + width, y, z ).tex( (u + tWidth) / SIZE, v / SIZE ).endVertex(); |
154 | | - buffer.pos( x, y, z ).tex( u / SIZE, v / SIZE ).endVertex(); |
| 152 | + buffer.pos( x, y + height, z ).tex( u / BG_SIZE, (v + tHeight) / BG_SIZE ).endVertex(); |
| 153 | + buffer.pos( x + width, y + height, z ).tex( (u + tWidth) / BG_SIZE, (v + tHeight) / BG_SIZE ).endVertex(); |
| 154 | + buffer.pos( x + width, y, z ).tex( (u + tWidth) / BG_SIZE, v / BG_SIZE ).endVertex(); |
| 155 | + buffer.pos( x, y, z ).tex( u / BG_SIZE, v / BG_SIZE ).endVertex(); |
155 | 156 | } |
156 | 157 |
|
157 | 158 | public static double offsetAt( int page ) |
|
0 commit comments