Project config file macro

This commit is contained in:
Serhii Snitsaruk 2024-01-09 15:23:02 +01:00
parent 59a8ab97d8
commit d1030b877c
3 changed files with 7 additions and 5 deletions

View File

@ -985,7 +985,7 @@ void LimboAIEditor::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
Ref<ConfigFile> cf;
cf.instantiate();
String conf_path = GET_PROJECT_SETTINGS_DIR().path_join("limbo_ai.cfg");
String conf_path = PROJECT_CONFIG_FILE();
if (cf->load(conf_path) == OK) {
hsc->set_split_offset(cf->get_value("bt_editor", "bteditor_hsplit", hsc->get_split_offset()));
}
@ -993,7 +993,7 @@ void LimboAIEditor::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
Ref<ConfigFile> cf;
cf.instantiate();
String conf_path = GET_PROJECT_SETTINGS_DIR().path_join("limbo_ai.cfg");
String conf_path = PROJECT_CONFIG_FILE();
cf->load(conf_path);
cf->set_value("bt_editor", "bteditor_hsplit", hsc->get_split_offset());
cf->save(conf_path);

View File

@ -390,7 +390,7 @@ void TaskPalette::refresh() {
// Restore collapsed state from config.
Ref<ConfigFile> cf;
cf.instantiate();
String conf_path = GET_PROJECT_SETTINGS_DIR().path_join("limbo_ai.cfg");
String conf_path = PROJECT_CONFIG_FILE();
if (cf->load(conf_path) == OK) {
Variant value = cf->get_value("task_palette", "collapsed_sections", Array());
if (VARIANT_IS_ARRAY(value)) {
@ -525,7 +525,7 @@ void TaskPalette::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
Ref<ConfigFile> cf;
cf.instantiate();
String conf_path = GET_PROJECT_SETTINGS_DIR().path_join("limbo_ai.cfg");
String conf_path = PROJECT_CONFIG_FILE();
if (cf->load(conf_path) == OK) {
Variant value = cf->get_value("task_palette", "type_filter", FilterSettings::TypeFilter(0));
if (VARIANT_IS_NUM(value)) {
@ -552,7 +552,7 @@ void TaskPalette::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: {
Ref<ConfigFile> cf;
cf.instantiate();
String conf_path = GET_PROJECT_SETTINGS_DIR().path_join("limbo_ai.cfg");
String conf_path = PROJECT_CONFIG_FILE();
cf->load(conf_path);
Array collapsed_sections;

View File

@ -149,4 +149,6 @@ inline void VARIANT_DELETE_IF_OBJECT(Variant m_variant) {
}
}
#define PROJECT_CONFIG_FILE() GET_PROJECT_SETTINGS_DIR().path_join("limbo_ai.cfg")
#endif // LIMBO_COMPAT_H