Skip to content

Fix Custom Styles not working #2582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/dialogic/Core/DialogicResourceUtil.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static func update() -> void:
update_directory('.dtl')
update_label_cache()
update_audio_channel_cache()
DialogicStylesUtil.update_style_directory()
DialogicStylesUtil.build_style_directory()


#region RESOURCE DIRECTORIES
Expand Down
16 changes: 9 additions & 7 deletions addons/dialogic/Modules/Style/DialogicStylesUtil.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ static var style_directory := {}
################################################################################

static func update_style_directory() -> void:
return ProjectSettings.get_setting('dialogic/layout/style_directory', {})
style_directory = ProjectSettings.get_setting('dialogic/layout/style_directory', {})


static func build_style_directory() -> void:
Expand All @@ -24,9 +24,11 @@ static func build_style_directory() -> void:
continue
# TODO this is bad
var resource: DialogicStyle = load(style_path)
style_directory[resource.name] = resource
ProjectSettings.set_setting('dialogic/layout/style_directory', style_directory)
ProjectSettings.save()
style_directory[resource.name] = style_path

if Engine.is_editor_hint():
ProjectSettings.set_setting('dialogic/layout/style_directory', style_directory)
ProjectSettings.save()


static func get_default_style_path() -> String:
Expand All @@ -46,16 +48,16 @@ static func get_fallback_style() -> DialogicStyle:


static func get_style_path(name_or_path:String) -> String:
var path := ""
print(style_directory)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix! Did you mean to leave in this print statement by the way?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, my bad 🙈 Will push a fix later!

if name_or_path.begins_with("res://"):
if not ResourceLoader.exists(name_or_path):
name_or_path = ""

if name_or_path in style_directory:
path = style_directory[name_or_path]
name_or_path = style_directory[name_or_path]
Copy link
Contributor

Choose a reason for hiding this comment

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

This function seems like it has a side effect of modifying the input argument name_or_path. Is that intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well it's returning the name_or_path variable later and because there is a chance the original value passed into the function is already the path I skipped creating a separate value. Strings are not passed by reference afaik, so this shouldn't be a problem I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. Worth testing quickly though. Strings can potentially be very large, so I would have assumed they are passed by reference in GDScript but happy to be proven wrong.


if not name_or_path:
path = get_default_style_path()
name_or_path = get_default_style_path()

if not name_or_path or not ResourceLoader.exists(name_or_path):
return get_fallback_style_path()
Expand Down