diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-06-29 00:29:49 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-06-29 00:29:49 -0300 |
commit | 95047562d743b1c1fdc007432c8a0c145a455c5d (patch) | |
tree | f563e5c900c4330fcc602b6e5a721bc63022b253 /scene/gui | |
parent | 2b64f73b0459190d20b2f6de39275ee7979317c4 (diff) |
Several performance improvements, mainly in loading and instancing scenes and resources.
A general speedup should be apparent, with even more peformance increase when compiling optimized.
WARNING: Tested and it seems to work, but if something breaks, please report.
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/base_button.cpp | 6 | ||||
-rw-r--r-- | scene/gui/button.cpp | 8 | ||||
-rw-r--r-- | scene/gui/button_array.cpp | 8 | ||||
-rw-r--r-- | scene/gui/control.cpp | 40 | ||||
-rw-r--r-- | scene/gui/label.cpp | 10 | ||||
-rw-r--r-- | scene/gui/texture_button.cpp | 16 | ||||
-rw-r--r-- | scene/gui/texture_frame.cpp | 6 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 6 |
8 files changed, 50 insertions, 50 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 8b6f433c9c..965e7f399d 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -390,10 +390,10 @@ void BaseButton::_bind_methods() { ADD_SIGNAL( MethodInfo("pressed" ) ); ADD_SIGNAL( MethodInfo("released" ) ); ADD_SIGNAL( MethodInfo("toggled", PropertyInfo( Variant::BOOL,"pressed") ) ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled")); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled")); ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed")); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press")); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed")); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press")); BIND_CONSTANT( DRAW_NORMAL ); diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index b465db5c80..edeb18bfc1 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -225,11 +225,11 @@ void Button::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_text_align"),&Button::get_text_align); ObjectTypeDB::bind_method(_MD("is_flat"),&Button::is_flat); - ADD_PROPERTY( PropertyInfo( Variant::STRING, "text", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL ), _SCS("set_text"),_SCS("get_text") ); - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), _SCS("set_button_icon"),_SCS("get_button_icon") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL ), _SCS("set_text"),_SCS("get_text") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture" ), _SCS("set_button_icon"),_SCS("get_button_icon") ); ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), _SCS("set_flat"),_SCS("is_flat") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "clip_text" ), _SCS("set_clip_text"),_SCS("get_clip_text") ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "align",PROPERTY_HINT_ENUM,"Left,Center,Right" ), _SCS("set_text_align"),_SCS("get_text_align") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "clip_text" ), _SCS("set_clip_text"),_SCS("get_clip_text") ); + ADD_PROPERTYNO( PropertyInfo( Variant::INT, "align",PROPERTY_HINT_ENUM,"Left,Center,Right" ), _SCS("set_text_align"),_SCS("get_text_align") ); } diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp index 7f565de244..b86e32dda7 100644 --- a/scene/gui/button_array.cpp +++ b/scene/gui/button_array.cpp @@ -34,7 +34,7 @@ bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) { String n=String(p_name); if (n.begins_with("button/")) { - String what = n.get_slice("/",1); + String what = n.get_slicec('/',1); if (what=="count") { int new_size=p_value; if (new_size>0 && buttons.size()==0) { @@ -57,7 +57,7 @@ bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) { } else { int idx=what.to_int(); ERR_FAIL_INDEX_V(idx,buttons.size(),false); - String f = n.get_slice("/",2); + String f = n.get_slicec('/',2); if (f=="text") buttons[idx].text=p_value; else if (f=="icon") @@ -80,7 +80,7 @@ bool ButtonArray::_get(const StringName& p_name,Variant &r_ret) const { String n=String(p_name); if (n.begins_with("button/")) { - String what = n.get_slice("/",1); + String what = n.get_slicec('/',1); if (what=="count") { r_ret=buttons.size(); } else if (what=="align") { @@ -92,7 +92,7 @@ bool ButtonArray::_get(const StringName& p_name,Variant &r_ret) const { } else { int idx=what.to_int(); ERR_FAIL_INDEX_V(idx,buttons.size(),false); - String f = n.get_slice("/",2); + String f = n.get_slicec('/',2); if (f=="text") r_ret=buttons[idx].text; else if (f=="icon") diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 2367c03e99..a1c0644650 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -136,27 +136,27 @@ bool Control::_set(const StringName& p_name, const Variant& p_value) { if (p_value.get_type()==Variant::NIL) { if (name.begins_with("custom_icons/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); data.icon_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); update(); } else if (name.begins_with("custom_styles/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); data.style_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); update(); } else if (name.begins_with("custom_fonts/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); data.font_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); update(); } else if (name.begins_with("custom_colors/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); data.color_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); update(); } else if (name.begins_with("custom_constants/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); data.constant_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); update(); @@ -165,23 +165,23 @@ bool Control::_set(const StringName& p_name, const Variant& p_value) { } else { if (name.begins_with("custom_icons/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); notification(NOTIFICATION_THEME_CHANGED); add_icon_override(dname,p_value); } else if (name.begins_with("custom_styles/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); add_style_override(dname,p_value); notification(NOTIFICATION_THEME_CHANGED); } else if (name.begins_with("custom_fonts/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); add_font_override(dname,p_value); notification(NOTIFICATION_THEME_CHANGED); } else if (name.begins_with("custom_colors/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); add_color_override(dname,p_value); notification(NOTIFICATION_THEME_CHANGED); } else if (name.begins_with("custom_constants/")) { - String dname = name.get_slice("/",1); + String dname = name.get_slicec('/',1); add_constant_override(dname,p_value); notification(NOTIFICATION_THEME_CHANGED); } else @@ -217,22 +217,22 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const { return false; if (sname.begins_with("custom_icons/")) { - String name = sname.get_slice("/",1); + String name = sname.get_slicec('/',1); r_ret= data.icon_override.has(name)?Variant(data.icon_override[name]):Variant(); } else if (sname.begins_with("custom_styles/")) { - String name = sname.get_slice("/",1); + String name = sname.get_slicec('/',1); r_ret= data.style_override.has(name)?Variant(data.style_override[name]):Variant(); } else if (sname.begins_with("custom_fonts/")) { - String name = sname.get_slice("/",1); + String name = sname.get_slicec('/',1); r_ret= data.font_override.has(name)?Variant(data.font_override[name]):Variant(); } else if (sname.begins_with("custom_colors/")) { - String name = sname.get_slice("/",1); + String name = sname.get_slicec('/',1); r_ret= data.color_override.has(name)?Variant(data.color_override[name]):Variant(); } else if (sname.begins_with("custom_constants/")) { - String name = sname.get_slice("/",1); + String name = sname.get_slicec('/',1); r_ret= data.constant_override.has(name)?Variant(data.constant_override[name]):Variant(); } else @@ -2832,16 +2832,16 @@ void Control::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/size", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_size"),_SCS("get_size") ); ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") ); ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint/tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") ); - ADD_PROPERTYI( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT ); - ADD_PROPERTYI( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP ); - ADD_PROPERTYI( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/right" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_RIGHT ); - ADD_PROPERTYI( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/bottom" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_BOTTOM ); + ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT ); + ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP ); + ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/right" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_RIGHT ); + ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/bottom" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_BOTTOM ); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus/ignore_mouse"), _SCS("set_ignore_mouse"),_SCS("is_ignoring_mouse") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus/stop_mouse"), _SCS("set_stop_mouse"),_SCS("is_stopping_mouse") ); ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"size_flags/horizontal", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_h_size_flags"),_SCS("get_h_size_flags") ); ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"size_flags/vertical", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_v_size_flags"),_SCS("get_v_size_flags") ); - ADD_PROPERTY( PropertyInfo(Variant::INT,"size_flags/stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"),_SCS("get_stretch_ratio") ); + ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags/stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"),_SCS("get_stretch_ratio") ); ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"theme/theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), _SCS("set_theme"),_SCS("get_theme") ); BIND_CONSTANT( ANCHOR_BEGIN ); diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 27d0f568a2..e7af4fa349 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -613,11 +613,11 @@ void Label::_bind_methods() { BIND_CONSTANT( VALIGN_BOTTOM ); BIND_CONSTANT( VALIGN_FILL ); - ADD_PROPERTY( PropertyInfo( Variant::STRING, "text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL), _SCS("set_text"),_SCS("get_text") ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "align", PROPERTY_HINT_ENUM,"Left,Center,Right,Fill" ),_SCS("set_align"),_SCS("get_align") ); - ADD_PROPERTY( PropertyInfo( Variant::INT, "valign", PROPERTY_HINT_ENUM,"Top,Center,Bottom,Fill" ),_SCS("set_valign"),_SCS("get_valign") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "autowrap"),_SCS("set_autowrap"),_SCS("has_autowrap") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "uppercase"),_SCS("set_uppercase"),_SCS("is_uppercase") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL), _SCS("set_text"),_SCS("get_text") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "align", PROPERTY_HINT_ENUM,"Left,Center,Right,Fill" ),_SCS("set_align"),_SCS("get_align") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "valign", PROPERTY_HINT_ENUM,"Top,Center,Bottom,Fill" ),_SCS("set_valign"),_SCS("get_valign") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "autowrap"),_SCS("set_autowrap"),_SCS("has_autowrap") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "uppercase"),_SCS("set_uppercase"),_SCS("is_uppercase") ); ADD_PROPERTY( PropertyInfo( Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE,"0,1,0.001"),_SCS("set_percent_visible"),_SCS("get_percent_visible") ); } diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index 823fd55c6e..5b2caecb5b 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -157,14 +157,14 @@ void TextureButton::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_scale"),&TextureButton::get_scale); ObjectTypeDB::bind_method(_MD("get_modulate"),&TextureButton::get_modulate); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_pressed_texture"), _SCS("get_pressed_texture")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/hover",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_hover_texture"), _SCS("get_hover_texture")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture")); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT,"textures/click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ; - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_scale"), _SCS("get_scale")); - ADD_PROPERTY(PropertyInfo(Variant::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate")); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture")); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_pressed_texture"), _SCS("get_pressed_texture")); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/hover",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_hover_texture"), _SCS("get_hover_texture")); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture")); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture")); + ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ; + ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_scale"), _SCS("get_scale")); + ADD_PROPERTYNO(PropertyInfo(Variant::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate")); } diff --git a/scene/gui/texture_frame.cpp b/scene/gui/texture_frame.cpp index 931fb1cb1a..5a6bc86638 100644 --- a/scene/gui/texture_frame.cpp +++ b/scene/gui/texture_frame.cpp @@ -77,9 +77,9 @@ void TextureFrame::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_expand","enable"), & TextureFrame::set_expand ); ObjectTypeDB::bind_method(_MD("has_expand"), & TextureFrame::has_expand ); - ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") ); - ADD_PROPERTY( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") ); - ADD_PROPERTY( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") ); + ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") ); + ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") ); } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index a09920cb2b..6c15f1cae4 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1106,7 +1106,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& int option = (int)p_item->cells[i].val; String s = p_item->cells[i].text; - s=s.get_slice(",",option); + s=s.get_slicec(',',option); Ref<Texture> downarrow = cache.select_arrow; @@ -1527,7 +1527,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_ popup_menu->clear(); for (int i=0;i<c.text.get_slice_count(",");i++) { - String s = c.text.get_slice(",",i); + String s = c.text.get_slicec(',',i); popup_menu->add_item(s,i); } @@ -2234,7 +2234,7 @@ bool Tree::edit_selected() { popup_menu->clear(); for (int i=0;i<c.text.get_slice_count(",");i++) { - String s = c.text.get_slice(",",i); + String s = c.text.get_slicec(',',i); popup_menu->add_item(s,i); } |