-
Notifications
You must be signed in to change notification settings - Fork 45
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
misc: improved serialization #189
Conversation
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.
Seems like some fixes required.
static func _get_key(keys:Array[String]) -> String: | ||
return ".".join(keys) | ||
|
||
static func get_value(keys:Array[String], default:Variant = null) -> Variant: | ||
var key := _get_key(keys) | ||
var cfg := _get_config() | ||
return cfg.get(key, default) | ||
|
||
static func set_value(key:String, val:Variant) -> void: | ||
var config = _get_config(USER_CONFIG_FILE_PATH) | ||
config[key] = val | ||
set_config(config) | ||
static func set_value(keys:Array[String], val:Variant) -> void: | ||
var key := _get_key(keys) |
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.
This cause many errors for me, since every PankuConfig.set_value
/PankuConfig.get_value
I can see have String
as first argument, not array. I miss the point why key array and join used here.
Seems it works fine with key-value args
static func get_value(key: String, default:Variant = null) -> Variant:
var cfg := _get_config()
return cfg.get(key, default)
static func set_value(key: String, val:Variant) -> void:
var cfg := _get_config()
cfg[key] = val
save_config_with_delay()
"engine_tools": { | ||
"time_scale": "1" | ||
}, | ||
"engine_tools.time_scale": "1", |
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.
Is not it some kind of duplication? Which dictionary structure was originally planned: nested or plain with joined keys?
@@ -8,8 +8,12 @@ const OPTIONS = { | |||
CUSTOM_DEFAULT_CONFIG = 'custom_default_config', | |||
} | |||
|
|||
const INITIAL_DEFAULT_CONFIG_FILE_PATH = "res://addons/panku_console/default_panku_config.cfg" | |||
const USER_CONFIG_FILE_PATH = "user://panku_config.cfg" | |||
const INITIAL_DEFAULT_CONFIG_FILE_PATH = "res://addons/panku_console/default_panku_config.tres" |
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.
I believe we need to change file extension hint here too.
Also, do we need to keep default_panku_config.cfg
file in project or may be we can delete it within this pull request?
a new pr has been upload #195 |
str_to_var()
, so you can edit default config (default_panku_config.tres
) in godot editor.set_value
and to better adapt something like slider value realtime change saving.