summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/particles_2d.cpp7
-rw-r--r--scene/2d/particles_2d.h1
-rw-r--r--scene/2d/tile_map.cpp2
-rw-r--r--scene/3d/camera.cpp5
-rw-r--r--scene/3d/particles.cpp7
-rw-r--r--scene/3d/particles.h1
-rw-r--r--scene/3d/skeleton.cpp24
-rw-r--r--scene/3d/skeleton.h2
-rw-r--r--scene/3d/spatial.cpp8
-rw-r--r--scene/3d/voxel_light_baker.cpp4
-rw-r--r--scene/animation/animation_tree_player.cpp21
-rw-r--r--scene/animation/animation_tree_player.h1
-rw-r--r--scene/gui/button.h3
-rw-r--r--scene/gui/color_picker.cpp18
-rw-r--r--scene/gui/color_picker.h4
-rw-r--r--scene/gui/menu_button.cpp28
-rw-r--r--scene/gui/menu_button.h5
-rw-r--r--scene/gui/option_button.cpp77
-rw-r--r--scene/gui/option_button.h2
-rw-r--r--scene/gui/split_container.cpp66
-rw-r--r--scene/gui/split_container.h4
-rw-r--r--scene/gui/text_edit.cpp58
-rw-r--r--scene/gui/text_edit.h4
-rw-r--r--scene/gui/tree.cpp52
-rw-r--r--scene/gui/tree.h8
-rw-r--r--scene/main/node.cpp3
-rw-r--r--scene/main/scene_tree.cpp15
-rw-r--r--scene/main/scene_tree.h9
-rw-r--r--scene/main/viewport.cpp10
-rw-r--r--scene/main/viewport.h1
-rw-r--r--scene/register_scene_types.cpp16
-rw-r--r--scene/resources/material.cpp2
-rw-r--r--scene/resources/shader.cpp77
-rw-r--r--scene/resources/shader.h17
-rw-r--r--scene/resources/texture.cpp2
-rw-r--r--scene/resources/tile_set.cpp4
36 files changed, 368 insertions, 200 deletions
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index 7d53557216..cc3829ad07 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -35,8 +35,7 @@
void Particles2D::set_emitting(bool p_emitting) {
- emitting = p_emitting;
- VS::get_singleton()->particles_set_emitting(particles, emitting);
+ VS::get_singleton()->particles_set_emitting(particles, p_emitting);
}
void Particles2D::set_amount(int p_amount) {
@@ -56,7 +55,7 @@ void Particles2D::set_one_shot(bool p_enable) {
one_shot = p_enable;
VS::get_singleton()->particles_set_one_shot(particles, one_shot);
- if (!one_shot && emitting)
+ if (!one_shot && is_emitting())
VisualServer::get_singleton()->particles_restart(particles);
}
void Particles2D::set_pre_process_time(float p_time) {
@@ -134,7 +133,7 @@ void Particles2D::set_speed_scale(float p_scale) {
bool Particles2D::is_emitting() const {
- return emitting;
+ return VS::get_singleton()->particles_get_emitting(particles);
}
int Particles2D::get_amount() const {
diff --git a/scene/2d/particles_2d.h b/scene/2d/particles_2d.h
index 6946f2a799..455a663693 100644
--- a/scene/2d/particles_2d.h
+++ b/scene/2d/particles_2d.h
@@ -47,7 +47,6 @@ public:
private:
RID particles;
- bool emitting;
bool one_shot;
int amount;
float lifetime;
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 7b30ddaa56..a83c1c1cad 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -1527,7 +1527,7 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("_recreate_quadrants"), &TileMap::_recreate_quadrants);
ClassDB::bind_method(D_METHOD("_update_dirty_quadrants"), &TileMap::_update_dirty_quadrants);
- ClassDB::bind_method(D_METHOD("update_bitmask_area"), &TileMap::update_bitmask_area);
+ ClassDB::bind_method(D_METHOD("update_bitmask_area", "position"), &TileMap::update_bitmask_area);
ClassDB::bind_method(D_METHOD("update_bitmask_region", "start", "end"), &TileMap::update_bitmask_region, DEFVAL(Vector2()), DEFVAL(Vector2()));
ClassDB::bind_method(D_METHOD("_set_tile_data"), &TileMap::_set_tile_data);
diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp
index c74abb7e2d..7143310036 100644
--- a/scene/3d/camera.cpp
+++ b/scene/3d/camera.cpp
@@ -70,6 +70,9 @@ void Camera::_validate_property(PropertyInfo &p_property) const {
void Camera::_update_camera() {
+ if (!is_inside_tree())
+ return;
+
Transform tr = get_camera_transform();
tr.origin += tr.basis.get_axis(1) * v_offset;
tr.origin += tr.basis.get_axis(0) * h_offset;
@@ -81,7 +84,7 @@ void Camera::_update_camera() {
get_viewport()->_camera_transform_changed_notify();
*/
- if (!is_inside_tree() || get_tree()->is_node_being_edited(this) || !is_current())
+ if (get_tree()->is_node_being_edited(this) || !is_current())
return;
get_viewport()->_camera_transform_changed_notify();
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index b445ccc5a9..9108973cbf 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -42,8 +42,7 @@ PoolVector<Face3> Particles::get_faces(uint32_t p_usage_flags) const {
void Particles::set_emitting(bool p_emitting) {
- emitting = p_emitting;
- VS::get_singleton()->particles_set_emitting(particles, emitting);
+ VS::get_singleton()->particles_set_emitting(particles, p_emitting);
}
void Particles::set_amount(int p_amount) {
@@ -63,7 +62,7 @@ void Particles::set_one_shot(bool p_one_shot) {
one_shot = p_one_shot;
VS::get_singleton()->particles_set_one_shot(particles, one_shot);
- if (!one_shot && emitting)
+ if (!one_shot && is_emitting())
VisualServer::get_singleton()->particles_restart(particles);
}
@@ -113,7 +112,7 @@ void Particles::set_speed_scale(float p_scale) {
bool Particles::is_emitting() const {
- return emitting;
+ return VS::get_singleton()->particles_get_emitting(particles);
}
int Particles::get_amount() const {
diff --git a/scene/3d/particles.h b/scene/3d/particles.h
index 5b8121e937..24154b5607 100644
--- a/scene/3d/particles.h
+++ b/scene/3d/particles.h
@@ -57,7 +57,6 @@ public:
private:
RID particles;
- bool emitting;
bool one_shot;
int amount;
float lifetime;
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index 3d40bb299a..417fe90d7c 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -153,6 +153,24 @@ void Skeleton::_notification(int p_what) {
case NOTIFICATION_EXIT_WORLD: {
} break;
+ case NOTIFICATION_TRANSFORM_CHANGED: {
+
+ if (dirty)
+ break; //will be eventually updated
+
+ //if moved, just update transforms
+ VisualServer *vs = VisualServer::get_singleton();
+ Bone *bonesptr = &bones[0];
+ int len = bones.size();
+ Transform global_transform = get_global_transform();
+ Transform global_transform_inverse = global_transform.affine_inverse();
+
+ for (int i = 0; i < len; i++) {
+
+ Bone &b = bonesptr[i];
+ vs->skeleton_bone_set_transform(skeleton, i, global_transform * (b.transform_final * global_transform_inverse));
+ }
+ } break;
case NOTIFICATION_UPDATE_SKELETON: {
VisualServer *vs = VisualServer::get_singleton();
@@ -242,9 +260,8 @@ void Skeleton::_notification(int p_what) {
}
}
- Transform transform = b.pose_global * b.rest_global_inverse;
-
- vs->skeleton_bone_set_transform(skeleton, i, global_transform * (transform * global_transform_inverse));
+ b.transform_final = b.pose_global * b.rest_global_inverse;
+ vs->skeleton_bone_set_transform(skeleton, i, global_transform * (b.transform_final * global_transform_inverse));
for (List<uint32_t>::Element *E = b.nodes_bound.front(); E; E = E->next()) {
@@ -548,6 +565,7 @@ Skeleton::Skeleton() {
rest_global_inverse_dirty = true;
dirty = false;
skeleton = VisualServer::get_singleton()->skeleton_create();
+ set_notify_transform(true);
}
Skeleton::~Skeleton() {
diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h
index fdc1100472..11ff728474 100644
--- a/scene/3d/skeleton.h
+++ b/scene/3d/skeleton.h
@@ -57,6 +57,8 @@ class Skeleton : public Spatial {
bool custom_pose_enable;
Transform custom_pose;
+ Transform transform_final;
+
List<uint32_t> nodes_bound;
Bone() {
diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp
index d9f88ac693..e890533ab7 100644
--- a/scene/3d/spatial.cpp
+++ b/scene/3d/spatial.cpp
@@ -558,27 +558,27 @@ bool Spatial::is_visible() const {
void Spatial::rotate(const Vector3 &p_normal, float p_radians) {
Transform t = get_transform();
- t.basis.rotate(p_normal, p_radians);
+ t.basis.rotate_local(p_normal, p_radians); //use local rotation here, as it makes more sense here in tree hierarchy
set_transform(t);
}
void Spatial::rotate_x(float p_radians) {
Transform t = get_transform();
- t.basis.rotate(Vector3(1, 0, 0), p_radians);
+ t.basis.rotate_local(Vector3(1, 0, 0), p_radians);
set_transform(t);
}
void Spatial::rotate_y(float p_radians) {
Transform t = get_transform();
- t.basis.rotate(Vector3(0, 1, 0), p_radians);
+ t.basis.rotate_local(Vector3(0, 1, 0), p_radians);
set_transform(t);
}
void Spatial::rotate_z(float p_radians) {
Transform t = get_transform();
- t.basis.rotate(Vector3(0, 0, 1), p_radians);
+ t.basis.rotate_local(Vector3(0, 0, 1), p_radians);
set_transform(t);
}
diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp
index 17aa649dff..bd7e52d947 100644
--- a/scene/3d/voxel_light_baker.cpp
+++ b/scene/3d/voxel_light_baker.cpp
@@ -1799,7 +1799,6 @@ Vector3 VoxelLightBaker::_compute_ray_trace_at_pos(const Vector3 &p_pos, const V
void VoxelLightBaker::_lightmap_bake_point(uint32_t p_x, LightMap *p_line) {
-
LightMap *pixel = &p_line[p_x];
if (pixel->pos == Vector3())
return;
@@ -1814,7 +1813,6 @@ void VoxelLightBaker::_lightmap_bake_point(uint32_t p_x, LightMap *p_line) {
// pixel->light = Vector3(1, 1, 1);
//}
}
-
}
Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh, LightMapData &r_lightmap, bool (*p_bake_time_func)(void *, float, float), void *p_bake_time_ud) {
@@ -1882,7 +1880,7 @@ Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh
for (int i = 0; i < height; i++) {
- thread_process_array(width,this,&VoxelLightBaker::_lightmap_bake_point,&lightmap_ptr[i*width]);
+ thread_process_array(width, this, &VoxelLightBaker::_lightmap_bake_point, &lightmap_ptr[i * width]);
lines = MAX(lines, i); //for multithread
if (p_bake_time_func) {
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index 32f82fe6b8..a50047e426 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -386,8 +386,6 @@ bool AnimationTreePlayer::_get(const StringName &p_name, Variant &r_ret) const {
void AnimationTreePlayer::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back(PropertyInfo(Variant::NODE_PATH, "base_path"));
- p_list->push_back(PropertyInfo(Variant::NODE_PATH, "master_player"));
p_list->push_back(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_NETWORK));
}
@@ -1140,6 +1138,9 @@ void AnimationTreePlayer::transition_node_set_input_count(const StringName &p_no
n->inputs.resize(p_inputs);
n->input_data.resize(p_inputs);
+
+ _clear_cycle_test();
+
last_error = _cycle_test(out_name);
}
void AnimationTreePlayer::transition_node_set_input_auto_advance(const StringName &p_node, int p_input, bool p_auto_advance) {
@@ -1360,6 +1361,8 @@ void AnimationTreePlayer::remove_node(const StringName &p_node) {
node_map.erase(p_node);
+ _clear_cycle_test();
+
// compute last error again, just in case
last_error = _cycle_test(out_name);
dirty_caches = true;
@@ -1387,6 +1390,14 @@ AnimationTreePlayer::ConnectError AnimationTreePlayer::_cycle_test(const StringN
return CONNECT_OK;
}
+// Use this function to not alter next complete _cycle_test().
+void AnimationTreePlayer::_clear_cycle_test() {
+ for (Map<StringName, NodeBase *>::Element *E = node_map.front(); E; E = E->next()) {
+ NodeBase *nb = E->get();
+ nb->cycletest = false;
+ }
+}
+
Error AnimationTreePlayer::connect_nodes(const StringName &p_src_node, const StringName &p_dst_node, int p_dst_input) {
ERR_FAIL_COND_V(!node_map.has(p_src_node), ERR_INVALID_PARAMETER);
@@ -1411,11 +1422,7 @@ Error AnimationTreePlayer::connect_nodes(const StringName &p_src_node, const Str
dst->inputs[p_dst_input].node = p_src_node;
- for (Map<StringName, NodeBase *>::Element *E = node_map.front(); E; E = E->next()) {
-
- NodeBase *nb = E->get();
- nb->cycletest = false;
- }
+ _clear_cycle_test();
last_error = _cycle_test(out_name);
if (last_error) {
diff --git a/scene/animation/animation_tree_player.h b/scene/animation/animation_tree_player.h
index c49b0c4d1b..7213441d6e 100644
--- a/scene/animation/animation_tree_player.h
+++ b/scene/animation/animation_tree_player.h
@@ -317,6 +317,7 @@ private:
bool reset_request;
ConnectError _cycle_test(const StringName &p_at_node);
+ void _clear_cycle_test();
Track *_find_track(const NodePath &p_path);
void _recompute_caches();
diff --git a/scene/gui/button.h b/scene/gui/button.h
index 35488582de..5c5a73bae3 100644
--- a/scene/gui/button.h
+++ b/scene/gui/button.h
@@ -56,7 +56,6 @@ private:
float _internal_margin[4];
protected:
- virtual Size2 get_minimum_size() const;
void _set_internal_margin(Margin p_margin, float p_value);
void _notification(int p_what);
static void _bind_methods();
@@ -64,6 +63,8 @@ protected:
public:
//
+ virtual Size2 get_minimum_size() const;
+
void set_text(const String &p_text);
String get_text() const;
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index cb6283507e..446676e80d 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -39,33 +39,32 @@ void ColorPicker::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
- //sample->set_texture(get_icon("color_sample"));
+
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
bt_add_preset->set_icon(get_icon("add_preset"));
_update_controls();
} break;
-
case NOTIFICATION_ENTER_TREE: {
+
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
bt_add_preset->set_icon(get_icon("add_preset"));
_update_color();
} break;
-
case NOTIFICATION_PARENTED: {
+
for (int i = 0; i < 4; i++)
set_margin((Margin)i, get_constant("margin"));
} break;
-
case NOTIFICATION_VISIBILITY_CHANGED: {
Popup *p = Object::cast_to<Popup>(get_parent());
if (p)
p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2));
} break;
-
case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
+
if (screen != NULL) {
if (screen->is_visible()) {
screen->hide();
@@ -523,7 +522,6 @@ ColorPicker::ColorPicker() :
add_child(hb_edit);
w_edit = memnew(Control);
- //w_edit->set_ignore_mouse(false);
w_edit->set_custom_minimum_size(Size2(get_constant("h_width"), 0));
w_edit->set_h_size_flags(SIZE_FILL);
w_edit->set_v_size_flags(SIZE_EXPAND_FILL);
@@ -589,7 +587,6 @@ ColorPicker::ColorPicker() :
c_text->set_h_size_flags(SIZE_EXPAND_FILL);
_update_controls();
- //_update_color();
updating = false;
set_pick_color(Color(1, 1, 1));
@@ -599,7 +596,6 @@ ColorPicker::ColorPicker() :
preset = memnew(TextureRect);
bbc->add_child(preset);
- //preset->set_ignore_mouse(false);
preset->connect("gui_input", this, "_preset_input");
preset->connect("draw", this, "_update_presets");
@@ -660,11 +656,13 @@ bool ColorPickerButton::is_editing_alpha() const {
return picker->is_editing_alpha();
}
-ColorPicker *ColorPickerButton::get_picker() {
+ColorPicker *ColorPickerButton::get_picker() const {
+
return picker;
}
-PopupPanel *ColorPickerButton::get_popup() {
+PopupPanel *ColorPickerButton::get_popup() const {
+
return popup;
}
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index c02cdc8608..2bae279ed5 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -129,8 +129,8 @@ public:
void set_edit_alpha(bool p_show);
bool is_editing_alpha() const;
- ColorPicker *get_picker();
- PopupPanel *get_popup();
+ ColorPicker *get_picker() const;
+ PopupPanel *get_popup() const;
ColorPickerButton();
};
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index d850553957..c235797bef 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -33,6 +33,9 @@
void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {
+ if (disable_shortcuts)
+ return;
+
if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event))) {
if (!get_parent() || !is_visible_in_tree() || is_disabled())
@@ -60,25 +63,10 @@ void MenuButton::pressed() {
void MenuButton::_gui_input(Ref<InputEvent> p_event) {
- /*if (p_event.type==InputEvent::MOUSE_BUTTON && p_event->get_button_index()==BUTTON_LEFT) {
- clicked=p_event->is_pressed();
- }
- if (clicked && p_event.type==InputEvent::MOUSE_MOTION && popup->is_visible_in_tree()) {
-
- Point2 gt = Point2(p_event.mouse_motion.x,p_event.mouse_motion.y);
- gt = get_global_transform().xform(gt);
- Point2 lt = popup->get_transform().affine_inverse().xform(gt);
- if (popup->has_point(lt)) {
- //print_line("HAS POINT!!!");
- popup->call_deferred("grab_click_focus");
- }
-
- }*/
-
BaseButton::_gui_input(p_event);
}
-PopupMenu *MenuButton::get_popup() {
+PopupMenu *MenuButton::get_popup() const {
return popup;
}
@@ -98,14 +86,22 @@ void MenuButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("_unhandled_key_input"), &MenuButton::_unhandled_key_input);
ClassDB::bind_method(D_METHOD("_set_items"), &MenuButton::_set_items);
ClassDB::bind_method(D_METHOD("_get_items"), &MenuButton::_get_items);
+ ClassDB::bind_method(D_METHOD("set_disable_shortcuts", "disabled"), &MenuButton::set_disable_shortcuts);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_items", "_get_items");
ADD_SIGNAL(MethodInfo("about_to_show"));
}
+
+void MenuButton::set_disable_shortcuts(bool p_disabled) {
+
+ disable_shortcuts = p_disabled;
+}
+
MenuButton::MenuButton() {
set_flat(true);
+ set_disable_shortcuts(false);
set_enabled_focus_mode(FOCUS_NONE);
popup = memnew(PopupMenu);
popup->hide();
diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h
index c7f1d976ff..1bd9b155b2 100644
--- a/scene/gui/menu_button.h
+++ b/scene/gui/menu_button.h
@@ -40,6 +40,7 @@ class MenuButton : public Button {
GDCLASS(MenuButton, Button);
bool clicked;
+ bool disable_shortcuts;
PopupMenu *popup;
virtual void pressed();
@@ -53,7 +54,9 @@ protected:
static void _bind_methods();
public:
- PopupMenu *get_popup();
+ PopupMenu *get_popup() const;
+ void set_disable_shortcuts(bool p_disabled);
+
MenuButton();
~MenuButton();
};
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 70f3d9ca83..6f784b56de 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -42,38 +42,35 @@ Size2 OptionButton::get_minimum_size() const {
void OptionButton::_notification(int p_what) {
- switch (p_what) {
-
- case NOTIFICATION_DRAW: {
-
- if (!has_icon("arrow"))
- return;
-
- RID ci = get_canvas_item();
- Ref<Texture> arrow = Control::get_icon("arrow");
- Ref<StyleBox> normal = get_stylebox("normal");
- Color clr = Color(1, 1, 1);
- if (get_constant("modulate_arrow"))
- switch (get_draw_mode()) {
- case DRAW_PRESSED:
- clr = get_color("font_color_pressed");
- break;
- case DRAW_HOVER:
- clr = get_color("font_color_hover");
- break;
- case DRAW_DISABLED:
- clr = get_color("font_color_disabled");
- break;
- default:
- clr = get_color("font_color");
- }
-
- Size2 size = get_size();
-
- Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
- arrow->draw(ci, ofs, clr);
-
- } break;
+ if (p_what == NOTIFICATION_DRAW) {
+
+ if (!has_icon("arrow"))
+ return;
+
+ RID ci = get_canvas_item();
+ Ref<Texture> arrow = Control::get_icon("arrow");
+ Ref<StyleBox> normal = get_stylebox("normal");
+ Color clr = Color(1, 1, 1);
+ if (get_constant("modulate_arrow")) {
+ switch (get_draw_mode()) {
+ case DRAW_PRESSED:
+ clr = get_color("font_color_pressed");
+ break;
+ case DRAW_HOVER:
+ clr = get_color("font_color_hover");
+ break;
+ case DRAW_DISABLED:
+ clr = get_color("font_color_disabled");
+ break;
+ default:
+ clr = get_color("font_color");
+ }
+ }
+
+ Size2 size = get_size();
+
+ Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
+ arrow->draw(ci, ofs, clr);
}
}
@@ -244,6 +241,11 @@ void OptionButton::remove_item(int p_idx) {
popup->remove_item(p_idx);
}
+PopupMenu *OptionButton::get_popup() const {
+
+ return popup;
+}
+
Array OptionButton::_get_items() const {
Array items;
@@ -310,6 +312,8 @@ void OptionButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_item", "idx"), &OptionButton::remove_item);
ClassDB::bind_method(D_METHOD("_select_int"), &OptionButton::_select_int);
+ ClassDB::bind_method(D_METHOD("get_popup"), &OptionButton::get_popup);
+
ClassDB::bind_method(D_METHOD("_set_items"), &OptionButton::_set_items);
ClassDB::bind_method(D_METHOD("_get_items"), &OptionButton::_get_items);
@@ -320,15 +324,16 @@ void OptionButton::_bind_methods() {
OptionButton::OptionButton() {
+ current = -1;
+ set_text_align(ALIGN_LEFT);
+ set_action_mode(ACTION_MODE_BUTTON_PRESS);
+
popup = memnew(PopupMenu);
popup->hide();
+ add_child(popup);
popup->set_as_toplevel(true);
popup->set_pass_on_modal_close_click(false);
- add_child(popup);
popup->connect("id_pressed", this, "_selected");
-
- current = -1;
- set_text_align(ALIGN_LEFT);
}
OptionButton::~OptionButton() {
diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h
index a06c540678..b09942b072 100644
--- a/scene/gui/option_button.h
+++ b/scene/gui/option_button.h
@@ -85,6 +85,8 @@ public:
void remove_item(int p_idx);
+ PopupMenu *get_popup() const;
+
virtual void get_translatable_strings(List<String> *p_strings) const;
OptionButton();
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index 4420a936d2..1c15953517 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -61,7 +61,7 @@ Control *SplitContainer::_getch(int p_idx) const {
void SplitContainer::_resort() {
- /** First pass, determine minimum size AND amount of stretchable elements */
+ /* First pass, determine minimum size AND amount of stretchable elements */
int axis = vertical ? 1 : 0;
@@ -114,10 +114,8 @@ void SplitContainer::_resort() {
Size2 ms_second = second->get_combined_minimum_size();
if (vertical) {
-
minimum = ms_first.height + ms_second.height;
} else {
-
minimum = ms_first.width + ms_second.width;
}
@@ -141,12 +139,10 @@ void SplitContainer::_resort() {
} else if (expand_first_mode) {
middle_sep = get_size()[axis] - ms_second[axis] - sep;
-
} else {
middle_sep = ms_first[axis];
}
-
} else if (ratiomode) {
int first_ratio = first->get_stretch_ratio();
@@ -160,23 +156,19 @@ void SplitContainer::_resort() {
expand_ofs = (available * (1.0 - ratio));
middle_sep = ms_first[axis] + available * ratio + expand_ofs;
-
} else if (expand_first_mode) {
if (expand_ofs > 0)
expand_ofs = 0;
-
- if (expand_ofs < -available)
+ else if (expand_ofs < -available)
expand_ofs = -available;
middle_sep = get_size()[axis] - ms_second[axis] - sep + expand_ofs;
-
} else {
if (expand_ofs < 0)
expand_ofs = 0;
-
- if (expand_ofs > available)
+ else if (expand_ofs > available)
expand_ofs = available;
middle_sep = ms_first[axis] + expand_ofs;
@@ -187,7 +179,6 @@ void SplitContainer::_resort() {
fit_child_in_rect(first, Rect2(Point2(0, 0), Size2(get_size().width, middle_sep)));
int sofs = middle_sep + sep;
fit_child_in_rect(second, Rect2(Point2(0, sofs), Size2(get_size().width, get_size().height - sofs)));
-
} else {
fit_child_in_rect(first, Rect2(Point2(0, 0), Size2(middle_sep, get_size().height)));
@@ -246,10 +237,12 @@ void SplitContainer::_notification(int p_what) {
_resort();
} break;
case NOTIFICATION_MOUSE_ENTER: {
+
mouse_inside = true;
update();
} break;
case NOTIFICATION_MOUSE_EXIT: {
+
mouse_inside = false;
update();
} break;
@@ -260,22 +253,17 @@ void SplitContainer::_notification(int p_what) {
if (collapsed || (!mouse_inside && get_constant("autohide")))
return;
+
int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_constant("separation") : 0;
Ref<Texture> tex = get_icon("grabber");
Size2 size = get_size();
- if (vertical) {
+ if (dragger_visibility == DRAGGER_VISIBLE) {
- //draw_style_box( get_stylebox("bg"), Rect2(0,middle_sep,get_size().width,sep));
- if (dragger_visibility == DRAGGER_VISIBLE)
+ if (vertical)
draw_texture(tex, Point2i((size.x - tex->get_width()) / 2, middle_sep + (sep - tex->get_height()) / 2));
-
- } else {
-
- //draw_style_box( get_stylebox("bg"), Rect2(middle_sep,0,sep,get_size().height));
- if (dragger_visibility == DRAGGER_VISIBLE)
+ else
draw_texture(tex, Point2i(middle_sep + (sep - tex->get_width()) / 2, (size.y - tex->get_height()) / 2));
}
-
} break;
}
}
@@ -292,11 +280,13 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
if (mb->get_button_index() == BUTTON_LEFT) {
if (mb->is_pressed()) {
+
int sep = get_constant("separation");
if (vertical) {
if (mb->get_position().y > middle_sep && mb->get_position().y < middle_sep + sep) {
+
dragging = true;
drag_from = mb->get_position().y;
drag_ofs = expand_ofs;
@@ -304,6 +294,7 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
} else {
if (mb->get_position().x > middle_sep && mb->get_position().x < middle_sep + sep) {
+
dragging = true;
drag_from = mb->get_position().x;
drag_ofs = expand_ofs;
@@ -318,36 +309,31 @@ void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseMotion> mm = p_event;
- if (mm.is_valid()) {
-
- if (dragging) {
+ if (mm.is_valid() && dragging) {
- expand_ofs = drag_ofs + ((vertical ? mm->get_position().y : mm->get_position().x) - drag_from);
- queue_sort();
- emit_signal("dragged", get_split_offset());
- }
+ expand_ofs = drag_ofs + ((vertical ? mm->get_position().y : mm->get_position().x) - drag_from);
+ queue_sort();
+ emit_signal("dragged", get_split_offset());
}
}
Control::CursorShape SplitContainer::get_cursor_shape(const Point2 &p_pos) const {
- if (collapsed)
- return Control::get_cursor_shape(p_pos);
-
if (dragging)
return (vertical ? CURSOR_VSIZE : CURSOR_HSIZE);
- int sep = get_constant("separation");
+ if (!collapsed && _getch(0) && _getch(1) && dragger_visibility == DRAGGER_VISIBLE) {
- if (vertical) {
+ int sep = get_constant("separation");
- if (p_pos.y > middle_sep && p_pos.y < middle_sep + sep) {
- return CURSOR_VSIZE;
- }
- } else {
+ if (vertical) {
- if (p_pos.x > middle_sep && p_pos.x < middle_sep + sep) {
- return CURSOR_HSIZE;
+ if (p_pos.y > middle_sep && p_pos.y < middle_sep + sep)
+ return CURSOR_VSIZE;
+ } else {
+
+ if (p_pos.x > middle_sep && p_pos.x < middle_sep + sep)
+ return CURSOR_HSIZE;
}
}
@@ -358,6 +344,7 @@ void SplitContainer::set_split_offset(int p_offset) {
if (expand_ofs == p_offset)
return;
+
expand_ofs = p_offset;
queue_sort();
}
@@ -371,6 +358,7 @@ void SplitContainer::set_collapsed(bool p_collapsed) {
if (collapsed == p_collapsed)
return;
+
collapsed = p_collapsed;
queue_sort();
}
diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h
index c7a484c4c5..40a58d4b32 100644
--- a/scene/gui/split_container.h
+++ b/scene/gui/split_container.h
@@ -88,7 +88,7 @@ class HSplitContainer : public SplitContainer {
public:
HSplitContainer() :
- SplitContainer(false) { set_default_cursor_shape(CURSOR_HSPLIT); }
+ SplitContainer(false) {}
};
class VSplitContainer : public SplitContainer {
@@ -97,7 +97,7 @@ class VSplitContainer : public SplitContainer {
public:
VSplitContainer() :
- SplitContainer(true) { set_default_cursor_shape(CURSOR_VSPLIT); }
+ SplitContainer(true) {}
};
#endif // SPLIT_CONTAINER_H
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 07f1bdf8e5..0fba4a6f94 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1695,10 +1695,9 @@ void TextEdit::indent_right() {
// fix selection and cursor being off by one on the last line
if (is_selection_active()) {
- selection.to_column++;
- selection.from_column++;
+ select(selection.from_line, selection.from_column + 1, selection.to_line, selection.to_column + 1);
}
- cursor.column++;
+ cursor_set_column(cursor.column + 1, false);
end_complex_operation();
update();
}
@@ -1737,14 +1736,9 @@ void TextEdit::indent_left() {
// fix selection and cursor being off by one on the last line
if (is_selection_active() && last_line_text != get_line(end_line)) {
- if (selection.to_column > 0)
- selection.to_column--;
- if (selection.from_column > 0)
- selection.from_column--;
- }
- if (cursor.column > 0) {
- cursor.column--;
+ select(selection.from_line, selection.from_column - 1, selection.to_line, selection.to_column - 1);
}
+ cursor_set_column(cursor.column - 1, false);
end_complex_operation();
update();
}
@@ -1973,6 +1967,31 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (mb->get_button_index() == BUTTON_RIGHT && context_menu_enabled) {
+ _reset_caret_blink_timer();
+
+ int row, col;
+ update_line_scroll_pos();
+ _get_mouse_pos(Point2i(mb->get_position().x, mb->get_position().y), row, col);
+
+ if (is_right_click_moving_caret()) {
+ if (is_selection_active()) {
+
+ int from_line = get_selection_from_line();
+ int to_line = get_selection_to_line();
+ int from_column = get_selection_from_column();
+ int to_column = get_selection_to_column();
+
+ if (row < from_line || row > to_line || (row == from_line && col < from_column) || (row == to_line && col > to_column)) {
+ // Right click is outside the seleted text
+ deselect();
+ }
+ }
+ if (!is_selection_active()) {
+ cursor_set_line(row, true, false);
+ cursor_set_column(col);
+ }
+ }
+
menu->set_position(get_global_transform().xform(get_local_mouse_position()));
menu->set_size(Vector2(1, 1));
menu->popup();
@@ -3708,6 +3727,14 @@ bool TextEdit::cursor_is_block_mode() const {
return block_caret;
}
+void TextEdit::set_right_click_moves_caret(bool p_enable) {
+ right_click_moves_caret = p_enable;
+}
+
+bool TextEdit::is_right_click_moving_caret() const {
+ return right_click_moves_caret;
+}
+
void TextEdit::_v_scroll_input() {
scrolling = false;
}
@@ -4168,11 +4195,15 @@ void TextEdit::select(int p_from_line, int p_from_column, int p_to_line, int p_t
p_from_line = text.size() - 1;
if (p_from_column >= text[p_from_line].length())
p_from_column = text[p_from_line].length();
+ if (p_from_column < 0)
+ p_from_column = 0;
if (p_to_line >= text.size())
p_to_line = text.size() - 1;
if (p_to_column >= text[p_to_line].length())
p_to_column = text[p_to_line].length();
+ if (p_to_column < 0)
+ p_to_column = 0;
selection.from_line = p_from_line;
selection.from_column = p_from_column;
@@ -5457,6 +5488,9 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("cursor_set_block_mode", "enable"), &TextEdit::cursor_set_block_mode);
ClassDB::bind_method(D_METHOD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode);
+ ClassDB::bind_method(D_METHOD("set_right_click_moves_caret", "enable"), &TextEdit::set_right_click_moves_caret);
+ ClassDB::bind_method(D_METHOD("is_right_click_moving_caret"), &TextEdit::is_right_click_moving_caret);
+
ClassDB::bind_method(D_METHOD("set_readonly", "enable"), &TextEdit::set_readonly);
ClassDB::bind_method(D_METHOD("is_readonly"), &TextEdit::is_readonly);
@@ -5492,7 +5526,7 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_hiding_enabled", "enable"), &TextEdit::set_hiding_enabled);
ClassDB::bind_method(D_METHOD("is_hiding_enabled"), &TextEdit::is_hiding_enabled);
ClassDB::bind_method(D_METHOD("set_line_as_hidden", "line", "enable"), &TextEdit::set_line_as_hidden);
- ClassDB::bind_method(D_METHOD("is_line_hidden"), &TextEdit::is_line_hidden);
+ ClassDB::bind_method(D_METHOD("is_line_hidden", "line"), &TextEdit::is_line_hidden);
ClassDB::bind_method(D_METHOD("fold_all_lines"), &TextEdit::fold_all_lines);
ClassDB::bind_method(D_METHOD("unhide_all_lines"), &TextEdit::unhide_all_lines);
ClassDB::bind_method(D_METHOD("fold_line", "line"), &TextEdit::fold_line);
@@ -5540,6 +5574,7 @@ void TextEdit::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_block_mode"), "cursor_set_block_mode", "cursor_is_block_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), "cursor_set_blink_enabled", "cursor_get_blink_enabled");
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed", PROPERTY_HINT_RANGE, "0.1,10,0.1"), "cursor_set_blink_speed", "cursor_get_blink_speed");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_moving_by_right_click"), "set_right_click_moves_caret", "is_right_click_moving_caret");
ADD_SIGNAL(MethodInfo("cursor_changed"));
ADD_SIGNAL(MethodInfo("text_changed"));
@@ -5617,6 +5652,7 @@ TextEdit::TextEdit() {
caret_blink_timer->set_wait_time(0.65);
caret_blink_timer->connect("timeout", this, "_toggle_draw_caret");
cursor_set_blink_enabled(false);
+ right_click_moves_caret = true;
idle_detect = memnew(Timer);
add_child(idle_detect);
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 836d5c7388..f18eaa85cb 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -246,6 +246,7 @@ class TextEdit : public Control {
bool draw_caret;
bool window_has_focus;
bool block_caret;
+ bool right_click_moves_caret;
bool setting_row;
bool wrap;
@@ -481,6 +482,9 @@ public:
void cursor_set_block_mode(const bool p_enable);
bool cursor_is_block_mode() const;
+ void set_right_click_moves_caret(bool p_enable);
+ bool is_right_click_moving_caret() const;
+
void set_readonly(bool p_readonly);
bool is_readonly() const;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index b5b42e8f29..51ad22e271 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1775,7 +1775,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
case TreeItem::CELL_MODE_STRING: {
//nothing in particular
- if (select_mode == SELECT_MULTI && (get_tree()->get_last_event_id() == focus_in_id || !already_cursor)) {
+ if (select_mode == SELECT_MULTI && (get_tree()->get_event_count() == focus_in_id || !already_cursor)) {
bring_up_editor = false;
}
@@ -1863,7 +1863,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
} else {
editor_text = String::num(p_item->cells[col].val, Math::step_decimals(p_item->cells[col].step));
- if (select_mode == SELECT_MULTI && get_tree()->get_last_event_id() == focus_in_id)
+ if (select_mode == SELECT_MULTI && get_tree()->get_event_count() == focus_in_id)
bring_up_editor = false;
}
}
@@ -2786,7 +2786,7 @@ void Tree::_notification(int p_what) {
if (p_what == NOTIFICATION_FOCUS_ENTER) {
- focus_in_id = get_tree()->get_last_event_id();
+ focus_in_id = get_tree()->get_event_count();
}
if (p_what == NOTIFICATION_MOUSE_EXIT) {
@@ -2950,43 +2950,51 @@ Size2 Tree::get_minimum_size() const {
return Size2(1, 1);
}
-TreeItem *Tree::create_item(TreeItem *p_parent) {
+TreeItem *Tree::create_item(TreeItem *p_parent, int p_idx) {
ERR_FAIL_COND_V(blocked > 0, NULL);
- TreeItem *ti = memnew(TreeItem(this));
-
- ERR_FAIL_COND_V(!ti, NULL);
- ti->cells.resize(columns.size());
+ TreeItem *ti = NULL;
if (p_parent) {
- /* Always append at the end */
+ // Append or insert a new item to the given parent.
+ ti = memnew(TreeItem(this));
+ ERR_FAIL_COND_V(!ti, NULL);
+ ti->cells.resize(columns.size());
- TreeItem *last = 0;
+ TreeItem *prev = NULL;
TreeItem *c = p_parent->childs;
+ int idx = 0;
while (c) {
-
- last = c;
+ if (idx++ == p_idx) {
+ ti->next = c;
+ break;
+ }
+ prev = c;
c = c->next;
}
- if (last) {
-
- last->next = ti;
- } else {
-
+ if (prev)
+ prev->next = ti;
+ else
p_parent->childs = ti;
- }
ti->parent = p_parent;
} else {
- if (root)
- ti->childs = root;
+ if (!root) {
+ // No root exists, make the given item the new root.
+ ti = memnew(TreeItem(this));
+ ERR_FAIL_COND_V(!ti, NULL);
+ ti->cells.resize(columns.size());
- root = ti;
+ root = ti;
+ } else {
+ // Root exists, append or insert to root.
+ ti = create_item(root, p_idx);
+ }
}
return ti;
@@ -3723,7 +3731,7 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("_scroll_moved"), &Tree::_scroll_moved);
ClassDB::bind_method(D_METHOD("clear"), &Tree::clear);
- ClassDB::bind_method(D_METHOD("create_item", "parent"), &Tree::_create_item, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("create_item", "parent", "idx"), &Tree::_create_item, DEFVAL(Variant()), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("get_root"), &Tree::get_root);
ClassDB::bind_method(D_METHOD("set_column_min_width", "column", "min_width"), &Tree::set_column_min_width);
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 112de3165f..b8d94bcffb 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -359,7 +359,7 @@ private:
LineEdit *text_editor;
HSlider *value_editor;
bool updating_value_editor;
- uint32_t focus_in_id;
+ int64_t focus_in_id;
PopupMenu *popup_menu;
Vector<ColumnInfo> columns;
@@ -511,8 +511,8 @@ protected:
static void _bind_methods();
//bind helpers
- Object *_create_item(Object *p_parent) {
- return create_item(Object::cast_to<TreeItem>(p_parent));
+ Object *_create_item(Object *p_parent, int p_idx = -1) {
+ return create_item(Object::cast_to<TreeItem>(p_parent), p_idx);
}
TreeItem *_get_next_selected(Object *p_item) {
@@ -532,7 +532,7 @@ public:
void clear();
- TreeItem *create_item(TreeItem *p_parent = 0);
+ TreeItem *create_item(TreeItem *p_parent = 0, int p_idx = -1);
TreeItem *get_root();
TreeItem *get_last_item();
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index de1ab9959a..942a6d5428 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -340,7 +340,8 @@ void Node::move_child(Node *p_child, int p_pos) {
data.children[i]->notification(NOTIFICATION_MOVED_IN_PARENT);
}
for (const Map<StringName, GroupData>::Element *E = p_child->data.grouped.front(); E; E = E->next()) {
- E->get().group->changed = true;
+ if (E->get().group)
+ E->get().group->changed = true;
}
data.blocked--;
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 7c31b72bb5..db39b37bd5 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -391,13 +391,12 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) {
if (Engine::get_singleton()->is_editor_hint() && (Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventJoypadMotion>(*p_event)))
return; //avoid joy input on editor
+ current_event++;
root_lock++;
- //last_id=p_event.ID;
input_handled = false;
Ref<InputEvent> ev = p_event;
- ev->set_id(++last_id); //this should work better
MainLoop::input_event(ev);
@@ -941,11 +940,6 @@ void SceneMainLoop::_update_listener_2d() {
}
*/
-uint32_t SceneTree::get_last_event_id() const {
-
- return last_id;
-}
-
Variant SceneTree::_call_group_flags(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
r_error.error = Variant::CallError::CALL_OK;
@@ -994,6 +988,10 @@ int64_t SceneTree::get_frame() const {
return current_frame;
}
+int64_t SceneTree::get_event_count() const {
+
+ return current_event;
+}
Array SceneTree::_get_nodes_in_group(const StringName &p_group) {
@@ -2287,9 +2285,10 @@ SceneTree::SceneTree() {
tree_version = 1;
physics_process_time = 1;
idle_process_time = 1;
- last_id = 1;
+
root = NULL;
current_frame = 0;
+ current_event = 0;
tree_changed_name = "tree_changed";
node_added_name = "node_added";
node_removed_name = "node_removed";
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 9c5b0f69cb..3e2e74b553 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -109,7 +109,6 @@ private:
float idle_process_time;
bool accept_quit;
bool quit_on_go_back;
- uint32_t last_id;
#ifdef DEBUG_ENABLED
bool debug_collisions_hint;
@@ -130,6 +129,7 @@ private:
bool use_font_oversampling;
int64_t current_frame;
+ int64_t current_event;
int node_count;
#ifdef TOOLS_ENABLED
@@ -325,7 +325,7 @@ public:
NOTIFICATION_TRANSFORM_CHANGED = 29
};
- enum CallGroupFlags {
+ enum GroupCallFlags {
GROUP_CALL_DEFAULT = 0,
GROUP_CALL_REVERSE = 1,
GROUP_CALL_REALTIME = 2,
@@ -335,8 +335,6 @@ public:
_FORCE_INLINE_ Viewport *get_root() const { return root; }
- uint32_t get_last_event_id() const;
-
void call_group_flags(uint32_t p_call_flags, const StringName &p_group, const StringName &p_function, VARIANT_ARG_LIST);
void notify_group_flags(uint32_t p_call_flags, const StringName &p_group, int p_notification);
void set_group_flags(uint32_t p_call_flags, const StringName &p_group, const String &p_name, const Variant &p_value);
@@ -412,6 +410,7 @@ public:
int get_collision_debug_contact_count() { return collision_debug_contacts; }
int64_t get_frame() const;
+ int64_t get_event_count() const;
int get_node_count() const;
@@ -467,6 +466,6 @@ public:
VARIANT_ENUM_CAST(SceneTree::StretchMode);
VARIANT_ENUM_CAST(SceneTree::StretchAspect);
-VARIANT_ENUM_CAST(SceneTree::CallGroupFlags);
+VARIANT_ENUM_CAST(SceneTree::GroupCallFlags);
#endif
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 8f431389d8..fa6a7832f5 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -184,7 +184,6 @@ Viewport::GUI::GUI() {
key_focus = NULL;
mouse_over = NULL;
- cancelled_input_ID = 0;
tooltip = NULL;
tooltip_popup = NULL;
tooltip_label = NULL;
@@ -1620,9 +1619,6 @@ bool Viewport::_gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_che
void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
- if (p_event->get_id() == gui.cancelled_input_ID) {
- return;
- }
//?
/*
if (!is_visible()) {
@@ -1640,7 +1636,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
if (mb->is_pressed()) {
Size2 pos = mpos;
- if (gui.mouse_focus && mb->get_button_index() != gui.mouse_focus_button) {
+ if (gui.mouse_focus && mb->get_button_index() != gui.mouse_focus_button && mb->get_button_index() == BUTTON_LEFT) {
//do not steal mouse focus and stuff
@@ -1752,7 +1748,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
_gui_call_input(gui.mouse_focus, mb);
}
- get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, "windows", "_cancel_input_ID", mb->get_id());
get_tree()->set_input_as_handled();
if (gui.drag_data.get_type() != Variant::NIL && mb->get_button_index() == BUTTON_LEFT) {
@@ -1825,7 +1820,6 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
gui.drag_data=Variant(); //always clear
}*/
- get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, "windows", "_cancel_input_ID", mb->get_id());
get_tree()->set_input_as_handled();
}
}
@@ -2904,7 +2898,7 @@ Viewport::Viewport() {
gui.canvas_sort_index = 0;
msaa = MSAA_DISABLED;
- hdr = false;
+ hdr = true;
usage = USAGE_3D;
debug_draw = DEBUG_DRAW_DISABLED;
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 0835e3f69a..c084e348b5 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -269,7 +269,6 @@ private:
float tooltip_timer;
float tooltip_delay;
List<Control *> modal_stack;
- unsigned int cancelled_input_ID;
Transform2D focus_inv_xform;
bool subwindow_order_dirty;
List<Control *> subwindows;
diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp
index 39e6698725..0c8837ee1a 100644
--- a/scene/register_scene_types.cpp
+++ b/scene/register_scene_types.cpp
@@ -200,6 +200,9 @@ static ResourceFormatLoaderDynamicFont *resource_loader_dynamic_font = NULL;
static ResourceFormatLoaderStreamTexture *resource_loader_stream_texture = NULL;
+static ResourceFormatSaverShader *resource_saver_shader = NULL;
+static ResourceFormatLoaderShader *resource_loader_shader = NULL;
+
void register_scene_types() {
SceneStringNames::create();
@@ -607,6 +610,12 @@ void register_scene_types() {
resource_loader_text = memnew(ResourceFormatLoaderText);
ResourceLoader::add_resource_format_loader(resource_loader_text, true);
+ resource_saver_shader = memnew(ResourceFormatSaverShader);
+ ResourceSaver::add_resource_format_saver(resource_saver_shader, true);
+
+ resource_loader_shader = memnew(ResourceFormatLoaderShader);
+ ResourceLoader::add_resource_format_loader(resource_loader_shader, true);
+
for (int i = 0; i < 20; i++) {
GLOBAL_DEF("layer_names/2d_render/layer_" + itos(i + 1), "");
GLOBAL_DEF("layer_names/2d_physics/layer_" + itos(i + 1), "");
@@ -632,6 +641,13 @@ void unregister_scene_types() {
memdelete(resource_loader_text);
}
+ if (resource_saver_shader) {
+ memdelete(resource_saver_shader);
+ }
+ if (resource_loader_shader) {
+ memdelete(resource_loader_shader);
+ }
+
SpatialMaterial::finish_shaders();
ParticlesMaterial::finish_shaders();
CanvasItemMaterial::finish_shaders();
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 326320c60f..cc9fde58e2 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -753,7 +753,7 @@ void SpatialMaterial::_update_shader() {
if (features[FEATURE_REFRACTION] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //refraction not supported with triplanar
if (features[FEATURE_NORMAL_MAPPING]) {
- code += "\tvec3 ref_normal = normalize( mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH) ) * SIDE;\n";
+ code += "\tvec3 ref_normal = normalize( mix(NORMAL,TANGENT * NORMALMAP.x + BINORMAL * NORMALMAP.y + NORMAL * NORMALMAP.z,NORMALMAP_DEPTH) );\n";
} else {
code += "\tvec3 ref_normal = NORMAL;\n";
}
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 66df7dfda8..207c50f673 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -151,3 +151,80 @@ Shader::~Shader() {
VisualServer::get_singleton()->free(shader);
}
+////////////
+
+RES ResourceFormatLoaderShader::load(const String &p_path, const String &p_original_path, Error *r_error) {
+
+ if (r_error)
+ *r_error = ERR_FILE_CANT_OPEN;
+
+ Ref<Shader> shader;
+ shader.instance();
+
+ Vector<uint8_t> buffer = FileAccess::get_file_as_array(p_path);
+
+ String str;
+ str.parse_utf8((const char *)buffer.ptr(), buffer.size());
+
+ shader->set_code(str);
+
+ if (r_error)
+ *r_error = OK;
+
+ return shader;
+}
+
+void ResourceFormatLoaderShader::get_recognized_extensions(List<String> *p_extensions) const {
+
+ p_extensions->push_back("shader");
+}
+
+bool ResourceFormatLoaderShader::handles_type(const String &p_type) const {
+
+ return (p_type == "Shader");
+}
+
+String ResourceFormatLoaderShader::get_resource_type(const String &p_path) const {
+
+ String el = p_path.get_extension().to_lower();
+ if (el == "shader")
+ return "Shader";
+ return "";
+}
+
+Error ResourceFormatSaverShader::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
+
+ Ref<Shader> shader = p_resource;
+ ERR_FAIL_COND_V(shader.is_null(), ERR_INVALID_PARAMETER);
+
+ String source = shader->get_code();
+
+ Error err;
+ FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
+
+ if (err) {
+
+ ERR_FAIL_COND_V(err, err);
+ }
+
+ file->store_string(source);
+ if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) {
+ memdelete(file);
+ return ERR_CANT_CREATE;
+ }
+ file->close();
+ memdelete(file);
+
+ return OK;
+}
+
+void ResourceFormatSaverShader::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
+
+ if (Object::cast_to<Shader>(*p_resource)) {
+ p_extensions->push_back("shader");
+ }
+}
+bool ResourceFormatSaverShader::recognize(const RES &p_resource) const {
+
+ return Object::cast_to<Shader>(*p_resource) != NULL;
+}
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 5cc70629c7..78d73a33e2 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -31,6 +31,7 @@
#define SHADER_H
#include "io/resource_loader.h"
+#include "io/resource_saver.h"
#include "resource.h"
#include "scene/resources/texture.h"
@@ -38,7 +39,6 @@ class Shader : public Resource {
GDCLASS(Shader, Resource);
OBJ_SAVE_TYPE(Shader);
- RES_BASE_EXTENSION("shd");
public:
enum Mode {
@@ -95,4 +95,19 @@ public:
VARIANT_ENUM_CAST(Shader::Mode);
+class ResourceFormatLoaderShader : public ResourceFormatLoader {
+public:
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
+ virtual void get_recognized_extensions(List<String> *p_extensions) const;
+ virtual bool handles_type(const String &p_type) const;
+ virtual String get_resource_type(const String &p_path) const;
+};
+
+class ResourceFormatSaverShader : public ResourceFormatSaver {
+public:
+ virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
+ virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
+ virtual bool recognize(const RES &p_resource) const;
+};
+
#endif // SHADER_H
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 987d6c5f6a..35d0d55d85 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -707,6 +707,8 @@ Ref<Image> StreamTexture::get_data() const {
}
void StreamTexture::set_flags(uint32_t p_flags) {
+ flags = p_flags;
+ VS::get_singleton()->texture_set_flags(texture, flags);
}
void StreamTexture::reload_from_file() {
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index bd6b917d4e..144c208c07 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -893,8 +893,8 @@ void TileSet::clear() {
void TileSet::_bind_methods() {
ClassDB::bind_method(D_METHOD("create_tile", "id"), &TileSet::create_tile);
- ClassDB::bind_method(D_METHOD("autotile_set_bitmask_mode", "mode"), &TileSet::autotile_set_bitmask_mode);
- ClassDB::bind_method(D_METHOD("autotile_get_bitmask_mode"), &TileSet::autotile_get_bitmask_mode);
+ ClassDB::bind_method(D_METHOD("autotile_set_bitmask_mode", "id", "mode"), &TileSet::autotile_set_bitmask_mode);
+ ClassDB::bind_method(D_METHOD("autotile_get_bitmask_mode", "id"), &TileSet::autotile_get_bitmask_mode);
ClassDB::bind_method(D_METHOD("tile_set_name", "id", "name"), &TileSet::tile_set_name);
ClassDB::bind_method(D_METHOD("tile_get_name", "id"), &TileSet::tile_get_name);
ClassDB::bind_method(D_METHOD("tile_set_texture", "id", "texture"), &TileSet::tile_set_texture);