Skip to content

refactor: 使用配置系统全面取代 ModBase.Setup 并移除部分 VB.CompilerServices#2866

Open
LuLu-ling wants to merge 6 commits into
devfrom
refactor/ModBase-Setup
Open

refactor: 使用配置系统全面取代 ModBase.Setup 并移除部分 VB.CompilerServices#2866
LuLu-ling wants to merge 6 commits into
devfrom
refactor/ModBase-Setup

Conversation

@LuLu-ling
Copy link
Copy Markdown
Member

@LuLu-ling LuLu-ling commented May 20, 2026

Partly Generated with DeepSeek-V4-Pro

Summary by Sourcery

重构启动器、UI 和 Minecraft 模块代码,使其使用新的强类型配置系统来替代 ModBase.SetupVB.CompilerServices,引入基于标签的映射辅助方法用于保存设置,并将旧版迁移、校验和下载逻辑与更新后的配置和状态结构对齐。

Enhancements:

  • 在启动、下载、UI 和配置文件等模块中(包括每个实例的设置),用强类型的 Config/ConfigService 访问方式替换 ModBase.Setup 以及 Conversions/Operators 的使用。
  • 在设置页和实例页中新增基于标签的辅助方法,用于将启动器、游戏管理、链接、杂项以及实例选项等 UI 控件映射到特定的配置字段。
  • 通过使用原生 C# API(如 string.CompareOrdinalint.Parsedouble.Parse 等)现代化版本号、UUID 和数值处理逻辑,并简化布尔值判断。
  • 更新旧版迁移、提示标志和事件处理逻辑,使其依赖新的配置元数据和 States 字段,而不是通用的 setup 键,从而在处理加密设置时提高安全性。
Original summary in English

Summary by Sourcery

Refactor launcher, UI, and Minecraft module code to use the new strongly-typed configuration system instead of ModBase.Setup and VB.CompilerServices, introducing tag-based mapping helpers for saving settings and aligning legacy migrations, validation, and download logic with the updated config and state structures.

Enhancements:

  • Replace ModBase.Setup and Conversions/Operators usage with strongly-typed Config/ConfigService access across launch, download, UI, and profile modules, including per-instance settings.
  • Add tag-based helper methods in setup and instance pages to map UI controls to specific config fields for launcher, game management, link, misc, and instance options.
  • Modernize version, UUID, and numeric handling by using native C# APIs (string.CompareOrdinal, int.Parse, double.Parse, etc.) and simplify boolean checks.
  • Update legacy migration, hint flags, and event handling to rely on new config metadata and States fields instead of generic setup keys, improving safety around encrypted settings.

增强内容:

  • 在 UI 页面、事件处理和 Minecraft 模块中,用通过 Config / ConfigService 进行的强类型配置访问(包括对实例级设置的支持),替换对 ModBase.Setup 的直接 get/set/reset 调用。
  • 引入集中化的辅助方法和保护机制用于读取和写入配置值(例如 setup 值解析器、加密设置保护),并更新迁移逻辑以使用配置元数据(IsDefault / Reset / DefaultValue)。
  • 清理已废弃的被注释页面声明,并将提示/可见性检查与基于新配置的状态标记对齐。
Original summary in English

Summary by Sourcery

重构启动器、UI 和 Minecraft 模块代码,使其使用新的强类型配置系统来替代 ModBase.SetupVB.CompilerServices,引入基于标签的映射辅助方法用于保存设置,并将旧版迁移、校验和下载逻辑与更新后的配置和状态结构对齐。

Enhancements:

  • 在启动、下载、UI 和配置文件等模块中(包括每个实例的设置),用强类型的 Config/ConfigService 访问方式替换 ModBase.Setup 以及 Conversions/Operators 的使用。
  • 在设置页和实例页中新增基于标签的辅助方法,用于将启动器、游戏管理、链接、杂项以及实例选项等 UI 控件映射到特定的配置字段。
  • 通过使用原生 C# API(如 string.CompareOrdinalint.Parsedouble.Parse 等)现代化版本号、UUID 和数值处理逻辑,并简化布尔值判断。
  • 更新旧版迁移、提示标志和事件处理逻辑,使其依赖新的配置元数据和 States 字段,而不是通用的 setup 键,从而在处理加密设置时提高安全性。
Original summary in English

Summary by Sourcery

