Skip to content

支持愚人节模式#5791

Open
Glavo wants to merge 32 commits intoHMCL-dev:mainfrom
Glavo:april-fools
Open

支持愚人节模式#5791
Glavo wants to merge 32 commits intoHMCL-dev:mainfrom
Glavo:april-fools

Conversation

@Glavo
Copy link
Member

@Glavo Glavo commented Mar 15, 2026

本 PR 实现了对愚人节模式的基本支持,以及基本的愚人节彩蛋以供测试。

在 4 月 1 日以外的时间,可以通过将环境变量 HMCL_APRIL_FOOLS 设置为 true 来触发彩蛋。彩蛋每年只会显示一次,关闭对话框后需要删除 hmcl.json 来重置。

@zkitefly
Copy link
Member

相关 issue:#2964

@Glavo Glavo marked this pull request as ready for review March 19, 2026 08:39
@Glavo Glavo requested a review from Copilot March 19, 2026 08:39
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

该 PR 为 HMCL 增加“愚人节模式”的基础框架:引入日期/配置/环境变量控制开关,并在接近愚人节时提供设置项,同时加入一个简单彩蛋(标题旋转)用于验证功能生效。

Changes:

  • 新增 AprilFools 工具类:判断是否为愚人节/临近愚人节,以及是否启用愚人节功能(含配置与系统属性/环境变量覆盖)。
  • 新增配置项 disableAprilFools,并在设置页临近愚人节时显示“禁用愚人节功能”的开关。
  • 在主界面标题处加入愚人节彩蛋(启用时旋转标题)。

Reviewed changes

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

Show a summary per file
File Description
HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties 添加“禁用愚人节功能”设置项的简中翻译
HMCL/src/main/resources/assets/lang/I18N_zh.properties 添加“禁用愚人节功能”设置项的繁中翻译
HMCL/src/main/resources/assets/lang/I18N.properties 添加“禁用愚人节功能”设置项的英文翻译
HMCL/src/main/java/org/jackhuang/hmcl/util/AprilFools.java 新增愚人节判断与开关工具类
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java 临近愚人节时显示“禁用愚人节功能”开关并绑定配置
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java 启用愚人节时旋转标题图标与标题文本
HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java 启动初始化阶段输出愚人节启用状态日志
HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java 新增 disableAprilFools 配置字段与属性访问器
HMCL/src/main/java/org/jackhuang/hmcl/Launcher.java 调整 util 相关 import 以适配新增工具类引用

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

@Glavo Glavo requested a review from Copilot March 19, 2026 09:07
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

该 PR 为 HMCL 增加“愚人节模式”的基础能力:在特定日期/区域启用彩蛋,并提供设置项允许用户禁用该行为,便于后续扩展更多彩蛋内容。

Changes:

  • 新增 AprilFools 工具类,用于判定愚人节模式是否启用及是否展示相关设置项
  • 在设置页新增“禁用愚人节功能”开关,并在主界面标题处增加愚人节彩蛋效果
  • 增加配置项 disableAprilFools 及对应的中英文本地化文案

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties 新增“禁用愚人节功能”中文(简体)文案
HMCL/src/main/resources/assets/lang/I18N_zh.properties 新增“禁用愚人节功能”中文(繁体)文案
HMCL/src/main/resources/assets/lang/I18N.properties 新增“禁用愚人节功能”英文文案
HMCL/src/main/java/org/jackhuang/hmcl/util/AprilFools.java 新增愚人节模式判定与设置展示逻辑
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java 在设置页按条件展示“禁用愚人节功能”开关并绑定配置
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java 在标题处根据愚人节模式触发翻转彩蛋
HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java 启动初始化时输出愚人节模式开关状态日志
HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java 新增 disableAprilFools 配置项及其属性访问器
HMCL/src/main/java/org/jackhuang/hmcl/Launcher.java 调整 util 相关 import(由显式导入改为通配符导入)

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

@Glavo Glavo requested a review from Copilot March 19, 2026 09:37
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

本 PR 为 HMCL 增加“愚人节模式”的基础支持:在特定日期/地区与可选覆盖开关下启用彩蛋,并提供一个可在设置页中关闭该功能的开关,以便在需要时禁用。

