summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/light_2d.cpp34
-rw-r--r--scene/2d/light_2d.h4
-rw-r--r--scene/2d/sprite.cpp1
-rw-r--r--scene/3d/camera.cpp12
-rw-r--r--scene/3d/light.cpp6
-rw-r--r--scene/animation/tween.cpp23
-rw-r--r--scene/gui/button_group.cpp4
-rw-r--r--scene/gui/control.cpp10
-rw-r--r--scene/gui/graph_edit.cpp22
-rw-r--r--scene/gui/graph_node.cpp5
-rw-r--r--scene/gui/popup_menu.cpp38
-rw-r--r--scene/gui/popup_menu.h2
-rw-r--r--scene/gui/text_edit.cpp51
-rw-r--r--scene/gui/text_edit.h10
-rw-r--r--scene/gui/tree.cpp13
-rw-r--r--scene/main/node.cpp158
-rw-r--r--scene/main/node.h9
-rw-r--r--scene/main/viewport.cpp3
-rw-r--r--scene/resources/default_theme/button_pressed.pngbin610 -> 499 bytes
-rw-r--r--scene/resources/world.cpp4
-rw-r--r--scene/resources/world_2d.cpp6
-rw-r--r--scene/resources/world_2d.h1
22 files changed, 274 insertions, 142 deletions
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index f37cef673d..3e548a24b0 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -67,7 +67,23 @@ void Light2D::_update_light_visibility() {
if (!is_inside_tree())
return;
- VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible());
+ bool editor_ok=true;
+
+#ifdef TOOLS_ENABLED
+ if (editor_only) {
+ if (!get_tree()->is_editor_hint()) {
+ editor_ok=false;
+ } else {
+ editor_ok = (get_tree()->get_edited_scene_root() && (this==get_tree()->get_edited_scene_root() || get_owner()==get_tree()->get_edited_scene_root()));
+ }
+ }
+#else
+ if (editor_only) {
+ editor_ok=false;
+ }
+#endif
+
+ VS::get_singleton()->canvas_light_set_enabled(canvas_light,enabled && is_visible() && editor_ok);
}
void Light2D::set_enabled( bool p_enabled) {
@@ -82,6 +98,17 @@ bool Light2D::is_enabled() const {
return enabled;
}
+void Light2D::set_editor_only(bool p_editor_only) {
+
+ editor_only=p_editor_only;
+ _update_light_visibility();
+}
+
+bool Light2D::is_editor_only() const{
+
+ return editor_only;
+}
+
void Light2D::set_texture( const Ref<Texture>& p_texture) {
texture=p_texture;
@@ -328,6 +355,9 @@ void Light2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_enabled","enabled"),&Light2D::set_enabled);
ObjectTypeDB::bind_method(_MD("is_enabled"),&Light2D::is_enabled);
+ ObjectTypeDB::bind_method(_MD("set_editor_only","editor_only"), &Light2D::set_editor_only );
+ ObjectTypeDB::bind_method(_MD("is_editor_only"), &Light2D::is_editor_only );
+
ObjectTypeDB::bind_method(_MD("set_texture","texture"),&Light2D::set_texture);
ObjectTypeDB::bind_method(_MD("get_texture"),&Light2D::get_texture);
@@ -383,6 +413,7 @@ void Light2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"enabled"),_SCS("set_enabled"),_SCS("is_enabled"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "editor_only"),_SCS("set_editor_only"),_SCS("is_editor_only"));
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_texture"),_SCS("get_texture"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_texture_offset"),_SCS("get_texture_offset"));
ADD_PROPERTY( PropertyInfo(Variant::REAL,"scale",PROPERTY_HINT_RANGE,"0.01,50,0.01"),_SCS("set_texture_scale"),_SCS("get_texture_scale"));
@@ -413,6 +444,7 @@ Light2D::Light2D() {
canvas_light=VisualServer::get_singleton()->canvas_light_create();
enabled=true;
+ editor_only=false;
shadow=false;
color=Color(1,1,1);
height=0;
diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h
index c03ef96eff..57c89b15e7 100644
--- a/scene/2d/light_2d.h
+++ b/scene/2d/light_2d.h
@@ -45,6 +45,7 @@ public:
private:
RID canvas_light;
bool enabled;
+ bool editor_only;
bool shadow;
Color color;
Color shadow_color;
@@ -78,6 +79,9 @@ public:
void set_enabled( bool p_enabled);
bool is_enabled() const;
+ void set_editor_only(bool p_editor_only);
+ bool is_editor_only() const;
+
void set_texture( const Ref<Texture>& p_texture);
Ref<Texture> get_texture() const;
diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp
index c5b338bf59..8723db95d6 100644
--- a/scene/2d/sprite.cpp
+++ b/scene/2d/sprite.cpp
@@ -214,6 +214,7 @@ void Sprite::set_frame(int p_frame) {
frame=p_frame;
+ _change_notify("frame");
emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index e76c0938fb..76543b67c6 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -648,12 +648,16 @@ void Camera::_bind_methods() {
ObjectTypeDB::bind_method( _MD("get_zfar"),&Camera::get_zfar );
ObjectTypeDB::bind_method( _MD("get_znear"),&Camera::get_znear );
ObjectTypeDB::bind_method( _MD("get_projection"),&Camera::get_projection );
+ ObjectTypeDB::bind_method( _MD("set_h_offset","ofs"),&Camera::set_h_offset );
+ ObjectTypeDB::bind_method( _MD("get_h_offset"),&Camera::get_h_offset );
+ ObjectTypeDB::bind_method( _MD("set_v_offset","ofs"),&Camera::set_v_offset );
+ ObjectTypeDB::bind_method( _MD("get_v_offset"),&Camera::get_v_offset );
ObjectTypeDB::bind_method( _MD("set_visible_layers","mask"),&Camera::set_visible_layers );
ObjectTypeDB::bind_method( _MD("get_visible_layers"),&Camera::get_visible_layers );
- ObjectTypeDB::bind_method(_MD("set_environment","env:Environment"),&Camera::set_environment);
- ObjectTypeDB::bind_method(_MD("get_environment:Environment"),&Camera::get_environment);
- ObjectTypeDB::bind_method(_MD("set_keep_aspect_mode","mode"),&Camera::set_keep_aspect_mode);
- ObjectTypeDB::bind_method(_MD("get_keep_aspect_mode"),&Camera::get_keep_aspect_mode);
+ ObjectTypeDB::bind_method( _MD("set_environment","env:Environment"),&Camera::set_environment );
+ ObjectTypeDB::bind_method( _MD("get_environment:Environment"),&Camera::get_environment );
+ ObjectTypeDB::bind_method( _MD("set_keep_aspect_mode","mode"),&Camera::set_keep_aspect_mode );
+ ObjectTypeDB::bind_method( _MD("get_keep_aspect_mode"),&Camera::get_keep_aspect_mode );
//ObjectTypeDB::bind_method( _MD("_camera_make_current"),&Camera::_camera_make_current );
BIND_CONSTANT( PROJECTION_PERSPECTIVE );
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 227bb3a59d..5b221d1574 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -446,6 +446,10 @@ bool editor_ok=true;
editor_ok = (get_tree()->get_edited_scene_root() && (this==get_tree()->get_edited_scene_root() || get_owner()==get_tree()->get_edited_scene_root()));
}
}
+#else
+ if (editor_only) {
+ editor_ok=false;
+ }
#endif
VS::get_singleton()->instance_light_set_enabled(get_instance(),is_visible() && enabled && editor_ok);
@@ -672,5 +676,3 @@ void SpotLight::_bind_methods() {
ADD_PROPERTYI( PropertyInfo( Variant::REAL, "params/spot_attenuation", PROPERTY_HINT_EXP_EASING, "spot_attenuation"), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPOT_ATTENUATION );
}
-
-
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index adc8f9c8cf..156f4956bb 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -199,13 +199,13 @@ void Tween::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_tween_process_mode"),&Tween::get_tween_process_mode);
ObjectTypeDB::bind_method(_MD("start"),&Tween::start );
- ObjectTypeDB::bind_method(_MD("reset","object","key"),&Tween::reset );
+ ObjectTypeDB::bind_method(_MD("reset","object","key"),&Tween::reset, DEFVAL("") );
ObjectTypeDB::bind_method(_MD("reset_all"),&Tween::reset_all );
- ObjectTypeDB::bind_method(_MD("stop","object","key"),&Tween::stop );
+ ObjectTypeDB::bind_method(_MD("stop","object","key"),&Tween::stop, DEFVAL("") );
ObjectTypeDB::bind_method(_MD("stop_all"),&Tween::stop_all );
- ObjectTypeDB::bind_method(_MD("resume","object","key"),&Tween::resume );
+ ObjectTypeDB::bind_method(_MD("resume","object","key"),&Tween::resume, DEFVAL("") );
ObjectTypeDB::bind_method(_MD("resume_all"),&Tween::resume_all );
- ObjectTypeDB::bind_method(_MD("remove","object","key"),&Tween::remove );
+ ObjectTypeDB::bind_method(_MD("remove","object","key"),&Tween::remove, DEFVAL("") );
ObjectTypeDB::bind_method(_MD("remove_all"),&Tween::remove_all );
ObjectTypeDB::bind_method(_MD("seek","time"),&Tween::seek );
ObjectTypeDB::bind_method(_MD("tell"),&Tween::tell );
@@ -723,7 +723,7 @@ bool Tween::reset(Object *p_object, String p_key) {
if(object == NULL)
continue;
- if(object == p_object && data.key == p_key) {
+ if(object == p_object && (data.key == p_key || p_key == "")) {
data.elapsed = 0;
data.finish = false;
@@ -759,7 +759,7 @@ bool Tween::stop(Object *p_object, String p_key) {
Object *object = ObjectDB::get_instance(data.id);
if(object == NULL)
continue;
- if(object == p_object && data.key == p_key)
+ if(object == p_object && (data.key == p_key || p_key == ""))
data.active = false;
}
pending_update --;
@@ -793,7 +793,7 @@ bool Tween::resume(Object *p_object, String p_key) {
Object *object = ObjectDB::get_instance(data.id);
if(object == NULL)
continue;
- if(object == p_object && data.key == p_key)
+ if(object == p_object && (data.key == p_key || p_key == ""))
data.active = true;
}
pending_update --;
@@ -821,17 +821,20 @@ bool Tween::remove(Object *p_object, String p_key) {
call_deferred("remove", p_object, p_key);
return true;
}
+ List<List<InterpolateData>::Element *> for_removal;
for(List<InterpolateData>::Element *E=interpolates.front();E;E=E->next()) {
InterpolateData& data = E->get();
Object *object = ObjectDB::get_instance(data.id);
if(object == NULL)
continue;
- if(object == p_object && data.key == p_key) {
- interpolates.erase(E);
- return true;
+ if(object == p_object && (data.key == p_key || p_key == "")) {
+ for_removal.push_back(E);
}
}
+ for(List<List<InterpolateData>::Element *>::Element *E=for_removal.front();E;E=E->next()) {
+ interpolates.erase(E->get());
+ }
return true;
}
diff --git a/scene/gui/button_group.cpp b/scene/gui/button_group.cpp
index 04ba5fc06d..5d9f290f78 100644
--- a/scene/gui/button_group.cpp
+++ b/scene/gui/button_group.cpp
@@ -60,6 +60,9 @@ void ButtonGroup::_pressed(Object *p_button) {
BaseButton *bb=E->get();
bb->set_pressed( b==bb );
+ if (b==bb){
+ emit_signal("button_selected", b);
+ }
}
}
@@ -153,6 +156,7 @@ void ButtonGroup::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_pressed"),&ButtonGroup::_pressed);
ObjectTypeDB::bind_method(_MD("set_pressed_button","button:BaseButton"),&ButtonGroup::_pressed);
+ ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::OBJECT,"button",PROPERTY_HINT_RESOURCE_TYPE,"BaseButton")));
}
ButtonGroup::ButtonGroup() : BoxContainer(true)
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index a5bee32a69..97f0db97c2 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1725,11 +1725,11 @@ Control *Control::find_next_valid_focus() const {
if (next_child==this) // no next control->
return (get_focus_mode()==FOCUS_ALL)?next_child:NULL;
-
- if (next_child->get_focus_mode()==FOCUS_ALL)
- return next_child;
-
- from = next_child;
+ if (next_child) {
+ if (next_child->get_focus_mode()==FOCUS_ALL)
+ return next_child;
+ from = next_child;
+ } else break;
}
return NULL;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 0de6add8cb..6366b5ee23 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -151,7 +151,7 @@ void GraphEdit::_update_scroll_offset() {
}
}
- connections_layer->set_pos(-Point2(h_scroll->get_val(),v_scroll->get_val())*zoom);
+ connections_layer->set_pos(-Point2(h_scroll->get_val(),v_scroll->get_val()));
set_block_minimum_size_adjust(false);
awaiting_scroll_offset_update=false;
@@ -254,6 +254,7 @@ void GraphEdit::add_child_notify(Node *p_child) {
gn->set_scale(Vector2(zoom,zoom));
gn->connect("offset_changed",this,"_graph_node_moved",varray(gn));
gn->connect("raise_request",this,"_graph_node_raised",varray(gn));
+ gn->connect("item_rect_changed",connections_layer,"update");
_graph_node_moved(gn);
gn->set_stop_mouse(false);
}
@@ -650,8 +651,8 @@ void GraphEdit::_draw_cos_line(CanvasItem* p_where,const Vector2& p_from, const
cp_offset=MAX(MIN(cp_len-diff,cp_neg_len),-diff*0.5);
}
- Vector2 c1 = Vector2(cp_offset,0);
- Vector2 c2 = Vector2(-cp_offset,0);
+ Vector2 c1 = Vector2(cp_offset*zoom,0);
+ Vector2 c2 = Vector2(-cp_offset*zoom,0);
int lines=0;
_bake_segment2d(p_where,0,1,p_from,c1,p_to,c2,0,3,9,8,p_color,p_to_color,lines);
@@ -726,9 +727,9 @@ void GraphEdit::_connections_layer_draw() {
continue;
}
- Vector2 frompos=gfrom->get_connection_output_pos(E->get().from_port)+gfrom->get_offset();
+ Vector2 frompos=gfrom->get_connection_output_pos(E->get().from_port)+gfrom->get_offset()*zoom;
Color color = gfrom->get_connection_output_color(E->get().from_port);
- Vector2 topos=gto->get_connection_input_pos(E->get().to_port)+gto->get_offset();
+ Vector2 topos=gto->get_connection_input_pos(E->get().to_port)+gto->get_offset()*zoom;
Color tocolor = gto->get_connection_input_color(E->get().to_port);
_draw_cos_line(connections_layer,frompos,topos,color,tocolor);
@@ -912,18 +913,20 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
if (b.button_index==BUTTON_LEFT && b.pressed) {
GraphNode *gn = NULL;
+ GraphNode *gn_selected = NULL;
for(int i=get_child_count()-1;i>=0;i--) {
- gn=get_child(i)->cast_to<GraphNode>();
+ gn_selected=get_child(i)->cast_to<GraphNode>();
- if (gn) {
+ if (gn_selected) {
- if (gn->is_resizing())
+ if (gn_selected->is_resizing())
continue;
- Rect2 r = gn->get_rect();
+ Rect2 r = gn_selected->get_rect();
r.size*=zoom;
if (r.has_point(get_local_mouse_pos()))
+ gn = gn_selected;
break;
}
}
@@ -1050,6 +1053,7 @@ void GraphEdit::set_zoom(float p_zoom) {
top_layer->update();
_update_scroll();
+ connections_layer->update();
if (is_visible()) {
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index da298a795a..eec973ebef 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -745,6 +745,9 @@ void GraphNode::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_resizeable","resizeable"),&GraphNode::set_resizeable);
ObjectTypeDB::bind_method(_MD("is_resizeable"),&GraphNode::is_resizeable);
+ ObjectTypeDB::bind_method(_MD("set_selected","selected"),&GraphNode::set_selected);
+ ObjectTypeDB::bind_method(_MD("is_selected"),&GraphNode::is_selected);
+
ObjectTypeDB::bind_method(_MD("get_connection_output_count"),&GraphNode::get_connection_output_count);
ObjectTypeDB::bind_method(_MD("get_connection_input_count"),&GraphNode::get_connection_input_count);
@@ -766,6 +769,7 @@ void GraphNode::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::STRING,"title"),_SCS("set_title"),_SCS("get_title"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_close"),_SCS("set_show_close_button"),_SCS("is_close_button_visible"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"resizeable"),_SCS("set_resizeable"),_SCS("is_resizeable"));
ADD_SIGNAL(MethodInfo("offset_changed"));
ADD_SIGNAL(MethodInfo("dragged",PropertyInfo(Variant::VECTOR2,"from"),PropertyInfo(Variant::VECTOR2,"to")));
@@ -788,4 +792,5 @@ GraphNode::GraphNode() {
comment=false;
resizeable=false;
resizing=false;
+ selected=false;
}
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index b3f18bf8fa..2fbb093e8e 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -701,6 +701,13 @@ void PopupMenu::set_item_submenu(int p_idx, const String& p_submenu) {
update();
}
+void PopupMenu::toggle_item_checked(int p_idx) {
+
+ ERR_FAIL_INDEX(p_idx,items.size());
+ items[p_idx].checked = !items[p_idx].checked;
+ update();
+}
+
String PopupMenu::get_item_text(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,items.size(),"");
@@ -1061,33 +1068,40 @@ void PopupMenu::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_icon_check_shortcut","texture","shortcut:ShortCut","id"),&PopupMenu::add_icon_check_shortcut,DEFVAL(-1));
ObjectTypeDB::bind_method(_MD("add_check_shortcut","shortcut:ShortCut","id"),&PopupMenu::add_check_shortcut,DEFVAL(-1));
-
ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&PopupMenu::set_item_text);
ObjectTypeDB::bind_method(_MD("set_item_icon","idx","icon"),&PopupMenu::set_item_icon);
+ ObjectTypeDB::bind_method(_MD("set_item_checked","idx","checked"),&PopupMenu::set_item_checked);
+ ObjectTypeDB::bind_method(_MD("set_item_ID","idx","id"),&PopupMenu::set_item_ID);
ObjectTypeDB::bind_method(_MD("set_item_accelerator","idx","accel"),&PopupMenu::set_item_accelerator);
ObjectTypeDB::bind_method(_MD("set_item_metadata","idx","metadata"),&PopupMenu::set_item_metadata);
- ObjectTypeDB::bind_method(_MD("set_item_checked","idx","checked"),&PopupMenu::set_item_checked);
ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&PopupMenu::set_item_disabled);
- ObjectTypeDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut"),&PopupMenu::set_item_shortcut);
ObjectTypeDB::bind_method(_MD("set_item_submenu","idx","submenu"),&PopupMenu::set_item_submenu);
ObjectTypeDB::bind_method(_MD("set_item_as_separator","idx","enable"),&PopupMenu::set_item_as_separator);
ObjectTypeDB::bind_method(_MD("set_item_as_checkable","idx","enable"),&PopupMenu::set_item_as_checkable);
- ObjectTypeDB::bind_method(_MD("set_item_ID","idx","id"),&PopupMenu::set_item_ID);
+ ObjectTypeDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&PopupMenu::set_item_tooltip);
+ ObjectTypeDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut"),&PopupMenu::set_item_shortcut);
+
+ ObjectTypeDB::bind_method(_MD("toggle_item_checked","idx"), &PopupMenu::toggle_item_checked);
+
ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&PopupMenu::get_item_text);
ObjectTypeDB::bind_method(_MD("get_item_icon","idx"),&PopupMenu::get_item_icon);
- ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&PopupMenu::get_item_metadata);
+ ObjectTypeDB::bind_method(_MD("is_item_checked","idx"),&PopupMenu::is_item_checked);
+ ObjectTypeDB::bind_method(_MD("get_item_ID","idx"),&PopupMenu::get_item_ID);
+ ObjectTypeDB::bind_method(_MD("get_item_index","id"),&PopupMenu::get_item_index);
ObjectTypeDB::bind_method(_MD("get_item_accelerator","idx"),&PopupMenu::get_item_accelerator);
- ObjectTypeDB::bind_method(_MD("get_item_shortcut:ShortCut","idx"),&PopupMenu::get_item_shortcut);
+ ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&PopupMenu::get_item_metadata);
+ ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&PopupMenu::is_item_disabled);
ObjectTypeDB::bind_method(_MD("get_item_submenu","idx"),&PopupMenu::get_item_submenu);
ObjectTypeDB::bind_method(_MD("is_item_separator","idx"),&PopupMenu::is_item_separator);
ObjectTypeDB::bind_method(_MD("is_item_checkable","idx"),&PopupMenu::is_item_checkable);
- ObjectTypeDB::bind_method(_MD("is_item_checked","idx"),&PopupMenu::is_item_checked);
- ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&PopupMenu::is_item_disabled);
- ObjectTypeDB::bind_method(_MD("get_item_ID","idx"),&PopupMenu::get_item_ID);
- ObjectTypeDB::bind_method(_MD("get_item_index","id"),&PopupMenu::get_item_index);
+ ObjectTypeDB::bind_method(_MD("get_item_tooltip","idx"),&PopupMenu::get_item_tooltip);
+ ObjectTypeDB::bind_method(_MD("get_item_shortcut:ShortCut","idx"),&PopupMenu::get_item_shortcut);
+
ObjectTypeDB::bind_method(_MD("get_item_count"),&PopupMenu::get_item_count);
- ObjectTypeDB::bind_method(_MD("add_separator"),&PopupMenu::add_separator);
+
ObjectTypeDB::bind_method(_MD("remove_item","idx"),&PopupMenu::remove_item);
+
+ ObjectTypeDB::bind_method(_MD("add_separator"),&PopupMenu::add_separator);
ObjectTypeDB::bind_method(_MD("clear"),&PopupMenu::clear);
ObjectTypeDB::bind_method(_MD("_set_items"),&PopupMenu::_set_items);
@@ -1125,5 +1139,3 @@ PopupMenu::PopupMenu() {
PopupMenu::~PopupMenu() {
}
-
-
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index f35e91d4e4..b3e8cd2713 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -116,6 +116,8 @@ public:
void set_item_tooltip(int p_idx,const String& p_tooltip);
void set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut);
+ void toggle_item_checked(int p_idx);
+
String get_item_text(int p_idx) const;
Ref<Texture> get_item_icon(int p_idx) const;
bool is_item_checked(int p_idx) const;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 14508e07a8..f1a2823e8f 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -482,6 +482,14 @@ void TextEdit::_notification(int p_what) {
Color color = cache.font_color;
int in_region=-1;
+ if (line_length_guideline) {
+ int x=xmargin_beg+cache.font->get_char_size('0').width*line_length_guideline_col-cursor.x_ofs;
+ if (x>xmargin_beg && x<xmargin_end) {
+ Color guideline_color(color.r,color.g,color.b,color.a*0.25f);
+ VisualServer::get_singleton()->canvas_item_add_line(ci,Point2(x,0),Point2(x,cache.size.height),guideline_color);
+ }
+ }
+
if (syntax_coloring) {
if (custom_bg_color.a>0.01) {
@@ -685,6 +693,8 @@ void TextEdit::_notification(int p_what) {
// get the highlighted words
String highlighted_text = get_selection_text();
+ String line_num_padding = line_numbers_zero_padded ? "0" : " ";
+
for (int i=0;i<visible_rows;i++) {
int line=i+cursor.line_ofs;
@@ -750,7 +760,7 @@ void TextEdit::_notification(int p_what) {
if (cache.line_number_w) {
String fc = String::num(line+1);
while (fc.length() < line_number_char_count) {
- fc="0"+fc;
+ fc=line_num_padding+fc;
}
cache.font->draw(ci,Point2(cache.style_normal->get_margin(MARGIN_LEFT)+cache.breakpoint_gutter_width,ofs_y+cache.font->get_ascent()),fc,cache.line_number_color);
@@ -1245,15 +1255,19 @@ void TextEdit::_notification(int p_what) {
}
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(get_text(),get_global_rect());
+ if (raised_from_completion) {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
+ }
} break;
case NOTIFICATION_FOCUS_EXIT: {
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
-
+ if (raised_from_completion) {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 0);
+ }
} break;
-
}
}
@@ -4197,12 +4211,17 @@ void TextEdit::_confirm_completion() {
void TextEdit::_cancel_code_hint() {
+
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 0);
+ raised_from_completion = false;
completion_hint="";
update();
}
void TextEdit::_cancel_completion() {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 0);
+ raised_from_completion = false;
if (!completion_active)
return;
@@ -4382,6 +4401,8 @@ void TextEdit::query_code_comple() {
void TextEdit::set_code_hint(const String& p_hint) {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
+ raised_from_completion = true;
completion_hint=p_hint;
completion_hint_offset=-0xFFFF;
update();
@@ -4389,7 +4410,8 @@ void TextEdit::set_code_hint(const String& p_hint) {
void TextEdit::code_complete(const Vector<String> &p_strings) {
-
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
+ raised_from_completion = true;
completion_strings=p_strings;
completion_active=true;
completion_current="";
@@ -4500,10 +4522,26 @@ void TextEdit::set_show_line_numbers(bool p_show) {
update();
}
+void TextEdit::set_line_numbers_zero_padded(bool p_zero_padded) {
+
+ line_numbers_zero_padded=p_zero_padded;
+ update();
+}
+
bool TextEdit::is_show_line_numbers_enabled() const {
return line_numbers;
}
+void TextEdit::set_show_line_length_guideline(bool p_show) {
+ line_length_guideline=p_show;
+ update();
+}
+
+void TextEdit::set_line_length_guideline_column(int p_column) {
+ line_length_guideline_col=p_column;
+ update();
+}
+
void TextEdit::set_draw_breakpoint_gutter(bool p_draw) {
draw_breakpoint_gutter = p_draw;
update();
@@ -4781,6 +4819,9 @@ TextEdit::TextEdit() {
completion_line_ofs=0;
tooltip_obj=NULL;
line_numbers=false;
+ line_numbers_zero_padded=false;
+ line_length_guideline=false;
+ line_length_guideline_col=80;
draw_breakpoint_gutter=false;
next_operation_is_complex=false;
scroll_past_end_of_file_enabled=false;
@@ -4792,6 +4833,8 @@ TextEdit::TextEdit() {
window_has_focus=true;
select_identifiers_enabled=false;
+ raised_from_completion = false;
+
context_menu_enabled=true;
menu = memnew( PopupMenu );
add_child(menu);
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 37477e3b7e..7820fefdd2 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -232,6 +232,9 @@ class TextEdit : public Control {
bool text_changed_dirty;
bool undo_enabled;
bool line_numbers;
+ bool line_numbers_zero_padded;
+ bool line_length_guideline;
+ int line_length_guideline_col;
bool draw_breakpoint_gutter;
int breakpoint_gutter_width;
@@ -244,6 +247,8 @@ class TextEdit : public Control {
bool insert_mode;
bool select_identifiers_enabled;
+ bool raised_from_completion;
+
String hilighted_word;
uint64_t last_dblclk;
@@ -485,6 +490,11 @@ public:
void set_show_line_numbers(bool p_show);
bool is_show_line_numbers_enabled() const;
+ void set_line_numbers_zero_padded(bool p_zero_padded);
+
+ void set_show_line_length_guideline(bool p_show);
+ void set_line_length_guideline_column(int p_column);
+
void set_draw_breakpoint_gutter(bool p_draw);
bool is_drawing_breakpoint_gutter() const;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 5a614fb1b2..ca9c666c01 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1704,16 +1704,11 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
} break;
case TreeItem::CELL_MODE_CHECK: {
- Ref<Texture> checked = cache.checked;
bring_up_editor=false; //checkboxes are not edited with editor
- if (x>=0 && x<= checked->get_width()+cache.hseparation ) {
-
-
- p_item->set_checked(col,!c.checked);
- item_edited(col,p_item);
- click_handled=true;
- //p_item->edited_signal.call(col);
- }
+ p_item->set_checked(col, !c.checked);
+ item_edited(col, p_item);
+ click_handled = true;
+ //p_item->edited_signal.call(col);
} break;
case TreeItem::CELL_MODE_RANGE:
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 1892240426..6e33dcb4c9 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -1249,51 +1249,12 @@ void Node::set_human_readable_collision_renaming(bool p_enabled) {
}
+#ifdef TOOLS_ENABLED
+String Node::validate_child_name(Node* p_child) {
-String Node::validate_child_name(const String& p_name) const {
-
- //this approach to autoset node names is human readable but very slow
- //it's turned on while running in the editor
-
- String basename = p_name;
-
- if (basename==String()) {
-
- return String();
- }
-
- int val=1;
-
- for(;;) {
-
- String attempted = val > 1 ? (basename + " " +itos(val) ) : basename;
-
- bool found=false;
-
- for (int i=0;i<data.children.size();i++) {
-
- //if (data.children[i]==p_child)
- // continue;
- if (data.children[i]->get_name() == attempted) {
- found=true;
- break;
- }
-
- }
-
- if (found) {
-
- val++;
- continue;
- }
-
- return attempted;
- break;
- }
-
- return basename;
-
+ return _generate_serial_child_name(p_child);
}
+#endif
void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
@@ -1304,41 +1265,8 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
//this approach to autoset node names is human readable but very slow
//it's turned on while running in the editor
- String basename = p_child->data.name;
-
- if (basename=="") {
-
- basename = p_child->get_type();
- }
-
- int val=1;
-
- for(;;) {
-
- String attempted = val > 1 ? (basename + " " +itos(val) ) : basename;
-
- bool found=false;
-
- for (int i=0;i<data.children.size();i++) {
-
- if (data.children[i]==p_child)
- continue;
- if (data.children[i]->get_name() == attempted) {
- found=true;
- break;
- }
-
- }
-
- if (found) {
-
- val++;
- continue;
- }
+ p_child->data.name=_generate_serial_child_name(p_child);
- p_child->data.name=attempted;
- break;
- }
} else {
//this approach to autoset node names is fast but not as readable
@@ -1373,6 +1301,67 @@ void Node::_validate_child_name(Node *p_child, bool p_force_human_readable) {
}
}
+String Node::_generate_serial_child_name(Node *p_child) {
+
+ String name = p_child->data.name;
+
+ if (name=="") {
+
+ name = p_child->get_type();
+ }
+
+ // Extract trailing number
+ String nums;
+ for(int i=name.length()-1;i>=0;i--) {
+ CharType n=name[i];
+ if (n>='0' && n<='9') {
+ nums=String::chr(name[i])+nums;
+ } else {
+ break;
+ }
+ }
+
+ String nnsep=_get_name_num_separator();
+ int num=0;
+ bool explicit_zero=false;
+ if (nums.length()>0 && name.substr(name.length()-nnsep.length()-nums.length(),nnsep.length()) == nnsep) {
+ // Base name + Separator + Number
+ num=nums.to_int();
+ name=name.substr(0,name.length()-nnsep.length()-nums.length()); // Keep base name
+ if (num==0) {
+ explicit_zero=true;
+ }
+ }
+
+ for(;;) {
+ String attempt = (name + (num > 0 || explicit_zero ? nnsep + itos(num) : "")).strip_edges();
+ bool found=false;
+ for(int i=0;i<data.children.size();i++) {
+ if (data.children[i]==p_child)
+ continue;
+ if (data.children[i]->data.name==attempt) {
+ found=true;
+ break;
+ }
+ }
+ if (!found) {
+ return attempt;
+ } else {
+ if (num==0) {
+ if (explicit_zero) {
+ // Name ended in separator + 0; user expects to get to separator + 1
+ num=1;
+ } else {
+ // Name was undecorated so skip to 2 for a more natural result
+ num=2;
+ }
+ } else {
+ num++;
+ }
+ }
+ }
+}
+
void Node::_add_child_nocheck(Node* p_child,const StringName& p_name) {
//add a child node quickly, without name validation
@@ -2811,6 +2800,10 @@ bool Node::is_displayed_folded() const {
void Node::_bind_methods() {
+ _GLOBAL_DEF("node/name_num_separator",0);
+ Globals::get_singleton()->set_custom_property_info("node/name_num_separator",PropertyInfo(Variant::INT,"node/name_num_separator",PROPERTY_HINT_ENUM, "None,Space,Underscore,Dash"));
+
+
ObjectTypeDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
ObjectTypeDB::bind_method(_MD("set_name","name"),&Node::set_name);
@@ -2979,6 +2972,17 @@ void Node::_bind_methods() {
}
+String Node::_get_name_num_separator() {
+ switch(Globals::get_singleton()->get("node/name_num_separator").operator int()) {
+ case 0: return "";
+ case 1: return " ";
+ case 2: return "_";
+ case 3: return "-";
+ }
+ return " ";
+}
+
+
Node::Node() {
data.pos=-1;
diff --git a/scene/main/node.h b/scene/main/node.h
index 3568da2ab0..f18dc81195 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -29,6 +29,7 @@
#ifndef NODE_H
#define NODE_H
+#include "globals.h"
#include "object.h"
#include "path_db.h"
#include "map.h"
@@ -150,7 +151,8 @@ private:
void _replace_connections_target(Node* p_new_target);
- void _validate_child_name(Node *p_name, bool p_force_human_readable=false);
+ void _validate_child_name(Node *p_child, bool p_force_human_readable=false);
+ String _generate_serial_child_name(Node *p_child);
void _propagate_reverse_notification(int p_notification);
void _propagate_deferred_notification(int p_notification, bool p_reverse);
@@ -193,6 +195,7 @@ protected:
void _propagate_replace_owner(Node *p_owner,Node* p_by_owner);
static void _bind_methods();
+ static String _get_name_num_separator();
friend class SceneState;
@@ -335,7 +338,9 @@ public:
static void print_stray_nodes();
- String validate_child_name(const String& p_name) const;
+#ifdef TOOLS_ENABLED
+ String validate_child_name(Node* p_child);
+#endif
void queue_delete();
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index b22d1fcdf4..0c243bd473 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1715,6 +1715,9 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g
}
Matrix32 matrix = p_xform * p_node->get_transform();
+ // matrix.basis_determinant() == 0.0f implies that node does not exist on scene
+ if(matrix.basis_determinant() == 0.0f)
+ return NULL;
if (!c || !c->clips_input() || c->has_point(matrix.affine_inverse().xform(p_global))) {
diff --git a/scene/resources/default_theme/button_pressed.png b/scene/resources/default_theme/button_pressed.png
index 4a807544ed..19a7e237aa 100644
--- a/scene/resources/default_theme/button_pressed.png
+++ b/scene/resources/default_theme/button_pressed.png
Binary files differ
diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp
index 0a88abf252..1aeea5fa43 100644
--- a/scene/resources/world.cpp
+++ b/scene/resources/world.cpp
@@ -332,6 +332,10 @@ World::World() {
sound_space = SpatialSoundServer::get_singleton()->space_create();
PhysicsServer::get_singleton()->space_set_active(space,true);
+ PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_GRAVITY,GLOBAL_DEF("physics/default_gravity",9.8));
+ PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_GRAVITY_VECTOR,GLOBAL_DEF("physics/default_gravity_vector",Vector3(0,-1,0)));
+ PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_LINEAR_DAMP,GLOBAL_DEF("physics/default_linear_damp",0.1));
+ PhysicsServer::get_singleton()->area_set_param(space,PhysicsServer::AREA_PARAM_ANGULAR_DAMP,GLOBAL_DEF("physics/default_angular_damp",0.1));
#ifdef _3D_DISABLED
indexer = NULL;
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index 4c963da5b4..df3a374fc9 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -416,12 +416,6 @@ World2D::World2D() {
}
Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_LINEAR_DAMP,GLOBAL_DEF("physics_2d/default_linear_damp",0.1));
Physics2DServer::get_singleton()->area_set_param(space,Physics2DServer::AREA_PARAM_ANGULAR_DAMP,GLOBAL_DEF("physics_2d/default_angular_damp",1));
- Physics2DServer::get_singleton()->space_set_param(space,Physics2DServer::SPACE_PARAM_CONTACT_RECYCLE_RADIUS,1.0);
- Physics2DServer::get_singleton()->space_set_param(space,Physics2DServer::SPACE_PARAM_CONTACT_MAX_SEPARATION,1.5);
- Physics2DServer::get_singleton()->space_set_param(space,Physics2DServer::SPACE_PARAM_BODY_MAX_ALLOWED_PENETRATION,0.3);
- Physics2DServer::get_singleton()->space_set_param(space,Physics2DServer::SPACE_PARAM_BODY_LINEAR_VELOCITY_SLEEP_TRESHOLD,2);
- Physics2DServer::get_singleton()->space_set_param(space,Physics2DServer::SPACE_PARAM_CONSTRAINT_DEFAULT_BIAS,0.2);
-
indexer = memnew( SpatialIndexer2D );
}
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index a939d935c4..d52189bcd4 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -31,6 +31,7 @@
#include "resource.h"
#include "servers/physics_2d_server.h"
+#include "globals.h"
class SpatialIndexer2D;
class VisibilityNotifier2D;