-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: | ||
|
@@ -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: | ||
|
@@ -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) | ||
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] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!