Skip to content

chore: Custom icons user folder and error prevention#622

Merged
EttyKitty merged 2 commits intoAdeptus-Dominus:mainfrom
EttyKitty:pr/custom-icons
Mar 23, 2025
Merged

chore: Custom icons user folder and error prevention#622
EttyKitty merged 2 commits intoAdeptus-Dominus:mainfrom
EttyKitty:pr/custom-icons

Conversation

@EttyKitty
Copy link
Copy Markdown
Collaborator

@EttyKitty EttyKitty commented Mar 23, 2025

Purpose of changes

  • Fix a bug caused by having a saved chapter that uses an icon that doesn't exist in the game folder.
  • Move custom icons out of the game folder, to prevent wipe on each reinstall.

Describe the solution

  • Implemented a -1 check for the icon, drawing the ? icon if it fails. Still need to test this.
  • Moved the custom icons folder to C:\Users\<UserName>\AppData\Local\ChapterMaster\Custom Files\Custom Icons\.
  • Updated the readme with the new path.
  • Updated all related paths in the code and formatted them. (I run a search for icons\\custom, so I can only hope that there are no more places with the old path)
  • Added a macro to avoid path retyping all the time.
  • Replaced string concentration with interpolation for readability.

Describe alternatives you've considered

None

Testing done

Dropped a custom icon into the new folder - seems to show up in the game.

Related links

https://discord.com/channels/714022226810372107/1353320065214320761

Custom player notes entry

Use the PR title.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 23, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Summary by CodeRabbit

  • Documentation

    • Updated instructions for adding custom chapter icons. Icons should now be placed in a new folder location with revised naming conventions.
    • Removed outdated guidance and example filenames.
  • New Features

    • The application now automatically creates the custom icons folder to simplify icon management.
  • Bug Fixes

    • Enhanced custom icon rendering so that when an icon is missing or invalid, a standard fallback icon is displayed.

Walkthrough

The sacred data has undergone a transformation. This pull request entails the removal of an entry from the IncludedFiles array in the ChapterMaster.yyp file, specifically the configuration for custom_icons_help.txt, which has also been eradicated from the system. The README has been revised to direct users to deposit custom icon files in a newly specified local directory (C:\Users\<UserName>\AppData\Local\ChapterMaster\Custom Files\Custom Icons\custom*.png), replacing the previous guidance. Furthermore, various scripts have been refined for clarity: variable declarations have been distinctly separated, logical operators and file path strings have been enhanced, and the error handling in the sprite drawing routine has been fortified to ensure the validity of custom icons. A new check has been introduced to ensure the creation of the necessary directory during initialisation. The core logic remains steadfast, with the alterations aimed solely at clarity, consistency, and proper file management.

Possibly related PRs

Suggested reviewers

  • OH296

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eefa4ae and 01e3222.

📒 Files selected for processing (5)
  • objects/obj_cuicons/Alarm_0.gml (1 hunks)
  • objects/obj_cuicons/Alarm_1.gml (1 hunks)
  • objects/obj_cuicons/Alarm_2.gml (1 hunks)
  • objects/obj_cuicons/Destroy_0.gml (1 hunks)
  • scripts/__init_external/__init_external.gml (1 hunks)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Type: Chore Does something that does't fit other labels Type: Docs Changes to documentation files Size: Medium labels Mar 23, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb3734c and eefa4ae.

📒 Files selected for processing (9)
  • ChapterMaster.yyp (0 hunks)
  • datafiles/README.md (1 hunks)
  • datafiles/icons/custom_icons_help.txt (0 hunks)
  • objects/obj_cuicons/Alarm_0.gml (1 hunks)
  • objects/obj_cuicons/Alarm_1.gml (1 hunks)
  • objects/obj_cuicons/Alarm_2.gml (1 hunks)
  • objects/obj_cuicons/Destroy_0.gml (1 hunks)
  • scripts/__init_external/__init_external.gml (1 hunks)
  • scripts/scr_creation_draw_slides/scr_creation_draw_slides.gml (1 hunks)
💤 Files with no reviewable changes (2)
  • datafiles/icons/custom_icons_help.txt
  • ChapterMaster.yyp
🔇 Additional comments (11)
scripts/__init_external/__init_external.gml (1)

21-23: Praise be to the Omnissiah! A sacred directory structure is now ensured.

