Skip to content

Commit 6aa2fdd

Browse files
committed
fix: Chroma color not displayed properly on Color SelectionGui's Selected Color box
remove: unused EnumRegistries
1 parent 91a877c commit 6aa2fdd

File tree

7 files changed

+35
-33
lines changed

7 files changed

+35
-33
lines changed

src/main/java/codes/biscuit/skyblockaddons/gui/buttons/ButtonColorBox.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import codes.biscuit.skyblockaddons.core.chroma.MulticolorShaderManager;
44
import codes.biscuit.skyblockaddons.core.chroma.ManualChromaManager;
5+
import codes.biscuit.skyblockaddons.core.feature.Feature;
56
import codes.biscuit.skyblockaddons.shader.ShaderManager;
67
import codes.biscuit.skyblockaddons.shader.chroma.ChromaScreenShader;
78
import codes.biscuit.skyblockaddons.utils.ColorCode;
89
import codes.biscuit.skyblockaddons.utils.ColorUtils;
10+
import codes.biscuit.skyblockaddons.utils.EnumUtils.ChromaMode;
911
import lombok.Getter;
1012
import net.minecraft.client.Minecraft;
1113
import net.minecraft.client.renderer.GlStateManager;
@@ -51,6 +53,24 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY) {
5153
}
5254
}
5355

56+
public static void drawColorRect(int left, int top, int right, int bottom, int color) {
57+
boolean isChromaColor = color == ColorCode.CHROMA.getColor(ColorUtils.getAlpha(color));
58+
59+
GlStateManager.enableBlend();
60+
if (isChromaColor) {
61+
if (MulticolorShaderManager.getInstance().shouldUseChromaShaders() && Feature.CHROMA_MODE.getValue() == ChromaMode.FADE) {
62+
ShaderManager.getInstance().enableShader(ChromaScreenShader.class);
63+
drawRect(left, top, right, bottom, color);
64+
ShaderManager.getInstance().disableShader();
65+
} else {
66+
drawChromaRect(left, top, right, bottom, ColorUtils.getAlpha(color));
67+
}
68+
} else {
69+
drawRect(left, top, right, bottom, color);
70+
}
71+
GlStateManager.disableBlend();
72+
}
73+
5474
public static void drawChromaRect(int left, int top, int right, int bottom, int alpha) {
5575
if (left < right) {
5676
int i = left;

src/main/java/codes/biscuit/skyblockaddons/gui/buttons/ButtonStepper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY) {
6868
startX = xPosition + width - height;
6969
}
7070
//noinspection SuspiciousNameCombination
71-
drawButtonBoxAndText(modifier.displayString, startX, yPosition, height, height, boxColor, boxAlpha, 1F, fontColor);
71+
drawButtonBoxAndText(modifier.displayString, startX, yPosition, height, height, boxColor, 1F, fontColor);
7272
}
7373

7474
boxColor = main.getUtils().getDefaultColor(100);
7575
int stringWidth = mc.fontRendererObj.getStringWidth(displayString);
7676
int textBoxWidth = width - 2 * (SPACER + height);
7777
float scale = stringWidth > WIDTH_LIMIT ? 1F / (stringWidth / WIDTH_LIMIT) : 1F;
78-
drawButtonBoxAndText(displayString, xPosition + height + SPACER, yPosition, textBoxWidth, height, boxColor, 100, scale, ColorCode.WHITE.getColor());
78+
drawButtonBoxAndText(displayString, xPosition + height + SPACER, yPosition, textBoxWidth, height, boxColor, scale, ColorCode.WHITE.getColor());
7979
GlStateManager.disableBlend();
8080
}
8181

src/main/java/codes/biscuit/skyblockaddons/gui/buttons/SkyblockAddonsButton.java

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
package codes.biscuit.skyblockaddons.gui.buttons;
22

33
import codes.biscuit.skyblockaddons.SkyblockAddons;
4-
import codes.biscuit.skyblockaddons.core.chroma.MulticolorShaderManager;
5-
import codes.biscuit.skyblockaddons.core.feature.Feature;
6-
import codes.biscuit.skyblockaddons.shader.ShaderManager;
7-
import codes.biscuit.skyblockaddons.shader.chroma.ChromaScreenShader;
8-
import codes.biscuit.skyblockaddons.utils.ColorCode;
94
import codes.biscuit.skyblockaddons.utils.DrawUtils;
10-
import codes.biscuit.skyblockaddons.utils.EnumUtils;
115
import net.minecraft.client.gui.GuiButton;
126
import net.minecraft.client.renderer.GlStateManager;
137

@@ -49,24 +43,12 @@ public float calculateAlphaMultiplier() {
4943
return 1.0F;
5044
}
5145

