Skip to content

Instantly share code, notes, and snippets.

@magnifikus
Created November 4, 2012 02:21
Show Gist options
  • Save magnifikus/4009834 to your computer and use it in GitHub Desktop.
Save magnifikus/4009834 to your computer and use it in GitHub Desktop.
package de.squig.plc.client.gui;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.common.registry.LanguageRegistry;
import de.squig.plc.client.gui.tiles.LogicTextureTile;
import de.squig.plc.container.ContainerController;
import de.squig.plc.tile.TileController;
import net.minecraft.src.BlockIce;
import net.minecraft.src.Gui;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiContainer;
import net.minecraft.src.GuiScreen;
import net.minecraft.src.InventoryPlayer;
import net.minecraft.src.Material;
import net.minecraft.src.StatCollector;
public class GuiController extends GuiScreen {
private TileController controller;
public static String tutorialString = "Hello World";
private int xSize = 192;
private int ySize = 192;
private int screenX = 0;
private int screenY = 0;
private int screenRows = 10;
private int screenCols = 8;
public GuiController(TileController controller) {
super();
//super(new ContainerController(player, controller));
//this.ySize = 176;
this.controller = controller;
}
public void initGui() {
controlList.clear();
//controlList.add(new GuiButton(1, width / 2 - 50, height / 2 - 40, 100, 20, "New Button"));
}
public void drawScreen(int i, int j, float f){
screenX = (this.width - xSize) / 2;
screenY = (this.height - ySize) / 2;
drawControllerScreen();
drawLogicTile(LogicTextureTile.INPUT, 0, 0, false,"99", LogicTextureTile.TAG_INPUT);
drawLogicTile(LogicTextureTile.LINE, 1, 0, false,null);
drawLogicTile(LogicTextureTile.LINE, 2, 0, false,null);
drawLogicTile(LogicTextureTile.LINE, 3, 0, false,null);
drawLogicTile(LogicTextureTile.LINE, 4, 0, false,null);
drawLogicTile(LogicTextureTile.LINE, 5, 0, false,null);
drawLogicTile(LogicTextureTile.LINE, 6, 0, false,null);
drawLogicTile(LogicTextureTile.OUTPUT, 7, 0, false,"99");
drawLogicTile(LogicTextureTile.INPUT, 0, 1, true,"99", LogicTextureTile.TAG_INPUT);
drawLogicTile(LogicTextureTile.LINE, 1, 1, true,null);
drawLogicTile(LogicTextureTile.LINE, 2, 1, true,null);
drawLogicTile(LogicTextureTile.LINE, 3, 1, true,null);
drawLogicTile(LogicTextureTile.LINE, 4, 1, true,null);
drawLogicTile(LogicTextureTile.LINE, 5, 1, true,null);
drawLogicTile(LogicTextureTile.LINE, 6, 1, true,null);
drawLogicTile(LogicTextureTile.OUTPUT, 7, 1, true,"99");
//this.drawTexturedModalRect(var5, var6, 0, 0, xSize, ySize);
// x y 0 0 width height
//drawCenteredString(fontRenderer, "We Made A GUI", width / 2, height / 2 - 20, 0xffffff);
//drawCenteredString(fontRenderer, tutorialString, width / 2, height / 2 - 20, 0xffffff);
//drawRect(10, 10, 100, 100, 16);
//this.drawTexturedModalRect(var5 + 79, var6 + 34, 176, 14, 15 + 1, 16);
super.drawScreen(i, j, f);
}
private void drawLogicTile(LogicTextureTile tile, int x, int y, boolean on, String text) {
drawLogicTile(tile, x, y, on, text, null);
}
private void drawLogicTile(LogicTextureTile tile, int x, int y, boolean on, String text, LogicTextureTile tag) {
int sx = screenX+16*(x+1);
int sy = screenY+16*(y+1);
if (text != null) {
this.fontRenderer.drawString(text, sx+2, sy+8, 0x000000);
}
int var4 = this.mc.renderEngine.getTexture("/ressources/art/gui/controller.png");
this.mc.renderEngine.bindTexture(var4);
if (!on) {
this.drawTexturedModalRect(sx, sy , tile.x, tile.y, 16, 16);
}
else {
this.drawTexturedModalRect(sx, sy , tile.xon, tile.yon, 16, 16);
}
if (tag != null)
this.drawTexturedModalRect(sx, sy , tag.x, tag.y, 16, 16);
}
private void drawControllerScreen () {
int var4 = this.mc.renderEngine.getTexture("/ressources/art/gui/controller.png");
this.mc.renderEngine.bindTexture(var4);
//GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
for (int x = 0; x < screenCols+2 ;x++) {
for (int y = 0; y < screenRows+2; y++) {
int tx = 16;
int ty = 16;
if (x==0)
tx = 0;
if (y==0)
ty = 0;
if (x==screenCols+1)
tx = 32;
if (y==screenRows+1)
ty = 32;
this.drawTexturedModalRect(screenX+16*x, screenY+16*y, tx, ty, 16, 16);
}
}
}
public void actionPerformed(GuiButton button) {
if(button.id == 1){
tutorialString = "GoodBye World";
}
}
/*
protected void drawGuiContainerForegroundLayer()
{
this.fontRenderer.drawString(LanguageRegistry.instance().getStringLocalization("Controller"), 60, 6, 4210752);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.height - 96 + 2, 4210752);
}
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int var4 = this.mc.renderEngine.getTexture("/ressources/art/gui/controller.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(var4);
int var5 = (this.width - this.width) / 2;
int var6 = (this.height - this.height) / 2;
this.drawTexturedModalRect(var5, var6, 0, 0, this.width, this.height);
int var7;
/*
* This bit shows the "fire" effect in the GUI
if (this.furnaceInventory.isBurning())
{
var7 = this.furnaceInventory.getBurnTimeRemainingScaled(12);
this.drawTexturedModalRect(var5 + 56, var6 + 36 + 12 - var7, 176, 12 - var7, 14, var7 + 2);
}
* This bit shows the progress bar in the GUI
var7 = this.furnaceInventory.getCookProgressScaled(24);
this.drawTexturedModalRect(var5 + 79, var6 + 34, 176, 14, var7 + 1, 16);
*/
//}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment