All GUI compile errors fixed, switched to excludes over includes in gradle build and lots, LOTS of more fixes.
This commit is contained in:
@@ -19,59 +19,39 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.config.FullnessMode;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.ItemSubstitution;
|
||||
import appeng.api.config.LevelType;
|
||||
import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.RelativeDirection;
|
||||
import appeng.api.config.SchedulingMode;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
|
||||
public class GuiImgButton extends Button implements ITooltip
|
||||
{
|
||||
private static final Pattern COMPILE = Pattern.compile( "%s" );
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private static Map<EnumPair, ButtonAppearance> appearances;
|
||||
private final Enum buttonSetting;
|
||||
private boolean halfSize = false;
|
||||
private String fillVar;
|
||||
private Enum currentValue;
|
||||
|
||||
public GuiImgButton( final int x, final int y, final Enum idx, final Enum val )
|
||||
public GuiImgButton( final int x, final int y, final Enum idx, final Enum val, IPressable onPress )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
super( x, y, 16, 16, "", onPress );
|
||||
|
||||
this.buttonSetting = idx;
|
||||
this.currentValue = val;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 16;
|
||||
this.height = 16;
|
||||
|
||||
if( appearances == null )
|
||||
{
|
||||
@@ -84,9 +64,9 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
this.registerApp( 16 * 9, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write );
|
||||
this.registerApp( 16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode, ButtonToolTips.ReadWrite );
|
||||
|
||||
this.registerApp( 16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.unlocalizedName );
|
||||
this.registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName );
|
||||
this.registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName );
|
||||
this.registerApp( 16 * 10, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.textComponent() );
|
||||
this.registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.textComponent() );
|
||||
this.registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.textComponent() );
|
||||
|
||||
this.registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive );
|
||||
this.registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal );
|
||||
@@ -177,38 +157,48 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
}
|
||||
}
|
||||
|
||||
private void registerApp( final int iconIndex, final Settings setting, final Enum val, final ButtonToolTips title, final Object hint )
|
||||
private void registerApp( final int iconIndex, final Settings setting, final Enum val, final ButtonToolTips title, final ITextComponent hint )
|
||||
{
|
||||
final ButtonAppearance a = new ButtonAppearance();
|
||||
a.displayName = title.getUnlocalized();
|
||||
a.displayValue = (String) ( hint instanceof String ? hint : ( (ButtonToolTips) hint ).getUnlocalized() );
|
||||
a.displayName = title.getTranslationKey();
|
||||
a.displayValue = hint;
|
||||
a.index = iconIndex;
|
||||
appearances.put( new EnumPair( setting, val ), a );
|
||||
}
|
||||
|
||||
private void registerApp( final int iconIndex, final Settings setting, final Enum val, final ButtonToolTips title, final ButtonToolTips hint )
|
||||
{
|
||||
registerApp(iconIndex, setting, val, title, hint.getTranslationKey());
|
||||
}
|
||||
|
||||
public void setVisibility( final boolean vis )
|
||||
{
|
||||
this.visible = vis;
|
||||
this.enabled = vis;
|
||||
this.active = vis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton( final Minecraft par1Minecraft, final int par2, final int par3, float partial )
|
||||
{
|
||||
public void renderButton(final int mouseX, final int mouseY, float partial) {
|
||||
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
|
||||
if( this.visible )
|
||||
{
|
||||
final int iconIndex = this.getIconIndex();
|
||||
|
||||
TextureManager textureManager = minecraft.getTextureManager();
|
||||
textureManager.bindTexture(TEXTURE_STATES);
|
||||
RenderSystem.disableDepthTest();
|
||||
if( this.halfSize )
|
||||
{
|
||||
this.width = 8;
|
||||
this.height = 8;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate( this.x, this.y, 0.0F );
|
||||
GlStateManager.scale( 0.5f, 0.5f, 0.5f );
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef( this.x, this.y, 0.0F );
|
||||
RenderSystem.scalef( 0.5f, 0.5f, 0.5f );
|
||||
|
||||
if( this.enabled )
|
||||
if( this.active )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
@@ -217,21 +207,16 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
}
|
||||
|
||||
par1Minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
|
||||
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
|
||||
|
||||
final int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
final int uv_y = (int) Math.floor( iconIndex / 16.0f );
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GuiUtils.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( this.enabled )
|
||||
if( this.active )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
@@ -240,16 +225,13 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
}
|
||||
|
||||
par1Minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
|
||||
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
|
||||
|
||||
final int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
}
|
||||
RenderSystem.enableDepthTest();
|
||||
}
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
@@ -281,8 +263,8 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
String displayName = null;
|
||||
String displayValue = null;
|
||||
ITextComponent displayName = null;
|
||||
ITextComponent displayValue = null;
|
||||
|
||||
if( this.buttonSetting != null && this.currentValue != null )
|
||||
{
|
||||
@@ -298,17 +280,8 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
|
||||
if( displayName != null )
|
||||
{
|
||||
String name = I18n.format( displayName );
|
||||
String value = I18n.format( displayValue );
|
||||
|
||||
if( name == null || name.isEmpty() )
|
||||
{
|
||||
name = displayName;
|
||||
}
|
||||
if( value == null || value.isEmpty() )
|
||||
{
|
||||
value = displayValue;
|
||||
}
|
||||
String name = displayName.getString();
|
||||
String value = displayValue.getString();
|
||||
|
||||
if( this.fillVar != null )
|
||||
{
|
||||
@@ -428,7 +401,7 @@ public class GuiImgButton extends Button implements ITooltip
|
||||
private static class ButtonAppearance
|
||||
{
|
||||
public int index;
|
||||
public String displayName;
|
||||
public String displayValue;
|
||||
public ITextComponent displayName;
|
||||
public ITextComponent displayValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ package appeng.client.gui.widgets;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
|
||||
|
||||
// FIXME: Fix this piece of crap (i.e. onChange listener)
|
||||
public class GuiNumberBox extends TextFieldWidget
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GuiNumberBox extends TextFieldWidget
|
||||
|
||||
public GuiNumberBox( final FontRenderer fontRenderer, final int x, final int y, final int width, final int height, final Class type )
|
||||
{
|
||||
super( 0, fontRenderer, x, y, width, height );
|
||||
super( fontRenderer, x, y, width, height, "0" );
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,16 @@ package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.container.interfaces.IProgressProvider;
|
||||
import appeng.core.localization.GuiText;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
|
||||
public class GuiProgressBar extends Button implements ITooltip
|
||||
public class GuiProgressBar extends Widget implements ITooltip
|
||||
{
|
||||
|
||||
private final IProgressProvider source;
|
||||
@@ -45,13 +47,9 @@ public class GuiProgressBar extends Button implements ITooltip
|
||||
|
||||
public GuiProgressBar( final IProgressProvider source, final String texture, final int posX, final int posY, final int u, final int y, final int width, final int height, final Direction dir, final String title )
|
||||
{
|
||||
super( posX, posY, width, "" );
|
||||
super( posX, posY, width, height, "" );
|
||||
this.source = source;
|
||||
this.x = posX;
|
||||
this.y = posY;
|
||||
this.texture = new ResourceLocation( "appliedenergistics2", "textures/" + texture );
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.fill_u = u;
|
||||
this.fill_v = y;
|
||||
this.layout = dir;
|
||||
@@ -59,26 +57,24 @@ public class GuiProgressBar extends Button implements ITooltip
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton( final Minecraft par1Minecraft, final int par2, final int par3, final float partial )
|
||||
public void renderButton( final int par2, final int par3, final float partial )
|
||||
{
|
||||
if( this.visible )
|
||||
{
|
||||
par1Minecraft.getTextureManager().bindTexture( this.texture );
|
||||
Minecraft.getInstance().getTextureManager().bindTexture( this.texture );
|
||||
final int max = this.source.getMaxProgress();
|
||||
final int current = this.source.getCurrentProgress();
|
||||
|
||||
if( this.layout == Direction.VERTICAL )
|
||||
{
|
||||
final int diff = this.height - ( max > 0 ? ( this.height * current ) / max : 0 );
|
||||
this.drawTexturedModalRect( this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width, this.height - diff );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y + diff, this.fill_u, this.fill_v + diff, this.width, this.height - diff, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
final int diff = this.width - ( max > 0 ? ( this.width * current ) / max : 0 );
|
||||
this.drawTexturedModalRect( this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff, this.height );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, this.fill_u + diff, this.fill_v, this.width - diff, this.height, 0 );
|
||||
}
|
||||
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,34 +19,31 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
|
||||
public class GuiTabButton extends Button implements ITooltip
|
||||
{
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private final ItemRenderer itemRenderer;
|
||||
private final String message;
|
||||
private int hideEdge = 0;
|
||||
private int myIcon = -1;
|
||||
private ItemStack myItem;
|
||||
|
||||
public GuiTabButton( final int x, final int y, final int ico, final String message, final ItemRenderer ir )
|
||||
public GuiTabButton( final int x, final int y, final int ico, final String message, final ItemRenderer ir, IPressable onPress )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
super( x, y, 22, 22, message, onPress );
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 22;
|
||||
this.height = 22;
|
||||
this.myIcon = ico;
|
||||
this.message = message;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
@@ -59,65 +56,51 @@ public class GuiTabButton extends Button implements ITooltip
|
||||
* @param message mouse over message
|
||||
* @param ir renderer
|
||||
*/
|
||||
public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir )
|
||||
public GuiTabButton( final int x, final int y, final ItemStack ico, final String message, final ItemRenderer ir, IPressable onPress )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 22;
|
||||
this.height = 22;
|
||||
super( x, y, 22, 22, message, onPress );
|
||||
this.myItem = ico;
|
||||
this.message = message;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton( final Minecraft minecraft, final int x, final int y, float partial )
|
||||
public void renderButton( final int x, final int y, float partial )
|
||||
{
|
||||
final Minecraft minecraft = Minecraft.getInstance();
|
||||
|
||||
if( this.visible )
|
||||
{
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
|
||||
this.hovered = x >= this.x && y >= this.y && x < this.x + this.width && y < this.y + this.height;
|
||||
minecraft.textureManager.bindTexture(TEXTURE_STATES);
|
||||
|
||||
int uv_x = ( this.hideEdge > 0 ? 11 : 13 );
|
||||
|
||||
final int offsetX = this.hideEdge > 0 ? 1 : 0;
|
||||
|
||||
this.drawTexturedModalRect( this.x, this.y, uv_x * 16, 0, 25, 22 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, 0, 25, 22, 0 );
|
||||
|
||||
if( this.myIcon >= 0 )
|
||||
{
|
||||
final int uv_y = (int) Math.floor( this.myIcon / 16 );
|
||||
uv_x = this.myIcon - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
GuiUtils.drawTexturedModalRect( offsetX + this.x + 3, this.y + 3, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
}
|
||||
|
||||
this.mouseDragged( minecraft, x, y );
|
||||
|
||||
if( this.myItem != null )
|
||||
{
|
||||
this.zLevel = 100.0F;
|
||||
this.itemRenderer.zLevel = 100.0F;
|
||||
|
||||
RenderSystem.enableDepthTest();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
// FIXME RenderHelper.enableGUIStandardItemLighting();
|
||||
this.itemRenderer.renderItemAndEffectIntoGUI( this.myItem, offsetX + this.x + 3, this.y + 3 );
|
||||
RenderSystem.disableDepthTest();
|
||||
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
|
||||
@@ -21,15 +21,17 @@ package appeng.client.gui.widgets;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
|
||||
public class GuiToggleButton extends Button implements ITooltip
|
||||
{
|
||||
public static final ResourceLocation TEXTURE_STATES = new ResourceLocation("appliedenergistics2", "textures/guis/states.png");
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile( "\\n", Pattern.LITERAL );
|
||||
private final int iconIdxOn;
|
||||
private final int iconIdxOff;
|
||||
@@ -39,17 +41,13 @@ public class GuiToggleButton extends Button implements ITooltip
|
||||
|
||||
private boolean isActive;
|
||||
|
||||
public GuiToggleButton( final int x, final int y, final int on, final int off, final String displayName, final String displayHint )
|
||||
public GuiToggleButton( final int x, final int y, final int on, final int off, final String displayName, final String displayHint, IPressable onPress )
|
||||
{
|
||||
super( 0, 0, 16, "" );
|
||||
super( x, y, 16, 16, "", onPress );
|
||||
this.iconIdxOn = on;
|
||||
this.iconIdxOff = off;
|
||||
this.displayName = displayName;
|
||||
this.displayHint = displayHint;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 16;
|
||||
this.height = 16;
|
||||
}
|
||||
|
||||
public void setState( final boolean isOn )
|
||||
@@ -58,22 +56,20 @@ public class GuiToggleButton extends Button implements ITooltip
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton( final Minecraft par1Minecraft, final int par2, final int par3, final float partial )
|
||||
public void renderButton( final int mouseX, final int mouseY, final float partial )
|
||||
{
|
||||
if( this.visible )
|
||||
{
|
||||
final int iconIndex = this.getIconIndex();
|
||||
|
||||
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
par1Minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
|
||||
this.hovered = par2 >= this.x && par3 >= this.y && par2 < this.x + this.width && par3 < this.y + this.height;
|
||||
Minecraft.getInstance().textureManager.bindTexture( TEXTURE_STATES );
|
||||
|
||||
final int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
final int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, 256 - 16, 256 - 16, 16, 16, 0 );
|
||||
GuiUtils.drawTexturedModalRect( this.x, this.y, uv_x * 16, uv_y * 16, 16, 16, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
|
||||
@@ -39,10 +40,6 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
{
|
||||
private static final int PADDING = 2;
|
||||
|
||||
private final int _xPos;
|
||||
private final int _yPos;
|
||||
private final int _width;
|
||||
private final int _height;
|
||||
private final int _fontPad;
|
||||
private int selectionColor = 0xFF00FF00;
|
||||
|
||||
@@ -58,21 +55,19 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
*/
|
||||
public MEGuiTextField( final FontRenderer fontRenderer, final int xPos, final int yPos, final int width, final int height )
|
||||
{
|
||||
super( 0, fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - fontRenderer.getCharWidth( '_' ), height - 2 * PADDING );
|
||||
super( fontRenderer, xPos + PADDING, yPos + PADDING, width - 2 * PADDING - (int) fontRenderer.getCharWidth( '_' ), height - 2 * PADDING, "" );
|
||||
|
||||
this._fontPad = fontRenderer.getCharWidth( '_' );
|
||||
this._xPos = xPos;
|
||||
this._yPos = yPos;
|
||||
this._width = width;
|
||||
this._height = height;
|
||||
this._fontPad = (int) fontRenderer.getCharWidth( '_' );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked( final int xPos, final int yPos, final int button )
|
||||
public boolean mouseClicked( final double xPos, final double yPos, final int button )
|
||||
{
|
||||
super.mouseClicked( xPos, yPos, button );
|
||||
if (!super.mouseClicked( xPos, yPos, button )) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean requiresFocus = this.isMouseIn( xPos, yPos );
|
||||
final boolean requiresFocus = this.isMouseOver( xPos, yPos );
|
||||
if( !this.isFocused() )
|
||||
{
|
||||
this.setFocused2( requiresFocus );
|
||||
@@ -81,22 +76,6 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the mouse is within the element
|
||||
*
|
||||
* @param xCoord current x coord of the mouse
|
||||
* @param yCoord current y coord of the mouse
|
||||
*
|
||||
* @return true if mouse position is within the text field area
|
||||
*/
|
||||
public boolean isMouseIn( final int xCoord, final int yCoord )
|
||||
{
|
||||
final boolean withinXRange = this._xPos <= xCoord && xCoord < this._xPos + this._width;
|
||||
final boolean withinYRange = this._yPos <= yCoord && yCoord < this._yPos + this._height;
|
||||
|
||||
return withinXRange && withinYRange;
|
||||
}
|
||||
|
||||
public void selectAll()
|
||||
{
|
||||
this.setCursorPosition( 0 );
|
||||
@@ -109,7 +88,7 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawTextBox()
|
||||
public void renderButton(int mouseX, int mouseY, float partial)
|
||||
{
|
||||
if( this.getVisible() )
|
||||
{
|
||||
@@ -123,7 +102,7 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
fill( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
|
||||
0xFFA8A8A8 );
|
||||
}
|
||||
super.drawTextBox();
|
||||
super.renderButton(mouseX, mouseY, partial);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,16 +152,16 @@ public class MEGuiTextField extends TextFieldWidget
|
||||
float alpha = ( this.selectionColor >> 24 & 255 ) / 255.0F;
|
||||
|
||||
RenderSystem.color4f( red, green, blue, alpha );
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.enableColorLogic();
|
||||
GlStateManager.colorLogicOp( GlStateManager.LogicOp.OR_REVERSE );
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.enableColorLogicOp();
|
||||
RenderSystem.logicOp( GlStateManager.LogicOp.OR_REVERSE );
|
||||
bufferbuilder.begin( 7, DefaultVertexFormats.POSITION );
|
||||
bufferbuilder.pos( startX, endY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( endX, endY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( endX, startY, 0.0D ).endVertex();
|
||||
bufferbuilder.pos( startX, startY, 0.0D ).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.disableColorLogic();
|
||||
RenderSystem.disableColorLogicOp();
|
||||
RenderSystem.enableTexture();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user