1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-30 05:12:58 +00:00

Move several methods out of the proxy

Some methods act the same on both sides, and so can be in utility
classes. Others are only needed on one side, and so do not really need
to be part of the proxy.

 - Remove TurtleVisionCamera. It would be possible to add this back in
   the future, but for now it is unused and so should be removed.
 - Move frame info (cursor blink, current render frame) into a
   FrameInfo class.
 - Move record methods (name, playing a record) into a RecordUtil class.
This commit is contained in:
SquidDev
2018-12-27 11:58:08 +00:00
parent 2c87e66db8
commit 26ba61097b
16 changed files with 147 additions and 463 deletions

View File

@@ -8,6 +8,7 @@ package dan200.computercraft.client.gui;
import dan200.computercraft.core.terminal.TextBuffer;
import dan200.computercraft.shared.util.Palette;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
@@ -20,17 +21,25 @@ import java.util.Arrays;
public class FixedWidthFontRenderer
{
private static ResourceLocation font = new ResourceLocation( "computercraft", "textures/gui/term_font.png" );
public static ResourceLocation background = new ResourceLocation( "computercraft", "textures/gui/term_background.png" );
private static final ResourceLocation FONT = new ResourceLocation( "computercraft", "textures/gui/term_font.png" );
public static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/term_background.png" );
public static int FONT_HEIGHT = 9;
public static int FONT_WIDTH = 6;
public static final int FONT_HEIGHT = 9;
public static final int FONT_WIDTH = 6;
private static FixedWidthFontRenderer instance;
public static FixedWidthFontRenderer instance()
{
if( instance != null ) return instance;
return instance = new FixedWidthFontRenderer();
}
private TextureManager m_textureManager;
public FixedWidthFontRenderer( TextureManager textureManager )
private FixedWidthFontRenderer()
{
m_textureManager = textureManager;
m_textureManager = Minecraft.getMinecraft().getTextureManager();
}
private static void greyscaleify( double[] rgb )
@@ -157,7 +166,7 @@ public class FixedWidthFontRenderer
if( backgroundColour != null )
{
// Bind the background texture
m_textureManager.bindTexture( background );
m_textureManager.bindTexture( BACKGROUND );
// Draw the quads
drawStringBackgroundPart( x, y, backgroundColour, leftMarginSize, rightMarginSize, greyScale, p );
@@ -185,7 +194,7 @@ public class FixedWidthFontRenderer
public void bindFont()
{
m_textureManager.bindTexture( font );
m_textureManager.bindTexture( FONT );
GlStateManager.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP );
}
}

View File

@@ -6,7 +6,7 @@
package dan200.computercraft.client.gui.widgets;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.client.FrameInfo;
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
import dan200.computercraft.core.terminal.Terminal;
import dan200.computercraft.core.terminal.TextBuffer;
@@ -387,8 +387,8 @@ public class WidgetTerminal extends Widget
// Get the data from the terminal first
// Unfortunately we have to keep the lock for the whole of drawing, so the text doesn't change under us.
FixedWidthFontRenderer fontRenderer = (FixedWidthFontRenderer) ComputerCraft.getFixedWidthFontRenderer();
boolean tblink = m_focus && terminal.getCursorBlink() && ComputerCraft.getGlobalCursorBlink();
FixedWidthFontRenderer fontRenderer = FixedWidthFontRenderer.instance();
boolean tblink = m_focus && terminal.getCursorBlink() && FrameInfo.instance().getGlobalCursorBlink();
int tw = terminal.getWidth();
int th = terminal.getHeight();
int tx = terminal.getCursorX();