Better constant, settings!

visibileWires
Astoria 2 years ago
parent bab40824b7
commit dbdd7ba11b

@ -21,6 +21,9 @@ public abstract class AbstractWireTile extends BlockContainer {
ToolWiring tool = ((ToolWiring)player.inventory.getCurrentItem().getItem());
this.displayWiringGui(player, wireEntity, tool, x, y, z);
return true;
} else if(player.inventory.getCurrentItem() != null && player.inventory.getCurrentItem().itemID == WireMod.ToolProgrammer.itemID && wireEntity.initialized && wireEntity.hasSettings) {
this.displaySettingsGui(player, wireEntity);
return true;
}
}
return false;
@ -42,6 +45,14 @@ public abstract class AbstractWireTile extends BlockContainer {
}
//Singleplayer
((IEntityPlayer)player).displayGuiProgrammer(chip);
}
public void displaySettingsGui(EntityPlayer player, AbstractWireTileEntity chip){
if(player instanceof EntityPlayerMP) {
//Multiplayer
((IEntityPlayer)player).displayGuiSettings(chip);
return;
}
//Singleplayer
((IEntityPlayer)player).displayGuiSettings(chip);
}
}

@ -9,6 +9,7 @@ public abstract class AbstractWireTileEntity extends TileEntity {
public WiringButton[] inputs = null;
public WiringButton[] outputs = null;
public boolean initialized = false;
public boolean hasSettings = false;
@Override
public void updateEntity() {
@ -19,6 +20,7 @@ public abstract class AbstractWireTileEntity extends TileEntity {
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
this.initialized = nbttagcompound.getBoolean("init");
this.initialized = nbttagcompound.getBoolean("set");
if(nbttagcompound.getBoolean("inputExists")){
this.inputs = new WiringButton[nbttagcompound.getInteger("inputLength")];
NBTTagList nbttaglistInputs = nbttagcompound.getTagList("Inputs");
@ -43,6 +45,7 @@ public abstract class AbstractWireTileEntity extends TileEntity {
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
nbttagcompound.setBoolean("init", this.initialized);
nbttagcompound.setBoolean("set", this.hasSettings);
if(inputs != null){
nbttagcompound.setBoolean("inputExists", true);
nbttagcompound.setInteger("inputLength", inputs.length);

@ -1,11 +1,15 @@
package net.brokenmoon.afloydwiremod.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.src.FontRenderer;
import net.minecraft.src.GuiButton;
import org.lwjgl.opengl.GL11;
public class GuiButtonExtended extends GuiButton {
public String type;
public int slot;
public int scroll;
public static final int width = 50;
public static final int height = 10;
public GuiButtonExtended(int id, int xPosition, String s, String extra, int slot) {
@ -16,4 +20,25 @@ public class GuiButtonExtended extends GuiButton {
public GuiButtonExtended(int id, int xPosition, String s) {
super(id, xPosition / 2 - (width / 2), 50 - height + (height * id), 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 && i < this.xPosition + this.width && j < this.yPosition + 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);
}
}
}

@ -5,7 +5,7 @@ import net.brokenmoon.afloydwiremod.tileentity.ChipTileEntity;
import net.minecraft.src.*;
import org.lwjgl.input.Mouse;
public class GuiProgrammer extends GuiScreen {
public class GuiProgrammer extends GuiScrollable {
private AbstractWireTileEntity wireEntity;
@ -19,20 +19,6 @@ public class GuiProgrammer extends GuiScreen {
this.controlList.add(new GuiButtonExtended(2, this.width, "Count"));
}
@Override
public void drawScreen(int x, int y, float renderPartialTicks) {
int wheel = Mouse.getDWheel();
for (int i = 0; i < this.controlList.size(); ++i) {
GuiButton guibutton = this.controlList.get(i);
if(wheel > 0)
guibutton.yPosition = guibutton.yPosition + 1;
if(wheel < 0)
guibutton.yPosition = guibutton.yPosition - 1;
if(guibutton.yPosition >= 50 && guibutton.yPosition <= 200)
guibutton.drawButton(this.mc, x, y);
}
}
public GuiProgrammer(EntityPlayer player, AbstractWireTileEntity wireEntity) {
super.initGui();
this.wireEntity = wireEntity;
@ -43,6 +29,7 @@ public class GuiProgrammer extends GuiScreen {
if(wireEntity instanceof ChipTileEntity) {
if (guibutton.id == 1) {
((ChipTileEntity) wireEntity).setMode("constant");
System.out.println("ae");
} else if (guibutton.id == 2) {
((ChipTileEntity) wireEntity).setMode("count");
}

@ -0,0 +1,31 @@
package net.brokenmoon.afloydwiremod.gui;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
import org.lwjgl.input.Mouse;
public class GuiScrollable extends GuiScreen {
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);
}
}
}

@ -8,7 +8,7 @@ import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiScreen;
import org.lwjgl.input.Mouse;
public class GuiWiring extends GuiScreen {
public class GuiWiring extends GuiScrollable {
private ToolWiring tool;
private int x;
@ -33,20 +33,6 @@ public class GuiWiring extends GuiScreen {
}
}
@Override
public void drawScreen(int x, int y, float renderPartialTicks) {
int wheel = Mouse.getDWheel();
for (int i = 0; i < this.controlList.size(); ++i) {
GuiButton guibutton = this.controlList.get(i);
if(wheel > 0)
guibutton.yPosition = guibutton.yPosition + 1;
if(wheel < 0)
guibutton.yPosition = guibutton.yPosition - 1;
if(guibutton.yPosition >= 50 && guibutton.yPosition <= 200)
guibutton.drawButton(this.mc, x, y);
}
}
public GuiWiring(EntityPlayer player, ToolWiring tool, AbstractWireTileEntity wireEntity, int x, int y, int z) {
super.initGui();
this.tool = tool;

@ -2,6 +2,7 @@ package net.brokenmoon.afloydwiremod.mixin;
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
import net.brokenmoon.afloydwiremod.gui.GuiProgrammer;
import net.brokenmoon.afloydwiremod.gui.GuiSettings;
import net.brokenmoon.afloydwiremod.gui.GuiWiring;
import net.brokenmoon.afloydwiremod.item.ToolWiring;
import net.brokenmoon.afloydwiremod.mixinInterfaces.IEntityPlayer;
@ -23,4 +24,9 @@ public class MixinEntityPlayerSP implements IEntityPlayer {
public void displayGuiWiring(ToolWiring tool, AbstractWireTileEntity chip, int x, int y, int z) {
this.mc.displayGuiScreen(new GuiWiring(((EntityPlayerSP)(Object)this), tool, chip, x, y, z));
}
@Override
public void displayGuiSettings(AbstractWireTileEntity chip) {
this.mc.displayGuiScreen(new GuiSettings(((EntityPlayerSP)(Object)this), chip));
}
}

@ -8,4 +8,5 @@ public interface IEntityPlayer {
public void displayGuiProgrammer(AbstractWireTileEntity chip);
public void displayGuiWiring(ToolWiring tool, AbstractWireTileEntity chip, int x, int y, int z);
public void displayGuiSettings(AbstractWireTileEntity chip);
}

@ -50,7 +50,9 @@ public class ChipTileEntity extends AbstractWireTileEntity {
mode = string;
this.inputs = new WiringButton[0];
this.outputs = new WiringButton[1];
this.outputs[0] = new WiringButton(214, 240, "Output", 0);
initialized = true;
hasSettings = true;
} else if (string.equals("count")) {
mode = string;
this.inputs = new WiringButton[3];

Loading…
Cancel
Save