Better programming GUI

main
Astoria 2 years ago
parent 685e23522f
commit f24c91702a

@ -9,7 +9,6 @@ public class GuiButtonExtended extends GuiButton {
public String type;
public int slot;
public int scroll;
public static final int width = 80;
public static final int height = 10;
public GuiButtonExtended(int id, int xPosition, String s, String extra, int slot) {
@ -20,25 +19,4 @@ public class GuiButtonExtended extends GuiButton {
public GuiButtonExtended(int id, int xPosition, String s) {
super(id, xPosition / 2 - (width / 2), 50 - height + (height * (id + 1)), width, height, s);
}
@Override
public void drawButton(Minecraft minecraft, int i, int j) {
if (!this.visible) {
return;
}
FontRenderer fontrenderer = minecraft.fontRenderer;
GL11.glBindTexture(3553, minecraft.renderEngine.getTexture("/gui/gui.png"));
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
boolean flag = i >= this.xPosition && j >= this.yPosition + scroll && i < this.xPosition + this.width && j < this.yPosition + scroll + this.height;
int k = this.getButtonState(flag);
this.drawTexturedModalRect(this.xPosition, this.yPosition + scroll, 0, 46 + k * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition + scroll, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);
this.mouseDragged(minecraft, i, j);
if (!this.enabled) {
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2 + scroll, -6250336);
} else if (flag) {
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2 + scroll, 0xFFFFA0);
} else {
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2 + scroll, 0xE0E0E0);
}
}
}

@ -1,51 +1,53 @@
package net.brokenmoon.afloydwiremod.gui;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
import net.brokenmoon.afloydwiremod.mixinInterfaces.INetHandler;
import net.brokenmoon.afloydwiremod.packet.WiremodProgrammerPacket;
import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.src.*;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
public class GuiProgrammer extends GuiScrollable {
private AbstractWireTileEntity wireEntity;
public int xSize = 100;
public int ySize = 180;
private int slot = 0;
@Override
public void initGui() {
//this.height - 240 is top
//This.width / 2
int i = 0;
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "TRUE"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "FALSE"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "AND"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "NAND"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "OR"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "NOR"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "XOR"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "XNOR"));
this.controlList.add(new GuiButtonExtended(i++, this.width - GuiButtonExtended.width * 2, "NOT"));
i = 0;
this.controlList.add(new GuiButtonExtended(i++, this.width, "Constant"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Increment"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Decrement"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Increment/Decrement"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Duplicate"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Addition"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Subtraction"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Multiplication"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Division"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Memory"));
this.controlList.add(new GuiButtonExtended(i++, this.width, "Pulse"));
i = 0;
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, "=="));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, "!="));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, ">"));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, ">="));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, "<"));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, "<="));
this.controlList.add(new GuiButtonExtended(i++, this.width + GuiButtonExtended.width * 2, "<=>"));
slot = 0;
this.controlList.add(new GuiButtonExtended(slot++, this.width, "Constant"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "Increment"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "Decrement"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "Increment/Decrement"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "Duplicate"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "Addition"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "Subtraction"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "Multiplication"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "Division"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "Memory"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "Pulse"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "TRUE"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "FALSE"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "AND"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "NAND"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "OR"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "NOR"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "XOR"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "XNOR"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "NOT"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "=="));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "!="));
this.controlList.add(new GuiButtonExtended(slot++, this.width, ">"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, ">="));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "<"));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "<="));
this.controlList.add(new GuiButtonExtended(slot++, this.width, "<=>"));
}
public GuiProgrammer(EntityPlayer player, ChipTileEntity wireEntity) {
@ -119,4 +121,39 @@ public class GuiProgrammer extends GuiScrollable {
((ChipTileEntity)Minecraft.getMinecraft().theWorld.getBlockTileEntity(wireEntity.xCoord, wireEntity.yCoord, wireEntity.zCoord)).setMode(string);
}
@Override
public void drawScreen(int x, int y, float renderPartialTicks){
this.drawDefaultBackground();
//Draw the overlay
this.drawGuiBackground(renderPartialTicks);
GL11.glPushMatrix();
GL11.glPopMatrix();
int k = (this.height - this.ySize) / 2;
int wheel = Mouse.getDWheel();
if(wheel > 0)
scroll++;
if (wheel < 0)
scroll--;
if(scroll > 0)
scroll = 0;
if(-scroll > slot - 16)
scroll = -(slot - 16);
for (int i = 0; i < this.controlList.size(); ++i) {
GuiButtonExtended guibutton = (GuiButtonExtended)this.controlList.get(i);
guibutton.yPosition = k + (guibutton.height * (guibutton.id + 1) + scroll * GuiButtonExtended.height);
if(guibutton.yPosition > k && guibutton.yPosition < k + 170){
guibutton.drawButton(this.mc, x, y);
}
}
}
protected void drawGuiBackground(float f) {
int guiTexture = this.mc.renderEngine.getTexture("/assets/afloydwiremod/gui/programmer.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(guiTexture);
int j = (this.width - this.xSize) / 2;
int k = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize);
}
}

