-
Notifications
You must be signed in to change notification settings - Fork 847
支持在“实例管理”按钮上通过滚动滚轮切换游戏实例 #4509
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
支持在“实例管理”按钮上通过滚动滚轮切换游戏实例 #4509
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -208,20 +208,11 @@ public final class MainPage extends StackPane implements DecoratorPage { | |||||||
| launchPane.getStyleClass().add("launch-pane"); | ||||||||
| launchPane.setMaxWidth(230); | ||||||||
| launchPane.setMaxHeight(55); | ||||||||
| launchPane.setOnScroll(event -> { | ||||||||
| double deltaY = event.getDeltaY(); | ||||||||
| if (deltaY == 0) | ||||||||
| return; | ||||||||
|
|
||||||||
| FXUtils.onScroll(launchPane, versions, list -> { | ||||||||
| String currentId = getCurrentGame(); | ||||||||
| int index = Lang.indexWhere(versions, instance -> instance.getId().equals(currentId)); | ||||||||
| if (index < 0) return; | ||||||||
| if (deltaY > 0) // up | ||||||||
| index--; | ||||||||
| else // down | ||||||||
| index++; | ||||||||
| profile.setSelectedVersion(versions.get((index + versions.size()) % versions.size()).getId()); | ||||||||
| }); | ||||||||
| return Lang.indexWhere(list, instance -> instance.getId().equals(currentId)); | ||||||||
| }, it -> profile.setSelectedVersion(it.getId())); | ||||||||
|
|
||||||||
| StackPane.setAlignment(launchPane, Pos.BOTTOM_RIGHT); | ||||||||
| { | ||||||||
| JFXButton launchButton = new JFXButton(); | ||||||||
|
|
@@ -435,6 +426,10 @@ public ReadOnlyObjectWrapper<State> stateProperty() { | |||||||
| return state; | ||||||||
| } | ||||||||
|
|
||||||||
| public Profile getProfile() { | ||||||||
| return profile; | ||||||||
|
||||||||
| return profile; | |
| // Return a defensive copy to prevent external modification | |
| return profile == null ? null : new Profile(profile); |
Copilot
AI
Sep 20, 2025
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.
The getVersions() method returns the internal ObservableList directly, allowing external code to modify it. Consider returning an unmodifiable view using FXCollections.unmodifiableObservableList(versions) to prevent unintended modifications.
| return versions; | |
| return FXCollections.unmodifiableObservableList(versions); |
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.
The
onScrollmethod lacks documentation. Add a JavaDoc comment explaining the purpose, parameters, and behavior of this utility method, especially the finder function's expected return value (-1 for not found) and how the circular navigation works.