Skip to content

Fix #3757 切换游戏文件夹后,全局游戏设置应重新读取设置 #3818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025

Conversation

burningtnt
Copy link
Member

Fix #3757

@burningtnt burningtnt changed the title Fix #3757 Fix #3757 切换游戏文件夹后,全局游戏设置应重新读取设置 Apr 12, 2025
@Glavo Glavo requested a review from Copilot May 20, 2025 05:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Ensures that global game settings are reloaded when switching the game folder by moving the version load logic into a navigation event handler and cleaning up imports.

  • Replaced the immediate loadVersion call with a NAVIGATED event handler to defer loading until navigation occurs.
  • Collapsed multiple org.jackhuang.hmcl.ui.construct imports into a wildcard import.

import org.jackhuang.hmcl.ui.construct.PageAware;
import org.jackhuang.hmcl.ui.construct.TabControl;
import org.jackhuang.hmcl.ui.construct.TabHeader;
import org.jackhuang.hmcl.ui.construct.*;
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Avoid wildcard imports to keep dependencies explicit; consider importing only the classes actually used (e.g., AdvancedListBox, PageAware, TabControl, TabHeader).

Suggested change
import org.jackhuang.hmcl.ui.construct.*;
import org.jackhuang.hmcl.ui.construct.AdvancedListBox;
import org.jackhuang.hmcl.ui.construct.PageAware;
import org.jackhuang.hmcl.ui.construct.TabControl;
import org.jackhuang.hmcl.ui.construct.TabHeader;

Copilot uses AI. Check for mistakes.

@@ -62,7 +59,7 @@ public LauncherSettingsPage() {
tab = new TabHeader(gameTab, javaManagementTab, settingsTab, personalizationTab, downloadTab, helpTab, feedbackTab, aboutTab);

tab.select(gameTab);
gameTab.getNode().loadVersion(Profiles.getSelectedProfile(), null);
addEventHandler(Navigator.NavigationEvent.NAVIGATED, event -> gameTab.getNode().loadVersion(Profiles.getSelectedProfile(), null));
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handler will reload the version on every navigation event, not just when the game tab is selected. Consider adding a check to only call loadVersion when gameTab is the active destination to avoid unnecessary reloads.

Suggested change
addEventHandler(Navigator.NavigationEvent.NAVIGATED, event -> gameTab.getNode().loadVersion(Profiles.getSelectedProfile(), null));
addEventHandler(Navigator.NavigationEvent.NAVIGATED, event -> {
if (tab.getSelectionModel().getSelectedItem() == gameTab) {
gameTab.getNode().loadVersion(Profiles.getSelectedProfile(), null);
}
});

Copilot uses AI. Check for mistakes.

@Glavo Glavo merged commit 0900ad3 into HMCL-dev:main May 20, 2025
2 checks passed
@burningtnt burningtnt deleted the fix3757/global-game-setting branch June 9, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] 切换游戏文件夹后再重启启动器后全局游戏设置会变为默认
2 participants