-
Notifications
You must be signed in to change notification settings - Fork 741
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
Conversation
There was a problem hiding this 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 aNAVIGATED
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.*; |
There was a problem hiding this comment.
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).
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)); |
There was a problem hiding this comment.
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.
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.
Fix #3757