Skip to content

feat: HMCL 彩蛋#2613

Merged
LuLu-ling merged 13 commits intodevfrom
feat/HMCL
Mar 22, 2026
Merged

feat: HMCL 彩蛋#2613
LuLu-ling merged 13 commits intodevfrom
feat/HMCL

Conversation

@LuLu-ling
Copy link
Copy Markdown
Member

@LuLu-ling LuLu-ling commented Mar 16, 2026

PixPin_2026-03-19_18-32-20

Summary by Sourcery

引入一个季节性 HMCL 颜色主题和标题栏外观,仅在 4 月 1 日启用,其余时间保持正常行为。

新功能:

  • 添加新的 HMCL 蓝色主题,具有专用的色调和饱和度设置,并在 4 月 1 日于界面中作为可选项提供。
  • 添加 HMCL 风格的窗口标题/Logo 模式,带有上下文帮助按钮,并将链接绑定到主窗口。

改进:

  • 为主题和颜色变更处理添加保护,避免重复更新,并确保愚人节 HMCL 逻辑在主题刷新之后执行。
  • 在非 4 月 1 日时自动将 HMCL 主题选择重置为默认蓝色主题,避免季节性主题持续生效。
  • 重命名窗口标题自定义文本配置属性,使其更准确地反映实际用途。
Original summary in English

Summary by Sourcery

Introduce a seasonal HMCL color theme and title bar appearance that activates only on April 1st while preserving normal behavior otherwise.

New Features:

  • Add a new HMCL blue color theme with dedicated hue and chroma values and expose it as a selectable option in the UI on April 1st.
  • Add an HMCL-styled window title/logo mode with a contextual help button and link wired to the main window.

Enhancements:

  • Guard theme and color-change handling to avoid redundant updates and ensure April Fools HMCL logic runs after theme refreshes.
  • Automatically reset HMCL theme selections to the default blue theme outside of April 1st so the seasonal theme does not persist.
  • Rename the window title custom text config property to better reflect its usage.

@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: L PR 大小评估:大型 labels Mar 16, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Mar 16, 2026

Reviewer's Guide

实现仅在愚人节启用的 HMCL 蓝色主题(包括标题栏 Logo 模式、主题色相/色度,以及在设置界面中的曝光),将其接入中心化的主题服务并基于日期进行控制,同时在 4 月 1 日以外的时间重置或隐藏 HMCL 相关设置,并避免冗余的主题更新。

愚人节 HMCL 主题应用的时序图

sequenceDiagram
  participant User
  participant PageSetupUI
  participant ConfigTheme as Config.ThemePreference
  participant ThemeService
  participant ConfigWindow as Config.WindowPreference
  participant ModSetup
  participant FormMain
  participant Basics

  User->>PageSetupUI: Open settings page
  PageSetupUI->>Basics: Check IsAprilFool
  alt IsAprilFool == true
    PageSetupUI-->>User: Show theme options [SkyBlue, CatBlue, DeathBlue, HMCL]
  else IsAprilFool == false
    PageSetupUI->>ConfigTheme: Ensure UiDarkColor != HmclBlue
    PageSetupUI->>ConfigTheme: Ensure UiLightColor != HmclBlue
    PageSetupUI-->>User: Show theme options [SkyBlue, CatBlue, DeathBlue]
  end

  User->>ConfigTheme: Select HMCL theme (April 1st)
  ConfigTheme->>ThemeService: Trigger color config changed

  ThemeService->>ThemeService: Validate change and mode
  ThemeService->>ThemeService: ApplyColorResources()
  ThemeService-->>User: ColorThemeChanged(CurrentTheme)
  ThemeService->>ThemeService: _AprilFoolLogic()

  alt IsAprilFool == true
    ThemeService->>ConfigWindow: WindowTitleTypeConfig.TriggerEvent(Changed)
    ConfigWindow->>ModSetup: UiLogoType(current value)
    ModSetup->>ThemeService: Read CurrentTheme
    alt CurrentTheme == HmclBlue
      ModSetup->>ModSetup: Override Value = 4
    end
    ModSetup->>FormMain: Apply HMCL title logo mode
    FormMain-->>User: Show HMCL logo and help button
  else IsAprilFool == false and CurrentTheme == HmclBlue
    ThemeService->>ThemeService: CurrentTheme = CatBlue
  end
Loading

愚人节 HMCL 主题集成的类图

classDiagram

class Basics {
  +string VersionBranch
  +bool IsAprilFool
}

class ColorTheme {
  <<enumeration>>
  SkyBlue
  CatBlue
  DeathBlue
  HmclBlue
}

class Config {
}

class ThemePreference {
  +ColorTheme LightColor
  +ColorTheme DarkColor
  +ConfigItem LightColorConfig
  +ConfigItem DarkColorConfig
}

class WindowPreference {
  +ConfigItem WindowTitleTypeConfig
  +string WindowTitleCustomText
}

class ThemeService {
  +bool IsDarkMode
  +ColorTheme CurrentTheme
  +event ColorThemeChanged(ColorTheme theme)
  +event ColorModeChanged(bool isDark, ColorTheme theme)
  +void ApplyColorResources()
  +void ApplyGrayResources()
  +static (int Hue, double LightAdjust, double ChromaAdjust) GetCurrentThemeColorConfig()
  -static void _RefreshAll()
  -static void _AprilFoolLogic()
}

class PageSetupUI {
  +bool IsLoaded
  +string[] ThemeColors
}

class ModSetup {
  +void UiLogoType(int Value)
}

class FormMain {
  +object ShapeTitleLogo
  +object ShapeHMCLTitleLogo
  +object LabTitleLogo
  +object ImageTitleLogo
  +object ImageHMCLTitleLogo
  +object BtnTitleHelp
  +void BtnTitleHelp_Click()
}

class ConfigItem {
  +void SetValue(ColorTheme value)
  +void TriggerEvent(ConfigEvent evt, object args)
}

Config <|.. ThemePreference
Config <|.. WindowPreference

ThemePreference --> ColorTheme
WindowPreference --> ConfigItem
ThemeService --> Basics : uses
ThemeService --> ThemePreference : uses
ThemeService --> WindowPreference : uses
ThemeService --> ColorTheme : manages
PageSetupUI --> Basics : checks IsAprilFool
PageSetupUI --> ColorTheme : uses HmclBlue index
ModSetup --> ThemeService : reads CurrentTheme
ModSetup --> FormMain : toggles title controls
FormMain --> Basics : implicit (app-wide utility)
ConfigItem ..> ColorTheme : SetValue
Loading

文件级变更

Change Details Files
Add April Fools date detection and guard HMCL theme usage to April 1st only.
  • 基于当前日期新增 Basics.IsAprilFool 辅助方法。
  • 在主题颜色刷新或变更时调用愚人节相关逻辑。
  • 在非愚人节日期,自动将任何处于激活状态的 HMCL 主题映射回 CatBlue,并修正设置状态中已持久化的 HMCL 选项。
PCL.Core/App/Basics.cs
PCL.Core/UI/Theme/ThemeService.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml.vb
Extend the color theme system with the HMCL blue variant and its appearance parameters.
  • ColorTheme 枚举中添加 HmclBlue 以用于配置存储。
  • 在主题解析中为 HmclBlue 定义色相/亮度/色度参数,并调整调试用的回退值。
  • 仅在愚人节于设置界面中额外暴露 HMCL 主题选项。
PCL.Core/App/ConfigEnums.cs
PCL.Core/UI/Theme/ThemeService.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml.vb
Integrate an HMCL-specific title logo mode that is automatically selected under the HMCL theme and wired to April Fools logic.
  • 在 Logo 选择逻辑中,将 HMCL 颜色主题映射到专用的标题 Logo 模式值。
  • 定义 HMCL Logo 模式:显示 HMCL Logo 相关视觉元素及帮助按钮,同时隐藏其他 Logo 控件及自定义面板。
  • 确保其他 Logo 模式显式隐藏 HMCL 专用元素,以避免状态冲突。
