mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-13 11:40:29 +00:00
Add missing classes
This commit is contained in:
parent
b202b7b8a5
commit
43d68db349
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
package dan200.computercraft.client.gui.widgets;
|
||||
|
||||
public class MousePos
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
|
||||
public MousePos( int x, int y )
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
@ -6,8 +6,6 @@
|
||||
|
||||
package dan200.computercraft.client.gui.widgets;
|
||||
|
||||
import dan200.computercraftedu.client.gui.widgets.MousePos;
|
||||
import dan200.computercraftedu.client.gui.widgets.WidgetContainer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
@ -0,0 +1,344 @@
|
||||
/**
|
||||
* This file is part of ComputerCraft - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2016. Do not distribute without permission.
|
||||
* Send enquiries to dratcliffe@gmail.com
|
||||
*/
|
||||
|
||||
|
||||
package dan200.computercraft.client.gui.widgets;
|
||||
|
||||
import dan200.computercraft.client.gui.widgets.Widget;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class WidgetContainer extends Widget
|
||||
{
|
||||
private ArrayList<Widget> m_widgets;
|
||||
private Widget m_modalWidget;
|
||||
|
||||
public WidgetContainer( int x, int y, int w, int h )
|
||||
{
|
||||
super( x, y, w, h );
|
||||
m_widgets = new ArrayList<Widget>();
|
||||
m_modalWidget = null;
|
||||
}
|
||||
|
||||
public void addWidget( Widget widget )
|
||||
{
|
||||
m_widgets.add( widget );
|
||||
widget.setParent( this );
|
||||
}
|
||||
|
||||
public void setModalWidget( Widget widget )
|
||||
{
|
||||
m_modalWidget = widget;
|
||||
if( widget != null )
|
||||
{
|
||||
widget.setParent( this );
|
||||
}
|
||||
}
|
||||
|
||||
public Widget getModalWidget()
|
||||
{
|
||||
return m_modalWidget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
for( int i=0; i<m_widgets.size(); ++i )
|
||||
{
|
||||
m_widgets.get( i ).update();
|
||||
}
|
||||
if( m_modalWidget != null )
|
||||
{
|
||||
m_modalWidget.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY )
|
||||
{
|
||||
for( int i=0; i<m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.draw(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
(m_modalWidget == null) ? (mouseX - getXPosition()) : -99,
|
||||
(m_modalWidget == null) ? (mouseY - getYPosition()) : -99
|
||||
);
|
||||
}
|
||||
}
|
||||
if( m_modalWidget != null )
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
try
|
||||
{
|
||||
GlStateManager.translate( 0.0f, 0.0f, 200.0f );
|
||||
m_modalWidget.draw(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
);
|
||||
}
|
||||
finally
|
||||
{
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawForeground( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY )
|
||||
{
|
||||
for( int i=0; i<m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.drawForeground(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
(m_modalWidget == null) ? (mouseX - getXPosition()) : -99,
|
||||
(m_modalWidget == null) ? (mouseY - getYPosition()) : -99
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if( m_modalWidget != null )
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
GlStateManager.pushMatrix();
|
||||
try
|
||||
{
|
||||
GlStateManager.translate( 0.0f, 0.0f, 200.0f );
|
||||
m_modalWidget.drawForeground(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
);
|
||||
}
|
||||
finally
|
||||
{
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyMousePosition( MousePos pos )
|
||||
{
|
||||
pos.x -= getXPosition();
|
||||
pos.y -= getYPosition();
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.modifyMousePosition( pos );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
m_modalWidget.modifyMousePosition( pos );
|
||||
}
|
||||
}
|
||||
pos.x += getXPosition();
|
||||
pos.y += getYPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean suppressItemTooltips( Minecraft mc, int xOrigin, int yOrigin, int mouseX, int mouseY )
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
if( widget.suppressItemTooltips(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() && m_modalWidget.suppressItemTooltips(
|
||||
mc,
|
||||
xOrigin + getXPosition(),
|
||||
yOrigin + getYPosition(),
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean suppressKeyPress( char c, int k )
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
if( widget.suppressKeyPress( c, k ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
if( m_modalWidget.suppressKeyPress( c, k ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput( int mouseX, int mouseY )
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.handleMouseInput(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
m_modalWidget.handleMouseInput(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleKeyboardInput()
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.handleKeyboardInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
m_modalWidget.handleKeyboardInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked( int mouseX, int mouseY, int mouseButton )
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.mouseClicked(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition(),
|
||||
mouseButton
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
m_modalWidget.mouseClicked(
|
||||
mouseX - getXPosition(),
|
||||
mouseY - getYPosition(),
|
||||
mouseButton
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped( char c, int k )
|
||||
{
|
||||
if( m_modalWidget == null )
|
||||
{
|
||||
for( int i = 0; i < m_widgets.size(); ++i )
|
||||
{
|
||||
Widget widget = m_widgets.get( i );
|
||||
if( widget.isVisible() )
|
||||
{
|
||||
widget.keyTyped( c, k );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( m_modalWidget.isVisible() )
|
||||
{
|
||||
m_modalWidget.keyTyped( c, k );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user