-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Custom Character Folder Image Feature Using Global Module Assets (#…
…697) # PR Checklist - [ ] Have you checked if it works normally in all models? *Ignore this if it doesn't use models.* - [x] Have you checked if it works normally in all web, local, and node hosted versions? If it doesn't, have you blocked it in those versions? - [x] Have you added type definitions? # Description This PR adds a new feature that allows users to add custom images to character folders. Instead of uploading images directly, this feature utilizes the existing image pool from **the global module**. Users can either select from existing images in the global module or upload new images to the module. The users can use a context menu on a folder to update its image. ## Why Use the Global Module? The global module was chosen for several reasons: 1. It allows the reuse of existing functions and code, minimizing the need for new implementations. 2. Users can easily select existing images without re-uploading them. 3. The global module provides reliable support for image upload and deletion. 4. Images uploaded via the global module are accessible across all platforms where the shared data is available. ## Note To retrieve the list of assets from the global module, I used the following code: ```typescript let assetPaths: { [key: string]: { path: string } } = {}; const moduleAssets = getModuleAssets(); if (moduleAssets.length > 0) { for (const asset of moduleAssets) { const assetPath = await getFileSrc(asset[1]); assetPaths[asset[0].toLocaleLowerCase()] = { path: assetPath, }; } } ``` I reused the `parseAdditionalAssets` code from `/src/ts/parser.svelte.ts` because it seemed simple and practical for this feature. I thought about refactoring it into a shared function but decided to keep it simple for now. I’m not sure if this is the best approach, but it can always be changed later if needed. --- If you are already working on a similar feature, find any issues with this code, or feel this PR does not align with the project's direction, I fully understand if this PR is not accepted. Thank you! --- One last note: With *transparent background images* and the existing folder color functionality, users can differentiate categories even when using the same image by applying different colors!
- Loading branch information
Showing
6 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1203,6 +1203,8 @@ export interface folder{ | |
data:string[] | ||
color:string | ||
id:string | ||
imgFile?:string | ||
img?:string | ||
} | ||
|
||
|
||
|