Plain Craft Launcher 2/Modules/Base/ModSetup.vb
Plain Craft Launcher 2/FormMain.xaml
Plain Craft Launcher 2/FormMain.xaml.vb
Minor config and UI wiring adjustments to support the new behavior cleanly.
  • 为提高清晰度重命名窗口标题文本配置属性,但不改变其底层键名。
  • 将帮助按钮连接至 HMCL 相关的外部链接。
  • 调整主窗体和设置页的 XAML,以添加 HMCL Logo/控件,并与新模式对齐。
PCL.Core/App/Config.cs
Plain Craft Launcher 2/FormMain.xaml.vb
Plain Craft Launcher 2/FormMain.xaml
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml

Tips and commands

与 Sourcery 交互

  • 触发新的评审: 在 Pull Request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的评审评论即可继续讨论。
  • 从评审评论生成 GitHub Issue: 在评审评论下回复,要求 Sourcery 基于该评论创建 Issue。你也可以直接回复 @sourcery-ai issue,从该评论创建 Issue。
  • 生成 Pull Request 标题: 在 Pull Request 标题中任意位置写上 @sourcery-ai 即可随时生成标题。也可以在 Pull Request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 Pull Request 摘要: 在 Pull Request 描述正文中任意位置写上 @sourcery-ai summary,即可在对应位置生成 PR 摘要。也可以评论 @sourcery-ai summary 来在任意时间(重新)生成摘要。
  • 生成 Reviewer's Guide: 在 Pull Request 中评论 @sourcery-ai guide,即可在任意时间(重新)生成评审指南。
  • 一次性解决所有 Sourcery 评论: 在 Pull Request 中评论 @sourcery-ai resolve,可将所有 Sourcery 评论标记为已解决。适用于你已经处理完所有评论且不希望再看到它们的情况。
  • 一次性忽略所有 Sourcery 评审: 在 Pull Request 中评论 @sourcery-ai dismiss,可忽略所有现有的 Sourcery 评审。特别适合你希望从头开始新的评审流程时——别忘了再评论一次 @sourcery-ai review 以触发新的评审!

自定义你的使用体验

访问你的 控制台 以:

  • 启用或禁用评审功能,例如 Sourcery 自动生成的 Pull Request 摘要、评审指南等。
  • 更改评审语言。
  • 添加、移除或编辑自定义评审指令。
  • 调整其他评审相关设置。

获取帮助

Original review guide in English

Reviewer's Guide

Implements an April Fools–only HMCL blue theme (including title-bar logo mode, theme hue/chroma, and setup UI exposure), wires it into the central theme service with date-based logic, and ensures HMCL-related settings are reset or hidden outside April 1st while guarding redundant theme updates.

Sequence diagram for April Fools HMCL theme application

sequenceDiagram
  participant User
  participant PageSetupUI
  participant ConfigTheme as Config.ThemePreference
  participant ThemeService
  participant ConfigWindow as Config.WindowPreference
  participant ModSetup
  participant FormMain
  participant Basics

  User->>PageSetupUI: Open settings page
  PageSetupUI->>Basics: Check IsAprilFool
  alt IsAprilFool == true
    PageSetupUI-->>User: Show theme options [SkyBlue, CatBlue, DeathBlue, HMCL]
  else IsAprilFool == false
    PageSetupUI->>ConfigTheme: Ensure UiDarkColor != HmclBlue
    PageSetupUI->>ConfigTheme: Ensure UiLightColor != HmclBlue
    PageSetupUI-->>User: Show theme options [SkyBlue, CatBlue, DeathBlue]
  end

  User->>ConfigTheme: Select HMCL theme (April 1st)
  ConfigTheme->>ThemeService: Trigger color config changed

  ThemeService->>ThemeService: Validate change and mode
  ThemeService->>ThemeService: ApplyColorResources()
  ThemeService-->>User: ColorThemeChanged(CurrentTheme)
  ThemeService->>ThemeService: _AprilFoolLogic()

  alt IsAprilFool == true
    ThemeService->>ConfigWindow: WindowTitleTypeConfig.TriggerEvent(Changed)
    ConfigWindow->>ModSetup: UiLogoType(current value)
    ModSetup->>ThemeService: Read CurrentTheme
    alt CurrentTheme == HmclBlue
      ModSetup->>ModSetup: Override Value = 4
    end
    ModSetup->>FormMain: Apply HMCL title logo mode
    FormMain-->>User: Show HMCL logo and help button
  else IsAprilFool == false and CurrentTheme == HmclBlue
    ThemeService->>ThemeService: CurrentTheme = CatBlue
  end
