package mcjty.rftools.blocks.screens.modulesclient;
import mcjty.lib.gui.widgets.Panel;
import mcjty.rftools.blocks.screens.ModuleGuiChanged;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
public class RedstoneClientScreenModule implements ClientScreenModule {
private String line = "";
private String yestext = "on";
private String notext = "off";
private int color = 0xffffff;
private int yescolor = 0xffffff;
private int nocolor = 0xffffff;
private int dim = 0;
@Override
public TransformMode getTransformMode() {
return TransformMode.TEXT;
}
@Override
public int getHeight() {
return 10;
}
@Override
public void render(FontRenderer fontRenderer, int currenty, Object[] screenData, float factor) {
GL11.glDisable(GL11.GL_LIGHTING);
int xoffset;
if (!line.isEmpty()) {
fontRenderer.drawString(line, 7, currenty, color);
xoffset = 7 + 40;
} else {
xoffset = 7;
}
if (screenData != null && screenData.length > 0 && screenData[0] instanceof Boolean) {
boolean rs = (Boolean) screenData[0];
fontRenderer.drawString(rs ? yestext : notext, xoffset, currenty, rs ? yescolor : nocolor);
} else {
fontRenderer.drawString("<invalid>", xoffset, currenty, 0xff0000);
}
}
@Override
public void mouseClick(World world, int x, int y, boolean clicked) {
}
@Override
public Panel createGui(Minecraft mc, Gui gui, final NBTTagCompound currentData, final ModuleGuiChanged moduleGuiChanged) {
return new ScreenModuleGuiBuilder(mc, gui, currentData, moduleGuiChanged).
label("Label:").text("text", "Label text").color("color", "Color for the label").nl().
label("Yes:").text("yestext", "Positive text").color("yescolor", "Color for the positive text").nl().
label("No:").text("notext", "Negative text").color("nocolor", "Color for the negative text").nl().
label("Block:").monitor().nl().
build();
}
@Override
public void setupFromNBT(NBTTagCompound tagCompound, int dim, int x, int y, int z) {
if (tagCompound != null) {
line = tagCompound.getString("text");
if (tagCompound.hasKey("yestext")) {
yestext = tagCompound.getString("yestext");
}
if (tagCompound.hasKey("notext")) {
notext = tagCompound.getString("notext");
}
if (tagCompound.hasKey("color")) {
color = tagCompound.getInteger("color");
} else {
color = 0xffffff;
}
if (tagCompound.hasKey("yescolor")) {
yescolor = tagCompound.getInteger("yescolor");
} else {
yescolor = 0xffffff;
}
if (tagCompound.hasKey("nocolor")) {
nocolor = tagCompound.getInteger("nocolor");
} else {
nocolor = 0xffffff;
}
}
}
@Override
public boolean needsServerData() {
return true;
}
}