summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/canvas_item.cpp56
-rw-r--r--scene/2d/parallax_background.cpp15
-rw-r--r--scene/2d/parallax_background.h7
-rw-r--r--scene/2d/parallax_layer.cpp36
-rw-r--r--scene/2d/parallax_layer.h4
-rw-r--r--scene/3d/skeleton.cpp16
-rw-r--r--scene/animation/animation_player.cpp14
-rw-r--r--scene/audio/stream_player.cpp10
-rw-r--r--scene/audio/stream_player.h2
-rw-r--r--scene/gui/base_button.cpp7
-rw-r--r--scene/gui/color_picker.cpp12
-rw-r--r--scene/gui/color_picker.h1
-rw-r--r--scene/gui/color_ramp_edit.cpp4
-rw-r--r--scene/gui/control.cpp19
-rw-r--r--scene/gui/control.h2
-rw-r--r--scene/gui/grid_container.cpp1
-rw-r--r--scene/gui/item_list.cpp16
-rw-r--r--scene/gui/item_list.h1
-rw-r--r--scene/gui/line_edit.cpp49
-rw-r--r--scene/gui/line_edit.h6
-rw-r--r--scene/gui/text_edit.cpp7
-rw-r--r--scene/gui/tree.cpp7
-rw-r--r--scene/main/node.cpp14
-rw-r--r--scene/main/node.h3
-rw-r--r--scene/main/viewport.cpp97
-rw-r--r--scene/main/viewport.h1
-rw-r--r--scene/resources/animation.cpp22
-rw-r--r--scene/resources/animation.h3
-rw-r--r--scene/resources/packed_scene.cpp8
-rw-r--r--scene/resources/packed_scene.h1
-rw-r--r--scene/resources/sample.cpp2
-rw-r--r--scene/resources/sample.h1
-rw-r--r--scene/resources/sample_library.cpp10
-rw-r--r--scene/resources/scene_format_text.cpp55
-rw-r--r--scene/resources/scene_format_text.h2
-rw-r--r--scene/resources/texture.cpp4
-rw-r--r--scene/resources/texture.h1
37 files changed, 333 insertions, 183 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 21a3ecef32..bc5bff3b8e 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -953,62 +953,8 @@ InputEvent CanvasItem::make_input_local(const InputEvent& p_event) const {
ERR_FAIL_COND_V(!is_inside_tree(),p_event);
- InputEvent ev = p_event;
+ return p_event.xform_by( (get_canvas_transform() * get_global_transform()).affine_inverse() );
- Matrix32 local_matrix = (get_canvas_transform() * get_global_transform()).affine_inverse();
-
- switch(ev.type) {
-
- case InputEvent::MOUSE_BUTTON: {
-
- Vector2 g = local_matrix.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y));
- Vector2 l = local_matrix.xform(Vector2(ev.mouse_button.x,ev.mouse_button.y));
- ev.mouse_button.x=l.x;
- ev.mouse_button.y=l.y;
- ev.mouse_button.global_x=g.x;
- ev.mouse_button.global_y=g.y;
-
- } break;
- case InputEvent::MOUSE_MOTION: {
-
- Vector2 g = local_matrix.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y));
- Vector2 l = local_matrix.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y));
- Vector2 r = local_matrix.basis_xform(Vector2(ev.mouse_motion.relative_x,ev.mouse_motion.relative_y));
- Vector2 s = local_matrix.basis_xform(Vector2(ev.mouse_motion.speed_x,ev.mouse_motion.speed_y));
- ev.mouse_motion.x=l.x;
- ev.mouse_motion.y=l.y;
- ev.mouse_motion.global_x=g.x;
- ev.mouse_motion.global_y=g.y;
- ev.mouse_motion.relative_x=r.x;
- ev.mouse_motion.relative_y=r.y;
- ev.mouse_motion.speed_x=s.x;
- ev.mouse_motion.speed_y=s.y;
-
- } break;
- case InputEvent::SCREEN_TOUCH: {
-
-
- Vector2 t = local_matrix.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y));
- ev.screen_touch.x=t.x;
- ev.screen_touch.y=t.y;
-
- } break;
- case InputEvent::SCREEN_DRAG: {
-
-
- Vector2 t = local_matrix.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y));
- Vector2 r = local_matrix.basis_xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y));
- Vector2 s = local_matrix.basis_xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y));
- ev.screen_drag.x=t.x;
- ev.screen_drag.y=t.y;
- ev.screen_drag.relative_x=r.x;
- ev.screen_drag.relative_y=r.y;
- ev.screen_drag.speed_x=s.x;
- ev.screen_drag.speed_y=s.y;
- } break;
- }
-
- return ev;
}
diff --git a/scene/2d/parallax_background.cpp b/scene/2d/parallax_background.cpp
index 7f2e9efd96..1b6ab66fcc 100644
--- a/scene/2d/parallax_background.cpp
+++ b/scene/2d/parallax_background.cpp
@@ -104,16 +104,18 @@ void ParallaxBackground::_update_scroll() {
}
ofs = -ofs;
+ final_offset=ofs;
+
for(int i=0;i<get_child_count();i++) {
ParallaxLayer *l=get_child(i)->cast_to<ParallaxLayer>();
if (!l)
continue;
- if (ignore_camera_zoom)
- l->set_base_offset_and_scale(ofs, 1.0);
- else
- l->set_base_offset_and_scale(ofs, scale);
+ if (ignore_camera_zoom)
+ l->set_base_offset_and_scale(ofs, 1.0);
+ else
+ l->set_base_offset_and_scale(ofs, scale);
}
}
@@ -180,6 +182,11 @@ bool ParallaxBackground::is_ignore_camera_zoom(){
}
+Vector2 ParallaxBackground::get_final_offset() const {
+
+ return final_offset;
+}
+
void ParallaxBackground::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved);
diff --git a/scene/2d/parallax_background.h b/scene/2d/parallax_background.h
index bdaf7d241f..c00cd52f26 100644
--- a/scene/2d/parallax_background.h
+++ b/scene/2d/parallax_background.h
@@ -44,6 +44,7 @@ class ParallaxBackground : public CanvasLayer {
String group_name;
Point2 limit_begin;
Point2 limit_end;
+ Point2 final_offset;
bool ignore_camera_zoom;
void _update_scroll();
@@ -73,8 +74,10 @@ public:
void set_limit_end(const Point2& p_ofs);
Point2 get_limit_end() const;
- void set_ignore_camera_zoom(bool ignore);
- bool is_ignore_camera_zoom();
+ void set_ignore_camera_zoom(bool ignore);
+ bool is_ignore_camera_zoom();
+
+ Vector2 get_final_offset() const;
ParallaxBackground();
};
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index bf559deb09..e9378b1d02 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -32,6 +32,15 @@
void ParallaxLayer::set_motion_scale(const Size2& p_scale) {
motion_scale=p_scale;
+
+
+ ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
+ if (is_inside_tree() && pb) {
+ Vector2 ofs = pb->get_final_offset();
+ float scale = pb->get_scroll_scale();
+ set_base_offset_and_scale(ofs,scale);
+ }
+
}
Size2 ParallaxLayer::get_motion_scale() const {
@@ -40,6 +49,23 @@ Size2 ParallaxLayer::get_motion_scale() const {
}
+void ParallaxLayer::set_motion_offset(const Size2& p_offset) {
+
+ motion_offset=p_offset;
+
+ ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
+ if (is_inside_tree() && pb) {
+ Vector2 ofs = pb->get_final_offset();
+ float scale = pb->get_scroll_scale();
+ set_base_offset_and_scale(ofs,scale);
+ }
+}
+
+Size2 ParallaxLayer::get_motion_offset() const {
+
+ return motion_offset;
+
+}
void ParallaxLayer::_update_mirroring() {
@@ -59,6 +85,11 @@ void ParallaxLayer::_update_mirroring() {
void ParallaxLayer::set_mirroring(const Size2& p_mirroring) {
mirroring=p_mirroring;
+ if (mirroring.x<0)
+ mirroring.x=0;
+ if (mirroring.y<0)
+ mirroring.y=0;
+
_update_mirroring();
}
@@ -89,7 +120,7 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2& p_offset,float p_sca
return;
if (get_tree()->is_editor_hint())
return;
- Point2 new_ofs = ((orig_offset+p_offset)*motion_scale)*p_scale;
+ Point2 new_ofs = ((orig_offset+p_offset)*motion_scale)*p_scale+motion_offset;
if (mirroring.x) {
@@ -132,10 +163,13 @@ void ParallaxLayer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_motion_scale","scale"),&ParallaxLayer::set_motion_scale);
ObjectTypeDB::bind_method(_MD("get_motion_scale"),&ParallaxLayer::get_motion_scale);
+ ObjectTypeDB::bind_method(_MD("set_motion_offset","offset"),&ParallaxLayer::set_motion_offset);
+ ObjectTypeDB::bind_method(_MD("get_motion_offset"),&ParallaxLayer::get_motion_offset);
ObjectTypeDB::bind_method(_MD("set_mirroring","mirror"),&ParallaxLayer::set_mirroring);
ObjectTypeDB::bind_method(_MD("get_mirroring"),&ParallaxLayer::get_mirroring);
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/scale"),_SCS("set_motion_scale"),_SCS("get_motion_scale"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/offset"),_SCS("set_motion_offset"),_SCS("get_motion_offset"));
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"motion/mirroring"),_SCS("set_mirroring"),_SCS("get_mirroring"));
}
diff --git a/scene/2d/parallax_layer.h b/scene/2d/parallax_layer.h
index c2d345da47..6b1d73ea66 100644
--- a/scene/2d/parallax_layer.h
+++ b/scene/2d/parallax_layer.h
@@ -38,6 +38,7 @@ class ParallaxLayer : public Node2D {
Point2 orig_offset;
Point2 orig_scale;
Size2 motion_scale;
+ Vector2 motion_offset;
Vector2 mirroring;
void _update_mirroring();
@@ -48,6 +49,9 @@ protected:
public:
+ void set_motion_offset(const Size2& p_scale);
+ Size2 get_motion_offset() const;
+
void set_motion_scale(const Size2& p_scale);
Size2 get_motion_scale() const;
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index d0b739e17f..c996a8123c 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -64,15 +64,17 @@ bool Skeleton::_set(const StringName& p_path, const Variant& p_value) {
else if (what=="bound_childs") {
Array children=p_value;
- bones[which].nodes_bound.clear();
+ if (is_inside_tree()) {
+ bones[which].nodes_bound.clear();
- for (int i=0;i<children.size();i++) {
+ for (int i=0;i<children.size();i++) {
- NodePath path=children[i];
- ERR_CONTINUE( path.operator String()=="" );
- Node *node = get_node(path);
- ERR_CONTINUE(!node);
- bind_child_node_to_bone(which,node);
+ NodePath path=children[i];
+ ERR_CONTINUE( path.operator String()=="" );
+ Node *node = get_node(path);
+ ERR_CONTINUE(!node);
+ bind_child_node_to_bone(which,node);
+ }
}
} else {
return false;
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index dd4fa992ac..30af9b0094 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -540,7 +540,6 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd,float p_delta,flo
float len=cd.from->animation->get_length();
bool loop=cd.from->animation->has_loop();
- bool loop_interpolation=cd.from->animation->has_loop_interpolation();
if (!loop) {
@@ -566,21 +565,10 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd,float p_delta,flo
}
- } else if (loop_interpolation) {
+ } else {
next_pos=Math::fposmod(next_pos,len);
- } else {
-
- if (next_pos<0 || next_pos>len) {
- if (!backwards)
- next_pos=0;
- else if (backwards)
- next_pos=len;
- }
- // fix delta - not sure if needed here
- delta=next_pos-cd.pos;
-
}
cd.pos=next_pos;
diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp
index 050e945c8f..99ecace1ed 100644
--- a/scene/audio/stream_player.cpp
+++ b/scene/audio/stream_player.cpp
@@ -77,7 +77,7 @@ void StreamPlayer::sp_update() {
if (to_mix==0) {
if (!stop_request) {
stop_request=true;
- call_deferred("stop");
+ call_deferred("_do_stop");
}
return;
}
@@ -91,7 +91,10 @@ void StreamPlayer::sp_update() {
}
}
-
+void StreamPlayer::_do_stop() {
+ stop();
+ emit_signal("finished");
+}
void StreamPlayer::_notification(int p_what) {
@@ -181,7 +184,7 @@ void StreamPlayer::stop() {
stop_request=false;
playback->stop();
resampler.flush();
- emit_signal("finished");
+
//set_idle_process(false);
}
@@ -381,6 +384,7 @@ void StreamPlayer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_set_play","play"),&StreamPlayer::_set_play);
ObjectTypeDB::bind_method(_MD("_get_play"),&StreamPlayer::_get_play);
+ ObjectTypeDB::bind_method(_MD("_do_stop"),&StreamPlayer::_do_stop);
ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/play"), _SCS("_set_play"), _SCS("_get_play") );
diff --git a/scene/audio/stream_player.h b/scene/audio/stream_player.h
index 475139c2a4..4facc3c816 100644
--- a/scene/audio/stream_player.h
+++ b/scene/audio/stream_player.h
@@ -71,6 +71,8 @@ class StreamPlayer : public Node {
AudioRBResampler resampler;
+ void _do_stop();
+
bool _play;
void _set_play(bool p_play);
bool _get_play() const;
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index d7632b14b8..699062fee4 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -31,6 +31,7 @@
#include "print_string.h"
#include "button_group.h"
#include "scene/scene_string_names.h"
+#include "scene/main/viewport.h"
void BaseButton::_input_event(InputEvent p_event) {
@@ -415,7 +416,11 @@ Ref<ShortCut> BaseButton:: get_shortcut() const {
void BaseButton::_unhandled_input(InputEvent p_event) {
- if (!is_disabled() && is_visible() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
+ if (!is_disabled() && is_visible() && p_event.is_pressed() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
+
+ if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this))
+ return; //ignore because of modal window
+
if (is_toggle_mode()) {
set_pressed(!is_pressed());
emit_signal("toggled",is_pressed());
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index d6bbdf2d21..06f8c27957 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -72,13 +72,16 @@ void ColorPicker::_notification(int p_what) {
_update_color();
}
- case NOTIFICATION_VISIBILITY_CHANGED: {
- c_text->call_deferred("grab_focus");
- c_text->call_deferred("select");
- } break;
+
}
}
+void ColorPicker::set_focus_on_line_edit() {
+
+ c_text->grab_focus();
+ c_text->select();
+}
+
void ColorPicker::_update_controls() {
if (edit_alpha) {
@@ -628,6 +631,7 @@ void ColorPickerButton::pressed() {
popup->set_pos(get_global_pos()-Size2(0,ms.height));
popup->set_size(ms);
popup->popup();
+ picker->set_focus_on_line_edit();
}
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index f5de982200..b9ef1f1e2f 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -107,6 +107,7 @@ public:
void set_raw_mode(bool p_enabled);
bool is_raw_mode() const;
+ void set_focus_on_line_edit();
ColorPicker();
};
diff --git a/scene/gui/color_ramp_edit.cpp b/scene/gui/color_ramp_edit.cpp
index 50e1ffbec9..b7347f00dc 100644
--- a/scene/gui/color_ramp_edit.cpp
+++ b/scene/gui/color_ramp_edit.cpp
@@ -271,7 +271,9 @@ void ColorRampEdit::_input_event(const InputEvent& p_event) {
void ColorRampEdit::_notification(int p_what) {
if (p_what==NOTIFICATION_ENTER_TREE) {
- picker->connect("color_changed",this,"_color_changed");
+ if (!picker->is_connected("color_changed",this,"_color_changed")) {
+ picker->connect("color_changed",this,"_color_changed");
+ }
}
if (p_what==NOTIFICATION_DRAW) {
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 2e28baa137..fc27c0d24f 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -49,14 +49,22 @@
Variant Control::edit_get_state() const {
- return get_rect();
+ Dictionary s;
+ s["rect"]=get_rect();
+ s["rot"]=get_rotation();
+ s["scale"]=get_scale();
+ return s;
}
void Control::edit_set_state(const Variant& p_state) {
- Rect2 state=p_state;
+ Dictionary s=p_state;
+
+ Rect2 state=s["rect"];
set_pos(state.pos);
set_size(state.size);
+ set_rotation(s["rot"]);
+ set_scale(s["scale"]);
}
void Control::set_custom_minimum_size(const Size2& p_custom) {
@@ -754,6 +762,11 @@ bool Control::is_window_modal_on_top() const {
return get_viewport()->_gui_is_modal_on_top(this);
}
+uint64_t Control::get_modal_frame() const {
+
+ return data.modal_frame;
+}
+
Size2 Control::get_minimum_size() const {
@@ -1829,6 +1842,7 @@ void Control::show_modal(bool p_exclusive) {
raise();
data.modal_exclusive=p_exclusive;
data.MI=get_viewport()->_gui_show_modal(this);
+ data.modal_frame=OS::get_singleton()->get_frames_drawn();
}
@@ -2539,6 +2553,7 @@ Control::Control() {
data.parent_canvas_item=NULL;
data.scale=Vector2(1,1);
data.drag_owner=0;
+ data.modal_frame=0;
for (int i=0;i<4;i++) {
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 07a28de1ea..830ebd1620 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -132,6 +132,7 @@ private:
ObjectID drag_owner;
bool modal;
bool modal_exclusive;
+ uint64_t modal_frame; //frame used to put something as modal
Ref<Theme> theme;
Control *theme_owner;
String tooltip;
@@ -249,6 +250,7 @@ public:
Size2 get_custom_minimum_size() const;
bool is_window_modal_on_top() const;
+ uint64_t get_modal_frame() const; //frame in which this was made modal
Control *get_parent_control() const;
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index dde9768a6d..5e6622b3f8 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -156,6 +156,7 @@ void GridContainer::_notification(int p_what) {
void GridContainer::set_columns(int p_columns) {
+ ERR_FAIL_COND(p_columns<1);
columns=p_columns;
queue_sort();
minimum_size_changed();
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 5379836746..d63c483ef9 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -1245,6 +1245,19 @@ real_t ItemList::get_icon_scale() const {
return icon_scale;
}
+Vector<int> ItemList::get_selected_items() {
+ Vector<int> selected;
+ for (int i = 0; i < items.size(); i++) {
+ if (items[i].selected) {
+ selected.push_back(i);
+ if (this->select_mode == SELECT_SINGLE) {
+ break;
+ }
+ }
+ }
+ return selected;
+}
+
void ItemList::_bind_methods(){
ObjectTypeDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true));
@@ -1277,6 +1290,7 @@ void ItemList::_bind_methods(){
ObjectTypeDB::bind_method(_MD("select","idx","single"),&ItemList::select,DEFVAL(true));
ObjectTypeDB::bind_method(_MD("unselect","idx"),&ItemList::unselect);
ObjectTypeDB::bind_method(_MD("is_selected","idx"),&ItemList::is_selected);
+ ObjectTypeDB::bind_method(_MD("get_selected_items"),&ItemList::get_selected_items);
ObjectTypeDB::bind_method(_MD("get_item_count"),&ItemList::get_item_count);
ObjectTypeDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item);
@@ -1330,8 +1344,6 @@ void ItemList::_bind_methods(){
ADD_SIGNAL( MethodInfo("item_activated",PropertyInfo(Variant::INT,"index")));
}
-
-
ItemList::ItemList() {
current=-1;
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index aa6dd64c50..e1902d1c1f 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -144,6 +144,7 @@ public:
void select(int p_idx,bool p_single=true);
void unselect(int p_idx);
bool is_selected(int p_idx) const;
+ Vector<int> get_selected_items();
void set_current(int p_current);
int get_current() const;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 579a6e2f0a..c025e4c706 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -108,7 +108,7 @@ void LineEdit::_input_event(InputEvent p_event) {
selection.doubleclick=false;
if (OS::get_singleton()->has_virtual_keyboard())
- OS::get_singleton()->show_virtual_keyboard(get_text(),get_global_rect());
+ OS::get_singleton()->show_virtual_keyboard(text,get_global_rect());
}
update();
@@ -556,7 +556,9 @@ void LineEdit::_notification(int p_what) {
cursor_set_blink_enabled(EDITOR_DEF("text_editor/caret_blink", false));
cursor_set_blink_speed(EDITOR_DEF("text_editor/caret_blink_speed", 0.65));
- EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");
+ if (!EditorSettings::get_singleton()->is_connected("settings_changed",this,"_editor_settings_changed")) {
+ EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");
+ }
}
} break;
#endif
@@ -634,14 +636,19 @@ void LineEdit::_notification(int p_what) {
Color font_color_selected=get_color("font_color_selected");
Color cursor_color=get_color("cursor_color");
+ const String& t = text.empty() ? placeholder : text;
+ // draw placeholder color
+ if(text.empty())
+ font_color.a *= placeholder_alpha;
+
while(true) {
//end of string, break!
- if (char_ofs>=text.length())
+ if (char_ofs>=t.length())
break;
- CharType cchar=pass?'*':text[char_ofs];
- CharType next=pass?'*':text[char_ofs+1];
+ CharType cchar=pass?'*':t[char_ofs];
+ CharType next=pass?'*':t[char_ofs+1];
int char_width=font->get_char_size( cchar,next ).width;
// end of widget, break!
@@ -678,7 +685,7 @@ void LineEdit::_notification(int p_what) {
}
if (OS::get_singleton()->has_virtual_keyboard())
- OS::get_singleton()->show_virtual_keyboard(get_text(),get_global_rect());
+ OS::get_singleton()->show_virtual_keyboard(text,get_global_rect());
} break;
case NOTIFICATION_FOCUS_EXIT: {
@@ -938,6 +945,29 @@ String LineEdit::get_text() const {
return text;
}
+void LineEdit::set_placeholder(String p_text) {
+
+ placeholder = p_text;
+ update();
+}
+
+String LineEdit::get_placeholder() const {
+
+ return placeholder;
+}
+
+
+void LineEdit::set_placeholder_alpha(float p_alpha) {
+
+ placeholder_alpha = p_alpha;
+ update();
+}
+
+float LineEdit::get_placeholder_alpha() const {
+
+ return placeholder_alpha;
+}
+
void LineEdit::set_cursor_pos(int p_pos) {
if (p_pos>(int)text.length())
@@ -1223,6 +1253,10 @@ void LineEdit::_bind_methods() {
ObjectTypeDB::bind_method(_MD("select_all"),&LineEdit::select_all);
ObjectTypeDB::bind_method(_MD("set_text","text"),&LineEdit::set_text);
ObjectTypeDB::bind_method(_MD("get_text"),&LineEdit::get_text);
+ ObjectTypeDB::bind_method(_MD("set_placeholder","text"),&LineEdit::set_placeholder);
+ ObjectTypeDB::bind_method(_MD("get_placeholder"),&LineEdit::get_placeholder);
+ ObjectTypeDB::bind_method(_MD("set_placeholder_alpha","alpha"),&LineEdit::set_placeholder_alpha);
+ ObjectTypeDB::bind_method(_MD("get_placeholder_alpha"),&LineEdit::get_placeholder_alpha);
ObjectTypeDB::bind_method(_MD("set_cursor_pos","pos"),&LineEdit::set_cursor_pos);
ObjectTypeDB::bind_method(_MD("get_cursor_pos"),&LineEdit::get_cursor_pos);
ObjectTypeDB::bind_method(_MD("cursor_set_blink_enabled", "enable"),&LineEdit::cursor_set_blink_enabled);
@@ -1257,6 +1291,8 @@ void LineEdit::_bind_methods() {
BIND_CONSTANT( MENU_MAX );
ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text" ), _SCS("set_text"),_SCS("get_text") );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "placeholder/text" ), _SCS("set_placeholder"),_SCS("get_placeholder") );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::REAL, "placeholder/alpha",PROPERTY_HINT_RANGE,"0,1,0.001" ), _SCS("set_placeholder_alpha"),_SCS("get_placeholder_alpha") );
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), _SCS("set_align"), _SCS("get_align"));
ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "max_length" ), _SCS("set_max_length"),_SCS("get_max_length") );
ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "editable" ), _SCS("set_editable"),_SCS("is_editable") );
@@ -1275,6 +1311,7 @@ LineEdit::LineEdit() {
window_has_focus=true;
max_length = 0;
pass=false;
+ placeholder_alpha=0.6;
selection_clear();
set_focus_mode( FOCUS_ALL );
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index e4da0f0b87..112e4ad55e 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -67,6 +67,8 @@ private:
String undo_text;
String text;
+ String placeholder;
+ float placeholder_alpha;
PopupMenu *menu;
@@ -135,6 +137,10 @@ public:
void delete_text(int p_from_column, int p_to_column);
void set_text(String p_text);
String get_text() const;
+ void set_placeholder(String p_text);
+ String get_placeholder() const;
+ void set_placeholder_alpha(float p_alpha);
+ float get_placeholder_alpha() const;
void set_cursor_pos(int p_pos);
int get_cursor_pos() const;
void set_max_length(int p_max_length);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 6fd6137ac8..e106f0dfc6 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -852,6 +852,11 @@ void TextEdit::_notification(int p_what) {
k++;
}
+ // check for space between name and bracket
+ while (k < str.length() && (str[k] == '\t' || str[k] == ' ')) {
+ k++;
+ }
+
if (str[k] == '(') {
in_function_name = true;
}
@@ -1973,6 +1978,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
}
} break;
case KEY_TAB: {
+ if (k.mod.command) break; // avoid tab when command
if (readonly)
break;
@@ -4541,6 +4547,7 @@ TextEdit::TextEdit() {
scroll_past_end_of_file_enabled=false;
auto_brace_completion_enabled=false;
brace_matching_enabled=false;
+ highlight_all_occurrences=false;
auto_indent=false;
insert_mode = false;
window_has_focus=true;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index f8516f8f5d..db14c15db8 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1355,6 +1355,8 @@ void Tree::select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col
switched=true;
}
+ bool emitted_row=false;
+
for (int i=0;i<columns.size();i++) {
TreeItem::Cell &c=p_current->cells[i];
@@ -1373,7 +1375,10 @@ void Tree::select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col
selected_item=p_selected;
selected_col=0;
selected_item=p_selected;
- emit_signal("item_selected");
+ if (!emitted_row) {
+ emit_signal("item_selected");
+ emitted_row=true;
+ }
//if (p_col==i)
// p_current->selected_signal.call(p_col);
}
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 11b400d4a9..bea6e75aef 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2085,6 +2085,15 @@ bool Node::is_owned_by_parent() const {
return data.parent_owned;
}
+void Node::set_display_folded(bool p_folded) {
+ data.display_folded=p_folded;
+}
+
+bool Node::is_displayed_folded() const {
+
+ return data.display_folded;
+}
+
void Node::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_add_child_below_node","node:Node","child_node:Node","legible_unique_name"),&Node::add_child_below_node,DEFVAL(false));
@@ -2140,6 +2149,8 @@ void Node::_bind_methods() {
ObjectTypeDB::bind_method(_MD("can_process"),&Node::can_process);
ObjectTypeDB::bind_method(_MD("print_stray_nodes"),&Node::_print_stray_nodes);
ObjectTypeDB::bind_method(_MD("get_position_in_parent"),&Node::get_position_in_parent);
+ ObjectTypeDB::bind_method(_MD("set_display_folded","fold"),&Node::set_display_folded);
+ ObjectTypeDB::bind_method(_MD("is_displayed_folded"),&Node::is_displayed_folded);
ObjectTypeDB::bind_method(_MD("get_tree:SceneTree"),&Node::get_tree);
@@ -2194,6 +2205,7 @@ void Node::_bind_methods() {
//ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/input" ), _SCS("set_process_input"),_SCS("is_processing_input" ) );
//ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "process/unhandled_input" ), _SCS("set_process_unhandled_input"),_SCS("is_processing_unhandled_input" ) );
ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "process/pause_mode",PROPERTY_HINT_ENUM,"Inherit,Stop,Process" ), _SCS("set_pause_mode"),_SCS("get_pause_mode" ) );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "editor/display_folded",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR ), _SCS("set_display_folded"),_SCS("is_displayed_folded" ) );
BIND_VMETHOD( MethodInfo("_process",PropertyInfo(Variant::REAL,"delta")) );
BIND_VMETHOD( MethodInfo("_fixed_process",PropertyInfo(Variant::REAL,"delta")) );
@@ -2231,6 +2243,7 @@ Node::Node() {
data.in_constructor=true;
data.viewport=NULL;
data.use_placeholder=false;
+ data.display_folded=false;
}
Node::~Node() {
@@ -2240,6 +2253,7 @@ Node::~Node() {
data.owned.clear();
data.children.clear();
+
ERR_FAIL_COND(data.parent);
ERR_FAIL_COND(data.children.size());
diff --git a/scene/main/node.h b/scene/main/node.h
index 88334f32f0..dcc3829d15 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -111,6 +111,7 @@ private:
bool in_constructor;
bool use_placeholder;
+ bool display_folded;
} data;
@@ -325,6 +326,8 @@ public:
void update_configuration_warning();
+ void set_display_folded(bool p_folded);
+ bool is_displayed_folded() const;
/* CANVAS */
Node();
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 3c52af1c1e..c6a32d5568 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1331,11 +1331,11 @@ Matrix32 Viewport::_get_input_pre_xform() const {
Matrix32 pre_xf;
if (render_target) {
- ERR_FAIL_COND_V(to_screen_rect.size.x==0,pre_xf);
- ERR_FAIL_COND_V(to_screen_rect.size.y==0,pre_xf);
+ if (to_screen_rect!=Rect2()) {
- pre_xf.elements[2]=-to_screen_rect.pos;
- pre_xf.scale(rect.size/to_screen_rect.size);
+ pre_xf.elements[2]=-to_screen_rect.pos;
+ pre_xf.scale(rect.size/to_screen_rect.size);
+ }
} else {
pre_xf.elements[2]=-rect.pos;
@@ -1575,35 +1575,38 @@ void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) {
// _block();
+ InputEvent ev = p_input;
+
//mouse wheel events can't be stopped
- bool cant_stop_me_now = (p_input.type==InputEvent::MOUSE_BUTTON &&
- (p_input.mouse_button.button_index==BUTTON_WHEEL_DOWN ||
- p_input.mouse_button.button_index==BUTTON_WHEEL_UP ||
- p_input.mouse_button.button_index==BUTTON_WHEEL_LEFT ||
- p_input.mouse_button.button_index==BUTTON_WHEEL_RIGHT ) );
+ bool cant_stop_me_now = (ev.type==InputEvent::MOUSE_BUTTON &&
+ (ev.mouse_button.button_index==BUTTON_WHEEL_DOWN ||
+ ev.mouse_button.button_index==BUTTON_WHEEL_UP ||
+ ev.mouse_button.button_index==BUTTON_WHEEL_LEFT ||
+ ev.mouse_button.button_index==BUTTON_WHEEL_RIGHT ) );
CanvasItem *ci=p_control;
while(ci) {
Control *control = ci->cast_to<Control>();
if (control) {
- control->call_multilevel(SceneStringNames::get_singleton()->_input_event,p_input);
+ control->call_multilevel(SceneStringNames::get_singleton()->_input_event,ev);
if (gui.key_event_accepted)
break;
if (!control->is_inside_tree())
break;
- control->emit_signal(SceneStringNames::get_singleton()->input_event,p_input);
+ control->emit_signal(SceneStringNames::get_singleton()->input_event,ev);
if (!control->is_inside_tree() || control->is_set_as_toplevel())
break;
if (gui.key_event_accepted)
break;
- if (!cant_stop_me_now && control->data.stop_mouse && (p_input.type==InputEvent::MOUSE_BUTTON || p_input.type==InputEvent::MOUSE_MOTION))
+ if (!cant_stop_me_now && control->data.stop_mouse && (ev.type==InputEvent::MOUSE_BUTTON || ev.type==InputEvent::MOUSE_MOTION))
break;
}
if (ci->is_set_as_toplevel())
break;
+ ev=ev.xform_by(ci->get_transform()); //transform event upwards
ci=ci->get_parent_item();
}
@@ -1749,8 +1752,9 @@ void Viewport::_gui_input_event(InputEvent p_event) {
Vector2 pos = top->get_global_transform_with_canvas().affine_inverse().xform(mpos);
if (!top->has_point(pos)) {
- if (top->data.modal_exclusive) {
+ if (top->data.modal_exclusive || top->data.modal_frame==OS::get_singleton()->get_frames_drawn()) {
//cancel event, sorry, modal exclusive EATS UP ALL
+ //alternative, you can't pop out a window the same frame it was made modal (fixes many issues)
//get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
get_tree()->set_input_as_handled();
return; // no one gets the event if exclusive NO ONE
@@ -1784,15 +1788,12 @@ void Viewport::_gui_input_event(InputEvent p_event) {
if (p_event.mouse_button.button_index==BUTTON_LEFT) {
gui.drag_accum=Vector2();
gui.drag_attempted=false;
- if (gui.drag_data.get_type()!=Variant::NIL) {
- _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
- }
- gui.drag_data=Variant();
}
}
+
p_event.mouse_button.global_x = pos.x;
p_event.mouse_button.global_y = pos.y;
@@ -1828,30 +1829,55 @@ 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();
+
+ if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+
+ //alternate drop use (when using force_drag(), as proposed by #5342
+ if (gui.mouse_focus && gui.mouse_focus->can_drop_data(pos,gui.drag_data)) {
+ gui.mouse_focus->drop_data(pos,gui.drag_data);
+ }
+
+ gui.drag_data=Variant();
+
+ if (gui.drag_preview) {
+ memdelete( gui.drag_preview );
+ gui.drag_preview=NULL;
+ }
+ _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
+ //change mouse accordingly
+ }
+
+
+
_gui_cancel_tooltip();
//gui.tooltip_popup->hide();
} else {
- if (gui.drag_preview && p_event.mouse_button.button_index==BUTTON_LEFT) {
- memdelete( gui.drag_preview );
- gui.drag_preview=NULL;
- }
- if (!gui.mouse_focus) {
- if (gui.mouse_over && gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ if (gui.mouse_over) {
Size2 pos = mpos;
pos = gui.focus_inv_xform.xform(pos);
if (gui.mouse_over->can_drop_data(pos,gui.drag_data)) {
gui.mouse_over->drop_data(pos,gui.drag_data);
}
- gui.drag_data=Variant();
- _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
- //change mouse accordingly
}
+ if (gui.drag_preview && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ memdelete( gui.drag_preview );
+ gui.drag_preview=NULL;
+ }
+
+ gui.drag_data=Variant();
+ _propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
+ //change mouse accordingly
+ }
+
+ if (!gui.mouse_focus) {
+ //release event is only sent if a mouse focus (previously pressed button) exists
break;
}
@@ -1871,10 +1897,10 @@ void Viewport::_gui_input_event(InputEvent p_event) {
gui.mouse_focus_button=-1;
}
- if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
+ /*if (gui.drag_data.get_type()!=Variant::NIL && p_event.mouse_button.button_index==BUTTON_LEFT) {
_propagate_viewport_notification(this,NOTIFICATION_DRAG_END);
gui.drag_data=Variant(); //always clear
- }
+ }*/
get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME,"windows","_cancel_input_ID",p_event.ID);
@@ -2032,7 +2058,12 @@ void Viewport::_gui_input_event(InputEvent p_event) {
case InputEvent::JOYSTICK_BUTTON:
case InputEvent::KEY: {
- if (gui.key_focus) {
+
+ if (gui.key_focus && !gui.key_focus->is_visible()) {
+ gui.key_focus->release_focus();
+ }
+
+ if (gui.key_focus) {
gui.key_event_accepted=false;
if (gui.key_focus->can_process()) {
@@ -2172,6 +2203,9 @@ void Viewport::_gui_remove_from_modal_stack(List<Control*>::Element *MI,ObjectID
void Viewport::_gui_force_drag(Control *p_base, const Variant& p_data, Control *p_control) {
+ ERR_EXPLAIN("Drag data must be a value");
+ ERR_FAIL_COND(p_data.get_type()==Variant::NIL);
+
gui.drag_data=p_data;
gui.mouse_focus=NULL;
@@ -2368,8 +2402,8 @@ void Viewport::input(const InputEvent& p_event) {
ERR_FAIL_COND(!is_inside_tree());
+ get_tree()->_call_input_pause(input_group,"_input",p_event); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input
_gui_input_event(p_event);
- get_tree()->_call_input_pause(input_group,"_input",p_event);
//get_tree()->call_group(SceneTree::GROUP_CALL_REVERSE|SceneTree::GROUP_CALL_REALTIME|SceneTree::GROUP_CALL_MULIILEVEL,gui_input_group,"_gui_input",p_event); //special one for GUI, as controls use their own process check
}
@@ -2498,6 +2532,9 @@ Variant Viewport::gui_get_drag_data() const {
return gui.drag_data;
}
+Control *Viewport::get_modal_stack_top() const {
+ return gui.modal_stack.size()?gui.modal_stack.back()->get():NULL;
+}
String Viewport::get_configuration_warning() const {
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 545020dfc7..aaa640e0e6 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -374,6 +374,7 @@ public:
bool gui_has_modal_stack() const;
Variant gui_get_drag_data() const;
+ Control *get_modal_stack_top() const;
virtual String get_configuration_warning() const;
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 8be39e3021..098801bcf5 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -38,8 +38,6 @@ bool Animation::_set(const StringName& p_name, const Variant& p_value) {
set_length(p_value);
else if (name=="loop")
set_loop(p_value);
- else if (name=="loop_interpolation")
- set_loop_interpolation(p_value);
else if (name=="step")
set_step(p_value);
else if (name.begins_with("tracks/")) {
@@ -270,8 +268,6 @@ bool Animation::_get(const StringName& p_name,Variant &r_ret) const {
r_ret= length;
else if (name=="loop")
r_ret= loop;
- else if (name=="loop_interpolation")
- r_ret= loop_interpolation;
else if (name=="step")
r_ret= step;
else if (name.begins_with("tracks/")) {
@@ -437,7 +433,6 @@ void Animation::_get_property_list( List<PropertyInfo> *p_list) const {
p_list->push_back( PropertyInfo( Variant::REAL, "length", PROPERTY_HINT_RANGE, "0.001,99999,0.001"));
p_list->push_back( PropertyInfo( Variant::BOOL, "loop" ));
- p_list->push_back( PropertyInfo( Variant::BOOL, "loop_interpolation"));
p_list->push_back( PropertyInfo( Variant::REAL, "step", PROPERTY_HINT_RANGE, "0,4096,0.001" ));
for (int i=0;i<tracks.size();i++) {
@@ -1244,7 +1239,7 @@ T Animation::_interpolate( const Vector< TKey<T> >& p_keys, float p_time, Inter
float c=0;
// prepare for all cases of interpolation
- if (loop && loop_interpolation) {
+ if (loop) {
// loop
if (idx>=0) {
@@ -1632,19 +1627,10 @@ void Animation::set_loop(bool p_enabled) {
loop=p_enabled;
emit_changed();
}
-void Animation::set_loop_interpolation(bool p_enabled) {
-
- loop_interpolation=p_enabled;
- emit_changed();
-}
bool Animation::has_loop() const {
return loop;
}
-bool Animation::has_loop_interpolation() const {
-
- return loop_interpolation;
-}
void Animation::track_move_up(int p_track) {
@@ -1741,9 +1727,7 @@ void Animation::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_length"),&Animation::get_length);
ObjectTypeDB::bind_method(_MD("set_loop","enabled"),&Animation::set_loop);
- ObjectTypeDB::bind_method(_MD("set_loop_interpolation","enabled"),&Animation::set_loop_interpolation);
ObjectTypeDB::bind_method(_MD("has_loop"),&Animation::has_loop);
- ObjectTypeDB::bind_method(_MD("has_loop_interpolation"),&Animation::has_loop_interpolation);
ObjectTypeDB::bind_method(_MD("set_step","size_sec"),&Animation::set_step);
ObjectTypeDB::bind_method(_MD("get_step"),&Animation::get_step);
@@ -1771,7 +1755,6 @@ void Animation::clear() {
memdelete( tracks[i] );
tracks.clear();
loop=false;
- loop_interpolation=true;
length=1;
}
@@ -2031,7 +2014,6 @@ Animation::Animation() {
step=0.1;
loop=false;
- loop_interpolation=true;
length=1;
}
@@ -2042,3 +2024,5 @@ Animation::~Animation() {
memdelete( tracks[i] );
}
+
+
diff --git a/scene/resources/animation.h b/scene/resources/animation.h
index ee643c9678..6c8d7252aa 100644
--- a/scene/resources/animation.h
+++ b/scene/resources/animation.h
@@ -172,7 +172,6 @@ private:
float length;
float step;
bool loop;
- bool loop_interpolation;
// bind helpers
private:
@@ -279,9 +278,7 @@ public:
float get_length() const;
void set_loop(bool p_enabled);
- void set_loop_interpolation(bool p_enabled);
bool has_loop() const;
- bool has_loop_interpolation() const;
void set_step(float p_step);
float get_step() const;
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index ac528e6659..4f5eed8796 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -375,7 +375,7 @@ Error SceneState::_parse_node(Node *p_owner,Node *p_node,int p_parent_idx, Map<S
PackState ps;
ps.node=node;
ps.state=state;
- pack_state_stack.push_front(ps);
+ pack_state_stack.push_back(ps);
instanced_by_owner=false;
}
}
@@ -545,6 +545,7 @@ https://github.com/godotengine/godot/issues/3127
}
#endif
+
if (exists) {
//check if already exists and did not change
@@ -556,6 +557,7 @@ https://github.com/godotengine/godot/issues/3127
if (Math::abs(a-b)<CMP_EPSILON)
continue;
} else if (bool(Variant::evaluate(Variant::OP_EQUAL,value,original))) {
+
continue;
}
}
@@ -729,6 +731,7 @@ Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,
List<MethodInfo> _signals;
p_node->get_signal_list(&_signals);
+ _signals.sort();
//ERR_FAIL_COND_V( !node_map.has(p_node), ERR_BUG);
//NodeData &nd = nodes[node_map[p_node]];
@@ -738,6 +741,9 @@ Error SceneState::_parse_connections(Node *p_owner,Node *p_node, Map<StringName,
List<Node::Connection> conns;
p_node->get_signal_connection_list(E->get().name,&conns);
+
+ conns.sort();
+
for(List<Node::Connection>::Element *F=conns.front();F;F=F->next()) {
const Node::Connection &c = F->get();
diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h
index 6bde508d72..3b6c0898e0 100644
--- a/scene/resources/packed_scene.h
+++ b/scene/resources/packed_scene.h
@@ -196,6 +196,7 @@ class PackedScene : public Resource {
protected:
+ virtual bool editor_can_reload_from_file() { return false; } // this is handled by editor better
static void _bind_methods();
public:
diff --git a/scene/resources/sample.cpp b/scene/resources/sample.cpp
index 87fcfc425d..aae4e85a27 100644
--- a/scene/resources/sample.cpp
+++ b/scene/resources/sample.cpp
@@ -187,6 +187,8 @@ RID Sample::get_rid() const {
return sample;
}
+
+
void Sample::_bind_methods(){
diff --git a/scene/resources/sample.h b/scene/resources/sample.h
index 0a88167233..18672e41c0 100644
--- a/scene/resources/sample.h
+++ b/scene/resources/sample.h
@@ -75,6 +75,7 @@ protected:
public:
+
void create(Format p_format, bool p_stereo, int p_length);
Format get_format() const;
diff --git a/scene/resources/sample_library.cpp b/scene/resources/sample_library.cpp
index 5b70ee0e11..73517b180e 100644
--- a/scene/resources/sample_library.cpp
+++ b/scene/resources/sample_library.cpp
@@ -122,9 +122,17 @@ bool SampleLibrary::has_sample(const StringName& p_name) const {
void SampleLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
+
+ List<PropertyInfo> tpl;
for(Map<StringName,SampleData>::Element *E=sample_map.front();E;E=E->next()) {
- p_list->push_back( PropertyInfo( Variant::DICTIONARY, "samples/"+E->key(),PROPERTY_HINT_RESOURCE_TYPE,"Sample",PROPERTY_USAGE_NOEDITOR ) );
+ tpl.push_back( PropertyInfo( Variant::DICTIONARY, "samples/"+E->key(),PROPERTY_HINT_RESOURCE_TYPE,"Sample",PROPERTY_USAGE_NOEDITOR ) );
+ }
+
+ tpl.sort();
+ //sort so order is kept
+ for(List<PropertyInfo>::Element *E=tpl.front();E;E=E->next()) {
+ p_list->push_back(E->get());
}
}
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index c7e2fc4e73..95645107d4 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -67,12 +67,17 @@ Error ResourceInteractiveLoaderText::_parse_sub_resource(VariantParser::Stream*
String path = local_path+"::"+itos(index);
- if (!ResourceCache::has(path)) {
- r_err_str="Can't load cached sub-resource: "+path;
- return ERR_PARSE_ERROR;
- }
+ if (!ignore_resource_parsing) {
- r_res=RES(ResourceCache::get(path));
+ if (!ResourceCache::has(path)) {
+ r_err_str="Can't load cached sub-resource: "+path;
+ return ERR_PARSE_ERROR;
+ }
+
+ r_res=RES(ResourceCache::get(path));
+ } else {
+ r_res=RES();
+ }
VariantParser::get_token(p_stream,token,line,r_err_str);
if (token.type!=VariantParser::TK_PARENTHESIS_CLOSE) {
@@ -95,25 +100,29 @@ Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream*
int id = token.value;
+ if (!ignore_resource_parsing) {
- if (!ext_resources.has(id)) {
- r_err_str="Can't load cached ext-resource #"+itos(id);
- return ERR_PARSE_ERROR;
- }
+ if (!ext_resources.has(id)) {
+ r_err_str="Can't load cached ext-resource #"+itos(id);
+ return ERR_PARSE_ERROR;
+ }
- String path = ext_resources[id].path;
- String type = ext_resources[id].type;
+ String path = ext_resources[id].path;
+ String type = ext_resources[id].type;
- if (path.find("://")==-1 && path.is_rel_path()) {
- // path is relative to file being loaded, so convert to a resource path
- path=Globals::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
+ if (path.find("://")==-1 && path.is_rel_path()) {
+ // path is relative to file being loaded, so convert to a resource path
+ path=Globals::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
- }
+ }
- r_res=ResourceLoader::load(path,type);
+ r_res=ResourceLoader::load(path,type);
- if (r_res.is_null()) {
- WARN_PRINT(String("Couldn't load external resource: "+path).utf8().get_data());
+ if (r_res.is_null()) {
+ WARN_PRINT(String("Couldn't load external resource: "+path).utf8().get_data());
+ }
+ } else {
+ r_res=RES();
}
VariantParser::get_token(p_stream,token,line,r_err_str);
@@ -625,6 +634,7 @@ void ResourceInteractiveLoaderText::get_dependencies(FileAccess *f,List<String>
open(f);
+ ignore_resource_parsing=true;
ERR_FAIL_COND(error!=OK);
while(next_tag.name=="ext_resource") {
@@ -662,6 +672,7 @@ void ResourceInteractiveLoaderText::get_dependencies(FileAccess *f,List<String>
Error err = VariantParser::parse_tag(&stream,lines,error_text,next_tag,&rp);
if (err) {
+ print_line(error_text+" - "+itos(lines));
error_text="Unexpected end of file";
_printerr();
error=ERR_FILE_CORRUPT;
@@ -676,7 +687,7 @@ Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const
open(p_f,true);
ERR_FAIL_COND_V(error!=OK,error);
-
+ ignore_resource_parsing=true;
//FileAccess
FileAccess *fw = NULL;
@@ -794,7 +805,7 @@ void ResourceInteractiveLoaderText::open(FileAccess *p_f,bool p_skip_first_tag)
stream.f=f;
is_scene=false;
-
+ ignore_resource_parsing=false;
resource_current=0;
@@ -879,6 +890,8 @@ String ResourceInteractiveLoaderText::recognize(FileAccess *p_f) {
stream.f=f;
+ ignore_resource_parsing=true;
+
VariantParser::Tag tag;
Error err = VariantParser::parse_tag(&stream,lines,error_text,tag);
@@ -1296,7 +1309,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path,const RES& p_re
if ((PE->get().usage&PROPERTY_USAGE_STORE_IF_NONZERO && value.is_zero())||(PE->get().usage&PROPERTY_USAGE_STORE_IF_NONONE && value.is_one()) )
continue;
- if (PE->get().type==Variant::OBJECT && value.is_zero() && (!PE->get().usage&PROPERTY_USAGE_STORE_IF_NULL))
+ if (PE->get().type==Variant::OBJECT && value.is_zero() && !(PE->get().usage&PROPERTY_USAGE_STORE_IF_NULL))
continue;
String vars;
diff --git a/scene/resources/scene_format_text.h b/scene/resources/scene_format_text.h
index 8dbfbfda48..6122a1f9d8 100644
--- a/scene/resources/scene_format_text.h
+++ b/scene/resources/scene_format_text.h
@@ -56,7 +56,7 @@ class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
bool is_scene;
String res_type;
-
+ bool ignore_resource_parsing;
// Map<String,String> remaps;
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 2fa00c7da7..726b1938c4 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -98,10 +98,6 @@ Texture::Texture() {
-bool ImageTexture::can_reload_from_file() {
-
- return true;
-}
void ImageTexture::reload_from_file() {
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 103b425cd8..05ea833978 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -103,7 +103,6 @@ private:
float lossy_storage_quality;
protected:
- virtual bool can_reload_from_file();
virtual void reload_from_file();
bool _set(const StringName& p_name, const Variant& p_value);