52-
public void drawButtonBoxAndText(int boxColor, int alpha, float scale, int fontColor) {
53-
drawButtonBoxAndText(displayString, xPosition, yPosition, width, height, boxColor, alpha, scale, fontColor);
46+
public void drawButtonBoxAndText(int boxColor, float scale, int fontColor) {
47+
drawButtonBoxAndText(displayString, xPosition, yPosition, width, height, boxColor, scale, fontColor);
5448
}
5549

56-
public void drawButtonBoxAndText(String displayString, int x, int y, int width, int height, int boxColor, int alpha, float scale, int fontColor) {
57-
boolean isChroma = boxColor == ColorCode.CHROMA.getColor(alpha);
58-
if (isChroma) {
59-
if (MulticolorShaderManager.getInstance().shouldUseChromaShaders()
60-
&& Feature.CHROMA_MODE.getValue() == EnumUtils.ChromaMode.FADE) {
61-
ShaderManager.getInstance().enableShader(ChromaScreenShader.class);
62-
drawRect(x, y, x + width, y + height, boxColor);
63-
ShaderManager.getInstance().disableShader();
64-
} else {
65-
ButtonColorBox.drawChromaRect(x, y, x + width, y + height, boxColor);
66-
}
67-
} else {
68-
drawRect(x, y, x + width, y + height, boxColor);
69-
}
50+
public static void drawButtonBoxAndText(String displayString, int x, int y, int width, int height, int boxColor, float scale, int fontColor) {
51+
ButtonColorBox.drawColorRect(x, y, x + width, y + height, boxColor);
7052
GlStateManager.pushMatrix();
7153
GlStateManager.scale(scale, scale, 1);
7254
//noinspection IntegerDivisionInFloatingPointContext

src/main/java/codes/biscuit/skyblockaddons/gui/buttons/feature/ButtonOpenColorMenu.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY) {
6666
GlStateManager.enableBlend();
6767
int stringWidth = mc.fontRendererObj.getStringWidth(displayString);
6868
float scale = stringWidth > WIDTH_LIMIT ? 1 / (stringWidth / WIDTH_LIMIT) : 1;
69-
drawButtonBoxAndText(boxColor, boxAlpha, scale, fontColor);
69+
drawButtonBoxAndText(boxColor, scale, fontColor);
7070
}
7171

7272
@Override

src/main/java/codes/biscuit/skyblockaddons/gui/buttons/feature/ButtonSolid.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void drawButton(Minecraft mc, int mouseX, int mouseY) {
5252
int stringWidth = mc.fontRendererObj.getStringWidth(displayString);
5353
float widthLimit = SkyblockAddonsGui.BUTTON_MAX_WIDTH - 10;
5454
float scale = stringWidth > widthLimit ? 1F / (stringWidth / widthLimit) : 1F;
55-
drawButtonBoxAndText(boxColor, boxAlpha, scale, fontColor);
55+
drawButtonBoxAndText(boxColor, scale, fontColor);
5656
GlStateManager.disableBlend();
5757
}
5858

src/main/java/codes/biscuit/skyblockaddons/gui/screens/ColorSelectionGui.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import codes.biscuit.skyblockaddons.utils.ColorCode;
1111
import codes.biscuit.skyblockaddons.utils.ColorUtils;
1212
import codes.biscuit.skyblockaddons.utils.EnumUtils;
13+
import codes.biscuit.skyblockaddons.utils.EnumUtils.ChromaMode;
1314
import net.minecraft.client.Minecraft;
1415
import net.minecraft.client.gui.Gui;
1516
import net.minecraft.client.gui.GuiButton;
@@ -232,7 +233,12 @@ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
232233
Gui.drawModalRectWithCustomSizedTexture(imageX, imageY, 0, 0, pickerWidth, pickerHeight, pickerWidth, pickerHeight);
233234

234235
drawScaledString(this, Translations.getMessage("messages.selectedColor"), 120, defaultBlue, 1.5, 75);
235-
drawRect(width / 2 + 90, 140, width / 2 + 130, 160, color.get());
236+
237+
int currentColor = this.color.get();
238+
if (setting == null && feature.isChroma() && Feature.CHROMA_MODE.getValue() == ChromaMode.FADE) {
239+
currentColor = ColorCode.CHROMA.getColor(); // alpha is default on here
240+
}
241+
ButtonColorBox.drawColorRect(width / 2 + 90, 140, width / 2 + 130, 160, currentColor);
236242

237243
if (chromaCheckbox != null) chromaCheckbox.draw();
238244

src/main/java/codes/biscuit/skyblockaddons/utils/EnumRegistry.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ public class EnumRegistry {
3333
REGISTRY.put("GOOD_ENCHANT_COLOR", ColorCode.class);
3434
REGISTRY.put("GREAT_ENCHANT_COLOR", ColorCode.class);
3535
REGISTRY.put("PERFECT_ENCHANT_COLOR", ColorCode.class);
36-
// Dungeon class colors
37-
REGISTRY.put("HEALER_COLOR", ColorCode.class);
38-
REGISTRY.put("MAGE_COLOR", ColorCode.class);
39-
REGISTRY.put("BERSERK_COLOR", ColorCode.class);
40-
REGISTRY.put("ARCHER_COLOR", ColorCode.class);
41-
REGISTRY.put("TANK_COLOR", ColorCode.class);
4236
}
4337

4438
public static RegistrableEnum getEnumValue(String enumType, String enumKey) {

0 commit comments

Comments
 (0)