diff options
-rw-r--r-- | doc/base/classes.xml | 9 | ||||
-rw-r--r-- | platform/x11/detect.py | 2 | ||||
-rw-r--r-- | scene/gui/color_picker.cpp | 45 | ||||
-rw-r--r-- | scene/gui/color_picker.h | 1 | ||||
-rw-r--r-- | scene/gui/control.cpp | 26 | ||||
-rw-r--r-- | scene/gui/control.h | 4 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 9 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 5 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 35 | ||||
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 8 | ||||
-rw-r--r-- | scene/resources/font.cpp | 6 | ||||
-rw-r--r-- | scene/resources/font.h | 1 | ||||
-rw-r--r-- | scene/resources/theme.cpp | 15 | ||||
-rw-r--r-- | servers/physics_2d/body_pair_2d_sw.cpp | 45 | ||||
-rw-r--r-- | tools/editor/create_dialog.cpp | 3 | ||||
-rw-r--r-- | tools/editor/icons/SCsub | 2 | ||||
-rw-r--r-- | tools/editor/io_plugins/editor_scene_import_plugin.cpp | 2 | ||||
-rw-r--r-- | tools/editor/plugins/script_editor_plugin.cpp | 57 | ||||
-rw-r--r-- | tools/editor/plugins/script_editor_plugin.h | 3 |
19 files changed, 205 insertions, 73 deletions
diff --git a/doc/base/classes.xml b/doc/base/classes.xml index d3d8b2d9f6..5be3639d9f 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -8663,7 +8663,7 @@ <return type="bool"> </return> <description> - Returns whether this color picker is in raw mode or not + Returns whether this color picker is in raw mode or not, raw mode will allow the color R, G, B component values to go beyond 1, you have to consider that the max value for color components is 1, going beyond that value will not have effect in the color, but can be used for special operations that require it (like tinting without darkening or rendering sprites in HDR). </description> </method> <method name="set_color"> @@ -8684,7 +8684,7 @@ <argument index="0" name="mode" type="bool"> </argument> <description> - When set to true, every color channel will be represented as a value from 0 to 1, insetead of 0, 255. + Set whether this color picker is using raw mode or not, see [method is_raw_mode]. </description> </method> </methods> @@ -12999,6 +12999,11 @@ Return the font descent (number of pixels below the baseline). </description> </method> + <method name="update_changes"> + <description> + After editing a font (changing size, ascent, char rects, etc.). Call this function to propagate changes to controls that might use it. + </description> + </method> <method name="get_height" qualifiers="const"> <return type="float"> </return> diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 3c50e2cf5b..2be8b01dc3 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -182,7 +182,7 @@ def configure(env): print("PulseAudio development libraries not found, disabling driver") env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL']) - env.Append(LIBS=['GL', 'GLU', 'pthread', 'z']) + env.Append(LIBS=['GL', 'pthread', 'z']) if (platform.system() == "Linux"): env.Append(LIBS='dl') #env.Append(CPPFLAGS=['-DMPC_FIXED_POINT']) diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 06f8c27957..c8bd9749df 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -140,14 +140,13 @@ void ColorPicker::_value_changed(double) { if (updating) return; - for(int i=0;i<3;i++) { + for(int i=0;i<4;i++) { color.components[i] = scroll[i]->get_val()/(raw_mode_enabled?1.0:255.0); } - color.components[3] = scroll[3]->get_val()/255.0; set_color(color); - c_text->set_text(color.to_html(edit_alpha && color.a<1)); + _update_text_value(); emit_signal("color_changed",color); @@ -174,22 +173,16 @@ void ColorPicker::_update_color() { for(int i=0;i<4;i++) { scroll[i]->set_max(255); scroll[i]->set_step(0.01); - if (raw_mode_enabled && i != 3) + if (raw_mode_enabled) { + if (i == 3) + scroll[i]->set_max(1); scroll[i]->set_val(color.components[i]); - else - scroll[i]->set_val(color.components[i]*255); + } else { + scroll[i]->set_val(color.components[i] * 255); + } } - if (text_is_constructor) { - String t = "Color("+String::num(color.r)+","+String::num(color.g)+","+String::num(color.b); - if (edit_alpha && color.a<1) - t+=(","+String::num(color.a)+")") ; - else - t+=")"; - c_text->set_text(t); - } else { - c_text->set_text(color.to_html(edit_alpha && color.a<1)); - } + _update_text_value(); sample->update(); updating=false; @@ -262,6 +255,20 @@ bool ColorPicker::is_raw_mode() const { return raw_mode_enabled; } + +void ColorPicker::_update_text_value() { + if (text_is_constructor) { + String t = "Color("+String::num(color.r)+","+String::num(color.g)+","+String::num(color.b); + if (edit_alpha && color.a<1) + t+=(","+String::num(color.a)+")") ; + else + t+=")"; + c_text->set_text(t); + } else { + c_text->set_text(color.to_html(edit_alpha && color.a<1)); + } +} + void ColorPicker::_sample_draw() { sample->draw_rect(Rect2(Point2(),Size2(256,20)),color); } @@ -271,12 +278,12 @@ void ColorPicker::_hsv_draw(int p_wich,Control* c) if (!c) return; if (p_wich==0) { - int x=c->get_size().x*s; - int y=c->get_size().y-c->get_size().y*v; + int x = CLAMP(c->get_size().x * s, 0, c->get_size().x); + int y = CLAMP(c->get_size().y-c->get_size().y * v, 0, c->get_size().y); Color col = color; col.a=1; c->draw_line(Point2(x,0),Point2(x,c->get_size().y),col.inverted()); - c->draw_line(Point2(0,y),Point2(c->get_size().x,y),col.inverted()); + c->draw_line(Point2(0, y),Point2(c->get_size().x, y),col.inverted()); c->draw_line(Point2(x,y),Point2(x,y),Color(1,1,1),2); } else if (p_wich==1) { int y=c->get_size().y-c->get_size().y*h; diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index b9ef1f1e2f..5e2cc57274 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -80,6 +80,7 @@ private: void _update_controls(); void _update_color(); void _update_presets(); + void _update_text_value(); void _text_type_toggled(); void _sample_draw(); void _hsv_draw(int p_wich,Control *c); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index fc27c0d24f..c176e50cee 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1865,7 +1865,7 @@ void Control::_modal_stack_remove() { } -void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner) { +void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner,bool p_assign) { Control *c = p_at->cast_to<Control>(); @@ -1884,15 +1884,30 @@ void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner) { if (c) { - c->data.theme_owner=p_owner; + if (p_assign) { + c->data.theme_owner=p_owner; + } c->_notification(NOTIFICATION_THEME_CHANGED); c->update(); } } + +void Control::_theme_changed() { + + _propagate_theme_changed(this,this,false); +} + void Control::set_theme(const Ref<Theme>& p_theme) { + if (data.theme==p_theme) + return; + + if (data.theme.is_valid()) { + data.theme->disconnect("changed",this,"_theme_changed"); + } + data.theme=p_theme; if (!p_theme.is_null()) { @@ -1909,6 +1924,9 @@ void Control::set_theme(const Ref<Theme>& p_theme) { } + if (data.theme.is_valid()) { + data.theme->connect("changed",this,"_theme_changed"); + } } @@ -2448,6 +2466,10 @@ void Control::_bind_methods() { ObjectTypeDB::bind_method(_MD("minimum_size_changed"), &Control::minimum_size_changed); + ObjectTypeDB::bind_method(_MD("_theme_changed"), &Control::_theme_changed); + + + ObjectTypeDB::bind_method(_MD("_font_changed"), &Control::_font_changed); BIND_VMETHOD(MethodInfo("_input_event",PropertyInfo(Variant::INPUT_EVENT,"event"))); diff --git a/scene/gui/control.h b/scene/gui/control.h index 830ebd1620..1337cbc4b9 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -172,7 +172,9 @@ private: float _get_range(int p_idx) const; float _s2a(float p_val, AnchorType p_anchor,float p_range) const; float _a2s(float p_val, AnchorType p_anchor,float p_range) const; - void _propagate_theme_changed(CanvasItem *p_at, Control *p_owner); + void _propagate_theme_changed(CanvasItem *p_at, Control *p_owner, bool p_assign=true); + void _theme_changed(); + void _change_notify_margins(); void _update_minimum_size(); diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 6c47072b33..89c235e101 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -118,7 +118,7 @@ void LineEdit::_input_event(InputEvent p_event) { const InputEventMouseMotion& m=p_event.mouse_motion; - if (m.button_mask&1) { + if (m.button_mask&BUTTON_LEFT) { if (selection.creating) { set_cursor_at_pixel_pos(m.x); @@ -616,11 +616,11 @@ void LineEdit::_notification(int p_what) { } break; case ALIGN_CENTER: { - x_ofs=x_ofs=int(size.width-(cached_width))/2; + x_ofs=int(size.width-(cached_width))/2; } break; case ALIGN_RIGHT: { - x_ofs=x_ofs=int(size.width-style->get_offset().x-(cached_width)); + x_ofs=int(size.width-style->get_offset().x-(cached_width)); } break; } @@ -811,6 +811,9 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { if ( (pixel_ofs-p_x) < (char_w >> 1 ) ) { ofs+=1; + } else if ( (pixel_ofs-p_x) > (char_w >> 1 ) ) { + + ofs-=1; } break; diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 46b64ce401..50b44c55a9 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1007,12 +1007,13 @@ void TextEdit::_notification(int p_what) { cursor_pos.y += (get_row_height() - 3); } + int caret_w = (str[j]=='\t') ? cache.font->get_char_size(' ').width : char_w; if (draw_caret) { if (insert_mode) { int caret_h = (block_caret) ? 4 : 1; - VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(char_w,caret_h)),cache.caret_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(caret_w,caret_h)),cache.caret_color); } else { - int caret_w = (block_caret) ? char_w : 1; + caret_w = (block_caret) ? caret_w : 1; VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(cursor_pos, Size2i(caret_w,get_row_height())),cache.caret_color); } } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index bb6e6e289b..bdb2754e5e 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1346,13 +1346,21 @@ Matrix32 Viewport::_get_input_pre_xform() const { void Viewport::_make_input_local(InputEvent& ev) { + switch(ev.type) { case InputEvent::MOUSE_BUTTON: { + Vector2 vp_ofs; + if (parent_control) { + vp_ofs = (parent_control->get_viewport()->get_final_transform() * parent_control->get_global_transform_with_canvas()).get_origin(); + } + Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform(); Vector2 g = ai.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y)); - Vector2 l = ai.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y)); + Vector2 l = ai.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y)-vp_ofs); + + ev.mouse_button.x=l.x; ev.mouse_button.y=l.y; ev.mouse_button.global_x=g.x; @@ -1361,11 +1369,18 @@ void Viewport::_make_input_local(InputEvent& ev) { } break; case InputEvent::MOUSE_MOTION: { + Vector2 vp_ofs; + if (parent_control) { + vp_ofs = (parent_control->get_viewport()->get_final_transform() * parent_control->get_global_transform_with_canvas()).get_origin(); + } + Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform(); Vector2 g = ai.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y)); - Vector2 l = ai.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y)); + Vector2 l = ai.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y)-vp_ofs); Vector2 r = ai.basis_xform(Vector2(ev.mouse_motion.relative_x,ev.mouse_motion.relative_y)); Vector2 s = ai.basis_xform(Vector2(ev.mouse_motion.speed_x,ev.mouse_motion.speed_y)); + + ev.mouse_motion.x=l.x; ev.mouse_motion.y=l.y; ev.mouse_motion.global_x=g.x; @@ -1378,16 +1393,28 @@ void Viewport::_make_input_local(InputEvent& ev) { } break; case InputEvent::SCREEN_TOUCH: { + Vector2 vp_ofs; + if (parent_control) { + vp_ofs = (parent_control->get_viewport()->get_final_transform() * parent_control->get_global_transform_with_canvas()).get_origin(); + } + Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform(); - Vector2 t = ai.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y)); + Vector2 t = ai.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y)-vp_ofs); + + ev.screen_touch.x=t.x; ev.screen_touch.y=t.y; } break; case InputEvent::SCREEN_DRAG: { + Vector2 vp_ofs; + if (parent_control) { + vp_ofs = (parent_control->get_viewport()->get_final_transform() * parent_control->get_global_transform_with_canvas()).get_origin(); + } + Matrix32 ai = get_final_transform().affine_inverse() * _get_input_pre_xform(); - Vector2 t = ai.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y)); + Vector2 t = ai.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y)-vp_ofs); Vector2 r = ai.basis_xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y)); Vector2 s = ai.basis_xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y)); ev.screen_drag.x=t.x; diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index ffc5232e8f..499cf0a169 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -54,8 +54,10 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, flo texture = Ref<ImageTexture>( memnew( ImageTexture ) ); Image img(p_src); - if (scale>1) + if (scale>1) { + img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); + } texture->create_from_image( img,ImageTexture::FLAG_FILTER ); (*tex_cache)[p_src]=texture; } @@ -92,8 +94,10 @@ static Ref<Texture> make_icon(T p_src) { Ref<ImageTexture> texture( memnew( ImageTexture ) ); Image img = Image(p_src); - if (scale>1) + if (scale>1) { + img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); + } texture->create_from_image( img,ImageTexture::FLAG_FILTER ); return texture; diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 6ad8a95565..1afa3fec19 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -71,6 +71,11 @@ void Font::draw(RID p_canvas_item, const Point2& p_pos, const String& p_text, co } } +void Font::update_changes() { + + emit_changed(); +} + void Font::_bind_methods() { ObjectTypeDB::bind_method(_MD("draw","canvas_item","pos","string","modulate","clip_w"),&Font::draw,DEFVAL(Color(1,1,1)),DEFVAL(-1)); @@ -80,6 +85,7 @@ void Font::_bind_methods() { ObjectTypeDB::bind_method(_MD("is_distance_field_hint"),&Font::is_distance_field_hint); ObjectTypeDB::bind_method(_MD("get_string_size","string"),&Font::get_string_size); ObjectTypeDB::bind_method(_MD("draw_char","canvas_item","pos","char","next","modulate"),&Font::draw_char,DEFVAL(-1),DEFVAL(Color(1,1,1))); + ObjectTypeDB::bind_method(_MD("update_changes"),&Font::update_changes); } diff --git a/scene/resources/font.h b/scene/resources/font.h index 67836564cd..fe4558f9e3 100644 --- a/scene/resources/font.h +++ b/scene/resources/font.h @@ -61,6 +61,7 @@ public: void draw_halign(RID p_canvas_item, const Point2& p_pos, HAlign p_align,float p_width,const String& p_text,const Color& p_modulate=Color(1,1,1)) const; virtual float draw_char(RID p_canvas_item, const Point2& p_pos, CharType p_char, CharType p_next=0,const Color& p_modulate=Color(1,1,1)) const=0; + void update_changes(); Font(); }; diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 92a6f0c0b9..b351167e10 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -219,7 +219,22 @@ Ref<Theme> Theme::get_default() { void Theme::set_default_theme_font( const Ref<Font>& p_default_font ) { + if (default_theme_font==p_default_font) + return; + + if (default_theme_font.is_valid()) { + _unref_font(default_theme_font); + } + default_theme_font=p_default_font; + + if (default_theme_font.is_valid()) { + _ref_font(default_theme_font); + } + + _change_notify(); + emit_changed();; + } Ref<Font> Theme::get_default_theme_font() const { diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index 35f19605df..ba0358a1f2 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -298,19 +298,17 @@ bool BodyPair2DSW::setup(float p_step) { if (A->is_using_one_way_collision()) { Vector2 direction = A->get_one_way_collision_direction(); bool valid=false; - for(int i=0;i<contact_count;i++) { - Contact& c = contacts[i]; - - if (c.normal.dot(direction)<0) - continue; - if (B->get_linear_velocity().dot(direction)<0) - continue; - - if (!c.reused) { - continue; + if (B->get_linear_velocity().dot(direction)>=0){ + for(int i=0;i<contact_count;i++) { + Contact& c = contacts[i]; + if (!c.reused) + continue; + if (c.normal.dot(direction)<0) + continue; + + valid=true; + break; } - - valid=true; } if (!valid) { @@ -323,20 +321,17 @@ bool BodyPair2DSW::setup(float p_step) { if (B->is_using_one_way_collision()) { Vector2 direction = B->get_one_way_collision_direction(); bool valid=false; - for(int i=0;i<contact_count;i++) { - - Contact& c = contacts[i]; - - if (c.normal.dot(direction)<0) - continue; - if (A->get_linear_velocity().dot(direction)<0) - continue; - - if (!c.reused) { - continue; + if (A->get_linear_velocity().dot(direction)>=0){ + for(int i=0;i<contact_count;i++) { + Contact& c = contacts[i]; + if (!c.reused) + continue; + if (c.normal.dot(direction)<0) + continue; + + valid=true; + break; } - - valid=true; } if (!valid) { collided=false; diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp index 210b799f3d..07d1566ab8 100644 --- a/tools/editor/create_dialog.cpp +++ b/tools/editor/create_dialog.cpp @@ -154,6 +154,9 @@ void CreateDialog::_update_search() { TreeItem *root = search_options->create_item(); root->set_text(0,base_type); + if (has_icon(base_type,"EditorIcons")) { + root->set_icon(0,get_icon(base_type,"EditorIcons")); + } List<StringName>::Element *I=type_list.front(); TreeItem *to_select=NULL; diff --git a/tools/editor/icons/SCsub b/tools/editor/icons/SCsub index 7132968c88..f2f5dcca48 100644 --- a/tools/editor/icons/SCsub +++ b/tools/editor/icons/SCsub @@ -65,7 +65,7 @@ def make_editor_icons_action(target, source, env): s.write("static Ref<ImageTexture> make_icon(const uint8_t* p_png,const uint8_t* p_hidpi_png) {\n") s.write("\tRef<ImageTexture> texture( memnew( ImageTexture ) );\n") s.write("\tImage img((editor_is_hidpi()&&p_hidpi_png)?p_hidpi_png:p_png);\n") - s.write("\tif (editor_is_hidpi() && !p_hidpi_png) img.expand_x2_hq2x();\n") + s.write("\tif (editor_is_hidpi() && !p_hidpi_png) { img.convert(Image::FORMAT_RGBA); img.expand_x2_hq2x(); }\n") s.write("\ttexture->create_from_image( img,ImageTexture::FLAG_FILTER );\n") s.write("\treturn texture;\n") s.write("}\n\n") diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index e24412d4ef..fa62283e37 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -756,6 +756,8 @@ void EditorSceneImportDialog::_import(bool p_and_open) { } + // Scenes should always be imported as binary format since vertex data is large and would take + // up a lot of space and time to load if imported as text format (GH-5778) String save_file = save_path->get_text().plus_file(import_path->get_text().get_file().basename()+".scn"); print_line("Saving to: "+save_file); diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 65741fd072..4032a790d8 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -819,7 +819,7 @@ void ScriptEditor::_close_tab(int p_idx) { _update_script_names(); - EditorNode::get_singleton()->save_layout(); + _save_layout(); } void ScriptEditor::_close_current_tab() { @@ -828,6 +828,22 @@ void ScriptEditor::_close_current_tab() { } +void ScriptEditor::_close_docs_tab() { + + int child_count = tab_container->get_child_count(); + for (int i = child_count-1; i>=0; i--) { + + EditorHelp *ste = tab_container->get_child(i)->cast_to<EditorHelp>(); + + if (ste) { + _close_tab(i); + } + + } + +} + + void ScriptEditor::_resave_scripts(const String& p_str) { @@ -1481,7 +1497,9 @@ void ScriptEditor::_menu_option(int p_option) { if (scr.is_null()) return; scr->set_source_code(te->get_text()); - scr->get_language()->reload_tool_script(scr,p_option==FILE_TOOL_RELOAD_SOFT); + bool soft = p_option==FILE_TOOL_RELOAD_SOFT || scr->get_instance_base_type()=="EditorPlugin"; //always soft-reload editor plugins + + scr->get_language()->reload_tool_script(scr,soft); } break; case EDIT_TRIM_TRAILING_WHITESAPCE: { _trim_trailing_whitespace(current->get_text_edit()); @@ -1611,6 +1629,9 @@ void ScriptEditor::_menu_option(int p_option) { _close_current_tab(); } } break; + case CLOSE_DOCS: { + _close_docs_tab(); + } break; case WINDOW_MOVE_LEFT: { if (tab_container->get_current_tab()>0) { @@ -1658,6 +1679,9 @@ void ScriptEditor::_menu_option(int p_option) { case FILE_CLOSE: { _close_current_tab(); } break; + case CLOSE_DOCS: { + _close_docs_tab(); + } break; } @@ -2057,6 +2081,9 @@ void ScriptEditor::_update_script_colors() { void ScriptEditor::_update_script_names() { + if (restoring_layout) + return; + waiting_update_names=false; Set<Ref<Script> > used; Node* edited = EditorNode::get_singleton()->get_edited_scene(); @@ -2220,10 +2247,8 @@ void ScriptEditor::edit(const Ref<Script>& p_script) { _update_script_names(); + _save_layout(); ste->connect("name_changed",this,"_update_script_names"); - if (!restoring_layout) { - EditorNode::get_singleton()->save_layout(); - } //test for modification, maybe the script was not edited but was loaded @@ -2343,6 +2368,15 @@ void ScriptEditor::_add_callback(Object *p_obj, const String& p_function, const } +void ScriptEditor::_save_layout() { + + if (restoring_layout) { + return; + } + + editor->save_layout(); +} + void ScriptEditor::_editor_settings_changed() { trim_trailing_whitespace_on_save = EditorSettings::get_singleton()->get("text_editor/trim_trailing_whitespace_on_save"); @@ -2400,7 +2434,7 @@ void ScriptEditor::_tree_changed() { void ScriptEditor::_script_split_dragged(float) { - EditorNode::get_singleton()->save_layout(); + _save_layout(); } void ScriptEditor::_unhandled_input(const InputEvent& p_event) { @@ -2446,7 +2480,6 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { } } - for(int i=0;i<helps.size();i++) { String path = helps[i]; @@ -2462,9 +2495,9 @@ void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { script_split->set_split_offset(p_layout->get_value("ScriptEditor","split_offset")); } - restoring_layout=false; + _update_script_names(); } void ScriptEditor::get_window_layout(Ref<ConfigFile> p_layout) { @@ -2524,7 +2557,7 @@ void ScriptEditor::_help_class_open(const String& p_class) { eh->go_to_class(p_class,0); eh->connect("go_to_help",this,"_help_class_goto"); _update_script_names(); - + _save_layout(); } void ScriptEditor::_help_class_goto(const String& p_desc) { @@ -2553,7 +2586,7 @@ void ScriptEditor::_help_class_goto(const String& p_desc) { eh->go_to_help(p_desc); eh->connect("go_to_help",this,"_help_class_goto"); _update_script_names(); - + _save_layout(); } void ScriptEditor::_update_history_pos(int p_new_pos) { @@ -2678,6 +2711,7 @@ void ScriptEditor::_bind_methods() { ObjectTypeDB::bind_method("_tab_changed",&ScriptEditor::_tab_changed); ObjectTypeDB::bind_method("_menu_option",&ScriptEditor::_menu_option); ObjectTypeDB::bind_method("_close_current_tab",&ScriptEditor::_close_current_tab); + ObjectTypeDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab); ObjectTypeDB::bind_method("_editor_play",&ScriptEditor::_editor_play); ObjectTypeDB::bind_method("_editor_pause",&ScriptEditor::_editor_pause); ObjectTypeDB::bind_method("_editor_stop",&ScriptEditor::_editor_stop); @@ -2760,7 +2794,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_theme", TTR("Save Theme")), FILE_SAVE_THEME); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_theme_as", TTR("Save Theme As")), FILE_SAVE_THEME_AS); file_menu->get_popup()->add_separator(); - file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD|KEY_W), FILE_CLOSE); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_docs", TTR("Close Docs")), CLOSE_DOCS); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE); file_menu->get_popup()->connect("item_pressed", this,"_menu_option"); edit_menu = memnew( MenuButton ); diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h index dfa72490a5..2f079b9fc7 100644 --- a/tools/editor/plugins/script_editor_plugin.h +++ b/tools/editor/plugins/script_editor_plugin.h @@ -127,6 +127,7 @@ class ScriptEditor : public VBoxContainer { FILE_SAVE_THEME, FILE_SAVE_THEME_AS, FILE_CLOSE, + CLOSE_DOCS, EDIT_UNDO, EDIT_REDO, EDIT_CUT, @@ -237,6 +238,7 @@ class ScriptEditor : public VBoxContainer { void _close_tab(int p_idx); void _close_current_tab(); + void _close_docs_tab(); bool grab_focus_block; @@ -268,6 +270,7 @@ class ScriptEditor : public VBoxContainer { void _update_window_menu(); void _script_created(Ref<Script> p_script); + void _save_layout(); void _editor_settings_changed(); void _autosave_scripts(); |