Loading

Class diagram for April Fools HMCL theme integration

classDiagram

class Basics {
  +string VersionBranch
  +bool IsAprilFool
}

class ColorTheme {
  <<enumeration>>
  SkyBlue
  CatBlue
  DeathBlue
  HmclBlue
}

class Config {
}

class ThemePreference {
  +ColorTheme LightColor
  +ColorTheme DarkColor
  +ConfigItem LightColorConfig
  +ConfigItem DarkColorConfig
}

class WindowPreference {
  +ConfigItem WindowTitleTypeConfig
  +string WindowTitleCustomText
}

class ThemeService {
  +bool IsDarkMode
  +ColorTheme CurrentTheme
  +event ColorThemeChanged(ColorTheme theme)
  +event ColorModeChanged(bool isDark, ColorTheme theme)
  +void ApplyColorResources()
  +void ApplyGrayResources()
  +static (int Hue, double LightAdjust, double ChromaAdjust) GetCurrentThemeColorConfig()
  -static void _RefreshAll()
  -static void _AprilFoolLogic()
}

class PageSetupUI {
  +bool IsLoaded
  +string[] ThemeColors
}

class ModSetup {
  +void UiLogoType(int Value)
}

class FormMain {
  +object ShapeTitleLogo
  +object ShapeHMCLTitleLogo
  +object LabTitleLogo
  +object ImageTitleLogo
  +object ImageHMCLTitleLogo
  +object BtnTitleHelp
  +void BtnTitleHelp_Click()
}

class ConfigItem {
  +void SetValue(ColorTheme value)
  +void TriggerEvent(ConfigEvent evt, object args)
}

Config <|.. ThemePreference
Config <|.. WindowPreference

ThemePreference --> ColorTheme
WindowPreference --> ConfigItem
ThemeService --> Basics : uses
ThemeService --> ThemePreference : uses
ThemeService --> WindowPreference : uses
ThemeService --> ColorTheme : manages
PageSetupUI --> Basics : checks IsAprilFool
PageSetupUI --> ColorTheme : uses HmclBlue index
ModSetup --> ThemeService : reads CurrentTheme
ModSetup --> FormMain : toggles title controls
FormMain --> Basics : implicit (app-wide utility)
ConfigItem ..> ColorTheme : SetValue
Loading

File-Level Changes

Change Details Files
Add April Fools date detection and guard HMCL theme usage to April 1st only.
  • Introduce a Basics.IsAprilFool helper based on current date.
  • Invoke April Fools logic whenever theme colors are refreshed or changed.
  • On non–April Fools days, automatically remap any active HMCL theme back to CatBlue and fix persisted HMCL selections in setup state.
PCL.Core/App/Basics.cs
PCL.Core/UI/Theme/ThemeService.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml.vb
Extend the color theme system with the HMCL blue variant and its appearance parameters.
  • Add HmclBlue to the ColorTheme enum for configuration storage.
  • Define hue/lightness/chroma parameters for HmclBlue in theme resolution, adjusting debug fallback values.
  • Expose HMCL as an extra theme option in the setup UI only on April Fools Day.
PCL.Core/App/ConfigEnums.cs
PCL.Core/UI/Theme/ThemeService.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml.vb
Integrate an HMCL-specific title logo mode that is automatically selected under the HMCL theme and wired to April Fools logic.
  • Map the HMCL color theme to a dedicated title logo mode value in the logo selection logic.
  • Define the HMCL logo mode to show the HMCL logo visuals and a help button while hiding other logo controls and customization panes.
  • Ensure other logo modes explicitly hide HMCL-specific elements to avoid conflicting states.
