summaryrefslogtreecommitdiff
path: root/tools/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'tools/editor/plugins')
-rw-r--r--tools/editor/plugins/canvas_item_editor_plugin.cpp56
-rw-r--r--tools/editor/plugins/multimesh_editor_plugin.cpp2
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp396
-rw-r--r--tools/editor/plugins/script_editor_plugin.h52
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.cpp120
-rw-r--r--tools/editor/plugins/tile_map_editor_plugin.h11
6 files changed, 439 insertions, 198 deletions
diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp
index fef5890f11..f2738f0a62 100644
--- a/tools/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp
@@ -150,8 +150,56 @@ void CanvasItemEditor::_unhandled_key_input(const InputEvent& p_ev) {
_tool_select(TOOL_MOVE);
if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_E)
_tool_select(TOOL_ROTATE);
- if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_V && drag==DRAG_ALL && can_move_pivot)
- drag=DRAG_PIVOT;
+ if (p_ev.key.pressed && !p_ev.key.echo && p_ev.key.scancode==KEY_V && drag==DRAG_NONE && can_move_pivot) {
+ if (p_ev.key.mod.shift) {
+ //move drag pivot
+ drag=DRAG_PIVOT;
+ } else if (!Input::get_singleton()->is_mouse_button_pressed(0)) {
+
+ List<Node*> &selection = editor_selection->get_selected_node_list();
+
+ Vector2 mouse_pos = viewport->get_local_mouse_pos();
+ if (selection.size() && viewport->get_rect().has_point(mouse_pos)) {
+ //just in case, make it work if over viewport
+ mouse_pos=transform.affine_inverse().xform(mouse_pos);
+ mouse_pos=snap_point(mouse_pos);
+
+ undo_redo->create_action("Move Pivot");
+
+ for(List<Node*>::Element *E=selection.front();E;E=E->next()) {
+
+ Node2D *n2d = E->get()->cast_to<Node2D>();
+
+ if (n2d && n2d->edit_has_pivot()) {
+
+ Vector2 offset = n2d->edit_get_pivot();
+ Vector2 gpos = n2d->get_global_pos();
+
+ Vector2 motion_ofs = gpos-mouse_pos;
+
+ undo_redo->add_do_method(n2d,"set_global_pos",mouse_pos);
+ undo_redo->add_do_method(n2d,"edit_set_pivot",offset+n2d->get_global_transform().affine_inverse().basis_xform(motion_ofs));
+ undo_redo->add_undo_method(n2d,"set_global_pos",gpos);
+ undo_redo->add_undo_method(n2d,"edit_set_pivot",offset);
+ for(int i=0;i<n2d->get_child_count();i++) {
+ Node2D *n2dc = n2d->get_child(i)->cast_to<Node2D>();
+ if (!n2dc)
+ continue;
+
+ undo_redo->add_do_method(n2dc,"set_global_pos",n2dc->get_global_pos());
+ undo_redo->add_undo_method(n2dc,"set_global_pos",n2dc->get_global_pos());
+
+ }
+
+ }
+
+ }
+
+ undo_redo->commit_action();
+ }
+
+ }
+ }
}
@@ -1685,7 +1733,7 @@ void CanvasItemEditor::_viewport_draw() {
viewport->draw_line(endpoints[i],endpoints[(i+1)%4],c,2);
}
- if (single && (tool==TOOL_SELECT || tool == TOOL_MOVE)) { //kind of sucks
+ if (single && (tool==TOOL_SELECT || tool == TOOL_MOVE || tool == TOOL_ROTATE)) { //kind of sucks
if (canvas_item->cast_to<Node2D>()) {
@@ -2854,7 +2902,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
hb->add_child(select_button);
select_button->connect("pressed",this,"_tool_select",make_binds(TOOL_SELECT));
select_button->set_pressed(true);
- select_button->set_tooltip("Select Mode (Q)\n"+keycode_get_string(KEY_MASK_CMD)+"Drag: Rotate\nAlt+Drag: Move\nPress 'v' to Move Pivot (while moving)");
+ select_button->set_tooltip("Select Mode (Q)\n"+keycode_get_string(KEY_MASK_CMD)+"Drag: Rotate\nAlt+Drag: Move\nPress 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).");
move_button = memnew( ToolButton );
move_button->set_toggle_mode(true);
diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp
index d858f3b896..0df906117e 100644
--- a/tools/editor/plugins/multimesh_editor_plugin.cpp
+++ b/tools/editor/plugins/multimesh_editor_plugin.cpp
@@ -305,7 +305,7 @@ void MultiMeshEditor::edit(MultiMeshInstance *p_multimesh) {
void MultiMeshEditor::_browse(bool p_source) {
browsing_source=p_source;
- std->get_tree()->set_marked(node,false);
+ std->get_scene_tree()->set_marked(node,false);
std->popup_centered_ratio();
if (p_source)
std->set_title("Select a Source Mesh:");
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index f5ba6a08e6..71ce040b05 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -38,10 +38,12 @@
#include "os/file_access.h"
#include "scene/main/viewport.h"
#include "os/keyboard.h"
-/*** SCRIPT EDITOR ****/
+#include "os/input.h"
+/*** SCRIPT EDITOR ****/
+#define SORT_SCRIPT_LIST
void ScriptEditorQuickOpen::popup(const Vector<String>& p_functions, bool p_dontclear) {
@@ -118,6 +120,8 @@ void ScriptEditorQuickOpen::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
connect("confirmed",this,"_confirmed");
+
+
}
}
@@ -286,8 +290,19 @@ void ScriptTextEditor::reload_text() {
ERR_FAIL_COND(script.is_null()) ;
- get_text_edit()->set_text(script->get_source_code());
- get_text_edit()->clear_undo_history();
+ TextEdit *te = get_text_edit();
+ int column = te->cursor_get_column();
+ int row = te->cursor_get_line();
+ int h = te->get_h_scroll();
+ int v = te->get_v_scroll();
+
+ te->set_text(script->get_source_code());
+ te->clear_undo_history();
+ te->cursor_set_line(row);
+ te->cursor_set_column(column);
+ te->set_h_scroll(h);
+ te->set_v_scroll(v);
+
_line_col_changed();
}
@@ -296,12 +311,11 @@ void ScriptTextEditor::_notification(int p_what) {
if (p_what==NOTIFICATION_READY) {
- _update_name();
+ //emit_signal("name_changed");
}
}
-void ScriptTextEditor::_update_name() {
-
+String ScriptTextEditor::get_name() {
String name;
if (script->get_path().find("local://")==-1 && script->get_path().find("::")==-1) {
@@ -314,21 +328,20 @@ void ScriptTextEditor::_update_name() {
else
name=script->get_type()+"("+itos(script->get_instance_ID())+")";
+ return name;
- if (name!=String(get_name())) {
+}
- set_name(name);
+Ref<Texture> ScriptTextEditor::get_icon() {
+ if (get_parent_control() && get_parent_control()->has_icon(script->get_type(),"EditorIcons")) {
+ return get_parent_control()->get_icon(script->get_type(),"EditorIcons");
}
- if (!has_meta("_tab_icon")) {
- if (get_parent_control() && get_parent_control()->has_icon(script->get_type(),"EditorIcons")) {
- set_meta("_tab_icon",get_parent_control()->get_icon(script->get_type(),"EditorIcons"));
- }
- }
+ return Ref<Texture>();
+}
-}
void ScriptTextEditor::set_edited_script(const Ref<Script>& p_script) {
@@ -344,8 +357,7 @@ void ScriptTextEditor::set_edited_script(const Ref<Script>& p_script) {
get_text_edit()->tag_saved_version();
- _update_name();
-
+ emit_signal("name_changed");
_line_col_changed();
}
@@ -384,7 +396,7 @@ void ScriptTextEditor::_validate_script() {
te->set_line_as_marked(i,line==i);
}
- _update_name();
+ emit_signal("name_changed");
}
@@ -418,6 +430,10 @@ void ScriptTextEditor::_code_complete_script(const String& p_code, List<String>*
}
}
+void ScriptTextEditor::_bind_methods() {
+
+ ADD_SIGNAL(MethodInfo("name_changed"));
+}
ScriptTextEditor::ScriptTextEditor() {
@@ -492,11 +508,15 @@ void ScriptEditor::_close_current_tab() {
memdelete(current);
if (idx>=tab_container->get_child_count())
idx=tab_container->get_child_count()-1;
- if (idx>=0)
+ if (idx>=0) {
tab_container->set_current_tab(idx);
+ //script_list->select(idx);
+ }
- _update_window_menu();
- _save_files_state();
+
+
+ _update_script_names();
+ EditorNode::get_singleton()->save_layout();
}
@@ -587,10 +607,10 @@ void ScriptEditor::_res_saved_callback(const Ref<Resource>& p_res) {
ste->get_text_edit()->tag_saved_version();
}
- ste->_update_name();
-
}
+ _update_script_names();
+
}
bool ScriptEditor::_test_script_times_on_disk() {
@@ -1045,7 +1065,7 @@ void ScriptEditor::_menu_option(int p_option) {
if (text != "")
editor->emit_signal("request_help", text);
} break;
- case WINDOW_CLOSE: {
+ case FILE_CLOSE: {
if (current->get_text_edit()->get_version()!=current->get_text_edit()->get_saved_version()) {
erase_tab_confirm->set_text("Close and save changes?\n\""+current->get_name()+"\"");
erase_tab_confirm->popup_centered_minsize();
@@ -1057,16 +1077,18 @@ void ScriptEditor::_menu_option(int p_option) {
if (tab_container->get_current_tab()>0) {
tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()-1);
+ script_list->call_deferred("select",tab_container->get_current_tab()-1);
tab_container->move_child(current,tab_container->get_current_tab()-1);
- _update_window_menu();
+ _update_script_names();
}
} break;
case WINDOW_MOVE_RIGHT: {
if (tab_container->get_current_tab()<tab_container->get_child_count()-1) {
tab_container->call_deferred("set_current_tab",tab_container->get_current_tab()+1);
+ script_list->call_deferred("select",tab_container->get_current_tab()+1);
tab_container->move_child(current,tab_container->get_current_tab()+1);
- _update_window_menu();
+ _update_script_names();
}
@@ -1076,6 +1098,8 @@ void ScriptEditor::_menu_option(int p_option) {
if (p_option>=WINDOW_SELECT_BASE) {
tab_container->set_current_tab(p_option-WINDOW_SELECT_BASE);
+ script_list->select(p_option-WINDOW_SELECT_BASE);
+
}
}
}
@@ -1096,6 +1120,8 @@ void ScriptEditor::_notification(int p_what) {
editor->connect("stop_pressed",this,"_editor_stop");
editor->connect("script_add_function_request",this,"_add_callback");
editor->connect("resource_saved",this,"_res_saved_callback");
+ script_list->connect("item_selected",this,"_script_selected");
+ script_split->connect("dragged",this,"_script_split_dragged");
autosave_timer->connect("timeout",this,"_autosave_scripts");
{
float autosave_time = EditorSettings::get_singleton()->get("text_editor/autosave_interval_secs");
@@ -1113,7 +1139,8 @@ void ScriptEditor::_notification(int p_what) {
}
if (p_what==NOTIFICATION_READY) {
- _update_window_menu();
+
+ get_tree()->connect("tree_changed",this,"_tree_changed");
}
if (p_what==NOTIFICATION_EXIT_TREE) {
@@ -1153,10 +1180,11 @@ static const Node * _find_node_with_script(const Node* p_node, const RefPtr & p_
Dictionary ScriptEditor::get_state() const {
- apply_scripts();
- Dictionary state;
+// apply_scripts();
+ Dictionary state;
+#if 0
Array paths;
int open=-1;
@@ -1189,12 +1217,12 @@ Dictionary ScriptEditor::get_state() const {
if (open!=-1)
state["current"]=open;
-
+#endif
return state;
}
void ScriptEditor::set_state(const Dictionary& p_state) {
-
+#if 0
print_line("attempt set state: "+String(Variant(p_state)));
if (!p_state.has("sources"))
@@ -1231,6 +1259,7 @@ void ScriptEditor::set_state(const Dictionary& p_state) {
if (p_state.has("current")) {
tab_container->set_current_tab(p_state["current"]);
}
+#endif
}
void ScriptEditor::clear() {
@@ -1254,68 +1283,17 @@ void ScriptEditor::clear() {
int idx = tab_container->get_current_tab();
if (idx>=tab_container->get_child_count())
idx=tab_container->get_child_count()-1;
- if (idx>=0)
+ if (idx>=0) {
tab_container->set_current_tab(idx);
-
- _update_window_menu();
-
-
-}
-
-void ScriptEditor::_save_files_state() {
-
- return; //no thank you
-
- String rpath="_open_scripts_"+Globals::get_singleton()->get_resource_path();
- rpath=rpath.replace("\\","_-_");
- rpath=rpath.replace("/","_-_");
- rpath=rpath.replace(":","_");
-
- Vector<String> scripts;
-
- for(int i=0;i<tab_container->get_child_count();i++) {
-
- ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
- if (!ste)
- continue;
-
-
- Ref<Script> script = ste->get_edited_script();
- if (script->get_path()!="" && script->get_path().find("local://")==-1 && script->get_path().find("::")==-1) {
-
-
- scripts.push_back(script->get_path());
- }
+ script_list->select( script_list->find_metadata(idx) );
}
- EditorSettings::get_singleton()->set(rpath,scripts);
- EditorSettings::get_singleton()->save();
-
-}
-
-void ScriptEditor::_load_files_state() {
- return;
-
- String rpath="_open_scripts_"+Globals::get_singleton()->get_resource_path();
- rpath=rpath.replace("\\","_-_");
- rpath=rpath.replace("/","_-_");
- rpath=rpath.replace(":","_");
-
- if (EditorSettings::get_singleton()->has(rpath)) {
-
- Vector<String> open_files=EditorSettings::get_singleton()->get("rpath");
- for(int i=0;i<open_files.size();i++) {
- Ref<Script> scr = ResourceLoader::load(open_files[i]);
- if (!scr.is_valid())
- continue;
- editor->edit_resource(scr);
- }
- }
}
+
void ScriptEditor::get_breakpoints(List<String> *p_breakpoints) {
for(int i=0;i<tab_container->get_child_count();i++) {
@@ -1360,11 +1338,18 @@ void ScriptEditor::_bind_methods() {
ObjectTypeDB::bind_method("_get_debug_tooltip",&ScriptEditor::_get_debug_tooltip);
ObjectTypeDB::bind_method("_autosave_scripts",&ScriptEditor::_autosave_scripts);
ObjectTypeDB::bind_method("_editor_settings_changed",&ScriptEditor::_editor_settings_changed);
+ ObjectTypeDB::bind_method("_update_script_names",&ScriptEditor::_update_script_names);
+ ObjectTypeDB::bind_method("_tree_changed",&ScriptEditor::_tree_changed);
+ ObjectTypeDB::bind_method("_script_selected",&ScriptEditor::_script_selected);
+ ObjectTypeDB::bind_method("_script_split_dragged",&ScriptEditor::_script_split_dragged);
}
void ScriptEditor::ensure_focus_current() {
+ if (!is_inside_tree())
+ return;
+
int cidx = tab_container->get_current_tab();
if (cidx<0 || cidx>=tab_container->get_tab_count());
Control *c = tab_container->get_child(cidx)->cast_to<Control>();
@@ -1376,6 +1361,13 @@ void ScriptEditor::ensure_focus_current() {
ste->get_text_edit()->grab_focus();
}
+void ScriptEditor::_script_selected(int p_idx) {
+
+ grab_focus_block = !Input::get_singleton()->is_mouse_button_pressed(1); //amazing hack, simply amazing
+ tab_container->set_current_tab(script_list->get_item_metadata(p_idx));
+ grab_focus_block=false;
+}
+
void ScriptEditor::ensure_select_current() {
@@ -1386,8 +1378,66 @@ void ScriptEditor::ensure_select_current() {
return;
Ref<Script> script = ste->get_edited_script();
- ste->get_text_edit()->grab_focus();
+ if (!grab_focus_block && is_inside_tree())
+ ste->get_text_edit()->grab_focus();
+ }
+
+
+}
+
+void ScriptEditor::_find_scripts(Node* p_base, Node* p_current, Set<Ref<Script> > &used) {
+ if (p_current!=p_base && p_current->get_owner()!=p_base)
+ return;
+
+ if (p_current->get_script_instance()) {
+ Ref<Script> scr = p_current->get_script();
+ if (scr.is_valid())
+ used.insert(scr);
+ }
+
+ for(int i=0;i<p_current->get_child_count();i++) {
+ _find_scripts(p_base,p_current->get_child(i),used);
+ }
+
+}
+
+
+void ScriptEditor::_update_script_names() {
+
+ waiting_update_names=false;
+ Set<Ref<Script> > used;
+ Node* edited = EditorNode::get_singleton()->get_edited_scene();
+ if (edited) {
+ _find_scripts(edited,edited,used);
+ }
+
+ script_list->clear();
+ for(int i=0;i<tab_container->get_child_count();i++) {
+
+ ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
+ if (!ste)
+ continue;
+
+ String script = ste->get_name();
+ Ref<Texture> icon = ste->get_icon();
+ String path = ste->get_edited_script()->get_path();
+ script_list->add_item(script,icon);
+
+ int index = script_list->get_item_count()-1;
+
+ script_list->set_item_tooltip(index,path);
+ script_list->set_item_metadata(index,i);
+ if (used.has(ste->get_edited_script())) {
+
+ script_list->set_item_custom_bg_color(index,Color(88/255.0,88/255.0,60/255.0));
+ }
+ if (tab_container->get_current_tab()==index) {
+ script_list->select(index);
+ }
}
+
+ script_list->sort_items_by_text();
+
}
void ScriptEditor::edit(const Ref<Script>& p_script) {
@@ -1425,9 +1475,13 @@ void ScriptEditor::edit(const Ref<Script>& p_script) {
if (ste->get_edited_script()==p_script) {
- if (tab_container->get_current_tab()!=i)
- tab_container->set_current_tab(i);
- ste->get_text_edit()->grab_focus();
+ if (!EditorNode::get_singleton()->is_changing_scene()) {
+ if (tab_container->get_current_tab()!=i) {
+ tab_container->set_current_tab(i);
+ script_list->select( script_list->find_metadata(i) );
+ }
+ ste->get_text_edit()->grab_focus();
+ }
return;
}
}
@@ -1440,9 +1494,13 @@ void ScriptEditor::edit(const Ref<Script>& p_script) {
tab_container->add_child(ste);
tab_container->set_current_tab(tab_container->get_tab_count()-1);
- _update_window_menu();
- _save_files_state();
+
+ _update_script_names();
+ ste->connect("name_changed",this,"_update_script_names");
+ if (!restoring_layout) {
+ EditorNode::get_singleton()->save_layout();
+ }
}
void ScriptEditor::save_external_data() {
@@ -1502,51 +1560,6 @@ void ScriptEditor::_editor_stop() {
debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true );
}
-void ScriptEditor::_update_window_menu() {
-
- int idx=0;
- for(int i=0;i<tab_container->get_child_count();i++) {
-
- ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
- if (!ste)
- continue;
- idx++;
- }
-
- if (idx==0) {
- window_menu->set_disabled(true);
- edit_menu->set_disabled(true);
- search_menu->set_disabled(true);
- return;
- } else {
-
- window_menu->set_disabled(false);
- edit_menu->set_disabled(false);
- search_menu->set_disabled(false);
- }
-
- window_menu->get_popup()->clear();
- window_menu->get_popup()->add_item("Close",WINDOW_CLOSE,KEY_MASK_CMD|KEY_W);
- window_menu->get_popup()->add_separator();
- window_menu->get_popup()->add_item("Move Left",WINDOW_MOVE_LEFT,KEY_MASK_CMD|KEY_MASK_ALT|KEY_LEFT);
- window_menu->get_popup()->add_item("Move Right",WINDOW_MOVE_RIGHT,KEY_MASK_CMD|KEY_MASK_ALT|KEY_RIGHT);
- window_menu->get_popup()->add_separator();
-
- idx=0;
- for(int i=0;i<tab_container->get_child_count();i++) {
-
- ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
- if (!ste)
- continue;
- String n = ste->get_name();
- uint32_t accel=0;
- if (idx<9) {
- accel=KEY_MASK_ALT|KEY_MASK_CMD|(KEY_1+idx);
- }
- window_menu->get_popup()->add_item(n,WINDOW_SELECT_BASE+idx,accel);
- idx++;
- }
-}
void ScriptEditor::_add_callback(Object *p_obj, const String& p_function, const StringArray& p_args) {
@@ -1582,6 +1595,8 @@ void ScriptEditor::_add_callback(Object *p_obj, const String& p_function, const
ste->get_text_edit()->cursor_set_line(pos);
ste->get_text_edit()->cursor_set_column(1);
+ script_list->select( script_list->find_metadata(i) );
+
break;
}
@@ -1607,8 +1622,80 @@ void ScriptEditor::_autosave_scripts() {
save_external_data();
}
+void ScriptEditor::_tree_changed() {
+
+ if (waiting_update_names)
+ return;
+
+ waiting_update_names=true;
+ call_deferred("_update_script_names");
+}
+
+void ScriptEditor::_script_split_dragged(float) {
+
+ EditorNode::get_singleton()->save_layout();
+}
+
+void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) {
+
+ if (!bool(EDITOR_DEF("text_editor/restore_scripts_on_load",true))) {
+ return;
+ }
+
+ if (!p_layout->has_section_key("ScriptEditor","open_scripts"))
+ return;
+
+ Array scripts = p_layout->get_value("ScriptEditor","open_scripts");
+
+ restoring_layout=true;
+
+ for(int i=0;i<scripts.size();i++) {
+
+ String path = scripts[i];
+ Ref<Script> scr = ResourceLoader::load(path);
+ if (scr.is_valid()) {
+ edit(scr);
+ }
+ }
+
+ if (p_layout->has_section_key("ScriptEditor","split_offset")) {
+ script_split->set_split_offset(p_layout->get_value("ScriptEditor","split_offset"));
+ }
+
+
+ restoring_layout=false;
+
+}
+
+void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) {
+
+ Array scripts;
+
+ for(int i=0;i<tab_container->get_child_count();i++) {
+
+ ScriptTextEditor *ste = tab_container->get_child(i)->cast_to<ScriptTextEditor>();
+ if (!ste)
+ continue;
+
+ String path = ste->get_edited_script()->get_path();
+ if (!path.is_resource_file())
+ continue;
+
+ scripts.push_back(path);
+
+ }
+
+ p_layout->set_value("ScriptEditor","open_scripts",scripts);
+ p_layout->set_value("ScriptEditor","split_offset",script_split->get_split_offset());
+
+}
+
+
+
ScriptEditor::ScriptEditor(EditorNode *p_editor) {
+ restoring_layout=false;
+ waiting_update_names=false;
editor=p_editor;
menu_hb = memnew( HBoxContainer );
@@ -1618,17 +1705,31 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
add_child(v_split);
v_split->set_v_size_flags(SIZE_EXPAND_FILL);
+ script_split = memnew( HSplitContainer );
+ v_split->add_child(script_split);
+ script_split->set_v_size_flags(SIZE_EXPAND_FILL);
+
+ script_list = memnew( ItemList );
+ script_split->add_child(script_list);
+ script_list->set_custom_minimum_size(Size2(140,0));
+
tab_container = memnew( TabContainer );
- v_split->add_child(tab_container);
- tab_container->set_v_size_flags(SIZE_EXPAND_FILL);
+ tab_container->set_tabs_visible(false);
+ script_split->add_child(tab_container);
+
+
+ tab_container->set_h_size_flags(SIZE_EXPAND_FILL);
file_menu = memnew( MenuButton );
menu_hb->add_child(file_menu);
file_menu->set_text("File");
file_menu->get_popup()->add_item("Open",FILE_OPEN);
+ file_menu->get_popup()->add_separator();
file_menu->get_popup()->add_item("Save",FILE_SAVE,KEY_MASK_ALT|KEY_MASK_CMD|KEY_S);
file_menu->get_popup()->add_item("Save As..",FILE_SAVE_AS);
file_menu->get_popup()->add_item("Save All",FILE_SAVE_ALL,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_S);
+ file_menu->get_popup()->add_separator();
+ file_menu->get_popup()->add_item("Close",FILE_CLOSE,KEY_MASK_CMD|KEY_W);
file_menu->get_popup()->connect("item_pressed", this,"_menu_option");
edit_menu = memnew( MenuButton );
@@ -1690,6 +1791,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_CONTINUE), true );
+#if 0
window_menu = memnew( MenuButton );
menu_hb->add_child(window_menu);
window_menu->set_text("Window");
@@ -1700,6 +1802,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
window_menu->get_popup()->add_separator();
window_menu->get_popup()->connect("item_pressed", this,"_menu_option");
+#endif
+
help_menu = memnew( MenuButton );
menu_hb->add_child(help_menu);
help_menu->set_text("Help");
@@ -1762,6 +1866,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
autosave_timer->set_one_shot(false);
add_child(autosave_timer);
+ grab_focus_block=false;
+
// debugger_gui->hide();
}
@@ -1826,20 +1932,24 @@ void ScriptEditorPlugin::apply_changes() {
void ScriptEditorPlugin::restore_global_state() {
- if (bool(EDITOR_DEF("text_editor/restore_scripts_on_load",true))) {
- script_editor->_load_files_state();
- }
}
void ScriptEditorPlugin::save_global_state() {
- if (bool(EDITOR_DEF("text_editor/restore_scripts_on_load",true))) {
- script_editor->_save_files_state();
- }
+}
+void ScriptEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
+
+ script_editor->set_window_layout(p_layout);
}
+void ScriptEditorPlugin::get_window_layout(Ref<ConfigFile> p_layout){
+
+ script_editor->get_window_layout(p_layout);
+}
+
+
void ScriptEditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index acfdd1e966..635db40c2f 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -38,7 +38,7 @@
#include "script_language.h"
#include "tools/editor/code_editor.h"
#include "scene/gui/split_container.h"
-
+#include "scene/gui/item_list.h"
class ScriptEditorQuickOpen : public ConfirmationDialog {
@@ -88,6 +88,7 @@ protected:
virtual void _code_complete_script(const String& p_code, List<String>* r_options);
virtual void _load_theme_settings();
void _notification(int p_what);
+ static void _bind_methods();
public:
@@ -97,7 +98,8 @@ public:
Vector<String> get_functions() ;
void set_edited_script(const Ref<Script>& p_script);
void reload_text();
- void _update_name();
+ String get_name() ;
+ Ref<Texture> get_icon() ;
ScriptTextEditor();
@@ -115,6 +117,7 @@ class ScriptEditor : public VBoxContainer {
FILE_SAVE,
FILE_SAVE_AS,
FILE_SAVE_ALL,
+ FILE_CLOSE,
EDIT_UNDO,
EDIT_REDO,
EDIT_CUT,
@@ -123,12 +126,12 @@ class ScriptEditor : public VBoxContainer {
EDIT_SELECT_ALL,
EDIT_COMPLETE,
EDIT_AUTO_INDENT,
- EDIT_TOGGLE_COMMENT,
- EDIT_MOVE_LINE_UP,
- EDIT_MOVE_LINE_DOWN,
- EDIT_INDENT_RIGHT,
- EDIT_INDENT_LEFT,
- EDIT_CLONE_DOWN,
+ EDIT_TOGGLE_COMMENT,
+ EDIT_MOVE_LINE_UP,
+ EDIT_MOVE_LINE_DOWN,
+ EDIT_INDENT_RIGHT,
+ EDIT_INDENT_LEFT,
+ EDIT_CLONE_DOWN,
SEARCH_FIND,
SEARCH_FIND_NEXT,
SEARCH_REPLACE,
@@ -140,8 +143,7 @@ class ScriptEditor : public VBoxContainer {
DEBUG_BREAK,
DEBUG_CONTINUE,
DEBUG_SHOW,
- HELP_CONTEXTUAL,
- WINDOW_CLOSE,
+ HELP_CONTEXTUAL,
WINDOW_MOVE_LEFT,
WINDOW_MOVE_RIGHT,
WINDOW_SELECT_BASE=100
@@ -151,12 +153,13 @@ class ScriptEditor : public VBoxContainer {
MenuButton *file_menu;
MenuButton *edit_menu;
MenuButton *search_menu;
- MenuButton *window_menu;
MenuButton *debug_menu;
MenuButton *help_menu;
Timer *autosave_timer;
uint64_t idle;
+ ItemList *script_list;
+ HSplitContainer *script_split;
TabContainer *tab_container;
FindReplaceDialog *find_replace_dialog;
GotoLineDialog *goto_line_dialog;
@@ -171,6 +174,8 @@ class ScriptEditor : public VBoxContainer {
VSplitContainer *v_split;
+ bool restoring_layout;
+
String _get_debug_tooltip(const String&p_text,Node *_ste);
void _resave_scripts(const String& p_str);
@@ -180,6 +185,8 @@ class ScriptEditor : public VBoxContainer {
void _close_current_tab();
+ bool grab_focus_block;
+
ScriptEditorQuickOpen *quick_open;
@@ -199,6 +206,18 @@ class ScriptEditor : public VBoxContainer {
void _editor_settings_changed();
void _autosave_scripts();
+ void _update_script_names();
+
+ void _script_selected(int p_idx);
+
+ void _find_scripts(Node* p_base, Node* p_current,Set<Ref<Script> >& used);
+
+ void _tree_changed();
+
+ void _script_split_dragged(float);
+
+ bool waiting_update_names;
+
static ScriptEditor *script_editor;
protected:
void _notification(int p_what);
@@ -206,9 +225,6 @@ protected:
public:
static ScriptEditor *get_singleton() { return script_editor; }
- void _save_files_state();
- void _load_files_state();
-
void ensure_focus_current();
void apply_scripts() const;
@@ -222,10 +238,13 @@ public:
void get_breakpoints(List<String> *p_breakpoints);
- void swap_lines(TextEdit *tx, int line1, int line2);
+ void swap_lines(TextEdit *tx, int line1, int line2);
void save_external_data();
+ void set_window_layout(Ref<ConfigFile> p_layout);
+ void get_window_layout(Ref<ConfigFile> p_layout);
+
ScriptEditor(EditorNode *p_editor);
};
@@ -254,6 +273,9 @@ public:
virtual void restore_global_state();
virtual void save_global_state();
+ virtual void set_window_layout(Ref<ConfigFile> p_layout);
+ virtual void get_window_layout(Ref<ConfigFile> p_layout);
+
virtual void get_breakpoints(List<String> *p_breakpoints);
diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp
index 5c82973da4..017a26441d 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.cpp
+++ b/tools/editor/plugins/tile_map_editor_plugin.cpp
@@ -71,22 +71,19 @@ void TileMapEditor::_canvas_mouse_exit() {
}
int TileMapEditor::get_selected_tile() const {
-
- TreeItem *item = palette->get_selected();
- if (!item)
+ int item = palette->get_current();
+ if (item==-1)
return TileMap::INVALID_CELL;
- return item->get_metadata(0);
+ return palette->get_item_metadata(item);
}
void TileMapEditor::set_selected_tile(int p_tile) {
- TreeItem *item = palette->get_root()->get_children();
- while (item) {
- if ((int)item->get_metadata(0) == p_tile) {
- item->select(0);
- palette->ensure_cursor_is_visible();
+ for (int i = 0; i < palette->get_item_count(); i++) {
+ if (palette->get_item_metadata(i).operator int() == p_tile) {
+ palette->select(i,true);
+ palette->ensure_current_is_visible();
break;
}
- item = item->get_next();
}
}
@@ -95,7 +92,7 @@ void TileMapEditor::_set_cell_shortened(const Point2& p_pos,int p_value,bool p_f
ERR_FAIL_COND(!node);
node->set_cell(floor(p_pos.x), floor(p_pos.y), p_value, p_flip_h, p_flip_v, p_transpose);
}
-
+
void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bool p_flip_v, bool p_transpose,bool p_with_undo) {
ERR_FAIL_COND(!node);
@@ -120,42 +117,78 @@ void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bo
}
+void TileMapEditor::_set_display_mode(int p_mode) {
+ if (display_mode == p_mode) {
+ return;
+ }
+
+ switch (p_mode) {
+ case DISPLAY_THUMBNAIL: {
+ button_thumbnail->set_pressed(true);
+ button_list->set_pressed(false);
+ } break;
+ case DISPLAY_LIST: {
+ button_thumbnail->set_pressed(false);
+ button_list->set_pressed(true);
+ } break;
+ }
+
+ display_mode = p_mode;
+
+ _update_palette();
+}
+
void TileMapEditor::_update_palette() {
if (!node)
return;
- palette->clear();;
+ palette->clear();
Ref<TileSet> tileset=node->get_tileset();
if (!tileset.is_valid())
return;
-
- TreeItem *root = palette->create_item();
- palette->set_hide_root(true);
List<int> tiles;
tileset->get_tile_list(&tiles);
- for(List<int>::Element *E=tiles.front();E;E=E->next()) {
+ if (display_mode == DISPLAY_THUMBNAIL) {
+ palette->set_max_columns(0);
+ palette->set_icon_mode(ItemList::ICON_MODE_TOP);
+ } else if (display_mode == DISPLAY_LIST) {
+ palette->set_max_columns(1);
+ palette->set_icon_mode(ItemList::ICON_MODE_LEFT);
+ }
- TreeItem *tile = palette->create_item(root);
+ palette->set_max_text_lines(2);
+
+ for(List<int>::Element *E=tiles.front();E;E=E->next()) {
+ palette->add_item("");
- tile->set_icon_max_width(0,64);
Ref<Texture> tex = tileset->tile_get_texture(E->get());
+
if (tex.is_valid()) {
- tile->set_icon(0,tex);
Rect2 region = tileset->tile_get_region(E->get());
- if (region!=Rect2())
- tile->set_icon_region(0,region);
- } else if (tileset->tile_get_name(E->get())!="")
- tile->set_text(0,tileset->tile_get_name(E->get()));
- else
- tile->set_text(0,"#"+itos(E->get()));
+ if (!region.has_no_area()) {
+ Image data = VS::get_singleton()->texture_get_data(tex->get_rid());
+
+ Ref<ImageTexture> img = memnew( ImageTexture );
+ img->create_from_image(data.get_rect(region));
+
+ palette->set_item_icon(palette->get_item_count()-1, img);
+ } else {
+ palette->set_item_icon(palette->get_item_count()-1,tex);
+ }
+ }
- tile->set_metadata(0,E->get());
+ if (tileset->tile_get_name(E->get())!="") {
+ palette->set_item_text(palette->get_item_count()-1, tileset->tile_get_name(E->get()));
+ } else {
+ palette->set_item_text(palette->get_item_count()-1, "#"+itos(E->get()));
+ }
+ palette->set_item_metadata(palette->get_item_count()-1, E->get());
}
}
@@ -387,7 +420,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) {
}
if (tool==TOOL_ERASING) {
- Point2i local =over_tile;
+ Point2i local =over_tile;
if (!paint_undo.has(over_tile)) {
paint_undo[over_tile]=_get_op_from_cell(over_tile);
}
@@ -641,7 +674,7 @@ void TileMapEditor::_canvas_draw() {
Ref<Texture> t = ts->tile_get_texture(st);
if (t.is_valid()) {
Vector2 from = node->map_to_world(over_tile)+node->get_cell_draw_offset();
- Rect2 r = ts->tile_get_region(st);
+ Rect2 r = ts->tile_get_region(st);
Size2 sc = xform.get_scale();
if (mirror_x->is_pressed())
sc.x*=-1.0;
@@ -755,7 +788,7 @@ void TileMapEditor::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_tileset_settings_changed"),&TileMapEditor::_tileset_settings_changed);
ObjectTypeDB::bind_method(_MD("_update_transform_buttons"),&TileMapEditor::_update_transform_buttons);
ObjectTypeDB::bind_method(_MD("_set_cell_shortened","pos","tile","flip_x","flip_y","transpose"),&TileMapEditor::_set_cell_shortened,DEFVAL(false),DEFVAL(false),DEFVAL(false));
-
+ ObjectTypeDB::bind_method(_MD("_set_display_mode","mode"),&TileMapEditor::_set_display_mode);
}
TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i& p_pos)
@@ -777,7 +810,7 @@ void TileMapEditor::_update_transform_buttons(Object *p_button) {
//ERR_FAIL_NULL(p_button);
ToolButton *b=p_button->cast_to<ToolButton>();
//ERR_FAIL_COND(!b);
-
+
mirror_x->set_block_signals(true);
mirror_y->set_block_signals(true);
transpose->set_block_signals(true);
@@ -785,7 +818,7 @@ void TileMapEditor::_update_transform_buttons(Object *p_button) {
rotate_90->set_block_signals(true);
rotate_180->set_block_signals(true);
rotate_270->set_block_signals(true);
-
+
if (b == rotate_0) {
mirror_x->set_pressed(false);
mirror_y->set_pressed(false);
@@ -806,7 +839,7 @@ void TileMapEditor::_update_transform_buttons(Object *p_button) {
mirror_y->set_pressed(true);
transpose->set_pressed(true);
}
-
+
rotate_0->set_pressed(!mirror_x->is_pressed() && !mirror_y->is_pressed() && !transpose->is_pressed());
rotate_90->set_pressed(mirror_x->is_pressed() && !mirror_y->is_pressed() && transpose->is_pressed());
rotate_180->set_pressed(mirror_x->is_pressed() && mirror_y->is_pressed() && !transpose->is_pressed());
@@ -833,8 +866,27 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
ec->set_custom_minimum_size(Size2(mw,0));
add_child(ec);
+ HBoxContainer *hb = memnew( HBoxContainer );
+ add_child(hb);
+ hb->set_h_size_flags(SIZE_EXPAND_FILL);
+ hb->add_spacer(true);
+
+ button_thumbnail = memnew( ToolButton );
+ button_thumbnail->set_toggle_mode(true);
+ button_thumbnail->set_pressed(true);
+ button_thumbnail->set_icon(p_editor->get_gui_base()->get_icon("FileThumbnail","EditorIcons"));
+ hb->add_child(button_thumbnail);
+ button_thumbnail->connect("pressed", this, "_set_display_mode", varray(DISPLAY_THUMBNAIL));
+
+ button_list = memnew( ToolButton );
+ button_list->set_toggle_mode(true);
+ button_list->set_pressed(false);
+ button_list->set_icon(p_editor->get_gui_base()->get_icon("FileList","EditorIcons"));
+ hb->add_child(button_list);
+ button_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST));
+
// Add tile palette
- palette = memnew( Tree );
+ palette = memnew( ItemList );
palette->set_v_size_flags(SIZE_EXPAND_FILL);
add_child(palette);
@@ -886,7 +938,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
rotate_270->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_270));
canvas_item_editor_hb->add_child(rotate_270);
canvas_item_editor_hb->hide();
-
+
rotate_0->set_pressed(true);
tool=TOOL_NONE;
selection_active=false;
diff --git a/tools/editor/plugins/tile_map_editor_plugin.h b/tools/editor/plugins/tile_map_editor_plugin.h
index eaa5c256d7..74d1573d0f 100644
--- a/tools/editor/plugins/tile_map_editor_plugin.h
+++ b/tools/editor/plugins/tile_map_editor_plugin.h
@@ -55,10 +55,18 @@ class TileMapEditor : public VBoxContainer {
TOOL_PICKING
};
+ enum DisplayMode {
+ DISPLAY_THUMBNAIL,
+ DISPLAY_LIST
+ };
+
Tool tool;
Control *canvas_item_editor;
- Tree *palette;
+ int display_mode;
+ ItemList *palette;
+ ToolButton *button_thumbnail;
+ ToolButton *button_list;
EditorNode *editor;
Panel *panel;
TileMap *node;
@@ -95,6 +103,7 @@ class TileMapEditor : public VBoxContainer {
int get_selected_tile() const;
void set_selected_tile(int p_tile);
+ void _set_display_mode(int p_mode);
void _update_palette();
void _canvas_draw();
void _menu_option(int p_option);