mirror of
https://github.com/GTNewHorizons/waila.git
synced 2026-11-21 04:32:17 +00:00
Added scalable ItemStack display.
This commit is contained in:
1 parent
8f32c0c770
commit
d134aba573
3 files changed
+51
-2
No files matched your search
@@ -72,7 +72,7 @@ public class ConfigKeyHandler extends KeyHandler {
|
||||
|
||||
if (kb.keyDescription == Constants.BIND_WAILA_TESTING){
|
||||
if(mc.currentScreen == null)
|
||||
mc.displayGuiScreen(new ScreenHUDConfig(mc.currentScreen));
|
||||
mc.displayGuiScreen(new ScreenTest(mc.currentScreen));
|
||||
}
|
||||
|
||||
if (mc.currentScreen != null)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mcp.mobius.waila.gui.testing;
|
||||
|
||||
import mcp.mobius.waila.gui.screens.ScreenBase;
|
||||
import mcp.mobius.waila.gui.widgets.ItemStackDisplay;
|
||||
import mcp.mobius.waila.gui.widgets.LabelFixedFont;
|
||||
import mcp.mobius.waila.gui.widgets.PictureDisplay;
|
||||
import mcp.mobius.waila.gui.widgets.PictureSwitch;
|
||||
@@ -11,13 +12,15 @@ import mcp.mobius.waila.gui.widgets.buttons.ButtonInteger;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonIntegerConfig;
|
||||
import mcp.mobius.waila.gui.widgets.buttons.ButtonScreenChange;
|
||||
import mcp.mobius.waila.gui.widgets.movable.PictureMovableRC;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ScreenTest extends ScreenBase {
|
||||
|
||||
public ScreenTest(GuiScreen parent) {
|
||||
super(parent);
|
||||
|
||||
this.getRoot().addWidget("Picture", new PictureMovableRC(this.getRoot(), "waila:textures/test.png"));
|
||||
this.getRoot().addWidget("Picture", new ItemStackDisplay(null, new ItemStack(Block.dirt, 8)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package mcp.mobius.waila.gui.widgets;
|
||||
|
||||
import mcp.mobius.waila.gui.interfaces.IWidget;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.Point;
|
||||
|
||||
import codechicken.nei.forge.GuiContainerManager;
|
||||
|
||||
public class ItemStackDisplay extends WidgetBase {
|
||||
|
||||
ItemStack stack = null;
|
||||
|
||||
public ItemStackDisplay(IWidget parent){
|
||||
this(parent, null);
|
||||
}
|
||||
|
||||
public ItemStackDisplay(IWidget parent, ItemStack stack){
|
||||
super(parent);
|
||||
this.stack = stack;
|
||||
this.geom.setSize(16, 16);
|
||||
}
|
||||
|
||||
public void setStack(ItemStack stack){
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public ItemStack getStack(){
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Point pos) {
|
||||
if (this.stack == null) return;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(this.getSize().getX()/16.0f, this.getSize().getY()/16.0f, 1.0f);
|
||||
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
GuiContainerManager.drawItem(pos.getX(), pos.getY(), this.stack);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user