Plain Craft Launcher 2/Modules/Base/ModSetup.vb
Plain Craft Launcher 2/FormMain.xaml
Plain Craft Launcher 2/FormMain.xaml.vb
Minor config and UI wiring adjustments to support the new behavior cleanly.
  • Rename the window title text config property for clarity without changing its underlying key.
  • Wire the help button to open the HMCL-related external link.
  • Adjust XAML for main form and setup UI pages to add HMCL logo/controls and align with the new modes.
PCL.Core/App/Config.cs
Plain Craft Launcher 2/FormMain.xaml.vb
Plain Craft Launcher 2/FormMain.xaml
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@SALTWOOD
Copy link
Copy Markdown
Member

🤔好怪,让我仔细品味

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - 我发现了两个问题,并给出了一些总体反馈:

  • IsAprilFool/IsAprilFool() 在 ThemeService 和 FormMain 中分别实现;建议将这部分逻辑集中到一个共享的辅助方法中,以避免重复实现和未来可能出现的不一致。
  • ThemeService.OnColorThemeConfigChanged 处理函数现在包含嵌套的愚人节和深色/浅色模式判断;可以考虑把这部分决策逻辑提取到一个小的辅助方法中(例如,用来判断哪些配置键是相关的),这样会更容易理解和维护。
  • 两处 IsAprilFool 实现都直接依赖 DateTime.Now;如果你预计需要模拟或覆盖这一行为(例如在非愚人节场景下做受控的行为),建议注入一个时钟或把日期访问封装到一个可重写/静态的提供者中。
面向 AI 代理的提示
Please address the comments from this code review:

## Overall Comments
- IsAprilFool/IsAprilFool() is implemented separately in ThemeService and FormMain; consider centralizing this logic in a single shared helper to avoid duplication and potential divergence.
- ThemeService.OnColorThemeConfigChanged handler now contains nested April Fools and dark/light mode checks; extracting this decision logic into a small helper (e.g., to determine which config keys are relevant) would make it easier to understand and maintain.
- Both IsAprilFool implementations rely directly on DateTime.Now; if you anticipate needing to simulate or override this behavior (e.g., for controlled behavior in non-April contexts), consider injecting a clock or wrapping the date access in a single overridable/static provider.

## Individual Comments

