Skip to content

Commit b6ad74d

Browse files
committed
feat: ui updates
1 parent 2668290 commit b6ad74d

32 files changed

Lines changed: 713 additions & 385 deletions

src/main/java/top/fpsmaster/features/impl/interfaces/Keystrokes.java

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,22 @@
1010
import java.awt.*;
1111

1212
public class Keystrokes extends InterfaceModule {
13-
public static ColorSetting pressedColor = new ColorSetting("PressedColor", new Color(255, 255, 255, 120));
14-
public static ColorSetting fontColor = new ColorSetting("FontColor", new Color(255, 255, 255));
15-
public static ColorSetting pressedFontColor = new ColorSetting("PressedFontColor", new Color(201, 201, 201));
16-
public static ModeSetting textColorMode = new ModeSetting("TextColorMode", 0, "Static", "Rainbow", "Chroma");
17-
public static NumberSetting textColorSpeed = new NumberSetting("TextColorSpeed", 1.0, 0.1, 5.0, 0.1, () -> !textColorMode.isMode("Static"));
18-
public static NumberSetting textColorSaturation = new NumberSetting("TextColorSaturation", 0.7, 0.0, 1.0, 0.05, () -> !textColorMode.isMode("Static"));
13+
private static final ColorSetting.ColorType[] KEYSTROKE_COLOR_TYPES = new ColorSetting.ColorType[] {
14+
ColorSetting.ColorType.STATIC,
15+
ColorSetting.ColorType.RAINBOW,
16+
ColorSetting.ColorType.CHROMA
17+
};
18+
19+
public static ColorSetting pressedColor = new ColorSetting("PressedColor", new Color(255, 255, 255, 120), KEYSTROKE_COLOR_TYPES);
20+
public static ColorSetting fontColor = new ColorSetting("FontColor", new Color(255, 255, 255), KEYSTROKE_COLOR_TYPES);
21+
public static ColorSetting pressedFontColor = new ColorSetting("PressedFontColor", new Color(201, 201, 201), KEYSTROKE_COLOR_TYPES);
1922

2023
public static NumberSetting borderWidth = new NumberSetting("BorderWidth", 1.0, 0.0, 4.0, 0.5);
21-
public static ModeSetting borderColorMode = new ModeSetting("BorderColorMode", 0, () -> borderWidth.getValue().floatValue() > 0, "Static", "Rainbow", "Chroma");
2224
public static ColorSetting borderColor = new ColorSetting(
2325
"BorderColor",
2426
new Color(255, 255, 255, 80),
25-
() -> borderWidth.getValue().floatValue() > 0 && borderColorMode.isMode("Static")
26-
);
27-
public static NumberSetting borderColorSpeed = new NumberSetting(
28-
"BorderColorSpeed",
29-
1.0,
30-
0.1,
31-
5.0,
32-
0.1,
33-
() -> borderWidth.getValue().floatValue() > 0 && !borderColorMode.isMode("Static")
34-
);
35-
public static NumberSetting borderColorSaturation = new NumberSetting(
36-
"BorderColorSaturation",
37-
0.7,
38-
0.0,
39-
1.0,
40-
0.05,
41-
() -> borderWidth.getValue().floatValue() > 0 && !borderColorMode.isMode("Static")
27+
() -> borderWidth.getValue().floatValue() > 0,
28+
KEYSTROKE_COLOR_TYPES
4229
);
4330

4431
public static ModeSetting pressAnimMode = new ModeSetting("PressAnimMode", 0, "Color", "Pulse", "Ripple", "Bloom", "Stack");
@@ -56,8 +43,7 @@ public Keystrokes() {
5643
addSettings(
5744
fontShadow, betterFont,
5845
pressedColor, fontColor, pressedFontColor,
59-
textColorMode, textColorSpeed, textColorSaturation,
60-
borderColorMode, borderColor, borderColorSpeed, borderColorSaturation, borderWidth,
46+
borderColor, borderWidth,
6147
pressAnimMode, pressAnimColor, pressAnimDuration,
6248
showSpace, cpsMode, wasdStyle, spaceStyle, spacing, bg, backgroundColor, rounded, roundRadius
6349
);

src/main/java/top/fpsmaster/features/settings/impl/ColorSetting.java

Lines changed: 179 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,162 @@
44
import top.fpsmaster.features.settings.impl.utils.CustomColor;
55

66
import java.awt.*;
7+
import java.util.Arrays;
78

89
public class ColorSetting extends Setting<CustomColor> {
910

11+
public enum ColorType {
12+
STATIC("colorsetting.type.static"),
13+
WAVE("colorsetting.type.breath"),
14+
CHROMA("colorsetting.type.chroma"),
15+
RAINBOW("colorsetting.type.rainbow");
16+
17+
public final String i18nKey;
18+
19+
ColorType(String i18nKey) {
20+
this.i18nKey = i18nKey;
21+
}
22+
}
23+
24+
private ColorType colorType = ColorType.STATIC;
25+
private final ColorType[] availableTypes;
26+
private Color latestResolvedColor;
27+
1028
public ColorSetting(String name, CustomColor value, VisibleCondition visible) {
1129
super(name, value, visible);
30+
this.availableTypes = new ColorType[] {ColorType.STATIC};
1231
}
1332

1433
public ColorSetting(String name, Color value, VisibleCondition visible) {
1534
super(name, new CustomColor(value), visible);
35+
this.availableTypes = new ColorType[] {ColorType.STATIC};
1636
}
1737

1838
public ColorSetting(String name, CustomColor value) {
1939
super(name, value);
40+
this.availableTypes = new ColorType[] {ColorType.STATIC};
2041
}
2142

2243
public ColorSetting(String name, Color value) {
2344
super(name, new CustomColor(value));
45+
this.availableTypes = new ColorType[] {ColorType.STATIC};
46+
}
47+
48+
public ColorSetting(String name, CustomColor value, VisibleCondition visible, ColorType... availableTypes) {
49+
super(name, value, visible);
50+
this.availableTypes = normalizeTypes(availableTypes);
51+
}
52+
53+
public ColorSetting(String name, Color value, VisibleCondition visible, ColorType... availableTypes) {
54+
super(name, new CustomColor(value), visible);
55+
this.availableTypes = normalizeTypes(availableTypes);
56+
}
57+
58+
public ColorSetting(String name, CustomColor value, ColorType... availableTypes) {
59+
super(name, value);
60+
this.availableTypes = normalizeTypes(availableTypes);
61+
}
62+
63+
public ColorSetting(String name, Color value, ColorType... availableTypes) {
64+
super(name, new CustomColor(value));
65+
this.availableTypes = normalizeTypes(availableTypes);
2466
}
2567

2668
public int getRGB() {
27-
return getValue().getRGB();
69+
return updateAndGetColor().getRGB();
70+
}
71+
72+
public int getRGB(float chromaOffset) {
73+
return updateAndGetColor(chromaOffset).getRGB();
2874
}
2975

3076
public Color getColor() {
31-
return getValue().getColor();
77+
return updateAndGetColor(0f);
78+
}
79+
80+
public Color getColor(float chromaOffset) {
81+
return updateAndGetColor(chromaOffset);
82+
}
83+
84+
public Color updateAndGetColor() {
85+
return updateAndGetColor(0f);
86+
}
87+
88+
public Color updateAndGetColor(float chromaOffset) {
89+
latestResolvedColor = resolveColor(getValue(), colorType, chromaOffset);
90+
return latestResolvedColor;
91+
}
92+
93+
public int updateAndGetRGB() {
94+
return updateAndGetColor().getRGB();
95+
}
96+
97+
public int updateAndGetRGB(float chromaOffset) {
98+
return updateAndGetColor(chromaOffset).getRGB();
99+
}
100+
101+
public Color getLatestResolvedColor() {
102+
return latestResolvedColor == null ? updateAndGetColor() : latestResolvedColor;
103+
}
104+
105+
public static Color resolveColor(CustomColor value, ColorType type, float chromaOffset) {
106+
long now = System.nanoTime();
107+
float dynamicHue = (float) ((now / 1_000_000_000.0 / 6.0) % 1.0);
108+
float normalizedOffset = chromaOffset - (float) Math.floor(chromaOffset);
109+
110+
switch (type) {
111+
case WAVE:
112+
float alphaWave = value.alpha * (0.35f + 0.65f * (float) ((Math.sin(now / 450_000_000.0) + 1.0) * 0.5));
113+
return new CustomColor(value.hue, value.brightness, value.saturation, alphaWave).getColor();
114+
case CHROMA:
115+
return new CustomColor((value.hue + dynamicHue + normalizedOffset) % 1.0f, value.brightness, value.saturation, value.alpha).getColor();
116+
case RAINBOW:
117+
return new CustomColor((dynamicHue + normalizedOffset) % 1.0f, value.brightness, value.saturation, value.alpha).getColor();
118+
case STATIC:
119+
default:
120+
return value.getColor();
121+
}
122+
}
123+
124+
public ColorType[] getAvailableTypes() {
125+
return Arrays.copyOf(availableTypes, availableTypes.length);
126+
}
127+
128+
public ColorType getColorType() {
129+
return colorType;
130+
}
131+
132+
public boolean supportsType(ColorType type) {
133+
for (ColorType availableType : availableTypes) {
134+
if (availableType == type) {
135+
return true;
136+
}
137+
}
138+
return false;
139+
}
140+
141+
public void setColorType(ColorType type) {
142+
if (type == null || !supportsType(type) || colorType == type) {
143+
return;
144+
}
145+
CustomColor current = getValue();
146+
CustomColor oldSnapshot = new CustomColor(current.hue, current.brightness, current.saturation, current.alpha);
147+
if (!fireValueChangeEvent(oldSnapshot, oldSnapshot)) {
148+
return;
149+
}
150+
colorType = type;
151+
notifyChangeListeners(oldSnapshot, oldSnapshot);
152+
}
153+
154+
public void cycleColorType() {
155+
int index = 0;
156+
for (int i = 0; i < availableTypes.length; i++) {
157+
if (availableTypes[i] == colorType) {
158+
index = i;
159+
break;
160+
}
161+
}
162+
setColorType(availableTypes[(index + 1) % availableTypes.length]);
32163
}
33164

34165
public void setColor(float hue, float saturation, float brightness, float alpha) {
@@ -52,6 +183,52 @@ public void setColor(Color color) {
52183
v.setColor(color);
53184
notifyChangeListeners(oldSnapshot, newSnapshot);
54185
}
186+
187+
private ColorType[] normalizeTypes(ColorType... modes) {
188+
if (modes == null || modes.length == 0) {
189+
return new ColorType[] {ColorType.STATIC};
190+
}
191+
192+
ColorType[] unique = new ColorType[modes.length];
193+
int size = 0;
194+
for (ColorType mode : modes) {
195+
if (mode == null) {
196+
continue;
197+
}
198+
boolean exists = false;
199+
for (int i = 0; i < size; i++) {
200+
if (unique[i] == mode) {
201+
exists = true;
202+
break;
203+
}
204+
}
205+
if (!exists) {
206+
unique[size++] = mode;
207+
}
208+
}
209+
210+
if (size == 0) {
211+
return new ColorType[] {ColorType.STATIC};
212+
}
213+
214+
ColorType[] result = Arrays.copyOf(unique, size);
215+
if (!supportsStatic(result)) {
216+
ColorType[] withStatic = new ColorType[size + 1];
217+
withStatic[0] = ColorType.STATIC;
218+
System.arraycopy(result, 0, withStatic, 1, size);
219+
return withStatic;
220+
}
221+
return result;
222+
}
223+
224+
private boolean supportsStatic(ColorType[] types) {
225+
for (ColorType type : types) {
226+
if (type == ColorType.STATIC) {
227+
return true;
228+
}
229+
}
230+
return false;
231+
}
55232
}
56233

57234

src/main/java/top/fpsmaster/forge/mixin/MixinGuiContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void logo(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
3636
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
3737
GL11.glPushMatrix();
3838
GuiScale.fixScale();
39-
Images.draw(new ResourceLocation("client/gui/settings/logo.png"), 0, (float) mc.displayHeight / GuiScale.getFixedScale() - 32, 163 / 2f, 32, -1);
39+
Images.draw(new ResourceLocation("client/gui/settings/logo.png"), 0, GuiScale.getFixedBounds()[1] - 32, 163 / 2f, 32, -1);
4040
GL11.glPopMatrix();
4141
}
4242

src/main/java/top/fpsmaster/modules/config/ConfigManager.java

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public void saveConfig(String name) throws FileException {
3939
JsonObject client = new JsonObject();
4040
client.addProperty("volume", configure.volume);
4141
client.addProperty("background", configure.background);
42+
client.addProperty("classicBackgroundColor", configure.classicBackgroundColor);
43+
client.addProperty("classicBackgroundHue", configure.classicBackgroundHue);
44+
client.addProperty("classicBackgroundSaturation", configure.classicBackgroundSaturation);
45+
client.addProperty("classicBackgroundBrightness", configure.classicBackgroundBrightness);
46+
client.addProperty("classicBackgroundAlpha", configure.classicBackgroundAlpha);
47+
client.addProperty("classicBackgroundMode", configure.classicBackgroundMode);
4248
json.add("client", client);
4349

4450
JsonArray components = new JsonArray();
@@ -68,6 +74,7 @@ public void saveConfig(String name) throws FileException {
6874
color.addProperty("s", value.saturation);
6975
color.addProperty("b", value.brightness);
7076
color.addProperty("a", value.alpha);
77+
color.addProperty("mode", colorSetting.getColorType().name());
7178
JsonObject settingJson = new JsonObject();
7279
settingJson.addProperty("type", "color");
7380
settingJson.add("value", color);
@@ -142,6 +149,32 @@ public void loadConfig(String name) throws Exception {
142149
if (client.has("background")) {
143150
configure.background = client.get("background").getAsString();
144151
}
152+
if (client.has("classicBackgroundColor")) {
153+
configure.classicBackgroundColor = client.get("classicBackgroundColor").getAsInt();
154+
}
155+
if (client.has("classicBackgroundHue")) {
156+
configure.classicBackgroundHue = client.get("classicBackgroundHue").getAsFloat();
157+
}
158+
if (client.has("classicBackgroundSaturation")) {
159+
configure.classicBackgroundSaturation = client.get("classicBackgroundSaturation").getAsFloat();
160+
}
161+
if (client.has("classicBackgroundBrightness")) {
162+
configure.classicBackgroundBrightness = client.get("classicBackgroundBrightness").getAsFloat();
163+
}
164+
if (client.has("classicBackgroundAlpha")) {
165+
configure.classicBackgroundAlpha = client.get("classicBackgroundAlpha").getAsFloat();
166+
}
167+
if (client.has("classicBackgroundMode")) {
168+
configure.classicBackgroundMode = client.get("classicBackgroundMode").getAsString();
169+
}
170+
171+
if (!client.has("classicBackgroundHue") || !client.has("classicBackgroundSaturation") || !client.has("classicBackgroundBrightness") || !client.has("classicBackgroundAlpha")) {
172+
CustomColor converted = new CustomColor(new java.awt.Color(configure.classicBackgroundColor, true));
173+
configure.classicBackgroundHue = converted.hue;
174+
configure.classicBackgroundSaturation = converted.saturation;
175+
configure.classicBackgroundBrightness = converted.brightness;
176+
configure.classicBackgroundAlpha = converted.alpha;
177+
}
145178
}
146179

147180
JsonArray components = json.getAsJsonArray("components");
@@ -186,12 +219,19 @@ public void loadConfig(String name) throws Exception {
186219
((TextSetting) setting).setValue(value.getAsString());
187220
} else if (setting instanceof ColorSetting && "color".equals(type)) {
188221
JsonObject color = value.getAsJsonObject();
189-
((ColorSetting) setting).getValue().setColor(
222+
ColorSetting colorSetting = (ColorSetting) setting;
223+
colorSetting.getValue().setColor(
190224
color.get("h").getAsFloat(),
191225
color.get("s").getAsFloat(),
192226
color.get("b").getAsFloat(),
193227
color.get("a").getAsFloat()
194228
);
229+
if (color.has("mode")) {
230+
try {
231+
colorSetting.setColorType(ColorSetting.ColorType.valueOf(color.get("mode").getAsString()));
232+
} catch (IllegalArgumentException ignored) {
233+
}
234+
}
195235
} else if (setting instanceof BindSetting && "bind".equals(type)) {
196236
((BindSetting) setting).setValue(value.getAsInt());
197237
} else if (setting instanceof MultipleItemSetting && "multiItem".equals(type)) {
@@ -215,6 +255,3 @@ private void openDefaultModules() {
215255
FPSMaster.moduleManager.getModule(ItemPhysics.class).set(true);
216256
}
217257
}
218-
219-
220-

src/main/java/top/fpsmaster/modules/config/Configure.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
public class Configure {
44
public double volume = 1.0;
55
public String background = "new";
6+
public int classicBackgroundColor = 0xFF000000;
7+
public float classicBackgroundHue = 0f;
8+
public float classicBackgroundSaturation = 0f;
9+
public float classicBackgroundBrightness = 0f;
10+
public float classicBackgroundAlpha = 1f;
11+
public String classicBackgroundMode = "STATIC";
612
}
713

814

0 commit comments

Comments
 (0)