The great format and clean up. IMPORTANT: Read below.

All devs and contributors should use the provided formatter settings. 
If your IDE does not support the format, the rules are simple, it is the
default java formatting rules, with 200char line lengths and 1 extra
line after class definitions.
This commit is contained in:
tterrag1098 committed 2015-01-07 19:50:18 -05:00
1 parent 906c730a3c
commit 4cfcc874dc
136 files changed
+10365 -11272

No files matched your search

@@ -11,18 +11,18 @@ import com.cricketcraft.chisel.inventory.ContainerAutoChisel;
public class GuiAutoChisel extends GuiContainer {
private static final ResourceLocation gui = new ResourceLocation("chisel:textures/autochisel-gui.png");
private static final ResourceLocation gui = new ResourceLocation("chisel:textures/autochisel-gui.png");
public GuiAutoChisel(InventoryPlayer inventoryPlayer, TileEntityAutoChisel tileEntityAutoChisel){
super(new ContainerAutoChisel(inventoryPlayer, tileEntityAutoChisel));
}
public GuiAutoChisel(InventoryPlayer inventoryPlayer, TileEntityAutoChisel tileEntityAutoChisel) {
super(new ContainerAutoChisel(inventoryPlayer, tileEntityAutoChisel));
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3){
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(gui);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x ,y, 0, 0, xSize, ySize);
}
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(gui);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
}
}
@@ -11,57 +11,48 @@ import com.cricketcraft.chisel.inventory.ContainerChisel;
import com.cricketcraft.chisel.inventory.InventoryChiselSelection;
import com.cricketcraft.chisel.utils.GeneralClient;
public class GuiChisel extends GuiContainer
{
public EntityPlayer player;
public ContainerChisel container;
public class GuiChisel extends GuiContainer {
public GuiChisel(InventoryPlayer iinventory, InventoryChiselSelection menu)
{
super(new ContainerChisel(iinventory, menu));
player = iinventory.player;
height = 177;
public EntityPlayer player;
public ContainerChisel container;
container = (ContainerChisel) inventorySlots;
}
public GuiChisel(InventoryPlayer iinventory, InventoryChiselSelection menu) {
super(new ContainerChisel(iinventory, menu));
player = iinventory.player;
height = 177;
@Override
public void onGuiClosed()
{
super.onGuiClosed();
inventorySlots.onContainerClosed(player);
}
container = (ContainerChisel) inventorySlots;
}
boolean isExtended()
{
return container.inventory.activeVariations > 16;
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
inventorySlots.onContainerClosed(player);
}
@Override
protected void drawGuiContainerForegroundLayer(int j, int i)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
boolean isExtended() {
return container.inventory.activeVariations > 16;
}
String line = isExtended() ?
I18n.format(this.container.inventory.getInventoryName() + ".titleShort") :
I18n.format(this.container.inventory.getInventoryName() + ".title");
fontRendererObj.drawString(line, 88 - fontRendererObj.getStringWidth(line) / 2, 13, 0x404040);
}
@Override
protected void drawGuiContainerForegroundLayer(int j, int i) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mx, int my)
{
drawDefaultBackground();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
String line = isExtended() ? I18n.format(this.container.inventory.getInventoryName() + ".titleShort") : I18n.format(this.container.inventory.getInventoryName() + ".title");
fontRendererObj.drawString(line, 88 - fontRendererObj.getStringWidth(line) / 2, 13, 0x404040);
}
int i = width - xSize >> 1;
int j = height - ySize >> 1;
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) {
drawDefaultBackground();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
String texture = isExtended() ?
"chisel:textures/chisel-gui-24.png" :
"chisel:textures/chisel-gui.png";
int i = width - xSize >> 1;
int j = height - ySize >> 1;
GeneralClient.bind(texture);
drawTexturedModalRect(i, j, 0, 0, xSize, ySize);
}
String texture = isExtended() ? "chisel:textures/chisel-gui-24.png" : "chisel:textures/chisel-gui.png";
GeneralClient.bind(texture);
drawTexturedModalRect(i, j, 0, 0, xSize, ySize);
}
}
@@ -9,11 +9,10 @@ import com.cricketcraft.chisel.Configurations;
import cpw.mods.fml.client.config.GuiConfig;
public class GuiChiselConfig extends GuiConfig
{
public class GuiChiselConfig extends GuiConfig {
public GuiChiselConfig(GuiScreen parent)
{
super(parent, new ConfigElement(Configurations.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), Chisel.MOD_ID, false, false, GuiConfig.getAbridgedConfigPath(Configurations.config.toString()));
}
public GuiChiselConfig(GuiScreen parent) {
super(parent, new ConfigElement(Configurations.config.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), Chisel.MOD_ID, false, false, GuiConfig
.getAbridgedConfigPath(Configurations.config.toString()));
}
}
@@ -2,70 +2,57 @@ package com.cricketcraft.chisel.client.gui;
import net.minecraft.client.gui.GuiTextField;
public class GuiEdit extends GuiElement
{
GuiTextField field;
String tempString = "";
public class GuiEdit extends GuiElement {
public GuiEdit(int x, int y, int w, int h)
{
super(x, y, w, h);
}
GuiTextField field;
String tempString = "";
@Override
public void onAdded()
{
field = new GuiTextField(gui.fontRendererObj(), x, y, w, h);
setText(tempString);
}
public GuiEdit(int x, int y, int w, int h) {
super(x, y, w, h);
}
public String getText()
{
if(field == null)
{
return tempString;
} else
{
return field.getText();
}
}
@Override
public void onAdded() {
field = new GuiTextField(gui.fontRendererObj(), x, y, w, h);
setText(tempString);
}
public void setText(String text)
{
if(field == null)
{
tempString = text;
} else
{
field.setText(text);
}
}
public String getText() {
if (field == null) {
return tempString;
} else {
return field.getText();
}
}
@Override
public void render()
{
field.drawTextBox();
}
public void setText(String text) {
if (field == null) {
tempString = text;
} else {
field.setText(text);
}
}
@Override
public void mouseDown(InputMouseEvent ev)
{
field.mouseClicked(ev.x, ev.y, ev.button);
@Override
public void render() {
field.drawTextBox();
}
if(isMouseOver(ev))
{
ev.handled = true;
}
}
@Override
public void mouseDown(InputMouseEvent ev) {
field.mouseClicked(ev.x, ev.y, ev.button);
@Override
public void keyPressed(InputKeyboardEvent ev)
{
field.textboxKeyTyped(ev.character, ev.key);
if (isMouseOver(ev)) {
ev.handled = true;
}
}
if(field.isFocused())
{
ev.handled = true;
}
}
@Override
public void keyPressed(InputKeyboardEvent ev) {
field.textboxKeyTyped(ev.character, ev.key);
if (field.isFocused()) {
ev.handled = true;
}
}
}
@@ -4,184 +4,150 @@ import java.util.ArrayList;
import org.lwjgl.opengl.GL11;
public class GuiElement
{
public int x;
public int y;
public int w;
public int h;
public class GuiElement {
public GuiScreenPlus gui;
public GuiElement parent, addedParent;
private ArrayList<GuiElement> children = null;
public int x;
public int y;
public int w;
public int h;
public GuiElement(int x, int y, int w, int h)
{
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
public GuiScreenPlus gui;
public GuiElement parent, addedParent;
private ArrayList<GuiElement> children = null;
public GuiElement addChild(GuiElement e)
{
if(children == null)
{
children = new ArrayList<GuiElement>();
}
public GuiElement(int x, int y, int w, int h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
if(e.parent != null)
{
e.parent.removeChild(e);
}
public GuiElement addChild(GuiElement e) {
if (children == null) {
children = new ArrayList<GuiElement>();
}
children.add(e);
e.x += x;
e.y += y;
e.parent = this;
e.gui = gui;
return e;
}
if (e.parent != null) {
e.parent.removeChild(e);
}
public GuiElement removeChild(GuiElement e)
{
if(children == null)
{
return e;
}
children.add(e);
e.x += x;
e.y += y;
e.parent = this;
e.gui = gui;
return e;
}
children.remove(e);
e.x -= x;
e.y -= y;
e.parent = null;
e.gui = null;
return e;
}
public GuiElement removeChild(GuiElement e) {
if (children == null) {
return e;
}
public void onAdded()
{
if(children == null)
{
return;
}
children.remove(e);
e.x -= x;
e.y -= y;
e.parent = null;
e.gui = null;
return e;
}
for(GuiElement e : children)
{
if(e.parent != e.addedParent)
{
e.onAdded();
}
public void onAdded() {
if (children == null) {
return;
}
e.addedParent = e.parent;
}
}
for (GuiElement e : children) {
if (e.parent != e.addedParent) {
e.onAdded();
}
boolean isMouseOver(InputMouseEvent ev)
{
return ev.x >= x && ev.x < x + w && ev.y >= y && ev.y < y + h;
}
e.addedParent = e.parent;
}
}
public void mouseDown(InputMouseEvent ev)
{
if(children == null)
{
return;
}
boolean isMouseOver(InputMouseEvent ev) {
return ev.x >= x && ev.x < x + w && ev.y >= y && ev.y < y + h;
}
for(GuiElement e : children)
{
e.mouseDown(ev);
public void mouseDown(InputMouseEvent ev) {
if (children == null) {
return;
}
if(ev.handled)
{
return;
}
}
}
for (GuiElement e : children) {
e.mouseDown(ev);
public void mouseUp(InputMouseEvent ev)
{
if(children == null)
{
return;
}
if (ev.handled) {
return;
}
}
}
for(GuiElement e : children)
{
e.mouseUp(ev);
public void mouseUp(InputMouseEvent ev) {
if (children == null) {
return;
}
if(ev.handled)
{
return;
}
}
}
for (GuiElement e : children) {
e.mouseUp(ev);
public void mouseMove(InputMouseEvent ev)
{
if(children == null)
{
return;
}
if (ev.handled) {
return;
}
}
}
for(GuiElement e : children)
{
e.mouseMove(ev);
public void mouseMove(InputMouseEvent ev) {
if (children == null) {
return;
}
if(ev.handled)
{
return;
}
}
}
for (GuiElement e : children) {
e.mouseMove(ev);
public void mouseWheel(InputMouseEvent ev)
{
if(children == null)
{
return;
}
if (ev.handled) {
return;
}
}
}
for(GuiElement e : children)
{
e.mouseWheel(ev);
public void mouseWheel(InputMouseEvent ev) {
if (children == null) {
return;
}
if(ev.handled)
{
return;
}
}
}
for (GuiElement e : children) {
e.mouseWheel(ev);
public void render()
{
if(children == null)
{
return;
}
if (ev.handled) {
return;
}
}
}
for(GuiElement e : children)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
e.render();
}
}
public void render() {
if (children == null) {
return;
}
public void keyPressed(InputKeyboardEvent ev)
{
if(children == null)
{
return;
}
for (GuiElement e : children) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
e.render();
}
}
for(GuiElement e : children)
{
e.keyPressed(ev);
public void keyPressed(InputKeyboardEvent ev) {
if (children == null) {
return;
}
if(ev.handled)
{
return;
}
}
}
for (GuiElement e : children) {
e.keyPressed(ev);
if (ev.handled) {
return;
}
}
}
}
@@ -1,83 +1,74 @@
package com.cricketcraft.chisel.client.gui;
public class GuiExButton extends GuiElement
{
protected String caption;
public class GuiExButton extends GuiElement {
int u, v, texw, texh;
int borderTop, borderRight, borderBottom, borderLeft;
protected String caption;
boolean over;
public boolean disabled;
int u, v, texw, texh;
int borderTop, borderRight, borderBottom, borderLeft;
public TexturedBox boxDisabled;
public TexturedBox boxNormal;
public TexturedBox boxOver;
boolean over;
public boolean disabled;
public GuiExButton(int x, int y, int w, int h, String caption)
{
this(x, y, w, h, caption, "textures/gui/widgets.png");
}
public TexturedBox boxDisabled;
public TexturedBox boxNormal;
public TexturedBox boxOver;
public GuiExButton(int x, int y, int w, int h, String caption, String texture)
{
super(x, y, w, h);
this.caption = caption;
disabled = false;
u = 0;
v = 46;
texw = 200;
texh = 20;
borderTop = 2;
borderRight = 2;
borderBottom = 3;
borderLeft = 2;
public GuiExButton(int x, int y, int w, int h, String caption) {
this(x, y, w, h, caption, "textures/gui/widgets.png");
}
boxDisabled = new TexturedBox(texture, 0, 46, 200, 20, 2, 2, 3, 2);
boxNormal = new TexturedBox(texture, 0, 66, 200, 20, 2, 2, 3, 2);
boxOver = new TexturedBox(texture, 0, 86, 200, 20, 2, 2, 3, 2);
public GuiExButton(int x, int y, int w, int h, String caption, String texture) {
super(x, y, w, h);
this.caption = caption;
disabled = false;
u = 0;
v = 46;
texw = 200;
texh = 20;
borderTop = 2;
borderRight = 2;
borderBottom = 3;
borderLeft = 2;
}
boxDisabled = new TexturedBox(texture, 0, 46, 200, 20, 2, 2, 3, 2);
boxNormal = new TexturedBox(texture, 0, 66, 200, 20, 2, 2, 3, 2);
boxOver = new TexturedBox(texture, 0, 86, 200, 20, 2, 2, 3, 2);
public void onClick()
{
}
}
@Override
public void render()
{
int color = 0xffe0e0e0;
TexturedBox box = boxDisabled;
public void onClick() {
}
if(!disabled && !over)
{
box = boxNormal;
color = 0xffffffff;
} else if(!disabled && over)
{
box = boxOver;
color = 0xffffff70;
}
@Override
public void render() {
int color = 0xffe0e0e0;
TexturedBox box = boxDisabled;
box.render(gui, x, y, w, h);
gui.drawCenteredStringWithShadow(caption, x + w / 2, y + h / 2, color);
}
if (!disabled && !over) {
box = boxNormal;
color = 0xffffffff;
} else if (!disabled && over) {
box = boxOver;
color = 0xffffff70;
}
@Override
public void mouseMove(InputMouseEvent ev)
{
over = isMouseOver(ev);
}
box.render(gui, x, y, w, h);
gui.drawCenteredStringWithShadow(caption, x + w / 2, y + h / 2, color);
}
@Override
public void mouseDown(InputMouseEvent ev)
{
if(!isMouseOver(ev))
{
return;
}
@Override
public void mouseMove(InputMouseEvent ev) {
over = isMouseOver(ev);
}
gui.playSound("random.click", 1.0f, 1.0f);
onClick();
}
@Override
public void mouseDown(InputMouseEvent ev) {
if (!isMouseOver(ev)) {
return;
}
gui.playSound("random.click", 1.0f, 1.0f);
onClick();
}
}
@@ -6,29 +6,25 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import cpw.mods.fml.client.IModGuiFactory;
public class GuiFactory implements IModGuiFactory
{
@Override
public void initialize(Minecraft minecraftInstance)
{
public class GuiFactory implements IModGuiFactory {
}
@Override
public void initialize(Minecraft minecraftInstance) {
@Override
public Class<? extends GuiScreen> mainConfigGuiClass()
{
return GuiChiselConfig.class;
}
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
{
return null;
}
@Override
public Class<? extends GuiScreen> mainConfigGuiClass() {
return GuiChiselConfig.class;
}
@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element)
{
return null;
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
return null;
}
@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
return null;
}
}
@@ -1,23 +1,20 @@
package com.cricketcraft.chisel.client.gui;
public class GuiLabel extends GuiElement
{
String caption;
public class GuiLabel extends GuiElement {
public GuiLabel(int x, int y, int w, int h, String caption)
{
super(x, y, w, h);
this.caption = caption;
}
String caption;
public GuiLabel(int x, int y, String string)
{
this(x, y, 0, 0, string);
}
public GuiLabel(int x, int y, int w, int h, String caption) {
super(x, y, w, h);
this.caption = caption;
}
@Override
public void render()
{
gui.drawString(caption, x, y, 0x404040);
}
public GuiLabel(int x, int y, String string) {
this(x, y, 0, 0, string);
}
@Override
public void render() {
gui.drawString(caption, x, y, 0x404040);
}
}
@@ -11,23 +11,24 @@ import com.cricketcraft.chisel.block.tileentity.TileEntityPresent;
import com.cricketcraft.chisel.inventory.ContainerPresent;
public class GuiPresent extends GuiContainer {
private static final ResourceLocation gui = new ResourceLocation("chisel:textures/present-gui.png");
private IInventory upper, lower;
private int rows;
public GuiPresent(InventoryPlayer inventoryPlayer, TileEntityPresent tileEntityPresent) {
super(new ContainerPresent(inventoryPlayer, tileEntityPresent));
rows = tileEntityPresent.getSizeInventory() / 9;
this.ySize = 114 + rows * 18;
}
private static final ResourceLocation gui = new ResourceLocation("chisel:textures/present-gui.png");
private IInventory upper, lower;
private int rows;
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(gui);
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.rows * 18 + 17);
this.drawTexturedModalRect(x, y + this.rows * 18 + 17, 0, 126, this.xSize, 96);
}
public GuiPresent(InventoryPlayer inventoryPlayer, TileEntityPresent tileEntityPresent) {
super(new ContainerPresent(inventoryPlayer, tileEntityPresent));
rows = tileEntityPresent.getSizeInventory() / 9;
this.ySize = 114 + rows * 18;
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(gui);
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.rows * 18 + 17);
this.drawTexturedModalRect(x, y + this.rows * 18 + 17, 0, 126, this.xSize, 96);
}
}
@@ -13,262 +13,223 @@ import org.lwjgl.opengl.GL11;
import com.cricketcraft.chisel.utils.DummyContainer;
import com.cricketcraft.chisel.utils.GeneralClient;
public class GuiScreenPlus extends GuiContainer
{
public int screenW;
public int screenH;
public int screenX;
public int screenY;
public class GuiScreenPlus extends GuiContainer {
public GuiElement root;
public int screenW;
public int screenH;
public int screenX;
public int screenY;
String backgroundTexture;
public GuiElement root;
public GuiScreenPlus(Container container, int w, int h, String backgroundTexture)
{
super(container);
root = new GuiElement(0, 0, w, h);
root.gui = this;
this.screenW = w;
this.screenH = h;
this.backgroundTexture = backgroundTexture;
}
String backgroundTexture;
public GuiScreenPlus(int w, int h, String backgroundTexture)
{
this(new DummyContainer(), w, h, backgroundTexture);
}
public GuiScreenPlus(Container container, int w, int h, String backgroundTexture) {
super(container);
root = new GuiElement(0, 0, w, h);
root.gui = this;
this.screenW = w;
this.screenH = h;
this.backgroundTexture = backgroundTexture;
}
@Override
public void initGui()
{
xSize = screenW;
ySize = screenH;
super.initGui();
screenX = guiLeft;
screenY = guiTop;
root.onAdded();
public GuiScreenPlus(int w, int h, String backgroundTexture) {
this(new DummyContainer(), w, h, backgroundTexture);
}
Keyboard.enableRepeatEvents(true);
}
@Override
public void initGui() {
xSize = screenW;
ySize = screenH;
super.initGui();
screenX = guiLeft;
screenY = guiTop;
root.onAdded();
Keyboard.enableRepeatEvents(true);
}
@Override
public void handleInput()
{
while(Mouse.next())
{
this.handleMouseInput();
}
@Override
public void handleInput() {
while (Mouse.next()) {
this.handleMouseInput();
}
while(Keyboard.next())
{
this.handleKeyboardInput();
}
}
while (Keyboard.next()) {
this.handleKeyboardInput();
}
}
InputMouseEvent mouseEvent = new InputMouseEvent();
int oldX = -1;
int oldY = -1;
InputMouseEvent mouseEvent = new InputMouseEvent();
int oldX = -1;
int oldY = -1;
boolean[] downButtons = new boolean[12];
boolean[] downButtons = new boolean[12];
@Override
public void handleMouseInput()
{
mouseEvent.handled = false;
mouseEvent.x = Mouse.getEventX() * width / mc.displayWidth - this.screenX;
mouseEvent.y = height - Mouse.getEventY() * height / mc.displayHeight - 1 - this.screenY;
@Override
public void handleMouseInput() {
mouseEvent.handled = false;
mouseEvent.x = Mouse.getEventX() * width / mc.displayWidth - this.screenX;
mouseEvent.y = height - Mouse.getEventY() * height / mc.displayHeight - 1 - this.screenY;
if(oldX == -1)
{
oldX = mouseEvent.x;
oldY = mouseEvent.y;
}
if (oldX == -1) {
oldX = mouseEvent.x;
oldY = mouseEvent.y;
}
mouseEvent.dx = mouseEvent.x - oldX;
mouseEvent.dy = mouseEvent.y - oldY;
oldX = mouseEvent.x;
oldY = mouseEvent.y;
mouseEvent.down = Mouse.getEventButtonState();
mouseEvent.button = Mouse.getEventButton();
mouseEvent.wheel = Mouse.getEventDWheel();
mouseEvent.dx = mouseEvent.x - oldX;
mouseEvent.dy = mouseEvent.y - oldY;
oldX = mouseEvent.x;
oldY = mouseEvent.y;
mouseEvent.down = Mouse.getEventButtonState();
mouseEvent.button = Mouse.getEventButton();
mouseEvent.wheel = Mouse.getEventDWheel();
if(mouseEvent.wheel != 0)
{
if(mouseEvent.wheel < 0)
{
mouseEvent.wheel = -1;
} else
{
mouseEvent.wheel = 1;
}
if (mouseEvent.wheel != 0) {
if (mouseEvent.wheel < 0) {
mouseEvent.wheel = -1;
} else {
mouseEvent.wheel = 1;
}
root.mouseWheel(mouseEvent);
} else if(mouseEvent.button >= 0 && mouseEvent.button < downButtons.length)
{
if(downButtons[mouseEvent.button] != mouseEvent.down)
{
downButtons[mouseEvent.button] = mouseEvent.down;
root.mouseWheel(mouseEvent);
} else if (mouseEvent.button >= 0 && mouseEvent.button < downButtons.length) {
if (downButtons[mouseEvent.button] != mouseEvent.down) {
downButtons[mouseEvent.button] = mouseEvent.down;
if(mouseEvent.down)
{
root.mouseDown(mouseEvent);
} else
{
root.mouseUp(mouseEvent);
}
} else if(mouseEvent.dx != 0 || mouseEvent.dy != 0)
{
root.mouseMove(mouseEvent);
}
} else if(mouseEvent.dx != 0 || mouseEvent.dy != 0)
{
root.mouseMove(mouseEvent);
}
if (mouseEvent.down) {
root.mouseDown(mouseEvent);
} else {
root.mouseUp(mouseEvent);
}
} else if (mouseEvent.dx != 0 || mouseEvent.dy != 0) {
root.mouseMove(mouseEvent);
}
} else if (mouseEvent.dx != 0 || mouseEvent.dy != 0) {
root.mouseMove(mouseEvent);
}
if(!mouseEvent.handled)
{
super.handleMouseInput();
}
}
if (!mouseEvent.handled) {
super.handleMouseInput();
}
}
InputKeyboardEvent keyboardEvent = new InputKeyboardEvent();
InputKeyboardEvent keyboardEvent = new InputKeyboardEvent();
@Override
public void handleKeyboardInput()
{
keyboardEvent.handled = false;
@Override
public void handleKeyboardInput() {
keyboardEvent.handled = false;
if(Keyboard.getEventKeyState())
{
keyboardEvent.key = Keyboard.getEventKey();
keyboardEvent.character = Keyboard.getEventCharacter();
if (Keyboard.getEventKeyState()) {
keyboardEvent.key = Keyboard.getEventKey();
keyboardEvent.character = Keyboard.getEventCharacter();
switch(keyboardEvent.key)
{
case 1:
break;
switch (keyboardEvent.key) {
case 1:
break;
default:
root.keyPressed(keyboardEvent);
}
}
default:
root.keyPressed(keyboardEvent);
}
}
if(!keyboardEvent.handled)
{
super.handleKeyboardInput();
}
}
if (!keyboardEvent.handled) {
super.handleKeyboardInput();
}
}
public void close()
{
mc.displayGuiScreen((GuiScreen) null);
mc.setIngameFocus();
}
public void close() {
mc.displayGuiScreen((GuiScreen) null);
mc.setIngameFocus();
}
protected void addChild(GuiElement e)
{
root.addChild(e);
}
protected void addChild(GuiElement e) {
root.addChild(e);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int bx, int by)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GeneralClient.bind(backgroundTexture);
drawTexturedModalRect(screenX, screenY, 0, 0, screenW, screenH);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int bx, int by) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GeneralClient.bind(backgroundTexture);
drawTexturedModalRect(screenX, screenY, 0, 0, screenW, screenH);
}
@Override
protected void drawGuiContainerForegroundLayer(int fx, int fy)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
root.render();
}
@Override
protected void drawGuiContainerForegroundLayer(int fx, int fy) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
root.render();
}
public void drawString(String text, int sx, int sy, int color)
{
fontRendererObj.drawString(text, sx, sy, color);
}
public void drawString(String text, int sx, int sy, int color) {
fontRendererObj.drawString(text, sx, sy, color);
}
public void drawCenteredString(String text, int sx, int sy, int color)
{
fontRendererObj.drawString(text, sx - fontRendererObj.getStringWidth(text) / 2, sy - fontRendererObj.FONT_HEIGHT / 2, color);
}
public void drawCenteredString(String text, int sx, int sy, int color) {
fontRendererObj.drawString(text, sx - fontRendererObj.getStringWidth(text) / 2, sy - fontRendererObj.FONT_HEIGHT / 2, color);
}
public void drawStringWithShadow(String text, int sx, int sy, int color)
{
fontRendererObj.drawStringWithShadow(text, sx, sy, color);
}
public void drawStringWithShadow(String text, int sx, int sy, int color) {
fontRendererObj.drawStringWithShadow(text, sx, sy, color);
}
public void drawCenteredStringWithShadow(String text, int sx, int sy, int color)
{
fontRendererObj.drawStringWithShadow(text, sx - fontRendererObj.getStringWidth(text) / 2, sy - fontRendererObj.FONT_HEIGHT / 2, color);
}
public void drawCenteredStringWithShadow(String text, int sx, int sy, int color) {
fontRendererObj.drawStringWithShadow(text, sx - fontRendererObj.getStringWidth(text) / 2, sy - fontRendererObj.FONT_HEIGHT / 2, color);
}
public FontRenderer fontRendererObj()
{
return this.fontRendererObj;
}
public FontRenderer fontRendererObj() {
return this.fontRendererObj;
}
protected void drawRect(int gx, int gy, int gw, int gh, int c1, int c2)
{
drawGradientRect(gx, gy, gx + gw, gy + gh, c1, c2);
}
protected void drawRect(int gx, int gy, int gw, int gh, int c1, int c2) {
drawGradientRect(gx, gy, gx + gw, gy + gh, c1, c2);
}
public void drawTiledRect(int rx, int ry, int rw, int rh, int u, int v, int tw, int th)
{
if(rw == 0 || rh == 0 || tw == 0 || th == 0) return;
public void drawTiledRect(int rx, int ry, int rw, int rh, int u, int v, int tw, int th) {
if (rw == 0 || rh == 0 || tw == 0 || th == 0)
return;
float pixel = 0.00390625f;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
float pixel = 0.00390625f;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
for(int y = 0; y < rh; y += th)
{
for(int x = 0; x < rw; x += tw)
{
int qw = tw;
for (int y = 0; y < rh; y += th) {
for (int x = 0; x < rw; x += tw) {
int qw = tw;
if(x + qw > rw)
{
qw = rw - x;
}
if (x + qw > rw) {
qw = rw - x;
}
int qh = th;
int qh = th;
if(y + qh > rh)
{
qh = rh - y;
}
if (y + qh > rh) {
qh = rh - y;
}
double x1 = rx + x;
double x2 = rx + x + qw;
double y1 = ry + y;
double y2 = ry + y + qh;
double u1 = pixel * (u);
double u2 = pixel * (u + tw);
double v1 = pixel * (v);
double v2 = pixel * (v + th);
tessellator.addVertexWithUV(x1, y2, this.zLevel, u1, v2);
tessellator.addVertexWithUV(x2, y2, this.zLevel, u2, v2);
tessellator.addVertexWithUV(x2, y1, this.zLevel, u2, v1);
tessellator.addVertexWithUV(x1, y1, this.zLevel, u1, v1);
}
}
double x1 = rx + x;
double x2 = rx + x + qw;
double y1 = ry + y;
double y2 = ry + y + qh;
double u1 = pixel * (u);
double u2 = pixel * (u + tw);
double v1 = pixel * (v);
double v2 = pixel * (v + th);
tessellator.addVertexWithUV(x1, y2, this.zLevel, u1, v2);
tessellator.addVertexWithUV(x2, y2, this.zLevel, u2, v2);
tessellator.addVertexWithUV(x2, y1, this.zLevel, u2, v1);
tessellator.addVertexWithUV(x1, y1, this.zLevel, u1, v1);
}
}
tessellator.draw();
}
tessellator.draw();
}
public void bindTexture(String tex)
{
GeneralClient.bind(tex);
}
public void bindTexture(String tex) {
GeneralClient.bind(tex);
}
public void playSound(String sound, float volume, float pitch)
{
// TODO
//mc.getSoundHandler().playSoundFX(null, 1.0F, 1.0F);
}
public void playSound(String sound, float volume, float pitch) {
// TODO
// mc.getSoundHandler().playSoundFX(null, 1.0F, 1.0F);
}
}
@@ -6,119 +6,107 @@ import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.opengl.GL11;
public class GuilScrolledBox extends GuiElement
{
public int offset = 0;
int contentHeight = 0;
int scrollingStart = -1;
public class GuilScrolledBox extends GuiElement {
public GuilScrolledBox(int x, int y, int w, int h)
{
super(x, y, w, h);
}
public int offset = 0;
int contentHeight = 0;
int scrollingStart = -1;
int x0, x1;
public GuilScrolledBox(int x, int y, int w, int h) {
super(x, y, w, h);
}
protected void overlayBackground(int start, int end, int color, int a1, int a2)
{
Tessellator tessellator = Tessellator.instance;
int x0, x1;
float f = 32.0F;
protected void overlayBackground(int start, int end, int color, int a1, int a2) {
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_I(color, a2);
tessellator.addVertexWithUV(x0, end, 0.0D, 0.0D, end / f);
tessellator.addVertexWithUV(x1, end, 0.0D, gui.width / f, end / f);
tessellator.setColorRGBA_I(color, a1);
tessellator.addVertexWithUV(x1, start, 0.0D, gui.width / f, start / f);
tessellator.addVertexWithUV(x0, start, 0.0D, 0.0D, start / f);
tessellator.draw();
}
float f = 32.0F;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_I(color, a2);
tessellator.addVertexWithUV(x0, end, 0.0D, 0.0D, end / f);
tessellator.addVertexWithUV(x1, end, 0.0D, gui.width / f, end / f);
tessellator.setColorRGBA_I(color, a1);
tessellator.addVertexWithUV(x1, start, 0.0D, gui.width / f, start / f);
tessellator.addVertexWithUV(x0, start, 0.0D, 0.0D, start / f);
tessellator.draw();
}
@Override
public GuiElement addChild(GuiElement e)
{
int childBottom = e.y + e.h - 18;
if(childBottom > contentHeight)
contentHeight = childBottom;
@Override
public GuiElement addChild(GuiElement e) {
int childBottom = e.y + e.h - 18;
if (childBottom > contentHeight)
contentHeight = childBottom;
return super.addChild(e);
}
return super.addChild(e);
}
@Override
public void render() {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.optionsBackground);
x0 = -gui.screenX;
x1 = -gui.screenX + gui.width;
@Override
public void render()
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.optionsBackground);
x0 = -gui.screenX;
x1 = -gui.screenX + gui.width;
overlayBackground(y, h, 0x202020, 0xff, 0xff);
overlayBackground(y, h, 0x202020, 0xff, 0xff);
GL11.glPushMatrix();
GL11.glTranslatef(0.0f, offset, 0.0f);
super.render();
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glTranslatef(0.0f, offset, 0.0f);
super.render();
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glDisable(GL11.GL_TEXTURE_2D);
overlayBackground(y, y + 8, 0x000000, 0xff, 0x00);
overlayBackground(h - 8, h, 0x000000, 0x00, 0xff);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glShadeModel(GL11.GL_SMOOTH);
GL11.glDisable(GL11.GL_TEXTURE_2D);
overlayBackground(y, y + 8, 0x000000, 0xff, 0x00);
overlayBackground(h - 8, h, 0x000000, 0x00, 0xff);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glDisable(GL11.GL_BLEND);
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.optionsBackground);
overlayBackground(-gui.screenY, y, 0x404040, 0xff, 0xff);
overlayBackground(h, -gui.screenY + gui.height, 0x404040, 0xff, 0xff);
}
Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.optionsBackground);
overlayBackground(-gui.screenY, y, 0x404040, 0xff, 0xff);
overlayBackground(h, -gui.screenY + gui.height, 0x404040, 0xff, 0xff);
}
@Override
public void mouseMove(InputMouseEvent ev) {
if (scrollingStart != -1) {
offset = ev.y - scrollingStart;
if (offset > contentHeight)
offset = contentHeight;
if (offset < -contentHeight)
offset = -contentHeight;
}
@Override
public void mouseMove(InputMouseEvent ev)
{
if(scrollingStart != -1)
{
offset = ev.y - scrollingStart;
if(offset > contentHeight) offset = contentHeight;
if(offset < -contentHeight) offset = -contentHeight;
}
ev.y -= offset;
super.mouseMove(ev);
ev.y += offset;
}
ev.y -= offset;
super.mouseMove(ev);
ev.y += offset;
}
@Override
public void mouseDown(InputMouseEvent ev) {
scrollingStart = ev.y - offset;
@Override
public void mouseDown(InputMouseEvent ev)
{
scrollingStart = ev.y - offset;
if (ev.y >= y && ev.y < y + h) {
ev.y -= offset;
super.mouseDown(ev);
ev.y += offset;
}
}
if(ev.y >= y && ev.y < y + h)
{
ev.y -= offset;
super.mouseDown(ev);
ev.y += offset;
}
}
@Override
public void mouseUp(InputMouseEvent ev) {
scrollingStart = -1;
@Override
public void mouseUp(InputMouseEvent ev)
{
scrollingStart = -1;
if(ev.y >= y && ev.y < y + h)
{
ev.y -= offset;
super.mouseUp(ev);
ev.y += offset;
}
}
if (ev.y >= y && ev.y < y + h) {
ev.y -= offset;
super.mouseUp(ev);
ev.y += offset;
}
}
}
@@ -1,6 +1,6 @@
package com.cricketcraft.chisel.client.gui;
public class InputEvent
{
public boolean handled;
public class InputEvent {
public boolean handled;
}
@@ -1,7 +1,7 @@
package com.cricketcraft.chisel.client.gui;
public class InputKeyboardEvent extends InputEvent
{
public int key;
public char character;
public class InputKeyboardEvent extends InputEvent {
public int key;
public char character;
}
@@ -1,12 +1,12 @@
package com.cricketcraft.chisel.client.gui;
public class InputMouseEvent extends InputEvent
{
public int x;
public int y;
public int dx;
public int dy;
public int wheel;
public int button;
public boolean down;
public class InputMouseEvent extends InputEvent {
public int x;
public int y;
public int dx;
public int dy;
public int wheel;
public int button;
public boolean down;
}
@@ -7,120 +7,103 @@ import org.lwjgl.input.Mouse;
import com.cricketcraft.chisel.utils.GeneralClient;
public abstract class Scrollbar extends GuiButton
{
public boolean active;
public abstract class Scrollbar extends GuiButton {
public float offset;
public float step;
public boolean active;
boolean dragged;
public float offset;
public float step;
int elementHeight = 15;
boolean dragged;
public Scrollbar(int id, int x, int y, int w, int h, String string)
{
super(id, x, y, w, h, string);
offset = 0;
step = 0.025f;
height = h;
active = true;
dragged = false;
}
int elementHeight = 15;
/**
* Returns true if the mouse has been pressed on this control. Equivalent of
* MouseListener.mousePressed(MouseEvent e).
*/
@Override
public boolean mousePressed(Minecraft mc, int x, int y)
{
if(x < xPosition || x >= xPosition + width)
{
return false;
}
public Scrollbar(int id, int x, int y, int w, int h, String string) {
super(id, x, y, w, h, string);
offset = 0;
step = 0.025f;
height = h;
active = true;
dragged = false;
}
if(y < yPosition || y >= yPosition + height)
{
return false;
}
/**
* Returns true if the mouse has been pressed on this control. Equivalent of
* MouseListener.mousePressed(MouseEvent e).
*/
@Override
public boolean mousePressed(Minecraft mc, int x, int y) {
if (x < xPosition || x >= xPosition + width) {
return false;
}
if(active)
{
dragged = true;
}
if (y < yPosition || y >= yPosition + height) {
return false;
}
return true;
}
if (active) {
dragged = true;
}
/**
* Draws this button to the screen.
*/
@Override
public void drawButton(Minecraft mc, int x, int y)
{
if(dragged)
{
float initialOffset = offset;
int off = y - yPosition - elementHeight / 2;
offset = 1.0f * off / (height - elementHeight);
return true;
}
if(offset < 0)
{
offset = 0;
}
/**
* Draws this button to the screen.
*/
@Override
public void drawButton(Minecraft mc, int x, int y) {
if (dragged) {
float initialOffset = offset;
int off = y - yPosition - elementHeight / 2;
offset = 1.0f * off / (height - elementHeight);
if(offset > 1)
{
offset = 1;
}
if (offset < 0) {
offset = 0;
}
if(initialOffset != offset)
{
onScrolled(offset);
}
}
if (offset > 1) {
offset = 1;
}
int bottom = yPosition + height;
GeneralClient.bind("/gui/allitems.png");
drawTexturedModalRect(xPosition, yPosition + (int) ((height - elementHeight) * offset), active ? 232 : 244, 0, 12, elementHeight);
}
if (initialOffset != offset) {
onScrolled(offset);
}
}
public void handleMouseInput()
{
if(Mouse.getEventButton() == 0 && !Mouse.getEventButtonState())
{
dragged = false;
}
int bottom = yPosition + height;
GeneralClient.bind("/gui/allitems.png");
drawTexturedModalRect(xPosition, yPosition + (int) ((height - elementHeight) * offset), active ? 232 : 244, 0, 12, elementHeight);
}
if(!active)
{
return;
}
public void handleMouseInput() {
if (Mouse.getEventButton() == 0 && !Mouse.getEventButtonState()) {
dragged = false;
}
float initialOffset = offset;
int direction = Mouse.getEventDWheel();
if (!active) {
return;
}
if(direction != 0)
{
offset += direction > 0 ? -step : step;
}
float initialOffset = offset;
int direction = Mouse.getEventDWheel();
if(offset < 0)
{
offset = 0;
}
if (direction != 0) {
offset += direction > 0 ? -step : step;
}
if(offset > 1)
{
offset = 1;
}
if (offset < 0) {
offset = 0;
}
if(initialOffset != offset)
{
onScrolled(offset);
}
}
if (offset > 1) {
offset = 1;
}
public abstract void onScrolled(float off);
if (initialOffset != offset) {
onScrolled(offset);
}
}
public abstract void onScrolled(float off);
}
@@ -1,73 +1,69 @@
package com.cricketcraft.chisel.client.gui;
public class TexturedBox
{
String texture;
int u, v, texw, texh;
int borderTop, borderRight, borderBottom, borderLeft;
public class TexturedBox {
public TexturedBox(String texture, int u, int v, int texw, int texh, int borderTop, int borderRight, int borderBottom, int borderLeft)
{
this.texture = texture;
this.u = u;
this.v = v;
this.texw = texw;
this.texh = texh;
this.borderTop = borderTop;
this.borderRight = borderRight;
this.borderBottom = borderBottom;
this.borderLeft = borderLeft;
}
String texture;
int u, v, texw, texh;
int borderTop, borderRight, borderBottom, borderLeft;
public void render(GuiScreenPlus gui, int x, int y, int w, int h)
{
int x1 = x;
int x2 = x + borderLeft;
int x3 = x + w - borderRight;
int y1 = y;
int y2 = y + borderTop;
int y3 = y + h - borderBottom;
int w1 = borderLeft;
int w2 = w - borderLeft - borderRight;
int w3 = borderRight;
int h1 = borderTop;
int h2 = h - borderTop - borderBottom;
int h3 = borderBottom;
int u1 = u;
int v1 = v;
int tw = texw;
public TexturedBox(String texture, int u, int v, int texw, int texh, int borderTop, int borderRight, int borderBottom, int borderLeft) {
this.texture = texture;
this.u = u;
this.v = v;
this.texw = texw;
this.texh = texh;
this.borderTop = borderTop;
this.borderRight = borderRight;
this.borderBottom = borderBottom;
this.borderLeft = borderLeft;
}
if(tw > w)
{
tw = w;
}
public void render(GuiScreenPlus gui, int x, int y, int w, int h) {
int x1 = x;
int x2 = x + borderLeft;
int x3 = x + w - borderRight;
int y1 = y;
int y2 = y + borderTop;
int y3 = y + h - borderBottom;
int w1 = borderLeft;
int w2 = w - borderLeft - borderRight;
int w3 = borderRight;
int h1 = borderTop;
int h2 = h - borderTop - borderBottom;
int h3 = borderBottom;
int u1 = u;
int v1 = v;
int tw = texw;
int th = texh;
if (tw > w) {
tw = w;
}
if(th > h)
{
th = h;
}
int th = texh;
int u2 = u1 + borderLeft;
int u3 = u1 + texw - borderRight;
int v2 = v1 + borderTop;
int v3 = v1 + texh - borderBottom;
int texw1 = borderLeft;
int texw2 = tw - borderLeft - borderRight;
int texw3 = borderRight;
int texh1 = borderTop;
int texh2 = th - borderTop - borderBottom;
int texh3 = borderBottom;
gui.bindTexture(texture);
gui.drawTexturedModalRect(x1, y1, u1, v1, w1, h1);
gui.drawTiledRect(x2, y1, w2, h1, u2, v1, texw2, texh1);
gui.drawTexturedModalRect(x3, y1, u3, v1, w3, h1);
gui.drawTiledRect(x1, y2, w1, h2, u1, v2, w1, texh2);
gui.drawTiledRect(x2, y2, w2, h2, u2, v2, texw2, texh2);
gui.drawTiledRect(x3, y2, w3, h2, u3, v2, w3, texh2);
gui.drawTexturedModalRect(x1, y3, u1, v3, w1, h3);
gui.drawTiledRect(x2, y3, w2, h3, u2, v3, texw2, texh3);
gui.drawTexturedModalRect(x3, y3, u3, v3, w3, h3);
}
if (th > h) {
th = h;
}
int u2 = u1 + borderLeft;
int u3 = u1 + texw - borderRight;
int v2 = v1 + borderTop;
int v3 = v1 + texh - borderBottom;
int texw1 = borderLeft;
int texw2 = tw - borderLeft - borderRight;
int texw3 = borderRight;
int texh1 = borderTop;
int texh2 = th - borderTop - borderBottom;
int texh3 = borderBottom;
gui.bindTexture(texture);
gui.drawTexturedModalRect(x1, y1, u1, v1, w1, h1);
gui.drawTiledRect(x2, y1, w2, h1, u2, v1, texw2, texh1);
gui.drawTexturedModalRect(x3, y1, u3, v1, w3, h1);
gui.drawTiledRect(x1, y2, w1, h2, u1, v2, w1, texh2);
gui.drawTiledRect(x2, y2, w2, h2, u2, v2, texw2, texh2);
gui.drawTiledRect(x3, y2, w3, h2, u3, v2, w3, texh2);
gui.drawTexturedModalRect(x1, y3, u1, v3, w1, h3);
gui.drawTiledRect(x2, y3, w2, h3, u2, v3, texw2, texh3);
gui.drawTexturedModalRect(x3, y3, u3, v3, w3, h3);
}
}