@ -7,27 +7,5 @@ import org.lwjgl.input.Mouse;
public class GuiScrollable extends GuiScreen {
public EntityPlayer player;
private int scroll;
@Override
public void drawScreen(int x, int y, float renderPartialTicks) {
//TODO: Tweak these values later to fit all the stuff
int wheel = Mouse.getDWheel();
if(wheel > 0)
scroll++;
if (wheel < 0)
scroll--;
if(scroll > 150)
scroll = 150;
if(scroll < 0)
scroll = 0;
for (int i = 0; i < this.controlList.size(); ++i) {
GuiButtonExtended guibutton = (GuiButtonExtended)this.controlList.get(i);
if(scroll >= 0)
guibutton.scroll = scroll;
if(scroll <= 0)
guibutton.scroll = scroll;
if(guibutton.yPosition >= 50 && guibutton.yPosition <= 200)
guibutton.drawButton(this.mc, x, y);
}
}
public int scroll;
}

@ -65,7 +65,7 @@ public class GuiSettings extends GuiScreen {
if(guiButton.id == 1){
((ChipTileEntity)wireEntity).tickAmount++;
}
if(guiButton.id == 2){
if(guiButton.id == 2 && ((ChipTileEntity)wireEntity).tickAmount > 0){
((ChipTileEntity)wireEntity).tickAmount--;
}
if(this.player instanceof EntityClientPlayerMP){

@ -23,11 +23,11 @@ public class GuiWireTool extends GuiScreen {
@Override
public void initGui() {
red = new GuiSlider(1, this.width/2-100, this.height/2-40, 200, 20, "Red", tool.red);
green = new GuiSlider(2, this.width/2-100, this.height/2-20, 200, 20, "Green", tool.green);
blue = new GuiSlider(3, this.width/2-100, this.height/2-0, 200, 20, "Blue", tool.blue);
alpha = new GuiSlider(4, this.width/2-100, this.height/2+20, 200, 20, "Alpha", tool.alpha);
widthslider = new GuiSlider(5, this.width/2-100, this.height/2+40, 200, 20, "Width", tool.width);
red = new GuiSlider(1, this.width/2-100, this.height/2-50, 200, 20, "Red", tool.red);
green = new GuiSlider(2, this.width/2-100, this.height/2-30, 200, 20, "Green", tool.green);
blue = new GuiSlider(3, this.width/2-100, this.height/2-10, 200, 20, "Blue", tool.blue);
alpha = new GuiSlider(4, this.width/2-100, this.height/2+10, 200, 20, "Alpha", tool.alpha);
widthslider = new GuiSlider(5, this.width/2-100, this.height/2+30, 200, 20, "Width", tool.width);
this.controlList.add(red);
this.controlList.add(green);
this.controlList.add(blue);

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Loading…
Cancel
Save