mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 05:33:00 +00:00 
			
		
		
		
	Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
 - Flatten everything. For instance, there are now three instances of
   BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
   more BlockPeripheral (thank heavens) - there's separate block classes
   for each peripheral type.
 - Remove pretty much all legacy code. As we're breaking world
   compatibility anyway, we can remove all the code to load worlds from
   1.4 days.
 - The command system is largely rewriten to take advantage of 1.13's
   new system. It's very fancy!
 - WidgetTerminal now uses Minecraft's "GUI listener" system.
 - BREAKING CHANGE: All the codes in keys.lua are different, due to the
   move to LWJGL 3. Hopefully this won't have too much of an impact.
   I don't want to map to the old key codes on the Java side, as there
   always ends up being small but slight inconsistencies. IMO it's
   better to make a clean break - people should be using keys rather
   than hard coding the constants anyway.
 - commands.list now allows fetching sub-commands. The ROM has already
   been updated to allow fancy usage such as commands.time.set("noon").
 - Turtles, modems and cables can be waterlogged.
			
			
This commit is contained in:
		| @@ -39,7 +39,7 @@ public final class FixedWidthFontRenderer | ||||
|  | ||||
|     private FixedWidthFontRenderer() | ||||
|     { | ||||
|         m_textureManager = Minecraft.getMinecraft().getTextureManager(); | ||||
|         m_textureManager = Minecraft.getInstance().getTextureManager(); | ||||
|     } | ||||
|  | ||||
|     private static void greyscaleify( double[] rgb ) | ||||
| @@ -195,6 +195,6 @@ public final class FixedWidthFontRenderer | ||||
|     public void bindFont() | ||||
|     { | ||||
|         m_textureManager.bindTexture( FONT ); | ||||
|         GlStateManager.glTexParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP ); | ||||
|         GlStateManager.texParameteri( GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP ); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -8,23 +8,19 @@ package dan200.computercraft.client.gui; | ||||
|  | ||||
| import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.client.gui.widgets.WidgetTerminal; | ||||
| import dan200.computercraft.client.gui.widgets.WidgetWrapper; | ||||
| import dan200.computercraft.shared.computer.blocks.TileComputer; | ||||
| import dan200.computercraft.shared.computer.core.ClientComputer; | ||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||
| import dan200.computercraft.shared.computer.core.IComputer; | ||||
| import dan200.computercraft.shared.computer.inventory.ContainerComputer; | ||||
| import net.minecraft.client.gui.inventory.GuiContainer; | ||||
| import net.minecraft.client.renderer.GlStateManager; | ||||
| import net.minecraft.inventory.Container; | ||||
| import net.minecraft.util.ResourceLocation; | ||||
| import org.lwjgl.input.Keyboard; | ||||
| import org.lwjgl.input.Mouse; | ||||
|  | ||||
| import java.io.IOException; | ||||
|  | ||||
| public class GuiComputer extends GuiContainer | ||||
| { | ||||
|     private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/corners.png" ); | ||||
|     private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( "computercraft", "textures/gui/corners_normal.png" ); | ||||
|     private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation( "computercraft", "textures/gui/corners_advanced.png" ); | ||||
|     private static final ResourceLocation BACKGROUND_COMMAND = new ResourceLocation( "computercraft", "textures/gui/corners_command.png" ); | ||||
|  | ||||
| @@ -32,7 +28,9 @@ public class GuiComputer extends GuiContainer | ||||
|     private final ClientComputer m_computer; | ||||
|     private final int m_termWidth; | ||||
|     private final int m_termHeight; | ||||
|     private WidgetTerminal m_terminal; | ||||
|  | ||||
|     private WidgetTerminal terminal; | ||||
|     private WidgetWrapper terminalWrapper; | ||||
|  | ||||
|     public GuiComputer( Container container, ComputerFamily family, ClientComputer computer, int termWidth, int termHeight ) | ||||
|     { | ||||
| @@ -41,13 +39,7 @@ public class GuiComputer extends GuiContainer | ||||
|         m_computer = computer; | ||||
|         m_termWidth = termWidth; | ||||
|         m_termHeight = termHeight; | ||||
|         m_terminal = null; | ||||
|     } | ||||
|  | ||||
|     @Deprecated | ||||
|     public GuiComputer( Container container, ComputerFamily family, IComputer computer, int termWidth, int termHeight ) | ||||
|     { | ||||
|         this( container, family, (ClientComputer) computer, termWidth, termHeight ); | ||||
|         terminal = null; | ||||
|     } | ||||
|  | ||||
|     public GuiComputer( TileComputer computer ) | ||||
| @@ -62,103 +54,60 @@ public class GuiComputer extends GuiContainer | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void initGui() | ||||
|     protected void initGui() | ||||
|     { | ||||
|         super.initGui(); | ||||
|         Keyboard.enableRepeatEvents( true ); | ||||
|         mc.keyboardListener.enableRepeatEvents( true ); | ||||
|  | ||||
|         m_terminal = new WidgetTerminal( 0, 0, m_termWidth, m_termHeight, () -> m_computer, 2, 2, 2, 2 ); | ||||
|         m_terminal.setAllowFocusLoss( false ); | ||||
|         xSize = m_terminal.getWidth() + 24; | ||||
|         ySize = m_terminal.getHeight() + 24; | ||||
|         int termPxWidth = m_termWidth * FixedWidthFontRenderer.FONT_WIDTH; | ||||
|         int termPxHeight = m_termHeight * FixedWidthFontRenderer.FONT_HEIGHT; | ||||
|  | ||||
|         xSize = termPxWidth + 4 + 24; | ||||
|         ySize = termPxHeight + 4 + 24; | ||||
|  | ||||
|         super.initGui(); | ||||
|  | ||||
|         terminal = new WidgetTerminal( mc, () -> m_computer, m_termWidth, m_termHeight, 2, 2, 2, 2 ); | ||||
|         terminalWrapper = new WidgetWrapper( terminal, 2 + 12 + guiLeft, 2 + 12 + guiTop, termPxWidth, termPxHeight ); | ||||
|  | ||||
|         children.add( terminalWrapper ); | ||||
|         setFocused( terminalWrapper ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onGuiClosed() | ||||
|     { | ||||
|         super.onGuiClosed(); | ||||
|         Keyboard.enableRepeatEvents( false ); | ||||
|         children.remove( terminal ); | ||||
|         terminal = null; | ||||
|         mc.keyboardListener.enableRepeatEvents( false ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateScreen() | ||||
|     public void tick() | ||||
|     { | ||||
|         super.updateScreen(); | ||||
|         m_terminal.update(); | ||||
|         super.tick(); | ||||
|         terminal.update(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void keyTyped( char c, int k ) throws IOException | ||||
|     { | ||||
|         if( k == 1 ) | ||||
|         { | ||||
|             super.keyTyped( c, k ); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             if( m_terminal.onKeyTyped( c, k ) ) keyHandled = true; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void mouseClicked( int x, int y, int button ) | ||||
|     { | ||||
|         int startX = (width - m_terminal.getWidth()) / 2; | ||||
|         int startY = (height - m_terminal.getHeight()) / 2; | ||||
|         m_terminal.mouseClicked( x - startX, y - startY, button ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void handleMouseInput() throws IOException | ||||
|     { | ||||
|         super.handleMouseInput(); | ||||
|  | ||||
|         int x = Mouse.getEventX() * width / mc.displayWidth; | ||||
|         int y = height - Mouse.getEventY() * height / mc.displayHeight - 1; | ||||
|         int startX = (width - m_terminal.getWidth()) / 2; | ||||
|         int startY = (height - m_terminal.getHeight()) / 2; | ||||
|         m_terminal.handleMouseInput( x - startX, y - startY ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void handleKeyboardInput() throws IOException | ||||
|     { | ||||
|         super.handleKeyboardInput(); | ||||
|         if( m_terminal.onKeyboardInput() ) keyHandled = true; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void drawGuiContainerForegroundLayer( int par1, int par2 ) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void drawGuiContainerBackgroundLayer( float var1, int var2, int var3 ) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void drawScreen( int mouseX, int mouseY, float partialTicks ) | ||||
|     public void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY ) | ||||
|     { | ||||
|         // Work out where to draw | ||||
|         int startX = (width - m_terminal.getWidth()) / 2; | ||||
|         int startY = (height - m_terminal.getHeight()) / 2; | ||||
|         int endX = startX + m_terminal.getWidth(); | ||||
|         int endY = startY + m_terminal.getHeight(); | ||||
|  | ||||
|         // Draw background | ||||
|         drawDefaultBackground(); | ||||
|         int startX = terminalWrapper.getX() - 2; | ||||
|         int startY = terminalWrapper.getY() - 2; | ||||
|         int endX = startX + terminalWrapper.getWidth() + 4; | ||||
|         int endY = startY + terminalWrapper.getHeight() + 4; | ||||
|  | ||||
|         // Draw terminal | ||||
|         m_terminal.draw( mc, startX, startY, mouseX, mouseY ); | ||||
|         terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() ); | ||||
|  | ||||
|         // Draw a border around the terminal | ||||
|         GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f ); | ||||
|         GlStateManager.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); | ||||
|         switch( m_family ) | ||||
|         { | ||||
|             case Normal: | ||||
|             default: | ||||
|                 mc.getTextureManager().bindTexture( BACKGROUND ); | ||||
|                 mc.getTextureManager().bindTexture( BACKGROUND_NORMAL ); | ||||
|                 break; | ||||
|             case Advanced: | ||||
|                 mc.getTextureManager().bindTexture( BACKGROUND_ADVANCED ); | ||||
| @@ -179,4 +128,26 @@ public class GuiComputer extends GuiContainer | ||||
|         drawTexturedModalRect( startX - 12, startY, 0, 28, 12, endY - startY ); | ||||
|         drawTexturedModalRect( endX, startY, 36, 28, 12, endY - startY ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void render( int mouseX, int mouseY, float partialTicks ) | ||||
|     { | ||||
|         drawDefaultBackground(); | ||||
|         super.render( mouseX, mouseY, partialTicks ); | ||||
|         renderHoveredToolTip( mouseX, mouseY ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY ) | ||||
|     { | ||||
|         return (getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY )) | ||||
|             || super.mouseDragged( x, y, button, deltaX, deltaY ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean mouseReleased( double x, double y, int button ) | ||||
|     { | ||||
|         return (getFocused() != null && getFocused().mouseReleased( x, y, button )) | ||||
|             || super.mouseReleased( x, y, button ); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,50 +0,0 @@ | ||||
| /* | ||||
|  * This file is part of ComputerCraft - http://www.computercraft.info | ||||
|  * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission. | ||||
|  * Send enquiries to dratcliffe@gmail.com | ||||
|  */ | ||||
|  | ||||
| package dan200.computercraft.client.gui; | ||||
|  | ||||
| import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.shared.Config; | ||||
| import net.minecraft.client.Minecraft; | ||||
| import net.minecraft.client.gui.GuiScreen; | ||||
| import net.minecraftforge.fml.client.IModGuiFactory; | ||||
| import net.minecraftforge.fml.client.config.GuiConfig; | ||||
|  | ||||
| import java.util.Set; | ||||
|  | ||||
| public class GuiConfigCC extends GuiConfig | ||||
| { | ||||
|     public GuiConfigCC( GuiScreen parentScreen ) | ||||
|     { | ||||
|         super( parentScreen, Config.getConfigElements(), ComputerCraft.MOD_ID, false, false, "CC: Tweaked" ); | ||||
|     } | ||||
|  | ||||
|     public static class Factory implements IModGuiFactory | ||||
|     { | ||||
|         @Override | ||||
|         public void initialize( Minecraft minecraft ) | ||||
|         { | ||||
|         } | ||||
|  | ||||
|         @Override | ||||
|         public boolean hasConfigGui() | ||||
|         { | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         @Override | ||||
|         public GuiScreen createConfigGui( GuiScreen parentScreen ) | ||||
|         { | ||||
|             return new GuiConfigCC( parentScreen ); | ||||
|         } | ||||
|  | ||||
|         @Override | ||||
|         public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() | ||||
|         { | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -14,7 +14,7 @@ import net.minecraft.util.ResourceLocation; | ||||
|  | ||||
| public class GuiDiskDrive extends GuiContainer | ||||
| { | ||||
|     private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/diskdrive.png" ); | ||||
|     private static final ResourceLocation BACKGROUND = new ResourceLocation( "computercraft", "textures/gui/disk_drive.png" ); | ||||
|  | ||||
|     private final ContainerDiskDrive m_container; | ||||
|  | ||||
| @@ -27,24 +27,24 @@ public class GuiDiskDrive extends GuiContainer | ||||
|     @Override | ||||
|     protected void drawGuiContainerForegroundLayer( int mouseX, int mouseY ) | ||||
|     { | ||||
|         String title = m_container.getDiskDrive().getDisplayName().getUnformattedText(); | ||||
|         fontRenderer.drawString( title, (xSize - fontRenderer.getStringWidth( title )) / 2, 6, 0x404040 ); | ||||
|         String title = m_container.getDiskDrive().getDisplayName().getString(); | ||||
|         fontRenderer.drawString( title, (xSize - fontRenderer.getStringWidth( title )) / 2.0f, 6, 0x404040 ); | ||||
|         fontRenderer.drawString( I18n.format( "container.inventory" ), 8, ySize - 96 + 2, 0x404040 ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY ) | ||||
|     { | ||||
|         GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F ); | ||||
|         GlStateManager.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); | ||||
|         mc.getTextureManager().bindTexture( BACKGROUND ); | ||||
|         drawTexturedModalRect( guiLeft, guiTop, 0, 0, xSize, ySize ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void drawScreen( int mouseX, int mouseY, float partialTicks ) | ||||
|     public void render( int mouseX, int mouseY, float partialTicks ) | ||||
|     { | ||||
|         drawDefaultBackground(); | ||||
|         super.drawScreen( mouseX, mouseY, partialTicks ); | ||||
|         super.render( mouseX, mouseY, partialTicks ); | ||||
|         renderHoveredToolTip( mouseX, mouseY ); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -7,19 +7,28 @@ | ||||
| package dan200.computercraft.client.gui; | ||||
|  | ||||
| import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.shared.media.inventory.ContainerHeldItem; | ||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||
| import dan200.computercraft.shared.pocket.inventory.ContainerPocketComputer; | ||||
| import dan200.computercraft.shared.pocket.items.ItemPocketComputer; | ||||
| import net.minecraft.item.Item; | ||||
| import net.minecraft.item.ItemStack; | ||||
|  | ||||
| public class GuiPocketComputer extends GuiComputer | ||||
| { | ||||
|     public GuiPocketComputer( ContainerHeldItem container ) | ||||
|     public GuiPocketComputer( ContainerPocketComputer container ) | ||||
|     { | ||||
|         super( | ||||
|             container, | ||||
|             ComputerCraft.Items.pocketComputer.getFamily( container.getStack() ), | ||||
|             getFamily( container.getStack() ), | ||||
|             ItemPocketComputer.createClientComputer( container.getStack() ), | ||||
|             ComputerCraft.terminalWidth_pocketComputer, | ||||
|             ComputerCraft.terminalHeight_pocketComputer | ||||
|         ); | ||||
|     } | ||||
|  | ||||
|     private static ComputerFamily getFamily( ItemStack stack ) | ||||
|     { | ||||
|         Item item = stack.getItem(); | ||||
|         return item instanceof ItemPocketComputer ? ((ItemPocketComputer) item).getFamily() : ComputerFamily.Normal; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -27,15 +27,15 @@ public class GuiPrinter extends GuiContainer | ||||
|     @Override | ||||
|     protected void drawGuiContainerForegroundLayer( int mouseX, int mouseY ) | ||||
|     { | ||||
|         String title = container.getPrinter().getDisplayName().getUnformattedText(); | ||||
|         fontRenderer.drawString( title, (xSize - fontRenderer.getStringWidth( title )) / 2, 6, 0x404040 ); | ||||
|         String title = container.getPrinter().getDisplayName().getString(); | ||||
|         fontRenderer.drawString( title, (xSize - fontRenderer.getStringWidth( title )) / 2.0f, 6, 0x404040 ); | ||||
|         fontRenderer.drawString( I18n.format( "container.inventory" ), 8, ySize - 96 + 2, 0x404040 ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY ) | ||||
|     { | ||||
|         GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F ); | ||||
|         GlStateManager.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); | ||||
|         mc.getTextureManager().bindTexture( BACKGROUND ); | ||||
|         drawTexturedModalRect( guiLeft, guiTop, 0, 0, xSize, ySize ); | ||||
|  | ||||
| @@ -43,10 +43,10 @@ public class GuiPrinter extends GuiContainer | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void drawScreen( int mouseX, int mouseY, float partialTicks ) | ||||
|     public void render( int mouseX, int mouseY, float partialTicks ) | ||||
|     { | ||||
|         drawDefaultBackground(); | ||||
|         super.drawScreen( mouseX, mouseY, partialTicks ); | ||||
|         super.render( mouseX, mouseY, partialTicks ); | ||||
|         renderHoveredToolTip( mouseX, mouseY ); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -7,13 +7,11 @@ | ||||
| package dan200.computercraft.client.gui; | ||||
|  | ||||
| import dan200.computercraft.core.terminal.TextBuffer; | ||||
| import dan200.computercraft.shared.media.inventory.ContainerHeldItem; | ||||
| import dan200.computercraft.shared.common.ContainerHeldItem; | ||||
| import dan200.computercraft.shared.media.items.ItemPrintout; | ||||
| import net.minecraft.client.gui.inventory.GuiContainer; | ||||
| import net.minecraft.client.renderer.GlStateManager; | ||||
| import org.lwjgl.input.Mouse; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import org.lwjgl.glfw.GLFW; | ||||
|  | ||||
| import static dan200.computercraft.client.render.PrintoutRenderer.*; | ||||
|  | ||||
| @@ -41,63 +39,70 @@ public class GuiPrintout extends GuiContainer | ||||
|  | ||||
|         m_page = 0; | ||||
|         m_pages = Math.max( m_text.length / ItemPrintout.LINES_PER_PAGE, 1 ); | ||||
|         m_book = ItemPrintout.getType( container.getStack() ) == ItemPrintout.Type.Book; | ||||
|         m_book = ((ItemPrintout) container.getStack().getItem()).getType() == ItemPrintout.Type.BOOK; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void keyTyped( char c, int k ) throws IOException | ||||
|     public boolean keyPressed( int key, int scancode, int modifiers ) | ||||
|     { | ||||
|         super.keyTyped( c, k ); | ||||
|         if( super.keyPressed( key, scancode, modifiers ) ) return true; | ||||
|  | ||||
|         if( k == 205 ) | ||||
|         if( key == GLFW.GLFW_KEY_RIGHT ) | ||||
|         { | ||||
|             // Right | ||||
|             if( m_page < m_pages - 1 ) m_page++; | ||||
|             return true; | ||||
|         } | ||||
|         else if( k == 203 ) | ||||
|  | ||||
|         if( key == GLFW.GLFW_KEY_LEFT ) | ||||
|         { | ||||
|             // Left | ||||
|             if( m_page > 0 ) m_page--; | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void handleMouseInput() throws IOException | ||||
|     public boolean mouseScrolled( double delta ) | ||||
|     { | ||||
|         super.handleMouseInput(); | ||||
|  | ||||
|         int mouseWheelChange = Mouse.getEventDWheel(); | ||||
|         if( mouseWheelChange < 0 ) | ||||
|         if( super.mouseScrolled( delta ) ) return true; | ||||
|         if( delta < 0 ) | ||||
|         { | ||||
|             // Scroll up goes to the next page | ||||
|             if( m_page < m_pages - 1 ) m_page++; | ||||
|             return true; | ||||
|         } | ||||
|         else if( mouseWheelChange > 0 ) | ||||
|  | ||||
|         if( delta > 0 ) | ||||
|         { | ||||
|             // Scroll down goes to the previous page | ||||
|             if( m_page > 0 ) m_page--; | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY ) | ||||
|     public void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY ) | ||||
|     { | ||||
|         // Draw the printout | ||||
|         GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f ); | ||||
|         GlStateManager.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); | ||||
|         GlStateManager.enableDepthTest(); | ||||
|  | ||||
|         drawBorder( guiLeft, guiTop, zLevel, m_page, m_pages, m_book ); | ||||
|         drawText( guiLeft + X_TEXT_MARGIN, guiTop + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * m_page, m_text, m_colours ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void drawScreen( int mouseX, int mouseY, float partialTicks ) | ||||
|     public void render( int mouseX, int mouseY, float partialTicks ) | ||||
|     { | ||||
|         // We must take the background further back in order to not overlap with our printed pages. | ||||
|         zLevel--; | ||||
|         drawDefaultBackground(); | ||||
|         zLevel++; | ||||
|  | ||||
|         super.drawScreen( mouseX, mouseY, partialTicks ); | ||||
|         super.render( mouseX, mouseY, partialTicks ); | ||||
|         renderHoveredToolTip( mouseX, mouseY ); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -8,29 +8,27 @@ package dan200.computercraft.client.gui; | ||||
|  | ||||
| import dan200.computercraft.ComputerCraft; | ||||
| import dan200.computercraft.client.gui.widgets.WidgetTerminal; | ||||
| import dan200.computercraft.client.gui.widgets.WidgetWrapper; | ||||
| import dan200.computercraft.shared.computer.core.ClientComputer; | ||||
| import dan200.computercraft.shared.computer.core.ComputerFamily; | ||||
| import dan200.computercraft.shared.turtle.blocks.TileTurtle; | ||||
| import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; | ||||
| import net.minecraft.client.Minecraft; | ||||
| import net.minecraft.client.gui.inventory.GuiContainer; | ||||
| import net.minecraft.client.renderer.GlStateManager; | ||||
| import net.minecraft.util.ResourceLocation; | ||||
| import org.lwjgl.input.Keyboard; | ||||
| import org.lwjgl.input.Mouse; | ||||
|  | ||||
| import java.io.IOException; | ||||
|  | ||||
| public class GuiTurtle extends GuiContainer | ||||
| { | ||||
|     private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( "computercraft", "textures/gui/turtle.png" ); | ||||
|     private static final ResourceLocation BACKGROUND_NORMAL = new ResourceLocation( "computercraft", "textures/gui/turtle_normal.png" ); | ||||
|     private static final ResourceLocation BACKGROUND_ADVANCED = new ResourceLocation( "computercraft", "textures/gui/turtle_advanced.png" ); | ||||
|  | ||||
|     private ContainerTurtle m_container; | ||||
|  | ||||
|     private final ComputerFamily m_family; | ||||
|     private final ClientComputer m_computer; | ||||
|     private WidgetTerminal m_terminalGui; | ||||
|  | ||||
|     private WidgetTerminal terminal; | ||||
|     private WidgetWrapper terminalWrapper; | ||||
|  | ||||
|     public GuiTurtle( TileTurtle turtle, ContainerTurtle container ) | ||||
|     { | ||||
| @@ -45,78 +43,48 @@ public class GuiTurtle extends GuiContainer | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void initGui() | ||||
|     protected void initGui() | ||||
|     { | ||||
|         super.initGui(); | ||||
|         Keyboard.enableRepeatEvents( true ); | ||||
|         m_terminalGui = new WidgetTerminal( | ||||
|             guiLeft + 8, | ||||
|             guiTop + 8, | ||||
|         mc.keyboardListener.enableRepeatEvents( true ); | ||||
|  | ||||
|         int termPxWidth = ComputerCraft.terminalWidth_turtle * FixedWidthFontRenderer.FONT_WIDTH; | ||||
|         int termPxHeight = ComputerCraft.terminalHeight_turtle * FixedWidthFontRenderer.FONT_HEIGHT; | ||||
|  | ||||
|         terminal = new WidgetTerminal( | ||||
|             mc, () -> m_computer, | ||||
|             ComputerCraft.terminalWidth_turtle, | ||||
|             ComputerCraft.terminalHeight_turtle, | ||||
|             () -> m_computer, | ||||
|             2, 2, 2, 2 | ||||
|         ); | ||||
|         m_terminalGui.setAllowFocusLoss( false ); | ||||
|         terminalWrapper = new WidgetWrapper( terminal, 2 + 8 + guiLeft, 2 + 8 + guiTop, termPxWidth, termPxHeight ); | ||||
|  | ||||
|         children.add( terminalWrapper ); | ||||
|         setFocused( terminalWrapper ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void onGuiClosed() | ||||
|     { | ||||
|         super.onGuiClosed(); | ||||
|         Keyboard.enableRepeatEvents( false ); | ||||
|         children.remove( terminal ); | ||||
|         terminal = null; | ||||
|         mc.keyboardListener.enableRepeatEvents( false ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateScreen() | ||||
|     public void tick() | ||||
|     { | ||||
|         super.updateScreen(); | ||||
|         m_terminalGui.update(); | ||||
|         super.tick(); | ||||
|         terminal.update(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void keyTyped( char c, int k ) throws IOException | ||||
|     { | ||||
|         if( k == 1 ) | ||||
|         { | ||||
|             super.keyTyped( c, k ); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             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 | ||||
|     { | ||||
|         super.handleMouseInput(); | ||||
|         int x = Mouse.getEventX() * width / mc.displayWidth; | ||||
|         int y = height - Mouse.getEventY() * height / mc.displayHeight - 1; | ||||
|         m_terminalGui.handleMouseInput( x, y ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void handleKeyboardInput() throws IOException | ||||
|     { | ||||
|         super.handleKeyboardInput(); | ||||
|         if( m_terminalGui.onKeyboardInput() ) keyHandled = true; | ||||
|     } | ||||
|  | ||||
|     protected void drawSelectionSlot( boolean advanced ) | ||||
|     private void drawSelectionSlot( boolean advanced ) | ||||
|     { | ||||
|         // Draw selection slot | ||||
|         int slot = m_container.getSelectedSlot(); | ||||
|         if( slot >= 0 ) | ||||
|         { | ||||
|             GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F ); | ||||
|             GlStateManager.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); | ||||
|             int slotX = slot % 4; | ||||
|             int slotY = slot / 4; | ||||
|             mc.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL ); | ||||
| @@ -129,10 +97,10 @@ public class GuiTurtle extends GuiContainer | ||||
|     { | ||||
|         // Draw term | ||||
|         boolean advanced = m_family == ComputerFamily.Advanced; | ||||
|         m_terminalGui.draw( Minecraft.getMinecraft(), 0, 0, mouseX, mouseY ); | ||||
|         terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() ); | ||||
|  | ||||
|         // Draw border/inventory | ||||
|         GlStateManager.color( 1.0F, 1.0F, 1.0F, 1.0F ); | ||||
|         GlStateManager.color4f( 1.0F, 1.0F, 1.0F, 1.0F ); | ||||
|         mc.getTextureManager().bindTexture( advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL ); | ||||
|         drawTexturedModalRect( guiLeft, guiTop, 0, 0, xSize, ySize ); | ||||
|  | ||||
| @@ -140,10 +108,10 @@ public class GuiTurtle extends GuiContainer | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void drawScreen( int mouseX, int mouseY, float partialTicks ) | ||||
|     public void render( int mouseX, int mouseY, float partialTicks ) | ||||
|     { | ||||
|         drawDefaultBackground(); | ||||
|         super.drawScreen( mouseX, mouseY, partialTicks ); | ||||
|         super.render( mouseX, mouseY, partialTicks ); | ||||
|         renderHoveredToolTip( mouseX, mouseY ); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,84 +0,0 @@ | ||||
| /* | ||||
|  * This file is part of ComputerCraft - http://www.computercraft.info | ||||
|  * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission. | ||||
|  * Send enquiries to dratcliffe@gmail.com | ||||
|  */ | ||||
|  | ||||
| package dan200.computercraft.client.gui.widgets; | ||||
|  | ||||
| import net.minecraft.client.Minecraft; | ||||
| import net.minecraft.client.gui.Gui; | ||||
|  | ||||
| public abstract class Widget extends Gui | ||||
| { | ||||
|     private int m_xPosition; | ||||
|     private int m_yPosition; | ||||
|     private int m_width; | ||||
|     private int m_height; | ||||
|  | ||||
|     protected Widget( int x, int y, int width, int height ) | ||||
|     { | ||||
|         m_xPosition = x; | ||||
|         m_yPosition = y; | ||||
|         m_width = width; | ||||
|         m_height = height; | ||||
|     } | ||||
|  | ||||
|     public int getXPosition() | ||||
|     { | ||||
|         return m_xPosition; | ||||
|     } | ||||
|  | ||||
|     public int getYPosition() | ||||
|     { | ||||
|         return m_yPosition; | ||||
|     } | ||||
|  | ||||
|     public int getWidth() | ||||
|     { | ||||
|         return m_width; | ||||
|     } | ||||
|  | ||||
|     public int getHeight() | ||||
|     { | ||||
|         return m_height; | ||||
|     } | ||||
|  | ||||
|     public void update() | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public void draw( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY ) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public void handleMouseInput( int mouseX, int mouseY ) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public boolean onKeyboardInput() | ||||
|     { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Deprecated | ||||
|     public void handleKeyboardInput() | ||||
|     { | ||||
|         onKeyboardInput(); | ||||
|     } | ||||
|  | ||||
|     public void mouseClicked( int mouseX, int mouseY, int mouseButton ) | ||||
|     { | ||||
|     } | ||||
|  | ||||
|     public boolean onKeyTyped( char c, int k ) | ||||
|     { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Deprecated | ||||
|     public void keyTyped( char c, int k ) | ||||
|     { | ||||
|         onKeyTyped( c, k ); | ||||
|     } | ||||
| } | ||||
| @@ -10,371 +10,349 @@ import dan200.computercraft.client.FrameInfo; | ||||
| import dan200.computercraft.client.gui.FixedWidthFontRenderer; | ||||
| import dan200.computercraft.core.terminal.Terminal; | ||||
| import dan200.computercraft.core.terminal.TextBuffer; | ||||
| import dan200.computercraft.shared.computer.core.ClientComputer; | ||||
| import dan200.computercraft.shared.computer.core.IComputer; | ||||
| import dan200.computercraft.shared.computer.core.IComputerContainer; | ||||
| import dan200.computercraft.shared.util.Colour; | ||||
| import dan200.computercraft.shared.util.Palette; | ||||
| import net.minecraft.client.Minecraft; | ||||
| import net.minecraft.client.gui.GuiScreen; | ||||
| import net.minecraft.client.gui.IGuiEventListener; | ||||
| import net.minecraft.client.renderer.BufferBuilder; | ||||
| import net.minecraft.client.renderer.GlStateManager; | ||||
| import net.minecraft.util.ChatAllowedCharacters; | ||||
| import org.lwjgl.input.Keyboard; | ||||
| import org.lwjgl.input.Mouse; | ||||
| import net.minecraft.client.renderer.Tessellator; | ||||
| import net.minecraft.client.renderer.vertex.DefaultVertexFormats; | ||||
| import net.minecraft.util.SharedConstants; | ||||
| import org.lwjgl.glfw.GLFW; | ||||
| import org.lwjgl.opengl.GL11; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.BitSet; | ||||
| import java.util.function.Supplier; | ||||
|  | ||||
| import static dan200.computercraft.client.gui.FixedWidthFontRenderer.BACKGROUND; | ||||
|  | ||||
| public class WidgetTerminal extends Widget | ||||
| public class WidgetTerminal implements IGuiEventListener | ||||
| { | ||||
|     private static final float TERMINATE_TIME = 0.5f; | ||||
|  | ||||
|     private final IComputerContainer m_computer; | ||||
|     private final Minecraft client; | ||||
|  | ||||
|     private float m_terminateTimer = 0.0f; | ||||
|     private float m_rebootTimer = 0.0f; | ||||
|     private float m_shutdownTimer = 0.0f; | ||||
|     private final Supplier<ClientComputer> computer; | ||||
|     private final int termWidth; | ||||
|     private final int termHeight; | ||||
|  | ||||
|     private int m_lastClickButton = -1; | ||||
|     private int m_lastClickX = -1; | ||||
|     private int m_lastClickY = -1; | ||||
|     private float terminateTimer = -1; | ||||
|     private float rebootTimer = -1; | ||||
|     private float shutdownTimer = -1; | ||||
|  | ||||
|     private boolean m_focus = false; | ||||
|     private boolean m_allowFocusLoss = true; | ||||
|     private int lastMouseButton = -1; | ||||
|     private int lastMouseX = -1; | ||||
|     private int lastMouseY = -1; | ||||
|  | ||||
|     private int m_leftMargin; | ||||
|     private int m_rightMargin; | ||||
|     private int m_topMargin; | ||||
|     private int m_bottomMargin; | ||||
|     private final int leftMargin; | ||||
|     private final int rightMargin; | ||||
|     private final int topMargin; | ||||
|     private final int bottomMargin; | ||||
|  | ||||
|     private final ArrayList<Integer> m_keysDown = new ArrayList<>(); | ||||
|     private final BitSet keysDown = new BitSet( 256 ); | ||||
|  | ||||
|     public WidgetTerminal( int x, int y, int termWidth, int termHeight, IComputerContainer computer, int leftMargin, int rightMargin, int topMargin, int bottomMargin ) | ||||
|     public WidgetTerminal( Minecraft client, Supplier<ClientComputer> computer, int termWidth, int termHeight, int leftMargin, int rightMargin, int topMargin, int bottomMargin ) | ||||
|     { | ||||
|         super( | ||||
|             x, y, | ||||
|             leftMargin + rightMargin + termWidth * FixedWidthFontRenderer.FONT_WIDTH, | ||||
|             topMargin + bottomMargin + termHeight * FixedWidthFontRenderer.FONT_HEIGHT | ||||
|         ); | ||||
|  | ||||
|         m_computer = computer; | ||||
|  | ||||
|         m_leftMargin = leftMargin; | ||||
|         m_rightMargin = rightMargin; | ||||
|         m_topMargin = topMargin; | ||||
|         m_bottomMargin = bottomMargin; | ||||
|     } | ||||
|  | ||||
|     public void setAllowFocusLoss( boolean allowFocusLoss ) | ||||
|     { | ||||
|         m_allowFocusLoss = allowFocusLoss; | ||||
|         m_focus = m_focus || !allowFocusLoss; | ||||
|         this.client = client; | ||||
|         this.computer = computer; | ||||
|         this.termWidth = termWidth; | ||||
|         this.termHeight = termHeight; | ||||
|         this.leftMargin = leftMargin; | ||||
|         this.rightMargin = rightMargin; | ||||
|         this.topMargin = topMargin; | ||||
|         this.bottomMargin = bottomMargin; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean onKeyTyped( char ch, int key ) | ||||
|     public boolean charTyped( char ch, int modifiers ) | ||||
|     { | ||||
|         if( m_focus ) | ||||
|         if( ch >= 32 && ch <= 126 || ch >= 160 && ch <= 255 ) // printable chars in byte range | ||||
|         { | ||||
|             // Ctrl+V for paste | ||||
|             if( ch == 22 ) | ||||
|             // Queue the "char" event | ||||
|             queueEvent( "char", Character.toString( ch ) ); | ||||
|         } | ||||
|  | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean keyPressed( int key, int scancode, int modifiers ) | ||||
|     { | ||||
|         if( key == GLFW.GLFW_KEY_ESCAPE ) return false; | ||||
|         if( (modifiers & GLFW.GLFW_MOD_CONTROL) != 0 ) | ||||
|         { | ||||
|             switch( key ) | ||||
|             { | ||||
|                 String clipboard = GuiScreen.getClipboardString(); | ||||
|                 if( clipboard != null ) | ||||
|                 { | ||||
|                     // Clip to the first occurrence of \r or \n | ||||
|                     int newLineIndex1 = clipboard.indexOf( '\r' ); | ||||
|                     int newLineIndex2 = clipboard.indexOf( '\n' ); | ||||
|                     if( newLineIndex1 >= 0 && newLineIndex2 >= 0 ) | ||||
|                     { | ||||
|                         clipboard = clipboard.substring( 0, Math.min( newLineIndex1, newLineIndex2 ) ); | ||||
|                     } | ||||
|                     else if( newLineIndex1 >= 0 ) | ||||
|                     { | ||||
|                         clipboard = clipboard.substring( 0, newLineIndex1 ); | ||||
|                     } | ||||
|                     else if( newLineIndex2 >= 0 ) | ||||
|                     { | ||||
|                         clipboard = clipboard.substring( 0, newLineIndex2 ); | ||||
|                     } | ||||
|                 case GLFW.GLFW_KEY_T: | ||||
|                     if( terminateTimer < 0 ) terminateTimer = 0; | ||||
|                     return true; | ||||
|                 case GLFW.GLFW_KEY_S: | ||||
|                     if( shutdownTimer < 0 ) shutdownTimer = 0; | ||||
|                     return true; | ||||
|                 case GLFW.GLFW_KEY_R: | ||||
|                     if( rebootTimer < 0 ) rebootTimer = 0; | ||||
|                     return true; | ||||
|  | ||||
|                     // Filter the string | ||||
|                     clipboard = ChatAllowedCharacters.filterAllowedCharacters( clipboard ); | ||||
|  | ||||
|                     if( !clipboard.isEmpty() ) | ||||
|                 case GLFW.GLFW_KEY_V: | ||||
|                     // Ctrl+V for paste | ||||
|                     String clipboard = client.keyboardListener.getClipboardString(); | ||||
|                     if( clipboard != null ) | ||||
|                     { | ||||
|                         // Clip to 512 characters | ||||
|                         if( clipboard.length() > 512 ) | ||||
|                         // Clip to the first occurrence of \r or \n | ||||
|                         int newLineIndex1 = clipboard.indexOf( "\r" ); | ||||
|                         int newLineIndex2 = clipboard.indexOf( "\n" ); | ||||
|                         if( newLineIndex1 >= 0 && newLineIndex2 >= 0 ) | ||||
|                         { | ||||
|                             clipboard = clipboard.substring( 0, 512 ); | ||||
|                             clipboard = clipboard.substring( 0, Math.min( newLineIndex1, newLineIndex2 ) ); | ||||
|                         } | ||||
|                         else if( newLineIndex1 >= 0 ) | ||||
|                         { | ||||
|                             clipboard = clipboard.substring( 0, newLineIndex1 ); | ||||
|                         } | ||||
|                         else if( newLineIndex2 >= 0 ) | ||||
|                         { | ||||
|                             clipboard = clipboard.substring( 0, newLineIndex2 ); | ||||
|                         } | ||||
|  | ||||
|                         // Queue the "paste" event | ||||
|                         queueEvent( "paste", new Object[] { clipboard } ); | ||||
|                     } | ||||
|                 } | ||||
|                 return true; | ||||
|             } | ||||
|                         // Filter the string | ||||
|                         clipboard = SharedConstants.filterAllowedCharacters( clipboard ); | ||||
|                         if( !clipboard.isEmpty() ) | ||||
|                         { | ||||
|                             // Clip to 512 characters and queue the event | ||||
|                             if( clipboard.length() > 512 ) clipboard = clipboard.substring( 0, 512 ); | ||||
|                             queueEvent( "paste", clipboard ); | ||||
|                         } | ||||
|  | ||||
|             // Regular keys normally | ||||
|             if( m_terminateTimer <= 0.0f && m_rebootTimer <= 0.0f && m_shutdownTimer <= 0.0f ) | ||||
|                         return true; | ||||
|                     } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if( key >= 0 && terminateTimer < 0 && rebootTimer < 0 && shutdownTimer < 0 ) | ||||
|         { | ||||
|             // Queue the "key" event and add to the down set | ||||
|             boolean repeat = keysDown.get( key ); | ||||
|             keysDown.set( key ); | ||||
|             IComputer computer = this.computer.get(); | ||||
|             if( computer != null ) computer.keyDown( key, repeat ); | ||||
|         } | ||||
|  | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean keyReleased( int key, int scancode, int modifiers ) | ||||
|     { | ||||
|         // Queue the "key_up" event and remove from the down set | ||||
|         if( key >= 0 && keysDown.get( key ) ) | ||||
|         { | ||||
|             keysDown.set( key, false ); | ||||
|             IComputer computer = this.computer.get(); | ||||
|             if( computer != null ) computer.keyUp( key ); | ||||
|         } | ||||
|  | ||||
|         switch( key ) | ||||
|         { | ||||
|             case GLFW.GLFW_KEY_T: | ||||
|                 terminateTimer = -1; | ||||
|                 break; | ||||
|             case GLFW.GLFW_KEY_R: | ||||
|                 rebootTimer = -1; | ||||
|                 break; | ||||
|             case GLFW.GLFW_KEY_S: | ||||
|                 shutdownTimer = -1; | ||||
|                 break; | ||||
|             case GLFW.GLFW_KEY_LEFT_CONTROL: | ||||
|             case GLFW.GLFW_KEY_RIGHT_CONTROL: | ||||
|                 terminateTimer = rebootTimer = shutdownTimer = -1; | ||||
|                 break; | ||||
|         } | ||||
|  | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean mouseClicked( double mouseX, double mouseY, int button ) | ||||
|     { | ||||
|         ClientComputer computer = this.computer.get(); | ||||
|         if( computer == null || !computer.isColour() || button < 0 || button > 2 ) return false; | ||||
|  | ||||
|         Terminal term = computer.getTerminal(); | ||||
|         if( term != null ) | ||||
|         { | ||||
|             int charX = (int) (mouseX / FixedWidthFontRenderer.FONT_WIDTH); | ||||
|             int charY = (int) (mouseY / FixedWidthFontRenderer.FONT_HEIGHT); | ||||
|             charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 ); | ||||
|             charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 ); | ||||
|  | ||||
|             computer.mouseClick( button + 1, charX + 1, charY + 1 ); | ||||
|  | ||||
|             lastMouseButton = button; | ||||
|             lastMouseX = charX; | ||||
|             lastMouseY = charY; | ||||
|         } | ||||
|  | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean mouseReleased( double mouseX, double mouseY, int button ) | ||||
|     { | ||||
|         ClientComputer computer = this.computer.get(); | ||||
|         if( computer == null || !computer.isColour() || button < 0 || button > 2 ) return false; | ||||
|  | ||||
|         Terminal term = computer.getTerminal(); | ||||
|         if( term != null ) | ||||
|         { | ||||
|             int charX = (int) (mouseX / FixedWidthFontRenderer.FONT_WIDTH); | ||||
|             int charY = (int) (mouseY / FixedWidthFontRenderer.FONT_HEIGHT); | ||||
|             charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 ); | ||||
|             charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 ); | ||||
|  | ||||
|             if( lastMouseButton == button ) | ||||
|             { | ||||
|                 boolean repeat = Keyboard.isRepeatEvent(); | ||||
|                 boolean handled = false; | ||||
|                 if( key > 0 ) | ||||
|                 { | ||||
|                     if( !repeat ) | ||||
|                     { | ||||
|                         m_keysDown.add( key ); | ||||
|                     } | ||||
|  | ||||
|                     // Queue the "key" event | ||||
|                     IComputer computer = m_computer.getComputer(); | ||||
|                     if( computer != null ) computer.keyDown( key, repeat ); | ||||
|                     handled = true; | ||||
|                 } | ||||
|  | ||||
|                 if( (ch >= 32 && ch <= 126) || (ch >= 160 && ch <= 255) ) // printable chars in byte range | ||||
|                 { | ||||
|                     // Queue the "char" event | ||||
|                     queueEvent( "char", new Object[] { Character.toString( ch ) } ); | ||||
|                     handled = true; | ||||
|                 } | ||||
|  | ||||
|                 return handled; | ||||
|                 computer.mouseUp( lastMouseButton + 1, charX + 1, charY + 1 ); | ||||
|                 lastMouseButton = -1; | ||||
|             } | ||||
|  | ||||
|             lastMouseX = charX; | ||||
|             lastMouseY = charY; | ||||
|         } | ||||
|  | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void mouseClicked( int mouseX, int mouseY, int button ) | ||||
|     public boolean mouseDragged( double mouseX, double mouseY, int button, double v2, double v3 ) | ||||
|     { | ||||
|         if( mouseX >= getXPosition() && mouseX < getXPosition() + getWidth() && | ||||
|             mouseY >= getYPosition() && mouseY < getYPosition() + getHeight() ) | ||||
|         ClientComputer computer = this.computer.get(); | ||||
|         if( computer == null || !computer.isColour() || button < 0 || button > 2 ) return false; | ||||
|  | ||||
|         Terminal term = computer.getTerminal(); | ||||
|         if( term != null ) | ||||
|         { | ||||
|             if( !m_focus && button == 0 ) | ||||
|             { | ||||
|                 m_focus = true; | ||||
|             } | ||||
|             int charX = (int) (mouseX / FixedWidthFontRenderer.FONT_WIDTH); | ||||
|             int charY = (int) (mouseY / FixedWidthFontRenderer.FONT_HEIGHT); | ||||
|             charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 ); | ||||
|             charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 ); | ||||
|  | ||||
|             if( m_focus ) | ||||
|             { | ||||
|                 IComputer computer = m_computer.getComputer(); | ||||
|                 if( computer != null && computer.isColour() && button >= 0 && button <= 2 ) | ||||
|                 { | ||||
|                     Terminal term = computer.getTerminal(); | ||||
|                     if( term != null ) | ||||
|                     { | ||||
|                         int charX = (mouseX - (getXPosition() + m_leftMargin)) / FixedWidthFontRenderer.FONT_WIDTH; | ||||
|                         int charY = (mouseY - (getYPosition() + m_topMargin)) / FixedWidthFontRenderer.FONT_HEIGHT; | ||||
|                         charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 ); | ||||
|                         charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 ); | ||||
|             computer.mouseDrag( button + 1, charX + 1, charY + 1 ); | ||||
|  | ||||
|                         computer.mouseClick( button + 1, charX + 1, charY + 1 ); | ||||
|  | ||||
|                         m_lastClickButton = button; | ||||
|                         m_lastClickX = charX; | ||||
|                         m_lastClickY = charY; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             if( m_focus && button == 0 && m_allowFocusLoss ) | ||||
|             { | ||||
|                 m_focus = false; | ||||
|             } | ||||
|             lastMouseX = charX; | ||||
|             lastMouseY = charY; | ||||
|             lastMouseButton = button; | ||||
|         } | ||||
|  | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean onKeyboardInput() | ||||
|     public boolean mouseScrolled( double delta ) | ||||
|     { | ||||
|         boolean handled = false; | ||||
|         for( int i = m_keysDown.size() - 1; i >= 0; --i ) | ||||
|         ClientComputer computer = this.computer.get(); | ||||
|         if( computer == null || !computer.isColour() ) return false; | ||||
|  | ||||
|         if( lastMouseX >= 0 && lastMouseY >= 0 && delta != 0 ) | ||||
|         { | ||||
|             int key = m_keysDown.get( i ); | ||||
|             if( !Keyboard.isKeyDown( key ) ) | ||||
|             { | ||||
|                 m_keysDown.remove( i ); | ||||
|                 if( m_focus ) | ||||
|                 { | ||||
|                     // Queue the "key_up" event | ||||
|                     IComputer computer = m_computer.getComputer(); | ||||
|                     if( computer != null ) computer.keyUp( key ); | ||||
|                     handled = true; | ||||
|                 } | ||||
|             } | ||||
|             queueEvent( "mouse_scroll", delta < 0 ? 1 : -1, lastMouseX + 1, lastMouseY + 1 ); | ||||
|         } | ||||
|  | ||||
|         return handled; | ||||
|         return true; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void handleMouseInput( int mouseX, int mouseY ) | ||||
|     { | ||||
|         IComputer computer = m_computer.getComputer(); | ||||
|         if( mouseX >= getXPosition() && mouseX < getXPosition() + getWidth() && | ||||
|             mouseY >= getYPosition() && mouseY < getYPosition() + getHeight() && | ||||
|             computer != null && computer.isColour() ) | ||||
|         { | ||||
|             Terminal term = computer.getTerminal(); | ||||
|             if( term != null ) | ||||
|             { | ||||
|                 int charX = (mouseX - (getXPosition() + m_leftMargin)) / FixedWidthFontRenderer.FONT_WIDTH; | ||||
|                 int charY = (mouseY - (getYPosition() + m_topMargin)) / FixedWidthFontRenderer.FONT_HEIGHT; | ||||
|                 charX = Math.min( Math.max( charX, 0 ), term.getWidth() - 1 ); | ||||
|                 charY = Math.min( Math.max( charY, 0 ), term.getHeight() - 1 ); | ||||
|  | ||||
|                 if( m_lastClickButton >= 0 && !Mouse.isButtonDown( m_lastClickButton ) ) | ||||
|                 { | ||||
|                     if( m_focus ) computer.mouseUp( m_lastClickButton + 1, charX + 1, charY + 1 ); | ||||
|                     m_lastClickButton = -1; | ||||
|                 } | ||||
|  | ||||
|                 int wheelChange = Mouse.getEventDWheel(); | ||||
|                 if( wheelChange == 0 && m_lastClickButton == -1 ) | ||||
|                 { | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 if( m_focus ) | ||||
|                 { | ||||
|                     if( wheelChange < 0 ) | ||||
|                     { | ||||
|                         computer.mouseScroll( 1, charX + 1, charY + 1 ); | ||||
|                     } | ||||
|                     else if( wheelChange > 0 ) | ||||
|                     { | ||||
|                         computer.mouseScroll( -1, charX + 1, charY + 1 ); | ||||
|                     } | ||||
|  | ||||
|                     if( m_lastClickButton >= 0 && (charX != m_lastClickX || charY != m_lastClickY) ) | ||||
|                     { | ||||
|                         computer.mouseDrag( m_lastClickButton + 1, charX + 1, charY + 1 ); | ||||
|                         m_lastClickX = charX; | ||||
|                         m_lastClickY = charY; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void update() | ||||
|     { | ||||
|         // Handle special keys | ||||
|         if( m_focus && (Keyboard.isKeyDown( 29 ) || Keyboard.isKeyDown( 157 )) ) | ||||
|         if( terminateTimer >= 0 && terminateTimer < TERMINATE_TIME && (terminateTimer += 0.05f) > TERMINATE_TIME ) | ||||
|         { | ||||
|             // Ctrl+T for terminate | ||||
|             if( Keyboard.isKeyDown( 20 ) ) | ||||
|             { | ||||
|                 if( m_terminateTimer < TERMINATE_TIME ) | ||||
|                 { | ||||
|                     m_terminateTimer += 0.05f; | ||||
|                     if( m_terminateTimer >= TERMINATE_TIME ) queueEvent( "terminate" ); | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 m_terminateTimer = 0.0f; | ||||
|             } | ||||
|  | ||||
|             // Ctrl+R for reboot | ||||
|             if( Keyboard.isKeyDown( 19 ) ) | ||||
|             { | ||||
|                 if( m_rebootTimer < TERMINATE_TIME ) | ||||
|                 { | ||||
|                     m_rebootTimer += 0.05f; | ||||
|                     if( m_rebootTimer >= TERMINATE_TIME ) | ||||
|                     { | ||||
|                         IComputer computer = m_computer.getComputer(); | ||||
|                         if( computer != null ) computer.reboot(); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 m_rebootTimer = 0.0f; | ||||
|             } | ||||
|  | ||||
|             // Ctrl+S for shutdown | ||||
|             if( Keyboard.isKeyDown( 31 ) ) | ||||
|             { | ||||
|                 if( m_shutdownTimer < TERMINATE_TIME ) | ||||
|                 { | ||||
|                     m_shutdownTimer += 0.05f; | ||||
|                     if( m_shutdownTimer >= TERMINATE_TIME ) | ||||
|                     { | ||||
|                         IComputer computer = m_computer.getComputer(); | ||||
|                         if( computer != null ) computer.shutdown(); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 m_shutdownTimer = 0.0f; | ||||
|             } | ||||
|             queueEvent( "terminate" ); | ||||
|         } | ||||
|         else | ||||
|  | ||||
|         if( shutdownTimer >= 0 && shutdownTimer < TERMINATE_TIME && (shutdownTimer += 0.05f) > TERMINATE_TIME ) | ||||
|         { | ||||
|             m_terminateTimer = 0.0f; | ||||
|             m_rebootTimer = 0.0f; | ||||
|             m_shutdownTimer = 0.0f; | ||||
|             ClientComputer computer = this.computer.get(); | ||||
|             if( computer != null ) computer.shutdown(); | ||||
|         } | ||||
|  | ||||
|         if( rebootTimer >= 0 && rebootTimer < TERMINATE_TIME && (rebootTimer += 0.05f) > TERMINATE_TIME ) | ||||
|         { | ||||
|             ClientComputer computer = this.computer.get(); | ||||
|             if( computer != null ) computer.reboot(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void draw( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY ) | ||||
|     public void focusChanged( boolean focused ) | ||||
|     { | ||||
|         int startX = xOrigin + getXPosition(); | ||||
|         int startY = yOrigin + getYPosition(); | ||||
|         if( !focused ) | ||||
|         { | ||||
|             // When blurring, we should make all keys go up | ||||
|             for( int key = 0; key < keysDown.size(); key++ ) | ||||
|             { | ||||
|                 if( keysDown.get( key ) ) queueEvent( "key_up", key ); | ||||
|             } | ||||
|             keysDown.clear(); | ||||
|  | ||||
|         synchronized( m_computer ) | ||||
|             // When blurring, we should make the last mouse button go up | ||||
|             if( lastMouseButton > 0 ) | ||||
|             { | ||||
|                 IComputer computer = this.computer.get(); | ||||
|                 if( computer != null ) computer.mouseUp( lastMouseButton + 1, lastMouseX + 1, lastMouseY + 1 ); | ||||
|                 lastMouseButton = -1; | ||||
|             } | ||||
|  | ||||
|             shutdownTimer = terminateTimer = rebootTimer = -1; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public void draw( int originX, int originY ) | ||||
|     { | ||||
|         synchronized( computer ) | ||||
|         { | ||||
|             // Draw the screen contents | ||||
|             IComputer computer = m_computer.getComputer(); | ||||
|             ClientComputer computer = this.computer.get(); | ||||
|             Terminal terminal = computer != null ? computer.getTerminal() : null; | ||||
|             if( terminal != null ) | ||||
|             { | ||||
|                 // Draw the terminal | ||||
|                 boolean greyscale = !computer.isColour(); | ||||
|  | ||||
|                 Palette palette = terminal.getPalette(); | ||||
|  | ||||
|                 // 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.instance(); | ||||
|                 boolean tblink = m_focus && terminal.getCursorBlink() && FrameInfo.getGlobalCursorBlink(); | ||||
|                 boolean tblink = terminal.getCursorBlink() && FrameInfo.getGlobalCursorBlink(); | ||||
|                 int tw = terminal.getWidth(); | ||||
|                 int th = terminal.getHeight(); | ||||
|                 int tx = terminal.getCursorX(); | ||||
|                 int ty = terminal.getCursorY(); | ||||
|  | ||||
|                 int x = startX + m_leftMargin; | ||||
|                 int y = startY + m_topMargin; | ||||
|  | ||||
|                 // Draw margins | ||||
|                 TextBuffer emptyLine = new TextBuffer( ' ', tw ); | ||||
|                 if( m_topMargin > 0 ) | ||||
|                 if( topMargin > 0 ) | ||||
|                 { | ||||
|                     fontRenderer.drawString( emptyLine, x, startY, terminal.getTextColourLine( 0 ), terminal.getBackgroundColourLine( 0 ), m_leftMargin, m_rightMargin, greyscale, palette ); | ||||
|                     fontRenderer.drawString( emptyLine, originX, originY - topMargin, | ||||
|                         terminal.getTextColourLine( 0 ), terminal.getBackgroundColourLine( 0 ), | ||||
|                         leftMargin, rightMargin, greyscale, palette ); | ||||
|                 } | ||||
|                 if( m_bottomMargin > 0 ) | ||||
|  | ||||
|                 if( bottomMargin > 0 ) | ||||
|                 { | ||||
|                     fontRenderer.drawString( emptyLine, x, startY + 2 * m_bottomMargin + (th - 1) * FixedWidthFontRenderer.FONT_HEIGHT, terminal.getTextColourLine( th - 1 ), terminal.getBackgroundColourLine( th - 1 ), m_leftMargin, m_rightMargin, greyscale, palette ); | ||||
|                     fontRenderer.drawString( emptyLine, originX, originY + bottomMargin + (th - 1) * FixedWidthFontRenderer.FONT_HEIGHT, | ||||
|                         terminal.getTextColourLine( th - 1 ), terminal.getBackgroundColourLine( th - 1 ), | ||||
|                         leftMargin, rightMargin, greyscale, palette ); | ||||
|                 } | ||||
|  | ||||
|                 // Draw lines | ||||
|                 int y = originY; | ||||
|                 for( int line = 0; line < th; line++ ) | ||||
|                 { | ||||
|                     TextBuffer text = terminal.getLine( line ); | ||||
|                     TextBuffer colour = terminal.getTextColourLine( line ); | ||||
|                     TextBuffer backgroundColour = terminal.getBackgroundColourLine( line ); | ||||
|                     fontRenderer.drawString( text, x, y, colour, backgroundColour, m_leftMargin, m_rightMargin, greyscale, palette ); | ||||
|                     fontRenderer.drawString( text, originX, y, colour, backgroundColour, leftMargin, rightMargin, greyscale, palette ); | ||||
|                     y += FixedWidthFontRenderer.FONT_HEIGHT; | ||||
|                 } | ||||
|  | ||||
| @@ -385,8 +363,8 @@ public class WidgetTerminal extends Widget | ||||
|  | ||||
|                     fontRenderer.drawString( | ||||
|                         cursor, | ||||
|                         x + FixedWidthFontRenderer.FONT_WIDTH * tx, | ||||
|                         startY + m_topMargin + FixedWidthFontRenderer.FONT_HEIGHT * ty, | ||||
|                         originX + FixedWidthFontRenderer.FONT_WIDTH * tx, | ||||
|                         originY + FixedWidthFontRenderer.FONT_HEIGHT * ty, | ||||
|                         cursorColour, null, | ||||
|                         0, 0, | ||||
|                         greyscale, | ||||
| @@ -397,16 +375,29 @@ public class WidgetTerminal extends Widget | ||||
|             else | ||||
|             { | ||||
|                 // Draw a black background | ||||
|                 mc.getTextureManager().bindTexture( BACKGROUND ); | ||||
|                 Colour black = Colour.Black; | ||||
|                 GlStateManager.color( black.getR(), black.getG(), black.getB(), 1.0f ); | ||||
|                 GlStateManager.color4f( black.getR(), black.getG(), black.getB(), 1.0f ); | ||||
|                 try | ||||
|                 { | ||||
|                     drawTexturedModalRect( startX, startY, 0, 0, getWidth(), getHeight() ); | ||||
|                     int x = originX - leftMargin; | ||||
|                     int y = originY - rightMargin; | ||||
|                     int width = termWidth * FixedWidthFontRenderer.FONT_WIDTH + leftMargin + rightMargin; | ||||
|                     int height = termHeight * FixedWidthFontRenderer.FONT_HEIGHT + topMargin + bottomMargin; | ||||
|  | ||||
|                     client.getTextureManager().bindTexture( BACKGROUND ); | ||||
|  | ||||
|                     Tessellator tesslector = Tessellator.getInstance(); | ||||
|                     BufferBuilder buffer = tesslector.getBuffer(); | ||||
|                     buffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX ); | ||||
|                     buffer.pos( x, y + height, 0 ).tex( 0 / 256.0, height / 256.0 ).endVertex(); | ||||
|                     buffer.pos( x + width, y + height, 0 ).tex( width / 256.0, height / 256.0 ).endVertex(); | ||||
|                     buffer.pos( x + width, y, 0 ).tex( width / 256.0, 0 / 256.0 ).endVertex(); | ||||
|                     buffer.pos( x, y, 0 ).tex( 0 / 256.0, 0 / 256.0 ).endVertex(); | ||||
|                     tesslector.draw(); | ||||
|                 } | ||||
|                 finally | ||||
|                 { | ||||
|                     GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f ); | ||||
|                     GlStateManager.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @@ -414,13 +405,13 @@ public class WidgetTerminal extends Widget | ||||
|  | ||||
|     private void queueEvent( String event ) | ||||
|     { | ||||
|         IComputer computer = m_computer.getComputer(); | ||||
|         ClientComputer computer = this.computer.get(); | ||||
|         if( computer != null ) computer.queueEvent( event ); | ||||
|     } | ||||
|  | ||||
|     private void queueEvent( String event, Object[] args ) | ||||
|     private void queueEvent( String event, Object... args ) | ||||
|     { | ||||
|         IComputer computer = m_computer.getComputer(); | ||||
|         ClientComputer computer = this.computer.get(); | ||||
|         if( computer != null ) computer.queueEvent( event, args ); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,104 @@ | ||||
| /* | ||||
|  * This file is part of ComputerCraft - http://www.computercraft.info | ||||
|  * Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission. | ||||
|  * Send enquiries to dratcliffe@gmail.com | ||||
|  */ | ||||
|  | ||||
| package dan200.computercraft.client.gui.widgets; | ||||
|  | ||||
| import net.minecraft.client.gui.IGuiEventListener; | ||||
|  | ||||
| public class WidgetWrapper implements IGuiEventListener | ||||
| { | ||||
|     private final IGuiEventListener listener; | ||||
|     private final int x; | ||||
|     private final int y; | ||||
|     private final int width; | ||||
|     private final int height; | ||||
|  | ||||
|     public WidgetWrapper( IGuiEventListener listener, int x, int y, int width, int height ) | ||||
|     { | ||||
|         this.listener = listener; | ||||
|         this.x = x; | ||||
|         this.y = y; | ||||
|         this.width = width; | ||||
|         this.height = height; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void focusChanged( boolean b ) | ||||
|     { | ||||
|         listener.focusChanged( b ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean canFocus() | ||||
|     { | ||||
|         return listener.canFocus(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean mouseClicked( double x, double y, int button ) | ||||
|     { | ||||
|         double dx = x - this.x, dy = y - this.y; | ||||
|         return dx >= 0 && dx < width && dy >= 0 && dy < height && listener.mouseClicked( dx, dy, button ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean mouseReleased( double x, double y, int button ) | ||||
|     { | ||||
|         double dx = x - this.x, dy = y - this.y; | ||||
|         return dx >= 0 && dx < width && dy >= 0 && dy < height && listener.mouseReleased( dx, dy, button ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY ) | ||||
|     { | ||||
|         double dx = x - this.x, dy = y - this.y; | ||||
|         return dx >= 0 && dx < width && dy >= 0 && dy < height && listener.mouseDragged( dx, dy, button, deltaX, deltaY ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean mouseScrolled( double delta ) | ||||
|     { | ||||
|         return listener.mouseScrolled( delta ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean keyPressed( int key, int scancode, int modifiers ) | ||||
|     { | ||||
|         return listener.keyPressed( key, scancode, modifiers ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean keyReleased( int key, int scancode, int modifiers ) | ||||
|     { | ||||
|         return listener.keyReleased( key, scancode, modifiers ); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public boolean charTyped( char character, int modifiers ) | ||||
|     { | ||||
|         return listener.charTyped( character, modifiers ); | ||||
|     } | ||||
|  | ||||
|     public int getX() | ||||
|     { | ||||
|         return x; | ||||
|     } | ||||
|  | ||||
|     public int getY() | ||||
|     { | ||||
|         return y; | ||||
|     } | ||||
|  | ||||
|     public int getWidth() | ||||
|     { | ||||
|         return width; | ||||
|     } | ||||
|  | ||||
|     public int getHeight() | ||||
|     { | ||||
|         return height; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 SquidDev
					SquidDev