diff options
Diffstat (limited to 'scene')
35 files changed, 483 insertions, 165 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 35b453d71d..316097fbcf 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -1193,6 +1193,14 @@ bool CanvasItem::is_local_transform_notification_enabled() const { return notify_local_transform; } +int CanvasItem::get_canvas_layer() const { + + if (canvas_layer) + return canvas_layer->get_layer(); + else + return 0; +} + CanvasItem::CanvasItem() : xform_change(this) { diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 5d10523261..05a2e725e9 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -268,6 +268,7 @@ public: void set_notify_local_transform(bool p_enable); bool is_local_transform_notification_enabled() const; + int get_canvas_layer() const; CanvasItem(); ~CanvasItem(); diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 9b0c24ffd6..3a45b0c84e 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -32,14 +32,14 @@ void CollisionObject2D::_update_shapes_from_children() { - shapes.resize(0); + shapes.clear(); for(int i=0;i<get_child_count();i++) { Node* n = get_child(i); n->call("_add_to_collision_object",this); } -// _update_shapes(); + _update_shapes(); } void CollisionObject2D::_notification(int p_what) { diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 179d1f451a..5c298e96f6 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -694,6 +694,10 @@ void TileMap::set_cell(int p_x,int p_y,int p_tile,bool p_flip_x,bool p_flip_y,bo } +int TileMap::get_cellv(const Vector2& p_pos) const { + return get_cell(p_pos.x,p_pos.y); +} + int TileMap::get_cell(int p_x,int p_y) const { PosKey pk(p_x,p_y); @@ -1198,6 +1202,7 @@ void TileMap::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false)); ObjectTypeDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell); + ObjectTypeDB::bind_method(_MD("get_cellv","pos"),&TileMap::get_cellv); ObjectTypeDB::bind_method(_MD("is_cell_x_flipped","x","y"),&TileMap::is_cell_x_flipped); ObjectTypeDB::bind_method(_MD("is_cell_y_flipped","x","y"),&TileMap::is_cell_y_flipped); diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 14cb52b736..cec5ac0a1b 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -211,6 +211,7 @@ public: bool is_cell_transposed(int p_x,int p_y) const; void set_cellv(const Vector2& p_pos,int p_tile,bool p_flip_x=false,bool p_flip_y=false,bool p_transpose=false); + int get_cellv(const Vector2& p_pos) const; Rect2 get_item_rect() const; diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index 3e78fef147..01163e40e8 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -213,8 +213,7 @@ void Camera::_notification(int p_what) { case NOTIFICATION_ENTER_WORLD: { - bool first_camera = get_viewport()->cameras.size()==0; - get_viewport()->cameras.insert(this); + bool first_camera = get_viewport()->_camera_add(this); if (!get_tree()->is_node_being_edited(this) && (current || first_camera)) make_current(); @@ -236,7 +235,7 @@ void Camera::_notification(int p_what) { } } - get_viewport()->cameras.erase(this); + get_viewport()->_camera_remove(this); } break; @@ -304,7 +303,7 @@ void Camera::make_current() { if (!is_inside_tree()) return; - get_viewport()->_set_camera(this); + get_viewport()->_camera_set(this); //get_scene()->call_group(SceneMainLoop::GROUP_CALL_REALTIME,camera_group,"_camera_make_current",this); } @@ -319,20 +318,8 @@ void Camera::clear_current() { return; if (get_viewport()->get_camera()==this) { - get_viewport()->_set_camera(NULL); - //a group is used beause this needs to be in order to be deterministic - - for (Set<Camera*>::Element *E=get_viewport()->cameras.front();E;E=E->next()) { - - if (this==E->get()) - continue; - if (!E->get()->is_inside_tree()) - continue; - if (get_viewport()->get_camera()!=NULL) - return; - - E->get()->make_current(); - } + get_viewport()->_camera_set(NULL); + get_viewport()->_camera_make_next_current(this); } } diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp index b50878da07..373c356a45 100644 --- a/scene/3d/collision_object.cpp +++ b/scene/3d/collision_object.cpp @@ -31,14 +31,14 @@ #include "scene/scene_string_names.h" void CollisionObject::_update_shapes_from_children() { - shapes.resize(0); + shapes.clear(); for(int i=0;i<get_child_count();i++) { Node* n = get_child(i); n->call("_add_to_collision_object",this); } -// _update_shapes(); + _update_shapes(); } void CollisionObject::_notification(int p_what) { diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index f6d058c2fd..344fc5ecde 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -147,14 +147,21 @@ void AnimationPlayer::_get_property_list( List<PropertyInfo> *p_list) const { List<String> names; + List<PropertyInfo> anim_names; + for( Map<StringName, AnimationData>::Element *E=animation_set.front();E;E=E->next()) { - p_list->push_back( PropertyInfo( Variant::OBJECT, "anims/"+String(E->key()), PROPERTY_HINT_RESOURCE_TYPE, "Animation",PROPERTY_USAGE_NOEDITOR) ); + anim_names.push_back( PropertyInfo( Variant::OBJECT, "anims/"+String(E->key()), PROPERTY_HINT_RESOURCE_TYPE, "Animation",PROPERTY_USAGE_NOEDITOR) ); if (E->get().next!=StringName()) - p_list->push_back( PropertyInfo( Variant::STRING, "next/"+String(E->key()), PROPERTY_HINT_NONE, "",PROPERTY_USAGE_NOEDITOR) ); + anim_names.push_back( PropertyInfo( Variant::STRING, "next/"+String(E->key()), PROPERTY_HINT_NONE, "",PROPERTY_USAGE_NOEDITOR) ); names.push_back(E->key()); } + anim_names.sort(); + + for( List<PropertyInfo>::Element *E=anim_names.front();E;E=E->next()) { + p_list->push_back(E->get()); + } { names.sort(); diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp index f7cfc31b03..fd18803394 100644 --- a/scene/audio/stream_player.cpp +++ b/scene/audio/stream_player.cpp @@ -100,11 +100,20 @@ void StreamPlayer::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { //set_idle_process(false); //don't annoy - if (stream.is_valid() && autoplay && !get_tree()->is_editor_hint()) - play(); + if (stream.is_valid() && !get_tree()->is_editor_hint()) { + if (resume_pos>=0) { + play(resume_pos); + resume_pos=-1; + } else if (autoplay) { + play(); + } + } } break; case NOTIFICATION_EXIT_TREE: { + if (is_playing()) { + resume_pos=get_pos(); + } stop(); //wathever it may be doing, stop } break; } @@ -397,6 +406,7 @@ StreamPlayer::StreamPlayer() { buffering_ms=500; loop_point=0; stop_request=false; + resume_pos=-1; } diff --git a/scene/audio/stream_player.h b/scene/audio/stream_player.h index 30840137e2..475139c2a4 100644 --- a/scene/audio/stream_player.h +++ b/scene/audio/stream_player.h @@ -67,6 +67,7 @@ class StreamPlayer : public Node { float loop_point; int buffering_ms; volatile bool stop_request; + float resume_pos; AudioRBResampler resampler; diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 8685ec1c99..f1b910d23f 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -34,7 +34,7 @@ #include "os/input.h" #include "os/keyboard.h" -void update_material(Ref<CanvasItemMaterial>mat,const Color& p_color) { +void update_material(Ref<CanvasItemMaterial>mat,const Color& p_color,float h,float s,float v) { if (!mat.is_valid()) return; Ref<Shader> sdr = mat->get_shader(); @@ -44,9 +44,9 @@ void update_material(Ref<CanvasItemMaterial>mat,const Color& p_color) { mat->set_shader_param("R",p_color.r); mat->set_shader_param("G",p_color.g); mat->set_shader_param("B",p_color.b); - mat->set_shader_param("H",p_color.get_h()); - mat->set_shader_param("S",p_color.get_s()); - mat->set_shader_param("V",p_color.get_v()); + mat->set_shader_param("H",h); + mat->set_shader_param("S",s); + mat->set_shader_param("V",v); mat->set_shader_param("A",p_color.a); } @@ -57,14 +57,25 @@ void ColorPicker::_notification(int p_what) { case NOTIFICATION_THEME_CHANGED: { uv_material->set_shader(get_shader("uv_editor")); w_material->set_shader(get_shader("w_editor")); - update_material(uv_material,color); - update_material(w_material,color); + update_material(uv_material,color,h,s,v); + update_material(w_material,color,h,s,v); _update_controls(); } break; case NOTIFICATION_ENTER_TREE: { btn_pick->set_icon(get_icon("screen_picker", "ColorPicker")); + update_material(uv_material, color,h,s,v); + update_material(w_material, color,h,s,v); + + uv_edit->get_child(0)->cast_to<Control>()->update(); + w_edit->get_child(0)->cast_to<Control>()->update(); + _update_color(); } + + case NOTIFICATION_VISIBILITY_CHANGED: { + c_text->call_deferred("grab_focus"); + c_text->call_deferred("select"); + } break; } } @@ -85,11 +96,19 @@ void ColorPicker::_update_controls() { void ColorPicker::set_color(const Color& p_color) { color=p_color; - h=color.get_h(); - s=color.get_s(); - v=color.get_v(); - update_material(uv_material, color); - update_material(w_material, color); + if (color != last_hsv) { + h=color.get_h(); + s=color.get_s(); + v=color.get_v(); + last_hsv = color; + } + + if (!is_inside_tree()) + return; + + update_material(uv_material, color,h,s,v); + update_material(w_material, color,h,s,v); + uv_edit->get_child(0)->cast_to<Control>()->update(); w_edit->get_child(0)->cast_to<Control>()->update(); _update_color(); @@ -100,6 +119,10 @@ void ColorPicker::set_edit_alpha(bool p_show) { edit_alpha=p_show; _update_controls(); + + if (!is_inside_tree()) + return; + _update_color(); sample->update(); } @@ -119,12 +142,9 @@ void ColorPicker::_value_changed(double) { } color.components[3] = scroll[3]->get_val()/255.0; - update_material(uv_material,color); - update_material(w_material,color); - - html->set_text(color.to_html(edit_alpha && color.a<1)); + set_color(color); - sample->update(); + c_text->set_text(color.to_html(edit_alpha && color.a<1)); emit_signal("color_changed",color); @@ -136,6 +156,10 @@ void ColorPicker::_html_entered(const String& p_html) { return; color = Color::html(p_html); + + if (!is_inside_tree()) + return; + _update_color(); emit_signal("color_changed",color); } @@ -153,7 +177,16 @@ void ColorPicker::_update_color() { scroll[i]->set_val(color.components[i]*255); } - html->set_text(color.to_html(edit_alpha && color.a<1)); + 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)); + } sample->update(); updating=false; @@ -173,6 +206,21 @@ void ColorPicker::_update_presets() preset->set_texture(t); } +void ColorPicker::_text_type_toggled() +{ + if (!get_tree()->is_editor_hint()) + return; + text_is_constructor = !text_is_constructor; + if (text_is_constructor) { + text_type->set_text(""); + text_type->set_icon(get_icon("Script", "EditorIcons")); + } else { + text_type->set_text("#"); + text_type->set_icon(NULL); + } + _update_color(); +} + Color ColorPicker::get_color() const { return color; @@ -199,6 +247,9 @@ void ColorPicker::set_raw_mode(bool p_enabled) { if (btn_mode->is_pressed()!=p_enabled) btn_mode->set_pressed(p_enabled); + if (!is_inside_tree()) + return; + _update_controls(); _update_color(); } @@ -217,15 +268,17 @@ void ColorPicker::_hsv_draw(int p_wich,Control* c) if (!c) return; if (p_wich==0) { - int x=c->get_size().x*color.get_s(); - int y=c->get_size().y-c->get_size().y*color.get_v(); - c->draw_line(Point2(x,0),Point2(x,c->get_size().y),color.inverted()); - c->draw_line(Point2(0,y),Point2(c->get_size().x,y),color.inverted()); + int x=c->get_size().x*s; + int y=c->get_size().y-c->get_size().y*v; + 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(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*color.get_h(); + int y=c->get_size().y-c->get_size().y*h; Color col=Color(); - col.set_hsv(color.get_h(),1,1); + col.set_hsv(h,1,1); c->draw_line(Point2(0,y),Point2(c->get_size().x,y),col.inverted()); } } @@ -240,6 +293,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) { s=x/256; v=1.0-y/256.0; color.set_hsv(h,s,v,color.a); + last_hsv = color; set_color(color); _update_color(); emit_signal("color_changed", color); @@ -255,6 +309,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) { s=x/256; v=1.0-y/256.0; color.set_hsv(h,s,v,color.a); + last_hsv = color; set_color(color); _update_color(); emit_signal("color_changed", color); @@ -272,6 +327,7 @@ void ColorPicker::_w_input(const InputEvent &ev) { changing_color = false; } color.set_hsv(h,s,v,color.a); + last_hsv = color; set_color(color); _update_color(); emit_signal("color_changed", color); @@ -282,6 +338,7 @@ void ColorPicker::_w_input(const InputEvent &ev) { float y = CLAMP((float)bev.y,0,256); h=1.0-y/256.0; color.set_hsv(h,s,v,color.a); + last_hsv = color; set_color(color); _update_color(); emit_signal("color_changed", color); @@ -364,6 +421,7 @@ void ColorPicker::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_preset"), &ColorPicker::add_preset); ObjectTypeDB::bind_method(_MD("_value_changed"),&ColorPicker::_value_changed); ObjectTypeDB::bind_method(_MD("_html_entered"),&ColorPicker::_html_entered); + ObjectTypeDB::bind_method(_MD("_text_type_toggled"),&ColorPicker::_text_type_toggled); ObjectTypeDB::bind_method(_MD("_add_preset_pressed"), &ColorPicker::_add_preset_pressed); ObjectTypeDB::bind_method(_MD("_screen_pick_pressed"), &ColorPicker::_screen_pick_pressed); ObjectTypeDB::bind_method(_MD("_sample_draw"),&ColorPicker::_sample_draw); @@ -381,6 +439,7 @@ ColorPicker::ColorPicker() : updating=true; edit_alpha=true; + text_is_constructor = false; raw_mode_enabled=false; changing_color=false; screen=NULL; @@ -490,18 +549,20 @@ ColorPicker::ColorPicker() : btn_mode->connect("toggled", this, "set_raw_mode"); hhb->add_child(btn_mode); vbr->add_child(hhb); - html_num = memnew( Label ); - hhb->add_child(html_num); + text_type = memnew( Button ); + text_type->set_flat(true); + text_type->connect("pressed", this, "_text_type_toggled"); + hhb->add_child(text_type); - html = memnew( LineEdit ); - hhb->add_child(html); - html->connect("text_entered",this,"_html_entered"); - html_num->set_text("#"); - html->set_h_size_flags(SIZE_EXPAND_FILL); + c_text = memnew( LineEdit ); + hhb->add_child(c_text); + c_text->connect("text_entered",this,"_html_entered"); + text_type->set_text("#"); + c_text->set_h_size_flags(SIZE_EXPAND_FILL); _update_controls(); - _update_color(); + //_update_color(); updating=false; uv_material.instance(); @@ -564,6 +625,8 @@ void ColorPickerButton::pressed() { popup->set_pos(get_global_pos()-Size2(0,ms.height)); popup->set_size(ms); popup->popup(); + + } void ColorPickerButton::_notification(int p_what) { diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index c6c7fe537d..4559bc7391 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -62,22 +62,25 @@ private: HSlider *scroll[4]; SpinBox *values[4]; Label *labels[4]; - Label *html_num; - LineEdit *html; + Button *text_type; + LineEdit *c_text; bool edit_alpha; Size2i ms; + bool text_is_constructor; Color color; bool raw_mode_enabled; bool updating; bool changing_color; float h,s,v; + Color last_hsv; void _html_entered(const String& p_html); void _value_changed(double); void _update_controls(); void _update_color(); void _update_presets(); + void _text_type_toggled(); void _sample_draw(); void _hsv_draw(int p_wich,Control *c); @@ -87,6 +90,7 @@ private: void _screen_input(const InputEvent& p_input); void _add_preset_pressed(); void _screen_pick_pressed(); + protected: void _notification(int); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index dce0a4ac0e..af3b37bec2 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -85,9 +85,14 @@ Size2 Control::edit_get_minimum_size() const { void Control::edit_set_rect(const Rect2& p_edit_rect) { - Rect2 new_rect=get_rect(); + Matrix32 postxf; + postxf.set_rotation_and_scale(data.rotation,data.scale); + Vector2 new_pos = postxf.xform(p_edit_rect.pos); + + Vector2 pos = get_pos()+new_pos; - new_rect.pos+=p_edit_rect.pos.snapped(Vector2(1,1)); + Rect2 new_rect=get_rect(); + new_rect.pos=pos.snapped(Vector2(1,1)); new_rect.size=p_edit_rect.size.snapped(Vector2(1,1)); set_pos(new_rect.pos); @@ -1597,7 +1602,9 @@ bool Control::has_focus() const { void Control::grab_focus() { - ERR_FAIL_COND(!is_inside_tree()); + if (!is_inside_tree()){ + ERR_FAIL_COND(!is_inside_tree()); + } if (data.focus_mode==FOCUS_NONE) return; @@ -2071,6 +2078,8 @@ Control *Control::get_root_parent_control() const { return const_cast<Control*>(root); } + + void Control::_bind_methods() { diff --git a/scene/gui/control.h b/scene/gui/control.h index a16d88a6df..74d40b7579 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -97,7 +97,12 @@ private: struct CComparator { - bool operator()(const Control* p_a, const Control* p_b) const { return p_b->is_greater_than(p_a); } + bool operator()(const Control* p_a, const Control* p_b) const { + if (p_a->get_canvas_layer()==p_b->get_canvas_layer()) + return p_b->is_greater_than(p_a); + else + return p_a->get_canvas_layer() < p_b->get_canvas_layer(); + } }; struct Data { diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 9472c589ca..c9c9dbd1d2 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -4,6 +4,12 @@ #include "scene/gui/box_container.h" +#define ZOOM_SCALE 1.2 + +#define MIN_ZOOM (((1/ZOOM_SCALE)/ZOOM_SCALE)/ZOOM_SCALE) +#define MAX_ZOOM (1*ZOOM_SCALE*ZOOM_SCALE*ZOOM_SCALE) + + bool GraphEditFilter::has_point(const Point2& p_point) const { return ge->_filter_input(p_point); @@ -85,9 +91,10 @@ void GraphEdit::_update_scroll_offset() { if (!gn) continue; - Point2 pos=gn->get_offset(); + Point2 pos=gn->get_offset()*zoom; pos-=Point2(h_scroll->get_val(),v_scroll->get_val()); gn->set_pos(pos); + gn->set_scale(Vector2(zoom,zoom)); } } @@ -106,8 +113,8 @@ void GraphEdit::_update_scroll() { continue; Rect2 r; - r.pos=gn->get_offset(); - r.size=gn->get_size(); + r.pos=gn->get_offset()*zoom; + r.size=gn->get_size()*zoom; screen = screen.merge(r); } @@ -193,10 +200,11 @@ void GraphEdit::_notification(int p_what) { h_scroll->set_anchor_and_margin(MARGIN_TOP,ANCHOR_END,hmin.height); h_scroll->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END,0); - zoom_icon->set_texture( get_icon("Zoom", "EditorIcons")); +// zoom_icon->set_texture( get_icon("Zoom", "EditorIcons")); } if (p_what==NOTIFICATION_DRAW) { + draw_style_box( get_stylebox("bg"),Rect2(Point2(),get_size()) ); VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true); } @@ -516,7 +524,7 @@ void GraphEdit::_input_event(const InputEvent& p_ev) { for(int i=get_child_count()-1;i>=0;i--) { GraphNode *gn=get_child(i)->cast_to<GraphNode>(); if (gn && gn->is_selected()) - gn->set_offset(gn->get_drag_from()+drag_accum); + gn->set_offset((gn->get_drag_from()*zoom+drag_accum)/zoom); } } @@ -650,6 +658,8 @@ void GraphEdit::_input_event(const InputEvent& p_ev) { } else { if (_filter_input(Vector2(b.x,b.y))) return; + if (Input::get_singleton()->is_key_pressed(KEY_SPACE)) + return; box_selecting = true; box_selecting_from = get_local_mouse_pos(); @@ -697,11 +707,13 @@ void GraphEdit::_input_event(const InputEvent& p_ev) { } if (b.button_index==BUTTON_WHEEL_UP && b.pressed) { - sl_zoom->set_val(zoom/0.9); + //too difficult to get right + //set_zoom(zoom*ZOOM_SCALE); } if (b.button_index==BUTTON_WHEEL_DOWN && b.pressed) { - sl_zoom->set_val(zoom*0.9); + //too difficult to get right + //set_zoom(zoom/ZOOM_SCALE); } } @@ -725,21 +737,29 @@ void GraphEdit::clear_connections() { void GraphEdit::set_zoom(float p_zoom) { - if (p_zoom<0.01) p_zoom=0.01; - if (p_zoom>4) p_zoom=4; + p_zoom=CLAMP(p_zoom,MIN_ZOOM,MAX_ZOOM); if (zoom == p_zoom) return; + zoom_minus->set_disabled(zoom==MIN_ZOOM); + zoom_plus->set_disabled(zoom==MAX_ZOOM); + + Vector2 sbofs = (Vector2( h_scroll->get_val(), v_scroll->get_val() ) + get_size()/2)/zoom; + float prev_zoom = zoom; zoom = p_zoom; - for (int i = 0; i < get_child_count(); i++) { - GraphNode *child = get_child(i)->cast_to<GraphNode>(); - if (!child) - continue; - Point2 ofs = child->get_offset() / prev_zoom * zoom; - child->set_scale(Vector2(zoom,zoom)); - child->set_offset(ofs); + top_layer->update(); + + _update_scroll(); + + if (is_visible()) { + + Vector2 ofs = sbofs*zoom - get_size()/2; + h_scroll->set_val( ofs.x ); + v_scroll->set_val( ofs.y ); } + + update(); } @@ -772,6 +792,26 @@ Array GraphEdit::_get_connection_list() const { } return arr; } + + + +void GraphEdit::_zoom_minus() { + + + set_zoom(zoom/ZOOM_SCALE); +} +void GraphEdit::_zoom_reset() { + + + set_zoom(1); +} + +void GraphEdit::_zoom_plus() { + + set_zoom(zoom*ZOOM_SCALE); +} + + void GraphEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("connect_node:Error","from","from_port","to","to_port"),&GraphEdit::connect_node); @@ -792,6 +832,9 @@ void GraphEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("_top_layer_input"),&GraphEdit::_top_layer_input); ObjectTypeDB::bind_method(_MD("_top_layer_draw"),&GraphEdit::_top_layer_draw); ObjectTypeDB::bind_method(_MD("_scroll_moved"),&GraphEdit::_scroll_moved); + ObjectTypeDB::bind_method(_MD("_zoom_minus"),&GraphEdit::_zoom_minus); + ObjectTypeDB::bind_method(_MD("_zoom_reset"),&GraphEdit::_zoom_reset); + ObjectTypeDB::bind_method(_MD("_zoom_plus"),&GraphEdit::_zoom_plus); ObjectTypeDB::bind_method(_MD("_input_event"),&GraphEdit::_input_event); @@ -837,18 +880,25 @@ GraphEdit::GraphEdit() { zoom = 1; - HBoxContainer* tools = memnew( HBoxContainer ); - add_child(tools); + HBoxContainer *zoom_hb = memnew( HBoxContainer ); + top_layer->add_child(zoom_hb); + zoom_hb->set_pos(Vector2(10,10)); + + + zoom_minus = memnew( ToolButton ); + zoom_hb->add_child(zoom_minus); + zoom_minus->connect("pressed",this,"_zoom_minus"); + zoom_minus->set_icon(get_icon("minus")); + + zoom_reset = memnew( ToolButton ); + zoom_hb->add_child(zoom_reset); + zoom_reset->connect("pressed",this,"_zoom_reset"); + zoom_reset->set_icon(get_icon("reset")); + + zoom_plus = memnew( ToolButton ); + zoom_hb->add_child(zoom_plus); + zoom_plus->connect("pressed",this,"_zoom_plus"); + zoom_plus->set_icon(get_icon("more")); - zoom_icon = memnew( TextureFrame ); - tools->add_child(zoom_icon); - sl_zoom = memnew( HSlider ); - sl_zoom->set_min(0.01); - sl_zoom->set_max(4); - sl_zoom->set_val(1); - sl_zoom->set_step(0.01); - sl_zoom->connect("value_changed", this, "set_zoom"); - tools->add_child(sl_zoom); - sl_zoom->set_custom_minimum_size(Size2(200,0)); } diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h index fe9c36cee4..a189c10046 100644 --- a/scene/gui/graph_edit.h +++ b/scene/gui/graph_edit.h @@ -4,7 +4,9 @@ #include "scene/gui/graph_node.h" #include "scene/gui/scroll_bar.h" #include "scene/gui/slider.h" +#include "scene/gui/tool_button.h" #include "texture_frame.h" + class GraphEdit; class GraphEditFilter : public Control { @@ -35,8 +37,15 @@ public: }; private: - TextureFrame* zoom_icon; - HSlider* sl_zoom; + + ToolButton *zoom_minus; + ToolButton *zoom_reset; + ToolButton *zoom_plus; + + void _zoom_minus(); + void _zoom_reset(); + void _zoom_plus(); + HScrollBar* h_scroll; VScrollBar* v_scroll; diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 762afb158a..eef1bf79c4 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -591,4 +591,5 @@ void GraphNode::_bind_methods() { GraphNode::GraphNode() { show_close=false; connpos_dirty=true; + set_stop_mouse(false); } diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index f035cb7722..2d2cabfc01 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -826,22 +826,25 @@ void ItemList::_notification(int p_what) { if (current_columns==1) { rcache.size.width = width-rcache.pos.x; } - if (items[i].custom_bg.a>0.001) { - Rect2 r=rcache; - r.pos+=base_ofs; - draw_rect(r,items[i].custom_bg); - } - if (items[i].selected) { - Rect2 r=rcache; - r.pos+=base_ofs; - r.pos.x-=sbsel->get_margin(MARGIN_LEFT); - r.size.x+=sbsel->get_margin(MARGIN_LEFT)+sbsel->get_margin(MARGIN_RIGHT); - r.pos.y-=sbsel->get_margin(MARGIN_TOP); - r.size.y+=sbsel->get_margin(MARGIN_TOP)+sbsel->get_margin(MARGIN_BOTTOM); + Rect2 r=rcache; + r.pos+=base_ofs; - draw_style_box(sbsel,r); + // Use stylebox to dimension potential bg color, even if not selected + r.pos.x-=sbsel->get_margin(MARGIN_LEFT); + r.size.x+=sbsel->get_margin(MARGIN_LEFT)+sbsel->get_margin(MARGIN_RIGHT); + r.pos.y-=sbsel->get_margin(MARGIN_TOP); + r.size.y+=sbsel->get_margin(MARGIN_TOP)+sbsel->get_margin(MARGIN_BOTTOM); + if (items[i].selected) { + draw_style_box(sbsel,r); + } + if (items[i].custom_bg.a>0.001) { + r.pos.x+=2; + r.size.x-=4; + r.pos.y+=2; + r.size.y-=4; + draw_rect(r,items[i].custom_bg); } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index fdced3f62f..2a62ab30fc 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -80,8 +80,8 @@ void LineEdit::_input_event(InputEvent p_event) { selection.creating=false; selection.doubleclick=false; - // notify to show soft keyboard - notification(NOTIFICATION_FOCUS_ENTER); + if (OS::get_singleton()->has_virtual_keyboard()) + OS::get_singleton()->show_virtual_keyboard(get_text(),get_global_rect()); } update(); @@ -230,8 +230,9 @@ void LineEdit::_input_event(InputEvent p_event) { case KEY_RETURN: { emit_signal( "text_entered",text ); - // notify to hide soft keyboard - notification(NOTIFICATION_FOCUS_EXIT); + if (OS::get_singleton()->has_virtual_keyboard()) + OS::get_singleton()->hide_virtual_keyboard(); + return; } break; diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index ecce71bdbd..c3e75842c3 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -633,7 +633,6 @@ int Tabs::get_tab_width(int p_idx) const { x+=tab_bg->get_minimum_size().width; if (tabs[p_idx].right_button.is_valid()) { - print_line("has right"); Ref<Texture> rb=tabs[p_idx].right_button; Size2 bms = rb->get_size();//+get_stylebox("button")->get_minimum_size(); bms.width+=get_constant("hseparation"); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 7f7c8c023c..bf012b7a03 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1197,6 +1197,12 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { if (mb.button_index==BUTTON_WHEEL_DOWN) { v_scroll->set_val( v_scroll->get_val() +3 ); } + if (mb.button_index==BUTTON_WHEEL_LEFT) { + h_scroll->set_val( h_scroll->get_val() -3 ); + } + if (mb.button_index==BUTTON_WHEEL_RIGHT) { + h_scroll->set_val( h_scroll->get_val() +3 ); + } if (mb.button_index==BUTTON_LEFT) { int row,col; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index e81c08dbea..05b1e8bcea 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -482,7 +482,7 @@ void TreeItem::deselect(int p_column) { _cell_deselected(p_column); } -void TreeItem::add_button(int p_column,const Ref<Texture>& p_button,int p_id) { +void TreeItem::add_button(int p_column, const Ref<Texture>& p_button, int p_id, bool p_disabled) { ERR_FAIL_INDEX( p_column, cells.size() ); @@ -492,6 +492,7 @@ void TreeItem::add_button(int p_column,const Ref<Texture>& p_button,int p_id) { if (p_id<0) p_id=cells[p_column].buttons.size(); button.id=p_id; + button.disabled=p_disabled; cells[p_column].buttons.push_back(button); _changed_notify(p_column); } @@ -533,6 +534,15 @@ int TreeItem::get_button_by_id(int p_column,int p_id) const { return -1; } + +bool TreeItem::is_button_disabled(int p_column, int p_idx) const { + + ERR_FAIL_INDEX_V( p_column, cells.size(), false ); + ERR_FAIL_INDEX_V( p_idx, cells[p_column].buttons.size(), false ); + + return cells[p_column].buttons[p_idx].disabled; + +} void TreeItem::set_button(int p_column,int p_idx,const Ref<Texture>& p_button){ ERR_FAIL_COND( p_button.is_null() ); @@ -672,10 +682,11 @@ void TreeItem::_bind_methods() { ObjectTypeDB::bind_method(_MD("clear_custom_bg_color","column"),&TreeItem::clear_custom_bg_color); ObjectTypeDB::bind_method(_MD("get_custom_bg_color","column"),&TreeItem::get_custom_bg_color); - ObjectTypeDB::bind_method(_MD("add_button","column","button:Texture","button_idx"),&TreeItem::add_button); + ObjectTypeDB::bind_method(_MD("add_button","column","button:Texture","button_idx","disabled"),&TreeItem::add_button,DEFVAL(-1),DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_button_count","column"),&TreeItem::get_button_count); ObjectTypeDB::bind_method(_MD("get_button:Texture","column","button_idx"),&TreeItem::get_button); ObjectTypeDB::bind_method(_MD("erase_button","column","button_idx"),&TreeItem::erase_button); + ObjectTypeDB::bind_method(_MD("is_button_disabled","column","button_idx"),&TreeItem::is_button_disabled); ObjectTypeDB::bind_method(_MD("set_tooltip","column","tooltip"),&TreeItem::set_tooltip); ObjectTypeDB::bind_method(_MD("get_tooltip","column"),&TreeItem::get_tooltip); @@ -1015,14 +1026,15 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& Point2i o = Point2i( ofs+w-s.width, p_pos.y )-cache.offset+p_draw_ofs; - if (cache.click_type==Cache::CLICK_BUTTON && cache.click_item==p_item && cache.click_column==i) { + if (cache.click_type==Cache::CLICK_BUTTON && cache.click_item==p_item && cache.click_column==i && !p_item->cells[i].buttons[j].disabled) { //being pressed cache.button_pressed->draw(get_canvas_item(),Rect2(o,s)); } o.y+=(label_h-s.height)/2; o+=cache.button_pressed->get_offset(); - b->draw(ci,o); + + b->draw(ci,o,p_item->cells[i].buttons[j].disabled?Color(1,1,1,0.5):Color(1,1,1,1)); w-=s.width+cache.button_margin; bw+=s.width+cache.button_margin; } @@ -1472,7 +1484,13 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_ for(int j=c.buttons.size()-1;j>=0;j--) { Ref<Texture> b=c.buttons[j].texture; int w = b->get_size().width + cache.button_pressed->get_minimum_size().width; + if (x>col_width-w) { + if (c.buttons[j].disabled) { + pressed_button=-1; + cache.click_type=Cache::CLICK_NONE; + return -1; + } pressed_button=j; cache.click_type=Cache::CLICK_BUTTON; cache.click_index=j; @@ -1730,6 +1748,8 @@ void Tree::_text_editor_modal_close() { return; } + if (value_editor->has_point(value_editor->get_local_mouse_pos())) + return; text_editor_enter(text_editor->get_text()); } @@ -2316,7 +2336,7 @@ bool Tree::edit_selected() { return false; Rect2 rect; - rect.pos.y = get_item_offset(s) - v_scroll->get_val(); + rect.pos.y = get_item_offset(s) - get_scroll().y; for(int i=0;i<col;i++) { diff --git a/scene/gui/tree.h b/scene/gui/tree.h index e4d349978c..e5c95b4d66 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -86,8 +86,9 @@ friend class Tree; struct Button { int id; + bool disabled; Ref<Texture> texture; - Button() { id=0; } + Button() { id=0; disabled=false; } }; Vector< Button > buttons; @@ -172,12 +173,13 @@ public: void set_icon_max_width(int p_column,int p_max); int get_icon_max_width(int p_column) const; - void add_button(int p_column,const Ref<Texture>& p_button,int p_id=-1); + void add_button(int p_column,const Ref<Texture>& p_button,int p_id=-1,bool p_disabled=false); int get_button_count(int p_column) const; Ref<Texture> get_button(int p_column,int p_idx) const; int get_button_id(int p_column,int p_idx) const; void erase_button(int p_column,int p_idx); int get_button_by_id(int p_column,int p_id) const; + bool is_button_disabled(int p_column,int p_idx) const; void set_button(int p_column,int p_idx,const Ref<Texture>& p_button); /* range works for mode number or mode combo */ diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 517cd414c5..fc7cc0a362 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -393,7 +393,7 @@ void VideoPlayer::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec); ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec); - ObjectTypeDB::bind_method(_MD("get_video_texutre:Texture"), &VideoPlayer::get_video_texture ); + ObjectTypeDB::bind_method(_MD("get_video_texture:Texture"), &VideoPlayer::get_video_texture ); ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") ); ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") ); diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 2c23b62b12..a118bc9782 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -42,6 +42,7 @@ void Timer::_notification(int p_what) { break; #endif start(); + autostart=false; } } break; case NOTIFICATION_PROCESS: { diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 9297d49e2b..104806d891 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -406,7 +406,7 @@ void Viewport::_notification(int p_what) { case NOTIFICATION_EXIT_TREE: { - + _gui_cancel_tooltip(); if (world_2d.is_valid()) world_2d->_remove_viewport(this); @@ -434,6 +434,12 @@ void Viewport::_notification(int p_what) { } break; case NOTIFICATION_FIXED_PROCESS: { + if (gui.tooltip_timer>=0) { + gui.tooltip_timer-=get_fixed_process_delta_time(); + if (gui.tooltip_timer<0) { + _gui_show_tooltip(); + } + } if (get_tree()->is_debugging_collisions_hint() && contact_2d_debug.is_valid()) { @@ -527,7 +533,7 @@ void Viewport::_notification(int p_what) { Vector2 point = get_canvas_transform().affine_inverse().xform(pos); Physics2DDirectSpaceState::ShapeResult res[64]; - int rc = ss2d->intersect_point(point,res,64,Set<RID>(),0xFFFFFFFF,0xFFFFFFFF); + int rc = ss2d->intersect_point(point,res,64,Set<RID>(),0xFFFFFFFF,0xFFFFFFFF,true); for(int i=0;i<rc;i++) { if (res[i].collider_id && res[i].collider) { @@ -849,7 +855,7 @@ void Viewport::_camera_transform_changed_notify() { #endif } -void Viewport::_set_camera(Camera* p_camera) { +void Viewport::_camera_set(Camera* p_camera) { #ifndef _3D_DISABLED @@ -874,6 +880,36 @@ void Viewport::_set_camera(Camera* p_camera) { #endif } +bool Viewport::_camera_add(Camera* p_camera) { + + cameras.insert(p_camera); + return cameras.size()==1; +} + +void Viewport::_camera_remove(Camera* p_camera) { + + cameras.erase(p_camera); + if (camera==p_camera) { + camera=NULL; + } +} + +void Viewport::_camera_make_next_current(Camera* p_exclude) { + + for(Set<Camera*>::Element *E=cameras.front();E;E=E->next()) { + + if (p_exclude==E->get()) + continue; + if (!E->get()->is_inside_tree()) + continue; + if (camera!=NULL) + return; + + E->get()->make_current(); + + } +} + void Viewport::set_transparent_background(bool p_enable) { @@ -1376,10 +1412,11 @@ void Viewport::_gui_sort_roots() { void Viewport::_gui_cancel_tooltip() { gui.tooltip=NULL; - if (gui.tooltip_timer) - gui.tooltip_timer->stop(); - if (gui.tooltip_popup) - gui.tooltip_popup->hide(); + gui.tooltip_timer=-1; + if (gui.tooltip_popup) { + gui.tooltip_popup->queue_delete(); + gui.tooltip_popup=NULL; + } } @@ -1393,10 +1430,25 @@ void Viewport::_gui_show_tooltip() { if (tooltip.length()==0) return; // bye + if (gui.tooltip_popup) { + memdelete(gui.tooltip_popup); + gui.tooltip_popup=NULL; + } - if (!gui.tooltip_label) { + Control *rp = gui.tooltip->get_root_parent_control(); + if (!rp) return; - } + + + gui.tooltip_popup = memnew( TooltipPanel ); + + rp->add_child(gui.tooltip_popup); + gui.tooltip_popup->force_parent_owned(); + gui.tooltip_label = memnew( TooltipLabel ); + gui.tooltip_popup->add_child(gui.tooltip_label); + gui.tooltip_popup->set_as_toplevel(true); + gui.tooltip_popup->hide(); + Ref<StyleBox> ttp = gui.tooltip_label->get_stylebox("panel","TooltipPanel"); gui.tooltip_label->set_anchor_and_margin(MARGIN_LEFT,Control::ANCHOR_BEGIN,ttp->get_margin(MARGIN_LEFT)); @@ -1416,11 +1468,10 @@ void Viewport::_gui_show_tooltip() { else if (r.pos.y<0) r.pos.y=0; - gui.tooltip_popup->set_pos(r.pos); + gui.tooltip_popup->set_global_pos(r.pos); gui.tooltip_popup->set_size(r.size); gui.tooltip_popup->raise(); - gui.tooltip_popup->show(); } @@ -1465,13 +1516,16 @@ Control* Viewport::_gui_find_control(const Point2& p_global) { CanvasItem *pci = sw->get_parent_item(); if (pci) xform=pci->get_global_transform_with_canvas(); - + else + xform=sw->get_canvas_transform(); Control *ret = _gui_find_control_at_pos(sw,p_global,xform,gui.focus_inv_xform); if (ret) return ret; } + _gui_sort_roots(); + for (List<Control*>::Element *E=gui.roots.back();E;E=E->prev()) { Control *sw = E->get(); @@ -1482,6 +1536,8 @@ Control* Viewport::_gui_find_control(const Point2& p_global) { CanvasItem *pci = sw->get_parent_item(); if (pci) xform=pci->get_global_transform_with_canvas(); + else + xform=sw->get_canvas_transform(); Control *ret = _gui_find_control_at_pos(sw,p_global,xform,gui.focus_inv_xform); @@ -1601,7 +1657,7 @@ void Viewport::_gui_input_event(InputEvent p_event) { - Matrix32 parent_xform; + //Matrix32 parent_xform; //if (data.parent_canvas_item) // parent_xform=data.parent_canvas_item->get_global_transform(); @@ -1660,7 +1716,8 @@ void Viewport::_gui_input_event(InputEvent p_event) { get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID); get_tree()->set_input_as_handled(); - gui.tooltip_popup->hide(); + _gui_cancel_tooltip(); + //gui.tooltip_popup->hide(); } else { @@ -1792,7 +1849,7 @@ void Viewport::_gui_input_event(InputEvent p_event) { p_event.mouse_motion.relative_x=rel.x; p_event.mouse_motion.relative_y=rel.y; - if (p_event.mouse_motion.button_mask==0 && gui.tooltip_timer) { + if (p_event.mouse_motion.button_mask==0) { //nothing pressed bool can_tooltip=true; @@ -1808,7 +1865,8 @@ void Viewport::_gui_input_event(InputEvent p_event) { gui.tooltip=over; gui.tooltip_pos=mpos;//(parent_xform * get_transform()).affine_inverse().xform(pos); - gui.tooltip_timer->start(); + gui.tooltip_timer=gui.tooltip_delay; + } } @@ -2053,8 +2111,10 @@ void Viewport::_gui_hid_control(Control *p_control) { gui.mouse_over=NULL; if (gui.tooltip == p_control) gui.tooltip=NULL; - if (gui.tooltip == p_control) + if (gui.tooltip == p_control) { gui.tooltip=NULL; + _gui_cancel_tooltip(); + } } @@ -2069,6 +2129,9 @@ void Viewport::_gui_remove_control(Control *p_control) { gui.mouse_over=NULL; if (gui.tooltip == p_control) gui.tooltip=NULL; + if (gui.tooltip_popup == p_control) { + _gui_cancel_tooltip(); + } } @@ -2147,7 +2210,7 @@ void Viewport::_gui_grab_click_focus(Control *p_control) { //send unclic - Point2 click =gui.mouse_focus->get_global_transform().affine_inverse().xform(gui.last_mouse_pos); + Point2 click =gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos); mb.x=click.x; mb.y=click.y; mb.button_index=gui.mouse_focus_button; @@ -2156,8 +2219,8 @@ void Viewport::_gui_grab_click_focus(Control *p_control) { gui.mouse_focus=p_control; - gui.focus_inv_xform=gui.mouse_focus->get_global_transform().affine_inverse(); - click =gui.mouse_focus->get_global_transform().affine_inverse().xform(gui.last_mouse_pos); + gui.focus_inv_xform=gui.mouse_focus->get_global_transform_with_canvas().affine_inverse(); + click =gui.mouse_focus->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos); mb.x=click.x; mb.y=click.y; mb.button_index=gui.mouse_focus_button; @@ -2461,21 +2524,16 @@ Viewport::Viewport() { disable_input=false; //window tooltip - gui.tooltip_timer = memnew( Timer ); - add_child(gui.tooltip_timer); - gui.tooltip_timer->force_parent_owned(); - gui.tooltip_timer->set_wait_time( GLOBAL_DEF("display/tooltip_delay",0.7)); - gui.tooltip_timer->connect("timeout",this,"_gui_show_tooltip"); + gui.tooltip_timer = -1; + + //gui.tooltip_timer->force_parent_owned(); + gui.tooltip_delay=GLOBAL_DEF("display/tooltip_delay",0.7); + gui.tooltip=NULL; - gui.tooltip_popup = memnew( TooltipPanel ); - add_child(gui.tooltip_popup); - gui.tooltip_popup->force_parent_owned(); - gui.tooltip_label = memnew( TooltipLabel ); - gui.tooltip_popup->add_child(gui.tooltip_label); - gui.tooltip_popup->set_as_toplevel(true); - gui.tooltip_popup->hide(); - gui.drag_attempted=false; + gui.tooltip_label=NULL; gui.drag_preview=NULL; + gui.drag_attempted=false; + parent_control=NULL; diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 89e053d607..5bf7418ee9 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -187,7 +187,8 @@ friend class RenderTargetTexture; bool drag_attempted; Variant drag_data; Control *drag_preview; - Timer *tooltip_timer; + float tooltip_timer; + float tooltip_delay; List<Control*> modal_stack; unsigned int cancelled_input_ID; Matrix32 focus_inv_xform; @@ -263,7 +264,11 @@ friend class Control; friend class Camera; void _camera_transform_changed_notify(); - void _set_camera(Camera* p_camera); + void _camera_set(Camera* p_camera); + bool _camera_add(Camera* p_camera); //true if first + void _camera_remove(Camera* p_camera); + void _camera_make_next_current(Camera* p_exclude); + protected: void _notification(int p_what); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index f713b9e979..fb9f66a40a 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -264,8 +264,8 @@ void make_default_theme() { // ToolButton Ref<StyleBox> tb_empty = memnew( StyleBoxEmpty ); - tb_empty->set_default_margin(MARGIN_LEFT,8); - tb_empty->set_default_margin(MARGIN_RIGHT,8); + tb_empty->set_default_margin(MARGIN_LEFT,6); + tb_empty->set_default_margin(MARGIN_RIGHT,6); tb_empty->set_default_margin(MARGIN_TOP,4); tb_empty->set_default_margin(MARGIN_BOTTOM,4); @@ -884,6 +884,13 @@ void make_default_theme() { t->set_stylebox("panelf","Panel", tc_sb ); t->set_stylebox("panel","PanelContainer", tc_sb ); + t->set_icon("minus","GraphEdit", make_icon(icon_zoom_less_png) ); + t->set_icon("reset","GraphEdit", make_icon(icon_zoom_reset_png) ); + t->set_icon("more","GraphEdit", make_icon(icon_zoom_more_png) ); + t->set_stylebox("bg","GraphEdit", make_stylebox( tree_bg_png,4,4,4,5) ); + + + t->set_icon( "logo","Icons", make_icon(logo_png) ); diff --git a/scene/resources/default_theme/icon_zoom_less.png b/scene/resources/default_theme/icon_zoom_less.png Binary files differnew file mode 100644 index 0000000000..3e50ce0c22 --- /dev/null +++ b/scene/resources/default_theme/icon_zoom_less.png diff --git a/scene/resources/default_theme/icon_zoom_more.png b/scene/resources/default_theme/icon_zoom_more.png Binary files differnew file mode 100644 index 0000000000..4f2928064c --- /dev/null +++ b/scene/resources/default_theme/icon_zoom_more.png diff --git a/scene/resources/default_theme/icon_zoom_reset.png b/scene/resources/default_theme/icon_zoom_reset.png Binary files differnew file mode 100644 index 0000000000..36fafc2037 --- /dev/null +++ b/scene/resources/default_theme/icon_zoom_reset.png diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h index 4c440ab99a..6414efa74d 100644 --- a/scene/resources/default_theme/theme_data.h +++ b/scene/resources/default_theme/theme_data.h @@ -214,6 +214,21 @@ static const unsigned char icon_stop_png[]={ }; +static const unsigned char icon_zoom_less_png[]={ +0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x12,0x0,0x0,0xb,0x12,0x1,0xd2,0xdd,0x7e,0xfc,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x2,0x8,0x11,0x19,0x15,0x8e,0xdd,0x4e,0x19,0x0,0x0,0x1,0x25,0x49,0x44,0x41,0x54,0x38,0xcb,0x9d,0x92,0xc1,0x8a,0xc2,0x30,0x10,0x86,0xbf,0x99,0x36,0x94,0xd2,0xaa,0x4,0x5b,0x28,0x78,0xe9,0xfb,0x3f,0x95,0x22,0x78,0x11,0x9,0x4a,0xf,0xb5,0xd8,0x64,0x2f,0xdb,0xec,0xb2,0xad,0xbb,0xae,0xdf,0x29,0xcc,0x64,0xfe,0xfc,0x33,0x19,0xe1,0x13,0xe7,0x1c,0xd6,0x5a,0x2e,0x97,0xb,0xde,0x7b,0x0,0x54,0x95,0xed,0x76,0x1b,0x73,0x4b,0xc8,0x54,0xc,0xd0,0x75,0x1d,0xe3,0x38,0x92,0xa6,0x29,0x0,0x8f,0xc7,0x83,0x24,0x49,0x28,0x8a,0x2,0x11,0x59,0x14,0x91,0xe9,0xb0,0xdf,0xef,0x11,0x11,0xd2,0x34,0x65,0xb7,0xdb,0xc5,0xb,0xa7,0xd3,0x89,0x61,0x18,0x68,0xdb,0x76,0xd1,0x89,0x38,0xe7,0xb8,0xdf,0xef,0xf4,0x7d,0xf,0xc0,0x66,0xb3,0x1,0xc0,0x5a,0x1b,0xb,0x8e,0xc7,0x23,0xc6,0x18,0x9a,0xa6,0x99,0x39,0x50,0x6b,0x2d,0x7d,0xdf,0x53,0x96,0x25,0xab,0xd5,0x2a,0x16,0x7f,0x17,0xc9,0xf3,0x3c,0x3e,0x30,0x13,0x88,0x56,0x44,0x50,0xd5,0xe5,0x3e,0x45,0x78,0x86,0x0,0x1c,0xe,0x7,0x42,0x8,0x81,0x7f,0xd0,0xb6,0xad,0x0,0xa8,0x73,0x8e,0x2c,0xcb,0x78,0x17,0x5,0x16,0x87,0xf3,0xb2,0xc0,0x34,0xa8,0x77,0x91,0xa5,0x4d,0x1c,0xc7,0x11,0x80,0x24,0x49,0xe2,0x26,0x5e,0xaf,0x57,0xb2,0x2c,0xc3,0x18,0x43,0x55,0x55,0xf3,0x5f,0x98,0xa6,0xaf,0xaa,0x18,0x63,0x30,0xc6,0xa0,0x1a,0xd3,0xe4,0x79,0xce,0x30,0xc,0x74,0x5d,0xc7,0xf9,0x7c,0x9e,0x3b,0xf8,0xd,0xe7,0x1c,0x21,0x4,0x6e,0xb7,0x5b,0x8c,0x15,0x45,0x41,0x5d,0xd7,0xaf,0x9,0x3c,0x13,0x29,0xcb,0xf2,0xab,0x85,0xbf,0xb0,0xd6,0x22,0x22,0xac,0xd7,0xeb,0x18,0xf3,0xde,0xbf,0xee,0xe0,0xa7,0x13,0xef,0x3d,0x55,0x55,0xf1,0x1,0x48,0x6e,0x80,0x3e,0x13,0xf0,0x5,0xd,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 +}; + + +static const unsigned char icon_zoom_more_png[]={ +0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x12,0x0,0x0,0xb,0x12,0x1,0xd2,0xdd,0x7e,0xfc,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x2,0x8,0x11,0x19,0x1f,0x6e,0x8,0xa7,0x7,0x0,0x0,0x1,0x23,0x49,0x44,0x41,0x54,0x38,0xcb,0x9d,0x92,0x4d,0xaf,0x82,0x30,0x10,0x45,0xcf,0x8c,0x36,0xe0,0x77,0x1a,0x59,0xb0,0x70,0xe1,0xff,0xff,0x57,0xae,0xd5,0x34,0x10,0x30,0x60,0x68,0xeb,0xe6,0xc1,0xf3,0x9,0x26,0xfa,0xee,0xae,0x69,0xe7,0xcc,0xcc,0xbd,0x15,0x7e,0xe4,0x9c,0xc3,0x5a,0xcb,0xf5,0x7a,0x25,0x84,0x0,0x80,0xaa,0xb2,0xdf,0xef,0x87,0xbb,0x29,0x49,0x5f,0xc,0x50,0x55,0x15,0xde,0x7b,0xe6,0xf3,0x39,0x0,0x5d,0xd7,0x31,0x9b,0xcd,0x58,0xad,0x56,0x88,0xc8,0x24,0x44,0x1,0xac,0xb5,0x14,0x45,0x41,0x8,0x1,0x63,0xc,0x87,0xc3,0x81,0xae,0xeb,0x22,0x10,0xbd,0xf7,0xb1,0x2c,0xcb,0x68,0xad,0x1d,0x1a,0xfd,0x99,0xc0,0x39,0x47,0xdb,0xb6,0x34,0x4d,0x3,0xc0,0x6e,0xb7,0x3,0xa0,0x28,0x8a,0xf8,0xfc,0x30,0x4d,0x53,0xc9,0xf3,0x7c,0x3c,0x81,0xb5,0x96,0xa6,0x69,0x58,0xaf,0xd7,0x6c,0x36,0x1b,0xfa,0x89,0x5e,0xd5,0x37,0x98,0x5c,0x1,0x40,0x44,0x50,0xd5,0xb7,0x66,0xbd,0x93,0x0,0x9c,0x4e,0x27,0x62,0x8c,0xf1,0x9b,0xc2,0xe3,0xf1,0x28,0x0,0xea,0x9c,0x23,0x49,0x12,0xfe,0x2b,0x5,0x98,0x32,0xe7,0x63,0xc0,0xbb,0x78,0xbe,0xf2,0xe0,0xf5,0x27,0x7a,0xef,0xb9,0xdd,0x6e,0xaf,0x9e,0x48,0x92,0x24,0x18,0x63,0xc8,0xb2,0x6c,0x9c,0x42,0xef,0xbe,0xaa,0x62,0x8c,0x19,0x75,0x5a,0x2c,0x16,0xdc,0xef,0x77,0xaa,0xaa,0xe2,0x7c,0x3e,0x8f,0x1,0xcf,0xa0,0xa9,0x28,0x8d,0x31,0xf4,0x41,0xd5,0x75,0x3d,0x40,0xf4,0xe3,0x5d,0x45,0xd8,0x6e,0xb7,0xc3,0xb9,0xae,0x6b,0x2e,0x97,0xcb,0xaf,0x7,0x9f,0xc8,0x39,0x47,0x8c,0x91,0xb2,0x2c,0x1,0x58,0x2e,0x97,0xdf,0x1,0x9e,0x21,0x21,0x4,0xb2,0x2c,0xe3,0x1,0xf3,0xd9,0x85,0xaf,0x46,0x21,0x2f,0x17,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 +}; + + +static const unsigned char icon_zoom_reset_png[]={ +0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x12,0x0,0x0,0xb,0x12,0x1,0xd2,0xdd,0x7e,0xfc,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x2,0x8,0x11,0x1b,0xa,0x31,0xe3,0x21,0x6e,0x0,0x0,0x0,0xd6,0x49,0x44,0x41,0x54,0x38,0xcb,0xa5,0x92,0xc1,0xaa,0x84,0x30,0xc,0x45,0x4f,0xaa,0x20,0xea,0x42,0x8a,0x2e,0x5c,0xf6,0xff,0xbf,0xaa,0x1f,0xa0,0x4,0xc4,0x85,0x82,0xb6,0x6f,0xf3,0x94,0x19,0x47,0x1d,0x66,0xe6,0xac,0x4a,0x93,0x9b,0x26,0xe9,0x15,0xfe,0x51,0x55,0xac,0xb5,0xf4,0x7d,0x4f,0x8,0x1,0x0,0x63,0xc,0x75,0x5d,0xef,0xb1,0x33,0x64,0x13,0x3,0x8c,0xe3,0xc8,0xba,0xae,0xa4,0x69,0xa,0xc0,0xb2,0x2c,0x24,0x49,0x42,0x59,0x96,0x88,0xc8,0x69,0x11,0xd9,0xe,0xde,0x7b,0x80,0x78,0xbc,0xdf,0x70,0xce,0x3d,0xe5,0x38,0xe7,0x4,0x20,0x55,0x55,0xe6,0x79,0x66,0x9a,0xa6,0xc8,0xd,0x87,0x7,0x76,0x8c,0xb5,0xf6,0x4e,0x1c,0x1f,0x44,0xa7,0x39,0x86,0x1f,0x31,0x0,0x22,0x22,0x67,0x73,0x9f,0xec,0xeb,0x25,0xc7,0xa8,0x2a,0x59,0x96,0x7d,0x24,0x7a,0xe9,0xa0,0x6d,0xdb,0xef,0x47,0xb0,0xd6,0xee,0x3e,0x78,0xb3,0xc4,0xeb,0xe,0xac,0xb5,0x54,0x55,0xf5,0xfd,0x12,0xb7,0x22,0x77,0xe4,0x79,0x7e,0x6d,0x65,0xef,0x7d,0xbc,0x8a,0x1d,0xc6,0x39,0xba,0x53,0x7e,0xf2,0x41,0xd7,0x75,0x6f,0xff,0xfe,0x9,0x55,0x25,0xc6,0xc8,0x30,0xc,0x0,0x14,0x45,0xf1,0x59,0x81,0xc7,0x22,0x21,0x4,0x9a,0xa6,0xe1,0xf,0x29,0x54,0x56,0xd3,0x43,0xf4,0x61,0x53,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 +}; + + static const unsigned char line_edit_png[]={ 0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xa,0x0,0x0,0x0,0xa,0x8,0x6,0x0,0x0,0x0,0x8d,0x32,0xcf,0xbd,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdf,0xa,0x14,0x3,0x1d,0x2f,0xec,0x8c,0x33,0x2f,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x0,0x9d,0x49,0x44,0x41,0x54,0x18,0xd3,0xb5,0x90,0x31,0xe,0xc2,0x40,0x10,0x3,0xed,0xbb,0xd5,0x25,0xa1,0xa1,0x3,0x9,0x41,0xc1,0x33,0x78,0x15,0x5f,0xc8,0x93,0x41,0x14,0x49,0x2e,0xbb,0xb7,0x29,0x2,0x52,0x20,0x14,0x34,0x58,0x72,0x63,0x4f,0x61,0x99,0xfb,0xdd,0xe1,0x9a,0x52,0xd5,0xc6,0x10,0x6b,0x92,0x58,0xca,0xdd,0x61,0xc5,0xfa,0x9c,0x87,0x96,0xa7,0xe3,0xf9,0x56,0xa5,0x7a,0x2b,0x22,0x0,0xde,0x41,0xc0,0xa1,0xaa,0x18,0x72,0x7f,0x97,0x18,0x62,0x23,0x22,0x88,0x22,0xe0,0x7,0xe8,0x70,0x0,0x80,0x6a,0x6c,0x2,0xc9,0x2,0x70,0x5,0x1,0x78,0x66,0x4,0xc9,0x12,0xf0,0xa3,0xfe,0x0,0xba,0x7b,0x98,0x67,0xfb,0xaa,0x9c,0x33,0x87,0xbb,0x7,0xb1,0x62,0x9d,0xaa,0xa6,0xd7,0xfc,0x6f,0xf7,0x58,0xb1,0x3e,0x36,0xf5,0xa6,0x3,0x70,0x29,0x66,0x30,0x53,0x5d,0x5a,0x75,0xd4,0x51,0xc7,0x47,0xce,0x43,0x3b,0x1,0xc,0x2e,0x55,0x5d,0x5f,0x72,0xb6,0x33,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 }; diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 57d2a8d890..43196a43d4 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -33,7 +33,7 @@ #include "scene/gui/control.h" #include "scene/2d/node_2d.h" #include "scene/main/instance_placeholder.h" - +#include "core/core_string_names.h" #define PACK_VERSION 2 bool SceneState::can_instance() const { @@ -99,6 +99,7 @@ Node *SceneState::instance(bool p_gen_edit_state) const { Node *node=NULL; + if (i==0 && base_scene_idx>=0) { //scene inheritance on root node //print_line("scene inherit"); @@ -193,7 +194,26 @@ Node *SceneState::instance(bool p_gen_edit_state) const { ERR_FAIL_INDEX_V( nprops[j].name, sname_count, NULL ); ERR_FAIL_INDEX_V( nprops[j].value, prop_count, NULL ); - node->set(snames[ nprops[j].name ],props[ nprops[j].value ],&valid); + if (snames[ nprops[j].name ]==CoreStringNames::get_singleton()->_script) { + //work around to avoid old script variables from disappearing, should be the proper fix to: + //https://github.com/godotengine/godot/issues/2958 + + //store old state + List<Pair<StringName,Variant> > old_state; + if (node->get_script_instance()) { + node->get_script_instance()->get_property_state(old_state); + } + + node->set(snames[ nprops[j].name ],props[ nprops[j].value ],&valid); + + //restore old state for new script, if exists + for (List<Pair<StringName,Variant> >::Element *E=old_state.front();E;E=E->next()) { + node->set(E->get().first,E->get().second); + } + } else { + + node->set(snames[ nprops[j].name ],props[ nprops[j].value ],&valid); + } } } @@ -460,6 +480,7 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S List<PropertyInfo> plist; p_node->get_property_list(&plist); + bool saved_script=false; for (List<PropertyInfo>::Element *E=plist.front();E;E=E->next()) { @@ -508,8 +529,10 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S break; } } - - if (exists && p_node->get_script_instance()) { +#if 0 +// this workaround ended up causing problems: +https://github.com/godotengine/godot/issues/3127 + if (saved_script && exists && p_node->get_script_instance()) { //if this is an overriden value by another script, save it anyway //as the script change will erase it //https://github.com/godotengine/godot/issues/2958 @@ -522,7 +545,7 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S } } - +#endif if (exists && bool(Variant::evaluate(Variant::OP_EQUAL,value,original))) { //exists and did not change continue; @@ -543,6 +566,9 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S } } + if (name=="script/script") + saved_script=true; + NodeData::Property prop; prop.name=_nm_get_string( name,name_map); prop.value=_vm_get_variant( value, variant_map); diff --git a/scene/resources/sample.cpp b/scene/resources/sample.cpp index 4b25a2c490..87fcfc425d 100644 --- a/scene/resources/sample.cpp +++ b/scene/resources/sample.cpp @@ -151,8 +151,8 @@ void Sample::set_loop_format(LoopFormat p_format) { if (sample.is_valid()) AudioServer::get_singleton()->sample_set_loop_format(sample,(AudioServer::SampleLoopFormat)p_format); loop_format=p_format; - } + Sample::LoopFormat Sample::get_loop_format() const { return loop_format; diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index 2f18e70d7f..d9f6beabc0 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -85,8 +85,7 @@ Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream* r_res=ResourceLoader::load(path,type); if (r_res.is_null()) { - r_err_str="Couldn't load external resource: "+path; - return ERR_PARSE_ERROR; + WARN_PRINT(String("Couldn't load external resource: "+path).utf8().get_data()); } VariantParser::get_token(p_stream,token,line,r_err_str); @@ -171,6 +170,7 @@ Error ResourceInteractiveLoaderText::poll() { _printerr(); } + resource_current++; return error; @@ -228,6 +228,8 @@ Error ResourceInteractiveLoaderText::poll() { } + resource_current++; + while(true) { String assign; @@ -292,6 +294,8 @@ Error ResourceInteractiveLoaderText::poll() { resource=Ref<Resource>(r); + resource_current++; + while(true) { String assign; @@ -394,6 +398,13 @@ Error ResourceInteractiveLoaderText::poll() { int node_id = packed_scene->get_state()->add_node(parent,owner,type,name,instance); + if (next_tag.fields.has("groups")) { + + Array groups = next_tag.fields["groups"]; + for (int i=0;i<groups.size();i++) { + packed_scene->get_state()->add_node_group(node_id,packed_scene->get_state()->add_name(groups[i])); + } + } while(true) { @@ -739,6 +750,8 @@ void ResourceInteractiveLoaderText::open(FileAccess *p_f,bool p_skip_first_tag) stream.f=f; is_scene=false; + resource_current=0; + VariantParser::Tag tag; Error err = VariantParser::parse_tag(&stream,lines,error_text,tag); @@ -1374,9 +1387,10 @@ bool ResourceFormatSaverText::recognize(const RES& p_resource) const { } void ResourceFormatSaverText::get_recognized_extensions(const RES& p_resource,List<String> *p_extensions) const { - p_extensions->push_back("tres"); //text resource if (p_resource->get_type()=="PackedScene") p_extensions->push_back("tscn"); //text scene + else + p_extensions->push_back("tres"); //text resource } |