Skip to content

Commit 685ce38

Browse files
gaoyu06claude
andcommitted
fix: OOBE completion persistence and UI improvements
- Fix OOBE completion status not persisting after restart - Add configLoaded flag to prevent saving before config is loaded - Optimize OOBE responsiveness for small windows (<600px) - Add animations for tutorial tips switching - Improve vertical centering and spacing - Add debug logging for config lifecycle Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6e02440 commit 685ce38

8 files changed

Lines changed: 1007 additions & 331 deletions

File tree

src/main/java/top/fpsmaster/features/GlobalListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void onChatSend(EventSendChatMessage e) {
4747

4848
@Subscribe
4949
public void onValueChange(EventValueChange e) {
50-
if (!FPSMaster.configManager.isLoadingConfig()) {
50+
if (FPSMaster.configManager.isConfigLoaded() && !FPSMaster.configManager.isLoadingConfig()) {
5151
FPSMaster.configManager.saveConfigQuietly("default");
5252
}
5353
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class ClientSettings extends InterfaceModule {
3030
};
3131
public static ModeSetting fixedScale = new ModeSetting(
3232
"FixedScale",
33-
5,
33+
3,
3434
() -> fixedScaleEnabled.getValue(),
3535
"0.5x", "0.75x", "1x", "1.25x", "1.5x", "2x", "2.5x", "3x"
3636
);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ public class ConfigManager {
3636
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
3737
private static final int SCHEMA_VERSION = 1;
3838
private boolean loadingConfig;
39+
private boolean configLoaded;
3940

4041
public Configure configure = new Configure();
4142

4243
public boolean isLoadingConfig() {
4344
return loadingConfig;
4445
}
4546

47+
public boolean isConfigLoaded() {
48+
return configLoaded;
49+
}
50+
4651
public void saveConfigQuietly(String name) {
4752
if (loadingConfig) {
4853
return;
@@ -54,6 +59,7 @@ public void saveConfigQuietly(String name) {
5459
}
5560

5661
public void saveConfig(String name) throws FileException {
62+
System.out.println("[ConfigManager] Saving config: " + name + ", oobeCompleted = " + configure.oobeCompleted);
5763
JsonObject json = new JsonObject();
5864
json.addProperty("schemaVersion", SCHEMA_VERSION);
5965
JsonObject client = new JsonObject();
@@ -186,6 +192,7 @@ public void loadConfig(String name) throws Exception {
186192
configure.oobeCompleted = client.has("oobeCompleted")
187193
? client.get("oobeCompleted").getAsBoolean()
188194
: FPSMaster.defaultConfigExistedBeforeLoad;
195+
System.out.println("[ConfigManager] Loaded oobeCompleted = " + configure.oobeCompleted + " (has field: " + client.has("oobeCompleted") + ", defaultConfigExistedBeforeLoad: " + FPSMaster.defaultConfigExistedBeforeLoad + ")");
189196
configure.antiCheatEnabled = !client.has("antiCheatEnabled") || client.get("antiCheatEnabled").getAsBoolean();
190197
configure.anonymousDataEnabled = !client.has("anonymousDataEnabled") || client.get("anonymousDataEnabled").getAsBoolean();
191198
if (client.has("classicBackgroundColor")) {
@@ -308,6 +315,7 @@ public void loadConfig(String name) throws Exception {
308315
}
309316
} finally {
310317
loadingConfig = false;
318+
configLoaded = true;
311319
}
312320
}
313321

src/main/java/top/fpsmaster/ui/common/TextField.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ public void drawTextBox(float x, float y, float width, float height) {
450450
}
451451

452452
boolean flag = j >= 0 && j <= s.length();
453-
boolean isFocus = this.isFocused && this.cursorCounter / 6 % 2 == 0 && flag;
453+
boolean isFocus = this.isFocused && (System.currentTimeMillis() / 500L) % 2L == 0L && flag;
454454
float l = this.xPosition + 4;
455455
float i1 = this.yPosition + (this.height - 8) / 2;
456456
float j1 = l;

src/main/java/top/fpsmaster/ui/screens/oobe/OobeButton.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import top.fpsmaster.FPSMaster;
44
import top.fpsmaster.ui.common.control.UiControl;
55
import top.fpsmaster.utils.math.anim.AnimClock;
6+
import top.fpsmaster.utils.math.anim.AnimMath;
67
import top.fpsmaster.utils.math.anim.ColorAnimator;
78
import top.fpsmaster.utils.render.draw.Hover;
89
import top.fpsmaster.utils.render.draw.Rects;
@@ -22,6 +23,8 @@ public class OobeButton implements UiControl {
2223
private float height;
2324
private boolean primary;
2425
private boolean enabled = true;
26+
private float hoverAnim;
27+
private float pressAnim;
2528

2629
public OobeButton(String text, boolean primary, Runnable onClick) {
2730
this.text = text;
@@ -51,15 +54,24 @@ public void render(float x, float y, float width, float height, float mouseX, fl
5154
this.y = y;
5255
this.width = width;
5356
this.height = height;
54-
colorAnimator.update(clock.tick());
57+
float dt = (float) clock.tick();
58+
colorAnimator.update(dt);
5559
boolean hovered = enabled && Hover.is(x, y, width, height, (int) mouseX, (int) mouseY);
60+
hoverAnim = (float) AnimMath.base(hoverAnim, hovered ? 1.0 : 0.0, 0.22);
61+
pressAnim = (float) AnimMath.base(pressAnim, 0.0, 0.30);
5662
Color target = primary
5763
? (hovered ? new Color(118, 131, 252, 242) : new Color(104, 117, 247, enabled ? 228 : 148))
5864
: (hovered ? new Color(255, 255, 255, 228) : new Color(255, 255, 255, enabled ? 188 : 145));
5965
colorAnimator.base(target);
60-
Rects.rounded(Math.round(x), Math.round(y), Math.round(width), Math.round(height), 12, colorAnimator.getColor().getRGB());
66+
float inset = pressAnim * 1.5f;
67+
float drawX = x + inset;
68+
float drawY = y + inset;
69+
float drawWidth = Math.max(4f, width - inset * 2f);
70+
float drawHeight = Math.max(4f, height - inset * 2f);
71+
Color fillColor = colorAnimator.getColor();
72+
Rects.rounded(Math.round(drawX), Math.round(drawY), Math.round(drawWidth), Math.round(drawHeight), 12, fillColor.getRGB());
6173
int textColor = primary ? Color.WHITE.getRGB() : new Color(42, 52, 78, enabled ? 255 : 160).getRGB();
62-
FPSMaster.fontManager.s14.drawCenteredString(text, x + width / 2f, y + height / 2f - 3.5f, textColor);
74+
FPSMaster.fontManager.s16.drawCenteredString(text, x + width / 2f, y + height / 2f - 4.5f + pressAnim * 0.5f, textColor);
6375
}
6476

6577
@Override
@@ -77,6 +89,7 @@ public void renderInScreen(ScaledGuiScreen screen, float x, float y, float width
7789
@Override
7890
public void mouseClicked(float mouseX, float mouseY, int button) {
7991
if (button == 0 && enabled && Hover.is(x, y, width, height, (int) mouseX, (int) mouseY)) {
92+
pressAnim = 1.0f;
8093
onClick.run();
8194
}
8295
}

src/main/java/top/fpsmaster/ui/screens/oobe/OobeDropdown.java

Lines changed: 69 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
11
package top.fpsmaster.ui.screens.oobe;
22

3+
import net.minecraft.util.ResourceLocation;
4+
import org.lwjgl.opengl.GL11;
35
import top.fpsmaster.FPSMaster;
46
import top.fpsmaster.utils.math.anim.AnimClock;
7+
import top.fpsmaster.utils.math.anim.AnimMath;
58
import top.fpsmaster.utils.render.draw.Hover;
9+
import top.fpsmaster.utils.render.draw.Images;
610
import top.fpsmaster.utils.render.draw.Rects;
711
import top.fpsmaster.utils.render.gui.ScaledGuiScreen;
812

913
import java.awt.Color;
1014

1115
public class OobeDropdown {
16+
private static final ResourceLocation ARROW_ICON = new ResourceLocation("client/gui/settings/icons/arrow.png");
17+
1218
private String label = "";
1319
private String[] items = new String[0];
1420
private int selectedIndex;
1521
private boolean open;
1622
private boolean enabled = true;
1723
private float openProgress;
1824
private final AnimClock clock = new AnimClock();
25+
private boolean selectionChanged;
26+
private float hoverAnim;
27+
private float pressAnim;
1928

2029
public OobeDropdown setLabel(String label) {
2130
this.label = label;
@@ -47,39 +56,87 @@ public int getSelectedIndex() {
4756
return selectedIndex;
4857
}
4958

59+
public boolean consumeSelectionChanged() {
60+
boolean changed = selectionChanged;
61+
selectionChanged = false;
62+
return changed;
63+
}
64+
5065
public void renderInScreen(ScaledGuiScreen screen, float x, float y, float width, float height, int mouseX, int mouseY) {
5166
float dt = (float) clock.tick();
5267
float target = open && enabled ? 1f : 0f;
53-
openProgress += (target - openProgress) * Math.min(1f, dt * 10f);
68+
openProgress += (target - openProgress) * Math.min(1f, dt * 12f);
69+
boolean hovered = enabled && Hover.is(x, y, width, height, mouseX, mouseY);
70+
hoverAnim = (float) AnimMath.base(hoverAnim, hovered ? 1.0 : 0.0, 0.22);
71+
pressAnim = (float) AnimMath.base(pressAnim, 0.0, 0.28);
72+
73+
Color headColor = enabled
74+
? (hovered ? new Color(247, 249, 255, 252) : new Color(244, 247, 255, 248))
75+
: new Color(235, 239, 246, 205);
76+
Color labelColor = enabled ? new Color(110, 119, 136, 255) : new Color(146, 152, 164, 200);
77+
Color valueColor = enabled ? new Color(27, 35, 48, 255) : new Color(126, 132, 144, 200);
78+
79+
float inset = pressAnim * 1.3f;
80+
float drawX = x + inset;
81+
float drawY = y + inset;
82+
float drawWidth = Math.max(4f, width - inset * 2f);
83+
float drawHeight = Math.max(4f, height - inset * 2f);
5484

55-
Rects.rounded(Math.round(x), Math.round(y), Math.round(width), Math.round(height), 12, new Color(255, 255, 255, enabled ? 224 : 168).getRGB());
56-
FPSMaster.fontManager.s16.drawString(label, x + 12f, y + 11f, new Color(58, 68, 96, enabled ? 255 : 140).getRGB());
85+
Rects.rounded(Math.round(drawX), Math.round(drawY), Math.round(drawWidth), Math.round(drawHeight), 14, headColor.getRGB());
86+
FPSMaster.fontManager.s16.drawString(label, drawX + 14f, drawY + 10f, labelColor.getRGB());
5787
String selected = items.length == 0 ? "" : items[selectedIndex];
58-
FPSMaster.fontManager.s16.drawString(selected, x + width - 64f, y + 11f, new Color(58, 68, 96, enabled ? 255 : 140).getRGB());
59-
FPSMaster.fontManager.s16.drawString(openProgress > 0.5f ? "^" : "v", x + width - 24f, y + 11f, new Color(58, 68, 96, enabled ? 255 : 140).getRGB());
88+
float valueX = drawX + drawWidth - 20f - FPSMaster.fontManager.s16.getStringWidth(selected) - 16f;
89+
FPSMaster.fontManager.s16.drawString(selected, Math.max(drawX + 74f, valueX), drawY + 10f + pressAnim * 0.5f, valueColor.getRGB());
90+
renderArrow(drawX + drawWidth - 18f, drawY + drawHeight / 2f, openProgress, new Color(104, 117, 247, 230));
6091

6192
if (enabled && screen.consumePressInBounds(x, y, width, height, 0) != null) {
93+
pressAnim = 1.0f;
6294
open = !open;
6395
}
6496

6597
if (openProgress > 0.02f && enabled) {
98+
float optionHeight = 24f;
99+
float optionGap = 3f;
100+
float panelHeight = items.length * optionHeight + Math.max(0, items.length - 1) * optionGap + 10f;
101+
float panelY = y + height + 6f;
102+
int panelAlpha = Math.max(0, Math.min(255, (int) (openProgress * 255f)));
103+
104+
Rects.rounded(Math.round(x), Math.round(panelY), Math.round(width), Math.round(panelHeight * openProgress), 10,
105+
new Color(255, 255, 255, Math.min(244, panelAlpha)).getRGB());
106+
66107
for (int i = 0; i < items.length; i++) {
67-
float optionY = y + height + 6f + i * 32f * openProgress;
108+
float optionY = panelY + 5f + i * (optionHeight + optionGap);
68109
int alpha = Math.max(0, Math.min(255, (int) (openProgress * 255f)));
69-
Rects.rounded(Math.round(x), Math.round(optionY), Math.round(width), 26, 10,
70-
(i == selectedIndex ? new Color(122, 139, 255, Math.min(230, alpha)) : new Color(255, 255, 255, Math.min(232, alpha))).getRGB());
71-
FPSMaster.fontManager.s16.drawString(items[i], x + 12f, optionY + 9f,
72-
(i == selectedIndex ? new Color(255, 255, 255, alpha) : new Color(58, 68, 96, alpha)).getRGB());
73-
if (openProgress > 0.95f && screen.consumePressInBounds(x, optionY, width, 28f, 0) != null) {
110+
boolean optionHovered = Hover.is(x + 4f, optionY, width - 8f, optionHeight, mouseX, mouseY);
111+
Color optionColor = i == selectedIndex
112+
? new Color(104, 117, 247, Math.min(228, alpha))
113+
: (optionHovered ? new Color(240, 244, 255, Math.min(236, alpha)) : new Color(255, 255, 255, 0));
114+
if (optionColor.getAlpha() > 0) {
115+
Rects.rounded(Math.round(x + 4f), Math.round(optionY), Math.round(width - 8f), Math.round(optionHeight), 10, optionColor.getRGB());
116+
}
117+
FPSMaster.fontManager.s16.drawString(items[i], x + 12f, optionY + 6f,
118+
(i == selectedIndex ? new Color(255, 255, 255, alpha) : new Color(78, 89, 108, alpha)).getRGB());
119+
if (openProgress > 0.95f && screen.consumePressInBounds(x, optionY, width, optionHeight, 0) != null) {
74120
selectedIndex = i;
121+
selectionChanged = true;
122+
pressAnim = 1.0f;
75123
open = false;
76124
}
77125
}
78126

79127
ScaledGuiScreen.PointerEvent outside = screen.peekAnyPress();
80-
if (outside != null && openProgress > 0.95f && !Hover.is(x, y, width, height + items.length * 32f + 12f, outside.x, outside.y)) {
128+
if (outside != null && openProgress > 0.95f && !Hover.is(x, y, width, height + panelHeight + 4f, outside.x, outside.y)) {
81129
open = false;
82130
}
83131
}
84132
}
133+
134+
private void renderArrow(float centerX, float centerY, float progress, Color color) {
135+
GL11.glPushMatrix();
136+
GL11.glTranslatef(centerX, centerY, 0f);
137+
GL11.glRotatef(progress * 180f, 0f, 0f, 1f);
138+
GL11.glTranslatef(-centerX, -centerY, 0f);
139+
Images.draw(ARROW_ICON, centerX - 4f, centerY - 4f, 8f, 8f, color);
140+
GL11.glPopMatrix();
141+
}
85142
}

0 commit comments

Comments
 (0)