The code augmentation implements a critical check for the existence of the "Custom Files\Custom Icons" directory, creating it when absent. This modification ensures the proper housing of user iconography, preventing data loss during system purges or reinstallations.

+ if (!directory_exists("Custom Files\\Custom Icons")) {
+     directory_create("Custom Files\\Custom Icons");
+ }
datafiles/README.md (2)

6-6: Binary encoding compatibility warning preserved.

The sacred warning regarding MS Paint's binary encoding incompatibility has been correctly maintained, though it now stands as its own paragraph. This information is crucial for users attempting to create their own iconography.


10-11: Updated cogitation-path for the storage of sacred iconography.

The documentation has been properly updated to reflect the new storage location for custom chapter icons. This change aligns with the implementation in the code and provides clear instruction for the faithful on where to place their chapter symbology.

The path C:\Users\<UserName>\AppData\Local\ChapterMaster\Custom Files\Custom Icons\custom*.png correctly directs users to the persistent storage location, which will survive system reinstallation rituals.

objects/obj_cuicons/Destroy_0.gml (2)

1-4: Logical formatting improvements detected.

Praise be to the Omnissiah, for these variable declarations have been refined to improve code readability. The spacing between operators and operands follows the sacred patterns of machine consistency. The binary cogitation patterns are now properly aligned.


8-8: Path modification implements machine spirit relocation protocol.

By the Machine God's wisdom, the file path has been updated to reference the new user-specific sacred repository (Custom Files\\Custom Icons\\custom). This modification aligns with the holy objective of protecting custom icon data from being purged during reinstallation rituals of the main program.

objects/obj_cuicons/Alarm_1.gml (4)

1-9: Logical structure optimized for enhanced ritual processing.

The binary cogitation patterns have been refined with proper spacing, improving the clarity of the machine spirit's logic flow. The variable initialization and conditional evaluation now follow a more consistent pattern that pleases the Omnissiah. The condition > 0 has been appropriately simplified to > when evaluating the presence of "custom" in the icon_name.


11-22: File path realignment and initialization value modification implemented.

The Machine God approves of the revised file path that now directs the cogitator to search for icons in the user's sacred data repository (Custom Files\\Custom Icons\\custom). Most significantly, line 18 now initializes spr_custom_icon[i] to -1 instead of 0, which enables the fallback mechanism to display the default "?" icon when the specified icon fails to load. This change implements the divine solution specified in the holy technical specifications.


24-41: Custom icon processing logic correctly preserves machine spirit integrity.

The binary rituals for loading custom icons have been preserved while updating the file paths to the new location. The Omnissiah is pleased with the consistent use of -1 as the default value at line 34, which will trigger the fallback icon display mechanism when loading fails. The spacing and formatting improvements enhance the logical flow of the code and please the machine spirits.


43-56: Secondary conditional branch appropriately updated.

The redundant icon cleanup logic has been correctly modified to use the new file path. The initialization of spr_custom_icon[i] to -1 at line 51 properly supports the error handling protocol. These changes maintain consistency with the modifications in other sections, ensuring that the machine spirit remains balanced and harmonious.

objects/obj_cuicons/Alarm_2.gml (2)

1-12: Initial cleanup routine properly reconfigured.

By the grace of the Omnissiah, the sprite cleanup logic has been updated to reference the new file path and maintain consistent formatting. The use of -1 as the initialization value for spr_custom_icon[i] at line 8 correctly implements the error-handling protocol as specified in the technical doctrine.


14-38: Icon loading ritual updated to use sanctified paths.

The machine spirit will now search for and load custom icons from the user's personal data repository, protecting these sacred images from accidental deletion during reinstallation rituals. The initialization of spr_custom_icon[i] to -1 at line 24 properly prepares the array for the icon loading ritual and enables the fallback mechanism.

The commented debugging rituals have been preserved, maintaining historical documentation of the binary priest's debugging incantations. These may be useful for future tech-adepts who must maintain this sacred code.

@EttyKitty EttyKitty merged commit 8ccbf2f into Adeptus-Dominus:main Mar 23, 2025
5 checks passed
@EttyKitty EttyKitty deleted the pr/custom-icons branch March 23, 2025 18:12
@EttyKitty EttyKitty added the Type: Fix This is a fix for a bug label Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: Medium Type: Chore Does something that does't fit other labels Type: Docs Changes to documentation files Type: Fix This is a fix for a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant