Skip to content

Conversation

@manuq
Copy link
Collaborator

@manuq manuq commented Sep 24, 2025

This will hopefully help contributors with accidental changes.

animated_texture_rect.gd: Use UID path to preload the template sprite
frames resource file.

Adjust the following files to the renamed directory:

  • .pre-commit-config.yaml
  • addons/storyquest_bootstrap/plugin.gd
  • project.godot

Resolve #1213


@manuq manuq requested a review from a team as a code owner September 24, 2025 18:51
@github-actions
Copy link

github-actions bot commented Sep 24, 2025

Test build no longer available.

Copy link
Member

@wjt wjt left a comment

Choose a reason for hiding this comment

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

I wrote the same PR the other day but the reason I didn't file it is that the next time you open the project after switching to this branch, you'll get:

Image

Here's what's in the console:

  ERROR: res://addons/storyquest_bootstrap/plugin.gd:166 - Parse Error: Could not resolve external class member "STORY_QUEST_TEMPLATE".
  ERROR: modules/gdscript/gdscript.cpp:3022 - Failed to load script "res://addons/storyquest_bootstrap/plugin.gd" with error "Parse error".
  ERROR: res://scenes/menus/storybook/components/storybook_page.gd:51 - Parse Error: Could not resolve external class member "sprite_frames".
  ERROR: res://scenes/menus/storybook/components/storybook.gd:0 - Compile Error: Failed to compile depended scripts.
  ERROR: modules/gdscript/gdscript.cpp:3022 - Failed to load script "res://scenes/menus/storybook/components/storybook.gd" with error "Parse error".
  ERROR: res://scenes/menus/storybook/components/animated_texture_rect.gd:15 - Parse Error: Preload file "res://scenes/quests/story_quests/template/template_player_components/template_player.tres" does not exist.
  ERROR: modules/gdscript/gdscript.cpp:3022 - Failed to load script "res://scenes/menus/storybook/components/animated_texture_rect.gd" with error "Parse error"

If you re-enable the plugin and then reload the project, the dialogue is not shown but I still see these errors:

  ERROR: res://scenes/menus/storybook/components/storybook_page.gd:51 - Parse Error: Could not resolve external class member "sprite_frames".
  ERROR: res://scenes/menus/storybook/components/storybook.gd:0 - Compile Error: Failed to compile depended scripts.
  ERROR: res://addons/storyquest_bootstrap/plugin.gd:0 - Compile Error: Failed to compile depended scripts.
  ERROR: modules/gdscript/gdscript.cpp:3022 - Failed to load script "res://addons/storyquest_bootstrap/plugin.gd" with error "Compilation failed".

Comment on lines 21 to 22
compress/uastc_level=0
compress/rdo_quality_loss=0.0
Copy link
Member

Choose a reason for hiding this comment

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

Did you write this PR with Godot 4.5? These properties are added by that version. When I try to edit the project in 4.4 it removes them again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Did you write this PR with Godot 4.5? These properties are added by that version. When I try to edit the project in 4.4 it removes them again.

Ugh yes sorry, I fixed it now.

@manuq
Copy link
Collaborator Author

manuq commented Sep 25, 2025

I wrote the same PR the other day but the reason I didn't file it is that the next time you open the project after switching to this branch, you'll get:

Image Here's what's in the console:
  ERROR: res://addons/storyquest_bootstrap/plugin.gd:166 - Parse Error: Could not resolve external class member "STORY_QUEST_TEMPLATE".
  ERROR: modules/gdscript/gdscript.cpp:3022 - Failed to load script "res://addons/storyquest_bootstrap/plugin.gd" with error "Parse error".
  ERROR: res://scenes/menus/storybook/components/storybook_page.gd:51 - Parse Error: Could not resolve external class member "sprite_frames".
  ERROR: res://scenes/menus/storybook/components/storybook.gd:0 - Compile Error: Failed to compile depended scripts.
  ERROR: modules/gdscript/gdscript.cpp:3022 - Failed to load script "res://scenes/menus/storybook/components/storybook.gd" with error "Parse error".
  ERROR: res://scenes/menus/storybook/components/animated_texture_rect.gd:15 - Parse Error: Preload file "res://scenes/quests/story_quests/template/template_player_components/template_player.tres" does not exist.
  ERROR: modules/gdscript/gdscript.cpp:3022 - Failed to load script "res://scenes/menus/storybook/components/animated_texture_rect.gd" with error "Parse error"

Oh I had the same compilation error in the plugin. I thought it was because of the following issue, hmm.

If you re-enable the plugin and then reload the project, the dialogue is not shown but I still see these errors:

  ERROR: res://scenes/menus/storybook/components/storybook_page.gd:51 - Parse Error: Could not resolve external class member "sprite_frames".
  ERROR: res://scenes/menus/storybook/components/storybook.gd:0 - Compile Error: Failed to compile depended scripts.
  ERROR: res://addons/storyquest_bootstrap/plugin.gd:0 - Compile Error: Failed to compile depended scripts.
  ERROR: modules/gdscript/gdscript.cpp:3022 - Failed to load script "res://addons/storyquest_bootstrap/plugin.gd" with error "Compilation failed".

Yes, I did this quickly, thinking that it will be easier. The Storybook animated_texture_rect.gd had a res:// path that was referencing the template. I changed it now to uid:// and it works.

Copy link
Member

@wjt wjt left a comment

