|
@@ -33,6 +33,7 @@
|
|
|
#include "editor_node.h"
|
|
|
#include "scene/gui/margin_container.h"
|
|
|
#include "translation.h"
|
|
|
+#include "global_constants.h"
|
|
|
|
|
|
ProjectSettings *ProjectSettings::singleton=NULL;
|
|
|
|
|
@@ -777,10 +778,11 @@ void ProjectSettings::_translation_file_open() {
|
|
|
void ProjectSettings::_autoload_file_callback(const String& p_path) {
|
|
|
|
|
|
autoload_add_path->set_text(p_path);
|
|
|
- if (autoload_add_name->get_text().strip_edges()==String()) {
|
|
|
+ //if (autoload_add_name->get_text().strip_edges()==String()) {
|
|
|
|
|
|
autoload_add_name->set_text( p_path.get_file().basename() );
|
|
|
- }
|
|
|
+ //}
|
|
|
+
|
|
|
//_translation_add(p_translation);
|
|
|
}
|
|
|
|
|
@@ -789,6 +791,40 @@ void ProjectSettings::_autoload_file_open() {
|
|
|
autoload_file_open->popup_centered_ratio();
|
|
|
}
|
|
|
|
|
|
+void ProjectSettings::_autoload_edited() {
|
|
|
+
|
|
|
+ if (updating_autoload)
|
|
|
+ return;
|
|
|
+
|
|
|
+ TreeItem *ti = autoload_list->get_edited();
|
|
|
+ if (!ti || autoload_list->get_edited_column()!=2)
|
|
|
+ return;
|
|
|
+
|
|
|
+ updating_autoload=true;
|
|
|
+ bool checked=ti->is_checked(2);
|
|
|
+
|
|
|
+ String base="autoload/"+ti->get_text(0);
|
|
|
+
|
|
|
+ String path = Globals::get_singleton()->get(base);
|
|
|
+
|
|
|
+ if (path.begins_with("*"))
|
|
|
+ path=path.substr(1,path.length());
|
|
|
+
|
|
|
+ if (checked)
|
|
|
+ path="*"+path;
|
|
|
+
|
|
|
+ undo_redo->create_action("Toggle Autoload GlobalVar");
|
|
|
+ undo_redo->add_do_property(Globals::get_singleton(),base,path);
|
|
|
+ undo_redo->add_undo_property(Globals::get_singleton(),base,Globals::get_singleton()->get(base));
|
|
|
+ undo_redo->add_do_method(this,"_update_autoload");
|
|
|
+ undo_redo->add_undo_method(this,"_update_autoload");
|
|
|
+ undo_redo->add_do_method(this,"_settings_changed");
|
|
|
+ undo_redo->add_undo_method(this,"_settings_changed");
|
|
|
+ undo_redo->commit_action();
|
|
|
+ updating_autoload=false;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
void ProjectSettings::_autoload_add() {
|
|
|
|
|
|
String name = autoload_add_name->get_text();
|
|
@@ -799,6 +835,35 @@ void ProjectSettings::_autoload_add() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if (ObjectTypeDB::type_exists(name)) {
|
|
|
+
|
|
|
+ message->set_text("Invalid Name.Must not collide with an existing engine class name.");
|
|
|
+ message->popup_centered(Size2(300,100));
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ for(int i=0;i<Variant::VARIANT_MAX;i++) {
|
|
|
+ if (Variant::get_type_name(Variant::Type(i))==name) {
|
|
|
+
|
|
|
+ message->set_text("Invalid Name.Must not collide with an existing buit-in type name.");
|
|
|
+ message->popup_centered(Size2(300,100));
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for(int i=0;i<GlobalConstants::get_global_constant_count();i++) {
|
|
|
+
|
|
|
+ if (GlobalConstants::get_global_constant_name(i)==name) {
|
|
|
+
|
|
|
+ message->set_text("Invalid Name.Must not collide with an existing global constant name.");
|
|
|
+ message->popup_centered(Size2(300,100));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
String path = autoload_add_path->get_text();
|
|
|
if (!FileAccess::exists(path)) {
|
|
|
message->set_text("Invalid Path.\nFile does not exist.");
|
|
@@ -815,7 +880,7 @@ void ProjectSettings::_autoload_add() {
|
|
|
|
|
|
undo_redo->create_action("Add Autoload");
|
|
|
name = "autoload/"+name;
|
|
|
- undo_redo->add_do_property(Globals::get_singleton(),name,path);
|
|
|
+ undo_redo->add_do_property(Globals::get_singleton(),name,"*"+path);
|
|
|
if (Globals::get_singleton()->has(name))
|
|
|
undo_redo->add_undo_property(Globals::get_singleton(),name,Globals::get_singleton()->get(name));
|
|
|
else
|
|
@@ -1208,6 +1273,11 @@ void ProjectSettings::_update_translations() {
|
|
|
|
|
|
void ProjectSettings::_update_autoload() {
|
|
|
|
|
|
+ if (updating_autoload)
|
|
|
+ return;
|
|
|
+
|
|
|
+ updating_autoload=true;
|
|
|
+
|
|
|
autoload_list->clear();
|
|
|
TreeItem *root = autoload_list->create_item();
|
|
|
autoload_list->set_hide_root(true);
|
|
@@ -1222,18 +1292,31 @@ void ProjectSettings::_update_autoload() {
|
|
|
continue;
|
|
|
|
|
|
String name = pi.name.get_slice("/",1);
|
|
|
+ String path = Globals::get_singleton()->get(pi.name);
|
|
|
+
|
|
|
if (name=="")
|
|
|
continue;
|
|
|
-
|
|
|
+ bool global=false;
|
|
|
+ if (path.begins_with("*")) {
|
|
|
+ path=path.substr(1,path.length());
|
|
|
+ global=true;
|
|
|
+ }
|
|
|
TreeItem *t = autoload_list->create_item(root);
|
|
|
t->set_text(0,name);
|
|
|
- t->set_text(1,Globals::get_singleton()->get(pi.name));
|
|
|
- t->add_button(1,get_icon("MoveUp","EditorIcons"),1);
|
|
|
- t->add_button(1,get_icon("MoveDown","EditorIcons"),2);
|
|
|
- t->add_button(1,get_icon("Del","EditorIcons"),0);
|
|
|
+ t->set_text(1,path);
|
|
|
+ t->set_cell_mode(2,TreeItem::CELL_MODE_CHECK);
|
|
|
+ t->set_editable(2,true);
|
|
|
+ t->set_text(2,"Enable");
|
|
|
+ t->set_checked(2,global);
|
|
|
+ t->add_button(3,get_icon("MoveUp","EditorIcons"),1);
|
|
|
+ t->add_button(3,get_icon("MoveDown","EditorIcons"),2);
|
|
|
+ t->add_button(3,get_icon("Del","EditorIcons"),0);
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
|
+ updating_autoload=false;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void ProjectSettings::_toggle_search_bar(bool p_pressed) {
|
|
@@ -1302,6 +1385,7 @@ void ProjectSettings::_bind_methods() {
|
|
|
ObjectTypeDB::bind_method(_MD("_autoload_file_callback"),&ProjectSettings::_autoload_file_callback);
|
|
|
ObjectTypeDB::bind_method(_MD("_update_autoload"),&ProjectSettings::_update_autoload);
|
|
|
ObjectTypeDB::bind_method(_MD("_autoload_delete"),&ProjectSettings::_autoload_delete);
|
|
|
+ ObjectTypeDB::bind_method(_MD("_autoload_edited"),&ProjectSettings::_autoload_edited);
|
|
|
|
|
|
ObjectTypeDB::bind_method(_MD("_clear_search_box"),&ProjectSettings::_clear_search_box);
|
|
|
ObjectTypeDB::bind_method(_MD("_toggle_search_bar"),&ProjectSettings::_toggle_search_bar);
|
|
@@ -1694,11 +1778,24 @@ ProjectSettings::ProjectSettings(EditorData *p_data) {
|
|
|
autoload_file_open->set_mode(EditorFileDialog::MODE_OPEN_FILE);
|
|
|
autoload_file_open->connect("file_selected",this,"_autoload_file_callback");
|
|
|
|
|
|
- autoload_list->set_columns(2);
|
|
|
+ autoload_list->set_columns(4);
|
|
|
autoload_list->set_column_titles_visible(true);
|
|
|
- autoload_list->set_column_title(0,"name");
|
|
|
- autoload_list->set_column_title(1,"path");
|
|
|
+ autoload_list->set_column_title(0,"Name");
|
|
|
+ autoload_list->set_column_expand(0,true);
|
|
|
+ autoload_list->set_column_min_width(0,100);
|
|
|
+ autoload_list->set_column_title(1,"Path");
|
|
|
+ autoload_list->set_column_expand(1,true);
|
|
|
+ autoload_list->set_column_min_width(1,100);
|
|
|
+ autoload_list->set_column_title(2,"GlobalVar");
|
|
|
+ autoload_list->set_column_expand(2,false);
|
|
|
+ autoload_list->set_column_min_width(2,80);
|
|
|
+ autoload_list->set_column_expand(3,false);
|
|
|
+ autoload_list->set_column_min_width(3,80);
|
|
|
+
|
|
|
autoload_list->connect("button_pressed",this,"_autoload_delete");
|
|
|
+ autoload_list->connect("item_edited",this,"_autoload_edited");
|
|
|
+
|
|
|
+ updating_autoload=false;
|
|
|
|
|
|
}
|
|
|
|