2014-02-10 01:10:30 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* settings_config_dialog.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* http://www.godotengine.org */
|
|
|
|
/*************************************************************************/
|
2016-01-01 13:50:53 +00:00
|
|
|
/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
|
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. */
|
|
|
|
/*************************************************************************/
|
|
|
|
#include "settings_config_dialog.h"
|
|
|
|
#include "editor_settings.h"
|
|
|
|
#include "scene/gui/margin_container.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "editor_file_system.h"
|
|
|
|
void EditorSettingsDialog::ok_pressed() {
|
|
|
|
|
|
|
|
if (!EditorSettings::get_singleton())
|
|
|
|
return;
|
|
|
|
|
|
|
|
_settings_save();
|
|
|
|
timer->stop();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorSettingsDialog::_settings_changed() {
|
|
|
|
|
|
|
|
|
|
|
|
timer->start();
|
2016-04-12 14:45:31 +00:00
|
|
|
property_editor->get_property_editor()->update_tree(); // else color's won't update when theme is selected.
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditorSettingsDialog::_settings_save() {
|
|
|
|
|
|
|
|
|
|
|
|
EditorSettings::get_singleton()->notify_changes();
|
|
|
|
EditorSettings::get_singleton()->save();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorSettingsDialog::cancel_pressed() {
|
|
|
|
|
|
|
|
if (!EditorSettings::get_singleton())
|
|
|
|
return;
|
|
|
|
|
|
|
|
EditorSettings::get_singleton()->notify_changes();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EditorSettingsDialog::popup_edit_settings() {
|
|
|
|
|
|
|
|
if (!EditorSettings::get_singleton())
|
|
|
|
return;
|
|
|
|
|
2016-04-12 14:45:31 +00:00
|
|
|
EditorSettings::get_singleton()->list_text_editor_themes(); // make sure we have an up to date list of themes
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
property_editor->edit(EditorSettings::get_singleton());
|
2015-12-16 02:39:36 +00:00
|
|
|
property_editor->get_property_editor()->update_tree();
|
2015-11-21 16:42:15 +00:00
|
|
|
|
2016-01-23 19:05:27 +00:00
|
|
|
search_box->select_all();
|
|
|
|
search_box->grab_focus();
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
popup_centered_ratio(0.7);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-01-23 19:05:27 +00:00
|
|
|
void EditorSettingsDialog::_clear_search_box() {
|
|
|
|
|
|
|
|
if (search_box->get_text()=="")
|
|
|
|
return;
|
|
|
|
|
|
|
|
search_box->clear();
|
|
|
|
property_editor->get_property_editor()->update_tree();
|
|
|
|
}
|
|
|
|
|
2014-02-10 01:10:30 +00:00
|
|
|
void EditorSettingsDialog::_notification(int p_what) {
|
|
|
|
|
2014-11-06 00:20:42 +00:00
|
|
|
if (p_what==NOTIFICATION_ENTER_TREE) {
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-01-23 19:05:27 +00:00
|
|
|
clear_button->set_icon(get_icon("Close","EditorIcons"));
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorSettingsDialog::_bind_methods() {
|
|
|
|
|
|
|
|
ObjectTypeDB::bind_method(_MD("_settings_save"),&EditorSettingsDialog::_settings_save);
|
|
|
|
ObjectTypeDB::bind_method(_MD("_settings_changed"),&EditorSettingsDialog::_settings_changed);
|
2016-01-23 19:05:27 +00:00
|
|
|
ObjectTypeDB::bind_method(_MD("_clear_search_box"),&EditorSettingsDialog::_clear_search_box);
|
2014-02-10 01:10:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EditorSettingsDialog::EditorSettingsDialog() {
|
|
|
|
|
2016-05-04 01:25:37 +00:00
|
|
|
set_title(TTR("Editor Settings"));
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
tabs = memnew( TabContainer );
|
|
|
|
add_child(tabs);
|
|
|
|
set_child_rect(tabs);
|
|
|
|
|
2016-01-23 19:05:27 +00:00
|
|
|
VBoxContainer *vbc = memnew( VBoxContainer );
|
|
|
|
tabs->add_child(vbc);
|
2016-05-04 01:25:37 +00:00
|
|
|
vbc->set_name(TTR("General"));
|
2016-01-23 19:05:27 +00:00
|
|
|
|
|
|
|
HBoxContainer *hbc = memnew( HBoxContainer );
|
|
|
|
hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
vbc->add_child(hbc);
|
|
|
|
|
|
|
|
Label *l = memnew( Label );
|
2016-05-18 22:08:12 +00:00
|
|
|
l->set_text(TTR("Search:")+" ");
|
2016-01-23 19:05:27 +00:00
|
|
|
hbc->add_child(l);
|
|
|
|
|
|
|
|
search_box = memnew( LineEdit );
|
|
|
|
search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
|
|
|
hbc->add_child(search_box);
|
|
|
|
|
|
|
|
clear_button = memnew( ToolButton );
|
|
|
|
hbc->add_child(clear_button);
|
|
|
|
clear_button->connect("pressed",this,"_clear_search_box");
|
|
|
|
|
2015-12-16 02:39:36 +00:00
|
|
|
property_editor = memnew( SectionedPropertyEditor );
|
|
|
|
//property_editor->hide_top_label();
|
2016-01-23 19:05:27 +00:00
|
|
|
property_editor->get_property_editor()->set_use_filter(true);
|
|
|
|
property_editor->get_property_editor()->register_text_enter(search_box);
|
2015-11-21 16:42:15 +00:00
|
|
|
property_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
2016-01-23 19:05:27 +00:00
|
|
|
vbc->add_child(property_editor);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-01-23 19:05:27 +00:00
|
|
|
vbc = memnew( VBoxContainer );
|
2014-02-10 01:10:30 +00:00
|
|
|
tabs->add_child(vbc);
|
2016-05-04 01:25:37 +00:00
|
|
|
vbc->set_name(TTR("Plugins"));
|
2014-02-10 01:10:30 +00:00
|
|
|
|
2016-01-23 19:05:27 +00:00
|
|
|
hbc = memnew( HBoxContainer );
|
2014-02-10 01:10:30 +00:00
|
|
|
vbc->add_child(hbc);
|
2016-05-18 22:08:12 +00:00
|
|
|
hbc->add_child( memnew( Label(TTR("Plugin List:")+" ") ));
|
2014-02-10 01:10:30 +00:00
|
|
|
hbc->add_spacer();
|
2016-02-05 23:05:34 +00:00
|
|
|
//Button *load = memnew( Button );
|
2016-05-18 22:08:12 +00:00
|
|
|
//load->set_text("Load..");
|
2016-02-05 23:05:34 +00:00
|
|
|
//hbc->add_child(load);
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
|
2016-05-18 22:08:12 +00:00
|
|
|
//get_ok()->set_text("Apply");
|
2014-02-10 01:10:30 +00:00
|
|
|
set_hide_on_ok(true);
|
2016-05-18 22:08:12 +00:00
|
|
|
//get_cancel()->set_text("Close");
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
timer = memnew( Timer );
|
|
|
|
timer->set_wait_time(1.5);
|
|
|
|
timer->connect("timeout",this,"_settings_save");
|
|
|
|
timer->set_one_shot(true);
|
|
|
|
add_child(timer);
|
|
|
|
EditorSettings::get_singleton()->connect("settings_changed",this,"_settings_changed");
|
2016-05-04 01:25:37 +00:00
|
|
|
get_ok()->set_text(TTR("Close"));
|
2014-02-10 01:10:30 +00:00
|
|
|
|
|
|
|
updating=false;
|
|
|
|
|
|
|
|
}
|