Choose a reason for hiding this comment

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

I still get this when I open the project after switching to this branch:

Image

Unable to load addon script from path: 'res://addons/storyquest_bootstrap/plugin.gd'. This might be due to a code error in that script.
Disabling the addon at 'res://addons/storyquest_bootstrap/plugin.cfg' to prevent further errors.

In the Output tab I see:

ERROR: res://addons/storyquest_bootstrap/plugin.gd:166 - Parse Error: Could not resolve external class member "STORY_QUEST_TEMPLATE".
ERROR: modules/gdscript/gdscript.cpp:3022 - Failed to load script "res://addons/storyquest_bootstrap/plugin.gd" with error "Parse error".

And indeed when I save, project.godot is modified to disable the plugin.

I'll see if I can fix this

wjt added 2 commits September 25, 2025 11:57
When we rename the template directory (in a future commit) the plugin
fails to load if the directory has been previously loaded into the
editor before the rename:

> ERROR: res://addons/storyquest_bootstrap/plugin.gd:166 - Parse Error:
> Could not resolve external class member "STORY_QUEST_TEMPLATE".
>
> ERROR: modules/gdscript/gdscript.cpp:3022 - Failed to load script
> "res://addons/storyquest_bootstrap/plugin.gd" with error "Parse
> error".

and the editor shows an error dialogue & disables it.

I think the problem is some combination of:

- storybook.gd is not a @tool script.
- It preload()s a bunch of files from the template
- But the editor is still reimporting resources at the point where the
  plugin loads & tries to access fields of storybook.gd

The best solution I have found is to avoid using Storybook in the
storyquest_bootstrap plugin:

- Hardcode the `quest.tres` filename again.
- Construct the path to the template quest resource based on the
  TEMPLATE_PATH (already hardcoded here) and the quest filename (as
  above).
Previously, this class defaulted to showing the template player, by
path.

Our convention is to preload by uid:// in scripts to avoid needing to
update every script when we rename a resource.

But more to the point: TextureRect does not display anything by default;
and this is meant to be an animated version of that standard Control.
@wjt
Copy link
Member

wjt commented Sep 25, 2025

I edited this branch to add 2 patches before the rename:

  • Fix the plugin load problem
  • Change AnimatedTextureRect to default to null SpriteFrames, just like TextureRect

Copy link
Member

@wjt wjt left a comment

Choose a reason for hiding this comment

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

@hydrolet in #1213 you wrote:

Can we try the re-name for this upcoming UTP iteration, because it's unlikely that the duplication tool will be solid before then? That way we can compare and see if we get any decrease in the number of files inadvertently edited?

Can you clarify whether, by “the re-name”, you meant:

  1. Rename scenes/quests/story_quests/template/0_template_intro/template_intro_components/template_intro.dialogue to scenes/quests/story_quests/NO_EDIT/0_template_intro/template_intro_components/template_intro.dialogue (which is what @manuq has implemented here)
  2. Rename scenes/quests/story_quests/template/0_template_intro/template_intro_components/template_intro.dialogue to scenes/quests/story_quests/NO_EDIT/0_NO_EDIT_intro/NO_EDIT_intro_components/NO_EDIT_intro.dialogue

@wjt wjt mentioned this pull request Sep 25, 2025
@wjt
Copy link
Member

wjt commented Sep 26, 2025

@hydrolet clarified on Slack that it is option 2 that she wants. I would tend to agree that there's no point in just renaming the folder: if you only have 1 scene or dialogue file open, its path is not shown in the tab, only the filename. So I think we should do the more thorough renaming as in 2.

@manuq
Copy link
Collaborator Author

manuq commented Sep 26, 2025

@hydrolet clarified on Slack that it is option 2 that she wants. I would tend to agree that there's no point in just renaming the folder: if you only have 1 scene or dialogue file open, its path is not shown in the tab, only the filename. So I think we should do the more thorough renaming as in 2.

OK! Let me work on it.

@manuq
Copy link
Collaborator Author

manuq commented Sep 26, 2025

@wjt I added 2 fixup commits. Could you review? In addons/storyquest_bootstrap/plugin.gd I factored out the prefix to a constant: const TEMPLATE_PREFIX := "NO_EDIT" in case we ever change it, it can be done in a single place.

This will hopefully help contributors with accidental changes.

Adjust the following files to the renamed directory:

- .pre-commit-config.yaml
- addons/storyquest_bootstrap/plugin.gd
- project.godot
Copy link
Member

@wjt wjt left a comment

Choose a reason for hiding this comment

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

OK, let's see if this helps!

"components_path": "/0_template_intro/template_intro_components/",
"dialogue_path": "/0_template_intro/template_intro_components/template_intro.dialogue",
"image_path": "0_template_intro/template_intro_components/template_intro_image.png",
"scene_path": "/0_{prefix}_intro/{prefix}_intro.tscn".format({"prefix": TEMPLATE_PREFIX}),
Copy link
Member

Choose a reason for hiding this comment

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

I personally think that the repeated .format({"prefix": TEMPLATE_PREFIX}) is much less legible than repeating NO_EDIT, even at the cost having to search-and-replace every line if we rename it again. But let's go with this for now.

@wjt wjt merged commit ae0a63b into main Sep 29, 2025
8 checks passed
@wjt wjt deleted the rename-template branch September 29, 2025 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clearly flag template files as not to be edited

3 participants