Refactor launcher, UI, and Minecraft module code to use the new strongly-typed configuration system instead of ModBase.Setup and VB.CompilerServices, introducing tag-based mapping helpers for saving settings and aligning legacy migrations, validation, and download logic with the updated config and state structures.

Enhancements:

  • Replace ModBase.Setup and Conversions/Operators usage with strongly-typed Config/ConfigService access across launch, download, UI, and profile modules, including per-instance settings.
  • Add tag-based helper methods in setup and instance pages to map UI controls to specific config fields for launcher, game management, link, misc, and instance options.
  • Modernize version, UUID, and numeric handling by using native C# APIs (string.CompareOrdinal, int.Parse, double.Parse, etc.) and simplify boolean checks.
  • Update legacy migration, hint flags, and event handling to rely on new config metadata and States fields instead of generic setup keys, improving safety around encrypted settings.

@pcl-ce-automation pcl-ce-automation Bot added 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 size: L PR 大小评估:大型 labels May 20, 2026
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 20, 2026

审阅者指南

重构了设置处理逻辑,完全使用新的强类型配置系统来替代 ModBase.Setup;将大量 VB.CompilerServices 的辅助方法替换为惯用的 C# 实现;并将 UI 页面、启动器启动流程、Minecraft 实例/启动逻辑、下载以及事件系统接入新的 Config/ConfigService API,并支持按实例配置。

使用 ConfigService 的 EventType.写入设置 时序图

sequenceDiagram
    participant User as User
    participant CustomEvent as CustomEvent
    participant ModEvent as ModEvent
    participant ConfigService as ConfigService
    participant ConfigItem as ConfigItem

    User->>CustomEvent: trigger event (type=写入设置, arg="key|value")
    CustomEvent->>ModEvent: Raise(type, arg)
    ModEvent->>ModEvent: parse args[0]=key, args[1]=value
    ModEvent->>ConfigService: TryGetConfigItemNoType(key)
    alt [config item found and not SharedEncrypt]
        ConfigService-->>ModEvent: item
        ModEvent->>ConfigItem: SetValueNoType(value, McInstanceSelected.PathInstance)
        ModEvent-->>User: optional hint "已写入设置"
    else [missing or encrypted]
        ModEvent-->>User: no write performed
    end
Loading

文件级变更

Change Details Files
将 Minecraft 启动、配置文件以及下载逻辑中基于 ModBase.Setup 的设置读写替换为强类型的 Config/ConfigService 访问,包括新的枚举以及按实例划分的配置集合。
  • 使用以 PathInstance 为键的 Config.InstanceAuth.* 字典来表示登录需求和认证服务器设置,而不是使用 VersionServerLoginRequire/VersionServerAuthServer 这些 setup 键。
  • 在 JVM 和游戏参数构造以及 RetroWrapper/JLW 开关中,使用 Config.Instance.* 的按实例设置(JvmArgs、GameArgs、DisableRw/Jlw、Renderer、ServerToEnter、TypeInfo 等)。
  • 将基于 ModBase.Setup 的资源校验、渲染器选择以及文件检查开关替换为 Config.Instance 中的布尔值/枚举,并简化 ShouldIgnoreFileCheck 使其仅返回 bool。
  • 在 ModLaunch、ModMinecraft、ModDownload 和 ModProfile 中,将大量 VB 风格的 Conversions/Operators 使用(如字符串比较、解析、布尔逻辑)简化为惯用的 C# 方法和枚举。
