Skip to content
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

Don't use EditorSettings metadata #96616

Merged
merged 1 commit into from
Sep 5, 2024
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
4 changes: 2 additions & 2 deletions editor/export/export_template_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ bool ExportTemplateManager::_install_file_selected(const String &p_file, bool p_
unzClose(pkg);

_update_template_status();
EditorSettings::get_singleton()->set_meta("export_template_download_directory", p_file.get_base_dir());
EditorSettings::get_singleton()->set("_export_template_download_directory", p_file.get_base_dir());
return true;
}

Expand Down Expand Up @@ -1102,7 +1102,7 @@ ExportTemplateManager::ExportTemplateManager() {
install_file_dialog->set_title(TTR("Select Template File"));
install_file_dialog->set_access(FileDialog::ACCESS_FILESYSTEM);
install_file_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);
install_file_dialog->set_current_dir(EditorSettings::get_singleton()->get_meta("export_template_download_directory", ""));
install_file_dialog->set_current_dir(EDITOR_DEF("_export_template_download_directory", ""));
install_file_dialog->add_filter("*.tpz", TTR("Godot Export Templates"));
install_file_dialog->connect("file_selected", callable_mp(this, &ExportTemplateManager::_install_file_selected).bind(false));
add_child(install_file_dialog);
Expand Down
39 changes: 17 additions & 22 deletions editor/script_create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,7 @@ static Vector<String> _get_hierarchy(const String &p_class_name) {

void ScriptCreateDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: {
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
Ref<Texture2D> language_icon = get_editor_theme_icon(ScriptServer::get_language(i)->get_type());
if (language_icon.is_valid()) {
language_menu->set_item_icon(i, language_icon);
}
}

case NOTIFICATION_ENTER_TREE: {
String last_language = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", "");
if (!last_language.is_empty()) {
for (int i = 0; i < language_menu->get_item_count(); i++) {
Expand All @@ -131,9 +123,16 @@ void ScriptCreateDialog::_notification(int p_what) {
} else {
language_menu->select(default_language);
}
if (EditorSettings::get_singleton()->has_meta("script_setup_use_script_templates")) {
is_using_templates = bool(EditorSettings::get_singleton()->get_meta("script_setup_use_script_templates"));
use_templates->set_pressed(is_using_templates);
is_using_templates = EDITOR_DEF("_script_setup_use_script_templates", false);
use_templates->set_pressed(is_using_templates);
} break;

case NOTIFICATION_THEME_CHANGED: {
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
Ref<Texture2D> language_icon = get_editor_theme_icon(ScriptServer::get_language(i)->get_type());
if (language_icon.is_valid()) {
language_menu->set_item_icon(i, language_icon);
}
}

path_button->set_icon(get_editor_theme_icon(SNAME("Folder")));
Expand Down Expand Up @@ -297,12 +296,9 @@ void ScriptCreateDialog::_template_changed(int p_template) {
EditorSettings::get_singleton()->set_project_metadata("script_setup", "templates_dictionary", dic_templates_project);
} else {
// Save template info to editor dictionary (not a project template).
Dictionary dic_templates;
if (EditorSettings::get_singleton()->has_meta("script_setup_templates_dictionary")) {
dic_templates = (Dictionary)EditorSettings::get_singleton()->get_meta("script_setup_templates_dictionary");
}
Dictionary dic_templates = EDITOR_GET("_script_setup_templates_dictionary");
dic_templates[parent_name->get_text()] = sinfo.get_hash();
EditorSettings::get_singleton()->set_meta("script_setup_templates_dictionary", dic_templates);
EditorSettings::get_singleton()->set("_script_setup_templates_dictionary", dic_templates);
// Remove template from project dictionary as we last used an editor level template.
Dictionary dic_templates_project = EditorSettings::get_singleton()->get_project_metadata("script_setup", "templates_dictionary", Dictionary());
if (dic_templates_project.has(parent_name->get_text())) {
Expand Down Expand Up @@ -415,7 +411,7 @@ void ScriptCreateDialog::_built_in_pressed() {

void ScriptCreateDialog::_use_template_pressed() {
is_using_templates = use_templates->is_pressed();
EditorSettings::get_singleton()->set_meta("script_setup_use_script_templates", is_using_templates);
EditorSettings::get_singleton()->set("_script_setup_use_script_templates", is_using_templates);
validation_panel->update();
}

Expand Down Expand Up @@ -509,10 +505,7 @@ void ScriptCreateDialog::_update_template_menu() {
if (is_language_using_templates) {
// Get the latest templates used for each type of node from project settings then global settings.
Dictionary last_local_templates = EditorSettings::get_singleton()->get_project_metadata("script_setup", "templates_dictionary", Dictionary());
Dictionary last_global_templates;
if (EditorSettings::get_singleton()->has_meta("script_setup_templates_dictionary")) {
last_global_templates = (Dictionary)EditorSettings::get_singleton()->get_meta("script_setup_templates_dictionary");
}
Dictionary last_global_templates = EDITOR_GET("_script_setup_templates_dictionary");
String inherits_base_type = parent_name->get_text();

// If it inherits from a script, get its parent class first.
Expand Down Expand Up @@ -825,6 +818,8 @@ void ScriptCreateDialog::_bind_methods() {
}

ScriptCreateDialog::ScriptCreateDialog() {
EDITOR_DEF("_script_setup_templates_dictionary", Dictionary());

/* Main Controls */

GridContainer *gc = memnew(GridContainer);
Expand Down
Loading