Auto Format code

This commit is contained in:
modmuss50 2016-10-08 20:46:16 +01:00
parent 112b1657cf
commit 796df6c055
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
503 changed files with 12260 additions and 16291 deletions

View file

@ -5,7 +5,6 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.translation.I18n;
import net.minecraft.util.text.translation.LanguageMap;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
@ -13,64 +12,63 @@ import java.util.ArrayList;
public abstract class GuiWidget<T extends Container> extends GuiContainer {
public static final LanguageMap translate = ObfuscationReflectionHelper.getPrivateValue(LanguageMap.class, null, 2);
public static final LanguageMap translate = ObfuscationReflectionHelper.getPrivateValue(LanguageMap.class, null, 2);
private final ArrayList<Widget> widgets = new ArrayList<>();
private final ResourceLocation background;
private final ArrayList<Widget> widgets = new ArrayList<>();
private final ResourceLocation background;
public GuiWidget(T inventorySlotsIn, ResourceLocation background, int xSize, int ySize) {
super(inventorySlotsIn);
this.xSize = xSize;
this.ySize = ySize;
this.background = background;
}
public GuiWidget(T inventorySlotsIn, ResourceLocation background, int xSize, int ySize) {
super(inventorySlotsIn);
this.xSize = xSize;
this.ySize = ySize;
this.background = background;
}
public T getContainer() {
return (T) inventorySlots;
}
public T getContainer() {
return (T) inventorySlots;
}
@Override
public void initGui() {
super.initGui();
widgets.clear();
initWidgets();
}
@Override
public void initGui() {
super.initGui();
widgets.clear();
initWidgets();
}
public void addWidget(Widget widget) {
widgets.add(widget);
}
public void addWidget(Widget widget) {
widgets.add(widget);
}
public void removeWidget(Widget widget) {
widgets.remove(widget);
}
public void removeWidget(Widget widget) {
widgets.remove(widget);
}
public abstract void initWidgets();
public abstract void initWidgets();
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(background);
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(background);
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
String name = translate.translateKey("tile.techreborn.industrialgrinder.name");
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
int x = (this.width - this.xSize) / 2;
int y = (this.height - this.ySize) / 2;
String name = translate.translateKey("tile.techreborn.industrialgrinder.name");
fontRendererObj.drawString(name, xSize / 2 - fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
fontRendererObj.drawString(translate.translateKey("container.inventory"), 8, ySize - 94, 4210752);
fontRendererObj.drawString(name, xSize / 2 - fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
fontRendererObj.drawString(translate.translateKey("container.inventory"), 8, ySize - 94, 4210752);
for (Widget widget : widgets)
widget.drawWidget(this, x, y, mouseX, mouseY);
}
for(Widget widget : widgets)
widget.drawWidget(this, x, y, mouseX, mouseY);
}
public FontRenderer getFontRenderer() {
return fontRendererObj;
}
public FontRenderer getFontRenderer() {
return fontRendererObj;
}
}

View file

