mirror of
https://github.com/GTNewHorizons/CodeChickenCore.git
synced 2026-11-16 01:54:50 +00:00
Apply spotless
This commit is contained in:
1 parent
8d95baccb5
commit
fa6fea6843
111 files changed
+3418
-4352
No files matched your search
@@ -6,8 +6,7 @@ import codechicken.lib.render.TextureUtils;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class Canvas9Seg
|
||||
{
|
||||
public class Canvas9Seg {
|
||||
public final ResourceLocation tex;
|
||||
public float[] seg_u = new float[4];
|
||||
public float[] seg_v = new float[4];
|
||||
@@ -24,12 +23,11 @@ public class Canvas9Seg
|
||||
|
||||
int marker = 1;
|
||||
int prev_col = data.data[0];
|
||||
for(int i = 1; i < size; i++) {
|
||||
if(data.data[i*stride] != prev_col) {
|
||||
for (int i = 1; i < size; i++) {
|
||||
if (data.data[i * stride] != prev_col) {
|
||||
markers[marker] = i;
|
||||
prev_col = data.data[i*stride];
|
||||
if(++marker == 4)
|
||||
break;
|
||||
prev_col = data.data[i * stride];
|
||||
if (++marker == 4) break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,10 +38,9 @@ public class Canvas9Seg
|
||||
|
||||
private void parseMarkers(TextureDataHolder data, int stride, int size, int[] sizes, float[] texcoords) {
|
||||
int[] markers = readMarkers(data, stride, size);
|
||||
for(int i = 0; i < 4; i++) {
|
||||
texcoords[i] = markers[i]/(float)size;
|
||||
if(i > 0)
|
||||
sizes[i-1] = markers[i]-markers[i-1];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
texcoords[i] = markers[i] / (float) size;
|
||||
if (i > 0) sizes[i - 1] = markers[i] - markers[i - 1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,11 +52,12 @@ public class Canvas9Seg
|
||||
|
||||
private void drawSeg(int[] sw, int[] sh, int seg) {
|
||||
Tessellator t = Tessellator.instance;
|
||||
int u = seg%3; int v = seg/3;
|
||||
int u = seg % 3;
|
||||
int v = seg / 3;
|
||||
t.addVertexWithUV(sw[u], sh[v], 0, seg_u[u], seg_v[v]);
|
||||
t.addVertexWithUV(sw[u], sh[v+1], 0, seg_u[u], seg_v[v+1]);
|
||||
t.addVertexWithUV(sw[u+1], sh[v+1], 0, seg_u[u+1], seg_v[v+1]);
|
||||
t.addVertexWithUV(sw[u+1], sh[v], 0, seg_u[u+1], seg_v[v]);
|
||||
t.addVertexWithUV(sw[u], sh[v + 1], 0, seg_u[u], seg_v[v + 1]);
|
||||
t.addVertexWithUV(sw[u + 1], sh[v + 1], 0, seg_u[u + 1], seg_v[v + 1]);
|
||||
t.addVertexWithUV(sw[u + 1], sh[v], 0, seg_u[u + 1], seg_v[v]);
|
||||
}
|
||||
|
||||
public void draw(int x, int y, int w, int h) {
|
||||
@@ -67,11 +65,10 @@ public class Canvas9Seg
|
||||
CCRenderState.reset();
|
||||
CCRenderState.startDrawing();
|
||||
|
||||
int[] sw = new int[]{x, x+seg_w[0], x+w-seg_w[2], x+w};
|
||||
int[] sh = new int[]{y, y+seg_h[0], y+h-seg_h[2], y+h};
|
||||
int[] sw = new int[] {x, x + seg_w[0], x + w - seg_w[2], x + w};
|
||||
int[] sh = new int[] {y, y + seg_h[0], y + h - seg_h[2], y + h};
|
||||
|
||||
for(int seg = 0; seg < 9; seg++)
|
||||
drawSeg(sw, sh, seg);
|
||||
for (int seg = 0; seg < 9; seg++) drawSeg(sw, sh, seg);
|
||||
|
||||
CCRenderState.draw();
|
||||
}
|
||||
|
||||
@@ -2,27 +2,23 @@ package codechicken.lib.gui;
|
||||
|
||||
import codechicken.lib.math.MathHelper;
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiDraw
|
||||
{
|
||||
public static class GuiHook extends Gui
|
||||
{
|
||||
public class GuiDraw {
|
||||
public static class GuiHook extends Gui {
|
||||
public void setZLevel(float f) {
|
||||
zLevel = f;
|
||||
}
|
||||
@@ -58,10 +54,8 @@ public class GuiDraw
|
||||
}
|
||||
|
||||
public static void drawString(String text, int x, int y, int colour, boolean shadow) {
|
||||
if (shadow)
|
||||
fontRenderer.drawStringWithShadow(text, x, y, colour);
|
||||
else
|
||||
fontRenderer.drawString(text, x, y, colour);
|
||||
if (shadow) fontRenderer.drawStringWithShadow(text, x, y, colour);
|
||||
else fontRenderer.drawString(text, x, y, colour);
|
||||
}
|
||||
|
||||
public static void drawString(String text, int x, int y, int colour) {
|
||||
@@ -137,10 +131,10 @@ public class GuiDraw
|
||||
* Have a string in the tooltip list with TOOLTIP_HANDLER + getTipLineId(handler) for a custom handler
|
||||
*/
|
||||
public static final String TOOLTIP_HANDLER = "\u00A7x";
|
||||
|
||||
private static List<ITooltipLineHandler> tipLineHandlers = new ArrayList<ITooltipLineHandler>();
|
||||
|
||||
public static interface ITooltipLineHandler
|
||||
{
|
||||
public static interface ITooltipLineHandler {
|
||||
public Dimension getSize();
|
||||
|
||||
public void draw(int x, int y);
|
||||
@@ -148,12 +142,11 @@ public class GuiDraw
|
||||
|
||||
public static int getTipLineId(ITooltipLineHandler handler) {
|
||||
tipLineHandlers.add(handler);
|
||||
return tipLineHandlers.size()-1;
|
||||
return tipLineHandlers.size() - 1;
|
||||
}
|
||||
|
||||
public static ITooltipLineHandler getTipLine(String line) {
|
||||
if(!line.startsWith(TOOLTIP_HANDLER))
|
||||
return null;
|
||||
if (!line.startsWith(TOOLTIP_HANDLER)) return null;
|
||||
return tipLineHandlers.get(Integer.parseInt(line.substring(2)));
|
||||
}
|
||||
|
||||
@@ -162,8 +155,7 @@ public class GuiDraw
|
||||
}
|
||||
|
||||
public static void drawMultilineTip(FontRenderer font, int x, int y, List<String> list) {
|
||||
if (list.isEmpty())
|
||||
return;
|
||||
if (list.isEmpty()) return;
|
||||
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
@@ -174,17 +166,19 @@ public class GuiDraw
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
String s = list.get(i);
|
||||
ITooltipLineHandler line = getTipLine(s);
|
||||
Dimension d = line != null ?
|
||||
line.getSize() :
|
||||
new Dimension(font.getStringWidth(s), list.get(i).endsWith(TOOLTIP_LINESPACE) && i + 1 < list.size() ? 12 : 10);
|
||||
Dimension d = line != null
|
||||
? line.getSize()
|
||||
: new Dimension(
|
||||
font.getStringWidth(s),
|
||||
list.get(i).endsWith(TOOLTIP_LINESPACE) && i + 1 < list.size() ? 12 : 10);
|
||||
w = Math.max(w, d.width);
|
||||
h += d.height;
|
||||
}
|
||||
|
||||
if (x < 8) x = 8;
|
||||
else if (x > displaySize().width - w - 8) {
|
||||
x -= 24 + w;//flip side of cursor
|
||||
if(x < 8) x = 8;
|
||||
x -= 24 + w; // flip side of cursor
|
||||
if (x < 8) x = 8;
|
||||
}
|
||||
y = (int) MathHelper.clip(y, 8, displaySize().height - 8 - h);
|
||||
|
||||
@@ -192,11 +186,10 @@ public class GuiDraw
|
||||
drawTooltipBox(x - 4, y - 4, w + 7, h + 7);
|
||||
for (String s : list) {
|
||||
ITooltipLineHandler line = getTipLine(s);
|
||||
if(line != null) {
|
||||
if (line != null) {
|
||||
line.draw(x, y);
|
||||
y += line.getSize().height;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
font.drawStringWithShadow(s, x, y, -1);
|
||||
y += s.endsWith(TOOLTIP_LINESPACE) ? 12 : 10;
|
||||
}
|
||||
@@ -214,7 +207,7 @@ public class GuiDraw
|
||||
int bg = 0xf0100010;
|
||||
drawGradientRect(x + 1, y, w - 1, 1, bg, bg);
|
||||
drawGradientRect(x + 1, y + h, w - 1, 1, bg, bg);
|
||||
drawGradientRect(x + 1, y + 1, w - 1, h - 1, bg, bg);//center
|
||||
drawGradientRect(x + 1, y + 1, w - 1, h - 1, bg, bg); // center
|
||||
drawGradientRect(x, y + 1, 1, h - 1, bg, bg);
|
||||
drawGradientRect(x + w, y + 1, 1, h - 1, bg, bg);
|
||||
int grad1 = 0x505000ff;
|
||||
|
||||
Reference in new issue
Block a user