Delete unused autoutils classes

This commit is contained in:
tterrag1098 committed 2015-05-20 21:41:48 -04:00
1 parent 11f45e59cd
commit 8395354116
12 files changed
-881

No files matched your search

@@ -1,58 +0,0 @@
package com.cricketcraft.chisel.client.gui;
import net.minecraft.client.gui.GuiTextField;
public class GuiEdit extends GuiElement {
GuiTextField field;
String tempString = "";
public GuiEdit(int x, int y, int w, int h) {
super(x, y, w, h);
}
@Override
public void onAdded() {
field = new GuiTextField(gui.fontRendererObj(), x, y, w, h);
setText(tempString);
}
public String getText() {
if (field == null) {
return tempString;
} else {
return field.getText();
}
}
public void setText(String text) {
if (field == null) {
tempString = text;
} else {
field.setText(text);
}
}
@Override
public void render() {
field.drawTextBox();
}
@Override
public void mouseDown(InputMouseEvent ev) {
field.mouseClicked(ev.x, ev.y, ev.button);
if (isMouseOver(ev)) {
ev.handled = true;
}
}
@Override
public void keyPressed(InputKeyboardEvent ev) {
field.textboxKeyTyped(ev.character, ev.key);
if (field.isFocused()) {
ev.handled = true;
}
}
}
@@ -1,153 +0,0 @@
package com.cricketcraft.chisel.client.gui;
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 GuiScreenPlus gui;
public GuiElement parent, addedParent;
private ArrayList<GuiElement> children = null;
public GuiElement(int x, int y, int w, int h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
public GuiElement addChild(GuiElement e) {
if (children == null) {
children = new ArrayList<GuiElement>();
}
if (e.parent != null) {
e.parent.removeChild(e);
}
children.add(e);
e.x += x;
e.y += y;
e.parent = this;
e.gui = gui;
return e;
}
public GuiElement removeChild(GuiElement e) {
if (children == null) {
return e;
}
children.remove(e);
e.x -= x;
e.y -= y;
e.parent = null;
e.gui = null;
return e;
}
public void onAdded() {
if (children == null) {
return;
}
for (GuiElement e : children) {
if (e.parent != e.addedParent) {
e.onAdded();
}
e.addedParent = e.parent;
}
}
boolean isMouseOver(InputMouseEvent ev) {
return ev.x >= x && ev.x < x + w && ev.y >= y && ev.y < y + h;
}
public void mouseDown(InputMouseEvent ev) {
if (children == null) {
return;
}
for (GuiElement e : children) {
e.mouseDown(ev);
if (ev.handled) {
return;
}
}
}
public void mouseUp(InputMouseEvent ev) {
if (children == null) {
return;
}
for (GuiElement e : children) {
e.mouseUp(ev);
if (ev.handled) {
return;
}
}
}
public void mouseMove(InputMouseEvent ev) {
if (children == null) {
return;
}
for (GuiElement e : children) {
e.mouseMove(ev);
if (ev.handled) {
return;
}
}
}
public void mouseWheel(InputMouseEvent ev) {
if (children == null) {
return;
}
for (GuiElement e : children) {
e.mouseWheel(ev);
if (ev.handled) {
return;
}
}
}
public void render() {
if (children == null) {
return;
}
for (GuiElement e : children) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
e.render();
}
}
public void keyPressed(InputKeyboardEvent ev) {
if (children == null) {
return;
}
for (GuiElement e : children) {
e.keyPressed(ev);
if (ev.handled) {
return;
}
}
}
}
@@ -1,74 +0,0 @@
package com.cricketcraft.chisel.client.gui;
public class GuiExButton extends GuiElement {
protected String caption;
int u, v, texw, texh;
int borderTop, borderRight, borderBottom, borderLeft;
boolean over;
public boolean disabled;
public TexturedBox boxDisabled;
public TexturedBox boxNormal;
public TexturedBox boxOver;
public GuiExButton(int x, int y, int w, int h, String caption) {
this(x, y, w, h, caption, "textures/gui/widgets.png");
}
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;
if (!disabled && !over) {
box = boxNormal;
color = 0xffffffff;
} else if (!disabled && over) {
box = boxOver;
color = 0xffffff70;
}
box.render(gui, x, y, w, h);
gui.drawCenteredStringWithShadow(caption, x + w / 2, y + h / 2, color);
}
@Override
public void mouseMove(InputMouseEvent ev) {
over = isMouseOver(ev);
}
@Override
public void mouseDown(InputMouseEvent ev) {
if (!isMouseOver(ev)) {
return;
}
gui.playSound("random.click", 1.0f, 1.0f);
onClick();
}
}
@@ -1,30 +0,0 @@
package com.cricketcraft.chisel.client.gui;
import java.util.Set;
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) {
}
@Override
public Class<? extends GuiScreen> mainConfigGuiClass() {
return GuiChiselConfig.class;
}
@Override
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
return null;
}
@Override
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
return null;
}
}
@@ -1,20 +0,0 @@
package com.cricketcraft.chisel.client.gui;
public class GuiLabel extends GuiElement {
String caption;
public GuiLabel(int x, int y, int w, int h, String caption) {
super(x, y, w, h);
this.caption = caption;
}
public GuiLabel(int x, int y, String string) {
this(x, y, 0, 0, string);
}
@Override
public void render() {
gui.drawString(caption, x, y, 0x404040);
}
}
@@ -1,235 +0,0 @@
package com.cricketcraft.chisel.client.gui;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.inventory.Container;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
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 GuiElement root;
String 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;
}
public GuiScreenPlus(int w, int h, String backgroundTexture) {
this(new DummyContainer(), w, h, backgroundTexture);
}
@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();
}
while (Keyboard.next()) {
this.handleKeyboardInput();
}
}
InputMouseEvent mouseEvent = new InputMouseEvent();
int oldX = -1;
int oldY = -1;
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;
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();
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;
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();
}
}
InputKeyboardEvent keyboardEvent = new InputKeyboardEvent();
@Override
public void handleKeyboardInput() {
keyboardEvent.handled = false;
if (Keyboard.getEventKeyState()) {
keyboardEvent.key = Keyboard.getEventKey();
keyboardEvent.character = Keyboard.getEventCharacter();
switch (keyboardEvent.key) {
case 1:
break;
default:
root.keyPressed(keyboardEvent);
}
}
if (!keyboardEvent.handled) {
super.handleKeyboardInput();
}
}
public void close() {
mc.displayGuiScreen((GuiScreen) null);
mc.setIngameFocus();
}
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 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 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 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;
}
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;
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;
if (x + qw > rw) {
qw = rw - x;
}
int qh = th;
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);
}
}
tessellator.draw();
}
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);
}
}
@@ -1,112 +0,0 @@
package com.cricketcraft.chisel.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
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 GuilScrolledBox(int x, int y, int w, int h) {
super(x, y, w, h);
}
int x0, x1;
protected void overlayBackground(int start, int end, int color, int a1, int a2) {
Tessellator tessellator = Tessellator.instance;
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;
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;
overlayBackground(y, h, 0x202020, 0xff, 0xff);
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);
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;
}
ev.y -= offset;
super.mouseMove(ev);
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;
}
}
@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;
}
}
}
@@ -1,6 +0,0 @@
package com.cricketcraft.chisel.client.gui;
public class InputEvent {
public boolean handled;
}
@@ -1,7 +0,0 @@
package com.cricketcraft.chisel.client.gui;
public class InputKeyboardEvent extends InputEvent {
public int key;
public char character;
}
@@ -1,12 +0,0 @@
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;
}
@@ -1,107 +0,0 @@
package com.cricketcraft.chisel.client.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import org.lwjgl.input.Mouse;
import com.cricketcraft.chisel.utils.GeneralClient;
public abstract class Scrollbar extends GuiButton {
public boolean active;
public float offset;
public float step;
boolean dragged;
int elementHeight = 15;
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;
}
/**
* 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 (y < yPosition || y >= yPosition + height) {
return false;
}
if (active) {
dragged = true;
}
return 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);
if (offset < 0) {
offset = 0;
}
if (offset > 1) {
offset = 1;
}
if (initialOffset != offset) {
onScrolled(offset);
}
}
GeneralClient.bind("/gui/allitems.png");
drawTexturedModalRect(xPosition, yPosition + (int) ((height - elementHeight) * offset), active ? 232 : 244, 0, 12, elementHeight);
}
public void handleMouseInput() {
if (Mouse.getEventButton() == 0 && !Mouse.getEventButtonState()) {
dragged = false;
}
if (!active) {
return;
}
float initialOffset = offset;
int direction = Mouse.getEventDWheel();
if (direction != 0) {
offset += direction > 0 ? -step : step;
}
if (offset < 0) {
offset = 0;
}
if (offset > 1) {
offset = 1;
}
if (initialOffset != offset) {
onScrolled(offset);
}
}
public abstract void onScrolled(float off);
}
@@ -1,67 +0,0 @@
package com.cricketcraft.chisel.client.gui;
public class TexturedBox {
String texture;
int u, v, texw, texh;
int borderTop, borderRight, borderBottom, borderLeft;
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;
}
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;
if (tw > w) {
tw = w;
}
int th = texh;
if (th > h) {
th = h;
}
int u2 = u1 + borderLeft;
int u3 = u1 + texw - borderRight;
int v2 = v1 + borderTop;
int v3 = v1 + texh - borderBottom;
int texw2 = tw - borderLeft - 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);
}
}