### Comment 1
<location path="PCL.Core/UI/Theme/ThemeService.cs" line_range="39-48" />
<code_context>
     public static ConfigEventRegistry OnColorThemeConfigChanged => new(
-        scope: [Config.Preference.Theme.DarkColorConfig, Config.Preference.Theme.LightColorConfig],
-        trigger: ConfigEvent.Update,
-        handler: e =>
+    scope: [
+        Config.Preference.Theme.DarkColorConfig,
+        Config.Preference.Theme.LightColorConfig,
+        Config.Preference.Theme.DarkColorFoolConfig,
+        Config.Preference.Theme.LightColorFoolConfig
+    ],
+    trigger: ConfigEvent.Update,
+    handler: e =>
+    {
+        if (e.OldValue == e.Value) return;
+
+        if (IsAprilFool())
+        {
+            if (IsDarkMode) { if (e.Item == Config.Preference.Theme.LightColorFoolConfig) return; }
+            else { if (e.Item == Config.Preference.Theme.DarkColorFoolConfig) return; }
+        }
+        else
         {
</code_context>
<issue_to_address>
**suggestion:** Consider simplifying the April Fools / normal theme branch logic in the config change handler.

The nested `if` chain (`IsAprilFool``IsDarkMode``e.Item`) is hard to follow and will get more fragile as additional theme configs are added. Consider extracting a helper like `IsRelevantThemeConfig(e.Item)` or flattening into combined conditions so it’s clearer which keys are ignored for each mode/date and easier to keep the logic consistent over time.
</issue_to_address>

### Comment 2
<location path="PCL.Core/UI/Theme/ThemeService.cs" line_range="253" />
<code_context>
         foreach (var c in colors) c.Apply();
     }
+
+    public static bool IsAprilFool()
+    {
+        return DateTime.Now.Month == 4 && DateTime.Now.Day == 1;
</code_context>
<issue_to_address>
**suggestion:** Avoid duplicating the April Fools date check logic across different classes.

There’s already an `IsAprilFool` implementation in `FormMain` with the same logic. Having two separate helpers that control theme behavior risks them diverging if the logic changes (e.g., different time base, test overrides, time zones). Consider centralizing this check (e.g., in `ThemeService` or a shared utility) and using that single source of truth everywhere.

Suggested implementation:

```csharp
    /// <summary>
    /// Centralized check for whether it is April Fools' Day.
    /// All theme / UI logic should rely on this single helper.
    /// </summary>
    public static bool IsAprilFool()
    {
        return DateTime.Now.Month == 4 && DateTime.Now.Day == 1;
    }

```

To fully implement the suggestion and avoid duplication:
1. Remove the existing `IsAprilFool` implementation from `FormMain` (or any other class that defines it).
2. Update all call sites that currently use `FormMain.IsAprilFool()` (or any other duplicate) to call `ThemeService.IsAprilFool()` instead.
3. If there are unit tests that reference the old location, update them to use `ThemeService.IsAprilFool()` as the single source of truth.
</issue_to_address>

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,请考虑分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈来改进后续的评审。
Original comment in English

Hey - I've found 2 issues, and left some high level feedback:

  • IsAprilFool/IsAprilFool() is implemented separately in ThemeService and FormMain; consider centralizing this logic in a single shared helper to avoid duplication and potential divergence.
  • ThemeService.OnColorThemeConfigChanged handler now contains nested April Fools and dark/light mode checks; extracting this decision logic into a small helper (e.g., to determine which config keys are relevant) would make it easier to understand and maintain.
  • Both IsAprilFool implementations rely directly on DateTime.Now; if you anticipate needing to simulate or override this behavior (e.g., for controlled behavior in non-April contexts), consider injecting a clock or wrapping the date access in a single overridable/static provider.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- IsAprilFool/IsAprilFool() is implemented separately in ThemeService and FormMain; consider centralizing this logic in a single shared helper to avoid duplication and potential divergence.
- ThemeService.OnColorThemeConfigChanged handler now contains nested April Fools and dark/light mode checks; extracting this decision logic into a small helper (e.g., to determine which config keys are relevant) would make it easier to understand and maintain.
- Both IsAprilFool implementations rely directly on DateTime.Now; if you anticipate needing to simulate or override this behavior (e.g., for controlled behavior in non-April contexts), consider injecting a clock or wrapping the date access in a single overridable/static provider.

## Individual Comments

### Comment 1
<location path="PCL.Core/UI/Theme/ThemeService.cs" line_range="39-48" />
<code_context>
     public static ConfigEventRegistry OnColorThemeConfigChanged => new(
-        scope: [Config.Preference.Theme.DarkColorConfig, Config.Preference.Theme.LightColorConfig],
-        trigger: ConfigEvent.Update,
-        handler: e =>
+    scope: [
+        Config.Preference.Theme.DarkColorConfig,
+        Config.Preference.Theme.LightColorConfig,
+        Config.Preference.Theme.DarkColorFoolConfig,
+        Config.Preference.Theme.LightColorFoolConfig
+    ],
+    trigger: ConfigEvent.Update,
+    handler: e =>
+    {
+        if (e.OldValue == e.Value) return;
+
+        if (IsAprilFool())
+        {
+            if (IsDarkMode) { if (e.Item == Config.Preference.Theme.LightColorFoolConfig) return; }
+            else { if (e.Item == Config.Preference.Theme.DarkColorFoolConfig) return; }
+        }
+        else
         {
</code_context>
<issue_to_address>
**suggestion:** Consider simplifying the April Fools / normal theme branch logic in the config change handler.

The nested `if` chain (`IsAprilFool``IsDarkMode``e.Item`) is hard to follow and will get more fragile as additional theme configs are added. Consider extracting a helper like `IsRelevantThemeConfig(e.Item)` or flattening into combined conditions so it’s clearer which keys are ignored for each mode/date and easier to keep the logic consistent over time.
</issue_to_address>

### Comment 2
<location path="PCL.Core/UI/Theme/ThemeService.cs" line_range="253" />
<code_context>
         foreach (var c in colors) c.Apply();
     }
+
+    public static bool IsAprilFool()
+    {
+        return DateTime.Now.Month == 4 && DateTime.Now.Day == 1;
</code_context>
<issue_to_address>
**suggestion:** Avoid duplicating the April Fools date check logic across different classes.

There’s already an `IsAprilFool` implementation in `FormMain` with the same logic. Having two separate helpers that control theme behavior risks them diverging if the logic changes (e.g., different time base, test overrides, time zones). Consider centralizing this check (e.g., in `ThemeService` or a shared utility) and using that single source of truth everywhere.

Suggested implementation:

```csharp
    /// <summary>
    /// Centralized check for whether it is April Fools' Day.
    /// All theme / UI logic should rely on this single helper.
    /// </summary>
    public static bool IsAprilFool()
    {
        return DateTime.Now.Month == 4 && DateTime.Now.Day == 1;
    }

```

To fully implement the suggestion and avoid duplication:
1. Remove the existing `IsAprilFool` implementation from `FormMain` (or any other class that defines it).
2. Update all call sites that currently use `FormMain.IsAprilFool()` (or any other duplicate) to call `ThemeService.IsAprilFool()` instead.
3. If there are unit tests that reference the old location, update them to use `ThemeService.IsAprilFool()` as the single source of truth.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread PCL.Core/UI/Theme/ThemeService.cs Outdated
Comment thread PCL.Core/UI/Theme/ThemeService.cs Outdated
Copy link
Copy Markdown
Contributor

@tangge233 tangge233 left a comment

Choose a reason for hiding this comment

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

有点复杂了,在当天显示 HMCL 主题选项,其余时候检查主题并做超范围重置工作应该就行了🤔

SALTWOOD
SALTWOOD previously approved these changes Mar 16, 2026
Copy link
Copy Markdown
Member

@SALTWOOD SALTWOOD left a comment

Choose a reason for hiding this comment

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

没想到你有这等实力

@pcl-ce-automation pcl-ce-automation Bot added size: M PR 大小评估:中型 and removed size: L PR 大小评估:大型 labels Mar 17, 2026
@LuLu-ling LuLu-ling requested a review from a team March 17, 2026 10:43
lhx077
lhx077 previously approved these changes Mar 17, 2026
Comment thread Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml.vb
Comment thread Plain Craft Launcher 2/FormMain.xaml.vb
@pcl-ce-automation pcl-ce-automation Bot added size: S PR 大小评估:小型 and removed size: M PR 大小评估:中型 labels Mar 17, 2026
@LuLu-ling LuLu-ling requested a review from a team March 17, 2026 13:23
lhx077
lhx077 previously requested changes Mar 18, 2026
Comment thread Plain Craft Launcher 2/Modules/Base/ModSetup.vb Outdated
@LuLu-ling LuLu-ling requested a review from a team March 18, 2026 10:40
@pcl-ce-automation pcl-ce-automation Bot added size: L PR 大小评估:大型 size: M PR 大小评估:中型 and removed size: S PR 大小评估:小型 size: L PR 大小评估:大型 labels Mar 18, 2026
ruattd
ruattd previously approved these changes Mar 19, 2026
@ruattd ruattd dismissed lhx077’s stale review March 19, 2026 04:58

Invalid problem.

@LuLu-ling LuLu-ling requested a review from a team March 19, 2026 10:30
@tangge233
Copy link
Copy Markdown
Contributor

@sourcery-ai review

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - 我已经给出了一些整体层面的反馈:

  • 当前愚人节相关逻辑分散在多个地方(ThemeService._AprilFoolLogic、PageSetupUI.ThemeColors、PageSetupUI_Loaded、UiLogoType、Basics.IsAprilFool);建议把这个功能开关逻辑集中到一个地方(例如单独的 helper 或 service),以避免重复检查,也便于将来下线或修改。
  • 在 ThemeService._AprilFoolLogic 中,直接修改 CurrentTheme 并触发 WindowTitleTypeConfig 事件,会在主题选择和标题栏 UI 之间形成隐式耦合;建议将这些操作封装到一个更高层级的 "ApplyAprilFoolUiState" 方法中,让这些副作用更加显式、易于理解。
  • ColorTheme.HmclBlue 回退到 CatBlue 的特殊处理同时出现在 ThemeService._AprilFoolLogic 和 PageSetupUI_Loaded 中;如果把这种重置行为统一放在一个地方(例如 ThemeService 或某个 helper 中),可以降低规则变更时出现状态不一致的风险。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- The April Fools behavior is currently scattered (ThemeService._AprilFoolLogic, PageSetupUI.ThemeColors, PageSetupUI_Loaded, UiLogoType, Basics.IsAprilFool); consider centralizing the feature toggle logic (e.g., a single helper or service) to avoid duplicated checks and make future removal/changes easier.
- In ThemeService._AprilFoolLogic, directly mutating CurrentTheme and triggering WindowTitleTypeConfig events creates hidden coupling between theme selection and title-bar UI; consider encapsulating this in a higher-level "ApplyAprilFoolUiState" method so the side effects are explicit and easier to reason about.
- The special handling of ColorTheme.HmclBlue fallback to CatBlue appears in both ThemeService._AprilFoolLogic and PageSetupUI_Loaded; unifying this reset behavior in a single place (e.g., ThemeService or a helper) would reduce the chance of inconsistent state if the rules change.

Sourcery 对开源项目是免费的——如果你觉得这次 review 有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈来改进之后的 review。
Original comment in English

Hey - I've left some high level feedback:

  • The April Fools behavior is currently scattered (ThemeService._AprilFoolLogic, PageSetupUI.ThemeColors, PageSetupUI_Loaded, UiLogoType, Basics.IsAprilFool); consider centralizing the feature toggle logic (e.g., a single helper or service) to avoid duplicated checks and make future removal/changes easier.
  • In ThemeService._AprilFoolLogic, directly mutating CurrentTheme and triggering WindowTitleTypeConfig events creates hidden coupling between theme selection and title-bar UI; consider encapsulating this in a higher-level "ApplyAprilFoolUiState" method so the side effects are explicit and easier to reason about.
  • The special handling of ColorTheme.HmclBlue fallback to CatBlue appears in both ThemeService._AprilFoolLogic and PageSetupUI_Loaded; unifying this reset behavior in a single place (e.g., ThemeService or a helper) would reduce the chance of inconsistent state if the rules change.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The April Fools behavior is currently scattered (ThemeService._AprilFoolLogic, PageSetupUI.ThemeColors, PageSetupUI_Loaded, UiLogoType, Basics.IsAprilFool); consider centralizing the feature toggle logic (e.g., a single helper or service) to avoid duplicated checks and make future removal/changes easier.
- In ThemeService._AprilFoolLogic, directly mutating CurrentTheme and triggering WindowTitleTypeConfig events creates hidden coupling between theme selection and title-bar UI; consider encapsulating this in a higher-level "ApplyAprilFoolUiState" method so the side effects are explicit and easier to reason about.
- The special handling of ColorTheme.HmclBlue fallback to CatBlue appears in both ThemeService._AprilFoolLogic and PageSetupUI_Loaded; unifying this reset behavior in a single place (e.g., ThemeService or a helper) would reduce the chance of inconsistent state if the rules change.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@pcl-ce-automation pcl-ce-automation Bot added 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 labels Mar 22, 2026
@LuLu-ling LuLu-ling merged commit 9ced6c2 into dev Mar 22, 2026
2 checks passed
@pcl-ce-automation pcl-ce-automation Bot added 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线 and removed 🕑 等待合并 已处理完毕,正在等待代码合并入主分支 labels Mar 22, 2026
@LuLu-ling LuLu-ling deleted the feat/HMCL branch March 22, 2026 04:09
@LuLu-ling LuLu-ling mentioned this pull request Apr 5, 2026
81 tasks
LuLu-ling added a commit to PCL-Community/PCL-CSharpE that referenced this pull request Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: M PR 大小评估:中型 👌 完成 相关问题已修复或功能已实现,计划在下次版本更新时正式上线

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants