Skip to content

支持在“实例管理”按钮上通过滚动滚轮切换游戏实例#4509

Merged
Glavo merged 4 commits intoHMCL-dev:mainfrom
Glavo:scroll
Sep 20, 2025
Merged

支持在“实例管理”按钮上通过滚动滚轮切换游戏实例#4509
Glavo merged 4 commits intoHMCL-dev:mainfrom
Glavo:scroll

Conversation

@Glavo
Copy link
Member

@Glavo Glavo commented Sep 18, 2025

考虑到账户管理按钮已经支持通过这种方式快速切换账户,让实例管理按钮支持同样的功能能够增强界面的一致性。

@zkitefly
Copy link
Member

要不要添加一个 tooltip 来提示一下?

@Glavo Glavo requested a review from Copilot September 20, 2025 12:13
Copy link
Contributor

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

This PR implements scroll wheel support for switching game instances on the "实例管理" (Instance Management) button to maintain UI consistency with the existing account management button that already supports this feature.

  • Extracts scroll wheel functionality into a reusable FXUtils.onScroll() utility method
  • Refactors existing account switching code to use the new utility method
  • Adds scroll wheel support to the game instance list item in the sidebar

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
FXUtils.java Adds generic onScroll() utility method for scroll wheel navigation through lists
AccountAdvancedListItem.java Refactors to use new utility method, removes duplicate scroll handling code
MainPage.java Refactors launch pane scroll handling to use utility method, adds getter methods
RootPage.java Adds scroll wheel support to game list item using new utility method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +1370 to +1373
public static <T> void onScroll(Node node, List<T> list,
ToIntFunction<List<T>> finder,
Consumer<T> updater
) {
Copy link

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

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

The onScroll method 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.

Copilot uses AI. Check for mistakes.
}

public Profile getProfile() {
return profile;
Copy link

Copilot AI Sep 20, 2025

Choose a reason for hiding this comment

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

[nitpick] The newly added getProfile() method exposes the internal profile object without any access control or immutability guarantees. Consider whether this direct exposure is necessary or if a more restricted API would be safer.

Suggested change
return profile;
// Return a defensive copy to prevent external modification
return profile == null ? null : new Profile(profile);

Copilot uses AI. Check for mistakes.
}

public ObservableList<Version> getVersions() {
return versions;
Copy link

Copilot AI Sep 20, 2025

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.

Suggested change
return versions;
return FXCollections.unmodifiableObservableList(versions);

Copilot uses AI. Check for mistakes.
@Glavo Glavo merged commit 867a04d into HMCL-dev:main Sep 20, 2025
2 checks passed
@Glavo Glavo deleted the scroll branch September 20, 2025 12:15
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.

3 participants