Plain Craft Launcher 2/Modules/Minecraft/ModLaunch.cs
Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.cs
Plain Craft Launcher 2/Modules/Minecraft/ModDownload.cs
Plain Craft Launcher 2/Modules/Minecraft/ModProfile.cs
重构启动器和实例设置 UI 页面,使其通过基于 Tag 的分发辅助方法直接绑定到 Config.* 结构,而不是通用的 ModBase.Setup,并为每个区域提供 SetByTag 辅助方法。
  • PageSetupUI 现在直接读写 Config.Preference 中的主题、字体、模糊、背景、音乐、主页以及可见性标志,并使用 SetByTag 辅助方法处理滑块、下拉框、复选框、文本框和单选框。
  • PageInstanceSetup 现在使用 Config.Instance 和 Config.InstanceAuth 来处理实例 RAM、JvmArgs/GameArgs、预启动命令、资源校验迁移、登录需求以及认证锁定;新的 SetInstanceByTag 辅助方法集中管理从 Tag 到配置字段的映射。
  • PageSetupLaunch、PageSetupGameManage、PageSetupLauncherMisc 和 PageSetupGameLink 各自引入 Set*ByTag 辅助方法,将其 XAML Tag 键映射到 Config.Launch、Config.Download、Config.System/Debug/Network 以及 Config.Link 对应的属性。
  • 这些页面中的重新加载和事件处理程序,现在在切换 UI 状态时使用枚举(GameWindowSizeMode、LauncherVisibility、GameProcessPriority 等),而不是整数“魔法值”。
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml.cs
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceSetup.xaml.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupLaunch.xaml.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupGameManage.xaml.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupLauncherMisc.xaml.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupGameLink.xaml.cs
移除 ModSetup 中通用的 ModBase.Setup 辅助方法,改为基于 Config 的特定 UI 行为辅助方法(logo、主页类型等),并更新启动和升级流程以使用配置元数据。
  • 删除 ModSetup.Set/Get/Reset/IsUnset 以及相关的 Safe 变体;保留 GetConfigItem,并新增静态 UiCustomType/UiLogoType/UiLogoText/UiLogoLeft,用于根据 Config.Preference 驱动 UI。
  • FormMain 启动时现在通过 Config.* 初始化基于配置驱动的设置,并在版本隔离迁移时使用 Config.Launch.IndieSolutionV2Config.IsDefault/Reset,而不是 ModBase.Setup.IsUnset/Reset。
  • 升级逻辑通过 Config.* 的元数据,而不是 ModBase.Setup,来迁移旧的 Mod 命名和独立设置。
  • 应用启动时使用 Config.Debug/Network/Download/Preference 预加载关键设置,而不是调用 ModBase.Setup.Load。
Plain Craft Launcher 2/Modules/Base/ModSetup.cs
Plain Craft Launcher 2/FormMain.xaml.cs
Plain Craft Launcher 2/Application.xaml.cs
调整事件、提示以及参数替换基础设施,使其基于 ConfigService 和新的状态标志而不是 ModBase.Setup,并更新提示持久化逻辑。
  • ModEvent.Raise 通过 ConfigService.TryGetConfigItemNoType 写入设置,并阻止对 SharedEncrypt 项的写入,而不是使用 ModBase.Setup.SetSafe;主页命令确认使用 States.Hint.HomepageCommand,而不是 HintCustomCommand 设置键。
  • ModMain.ArgumentReplace 现在通过 ConfigService.TryGetConfigItemNoType 解析 {setup:...} 占位符,并遵守加密配置源的限制。
  • MyHint 控件现在通过 ConfigService 而非 ModBase.Setup 来检查/更新提示关闭状态。
  • 日志右侧面板中的 MaxLog 滑块现在直接写入 Config.System.MaxGameLog,而不是使用 ModBase.Setup.Set。
Plain Craft Launcher 2/Modules/ModEvent.cs
Plain Craft Launcher 2/Modules/ModMain.cs
Plain Craft Launcher 2/Controls/MyHint.xaml.cs
Plain Craft Launcher 2/Pages/PageLogRight.xaml.cs
在核心模块中对 VB.CompilerServices 使用进行杂项清理,并修复了一些小的行为问题。
  • 在 ModMinecraft、ModDownload、ModProfile、ModLaunch 以及部分 UI 代码中,将 Microsoft.VisualBasic.Conversions 和 Operators 的使用替换为原生 C# 运算符/方法(string.CompareOrdinal、int.Parse、double.Parse、long.Parse、Equals 等)。
  • 修正类型签名,使其返回具体类型(例如 IsProfileValid 现在返回 string,ShouldIgnoreFileCheck 返回 bool),并相应更新调用方。
  • 简化 ModMinecraft/ModProfile 中的 UUID 和版本格式化/比较逻辑,移除 VB 风格的字符串拼接和比较。
  • 直接使用 Config.Debug.AddRandomDelay 以及其他强类型开关,并调整默认值/迁移路径(例如 Java 选择重置、渲染器提示标志),使其依赖 Config/States 而非 ModBase.Setup。
Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.cs
Plain Craft Launcher 2/Modules/Minecraft/ModDownload.cs
Plain Craft Launcher 2/Modules/Minecraft/ModProfile.cs
Plain Craft Launcher 2/Modules/Minecraft/ModLaunch.cs
Plain Craft Launcher 2/Modules/Minecraft/ModJava.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml.cs
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceSetup.xaml.cs
Plain Craft Launcher 2/Modules/Base/ModBase.cs

可能关联的 Issue

  • #0: 本 PR 将 ModBase.Setup 调用迁移到新的 Config 系统,是该重构占位 issue 的具体实现。

技巧与指令

与 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 摘要。你也可以在 Pull Request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审阅者指南: 在 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

Refactors settings handling to fully use the new typed configuration system instead of ModBase.Setup, replaces many VB.CompilerServices helpers with idiomatic C#, and wires UI pages, launcher startup, Minecraft instance/launch logic, downloads, and events to the new Config/ConfigService APIs with per-instance support.

Sequence diagram for EventType.写入设置 using ConfigService

sequenceDiagram
    participant User as User
    participant CustomEvent as CustomEvent
    participant ModEvent as ModEvent
    participant ConfigService as ConfigService
    participant ConfigItem as ConfigItem

    User->>CustomEvent: trigger event (type=写入设置, arg="key|value")
    CustomEvent->>ModEvent: Raise(type, arg)
    ModEvent->>ModEvent: parse args[0]=key, args[1]=value
    ModEvent->>ConfigService: TryGetConfigItemNoType(key)
    alt [config item found and not SharedEncrypt]
        ConfigService-->>ModEvent: item
        ModEvent->>ConfigItem: SetValueNoType(value, McInstanceSelected.PathInstance)
        ModEvent-->>User: optional hint "已写入设置"
    else [missing or encrypted]
        ModEvent-->>User: no write performed
    end
Loading

File-Level Changes

Change Details Files
Replace ModBase.Setup-based settings reads/writes in Minecraft launch, profile, and download logic with strongly typed Config/ConfigService access, including new enums and per-instance config collections.
  • Use Config.InstanceAuth.* dictionaries keyed by PathInstance for login requirement and auth server settings instead of VersionServerLoginRequire/VersionServerAuthServer setup keys.
  • Use Config.Instance.* per-instance settings (JvmArgs, GameArgs, DisableRw/Jlw, Renderer, ServerToEnter, TypeInfo, etc.) in JVM and game argument construction and RetroWrapper/JLW toggles.
  • Replace ModBase.Setup-based asset verification, renderer selection, and file-check toggles with Config.Instance booleans/enums and simplify ShouldIgnoreFileCheck to return bool.
  • Simplify many VB-style Conversions/Operators usage (e.g., string comparisons, parsing, bool logic) to idiomatic C# methods and enums in ModLaunch, ModMinecraft, ModDownload, and ModProfile.
Plain Craft Launcher 2/Modules/Minecraft/ModLaunch.cs
Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.cs
Plain Craft Launcher 2/Modules/Minecraft/ModDownload.cs
Plain Craft Launcher 2/Modules/Minecraft/ModProfile.cs
Refactor launcher and instance setup UI pages to bind directly to Config.* structures via tag-based dispatch helpers instead of generic ModBase.Setup, with per-section SetByTag helpers.
  • PageSetupUI now reads/writes Config.Preference theme, font, blur, background, music, homepage, and visibility flags directly and uses a SetByTag helper for sliders, combos, checkboxes, textboxes, and radioboxes.
  • PageInstanceSetup now uses Config.Instance and Config.InstanceAuth for instance RAM, JvmArgs/GameArgs, pre-launch commands, asset verification migration, login requirement, and auth lock; new SetInstanceByTag helper centralizes mapping from tags to config fields.
  • PageSetupLaunch, PageSetupGameManage, PageSetupLauncherMisc, and PageSetupGameLink each introduce Set*ByTag helpers to map their XAML Tag keys to Config.Launch, Config.Download, Config.System/Debug/Network, and Config.Link properties respectively.
  • Reload and event handlers in these pages now reference enums (GameWindowSizeMode, LauncherVisibility, GameProcessPriority, etc.) instead of integer magic values when switching UI states.
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml.cs
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceSetup.xaml.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupLaunch.xaml.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupGameManage.xaml.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupLauncherMisc.xaml.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupGameLink.xaml.cs
Remove generic ModBase.Setup helper methods in ModSetup and move to direct Config-based helpers for specific UI behaviors (logo, homepage type), plus update startup and upgrade flows to use config metadata.
  • Delete ModSetup.Set/Get/Reset/IsUnset and related Safe variants; retain GetConfigItem and add static UiCustomType/UiLogoType/UiLogoText/UiLogoLeft that drive UI from Config.Preference.
  • FormMain startup now initializes config-driven settings via Config.* and uses Config.Launch.IndieSolutionV2Config.IsDefault/Reset instead of ModBase.Setup.IsUnset/Reset for version isolation migration.
  • Upgrade logic migrates old Mod naming and indie settings using Config.* metadata instead of ModBase.Setup.
  • Application startup uses Config.Debug/Network/Download/Preference to pre-load key settings instead of calling ModBase.Setup.Load.
Plain Craft Launcher 2/Modules/Base/ModSetup.cs
Plain Craft Launcher 2/FormMain.xaml.cs
Plain Craft Launcher 2/Application.xaml.cs
Adjust event, hint, and argument replacement infrastructure to operate on ConfigService and new state flags instead of ModBase.Setup, and update hint persistence.
  • ModEvent.Raise writes settings via ConfigService.TryGetConfigItemNoType and blocks SharedEncrypt items instead of ModBase.Setup.SetSafe; homepage command confirmation uses States.Hint.HomepageCommand instead of HintCustomCommand setup key.
  • ModMain.ArgumentReplace now resolves {setup:...} placeholders via ConfigService.TryGetConfigItemNoType and respects encrypted config sources.
  • MyHint control now checks/updates hint-dismiss state via ConfigService rather than ModBase.Setup.
  • Log-right panel MaxLog slider writes directly to Config.System.MaxGameLog instead of ModBase.Setup.Set.
Plain Craft Launcher 2/Modules/ModEvent.cs
Plain Craft Launcher 2/Modules/ModMain.cs
Plain Craft Launcher 2/Controls/MyHint.xaml.cs
Plain Craft Launcher 2/Pages/PageLogRight.xaml.cs
Miscellaneous cleanup of VB.CompilerServices usage and minor behavior fixes in core modules.
  • Replace Microsoft.VisualBasic.Conversions and Operators usages with native C# operators/methods (string.CompareOrdinal, int.Parse, double.Parse, long.Parse, Equals, etc.) across ModMinecraft, ModDownload, ModProfile, ModLaunch, and UI code.
  • Fix type signatures to return concrete types (e.g., IsProfileValid now returns string, ShouldIgnoreFileCheck returns bool) and adjust callers accordingly.
  • Simplify UUID and version formatting/comparison logic in ModMinecraft/ModProfile, removing VB-style concatenation and comparisons.
  • Use Config.Debug.AddRandomDelay and other strongly-typed flags directly, and adjust defaults/migration paths (e.g., Java selection reset, renderer hint flag) to rely on Config/States instead of ModBase.Setup.
Plain Craft Launcher 2/Modules/Minecraft/ModMinecraft.cs
Plain Craft Launcher 2/Modules/Minecraft/ModDownload.cs
Plain Craft Launcher 2/Modules/Minecraft/ModProfile.cs
Plain Craft Launcher 2/Modules/Minecraft/ModLaunch.cs
Plain Craft Launcher 2/Modules/Minecraft/ModJava.cs
Plain Craft Launcher 2/Pages/PageSetup/PageSetupUI.xaml.cs
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceSetup.xaml.cs
Plain Craft Launcher 2/Modules/Base/ModBase.cs

Possibly linked issues

  • #0: PR 将 ModBase.Setup 调用迁移到新的 Config 系统,正是该重构占位 issue 的实现。

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

@LuLu-ling LuLu-ling added the ⚠️ 破坏性 涉及对启动器核心功能有潜在破坏风险的更改,需特别谨慎评估和测试 label May 20, 2026
@LuLu-ling LuLu-ling force-pushed the refactor/ModBase-Setup branch from 8b9c4d3 to 8af4c2a Compare May 21, 2026 09:54
@pcl-ce-automation pcl-ce-automation Bot added size: XL PR 大小评估:超大型 and removed ⚠️ 破坏性 涉及对启动器核心功能有潜在破坏风险的更改,需特别谨慎评估和测试 size: L PR 大小评估:大型 labels May 21, 2026
@LuLu-ling LuLu-ling changed the title refactor: 使用配置系统全面取代 ModBase.Setup refactor: 使用配置系统全面取代 ModBase.Setup 并移除部分 VB.CompilerServices May 21, 2026
@LuLu-ling LuLu-ling marked this pull request as ready for review May 21, 2026 11:25
@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 and removed 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 labels May 21, 2026
@LuLu-ling LuLu-ling requested a review from a team May 21, 2026 11:25
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,我在这里给出了一些整体性的反馈:

  • 在各个 Set*ByTag 辅助方法中(例如 SetByTagSetLaunchByTagSetGameManageByTagSetInstanceByTag),很多分支会把 object value 直接强制转换为 int / double / bool,但调用方(滑块等)往往会传入 double 或可空类型,这可能会抛出 InvalidCastException。建议使用 Convert.ToInt32 / Convert.ToDouble 并结合空值安全处理,而不是直接强转。
  • 新的直接配置 setter 绕过了旧的 ModBase.Setup 事件/副作用机制;对于之前依赖变更回调的选项(例如 logo 类型/标题的更新、一些 UI 刷新操作),请仔细检查:确保在用户修改设置时仍然会调用等价的方法(如 ModSetup.UiLogoType/UiLogoText/UiLogoLeft),而不是只在启动时调用一次。
  • MyHint 中,加载/关闭逻辑现在使用 ConfigService.TryGetConfigItemNoType(...).GetValueNoType() 来决定可见性并持久化关闭状态;请确认对应的配置项在未设置时的状态是 null(或使用 IsDefault),以避免因为非空默认值导致提示在一开始就被隐藏。
给 AI 智能体的提示
Please address the comments from this code review:

## Overall Comments
- In the various `Set*ByTag` helpers (e.g. `SetByTag`, `SetLaunchByTag`, `SetGameManageByTag`, `SetInstanceByTag`), many cases cast `object value` directly to `int`/`double`/`bool`, but the callers (sliders, etc.) often pass a `double` or nullable type, which can throw `InvalidCastException`; consider using `Convert.ToInt32`/`Convert.ToDouble` and null-safe handling instead of direct casts.
- The new direct-config setters bypass the old `ModBase.Setup` event/side-effect mechanism; for options that previously relied on change callbacks (e.g. logo type/title updates, some UI refresh actions), double-check that equivalent calls (like `ModSetup.UiLogoType/UiLogoText/UiLogoLeft`) are still invoked on user changes rather than only at startup.
- In `MyHint`, the loaded/close logic now uses `ConfigService.TryGetConfigItemNoType(...).GetValueNoType()` to decide visibility and persist dismissal; verify that the corresponding config items have `null` as their unset state (or use `IsDefault`) so that hints are not hidden immediately due to a non-null default value.

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

Hey - I've left some high level feedback:

  • In the various Set*ByTag helpers (e.g. SetByTag, SetLaunchByTag, SetGameManageByTag, SetInstanceByTag), many cases cast object value directly to int/double/bool, but the callers (sliders, etc.) often pass a double or nullable type, which can throw InvalidCastException; consider using Convert.ToInt32/Convert.ToDouble and null-safe handling instead of direct casts.
  • The new direct-config setters bypass the old ModBase.Setup event/side-effect mechanism; for options that previously relied on change callbacks (e.g. logo type/title updates, some UI refresh actions), double-check that equivalent calls (like ModSetup.UiLogoType/UiLogoText/UiLogoLeft) are still invoked on user changes rather than only at startup.
  • In MyHint, the loaded/close logic now uses ConfigService.TryGetConfigItemNoType(...).GetValueNoType() to decide visibility and persist dismissal; verify that the corresponding config items have null as their unset state (or use IsDefault) so that hints are not hidden immediately due to a non-null default value.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the various `Set*ByTag` helpers (e.g. `SetByTag`, `SetLaunchByTag`, `SetGameManageByTag`, `SetInstanceByTag`), many cases cast `object value` directly to `int`/`double`/`bool`, but the callers (sliders, etc.) often pass a `double` or nullable type, which can throw `InvalidCastException`; consider using `Convert.ToInt32`/`Convert.ToDouble` and null-safe handling instead of direct casts.
- The new direct-config setters bypass the old `ModBase.Setup` event/side-effect mechanism; for options that previously relied on change callbacks (e.g. logo type/title updates, some UI refresh actions), double-check that equivalent calls (like `ModSetup.UiLogoType/UiLogoText/UiLogoLeft`) are still invoked on user changes rather than only at startup.
- In `MyHint`, the loaded/close logic now uses `ConfigService.TryGetConfigItemNoType(...).GetValueNoType()` to decide visibility and persist dismissal; verify that the corresponding config items have `null` as their unset state (or use `IsDefault`) so that hints are not hidden immediately due to a non-null default value.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: XL PR 大小评估:超大型 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant