Work on GUIs (specifically to get SkyChest GUI)

This commit is contained in:
Sebastian Hartte
2020-06-02 02:14:09 +02:00
parent 271e8889a1
commit 9f63859769
109 changed files with 1133 additions and 1301 deletions
@@ -3,12 +3,12 @@ package appeng.client.gui.widgets;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
public abstract class GuiCustomSlot extends Gui implements ITooltip
public abstract class GuiCustomSlot extends AbstractGui implements ITooltip
{
private final int x;
private final int y;
@@ -210,11 +210,11 @@ public class GuiImgButton extends Button implements ITooltip
if( this.enabled )
{
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
}
else
{
GlStateManager.color( 0.5f, 0.5f, 0.5f, 1.0f );
RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f );
}
par1Minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
@@ -233,11 +233,11 @@ public class GuiImgButton extends Button implements ITooltip
{
if( this.enabled )
{
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
}
else
{
GlStateManager.color( 0.5f, 0.5f, 0.5f, 1.0f );
RenderSystem.color4f( 0.5f, 0.5f, 0.5f, 1.0f );
}
par1Minecraft.renderEngine.bindTexture( new ResourceLocation( "appliedenergistics2", "textures/guis/states.png" ) );
@@ -251,7 +251,7 @@ public class GuiImgButton extends Button implements ITooltip
this.mouseDragged( par1Minecraft, par2, par3 );
}
}
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
}
private int getIconIndex()
@@ -19,9 +19,10 @@
package appeng.client.gui.widgets;
import net.minecraft.client.renderer.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import appeng.client.gui.AEBaseGui;
import net.minecraftforge.fml.client.gui.GuiUtils;
public class GuiScrollbar implements IScrollSource
@@ -40,16 +41,16 @@ public class GuiScrollbar implements IScrollSource
public void draw( final AEBaseGui g )
{
g.bindTexture( "minecraft", "gui/container/creative_inventory/tabs.png" );
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
if( this.getRange() == 0 )
{
g.drawTexturedModalRect( this.displayX, this.displayY, 232 + this.width, 0, this.width, 15 );
GuiUtils.drawTexturedModalRect( this.displayX, this.displayY, 232 + this.width, 0, this.width, 15, 0 /* FIXME: this used the GUI's zIndex before */ );
}
else
{
final int offset = ( this.currentScroll - this.minScroll ) * ( this.height - 15 ) / this.getRange();
g.drawTexturedModalRect( this.displayX, offset + this.displayY, 232, 0, this.width, 15 );
GuiUtils.drawTexturedModalRect( this.displayX, offset + this.displayY, 232, 0, this.width, 15, 0 /* FIXME: this used the GUI's zIndex before */ );
}
}
@@ -127,7 +128,7 @@ public class GuiScrollbar implements IScrollSource
return this.currentScroll;
}
public void click( final AEBaseGui aeBaseGui, final int x, final int y )
public void click(final double x, final double y)
{
if( this.getRange() == 0 )
{
@@ -138,7 +139,7 @@ public class GuiScrollbar implements IScrollSource
{
if( y > this.displayY && y <= this.displayY + this.height )
{
this.currentScroll = ( y - this.displayY );
this.currentScroll = (int) ( y - this.displayY );
this.currentScroll = this.minScroll + ( ( this.currentScroll * 2 * this.getRange() / this.height ) );
this.currentScroll = ( this.currentScroll + 1 ) >> 1;
this.applyRange();
@@ -146,7 +147,7 @@ public class GuiScrollbar implements IScrollSource
}
}
public void wheel( int delta )
public void wheel( double delta )
{
delta = Math.max( Math.min( -delta, 1 ), -1 );
this.currentScroll += delta * this.pageSize;
@@ -75,7 +75,7 @@ public class GuiTabButton extends Button implements ITooltip
{
if( this.visible )
{
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
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;
@@ -100,10 +100,10 @@ public class GuiTabButton extends Button implements ITooltip
this.zLevel = 100.0F;
this.itemRenderer.zLevel = 100.0F;
GlStateManager.enableDepth();
RenderSystem.enableDepthTest();
RenderHelper.enableGUIStandardItemLighting();
this.itemRenderer.renderItemAndEffectIntoGUI( this.myItem, offsetX + this.x + 3, this.y + 3 );
GlStateManager.disableDepth();
RenderSystem.disableDepthTest();
this.itemRenderer.zLevel = 0.0F;
this.zLevel = 0.0F;
@@ -64,7 +64,7 @@ public class GuiToggleButton extends Button implements ITooltip
{
final int iconIndex = this.getIconIndex();
GlStateManager.color( 1.0f, 1.0f, 1.0f, 1.0f );
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;
@@ -115,12 +115,12 @@ public class MEGuiTextField extends TextFieldWidget
{
if( this.isFocused() )
{
drawRect( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
fill( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
0xFF606060 );
}
else
{
drawRect( this.x - PADDING + 1, this.y - PADDING + 1, this.x + this.width + this._fontPad + PADDING - 1, this.y + this.height + PADDING - 1,
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();
@@ -172,7 +172,7 @@ public class MEGuiTextField extends TextFieldWidget
float green = ( this.selectionColor & 255 ) / 255.0F;
float alpha = ( this.selectionColor >> 24 & 255 ) / 255.0F;
GlStateManager.color( red, green, blue, alpha );
RenderSystem.color4f( red, green, blue, alpha );
GlStateManager.disableTexture2D();
GlStateManager.enableColorLogic();
GlStateManager.colorLogicOp( GlStateManager.LogicOp.OR_REVERSE );
@@ -183,7 +183,7 @@ public class MEGuiTextField extends TextFieldWidget
bufferbuilder.pos( startX, startY, 0.0D ).endVertex();
tessellator.draw();
GlStateManager.disableColorLogic();
GlStateManager.enableTexture2D();
RenderSystem.enableTexture();
}
}