refactor(mod-base): 重构 ModBase.cs#3294
Conversation
# Conflicts: # Plain Craft Launcher 2/Modules/Minecraft/ModLocalComp.cs # Plain Craft Launcher 2/Modules/Network/Downloader/FileDownloader.cs
There was a problem hiding this comment.
💡 Codex Review
PCL-CE/PCL.Core/IO/Directories.cs
Line 230 in 2d7a963
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.
Lines 123 to 127 in 2d7a963
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(); |
There was a problem hiding this comment.
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 👍 / 👎.
| (JsonObject)JsonCompat.ParseNode( | ||
| Files.ReadAllTextOrEmptyAsync(LauncherFileSystem.ResolvePath(ModFolder.mcFolderSelected + "launcher_profiles.json")).GetAwaiter().GetResult()); |
There was a problem hiding this comment.
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 👍 / 👎.
close: #3288