Skip to content

若背景自定义路径是文件夹 则随机在文件夹选取图片展示#5769

Merged
Glavo merged 5 commits intoHMCL-dev:mainfrom
CiiLu:w
Mar 13, 2026
Merged

若背景自定义路径是文件夹 则随机在文件夹选取图片展示#5769
Glavo merged 5 commits intoHMCL-dev:mainfrom
CiiLu:w

Conversation

@CiiLu
Copy link
Contributor

@CiiLu CiiLu commented Mar 11, 2026

No description provided.

@Glavo Glavo requested a review from Copilot March 13, 2026 13:41
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

为启动器背景“自定义路径”增加对文件夹路径的支持:当配置的背景路径指向文件夹时,从该文件夹内随机选择图片作为背景展示,从而提升背景自定义的灵活性。

Changes:

  • 自定义背景路径为目录时,随机选取目录内图片加载
  • 自定义背景路径为文件时,保持按文件路径加载
  • 移除未使用的 Paths 导入,改用 Path.of(...)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +196 to +199
Path path = Path.of(backgroundImage);
image = Files.isDirectory(path)
? randomImageIn(path)
: tryLoadImage(path);
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 extends HMCL’s background image loading so that when the user’s custom background path points to a directory, the UI will randomly pick an image from that directory to display.

Changes:

  • In CUSTOM background mode, treat the configured path as either a file (load directly) or a directory (pick a random image).
  • Adjust default-background directory scanning to collect into a mutable list and improve the log message with the actual directory path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +196 to +199
Path path = Path.of(backgroundImage);
image = Files.isDirectory(path)
? randomImageIn(path)
: tryLoadImage(path);
List<Path> candidates;
ArrayList<Path> candidates;
try (Stream<Path> stream = Files.list(imageDir)) {
candidates = stream
@Glavo Glavo merged commit 5e18c0a into HMCL-dev:main Mar 13, 2026
6 checks passed
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