diff options
29 files changed, 191 insertions, 122 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index b947eec8d4..df49ecebcf 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -480,9 +480,9 @@ void _OS::set_use_vsync(bool p_enable) { OS::get_singleton()->set_use_vsync(p_enable); } -bool _OS::is_vsnc_enabled() const { +bool _OS::is_vsync_enabled() const { - return OS::get_singleton()->is_vsnc_enabled(); + return OS::get_singleton()->is_vsync_enabled(); } @@ -1172,7 +1172,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_thread_name","name"),&_OS::set_thread_name); ObjectTypeDB::bind_method(_MD("set_use_vsync","enable"),&_OS::set_use_vsync); - ObjectTypeDB::bind_method(_MD("is_vsnc_enabled"),&_OS::is_vsnc_enabled); + ObjectTypeDB::bind_method(_MD("is_vsync_enabled"),&_OS::is_vsync_enabled); ObjectTypeDB::bind_method(_MD("get_engine_version"),&_OS::get_engine_version); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index d86306726c..2fb7f93cef 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -318,7 +318,7 @@ public: Error set_thread_name(const String& p_name); void set_use_vsync(bool p_enable); - bool is_vsnc_enabled() const; + bool is_vsync_enabled() const; Dictionary get_engine_version() const; diff --git a/core/input_map.cpp b/core/input_map.cpp index 09cb7ce426..ad1403a64b 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -106,7 +106,7 @@ List<StringName> InputMap::get_actions() const { return actions; } -List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const InputEvent& p_event) const { +List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const InputEvent& p_event, bool p_mod_ignore=false) const { for (List<InputEvent>::Element *E=p_list.front();E;E=E->next()) { @@ -122,7 +122,7 @@ List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const case InputEvent::KEY: { - same=(e.key.scancode==p_event.key.scancode && e.key.mod == p_event.key.mod); + same=(e.key.scancode==p_event.key.scancode && (p_mod_ignore || e.key.mod == p_event.key.mod)); } break; case InputEvent::JOYSTICK_BUTTON: { @@ -229,7 +229,7 @@ bool InputMap::event_is_action(const InputEvent& p_event, const StringName& p_ac return p_event.action.action==E->get().id; } - return _find_event(E->get().inputs,p_event)!=NULL; + return _find_event(E->get().inputs,p_event,!p_event.is_pressed())!=NULL; } const Map<StringName, InputMap::Action>& InputMap::get_action_map() const { diff --git a/core/input_map.h b/core/input_map.h index 21c479588d..a974f6f103 100644 --- a/core/input_map.h +++ b/core/input_map.h @@ -46,7 +46,7 @@ private: mutable Map<StringName, Action> input_map; mutable Map<int,StringName> input_id_map; - List<InputEvent>::Element *_find_event(List<InputEvent> &p_list,const InputEvent& p_event) const; + List<InputEvent>::Element *_find_event(List<InputEvent> &p_list,const InputEvent& p_event, bool p_mod_ignore) const; Array _get_action_list(const StringName& p_action); Array _get_actions(); 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/core/math/triangulate.cpp b/core/math/triangulate.cpp index 1f5d5ed6b3..eaf019f200 100644 --- a/core/math/triangulate.cpp +++ b/core/math/triangulate.cpp @@ -71,7 +71,7 @@ bool Triangulate::is_inside_triangle(float Ax, float Ay, return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f)); }; -bool Triangulate::snip(const Vector<Vector2> &p_contour,int u,int v,int w,int n,int *V) +bool Triangulate::snip(const Vector<Vector2> &p_contour,int u,int v,int w,int n,const Vector<int>& V) { int p; float Ax, Ay, Bx, By, Cx, Cy, Px, Py; @@ -107,8 +107,8 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour,Vector<int> &result if ( n < 3 ) return false; - - int *V = (int*)alloca(sizeof(int)*n); + Vector<int> V; + V.resize(n); /* we want a counter-clockwise polygon in V */ @@ -122,7 +122,7 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour,Vector<int> &result /* remove nv-2 Vertices, creating 1 triangle every time */ int count = 2*nv; /* error detection */ - for(int m=0, v=nv-1; nv>2; ) + for(int v=nv-1; nv>2; ) { /* if we loop, it is probably a non-simple polygon */ if (0 >= (count--)) @@ -144,18 +144,10 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour,Vector<int> &result a = V[u]; b = V[v]; c = V[w]; /* output Triangle */ - /* - result.push_back( contour[a] ); - result.push_back( contour[b] ); - result.push_back( contour[c] ); -*/ - result.push_back( a ); result.push_back( b ); result.push_back( c ); - m++; - /* remove v from remaining polygon */ for(s=v,t=v+1;t<nv;s++,t++) V[s] = V[t]; diff --git a/core/math/triangulate.h b/core/math/triangulate.h index 7dcc91b2fd..ef622b5005 100644 --- a/core/math/triangulate.h +++ b/core/math/triangulate.h @@ -56,7 +56,7 @@ public: private: - static bool snip(const Vector<Vector2> &p_contour,int u,int v,int w,int n,int *V); + static bool snip(const Vector<Vector2> &p_contour,int u,int v,int w,int n,const Vector<int>& V); }; diff --git a/core/os/os.cpp b/core/os/os.cpp index ee32476234..11a315a01b 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -542,7 +542,7 @@ void OS::set_use_vsync(bool p_enable) { } -bool OS::is_vsnc_enabled() const{ +bool OS::is_vsync_enabled() const{ return true; } diff --git a/core/os/os.h b/core/os/os.h index c2b46a5420..037fcac039 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -431,7 +431,7 @@ public: virtual void set_context(int p_context); virtual void set_use_vsync(bool p_enable); - virtual bool is_vsnc_enabled() const; + virtual bool is_vsync_enabled() const; Dictionary get_engine_version() const; diff --git a/doc/base/classes.xml b/doc/base/classes.xml index d0a7157d46..246f8cdac6 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -18023,7 +18023,7 @@ <argument index="1" name="action" type="String"> </argument> <description> - Return whether the given event is part of an existing action. + Return whether the given event is part of an existing action. This method ignores keyboard modifiers if the given [InputEvent] is not pressed (for proper release detection). See [method action_has_event] if you don't want this behavior. </description> </method> <method name="get_action_from_id" qualifiers="const"> @@ -24152,7 +24152,7 @@ Return true if the window is resizable. </description> </method> - <method name="is_vsnc_enabled" qualifiers="const"> + <method name="is_vsync_enabled" qualifiers="const"> <return type="bool"> </return> <description> diff --git a/main/input_default.cpp b/main/input_default.cpp index 0995f7132d..f4590fd070 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -377,13 +377,13 @@ void InputDefault::parse_input_event(const InputEvent& p_event) { if (InputMap::get_singleton()->event_is_action(p_event,E->key())) { - Action action; - action.fixed_frame=OS::get_singleton()->get_fixed_frames(); - action.idle_frame=OS::get_singleton()->get_idle_frames(); - action.pressed=p_event.is_pressed(); - - action_state[E->key()]=action; - + if(is_action_pressed(E->key()) != p_event.is_pressed()) { + Action action; + action.fixed_frame=OS::get_singleton()->get_fixed_frames(); + action.idle_frame=OS::get_singleton()->get_idle_frames(); + action.pressed=p_event.is_pressed(); + action_state[E->key()]=action; + } } } } diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index 57376f8103..06be1f747d 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -154,7 +154,7 @@ Error DirAccessJAndroid::change_dir(String p_dir){ String DirAccessJAndroid::get_current_dir(){ - return "/"+current_dir; + return "res://"+current_dir; } bool DirAccessJAndroid::file_exists(String p_file){ @@ -268,6 +268,6 @@ DirAccessJAndroid::DirAccessJAndroid() { DirAccessJAndroid::~DirAccessJAndroid() { - list_dir_end();; + list_dir_end(); } #endif diff --git a/platform/android/java/src/org/godotengine/godot/GodotIO.java b/platform/android/java/src/org/godotengine/godot/GodotIO.java index 55e330924a..128a9b2f7b 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/src/org/godotengine/godot/GodotIO.java @@ -288,6 +288,11 @@ public class GodotIO { try { ad.files = am.list(path); + // no way to find path is directory or file exactly. + // but if ad.files.length==0, then it's an empty directory or file. + if (ad.files.length==0) { + return -1; + } } catch (IOException e) { System.out.printf("Exception on dir_open: %s\n",e); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 286f5fb0b7..3987044d80 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2388,7 +2388,7 @@ void OS_Windows::set_use_vsync(bool p_enable) { gl_context->set_use_vsync(p_enable); } -bool OS_Windows::is_vsnc_enabled() const{ +bool OS_Windows::is_vsync_enabled() const{ if (gl_context) return gl_context->is_using_vsync(); diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 903dd10c70..11fa094b88 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -295,7 +295,7 @@ public: virtual String get_joy_guid(int p_device) const; virtual void set_use_vsync(bool p_enable); - virtual bool is_vsnc_enabled() const; + virtual bool is_vsync_enabled() const; OS_Windows(HINSTANCE _hInstance); ~OS_Windows(); diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 5f1ab5b4aa..0172dca4c4 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1951,7 +1951,7 @@ void OS_X11::set_use_vsync(bool p_enable) { return context_gl->set_use_vsync(p_enable); } -bool OS_X11::is_vsnc_enabled() const { +bool OS_X11::is_vsync_enabled() const { if (context_gl) return context_gl->is_using_vsync(); diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index b27f71406a..efa7e44afe 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -264,7 +264,7 @@ public: virtual void set_context(int p_context); virtual void set_use_vsync(bool p_enable); - virtual bool is_vsnc_enabled() const; + virtual bool is_vsync_enabled() const; void run(); 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/scene/gui/range.cpp b/scene/gui/range.cpp index e056c55f71..ed58c4eb49 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -136,16 +136,25 @@ double Range::get_page() const { } void Range::set_unit_value(double p_value) { + + double v; + if (shared->exp_unit_value && get_min()>0) { double exp_min = Math::log(get_min())/Math::log(2); double exp_max = Math::log(get_max())/Math::log(2); - double v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value); - - set_val( v ); + v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value); } else { - set_val( (get_max() - get_min()) * p_value + get_min() ); + + double percent = (get_max() - get_min()) * p_value; + if (get_step() > 0) { + double steps = round(percent / get_step()); + v = steps * get_step() + get_min(); + } else { + v = percent + get_min(); + } } + set_val( v ); } double Range::get_unit_value() const { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 9b3b047712..871a3ca68f 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -492,10 +492,10 @@ void TextEdit::_notification(int p_what) { if (syntax_coloring) { - if (custom_bg_color.a>0.01) { + if (cache.background_color.a>0.01) { Point2i ofs = Point2i(cache.style_normal->get_offset())/2.0; - VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(ofs, get_size()-cache.style_normal->get_minimum_size()+ofs),custom_bg_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(ofs, get_size()-cache.style_normal->get_minimum_size()+ofs),cache.background_color); } //compute actual region to start (may be inside say, a comment). //slow in very large documments :( but ok for source! @@ -907,7 +907,7 @@ void TextEdit::_notification(int p_what) { else if (in_function_name) color=cache.function_color; else if (is_symbol) - color=symbol_color; + color=cache.symbol_color; else if (is_number) color=cache.number_color; @@ -3489,6 +3489,8 @@ void TextEdit::_update_caches() { cache.word_highlighted_color=get_color("word_highlighted_color"); cache.search_result_color=get_color("search_result_color"); cache.search_result_border_color=get_color("search_result_border_color"); + cache.symbol_color=get_color("symbol_color"); + cache.background_color=get_color("background_color"); cache.line_spacing=get_constant("line_spacing"); cache.row_height = cache.font->get_height() + cache.line_spacing; cache.tab_icon=get_icon("tab"); @@ -3500,15 +3502,8 @@ void TextEdit::_update_caches() { void TextEdit::clear_colors() { keywords.clear(); - color_regions.clear();; + color_regions.clear(); text.clear_caches(); - custom_bg_color=Color(0,0,0,0); -} - -void TextEdit::set_custom_bg_color(const Color& p_color) { - - custom_bg_color=p_color; - update(); } void TextEdit::add_keyword_color(const String& p_keyword,const Color& p_color) { @@ -3526,12 +3521,6 @@ void TextEdit::add_color_region(const String& p_begin_key,const String& p_end_ke } -void TextEdit::set_symbol_color(const Color& p_color) { - - symbol_color=p_color; - update(); -} - void TextEdit::set_syntax_coloring(bool p_enabled) { syntax_coloring=p_enabled; @@ -4689,8 +4678,6 @@ void TextEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_keyword_color","keyword","color"),&TextEdit::add_keyword_color); ObjectTypeDB::bind_method(_MD("add_color_region","begin_key","end_key","color","line_only"),&TextEdit::add_color_region,DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("set_symbol_color","color"),&TextEdit::set_symbol_color); - ObjectTypeDB::bind_method(_MD("set_custom_bg_color","color"),&TextEdit::set_custom_bg_color); ObjectTypeDB::bind_method(_MD("clear_colors"),&TextEdit::clear_colors); ObjectTypeDB::bind_method(_MD("menu_option"),&TextEdit::menu_option); ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"),&TextEdit::get_menu); @@ -4775,7 +4762,6 @@ TextEdit::TextEdit() { caret_blink_timer->connect("timeout", this,"_toggle_draw_caret"); cursor_set_blink_enabled(false); - custom_bg_color=Color(0,0,0,0); idle_detect = memnew( Timer ); add_child(idle_detect); idle_detect->set_one_shot(true); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 7820fefdd2..4cf096b7bf 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -95,6 +95,8 @@ class TextEdit : public Control { Color word_highlighted_color; Color search_result_color; Color search_result_border_color; + Color symbol_color; + Color background_color; int row_height; int line_spacing; @@ -187,9 +189,7 @@ class TextEdit : public Control { //syntax coloring - Color symbol_color; HashMap<String,Color> keywords; - Color custom_bg_color; Vector<ColorRegion> color_regions; @@ -471,8 +471,6 @@ public: void add_keyword_color(const String& p_keyword,const Color& p_color); void add_color_region(const String& p_begin_key=String(),const String& p_end_key=String(),const Color &p_color=Color(),bool p_line_only=false); - void set_symbol_color(const Color& p_color); - void set_custom_bg_color(const Color& p_color); void clear_colors(); int get_v_scroll() const; diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 0740b591c4..4c759bddef 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -490,6 +490,7 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref t->set_font("font","TextEdit", default_font ); + t->set_color("background_color", "TextEdit", Color(0,0,0,0)); t->set_color("completion_background_color", "TextEdit",Color::html("2C2A32")); t->set_color("completion_selected_color", "TextEdit",Color::html("434244")); t->set_color("completion_existing_color", "TextEdit",Color::html("21dfdfdf")); diff --git a/tools/editor/editor_run_native.cpp b/tools/editor/editor_run_native.cpp index edbcc71284..330103923d 100644 --- a/tools/editor/editor_run_native.cpp +++ b/tools/editor/editor_run_native.cpp @@ -55,6 +55,7 @@ void EditorRunNative::_notification(int p_what) { small_icon->create_from_image(im); MenuButton *mb = memnew( MenuButton ); mb->get_popup()->connect("item_pressed",this,"_run_native",varray(E->get())); + mb->connect("pressed",this,"_run_native",varray(-1, E->get())); mb->set_icon(small_icon); add_child(mb); menus[E->get()]=mb; @@ -79,13 +80,16 @@ void EditorRunNative::_notification(int p_what) { if (dc==0) { mb->hide(); } else { - mb->get_popup()->clear(); mb->show(); - for(int i=0;i<dc;i++) { - - mb->get_popup()->add_icon_item(get_icon("Play","EditorIcons"),eep->get_device_name(i)); - mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() -1,eep->get_device_info(i)); + if (dc == 1) { + mb->set_tooltip(eep->get_device_name(0) + "\n\n" + eep->get_device_info(0).strip_edges()); + } else { + mb->set_tooltip("Select device from the list"); + for(int i=0;i<dc;i++) { + mb->get_popup()->add_icon_item(get_icon("Play","EditorIcons"),eep->get_device_name(i)); + mb->get_popup()->set_item_tooltip(mb->get_popup()->get_item_count() -1,eep->get_device_info(i).strip_edges()); + } } } } @@ -96,11 +100,18 @@ void EditorRunNative::_notification(int p_what) { } - void EditorRunNative::_run_native(int p_idx,const String& p_platform) { Ref<EditorExportPlatform> eep = EditorImportExport::get_singleton()->get_export_platform(p_platform); ERR_FAIL_COND(eep.is_null()); + if (p_idx == -1) { + if (eep->get_device_count() == 1) { + menus[p_platform]->get_popup()->hide(); + p_idx = 0; + } else { + return; + } + } emit_signal("native_run"); int flags=0; diff --git a/tools/editor/plugins/script_text_editor.cpp b/tools/editor/plugins/script_text_editor.cpp index 40fc3a7bda..23252c4077 100644 --- a/tools/editor/plugins/script_text_editor.cpp +++ b/tools/editor/plugins/script_text_editor.cpp @@ -100,7 +100,7 @@ void ScriptTextEditor::_load_theme_settings() { /* keyword color */ - text_edit->set_custom_bg_color(EDITOR_DEF("text_editor/background_color",Color(0,0,0,0))); + text_edit->add_color_override("background_color", EDITOR_DEF("text_editor/background_color",Color(0,0,0,0))); text_edit->add_color_override("completion_background_color", EDITOR_DEF("text_editor/completion_background_color", Color(0,0,0,0))); text_edit->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/completion_selected_color", Color::html("434244"))); text_edit->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/completion_existing_color", Color::html("21dfdfdf"))); @@ -122,6 +122,7 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->add_color_override("breakpoint_color", EDITOR_DEF("text_editor/breakpoint_color", Color(0.8,0.8,0.4,0.2))); text_edit->add_color_override("search_result_color",EDITOR_DEF("text_editor/search_result_color",Color(0.05,0.25,0.05,1))); text_edit->add_color_override("search_result_border_color",EDITOR_DEF("text_editor/search_result_border_color",Color(0.1,0.45,0.1,1))); + text_edit->add_color_override("symbol_color",EDITOR_DEF("text_editor/symbol_color",Color::hex(0x005291ff))); text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/line_spacing",4)); Color keyword_color= EDITOR_DEF("text_editor/keyword_color",Color(0.5,0.0,0.2)); @@ -190,11 +191,6 @@ void ScriptTextEditor::_load_theme_settings() { String end = string.get_slice_count(" ")>1?string.get_slice(" ",1):String(); text_edit->add_color_region(beg,end,string_color,end==""); } - - //colorize symbols - Color symbol_color= EDITOR_DEF("text_editor/symbol_color",Color::hex(0x005291ff)); - text_edit->set_symbol_color(symbol_color); - } diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp index 861f5678f6..f67151d8e9 100644 --- a/tools/editor/plugins/shader_editor_plugin.cpp +++ b/tools/editor/plugins/shader_editor_plugin.cpp @@ -77,7 +77,7 @@ void ShaderTextEditor::_load_theme_settings() { /* keyword color */ - get_text_edit()->set_custom_bg_color(EDITOR_DEF("text_editor/background_color",Color(0,0,0,0))); + get_text_edit()->add_color_override("background_color", EDITOR_DEF("text_editor/background_color",Color(0,0,0,0))); get_text_edit()->add_color_override("completion_background_color", EDITOR_DEF("text_editor/completion_background_color", Color(0,0,0,0))); get_text_edit()->add_color_override("completion_selected_color", EDITOR_DEF("text_editor/completion_selected_color", Color::html("434244"))); get_text_edit()->add_color_override("completion_existing_color", EDITOR_DEF("text_editor/completion_existing_color", Color::html("21dfdfdf"))); @@ -99,6 +99,7 @@ void ShaderTextEditor::_load_theme_settings() { get_text_edit()->add_color_override("breakpoint_color", EDITOR_DEF("text_editor/breakpoint_color", Color(0.8,0.8,0.4,0.2))); get_text_edit()->add_color_override("search_result_color",EDITOR_DEF("text_editor/search_result_color",Color(0.05,0.25,0.05,1))); get_text_edit()->add_color_override("search_result_border_color",EDITOR_DEF("text_editor/search_result_border_color",Color(0.1,0.45,0.1,1))); + get_text_edit()->add_color_override("symbol_color",EDITOR_DEF("text_editor/symbol_color",Color::hex(0x005291ff))); Color keyword_color= EDITOR_DEF("text_editor/keyword_color",Color(0.5,0.0,0.2)); @@ -135,11 +136,6 @@ void ShaderTextEditor::_load_theme_settings() { String end = string.get_slice_count(" ")>1?string.get_slice(" ",1):String(); get_text_edit()->add_color_region(beg,end,string_color,end==""); }*/ - - //colorize symbols - Color symbol_color= EDITOR_DEF("text_editor/symbol_color",Color::hex(0x005291ff)); - get_text_edit()->set_symbol_color(symbol_color); - } diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index 1c99982155..069d7cef81 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -141,7 +141,7 @@ private: } String sp = p.simplify_path(); project_path->set_text(sp); - _path_text_changed(p); + _path_text_changed(sp); get_ok()->call_deferred("grab_focus"); } @@ -150,7 +150,7 @@ private: String p = p_path; String sp = p.simplify_path(); project_path->set_text(sp); - _path_text_changed(p); + _path_text_changed(sp); get_ok()->call_deferred("grab_focus"); } @@ -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); diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 619ff12296..b9cce34454 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -1630,7 +1630,7 @@ static bool _is_node_visible(Node* p_node) { static bool _has_visible_children(Node* p_node) { - bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false; + bool collapsed = p_node->is_displayed_folded(); if (collapsed) return false; @@ -1653,7 +1653,7 @@ static Node* _find_last_visible(Node* p_node) { Node* last=NULL; - bool collapsed = p_node->has_meta("_editor_collapsed") ? (bool)p_node->get_meta("_editor_collapsed") : false; + bool collapsed = p_node->is_displayed_folded(); if (!collapsed) { for(int i=0;i<p_node->get_child_count();i++) { @@ -1688,36 +1688,9 @@ void SceneTreeDock::_normalize_drop(Node*& to_node, int &to_pos, int p_type) { ERR_EXPLAIN("Cannot perform drop above the root node!"); ERR_FAIL(); } - Node* upper_sibling=NULL; - for(int i=0;i<to_node->get_index();i++) { - Node *c =to_node->get_parent()->get_child(i); - if (_is_node_visible(c)) { - upper_sibling=c; - } - } - - - if (upper_sibling) { - //quite complicated, look for next visible in tree - upper_sibling=_find_last_visible(upper_sibling); - - if (upper_sibling->get_parent()==to_node->get_parent()) { - //just insert over this node because nothing is above at an upper level - to_pos=to_node->get_index(); - to_node=to_node->get_parent(); - } else { - to_pos=-1; //insert last in whathever is up - to_node=upper_sibling->get_parent(); //insert at a parent of whathever is up - } - - - } else { - //just insert over this node because nothing is above at the same level - to_pos=to_node->get_index(); - to_node=to_node->get_parent(); - - } + to_pos=to_node->get_index(); + to_node=to_node->get_parent(); } else if (p_type==1) { //drop at below selected node |