Changes:

  • 新增 AprilFools 工具类,用于判定是否启用/是否展示相关设置项(支持地区白名单 + 环境变量/系统属性覆盖 + 配置开关)。
  • 在设置页新增“禁用愚人节功能”开关(需要重启生效)。
  • 在主界面标题处增加一个基础彩蛋(启用时旋转标题图标与文字),并在启动初始化日志中输出启用状态。

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties 增加“禁用愚人节功能”中文(简体)文案键值。
HMCL/src/main/resources/assets/lang/I18N_zh.properties 增加“禁用愚人节功能”中文(繁体)文案键值。
HMCL/src/main/resources/assets/lang/I18N.properties 增加英文文案键值。
HMCL/src/main/java/org/jackhuang/hmcl/util/AprilFools.java 新增愚人节模式判定与设置项展示判定逻辑。
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java 条件展示“禁用愚人节功能”开关并绑定到配置。
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java 启用愚人节时对标题图标/文字应用旋转彩蛋。
HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java 初始化阶段输出愚人节启用状态日志。
HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java 新增 disableAprilFools 配置项并提供 JavaFX property API。
HMCL/src/main/java/org/jackhuang/hmcl/Launcher.java 调整 util 导入方式以适配新增工具类引用(imports 变更)。

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

Comment on lines +51 to +63
boolean aprilFoolsMode;
String value = System.getProperty("hmcl.april_fools", System.getenv("HMCL_APRIL_FOOLS"));
if ("true".equalsIgnoreCase(value))
aprilFoolsMode = true;
else if ("false".equalsIgnoreCase(value) || !supportedRegion)
aprilFoolsMode = false;
else
aprilFoolsMode = date.getMonth() == Month.APRIL && date.getDayOfMonth() == 1;

ENABLED = aprilFoolsMode && !config().isDisableAprilFools();
SHOW_APRIL_FOOLS_SETTINGS = aprilFoolsMode || supportedRegion && date.getMonth() == Month.MARCH && date.getDayOfMonth() > 30;
}

aprilFoolsMode = date.getMonth() == Month.APRIL && date.getDayOfMonth() == 1;

ENABLED = aprilFoolsMode && !config().isDisableAprilFools();
SHOW_APRIL_FOOLS_SETTINGS = aprilFoolsMode || supportedRegion && date.getMonth() == Month.MARCH && date.getDayOfMonth() > 30;
@Glavo Glavo requested a review from Copilot March 19, 2026 13:53
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

本 PR 为 HMCL 增加“愚人节模式”的基础支持:在特定日期/地区启用彩蛋,并提供设置项用于禁用相关功能,同时加入一个用于测试的彩蛋(标题旋转 + 引导切换文言文)。

Changes:

  • 新增 AprilFools 工具类:基于日期、地区白名单与配置项决定是否启用/展示愚人节功能入口
  • 设置页按条件展示“禁用愚人节功能”开关,并写入配置
  • 启动时在满足条件时弹窗引导中文用户切换到文言文模式;主页标题在愚人节模式下旋转

Reviewed changes

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

Show a summary per file
File Description
HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties 新增愚人节引导切换文言文的提示文案、设置项文案(简中)
HMCL/src/main/resources/assets/lang/I18N_zh.properties 新增愚人节引导切换文言文的提示文案、设置项文案(繁中)
HMCL/src/main/resources/assets/lang/I18N.properties 新增愚人节引导与设置项英文文案
HMCL/src/main/java/org/jackhuang/hmcl/util/AprilFools.java 新增愚人节模式判定/开关逻辑
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java 条件展示“禁用愚人节功能”开关并绑定配置
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/MainPage.java 愚人节模式下标题图标/文字旋转彩蛋
HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java 初始化时输出日志,并在满足条件时弹窗引导切换文言文
HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java 新增 disableAprilFools 配置项及属性访问器
HMCL/src/main/java/org/jackhuang/hmcl/Launcher.java 调整 util 相关 import(合并为通配符)

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

launcher.agreement.accept=同意
launcher.agreement.decline=拒绝
launcher.agreement.hint=同意本软件的用户协议与免责声明以使用本软件。
launcher.april_fools.switch_lzh=HMCL 启动器现已支持文言文,是否要切换至文言文模式?\n你可以在“置設 → 貫用 → 語言”中切换回简体中文。
launcher.agreement.accept=同意
launcher.agreement.decline=拒絕
launcher.agreement.hint=同意本軟體的使用者協議與免責宣告以使用本軟體。
launcher.april_fools.switch_lzh=HMCL 啟動器現已支援文言文,是否要切換至文言文模式?\n你可以在「置設 → 貫用 → 語言」中切換回繁體中文。
launcher.agreement.accept=Accept
launcher.agreement.decline=Decline
launcher.agreement.hint=You must agree to the EULA to use this software.
launcher.april_fools.switch_lzh=HMCL Launcher now supports Classical Chinese, do you want to switch to Classical Chinese mode?\nYou can switch back to English in "置設 → 貫用 → 語言".
Comment on lines +228 to +234
if (AprilFools.isShowAprilFoolsSettings()) {
LineToggleButton disableAprilFools = new LineToggleButton();
disableAprilFools.setTitle(i18n("settings.launcher.disable_april_fools"));
disableAprilFools.setSubtitle(i18n("settings.take_effect_after_restart"));
disableAprilFools.selectedProperty().bindBidirectional(config().disableAprilFoolsProperty());
settingsPane.getContent().add(disableAprilFools);
}
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

本 PR 为 HMCL 增加“愚人节模式”的基础支持:通过日期/地区白名单与配置开关控制功能启用,并在满足条件时弹窗引导中文用户切换到文言(lzh)界面,同时补齐相关多语言文案与设置项入口。

Changes:

  • 新增 AprilFools 工具类:计算愚人节模式是否启用、是否显示相关设置项,并支持通过系统属性/环境变量强制开关
  • Controllers.initialize 中加入愚人节彩蛋:满足条件时引导切换到 lzh 并尝试重启
  • 增加配置项 disableAprilFools 及设置页开关,并补充各语言资源文案;新增 Restarter 辅助重启

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties 增加愚人节引导切换文言与“禁用愚人节功能”文案(简体)
HMCL/src/main/resources/assets/lang/I18N_zh.properties 增加对应文案(繁体)
HMCL/src/main/resources/assets/lang/I18N_lzh.properties 调整文言环境下的语言项显示文本
HMCL/src/main/resources/assets/lang/I18N.properties 增加对应英文文案与设置项文案
HMCL/src/main/java/org/jackhuang/hmcl/util/Restarter.java 新增自重启工具类(基于 UpdateHandler.startJava
HMCL/src/main/java/org/jackhuang/hmcl/util/FileSaver.java 增加等待保存队列完成的辅助方法
HMCL/src/main/java/org/jackhuang/hmcl/util/AprilFools.java 新增愚人节模式判定与设置显示逻辑
HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateHandler.java startJava 提升为 public 以支持外部复用
HMCL/src/main/java/org/jackhuang/hmcl/ui/main/SettingsPage.java 条件展示“禁用愚人节功能”开关并绑定配置
HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java 启动时注入愚人节引导弹窗与切换/重启流程
HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java 增加 disableAprilFools 配置字段与属性
HMCL/src/main/java/org/jackhuang/hmcl/Launcher.java 调整 util 相关 import 组织方式

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

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

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

Comments suppressed due to low confidence (1)

HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateHandler.java:182

  • startJava was changed from private to public. This exposes a low-level process-spawn helper as part of the public API of UpdateHandler, which can encourage unintended use and makes future refactors harder. Consider keeping it package-private and moving Restarter into the same package, or introducing a dedicated public restart API (e.g., UpdateHandler.restart(Path, ...)) with clearer semantics.
        startJava(updateTo, "--apply-to", self.toString());
    }

    public static void startJava(Path jar, String... appArgs) throws IOException {
        List<String> commandline = new ArrayList<>();
        commandline.add(JavaRuntime.getDefault().getBinary().toString());

        try {

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

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