1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-26 07:03:22 +00:00

Add back the previous widget methods for back compat

Previously introduced in f765b6a487.

Fixes #87
This commit is contained in:
SquidDev 2018-12-23 16:55:25 +00:00
parent 05a97a4f12
commit 70cb8ae16c
4 changed files with 33 additions and 30 deletions

View File

@ -95,7 +95,7 @@ protected void keyTyped(char c, int k) throws IOException
}
else
{
if( m_terminal.keyTyped( c, k ) ) keyHandled = true;
if( m_terminal.onKeyTyped( c, k ) ) keyHandled = true;
}
}
@ -123,7 +123,7 @@ public void handleMouseInput() throws IOException
public void handleKeyboardInput() throws IOException
{
super.handleKeyboardInput();
if( m_terminal.handleKeyboardInput() ) keyHandled = true;
if( m_terminal.onKeyboardInput() ) keyHandled = true;
}
@Override
@ -150,7 +150,7 @@ public void drawScreen( int mouseX, int mouseY, float f )
// Draw terminal
m_terminal.draw( this.mc, startX, startY, mouseX, mouseY );
// Draw a border around the terminal
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
switch( m_family )

View File

@ -28,7 +28,7 @@ public class GuiTurtle extends GuiContainer
{
private static final ResourceLocation background = new ResourceLocation( "computercraft", "textures/gui/turtle.png" );
private static final ResourceLocation backgroundAdvanced = new ResourceLocation( "computercraft", "textures/gui/turtle_advanced.png" );
protected World m_world;
protected ContainerTurtle m_container;
@ -36,7 +36,7 @@ public class GuiTurtle extends GuiContainer
protected final ITurtleAccess m_turtle;
protected final IComputer m_computer;
protected WidgetTerminal m_terminalGui;
public GuiTurtle( World world, InventoryPlayer inventoryplayer, TileTurtle turtle )
{
this( world, turtle, new ContainerTurtle( inventoryplayer, turtle.getAccess() ) );
@ -51,7 +51,7 @@ protected GuiTurtle( World world, TileTurtle turtle, ContainerTurtle container )
m_family = turtle.getFamily();
m_turtle = turtle.getAccess();
m_computer = turtle.createComputer();
xSize = 254;
ySize = 217;
}
@ -95,17 +95,17 @@ protected void keyTyped(char c, int k) throws IOException
}
else
{
if( m_terminalGui.keyTyped( c, k ) ) keyHandled = true;
if( m_terminalGui.onKeyTyped( c, k ) ) keyHandled = true;
}
}
@Override
protected void mouseClicked(int x, int y, int button) throws IOException
{
super.mouseClicked( x, y, button );
m_terminalGui.mouseClicked( x, y, button );
}
@Override
public void handleMouseInput() throws IOException
{
@ -119,14 +119,14 @@ public void handleMouseInput() throws IOException
public void handleKeyboardInput() throws IOException
{
super.handleKeyboardInput();
if( m_terminalGui.handleKeyboardInput() ) keyHandled = true;
if( m_terminalGui.onKeyboardInput() ) keyHandled = true;
}
protected void drawSelectionSlot( boolean advanced )
{
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
// Draw selection slot
int slot = m_container.getSelectedSlot();
if( slot >= 0 )
@ -145,14 +145,14 @@ protected void drawGuiContainerBackgroundLayer( float f, int mouseX, int mouseY
// Draw term
boolean advanced = (m_family == ComputerFamily.Advanced);
m_terminalGui.draw( Minecraft.getMinecraft(), 0, 0, mouseX, mouseY );
// Draw border/inventory
GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F );
this.mc.getTextureManager().bindTexture( advanced ? backgroundAdvanced : background );
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
drawSelectionSlot( advanced );
}

View File

@ -7,16 +7,7 @@
package dan200.computercraft.client.gui.widgets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import javax.annotation.Nonnull;
public abstract class Widget extends Gui
{
@ -65,17 +56,29 @@ public void handleMouseInput( int mouseX, int mouseY )
{
}
public boolean handleKeyboardInput()
public boolean onKeyboardInput()
{
return false;
}
@Deprecated
public void handleKeyboardInput()
{
onKeyboardInput();
}
public void mouseClicked( int mouseX, int mouseY, int mouseButton )
{
}
public boolean keyTyped( char c, int k )
public boolean onKeyTyped( char c, int k )
{
return false;
}
@Deprecated
public void keyTyped( char c, int k )
{
onKeyTyped( c, k );
}
}

View File

@ -84,7 +84,7 @@ public void setAllowFocusLoss( boolean allowFocusLoss )
}
@Override
public boolean keyTyped( char ch, int key )
public boolean onKeyTyped( char ch, int key )
{
if( m_focus )
{
@ -161,7 +161,7 @@ else if( newLineIndex2 >= 0 )
return handled;
}
}
return false;
}
@ -210,7 +210,7 @@ public void mouseClicked( int mouseX, int mouseY, int button )
}
@Override
public boolean handleKeyboardInput()
public boolean onKeyboardInput()
{
boolean handled = false;
for( int i = m_keysDown.size() - 1; i >= 0; --i )
@ -296,10 +296,10 @@ else if( wheelChange > 0 )
@Override
public void update()
{
{
// Handle special keys
if( m_focus && (Keyboard.isKeyDown( 29 ) || Keyboard.isKeyDown( 157 )) )
{
{
// Ctrl+T for terminate
if( Keyboard.isKeyDown( 20 ) )
{
@ -316,7 +316,7 @@ public void update()
{
m_terminateTimer = 0.0f;
}
// Ctrl+R for reboot
if( Keyboard.isKeyDown(19) )
{