2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2017-09-01 14:07:55 +00:00
|
|
|
/* project_settings_editor.cpp */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
2020-01-01 10:16:22 +00:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2014-02-10 01:10:30 +00:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2017-07-19 20:00:46 +00:00
|
|
|
#include "project_settings_editor.h"
|
2017-01-16 07:04:19 +00:00
|
|
|
|
2017-08-26 15:46:49 +00:00
|
|
|
#include "core/project_settings.h"
|
2019-12-24 07:17:23 +00:00
|
|
|
#include "editor/editor_export.h"
|
2017-08-26 15:46:49 +00:00
|
|
|
#include "editor/editor_node.h"
|
2019-12-24 07:17:23 +00:00
|
|
|
#include "editor/editor_scale.h"
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-04-01 23:20:12 +00:00
|
|
|
ProjectSettingsEditor *ProjectSettingsEditor::singleton = nullptr;
|
2017-03-05 15:44:50 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::popup_project_settings() {
|
|
|
|
// Restore valid window bounds or pop up at default size.
|
|
|
|
Rect2 saved_size = EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "project_settings", Rect2());
|
|
|
|
if (saved_size != Rect2()) {
|
|
|
|
popup(saved_size);
|
|
|
|
} else {
|
|
|
|
popup_centered_clamped(Size2(900, 700) * EDSCALE, 0.8);
|
|
|
|
}
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
_add_feature_overrides();
|
|
|
|
inspector->update_category_list();
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
localization_editor->update_translations();
|
|
|
|
autoload_settings->update_autoload();
|
|
|
|
plugin_settings->update_plugins();
|
|
|
|
}
|
2016-04-28 13:53:49 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
void ProjectSettingsEditor::queue_save() {
|
|
|
|
timer->start();
|
2019-10-06 15:13:56 +00:00
|
|
|
}
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
void ProjectSettingsEditor::set_plugins_page() {
|
|
|
|
tab_container->set_current_tab(plugin_settings->get_index());
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::update_plugins() {
|
|
|
|
plugin_settings->update_plugins();
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
void ProjectSettingsEditor::_setting_edited(const String &p_name) {
|
|
|
|
queue_save();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectSettingsEditor::_advanced_pressed() {
|
|
|
|
if (advanced->is_pressed()) {
|
|
|
|
_update_advanced_bar();
|
|
|
|
advanced_bar->show();
|
|
|
|
} else {
|
|
|
|
advanced_bar->hide();
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2020-07-10 22:52:52 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
void ProjectSettingsEditor::_setting_selected(const String &p_path) {
|
|
|
|
if (p_path == String()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
category_box->set_text(inspector->get_current_section());
|
|
|
|
property_box->set_text(p_path);
|
|
|
|
|
|
|
|
if (advanced_bar->is_visible()) {
|
|
|
|
_update_advanced_bar(); // set_text doesn't trigger text_changed
|
|
|
|
}
|
2020-07-10 22:52:52 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
void ProjectSettingsEditor::_add_setting() {
|
|
|
|
String setting = _get_setting_name();
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
// Initialize the property with the default value for the given type.
|
|
|
|
// The type list starts at 1 (as we exclude Nil), so add 1 to the selected value.
|
|
|
|
Callable::CallError ce;
|
|
|
|
const Variant value = Variant::construct(Variant::Type(type->get_selected() + 1), nullptr, 0, ce);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
undo_redo->create_action(TTR("Add Project Setting"));
|
|
|
|
undo_redo->add_do_property(ps, setting, value);
|
|
|
|
undo_redo->add_undo_property(ps, setting, ps->has_setting(setting) ? ps->get(setting) : Variant());
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
undo_redo->add_do_method(inspector, "update_category_list");
|
|
|
|
undo_redo->add_undo_method(inspector, "update_category_list");
|
|
|
|
undo_redo->add_do_method(this, "queue_save");
|
|
|
|
undo_redo->add_undo_method(this, "queue_save");
|
|
|
|
undo_redo->commit_action();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
inspector->set_current_section(setting.get_slice("/", 1));
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-08-14 08:04:34 +00:00
|
|
|
void ProjectSettingsEditor::_delete_setting(bool p_confirmed) {
|
2020-07-15 16:33:34 +00:00
|
|
|
String setting = _get_setting_name();
|
|
|
|
Variant value = ps->get(setting);
|
|
|
|
int order = ps->get_order(setting);
|
2017-10-17 15:27:54 +00:00
|
|
|
|
2020-08-14 08:04:34 +00:00
|
|
|
if (!p_confirmed) {
|
|
|
|
del_confirmation->set_text(vformat(TTR("Are you sure you want to delete '%s'?"), setting));
|
|
|
|
del_confirmation->popup_centered();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
undo_redo->create_action(TTR("Delete Item"));
|
2017-10-17 15:27:54 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
undo_redo->add_do_method(ps, "clear", setting);
|
|
|
|
undo_redo->add_undo_method(ps, "set", setting, value);
|
|
|
|
undo_redo->add_undo_method(ps, "set_order", setting, order);
|
2017-10-17 15:27:54 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
undo_redo->add_do_method(inspector, "update_category_list");
|
|
|
|
undo_redo->add_undo_method(inspector, "update_category_list");
|
|
|
|
undo_redo->add_do_method(this, "queue_save");
|
|
|
|
undo_redo->add_undo_method(this, "queue_save");
|
2017-10-17 15:27:54 +00:00
|
|
|
|
|
|
|
undo_redo->commit_action();
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
property_box->clear();
|
2020-07-10 22:52:52 +00:00
|
|
|
}
|
2017-10-17 15:27:54 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
void ProjectSettingsEditor::_text_field_changed(const String &p_text) {
|
|
|
|
_update_advanced_bar();
|
|
|
|
}
|
2017-10-17 15:27:54 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
void ProjectSettingsEditor::_feature_selected(int p_index) {
|
|
|
|
_update_advanced_bar();
|
|
|
|
}
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
void ProjectSettingsEditor::_update_advanced_bar() {
|
|
|
|
const String property_text = property_box->get_text().strip_edges();
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
String error_msg = "";
|
|
|
|
bool disable_add = true;
|
|
|
|
bool disable_del = true;
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
if (!property_box->get_text().empty()) {
|
|
|
|
const String setting = _get_setting_name();
|
|
|
|
bool setting_exists = ps->has_setting(setting);
|
|
|
|
if (setting_exists) {
|
|
|
|
error_msg = TTR(" - Cannot add already existing setting.");
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
disable_del = ps->is_builtin_setting(setting);
|
|
|
|
if (disable_del) {
|
|
|
|
String msg = TTR(" - Cannot delete built-in setting.");
|
|
|
|
error_msg += (error_msg == "") ? msg : "\n" + msg;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bool bad_category = false; // Allow empty string.
|
|
|
|
Vector<String> cats = category_box->get_text().strip_edges().split("/");
|
|
|
|
for (int i = 0; i < cats.size(); i++) {
|
|
|
|
if (!cats[i].is_valid_identifier()) {
|
|
|
|
bad_category = true;
|
|
|
|
error_msg = TTR(" - Invalid category name.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-08-14 15:14:23 +00:00
|
|
|
disable_add = bad_category;
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
if (!property_text.is_valid_identifier()) {
|
|
|
|
disable_add = true;
|
|
|
|
String msg = TTR(" - Invalid property name.");
|
|
|
|
error_msg += (error_msg == "") ? msg : "\n" + msg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-10 22:52:52 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
add_button->set_disabled(disable_add);
|
|
|
|
del_button->set_disabled(disable_del);
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
error_label->set_text(error_msg);
|
|
|
|
error_label->set_visible(error_msg != "");
|
2020-06-19 09:56:24 +00:00
|
|
|
}
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
String ProjectSettingsEditor::_get_setting_name() const {
|
|
|
|
const String cat = category_box->get_text();
|
|
|
|
const String name = (cat.empty() ? "global" : cat.strip_edges()).plus_file(property_box->get_text().strip_edges());
|
|
|
|
const String feature = feature_override->get_item_text(feature_override->get_selected());
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
return (feature == "") ? name : (name + "." + feature);
|
2020-06-19 09:56:24 +00:00
|
|
|
}
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
void ProjectSettingsEditor::_add_feature_overrides() {
|
2020-07-10 22:52:52 +00:00
|
|
|
Set<String> presets;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
presets.insert("bptc");
|
|
|
|
presets.insert("s3tc");
|
|
|
|
presets.insert("etc");
|
|
|
|
presets.insert("etc2");
|
|
|
|
presets.insert("pvrtc");
|
|
|
|
presets.insert("debug");
|
|
|
|
presets.insert("release");
|
|
|
|
presets.insert("editor");
|
|
|
|
presets.insert("standalone");
|
|
|
|
presets.insert("32");
|
|
|
|
presets.insert("64");
|
2020-07-15 16:33:34 +00:00
|
|
|
presets.insert("Server"); // Not available as an export platform yet, so it needs to be added manually
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
EditorExport *ee = EditorExport::get_singleton();
|
|
|
|
|
|
|
|
for (int i = 0; i < ee->get_export_platform_count(); i++) {
|
2020-07-10 22:52:52 +00:00
|
|
|
List<String> p;
|
2020-07-15 16:33:34 +00:00
|
|
|
ee->get_export_platform(i)->get_platform_features(&p);
|
2020-07-10 22:52:52 +00:00
|
|
|
for (List<String>::Element *E = p.front(); E; E = E->next()) {
|
|
|
|
presets.insert(E->get());
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
for (int i = 0; i < ee->get_export_preset_count(); i++) {
|
2020-07-10 22:52:52 +00:00
|
|
|
List<String> p;
|
2020-07-15 16:33:34 +00:00
|
|
|
ee->get_export_preset(i)->get_platform()->get_preset_features(ee->get_export_preset(i), &p);
|
2020-07-10 22:52:52 +00:00
|
|
|
for (List<String>::Element *E = p.front(); E; E = E->next()) {
|
|
|
|
presets.insert(E->get());
|
2017-10-17 15:27:54 +00:00
|
|
|
}
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
String custom = ee->get_export_preset(i)->get_custom_features();
|
2020-07-10 22:52:52 +00:00
|
|
|
Vector<String> custom_list = custom.split(",");
|
|
|
|
for (int j = 0; j < custom_list.size(); j++) {
|
|
|
|
String f = custom_list[j].strip_edges();
|
|
|
|
if (f != String()) {
|
|
|
|
presets.insert(f);
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2017-10-17 15:27:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
feature_override->clear();
|
|
|
|
feature_override->add_item("", 0); // So it is always on top.
|
|
|
|
int id = 1;
|
2020-07-10 22:52:52 +00:00
|
|
|
for (Set<String>::Element *E = presets.front(); E; E = E->next()) {
|
2020-07-15 16:33:34 +00:00
|
|
|
feature_override->add_item(E->get(), id++);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
2020-07-10 22:52:52 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2018-07-19 21:58:15 +00:00
|
|
|
void ProjectSettingsEditor::_editor_restart() {
|
2019-01-25 20:23:56 +00:00
|
|
|
EditorNode::get_singleton()->save_all_scenes();
|
|
|
|
EditorNode::get_singleton()->restart_editor();
|
2018-07-19 21:58:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectSettingsEditor::_editor_restart_request() {
|
|
|
|
restart_container->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectSettingsEditor::_editor_restart_close() {
|
|
|
|
restart_container->hide();
|
|
|
|
}
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
void ProjectSettingsEditor::_notification(int p_what) {
|
|
|
|
switch (p_what) {
|
|
|
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
|
|
|
if (!is_visible()) {
|
|
|
|
EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "project_settings", Rect2(get_position(), get_size()));
|
|
|
|
if (advanced->is_pressed()) {
|
|
|
|
advanced->set_pressed(false);
|
|
|
|
advanced_bar->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case NOTIFICATION_ENTER_TREE: {
|
|
|
|
inspector->edit(ps);
|
|
|
|
|
|
|
|
error_label->add_theme_color_override("font_color", error_label->get_theme_color("error_color", "Editor"));
|
|
|
|
add_button->set_icon(get_theme_icon("Add", "EditorIcons"));
|
|
|
|
del_button->set_icon(get_theme_icon("Remove", "EditorIcons"));
|
|
|
|
|
|
|
|
search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
|
|
|
|
search_box->set_clear_button_enabled(true);
|
|
|
|
|
|
|
|
restart_close_button->set_icon(get_theme_icon("Close", "EditorIcons"));
|
|
|
|
restart_container->add_theme_style_override("panel", get_theme_stylebox("bg", "Tree"));
|
|
|
|
restart_icon->set_texture(get_theme_icon("StatusWarning", "EditorIcons"));
|
|
|
|
restart_label->add_theme_color_override("font_color", get_theme_color("warning_color", "Editor"));
|
|
|
|
} break;
|
|
|
|
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
|
|
|
search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
|
|
|
|
search_box->set_clear_button_enabled(true);
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
}
|
2018-07-19 21:58:15 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
void ProjectSettingsEditor::_bind_methods() {
|
|
|
|
ClassDB::bind_method(D_METHOD("queue_save"), &ProjectSettingsEditor::queue_save);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 20:00:46 +00:00
|
|
|
ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
|
2017-03-05 15:44:50 +00:00
|
|
|
singleton = this;
|
2017-05-01 15:44:52 +00:00
|
|
|
set_title(TTR("Project Settings (project.godot)"));
|
2020-03-06 17:00:16 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
ps = ProjectSettings::get_singleton();
|
2017-03-05 15:44:50 +00:00
|
|
|
undo_redo = &p_data->get_undo_redo();
|
|
|
|
data = p_data;
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
tab_container = memnew(TabContainer);
|
2017-05-02 20:13:12 +00:00
|
|
|
tab_container->set_tab_align(TabContainer::ALIGN_LEFT);
|
2019-01-26 18:41:36 +00:00
|
|
|
tab_container->set_use_hidden_tabs_for_min_size(true);
|
2014-02-10 01:10:30 +00:00
|
|
|
add_child(tab_container);
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
VBoxContainer *general_editor = memnew(VBoxContainer);
|
|
|
|
general_editor->set_name(TTR("General"));
|
|
|
|
general_editor->set_alignment(BoxContainer::ALIGN_BEGIN);
|
|
|
|
general_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
tab_container->add_child(general_editor);
|
|
|
|
|
|
|
|
VBoxContainer *header = memnew(VBoxContainer);
|
|
|
|
header->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
general_editor->add_child(header);
|
|
|
|
|
|
|
|
{
|
|
|
|
// Search bar.
|
|
|
|
search_bar = memnew(HBoxContainer);
|
|
|
|
search_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
header->add_child(search_bar);
|
|
|
|
|
|
|
|
search_box = memnew(LineEdit);
|
2020-08-14 15:14:23 +00:00
|
|
|
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
2020-07-15 16:33:34 +00:00
|
|
|
search_bar->add_child(search_box);
|
|
|
|
|
|
|
|
advanced = memnew(CheckButton);
|
|
|
|
advanced->set_text(TTR("Advanced"));
|
|
|
|
advanced->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_advanced_pressed));
|
|
|
|
search_bar->add_child(advanced);
|
2019-10-07 15:17:13 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
{
|
|
|
|
// Advanced bar.
|
|
|
|
advanced_bar = memnew(VBoxContainer);
|
|
|
|
advanced_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
advanced_bar->hide();
|
|
|
|
header->add_child(advanced_bar);
|
|
|
|
|
2020-08-14 15:14:23 +00:00
|
|
|
advanced_bar->add_child(memnew(HSeparator));
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
HBoxContainer *hbc = memnew(HBoxContainer);
|
|
|
|
hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
2020-08-14 15:14:23 +00:00
|
|
|
advanced_bar->add_margin_child(TTR("Add or Remove Custom Project Settings:"), hbc, true);
|
2020-07-15 16:33:34 +00:00
|
|
|
|
|
|
|
category_box = memnew(LineEdit);
|
2020-08-14 15:14:23 +00:00
|
|
|
category_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
2020-07-15 16:33:34 +00:00
|
|
|
category_box->connect("text_changed", callable_mp(this, &ProjectSettingsEditor::_text_field_changed));
|
|
|
|
category_box->set_placeholder(TTR("Category"));
|
|
|
|
hbc->add_child(category_box);
|
|
|
|
|
|
|
|
Label *l = memnew(Label);
|
|
|
|
l->set_text("/");
|
|
|
|
hbc->add_child(l);
|
|
|
|
|
|
|
|
property_box = memnew(LineEdit);
|
|
|
|
property_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
property_box->set_placeholder(TTR("Property"));
|
|
|
|
property_box->connect("text_changed", callable_mp(this, &ProjectSettingsEditor::_text_field_changed));
|
|
|
|
hbc->add_child(property_box);
|
|
|
|
|
|
|
|
l = memnew(Label);
|
|
|
|
l->set_text(TTR("Type:"));
|
|
|
|
hbc->add_child(l);
|
|
|
|
|
|
|
|
type = memnew(OptionButton);
|
2020-08-14 15:14:23 +00:00
|
|
|
type->set_custom_minimum_size(Size2(100, 0) * EDSCALE);
|
2020-07-15 16:33:34 +00:00
|
|
|
hbc->add_child(type);
|
|
|
|
|
|
|
|
// Start at 1 to avoid adding "Nil" as an option
|
|
|
|
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
|
|
|
|
type->add_item(Variant::get_type_name(Variant::Type(i)));
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
l = memnew(Label);
|
|
|
|
l->set_text(TTR("Feature Override:"));
|
|
|
|
hbc->add_child(l);
|
2016-01-23 19:05:27 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
feature_override = memnew(OptionButton);
|
2020-08-14 15:14:23 +00:00
|
|
|
feature_override->set_custom_minimum_size(Size2(100, 0) * EDSCALE);
|
2020-07-15 16:33:34 +00:00
|
|
|
feature_override->connect("item_selected", callable_mp(this, &ProjectSettingsEditor::_feature_selected));
|
|
|
|
hbc->add_child(feature_override);
|
2016-01-23 19:05:27 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
add_button = memnew(Button);
|
2020-08-14 15:14:23 +00:00
|
|
|
add_button->set_flat(true);
|
2020-07-15 16:33:34 +00:00
|
|
|
add_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_add_setting));
|
|
|
|
hbc->add_child(add_button);
|
2015-11-21 16:42:15 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
del_button = memnew(Button);
|
2020-08-14 15:14:23 +00:00
|
|
|
del_button->set_flat(true);
|
2020-08-14 08:04:34 +00:00
|
|
|
del_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_delete_setting), varray(false));
|
2020-07-15 16:33:34 +00:00
|
|
|
hbc->add_child(del_button);
|
2015-11-21 16:42:15 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
error_label = memnew(Label);
|
|
|
|
advanced_bar->add_child(error_label);
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
inspector = memnew(SectionedInspector);
|
|
|
|
inspector->get_inspector()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
|
|
|
|
inspector->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
inspector->register_search_box(search_box);
|
|
|
|
inspector->get_inspector()->connect("property_selected", callable_mp(this, &ProjectSettingsEditor::_setting_selected));
|
|
|
|
inspector->get_inspector()->connect("property_edited", callable_mp(this, &ProjectSettingsEditor::_setting_edited));
|
|
|
|
inspector->get_inspector()->connect("restart_requested", callable_mp(this, &ProjectSettingsEditor::_editor_restart_request));
|
|
|
|
general_editor->add_child(inspector);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2018-07-19 21:58:15 +00:00
|
|
|
restart_container = memnew(PanelContainer);
|
2020-07-15 16:33:34 +00:00
|
|
|
general_editor->add_child(restart_container);
|
2020-07-10 22:52:52 +00:00
|
|
|
|
2018-07-19 21:58:15 +00:00
|
|
|
HBoxContainer *restart_hb = memnew(HBoxContainer);
|
2020-07-10 22:52:52 +00:00
|
|
|
restart_container->hide();
|
2018-07-19 21:58:15 +00:00
|
|
|
restart_container->add_child(restart_hb);
|
2020-07-10 22:52:52 +00:00
|
|
|
|
2018-07-19 21:58:15 +00:00
|
|
|
restart_icon = memnew(TextureRect);
|
2020-03-06 17:00:16 +00:00
|
|
|
restart_icon->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
|
2018-07-19 21:58:15 +00:00
|
|
|
restart_hb->add_child(restart_icon);
|
2020-07-10 22:52:52 +00:00
|
|
|
|
2018-07-19 21:58:15 +00:00
|
|
|
restart_label = memnew(Label);
|
2020-06-18 22:43:57 +00:00
|
|
|
restart_label->set_text(TTR("Changed settings will be applied to the editor after restarting."));
|
2018-07-19 21:58:15 +00:00
|
|
|
restart_hb->add_child(restart_label);
|
|
|
|
restart_hb->add_spacer();
|
2020-07-10 22:52:52 +00:00
|
|
|
|
2018-07-19 21:58:15 +00:00
|
|
|
Button *restart_button = memnew(Button);
|
2020-02-21 17:28:45 +00:00
|
|
|
restart_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_editor_restart));
|
2018-07-19 21:58:15 +00:00
|
|
|
restart_hb->add_child(restart_button);
|
|
|
|
restart_button->set_text(TTR("Save & Restart"));
|
2020-07-10 22:52:52 +00:00
|
|
|
|
2020-06-19 18:49:04 +00:00
|
|
|
restart_close_button = memnew(Button);
|
|
|
|
restart_close_button->set_flat(true);
|
2020-02-21 17:28:45 +00:00
|
|
|
restart_close_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_editor_restart_close));
|
2018-07-19 21:58:15 +00:00
|
|
|
restart_hb->add_child(restart_close_button);
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
inputmap_editor = memnew(InputMapEditor);
|
|
|
|
inputmap_editor->set_name(TTR("Input Map"));
|
2020-07-15 16:33:34 +00:00
|
|
|
inputmap_editor->connect("inputmap_changed", callable_mp(this, &ProjectSettingsEditor::queue_save));
|
2020-07-10 22:52:52 +00:00
|
|
|
tab_container->add_child(inputmap_editor);
|
2017-10-17 15:27:54 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
localization_editor = memnew(LocalizationEditor);
|
|
|
|
localization_editor->set_name(TTR("Localization"));
|
2020-07-15 16:33:34 +00:00
|
|
|
localization_editor->connect("localization_changed", callable_mp(this, &ProjectSettingsEditor::queue_save));
|
2020-07-10 22:52:52 +00:00
|
|
|
tab_container->add_child(localization_editor);
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2017-12-07 23:49:44 +00:00
|
|
|
autoload_settings = memnew(EditorAutoloadSettings);
|
|
|
|
autoload_settings->set_name(TTR("AutoLoad"));
|
2020-07-15 16:33:34 +00:00
|
|
|
autoload_settings->connect("autoload_changed", callable_mp(this, &ProjectSettingsEditor::queue_save));
|
2020-07-10 22:52:52 +00:00
|
|
|
tab_container->add_child(autoload_settings);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-04-17 02:52:00 +00:00
|
|
|
shaders_global_variables_editor = memnew(ShaderGlobalsEditor);
|
|
|
|
shaders_global_variables_editor->set_name(TTR("Shader Globals"));
|
2020-07-15 16:33:34 +00:00
|
|
|
shaders_global_variables_editor->connect("globals_changed", callable_mp(this, &ProjectSettingsEditor::queue_save));
|
2020-07-10 22:52:52 +00:00
|
|
|
tab_container->add_child(shaders_global_variables_editor);
|
2020-04-17 02:52:00 +00:00
|
|
|
|
2017-12-07 23:49:44 +00:00
|
|
|
plugin_settings = memnew(EditorPluginSettings);
|
|
|
|
plugin_settings->set_name(TTR("Plugins"));
|
|
|
|
tab_container->add_child(plugin_settings);
|
2016-02-28 02:10:44 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
timer = memnew(Timer);
|
2018-07-03 17:33:06 +00:00
|
|
|
timer->set_wait_time(1.5);
|
2020-07-15 16:33:34 +00:00
|
|
|
timer->connect("timeout", callable_mp(ps, &ProjectSettings::save));
|
2014-02-10 01:10:30 +00:00
|
|
|
timer->set_one_shot(true);
|
|
|
|
add_child(timer);
|
2020-07-15 16:33:34 +00:00
|
|
|
|
2020-08-14 08:04:34 +00:00
|
|
|
del_confirmation = memnew(ConfirmationDialog);
|
|
|
|
del_confirmation->connect("confirmed", callable_mp(this, &ProjectSettingsEditor::_delete_setting), varray(true));
|
|
|
|
add_child(del_confirmation);
|
|
|
|
|
2020-07-15 16:33:34 +00:00
|
|
|
get_ok()->set_text(TTR("Close"));
|
|
|
|
set_hide_on_ok(true);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|