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/global_constants.h"
|
|
|
|
#include "core/os/keyboard.h"
|
|
|
|
#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);
|
|
|
|
}
|
|
|
|
|
|
|
|
globals_editor->update_category_list();
|
|
|
|
localization_editor->update_translations();
|
|
|
|
autoload_settings->update_autoload();
|
|
|
|
plugin_settings->update_plugins();
|
|
|
|
set_process_unhandled_input(true);
|
|
|
|
}
|
2016-04-28 13:53:49 +00:00
|
|
|
|
2019-10-06 15:13:56 +00:00
|
|
|
void ProjectSettingsEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
|
|
|
|
const Ref<InputEventKey> k = p_event;
|
|
|
|
|
2020-03-06 17:00:16 +00:00
|
|
|
if (k.is_valid() && k->is_pressed()) {
|
2018-04-05 17:59:35 +00:00
|
|
|
if (k->get_keycode_with_modifiers() == (KEY_MASK_CMD | KEY_F)) {
|
2019-10-06 15:13:56 +00:00
|
|
|
if (search_button->is_pressed()) {
|
|
|
|
search_box->grab_focus();
|
|
|
|
search_box->select_all();
|
|
|
|
} else {
|
|
|
|
// This toggles the search bar display while giving the button its "pressed" appearance
|
|
|
|
search_button->set_pressed(true);
|
|
|
|
}
|
|
|
|
|
2020-03-06 17:00:16 +00:00
|
|
|
set_input_as_handled();
|
2019-10-06 15:13:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-19 20:00:46 +00:00
|
|
|
void ProjectSettingsEditor::_notification(int p_what) {
|
2017-03-02 21:43:56 +00:00
|
|
|
switch (p_what) {
|
2020-03-06 17:00:16 +00:00
|
|
|
case NOTIFICATION_VISIBILITY_CHANGED: {
|
|
|
|
if (!is_visible()) {
|
|
|
|
EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "project_settings", Rect2(get_position(), get_size()));
|
|
|
|
set_process_unhandled_input(false);
|
|
|
|
}
|
|
|
|
} break;
|
2017-03-02 21:43:56 +00:00
|
|
|
case NOTIFICATION_ENTER_TREE: {
|
2017-07-19 20:00:46 +00:00
|
|
|
globals_editor->edit(ProjectSettings::get_singleton());
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
search_button->set_icon(get_theme_icon("Search", "EditorIcons"));
|
|
|
|
search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
|
2018-07-26 11:45:38 +00:00
|
|
|
search_box->set_clear_button_enabled(true);
|
2018-02-21 21:06:34 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
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"));
|
2017-06-24 12:35:36 +00:00
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
} break;
|
2020-07-10 22:52:52 +00:00
|
|
|
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
|
|
|
search_button->set_icon(get_theme_icon("Search", "EditorIcons"));
|
|
|
|
search_box->set_right_icon(get_theme_icon("Search", "EditorIcons"));
|
|
|
|
search_box->set_clear_button_enabled(true);
|
|
|
|
} break;
|
2017-10-17 15:27:54 +00:00
|
|
|
}
|
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-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::_item_selected(const String &p_path) {
|
|
|
|
const String &selected_path = p_path;
|
|
|
|
if (selected_path == String()) {
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2020-07-10 22:52:52 +00:00
|
|
|
category->set_text(globals_editor->get_current_section());
|
|
|
|
property->set_text(selected_path);
|
|
|
|
popup_copy_to_feature->set_disabled(false);
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::_item_adds(String) {
|
|
|
|
_item_add();
|
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::_item_add() {
|
|
|
|
// 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-10 22:52:52 +00:00
|
|
|
String catname = category->get_text().strip_edges();
|
|
|
|
String propname = property->get_text().strip_edges();
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
if (propname.empty()) {
|
2014-02-10 01:10:30 +00:00
|
|
|
return;
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
if (catname.empty()) {
|
|
|
|
catname = "global";
|
2020-05-14 14:41:43 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
String name = catname + "/" + propname;
|
2017-10-17 15:27:54 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
undo_redo->create_action(TTR("Add Global Property"));
|
2017-10-17 15:27:54 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
undo_redo->add_do_property(ProjectSettings::get_singleton(), name, value);
|
2017-10-17 15:27:54 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
if (ProjectSettings::get_singleton()->has_setting(name)) {
|
|
|
|
undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name));
|
2017-10-17 15:27:54 +00:00
|
|
|
} else {
|
2020-07-10 22:52:52 +00:00
|
|
|
undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, Variant());
|
2017-10-17 15:27:54 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
undo_redo->add_do_method(globals_editor, "update_category_list");
|
|
|
|
undo_redo->add_undo_method(globals_editor, "update_category_list");
|
2017-10-17 15:27:54 +00:00
|
|
|
undo_redo->add_do_method(this, "_settings_changed");
|
|
|
|
undo_redo->add_undo_method(this, "_settings_changed");
|
|
|
|
undo_redo->commit_action();
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
globals_editor->set_current_section(catname);
|
2017-10-17 15:27:54 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
_settings_changed();
|
|
|
|
}
|
2017-10-17 15:27:54 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::_item_del() {
|
|
|
|
String path = globals_editor->get_inspector()->get_selected_path();
|
|
|
|
if (path == String()) {
|
|
|
|
EditorNode::get_singleton()->show_warning(TTR("Select a setting item first!"));
|
|
|
|
return;
|
2017-10-17 15:27:54 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
String property = globals_editor->get_current_section().plus_file(path);
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
if (!ProjectSettings::get_singleton()->has_setting(property)) {
|
|
|
|
EditorNode::get_singleton()->show_warning(vformat(TTR("No property '%s' exists."), property));
|
|
|
|
return;
|
2020-06-19 09:56:24 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
if (ProjectSettings::get_singleton()->get_order(property) < ProjectSettings::NO_BUILTIN_ORDER_BASE) {
|
|
|
|
EditorNode::get_singleton()->show_warning(vformat(TTR("Setting '%s' is internal, and it can't be deleted."), property));
|
|
|
|
return;
|
|
|
|
}
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
undo_redo->create_action(TTR("Delete Item"));
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
Variant value = ProjectSettings::get_singleton()->get(property);
|
|
|
|
int order = ProjectSettings::get_singleton()->get_order(property);
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", property);
|
|
|
|
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", property, value);
|
|
|
|
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", property, order);
|
2020-06-19 09:56:24 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
undo_redo->add_do_method(globals_editor, "update_category_list");
|
|
|
|
undo_redo->add_undo_method(globals_editor, "update_category_list");
|
2020-06-19 09:56:24 +00:00
|
|
|
|
|
|
|
undo_redo->add_do_method(this, "_settings_changed");
|
|
|
|
undo_redo->add_undo_method(this, "_settings_changed");
|
2020-07-10 22:52:52 +00:00
|
|
|
|
2020-06-19 09:56:24 +00:00
|
|
|
undo_redo->commit_action();
|
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::_save() {
|
|
|
|
Error err = ProjectSettings::get_singleton()->save();
|
|
|
|
message->set_text(err != OK ? TTR("Error saving settings.") : TTR("Settings saved OK."));
|
|
|
|
message->popup_centered(Size2(300, 100) * EDSCALE);
|
2020-06-19 09:56:24 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::_settings_prop_edited(const String &p_name) {
|
|
|
|
// Method needed to discard the mandatory argument of the property_edited signal
|
|
|
|
_settings_changed();
|
2020-06-19 09:56:24 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::_settings_changed() {
|
|
|
|
timer->start();
|
2020-06-19 09:56:24 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::queue_save() {
|
|
|
|
_settings_changed();
|
2020-06-23 11:48:59 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::_copy_to_platform_about_to_show() {
|
|
|
|
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");
|
|
|
|
// Not available as an export platform yet, so it needs to be added manually
|
|
|
|
presets.insert("Server");
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) {
|
|
|
|
List<String> p;
|
|
|
|
EditorExport::get_singleton()->get_export_platform(i)->get_platform_features(&p);
|
|
|
|
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-10 22:52:52 +00:00
|
|
|
for (int i = 0; i < EditorExport::get_singleton()->get_export_preset_count(); i++) {
|
|
|
|
List<String> p;
|
|
|
|
EditorExport::get_singleton()->get_export_preset(i)->get_platform()->get_preset_features(EditorExport::get_singleton()->get_export_preset(i), &p);
|
|
|
|
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-10 22:52:52 +00:00
|
|
|
String custom = EditorExport::get_singleton()->get_export_preset(i)->get_custom_features();
|
|
|
|
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-10 22:52:52 +00:00
|
|
|
popup_copy_to_feature->get_popup()->clear();
|
|
|
|
int id = 0;
|
|
|
|
for (Set<String>::Element *E = presets.front(); E; E = E->next()) {
|
|
|
|
popup_copy_to_feature->get_popup()->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
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
void ProjectSettingsEditor::_copy_to_platform(int p_which) {
|
|
|
|
String path = globals_editor->get_inspector()->get_selected_path();
|
|
|
|
if (path == String()) {
|
|
|
|
EditorNode::get_singleton()->show_warning(TTR("Select a setting item first!"));
|
|
|
|
return;
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
String property = globals_editor->get_current_section().plus_file(path);
|
|
|
|
|
|
|
|
undo_redo->create_action(TTR("Override for Feature"));
|
|
|
|
|
|
|
|
Variant value = ProjectSettings::get_singleton()->get(property);
|
|
|
|
if (property.find(".") != -1) { //overwriting overwrite, keep overwrite
|
|
|
|
undo_redo->add_do_method(ProjectSettings::get_singleton(), "clear", property);
|
|
|
|
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", property, value);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
String feature = popup_copy_to_feature->get_popup()->get_item_text(p_which);
|
|
|
|
String new_path = property + "." + feature;
|
|
|
|
|
|
|
|
undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", new_path, value);
|
|
|
|
if (ProjectSettings::get_singleton()->has_setting(new_path)) {
|
|
|
|
undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", new_path, ProjectSettings::get_singleton()->get(new_path));
|
2020-06-19 09:56:24 +00:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
undo_redo->add_do_method(globals_editor, "update_category_list");
|
|
|
|
undo_redo->add_undo_method(globals_editor, "update_category_list");
|
|
|
|
|
|
|
|
undo_redo->add_do_method(this, "_settings_changed");
|
|
|
|
undo_redo->add_undo_method(this, "_settings_changed");
|
|
|
|
|
|
|
|
undo_redo->commit_action();
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-07-19 20:00:46 +00:00
|
|
|
void ProjectSettingsEditor::_toggle_search_bar(bool p_pressed) {
|
2018-07-19 21:58:15 +00:00
|
|
|
globals_editor->get_inspector()->set_use_filter(p_pressed);
|
2016-01-23 19:05:27 +00:00
|
|
|
|
|
|
|
if (p_pressed) {
|
|
|
|
search_bar->show();
|
|
|
|
add_prop_bar->hide();
|
|
|
|
search_box->grab_focus();
|
|
|
|
search_box->select_all();
|
|
|
|
} else {
|
2019-02-08 22:59:51 +00:00
|
|
|
search_box->clear();
|
2016-01-23 19:05:27 +00:00
|
|
|
search_bar->hide();
|
|
|
|
add_prop_bar->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-19 20:00:46 +00:00
|
|
|
void ProjectSettingsEditor::set_plugins_page() {
|
2017-03-05 15:44:50 +00:00
|
|
|
tab_container->set_current_tab(plugin_settings->get_index());
|
2016-03-12 13:44:12 +00:00
|
|
|
}
|
|
|
|
|
2017-09-03 13:29:56 +00:00
|
|
|
TabContainer *ProjectSettingsEditor::get_tabs() {
|
|
|
|
return tab_container;
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2017-07-19 20:00:46 +00:00
|
|
|
void ProjectSettingsEditor::_bind_methods() {
|
2019-10-06 15:13:56 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_unhandled_input"), &ProjectSettingsEditor::_unhandled_input);
|
2017-07-19 20:00:46 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("_save"), &ProjectSettingsEditor::_save);
|
2018-07-19 21:58:15 +00:00
|
|
|
|
2017-09-03 13:29:56 +00:00
|
|
|
ClassDB::bind_method(D_METHOD("get_tabs"), &ProjectSettingsEditor::get_tabs);
|
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
|
|
|
|
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);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
VBoxContainer *props_base = memnew(VBoxContainer);
|
2020-07-10 22:52:52 +00:00
|
|
|
props_base->set_name(TTR("General"));
|
2015-11-21 16:42:15 +00:00
|
|
|
props_base->set_alignment(BoxContainer::ALIGN_BEGIN);
|
|
|
|
props_base->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
2014-02-10 01:10:30 +00:00
|
|
|
tab_container->add_child(props_base);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
HBoxContainer *hbc = memnew(HBoxContainer);
|
2015-11-21 16:42:15 +00:00
|
|
|
hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
props_base->add_child(hbc);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2018-02-02 16:38:45 +00:00
|
|
|
search_button = memnew(Button);
|
2020-07-10 22:52:52 +00:00
|
|
|
search_button->set_text(TTR("Search"));
|
2016-01-23 19:05:27 +00:00
|
|
|
search_button->set_toggle_mode(true);
|
|
|
|
search_button->set_pressed(false);
|
2020-02-21 17:28:45 +00:00
|
|
|
search_button->connect("toggled", callable_mp(this, &ProjectSettingsEditor::_toggle_search_bar));
|
2020-07-10 22:52:52 +00:00
|
|
|
hbc->add_child(search_button);
|
2016-01-23 19:05:27 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
hbc->add_child(memnew(VSeparator));
|
2016-01-23 19:05:27 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
add_prop_bar = memnew(HBoxContainer);
|
2016-01-23 19:05:27 +00:00
|
|
|
add_prop_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
hbc->add_child(add_prop_bar);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Label *l = memnew(Label);
|
2016-05-04 01:25:37 +00:00
|
|
|
l->set_text(TTR("Category:"));
|
2020-07-10 22:52:52 +00:00
|
|
|
add_prop_bar->add_child(l);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
category = memnew(LineEdit);
|
2015-11-21 16:42:15 +00:00
|
|
|
category->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
2020-02-21 17:28:45 +00:00
|
|
|
category->connect("text_entered", callable_mp(this, &ProjectSettingsEditor::_item_adds));
|
2020-07-10 22:52:52 +00:00
|
|
|
add_prop_bar->add_child(category);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
l = memnew(Label);
|
2016-05-04 01:25:37 +00:00
|
|
|
l->set_text(TTR("Property:"));
|
2020-07-10 22:52:52 +00:00
|
|
|
add_prop_bar->add_child(l);
|
2015-11-21 16:42:15 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
property = memnew(LineEdit);
|
2015-11-21 16:42:15 +00:00
|
|
|
property->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
2020-02-21 17:28:45 +00:00
|
|
|
property->connect("text_entered", callable_mp(this, &ProjectSettingsEditor::_item_adds));
|
2020-07-10 22:52:52 +00:00
|
|
|
add_prop_bar->add_child(property);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
l = memnew(Label);
|
2016-05-04 01:25:37 +00:00
|
|
|
l->set_text(TTR("Type:"));
|
2020-07-10 22:52:52 +00:00
|
|
|
add_prop_bar->add_child(l);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
type = memnew(OptionButton);
|
2015-11-21 16:42:15 +00:00
|
|
|
type->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
2016-01-23 19:05:27 +00:00
|
|
|
add_prop_bar->add_child(type);
|
2019-10-07 15:17:13 +00:00
|
|
|
|
|
|
|
// Start at 1 to avoid adding "Nil" as an option
|
|
|
|
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
|
2019-10-25 21:56:08 +00:00
|
|
|
type->add_item(Variant::get_type_name(Variant::Type(i)));
|
2019-10-07 15:17:13 +00:00
|
|
|
}
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Button *add = memnew(Button);
|
2016-05-04 01:25:37 +00:00
|
|
|
add->set_text(TTR("Add"));
|
2020-02-21 17:28:45 +00:00
|
|
|
add->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_item_add));
|
2020-07-10 22:52:52 +00:00
|
|
|
add_prop_bar->add_child(add);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
search_bar = memnew(HBoxContainer);
|
2016-01-23 19:05:27 +00:00
|
|
|
search_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
search_bar->hide();
|
2020-07-10 22:52:52 +00:00
|
|
|
hbc->add_child(search_bar);
|
2016-01-23 19:05:27 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
search_box = memnew(LineEdit);
|
2016-01-23 19:05:27 +00:00
|
|
|
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
search_bar->add_child(search_box);
|
|
|
|
|
2018-07-19 21:58:15 +00:00
|
|
|
globals_editor = memnew(SectionedInspector);
|
|
|
|
globals_editor->get_inspector()->set_undo_redo(EditorNode::get_singleton()->get_undo_redo());
|
2015-11-21 16:42:15 +00:00
|
|
|
globals_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
2017-07-18 00:05:38 +00:00
|
|
|
globals_editor->register_search_box(search_box);
|
2020-02-21 17:28:45 +00:00
|
|
|
globals_editor->get_inspector()->connect("property_selected", callable_mp(this, &ProjectSettingsEditor::_item_selected));
|
|
|
|
globals_editor->get_inspector()->connect("property_edited", callable_mp(this, &ProjectSettingsEditor::_settings_prop_edited));
|
|
|
|
globals_editor->get_inspector()->connect("restart_requested", callable_mp(this, &ProjectSettingsEditor::_editor_restart_request));
|
2020-07-10 22:52:52 +00:00
|
|
|
props_base->add_child(globals_editor);
|
2015-11-21 16:42:15 +00:00
|
|
|
|
2017-07-19 20:00:46 +00:00
|
|
|
Button *del = memnew(Button);
|
|
|
|
del->set_text(TTR("Delete"));
|
2020-02-21 17:28:45 +00:00
|
|
|
del->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_item_del));
|
2020-07-10 22:52:52 +00:00
|
|
|
hbc->add_child(del);
|
2015-11-21 16:42:15 +00:00
|
|
|
|
2017-07-19 20:00:46 +00:00
|
|
|
add_prop_bar->add_child(memnew(VSeparator));
|
2015-11-21 16:42:15 +00:00
|
|
|
|
2017-07-19 20:00:46 +00:00
|
|
|
popup_copy_to_feature = memnew(MenuButton);
|
2018-04-22 17:36:01 +00:00
|
|
|
popup_copy_to_feature->set_text(TTR("Override For..."));
|
2017-07-19 20:00:46 +00:00
|
|
|
popup_copy_to_feature->set_disabled(true);
|
|
|
|
add_prop_bar->add_child(popup_copy_to_feature);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2020-02-21 17:28:45 +00:00
|
|
|
popup_copy_to_feature->get_popup()->connect("id_pressed", callable_mp(this, &ProjectSettingsEditor::_copy_to_platform));
|
2020-03-12 12:37:40 +00:00
|
|
|
popup_copy_to_feature->get_popup()->connect("about_to_popup", callable_mp(this, &ProjectSettingsEditor::_copy_to_platform_about_to_show));
|
2017-07-19 20:00:46 +00:00
|
|
|
|
2016-05-04 01:25:37 +00:00
|
|
|
get_ok()->set_text(TTR("Close"));
|
2014-02-10 01:10:30 +00:00
|
|
|
set_hide_on_ok(true);
|
|
|
|
|
2018-07-19 21:58:15 +00:00
|
|
|
restart_container = memnew(PanelContainer);
|
|
|
|
props_base->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);
|
|
|
|
|
2017-09-01 21:08:50 +00:00
|
|
|
message = memnew(AcceptDialog);
|
2014-02-10 01:10:30 +00:00
|
|
|
add_child(message);
|
|
|
|
|
2020-07-10 22:52:52 +00:00
|
|
|
inputmap_editor = memnew(InputMapEditor);
|
|
|
|
inputmap_editor->set_name(TTR("Input Map"));
|
|
|
|
inputmap_editor->connect("inputmap_changed", callable_mp(this, &ProjectSettingsEditor::_settings_changed));
|
|
|
|
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"));
|
|
|
|
localization_editor->connect("localization_changed", callable_mp(this, &ProjectSettingsEditor::_settings_changed));
|
|
|
|
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-02-21 17:28:45 +00:00
|
|
|
autoload_settings->connect("autoload_changed", callable_mp(this, &ProjectSettingsEditor::_settings_changed));
|
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"));
|
|
|
|
shaders_global_variables_editor->connect("globals_changed", callable_mp(this, &ProjectSettingsEditor::_settings_changed));
|
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-02-21 22:26:13 +00:00
|
|
|
timer->connect("timeout", callable_mp(ProjectSettings::get_singleton(), &ProjectSettings::save));
|
2014-02-10 01:10:30 +00:00
|
|
|
timer->set_one_shot(true);
|
|
|
|
add_child(timer);
|
|
|
|
}
|