Add TextureSaveHandlerBase #97
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
IllusionMods/IllusionModdingAPI!97
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "Add-TextureSaveHandlerBase"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ManlyMarco Copilot me senpai
@ -56,0 +56,4 @@KoikatuAPI.Instance.Config.Bind("Local Textures", "Audit Local Files", 0, new ConfigDescription("Parse all character / scene files and check for missing or unused local files. Takes a long time if you have many cards and scenes.", null, new ConfigurationManagerAttributes{CustomDrawer = new System.Action<ConfigEntryBase>(TextureSaveHandlerBase.AuditOptionDrawer),Order = 0,It could also just be an unassigned hotkey, though it would need code in an Update then.
Pull Request Overview
This PR adds a new
TextureSaveHandlerBaseclass that provides a template for handling texture saving operations and introduces an audit feature for checking missing or unused local texture files. The audit system scans character cards and scenes to identify textures that are referenced but missing, or exist locally but are not used.Key changes:
TextureSaveHandlerBaseclass with auditing functionality for local texture filesSubSetextension method for extracting array segmentsReviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 13 comments.
Show a summary per file
Comments suppressed due to low confidence (5)
src/Shared.Core/Utilities/TextureSaveHandlerBase.cs:515
src/Shared.Core/Utilities/TextureSaveHandlerBase.cs:521
src/Shared.Core/Utilities/TextureSaveHandlerBase.cs:526
src/Shared.Core/Utilities/TextureSaveHandlerBase.cs:527
src/Shared.Core/Utilities/TextureSaveHandlerBase.cs:527
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@ -51,8 +51,15 @@ namespace KKAPI.Makerstatic CharaLocalTextures()Corrected spelling of 'times' to 'time' in the description.
@ -56,10 +56,18 @@ namespace KKAPI.Maker {static CharaLocalTextures()Corrected spelling of 'times' to 'time' in the description.
@ -434,5 +434,30 @@ namespace KKAPI.Utilitiesvar height = corners[1].y - corners[0].y;The
ArgumentOutOfRangeExceptionconstructor should specify which parameter is invalid. Use the overload that accepts a parameter name:throw new ArgumentOutOfRangeException(nameof(size), \"Size should be positive!\")andthrow new ArgumentOutOfRangeException(nameof(start), \"Start + size goes beyond array bounds!\").@ -0,0 +1,724 @@using BepInEx;The hardcoded cutoff date (October 21, 2025) appears to be a magic value. Consider making this configurable or using a more meaningful constant with documentation explaining its purpose (e.g., why files before this date should be ignored).
This clears the entire
auditUnusedTexturesdictionary instead of just the current plugin's entry. It should beauditUnusedTextures[auditPlugins[auditNowPlugin]].Clear()to match the behavior at line 516.The destination path has nested
Path.Combinecalls making it harder to read. Consider computing the unused folder path once (similar to line 521) and reusing it: storePath.Combine(auditPlugins[auditNowPlugin].LocalTexturePath, auditPlugins[auditNowPlugin].LocalTexUnusedFolder)in theunusedFoldervariable and use it here.Poor error handling: empty catch block.
These 'if' statements can be combined.
Generic catch clause.
Generic catch clause.
@ -0,0 +237,4 @@var pngs = new List<string>();pngs.AddRange(Directory.GetFiles(Path.Combine(Paths.GameRootPath, @"UserData\chara"), "*.png", SearchOption.AllDirectories));pngs.AddRange(Directory.GetFiles(Path.Combine(Paths.GameRootPath, @"UserData\Studio\scene"), "*.png", SearchOption.AllDirectories));Call to 'System.IO.Path.Combine'.
Call to 'System.IO.Path.Combine'.
@ -0,0 +376,4 @@foreach (var plugin in auditPlugins)foreach (var kvp in auditFoundHashToFiles[plugin])if (!auditUnusedTextures[plugin].Remove(kvp.Key))auditMissingTextures[plugin].Add(kvp.Key, kvp.Value);This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
@ -56,0 +56,4 @@KoikatuAPI.Instance.Config.Bind("Local Textures", "Audit Local Files", 0, new ConfigDescription("Parse all character / scene files and check for missing or unused local files. Takes a long time if you have many cards and scenes.", null, new ConfigurationManagerAttributes{CustomDrawer = new System.Action<ConfigEntryBase>(TextureSaveHandlerBase.AuditOptionDrawer),Order = 0,Nah that's stupid, then you'd need to bind it, use it, then unbind it. No one's gonna actually want to keep around a hotkey for this.
@ -56,0 +56,4 @@KoikatuAPI.Instance.Config.Bind("Local Textures", "Audit Local Files", 0, new ConfigDescription("Parse all character / scene files and check for missing or unused local files. Takes a long time if you have many cards and scenes.", null, new ConfigurationManagerAttributes{CustomDrawer = new System.Action<ConfigEntryBase>(TextureSaveHandlerBase.AuditOptionDrawer),Order = 0,How about having a button for this in the texture storage type selection box itself? That would be way easier to discover and use by users.