summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/camera_2d.cpp39
-rw-r--r--scene/2d/camera_2d.h6
-rw-r--r--scene/gui/popup_menu.cpp17
-rw-r--r--scene/gui/popup_menu.h1
-rw-r--r--scene/resources/color_ramp.cpp34
-rw-r--r--scene/resources/color_ramp.h3
6 files changed, 87 insertions, 13 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 52ae5d2954..b7b99f935a 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -118,10 +118,10 @@ Matrix32 Camera2D::get_camera_transform() {
- if (smoothing>0.0) {
+ if (smoothing_enabled) {
float c = smoothing*get_fixed_process_delta_time();
- smoothed_camera_pos = ((new_camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos;
+ smoothed_camera_pos = ((camera_pos-smoothed_camera_pos)*c)+smoothed_camera_pos;
ret_camera_pos=smoothed_camera_pos;
// camera_pos=camera_pos*(1.0-smoothing)+new_camera_pos*smoothing;
} else {
@@ -440,6 +440,27 @@ float Camera2D::get_h_offset() const{
}
+void Camera2D::_set_old_smoothing(float p_val) {
+ //compatibility
+ if (p_val>0) {
+ smoothing_enabled=true;
+ set_follow_smoothing(p_val);
+ }
+
+}
+
+void Camera2D::set_enable_follow_smoothing(bool p_enabled) {
+
+ smoothing_enabled=p_enabled;
+
+}
+
+bool Camera2D::is_follow_smoothing_enabled() const {
+
+ return smoothing_enabled;
+}
+
+
void Camera2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_offset","offset"),&Camera2D::set_offset);
@@ -489,14 +510,17 @@ void Camera2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_follow_smoothing","follow_smoothing"),&Camera2D::set_follow_smoothing);
ObjectTypeDB::bind_method(_MD("get_follow_smoothing"),&Camera2D::get_follow_smoothing);
+ ObjectTypeDB::bind_method(_MD("set_enable_follow_smoothing","follow_smoothing"),&Camera2D::set_enable_follow_smoothing);
+ ObjectTypeDB::bind_method(_MD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled);
+
ObjectTypeDB::bind_method(_MD("force_update_scroll"),&Camera2D::force_update_scroll);
+ ObjectTypeDB::bind_method(_MD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing);
ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"offset"),_SCS("set_offset"),_SCS("get_offset"));
ADD_PROPERTY( PropertyInfo(Variant::INT,"anchor_mode",PROPERTY_HINT_ENUM,"Fixed TopLeft,Drag Center"),_SCS("set_anchor_mode"),_SCS("get_anchor_mode"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"rotating"),_SCS("set_rotating"),_SCS("is_rotating"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"current"),_SCS("_set_current"),_SCS("is_current"));
- ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") );
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"zoom"),_SCS("set_zoom"),_SCS("get_zoom") );
ADD_PROPERTYI( PropertyInfo(Variant::INT,"limit/left"),_SCS("set_limit"),_SCS("get_limit"),MARGIN_LEFT);
@@ -507,6 +531,12 @@ void Camera2D::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/h_enabled"),_SCS("set_h_drag_enabled"),_SCS("is_h_drag_enabled") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"drag_margin/v_enabled"),_SCS("set_v_drag_enabled"),_SCS("is_v_drag_enabled") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"smoothing/enable"),_SCS("set_enable_follow_smoothing"),_SCS("is_follow_smoothing_enabled") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing/speed"),_SCS("set_follow_smoothing"),_SCS("get_follow_smoothing") );
+
+ //compatibility
+ ADD_PROPERTY( PropertyInfo(Variant::REAL,"smoothing",PROPERTY_HINT_NONE,"",0),_SCS("_set_old_smoothing"),_SCS("get_follow_smoothing") );
+
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/left",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_LEFT);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/top",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_TOP);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"drag_margin/right",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_drag_margin"),_SCS("get_drag_margin"),MARGIN_RIGHT);
@@ -535,8 +565,9 @@ Camera2D::Camera2D() {
drag_margin[MARGIN_BOTTOM]=0.2;
camera_pos=Vector2();
first=true;
+ smoothing_enabled=false;
- smoothing=0.0;
+ smoothing=5.0;
zoom = Vector2(1, 1);
h_drag_enabled=true;
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 79d84f48d0..dcf98d4295 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -59,6 +59,7 @@ protected:
bool rotating;
bool current;
float smoothing;
+ bool smoothing_enabled;
int limit[4];
float drag_margin[4];
@@ -73,6 +74,8 @@ protected:
void _make_current(Object *p_which);
void _set_current(bool p_current);
+
+ void _set_old_smoothing(float p_enable);
protected:
virtual Matrix32 get_camera_transform();
@@ -108,6 +111,9 @@ public:
void set_h_offset(float p_offset);
float get_h_offset() const;
+ void set_enable_follow_smoothing(bool p_enabled);
+ bool is_follow_smoothing_enabled() const;
+
void set_follow_smoothing(float p_speed);
float get_follow_smoothing() const;
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 20f28ecf10..25e39c1891 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -524,7 +524,7 @@ void PopupMenu::add_icon_item(const Ref<Texture>& p_icon,const String& p_label,i
item.icon=p_icon;
item.text=p_label;
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
items.push_back(item);
update();
}
@@ -533,7 +533,7 @@ void PopupMenu::add_item(const String& p_label,int p_ID,uint32_t p_accel) {
Item item;
item.text=XL_MESSAGE(p_label);
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
items.push_back(item);
update();
}
@@ -542,7 +542,7 @@ void PopupMenu::add_submenu_item(const String& p_label, const String& p_submenu,
Item item;
item.text=XL_MESSAGE(p_label);
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
item.submenu=p_submenu;
items.push_back(item);
update();
@@ -554,7 +554,7 @@ void PopupMenu::add_icon_check_item(const Ref<Texture>& p_icon,const String& p_l
item.icon=p_icon;
item.text=XL_MESSAGE(p_label);
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
item.checkable=true;
items.push_back(item);
update();
@@ -564,7 +564,7 @@ void PopupMenu::add_check_item(const String& p_label,int p_ID,uint32_t p_accel)
Item item;
item.text=XL_MESSAGE(p_label);
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
item.checkable=true;
items.push_back(item);
update();
@@ -755,7 +755,8 @@ void PopupMenu::activate_item(int p_item) {
ERR_FAIL_INDEX(p_item,items.size());
ERR_FAIL_COND(items[p_item].separator);
- emit_signal("item_pressed",items[p_item].ID);
+ int id = items[p_item].ID>=0?items[p_item].ID:p_item;
+ emit_signal("item_pressed",id);
//hide all parent PopupMenue's
Node *next = get_parent();
@@ -789,7 +790,7 @@ void PopupMenu::clear() {
items.clear();
mouse_over=-1;
update();
- idcount=0;
+
}
@@ -937,7 +938,7 @@ void PopupMenu::set_invalidate_click_until_motion() {
PopupMenu::PopupMenu() {
- idcount=0;
+
mouse_over=-1;
set_focus_mode(FOCUS_ALL);
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index ed78fe6738..30223469a3 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -59,7 +59,6 @@ class PopupMenu : public Popup {
Timer *submenu_timer;
List<Rect2> autohide_areas;
Vector<Item> items;
- int idcount;
int mouse_over;
int submenu_over;
Rect2 parent_rect;
diff --git a/scene/resources/color_ramp.cpp b/scene/resources/color_ramp.cpp
index 97d3fafd58..bf1f298e7a 100644
--- a/scene/resources/color_ramp.cpp
+++ b/scene/resources/color_ramp.cpp
@@ -26,6 +26,23 @@ ColorRamp::~ColorRamp() {
void ColorRamp::_bind_methods() {
+
+
+
+
+ ObjectTypeDB::bind_method(_MD("add_point","offset","color"),&ColorRamp::add_point);
+ ObjectTypeDB::bind_method(_MD("remove_point","offset","color"),&ColorRamp::remove_point);
+
+ ObjectTypeDB::bind_method(_MD("set_offset","point","offset"),&ColorRamp::set_offset);
+ ObjectTypeDB::bind_method(_MD("get_offset","point"),&ColorRamp::get_offset);
+
+ ObjectTypeDB::bind_method(_MD("set_color","point","color"),&ColorRamp::set_color);
+ ObjectTypeDB::bind_method(_MD("get_color","point"),&ColorRamp::get_color);
+
+ ObjectTypeDB::bind_method(_MD("interpolate","offset"),&ColorRamp::get_color_at_offset);
+
+ ObjectTypeDB::bind_method(_MD("get_point_count"),&ColorRamp::get_points_count);
+
ObjectTypeDB::bind_method(_MD(COLOR_RAMP_SET_OFFSETS,"offsets"),&ColorRamp::set_offsets);
ObjectTypeDB::bind_method(_MD(COLOR_RAMP_GET_OFFSETS),&ColorRamp::get_offsets);
@@ -79,6 +96,23 @@ Vector<ColorRamp::Point>& ColorRamp::get_points() {
return points;
}
+void ColorRamp::add_point(float p_offset, const Color& p_color) {
+
+ Point p;
+ p.offset=p_offset;
+ p.color=p_color;
+ is_sorted=false;
+ points.push_back(p);
+
+}
+
+void ColorRamp::remove_point(int p_index) {
+
+ ERR_FAIL_INDEX(p_index,points.size());
+ ERR_FAIL_COND(points.size()<=2);
+ points.remove(p_index);
+}
+
void ColorRamp::set_points(Vector<ColorRamp::Point>& p_points) {
points = p_points;
is_sorted = false;
diff --git a/scene/resources/color_ramp.h b/scene/resources/color_ramp.h
index 8f6ba2c3e5..aab5698c2b 100644
--- a/scene/resources/color_ramp.h
+++ b/scene/resources/color_ramp.h
@@ -32,6 +32,9 @@ public:
ColorRamp();
virtual ~ColorRamp();
+ void add_point(float p_offset, const Color& p_color);
+ void remove_point(int p_index);
+
void set_points(Vector<Point>& points);
Vector<Point>& get_points();