diff options
-rw-r--r-- | core/math/a_star.cpp | 28 | ||||
-rw-r--r-- | core/math/a_star.h | 31 | ||||
-rw-r--r-- | scene/gui/label.cpp | 6 | ||||
-rw-r--r-- | tools/editor/project_manager.cpp | 45 | ||||
-rw-r--r-- | tools/editor/project_manager.h | 2 |
5 files changed, 107 insertions, 5 deletions
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 5bbbbdaa5a..198d9f6076 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* a_star.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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 "a_star.h" #include "geometry.h" diff --git a/core/math/a_star.h b/core/math/a_star.h index a0517b5941..26f3a85046 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -1,8 +1,39 @@ +/*************************************************************************/ +/* a_star.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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. */ +/*************************************************************************/ #ifndef ASTAR_H #define ASTAR_H #include "reference.h" #include "self_list.h" +/** + @author Juan Linietsky <reduzio@gmail.com> +*/ class AStar: public Reference { diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 3b15776c55..f95b151024 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -118,19 +118,19 @@ void Label::_notification(int p_what) { //nothing } break; case VALIGN_CENTER: { - vbegin=(size.y - lines_visible * font_h) / 2; + vbegin=(size.y - (lines_visible * font_h - line_spacing)) / 2; vsep=0; } break; case VALIGN_BOTTOM: { - vbegin=size.y - lines_visible * font_h; + vbegin=size.y - (lines_visible * font_h - line_spacing); vsep=0; } break; case VALIGN_FILL: { vbegin=0; if (lines_visible>1) { - vsep=(size.y - lines_visible * font_h) / (lines_visible - 1); + vsep=(size.y - (lines_visible * font_h - line_spacing)) / (lines_visible - 1); } else { vsep=0; } diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index dcfea9e305..069d7cef81 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -335,7 +335,7 @@ private: hide(); - emit_signal("project_created"); + emit_signal("project_created", dir); } @@ -882,6 +882,7 @@ void ProjectManager::_load_recent_projects() { hb->add_child(tf); VBoxContainer *vb = memnew(VBoxContainer); + vb->set_name("project"); hb->add_child(vb); Control *ec = memnew( Control ); ec->set_custom_minimum_size(Size2(0,1)); @@ -891,6 +892,7 @@ void ProjectManager::_load_recent_projects() { title->add_color_override("font_color",font_color); vb->add_child(title); Label *fpath = memnew( Label(path) ); + fpath->set_name("path"); vb->add_child(fpath); fpath->set_opacity(0.5); fpath->add_color_override("font_color",font_color); @@ -912,6 +914,43 @@ void ProjectManager::_load_recent_projects() { tabs->set_current_tab(0); } +void ProjectManager::_on_project_created(const String& dir) { + bool has_already=false; + for (int i=0;i<scroll_childs->get_child_count();i++) { + HBoxContainer *hb=scroll_childs->get_child(i)->cast_to<HBoxContainer>(); + Label *fpath=hb->get_node(NodePath("project/path"))->cast_to<Label>(); + if (fpath->get_text()==dir) { + has_already=true; + break; + } + } + if (has_already) { + _update_scroll_pos(dir); + } else { + _load_recent_projects(); + scroll->connect("draw", this, "_update_scroll_pos", varray(dir), CONNECT_ONESHOT); + } +} + +void ProjectManager::_update_scroll_pos(const String& dir) { + for (int i=0;i<scroll_childs->get_child_count();i++) { + HBoxContainer *hb=scroll_childs->get_child(i)->cast_to<HBoxContainer>(); + Label *fpath=hb->get_node(NodePath("project/path"))->cast_to<Label>(); + if (fpath->get_text()==dir) { + last_clicked=hb->get_meta("name"); + selected_list.clear(); + selected_list.insert(hb->get_meta("name"), hb->get_meta("main_scene")); + _update_project_buttons(); + int last_y_visible=scroll->get_v_scroll()+scroll->get_size().y; + int offset_diff=(hb->get_pos().y + hb->get_size().y)-last_y_visible; + + if (offset_diff>0) + scroll->set_v_scroll(scroll->get_v_scroll()+offset_diff); + break; + } + } +} + void ProjectManager::_open_project_confirm() { for (Map<String,String>::Element *E=selected_list.front(); E; E=E->next()) { @@ -1164,6 +1203,8 @@ void ProjectManager::_bind_methods() { ObjectTypeDB::bind_method("_erase_project_confirm",&ProjectManager::_erase_project_confirm); ObjectTypeDB::bind_method("_exit_dialog",&ProjectManager::_exit_dialog); ObjectTypeDB::bind_method("_load_recent_projects",&ProjectManager::_load_recent_projects); + ObjectTypeDB::bind_method("_on_project_created",&ProjectManager::_on_project_created); + ObjectTypeDB::bind_method("_update_scroll_pos",&ProjectManager::_update_scroll_pos); ObjectTypeDB::bind_method("_panel_draw",&ProjectManager::_panel_draw); ObjectTypeDB::bind_method("_panel_input",&ProjectManager::_panel_input); ObjectTypeDB::bind_method("_unhandled_input",&ProjectManager::_unhandled_input); @@ -1382,7 +1423,7 @@ ProjectManager::ProjectManager() { npdialog = memnew( NewProjectDialog ); gui_base->add_child(npdialog); - npdialog->connect("project_created", this,"_load_recent_projects"); + npdialog->connect("project_created", this,"_on_project_created"); _load_recent_projects(); if ( EditorSettings::get_singleton()->get("global/autoscan_project_path") ) { diff --git a/tools/editor/project_manager.h b/tools/editor/project_manager.h index 46f7aea3a5..af2d47aeb3 100644 --- a/tools/editor/project_manager.h +++ b/tools/editor/project_manager.h @@ -85,6 +85,8 @@ class ProjectManager : public Control { void _scan_begin(const String& p_base); void _load_recent_projects(); + void _on_project_created(const String& dir); + void _update_scroll_pos(const String& dir); void _scan_dir(DirAccess *da,float pos, float total,List<String> *r_projects); void _install_project(const String& p_zip_path,const String& p_title); |