aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/thatgravyboat/skyblockhud/core
diff options
context:
space:
mode:
authorThatGravyBoat <ThatGravyBoat@users.noreply.github.com>2021-07-15 04:07:36 +0000
committerGitHub Action <actions@github.com>2021-07-15 04:07:36 +0000
commit4e4058da31c3575b69c69d2d7bb3c9af29e248dc (patch)
treed46d48754f080386e23bb86e884580fed0f555f3 /src/main/java/com/thatgravyboat/skyblockhud/core
parent718740e85f48b57bf712a62f811cd4d34dd98450 (diff)
downloadskyblockhud-4e4058da31c3575b69c69d2d7bb3c9af29e248dc.tar.gz
skyblockhud-4e4058da31c3575b69c69d2d7bb3c9af29e248dc.tar.bz2
skyblockhud-4e4058da31c3575b69c69d2d7bb3c9af29e248dc.zip
Prettified Code!
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/core')
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java58
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java20
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java23
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java4
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java44
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java237
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementTextField.java336
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/Config.java4
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/KeybindHelper.java25
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/annotations/ConfigEditorKeybind.java2
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditor.java22
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorAccordion.java20
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorBoolean.java11
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorButton.java19
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorColour.java36
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDraggableList.java148
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorDropdown.java79
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorKeybind.java31
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorSlider.java97
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiOptionEditorText.java34
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/gui/GuiPositionEditor.java55
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/config/struct/ConfigProcessor.java89
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/GuiElementSlider.java58
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/StringUtils.java1
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpUtils.java11
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingFloat.java16
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/lerp/LerpingInteger.java16
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/core/util/render/TextRenderUtils.java20
28 files changed, 696 insertions, 820 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java
index f143b97..64f04fe 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java
@@ -23,6 +23,7 @@ import org.lwjgl.opengl.GL30;
public class BackgroundBlur {
private static class OutputStuff {
+
public Framebuffer framebuffer;
public Shader blurShaderHorz = null;
public Shader blurShaderVert = null;
@@ -41,8 +42,9 @@ public class BackgroundBlur {
private static int fogColour = 0;
private static boolean registered = false;
+
public static void registerListener() {
- if(!registered) {
+ if (!registered) {
registered = true;
MinecraftForge.EVENT_BUS.register(new BackgroundBlur());
}
@@ -69,18 +71,21 @@ public class BackgroundBlur {
int width = Minecraft.getMinecraft().displayWidth;
int height = Minecraft.getMinecraft().displayHeight;
- OutputStuff output = blurOutput.computeIfAbsent(blur, k -> {
- Framebuffer fb = new Framebuffer(width, height, false);
- fb.setFramebufferFilter(GL11.GL_NEAREST);
- return new OutputStuff(fb, null, null);
- });
+ OutputStuff output = blurOutput.computeIfAbsent(
+ blur,
+ k -> {
+ Framebuffer fb = new Framebuffer(width, height, false);
+ fb.setFramebufferFilter(GL11.GL_NEAREST);
+ return new OutputStuff(fb, null, null);
+ }
+ );
- if(output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) {
+ if (output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) {
output.framebuffer.createBindFramebuffer(width, height);
- if(output.blurShaderHorz != null) {
+ if (output.blurShaderHorz != null) {
output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
}
- if(output.blurShaderVert != null) {
+ if (output.blurShaderVert != null) {
output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
}
}
@@ -105,7 +110,7 @@ public class BackgroundBlur {
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onScreenRender(RenderGameOverlayEvent.Pre event) {
- if(event.type == RenderGameOverlayEvent.ElementType.ALL) {
+ if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
processBlurs();
}
}
@@ -141,7 +146,7 @@ public class BackgroundBlur {
}
private static void blurBackground(OutputStuff output, float blurFactor) {
- if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
+ if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return;
int width = Minecraft.getMinecraft().displayWidth;
int height = Minecraft.getMinecraft().displayHeight;
@@ -153,36 +158,34 @@ public class BackgroundBlur {
GlStateManager.loadIdentity();
GlStateManager.translate(0.0F, 0.0F, -2000.0F);
- if(blurOutputHorz == null) {
+ if (blurOutputHorz == null) {
blurOutputHorz = new Framebuffer(width, height, false);
blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST);
}
- if(blurOutputHorz == null || output == null) {
+ if (blurOutputHorz == null || output == null) {
return;
}
- if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
+ if (blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) {
blurOutputHorz.createBindFramebuffer(width, height);
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
}
- if(output.blurShaderHorz == null) {
+ if (output.blurShaderHorz == null) {
try {
- output.blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- output.framebuffer, blurOutputHorz);
+ output.blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", output.framebuffer, blurOutputHorz);
output.blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0);
output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception ignored) { }
+ } catch (Exception ignored) {}
}
- if(output.blurShaderVert == null) {
+ if (output.blurShaderVert == null) {
try {
- output.blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur",
- blurOutputHorz, output.framebuffer);
+ output.blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", blurOutputHorz, output.framebuffer);
output.blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1);
output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height));
- } catch(Exception ignored) { }
+ } catch (Exception ignored) {}
}
- if(output.blurShaderHorz != null && output.blurShaderVert != null) {
- if(output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
+ if (output.blurShaderHorz != null && output.blurShaderVert != null) {
+ if (output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) {
//Corrupted shader?
return;
}
@@ -193,9 +196,7 @@ public class BackgroundBlur {
GL11.glPushMatrix();
GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject);
GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebuffer.framebufferObject);
- GL30.glBlitFramebuffer(0, 0, width, height,
- 0, 0, output.framebuffer.framebufferWidth, output.framebuffer.framebufferHeight,
- GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);
+ GL30.glBlitFramebuffer(0, 0, width, height, 0, 0, output.framebuffer.framebufferWidth, output.framebuffer.framebufferHeight, GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);
output.blurShaderHorz.loadShader(0);
output.blurShaderVert.loadShader(0);
@@ -228,7 +229,7 @@ public class BackgroundBlur {
if (blurOutput.isEmpty()) return;
OutputStuff out = blurOutput.get(blurStrength);
- if(out == null) {
+ if (out == null) {
out = blurOutput.values().iterator().next();
}
@@ -245,5 +246,4 @@ public class BackgroundBlur {
out.framebuffer.unbindFramebufferTexture();
GlStateManager.depthMask(true);
}
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java
index b9f4e79..d43e8b9 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java
@@ -25,9 +25,8 @@ public class ChromaColour {
int[] arr = new int[split.length];
-
- for(int i=0; i<split.length; i++) {
- arr[i] = Integer.parseInt(split[split.length-1-i], RADIX);
+ for (int i = 0; i < split.length; i++) {
+ arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX);
}
return arr;
}
@@ -48,15 +47,16 @@ public class ChromaColour {
}
public static float getSecondsForSpeed(int speed) {
- return (255-speed)/254f*(MAX_CHROMA_SECS-MIN_CHROMA_SECS)+MIN_CHROMA_SECS;
+ return (255 - speed) / 254f * (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + MIN_CHROMA_SECS;
}
private static final int MIN_CHROMA_SECS = 1;
private static final int MAX_CHROMA_SECS = 60;
public static long startTime = -1;
+
public static int specialToChromaRGB(String special) {
- if(startTime < 0) startTime = System.currentTimeMillis();
+ if (startTime < 0) startTime = System.currentTimeMillis();
int[] d = decompose(special);
int chr = d[4];
@@ -67,11 +67,11 @@ public class ChromaColour {
float[] hsv = Color.RGBtoHSB(r, g, b, null);
- if(chr > 0) {
+ if (chr > 0) {
float seconds = getSecondsForSpeed(chr);
- hsv[0] += (System.currentTimeMillis()-startTime)/1000f/seconds;
+ hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds;
hsv[0] %= 1;
- if(hsv[0] < 0) hsv[0] += 1;
+ if (hsv[0] < 0) hsv[0] += 1;
}
return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
@@ -85,11 +85,9 @@ public class ChromaColour {
float[] hsv = Color.RGBtoHSB(r, g, b, null);
- hsv[0] += degrees/360f;
+ hsv[0] += degrees / 360f;
hsv[0] %= 1;
return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF);
}
-
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java
index 6f21e9a..0e1694e 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java
@@ -1,14 +1,14 @@
package com.thatgravyboat.skyblockhud.core;
+import java.util.LinkedList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import org.lwjgl.opengl.GL11;
-import java.util.LinkedList;
-
public class GlScissorStack {
private static class Bounds {
+
int left;
int top;
int right;
@@ -27,10 +27,10 @@ public class GlScissorStack {
right = Math.min(right, this.right);
bottom = Math.min(bottom, this.bottom);
- if(top > bottom) {
+ if (top > bottom) {
top = bottom;
}
- if(left > right) {
+ if (left > right) {
left = right;
}
@@ -40,39 +40,39 @@ public class GlScissorStack {
public void set(ScaledResolution scaledResolution) {
int height = Minecraft.getMinecraft().displayHeight;
int scale = scaledResolution.getScaleFactor();
- GL11.glScissor(left*scale, height-bottom*scale, (right-left)*scale, (bottom-top)*scale);
+ GL11.glScissor(left * scale, height - bottom * scale, (right - left) * scale, (bottom - top) * scale);
}
}
private static final LinkedList<Bounds> boundsStack = new LinkedList<>();
public static void push(int left, int top, int right, int bottom, ScaledResolution scaledResolution) {
- if(right < left) {
+ if (right < left) {
int temp = right;
right = left;
left = temp;
}
- if(bottom < top) {
+ if (bottom < top) {
int temp = bottom;
bottom = top;
top = temp;
}
- if(boundsStack.isEmpty()) {
+ if (boundsStack.isEmpty()) {
boundsStack.push(new Bounds(left, top, right, bottom));
} else {
boundsStack.push(boundsStack.peek().createSubBound(left, top, right, bottom));
}
- if(!boundsStack.isEmpty()) {
+ if (!boundsStack.isEmpty()) {
boundsStack.peek().set(scaledResolution);
}
GL11.glEnable(GL11.GL_SCISSOR_TEST);
}
public static void pop(ScaledResolution scaledResolution) {
- if(!boundsStack.isEmpty()) {
+ if (!boundsStack.isEmpty()) {
boundsStack.pop();
}
- if(boundsStack.isEmpty()) {
+ if (boundsStack.isEmpty()) {
GL11.glDisable(GL11.GL_SCISSOR_TEST);
} else {
boundsStack.peek().set(scaledResolution);
@@ -83,5 +83,4 @@ public class GlScissorStack {
boundsStack.clear();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
-
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java
index ff817cf..e8d9d62 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java
@@ -2,9 +2,11 @@ package com.thatgravyboat.skyblockhud.core;
import net.minecraft.client.gui.Gui;
-public abstract class GuiElement extends Gui {
+public abstract class GuiElement extends Gui {
public abstract void render();
+
public abstract boolean mouseInput(int mouseX, int mouseY);
+
public abstract boolean keyboardInput();
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java
index 7c401ed..8daf4b1 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java
@@ -37,7 +37,7 @@ public class GuiElementBoolean extends GuiElement {
this.toggleCallback = toggleCallback;
this.lastMillis = System.currentTimeMillis();
- if(value) animation = 36;
+ if (value) animation = 36;
}
@Override
@@ -51,58 +51,56 @@ public class GuiElementBoolean extends GuiElement {
long deltaMillis = currentMillis - lastMillis;
lastMillis = currentMillis;
boolean passedLimit = false;
- if(previewValue != value) {
- if((previewValue && animation > 12) ||
- (!previewValue && animation < 24)) {
+ if (previewValue != value) {
+ if ((previewValue && animation > 12) || (!previewValue && animation < 24)) {
passedLimit = true;
}
}
- if(previewValue != passedLimit) {
- animation += deltaMillis/10;
+ if (previewValue != passedLimit) {
+ animation += deltaMillis / 10;
} else {
- animation -= deltaMillis/10;
+ animation -= deltaMillis / 10;
}
- lastMillis -= deltaMillis%10;
+ lastMillis -= deltaMillis % 10;
- if(previewValue == value) {
+ if (previewValue == value) {
animation = Math.max(0, Math.min(36, animation));
- } else if(!passedLimit) {
- if(previewValue) {
+ } else if (!passedLimit) {
+ if (previewValue) {
animation = Math.max(0, Math.min(12, animation));
} else {
animation = Math.max(24, Math.min(36, animation));
}
} else {
- if(previewValue) {
+ if (previewValue) {
animation = Math.max(12, animation);
} else {
animation = Math.min(24, animation);
}
}
- int animation = (int)(LerpUtils.sigmoidZeroOne(this.animation/36f)*36);
- if(animation < 3) {
+ int animation = (int) (LerpUtils.sigmoidZeroOne(this.animation / 36f) * 36);
+ if (animation < 3) {
buttonLoc = GuiTextures.OFF;
- } else if(animation < 13) {
+ } else if (animation < 13) {
buttonLoc = GuiTextures.ONE;
- } else if(animation < 23) {
+ } else if (animation < 23) {
buttonLoc = GuiTextures.TWO;
- } else if(animation < 33) {
+ } else if (animation < 33) {
buttonLoc = GuiTextures.THREE;
}
Minecraft.getMinecraft().getTextureManager().bindTexture(buttonLoc);
- RenderUtils.drawTexturedRect(x+animation, y, 12, 14);
+ RenderUtils.drawTexturedRect(x + animation, y, 12, 14);
}
@Override
public boolean mouseInput(int mouseX, int mouseY) {
- if(mouseX > x-clickRadius && mouseX < x+xSize+clickRadius &&
- mouseY > y-clickRadius && mouseY < y+ySize+clickRadius) {
- if(Mouse.getEventButton() == 0) {
- if(Mouse.getEventButtonState()) {
+ if (mouseX > x - clickRadius && mouseX < x + xSize + clickRadius && mouseY > y - clickRadius && mouseY < y + ySize + clickRadius) {
+ if (Mouse.getEventButton() == 0) {
+ if (Mouse.getEventButtonState()) {
previewValue = !value;
- } else if(previewValue == !value) {
+ } else if (previewValue == !value) {
value = !value;
toggleCallback.accept(value);
}
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java
index e2d3e0a..27a1d84 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java
@@ -45,17 +45,15 @@ public class GuiElementColour extends GuiElement {
private final boolean opacitySlider;
private final boolean valueSlider;
- public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback,
- Runnable closeCallback) {
+ public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback, Runnable closeCallback) {
this(x, y, initialColour, colourChangedCallback, closeCallback, true, true);
}
- public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback,
- Runnable closeCallback, boolean opacitySlider, boolean valueSlider) {
+ public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback, Runnable closeCallback, boolean opacitySlider, boolean valueSlider) {
final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- this.y = Math.max(10, Math.min(scaledResolution.getScaledHeight()-ySize-10, y));
- this.x = Math.max(10, Math.min(scaledResolution.getScaledWidth()-xSize-10, x));
+ this.y = Math.max(10, Math.min(scaledResolution.getScaledHeight() - ySize - 10, y));
+ this.x = Math.max(10, Math.min(scaledResolution.getScaledWidth() - xSize - 10, x));
this.colour = initialColour;
this.colourChangedCallback = colourChangedCallback;
@@ -69,13 +67,13 @@ public class GuiElementColour extends GuiElement {
this.opacitySlider = opacitySlider;
this.valueSlider = valueSlider;
- if(!valueSlider) xSize -= 15;
- if(!opacitySlider) xSize -= 15;
+ if (!valueSlider) xSize -= 15;
+ if (!opacitySlider) xSize -= 15;
}
public void updateAngleAndRadius(float[] hsv) {
this.wheelRadius = hsv[1];
- this.wheelAngle = hsv[0]*360;
+ this.wheelAngle = hsv[0] * 360;
}
public void render() {
@@ -87,79 +85,76 @@ public class GuiElementColour extends GuiElement {
BufferedImage bufferedImage = new BufferedImage(288, 288, BufferedImage.TYPE_INT_ARGB);
float borderRadius = 0.05f;
- if(Keyboard.isKeyDown(Keyboard.KEY_N)) borderRadius = 0;
- for(int x=-16; x<272; x++) {
- for(int y=-16; y<272; y++) {
- float radius = (float) Math.sqrt(((x-128)*(x-128)+(y-128)*(y-128))/16384f);
- float angle = (float) Math.toDegrees(Math.atan((128-x)/(y-128+1E-5))+Math.PI/2);
- if(y < 128) angle += 180;
- if(radius <= 1) {
- int rgb = Color.getHSBColor(angle/360f, (float)Math.pow(radius, 1.5f), hsv[2]).getRGB();
- bufferedImage.setRGB(x+16, y+16, rgb);
- } else if(radius <= 1+borderRadius) {
- float invBlackAlpha = Math.abs(radius-1-borderRadius/2)/borderRadius*2;
- float blackAlpha = 1-invBlackAlpha;
-
- if(radius > 1+borderRadius/2) {
- bufferedImage.setRGB(x+16, y+16, (int)(blackAlpha*255) << 24);
+ if (Keyboard.isKeyDown(Keyboard.KEY_N)) borderRadius = 0;
+ for (int x = -16; x < 272; x++) {
+ for (int y = -16; y < 272; y++) {
+ float radius = (float) Math.sqrt(((x - 128) * (x - 128) + (y - 128) * (y - 128)) / 16384f);
+ float angle = (float) Math.toDegrees(Math.atan((128 - x) / (y - 128 + 1E-5)) + Math.PI / 2);
+ if (y < 128) angle += 180;
+ if (radius <= 1) {
+ int rgb = Color.getHSBColor(angle / 360f, (float) Math.pow(radius, 1.5f), hsv[2]).getRGB();
+ bufferedImage.setRGB(x + 16, y + 16, rgb);
+ } else if (radius <= 1 + borderRadius) {
+ float invBlackAlpha = Math.abs(radius - 1 - borderRadius / 2) / borderRadius * 2;
+ float blackAlpha = 1 - invBlackAlpha;
+
+ if (radius > 1 + borderRadius / 2) {
+ bufferedImage.setRGB(x + 16, y + 16, (int) (blackAlpha * 255) << 24);
} else {
- Color col = Color.getHSBColor(angle/360f, 1, hsv[2]);
- int rgb = (int)(col.getRed()*invBlackAlpha) << 16 |
- (int)(col.getGreen()*invBlackAlpha) << 8 |
- (int)(col.getBlue()*invBlackAlpha);
- bufferedImage.setRGB(x+16, y+16, 0xff000000 | rgb);
+ Color col = Color.getHSBColor(angle / 360f, 1, hsv[2]);
+ int rgb = (int) (col.getRed() * invBlackAlpha) << 16 | (int) (col.getGreen() * invBlackAlpha) << 8 | (int) (col.getBlue() * invBlackAlpha);
+ bufferedImage.setRGB(x + 16, y + 16, 0xff000000 | rgb);
}
-
}
}
}
BufferedImage bufferedImageValue = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB);
- for(int x=0; x<10; x++) {
- for(int y=0; y<64; y++) {
- if((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
+ for (int x = 0; x < 10; x++) {
+ for (int y = 0; y < 64; y++) {
+ if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
- int rgb = Color.getHSBColor(wheelAngle/360, wheelRadius, (64-y)/64f).getRGB();
+ int rgb = Color.getHSBColor(wheelAngle / 360, wheelRadius, (64 - y) / 64f).getRGB();
bufferedImageValue.setRGB(x, y, rgb);
}
}
BufferedImage bufferedImageOpacity = new BufferedImage(10, 64, BufferedImage.TYPE_INT_ARGB);
- for(int x=0; x<10; x++) {
- for(int y=0; y<64; y++) {
- if((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
+ for (int x = 0; x < 10; x++) {
+ for (int y = 0; y < 64; y++) {
+ if ((x == 0 || x == 9) && (y == 0 || y == 63)) continue;
- int rgb = (currentColour & 0x00FFFFFF) | (Math.min(255, (64-y)*4) << 24);
+ int rgb = (currentColour & 0x00FFFFFF) | (Math.min(255, (64 - y) * 4) << 24);
bufferedImageOpacity.setRGB(x, y, rgb);
}
}
- float selradius = (float)Math.pow(wheelRadius, 1/1.5f)*32;
- int selx = (int)(Math.cos(Math.toRadians(wheelAngle))*selradius);
- int sely = (int)(Math.sin(Math.toRadians(wheelAngle))*selradius);
+ float selradius = (float) Math.pow(wheelRadius, 1 / 1.5f) * 32;
+ int selx = (int) (Math.cos(Math.toRadians(wheelAngle)) * selradius);
+ int sely = (int) (Math.sin(Math.toRadians(wheelAngle)) * selradius);
int valueOffset = 0;
- if(valueSlider) {
+ if (valueSlider) {
valueOffset = 15;
Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarValueLocation, new DynamicTexture(bufferedImageValue));
Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarValueLocation);
GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+5+64+5, y+5, 10, 64, GL11.GL_NEAREST);
+ RenderUtils.drawTexturedRect(x + 5 + 64 + 5, y + 5, 10, 64, GL11.GL_NEAREST);
}
int opacityOffset = 0;
- if(opacitySlider) {
+ if (opacitySlider) {
opacityOffset = 15;
Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar_alpha);
GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+5+64+5+valueOffset, y+5, 10, 64, GL11.GL_NEAREST);
-
+ RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + valueOffset, y + 5, 10, 64, GL11.GL_NEAREST);
+
Minecraft.getMinecraft().getTextureManager().loadTexture(colourPickerBarOpacityLocation, new DynamicTexture(bufferedImageOpacity));
Minecraft.getMinecraft().getTextureManager().bindTexture(colourPickerBarOpacityLocation);
GlStateManager.color(1, 1, 1, 1);
- RenderUtils.drawTexturedRect(x+5+64+5+valueOffset, y+5, 10, 64, GL11.GL_NEAREST);
+ RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + valueOffset, y + 5, 10, 64, GL11.GL_NEAREST);
}
int chromaSpeed = ChromaColour.getSpeed(colour);
@@ -167,139 +162,120 @@ public class GuiElementColour extends GuiElement {
Color cChroma = new Color(currentColourChroma, true);
float hsvChroma[] = Color.RGBtoHSB(cChroma.getRed(), cChroma.getGreen(), cChroma.getBlue(), null);
- if(chromaSpeed > 0) {
- Gui.drawRect(x+5+64+valueOffset+opacityOffset+5+1, y+5+1,
- x+5+64+valueOffset+opacityOffset+5+10-1, y+5+64-1,
- Color.HSBtoRGB(hsvChroma[0], 0.8f, 0.8f));
+ if (chromaSpeed > 0) {
+ Gui.drawRect(x + 5 + 64 + valueOffset + opacityOffset + 5 + 1, y + 5 + 1, x + 5 + 64 + valueOffset + opacityOffset + 5 + 10 - 1, y + 5 + 64 - 1, Color.HSBtoRGB(hsvChroma[0], 0.8f, 0.8f));
} else {
- Gui.drawRect(x+5+64+valueOffset+opacityOffset+5+1, y+5+27+1,
- x+5+64+valueOffset+opacityOffset+5+10-1, y+5+37-1,
- Color.HSBtoRGB((hsvChroma[0]+(System.currentTimeMillis()-ChromaColour.startTime)/1000f)%1, 0.8f, 0.8f));
+ Gui.drawRect(x + 5 + 64 + valueOffset + opacityOffset + 5 + 1, y + 5 + 27 + 1, x + 5 + 64 + valueOffset + opacityOffset + 5 + 10 - 1, y + 5 + 37 - 1, Color.HSBtoRGB((hsvChroma[0] + (System.currentTimeMillis() - ChromaColour.startTime) / 1000f) % 1, 0.8f, 0.8f));
}
Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_bar);
GlStateManager.color(1, 1, 1, 1);
- if(valueSlider) RenderUtils.drawTexturedRect(x+5+64+5, y+5, 10, 64, GL11.GL_NEAREST);
- if(opacitySlider) RenderUtils.drawTexturedRect(x+5+64+5+valueOffset, y+5, 10, 64, GL11.GL_NEAREST);
+ if (valueSlider) RenderUtils.drawTexturedRect(x + 5 + 64 + 5, y + 5, 10, 64, GL11.GL_NEAREST);
+ if (opacitySlider) RenderUtils.drawTexturedRect(x + 5 + 64 + 5 + valueOffset, y + 5, 10, 64, GL11.GL_NEAREST);
- if(chromaSpeed > 0) {
- RenderUtils.drawTexturedRect(x+5+64+valueOffset+opacityOffset+5, y+5, 10, 64, GL11.GL_NEAREST);
+ if (chromaSpeed > 0) {
+ RenderUtils.drawTexturedRect(x + 5 + 64 + valueOffset + opacityOffset + 5, y + 5, 10, 64, GL11.GL_NEAREST);
} else {
Minecraft.getMinecraft().getTextureManager().bindTexture(colour_selector_chroma);
- RenderU