@ -5,45 +5,46 @@ import techreborn.client.gui.widget.tooltip.ToolTip;
public abstract class Widget {
private final int x, y;
protected final int width, height;
private final int x, y;
protected final int width, height;
private ToolTip toolTip;
private ToolTip toolTip;
public Widget(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public Widget(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public int getWidth() {
return width;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public int getHeight() {
return height;
}
public ToolTip getToolTip() {
return toolTip;
}
public ToolTip getToolTip() {
return toolTip;
}
public void setToolTip(ToolTip toolTip) {
this.toolTip = toolTip;
}
public void setToolTip(ToolTip toolTip) {
this.toolTip = toolTip;
}
public final void drawWidget(GuiWidget gui, int cornerX, int cornerY, int mouseX, int mouseY) {
int drawX = cornerX + x;
int drawY = cornerY + y;
if(toolTip != null && drawX > mouseX && drawY > mouseY &&
drawX + width < mouseX && drawY + height < mouseY) {
toolTip.draw(gui.getFontRenderer(), mouseX, mouseY);
}
draw(gui, drawX, drawY);
}
public final void drawWidget(GuiWidget gui, int cornerX, int cornerY, int mouseX, int mouseY) {
int drawX = cornerX + x;
int drawY = cornerY + y;
if (toolTip != null && drawX > mouseX && drawY > mouseY &&
drawX + width < mouseX && drawY + height < mouseY) {
toolTip.draw(gui.getFontRenderer(), mouseX, mouseY);
}
draw(gui, drawX, drawY);
}
protected abstract void draw(GuiScreen guiScreen, int x, int y);
protected abstract void mouseClick(GuiWidget guiWidget, int mouseX, int mouseY);
protected abstract void draw(GuiScreen guiScreen, int x, int y);
protected abstract void mouseClick(GuiWidget guiWidget, int mouseX, int mouseY);
}

View file

@ -1,6 +1,5 @@
package techreborn.client.gui.widget.tooltip;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import reborncore.client.gui.GuiUtil;
@ -9,53 +8,53 @@ import java.util.Collections;
public class ToolTip {
protected ArrayList<ToolTipLine> lines = new ArrayList<>();
protected ArrayList<ToolTipLine> lines = new ArrayList<>();
public ToolTip(String... textLines) {
for(String text : textLines)
lines.add(new ToolTipLine(text));
}
public ToolTip(String... textLines) {
for (String text : textLines)
lines.add(new ToolTipLine(text));
}
public ToolTip(ToolTipLine... toolTipLines) {
Collections.addAll(lines, toolTipLines);
}
public ToolTip(ToolTipLine... toolTipLines) {
Collections.addAll(lines, toolTipLines);
}
public ToolTip(int linesSize) {
for(int i = 0; i < linesSize; i++)
lines.add(new ToolTipLine());
}
public ToolTip(int linesSize) {
for (int i = 0; i < linesSize; i++)
lines.add(new ToolTipLine());
}
public void addLine(ToolTipLine toolTipLine) {
lines.add(toolTipLine);
}
public void addLine(ToolTipLine toolTipLine) {
lines.add(toolTipLine);
}
public void removeLine(int index) {
lines.remove(index);
}
public void removeLine(int index) {
lines.remove(index);
}
public ToolTipLine getLine(int index) {
return lines.get(index);
}
public ToolTipLine getLine(int index) {
return lines.get(index);
}
public ArrayList<ToolTipLine> getLines() {
return lines;
}
public ArrayList<ToolTipLine> getLines() {
return lines;
}
protected void refresh() {}
protected void refresh() {}
public void draw(FontRenderer font, int mouseX, int mouseY) {
refresh();
int maxLineLength = 0;
int textX = mouseX + 3;
int textY = mouseY + 3;
for(ToolTipLine toolTipLine : lines) {
toolTipLine.draw(font, textX, textY);
textY += (font.FONT_HEIGHT + 3);
int lineWidth = toolTipLine.getWidth(font);
if(lineWidth > maxLineLength)
maxLineLength = lineWidth;
}
GuiUtil.drawTooltipBox(mouseX, mouseY, maxLineLength, textY + 3);
}
public void draw(FontRenderer font, int mouseX, int mouseY) {
refresh();
int maxLineLength = 0;
int textX = mouseX + 3;
int textY = mouseY + 3;
for (ToolTipLine toolTipLine : lines) {
toolTipLine.draw(font, textX, textY);
textY += (font.FONT_HEIGHT + 3);
int lineWidth = toolTipLine.getWidth(font);
if (lineWidth > maxLineLength)
maxLineLength = lineWidth;
}
GuiUtil.drawTooltipBox(mouseX, mouseY, maxLineLength, textY + 3);
}
}

View file

@ -4,81 +4,83 @@ import net.minecraft.client.gui.FontRenderer;
public class ToolTipLine {
private String line;
private int color;
private boolean shadowed;
private String line;
private int color;
private boolean shadowed;
public ToolTipLine(String line, int color, boolean shadowed) {
this.line = line;
this.color = color;
this.shadowed = shadowed;
}
public ToolTipLine(String line, int color, boolean shadowed) {
this.line = line;
this.color = color;
this.shadowed = shadowed;
}
public ToolTipLine(String line, int color) {
this(line, color, false);
}
public ToolTipLine(String line, int color) {
this(line, color, false);
}
public ToolTipLine(String line, boolean shadowed) {
this(line, 0xFFFFFF, shadowed);
}
public ToolTipLine(String line, boolean shadowed) {
this(line, 0xFFFFFF, shadowed);
}
public ToolTipLine(String line) {
this(line, 0xFFFFFF, false);
}
public ToolTipLine(String line) {
this(line, 0xFFFFFF, false);
}
public ToolTipLine() {
this("");
}
public ToolTipLine() {
this("");
}
public String getLine() {
return line;
}
public String getLine() {
return line;
}
public void setLine(String line) {
this.line = line;
}
public void setLine(String line) {
this.line = line;
}
public int getColor() {
return color;
}
public int getColor() {
return color;
}
public void setColor(int color) {
this.color = color;
}
public void setColor(int color) {
this.color = color;
}
public boolean isShadowed() {
return shadowed;
}
public boolean isShadowed() {
return shadowed;
}
public void setShadowed(boolean shadowed) {
this.shadowed = shadowed;
}
public void setShadowed(boolean shadowed) {
this.shadowed = shadowed;
}
public int getWidth(FontRenderer fontRenderer) {
return fontRenderer.getStringWidth(getLine());
}
public int getWidth(FontRenderer fontRenderer) {
return fontRenderer.getStringWidth(getLine());
}
public void draw(FontRenderer fontRenderer, int x, int y) {
fontRenderer.drawString(getLine(), x, y, color, isShadowed());
}
public void draw(FontRenderer fontRenderer, int x, int y) {
fontRenderer.drawString(getLine(), x, y, color, isShadowed());
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ToolTipLine that = (ToolTipLine) o;
return color == that.color &&
shadowed == that.shadowed &&
line.equals(that.line);
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
ToolTipLine that = (ToolTipLine) o;
return color == that.color &&
shadowed == that.shadowed &&
line.equals(that.line);
}
}
@Override
public int hashCode() {
int result = line.hashCode();
result = 31 * result + color;
result = 31 * result + (shadowed ? 1 : 0);
return result;
}
@Override
public int hashCode() {
int result = line.hashCode();
result = 31 * result + color;
result = 31 * result + (shadowed ? 1 : 0);
return result;
}
}