Skip to content

refactor(mod-base): 重构 ModBase.cs#3294

Open
Chiloven945 wants to merge 12 commits into
devfrom
refactor/mod-base
Open

refactor(mod-base): 重构 ModBase.cs#3294
Chiloven945 wants to merge 12 commits into
devfrom
refactor/mod-base

Conversation

@Chiloven945

Copy link
Copy Markdown
Member

GPT-5.5 Thinking 辅助并校对

close: #3288

@Chiloven945 Chiloven945 self-assigned this Jul 1, 2026
sourcery-ai[bot]

This comment was marked as abuse.

@pcl-ce-automation pcl-ce-automation Bot added 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 size: XXL PR 大小评估:巨型 labels Jul 1, 2026
# Conflicts:
#	Plain Craft Launcher 2/Modules/Minecraft/ModLocalComp.cs
#	Plain Craft Launcher 2/Modules/Network/Downloader/FileDownloader.cs
@Chiloven945 Chiloven945 marked this pull request as ready for review July 4, 2026 11:27
sourcery-ai[bot]

This comment was marked as abuse.

@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 and removed 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 labels Jul 4, 2026
@Chiloven945 Chiloven945 requested a review from a team July 4, 2026 11:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

progressIncrementHandler?.Invoke((double)copiedFiles / totalFiles);

P2 Badge Keep copy progress callbacks incremental

For modpacks with an override folder containing multiple files, CopyOverrideDirectory still adds the callback value to loader.Progress, matching the old CopyDirectory contract of reporting 1 / fileCount increments. This new implementation reports the cumulative fraction (copiedFiles / totalFiles), so the caller adds 1/n + 2/n + ... + 1 and the progress jumps far past the intended range during override copying.


case 8: // #RRGGBBAA
r = Convert.ToInt32(trimmedString[..2], 16);
g = Convert.ToInt32(trimmedString[2..4], 16);
b = Convert.ToInt32(trimmedString[4..6], 16);
a = Convert.ToInt32(trimmedString[6..8], 16);

P2 Badge Parse WPF hex colors as ARGB

When a caller passes an 8-digit WPF color string that the previous ColorConverter path accepted, such as #80FF0000, this now treats it as #RRGGBBAA instead of WPF's #AARRGGBB. Semi-transparent colors are therefore decoded with the alpha byte in the blue channel and often become fully transparent or the wrong color when converted through NColor.

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// 解压文件,ProgressIncrementHandler 通过 Lambda 更新进度
ModBase.ExtractFile(fileAddress, installTemp, encode,
delta => loader.Progress += delta * progressIncrement);
Files.ExtractFileAsync(fileAddress, installTemp, delta => loader.Progress += delta * progressIncrement).GetAwaiter().GetResult();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the modpack ZIP filename encoding

When importing a ZIP modpack that contains GB18030/Chinese entry names, this replacement drops the encode value that the old ModBase.ExtractFile(..., encode, ...) passed into ZipFile.Open; Files.ExtractFileAsync opens ZIPs without an encoding override, so non-Unicode entry names are decoded with the library default and extract to garbled paths or fail. This affects local compressed-pack installs with localized filenames.

Useful? React with 👍 / 👎.

Comment on lines +3183 to +3184
(JsonObject)JsonCompat.ParseNode(
Files.ReadAllTextOrEmptyAsync(LauncherFileSystem.ResolvePath(ModFolder.mcFolderSelected + "launcher_profiles.json")).GetAwaiter().GetResult());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Read launcher_profiles with its written encoding

This reads launcher_profiles.json with Files.ReadAllTextOrEmptyAsync's default UTF-8 path, but the same code writes the file as GB18030 immediately below and the old ModBase.ReadFile auto-detected GB18030. If an existing launcher profile contains non-UTF8 bytes, such as Chinese profile names, launch-time profile updates can corrupt the JSON text or fall into the delete-and-recreate path.

Useful? React with 👍 / 👎.

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

重构 ModBase.cs

1 participant