summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/array.cpp18
-rw-r--r--core/array.h6
-rw-r--r--core/variant_call.cpp6
-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
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp24
-rw-r--r--tools/editor/plugins/script_editor_plugin.h3
-rw-r--r--tools/editor/script_editor_debugger.cpp14
-rw-r--r--tools/editor/script_editor_debugger.h4
13 files changed, 151 insertions, 24 deletions
diff --git a/core/array.cpp b/core/array.cpp
index ab9f19d6a0..41af460d83 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -222,6 +222,24 @@ void Array::invert(){
}
+void Array::push_front(const Variant& p_value) {
+
+ _p->array.insert(0,p_value);
+}
+
+void Array::pop_back(){
+
+ if (!_p->array.empty())
+ _p->array.resize( _p->array.size() -1 );
+
+}
+void Array::pop_front(){
+
+ if (!_p->array.empty())
+ _p->array.remove(0);
+
+}
+
Array::Array(const Array& p_from) {
diff --git a/core/array.h b/core/array.h
index 904309b257..c29b4355ca 100644
--- a/core/array.h
+++ b/core/array.h
@@ -53,7 +53,7 @@ public:
bool empty() const;
void clear();
- bool is_shared() const;
+ bool is_shared() const;
bool operator==(const Array& p_array) const;
@@ -75,6 +75,10 @@ public:
void erase(const Variant& p_value);
+ void push_front(const Variant& p_value);
+ void pop_back();
+ void pop_front();
+
Array(const Array& p_from);
Array(bool p_shared=false);
~Array();
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 2d10cf4d44..2ac876c8f4 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -450,6 +450,9 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM0(Array,clear);
VCALL_LOCALMEM0R(Array,hash);
VCALL_LOCALMEM1(Array,push_back);
+ VCALL_LOCALMEM1(Array,push_front);
+ VCALL_LOCALMEM0(Array,pop_back);
+ VCALL_LOCALMEM0(Array,pop_front);
VCALL_LOCALMEM1(Array,append);
VCALL_LOCALMEM1(Array,resize);
VCALL_LOCALMEM2(Array,insert);
@@ -1426,12 +1429,15 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(ARRAY,NIL,Array,clear,varray());
ADDFUNC0(ARRAY,INT,Array,hash,varray());
ADDFUNC1(ARRAY,NIL,Array,push_back,NIL,"value",varray());
+ ADDFUNC1(ARRAY,NIL,Array,push_front,NIL,"value",varray());
ADDFUNC1(ARRAY,NIL,Array,append,NIL,"value",varray());
ADDFUNC1(ARRAY,NIL,Array,resize,INT,"pos",varray());
ADDFUNC2(ARRAY,NIL,Array,insert,INT,"pos",NIL,"value",varray());
ADDFUNC1(ARRAY,NIL,Array,remove,INT,"pos",varray());
ADDFUNC1(ARRAY,NIL,Array,erase,NIL,"value",varray());
ADDFUNC1(ARRAY,INT,Array,find,NIL,"value",varray());
+ ADDFUNC0(ARRAY,NIL,Array,pop_back,varray());
+ ADDFUNC0(ARRAY,NIL,Array,pop_front,varray());
ADDFUNC0(ARRAY,NIL,Array,sort,varray());
ADDFUNC2(ARRAY,NIL,Array,sort_custom,OBJECT,"obj",STRING,"func",varray());
ADDFUNC0(ARRAY,NIL,Array,invert,varray());
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();
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index c96616b42c..4332ba57a3 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -982,7 +982,22 @@ void ScriptEditor::_menu_option(int p_option) {
case WINDOW_PREV: {
_history_back();
} break;
-
+ case DEBUG_SHOW: {
+ if (debugger) {
+ bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW) );
+ debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW), !visible);
+ if (visible)
+ debugger->hide();
+ else
+ debugger->show();
+ }
+ } break;
+ case DEBUG_SHOW_KEEP_OPEN: {
+ bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN) );
+ if (debugger)
+ debugger->set_hide_on_stop(visible);
+ debug_menu->get_popup()->set_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW_KEEP_OPEN), !visible);
+ } break;
}
@@ -1336,12 +1351,6 @@ void ScriptEditor::_menu_option(int p_option) {
debugger->debug_continue();
} break;
- case DEBUG_SHOW: {
- if (debugger) {
- bool visible = debug_menu->get_popup()->is_item_checked( debug_menu->get_popup()->get_item_index(DEBUG_SHOW) );
- _show_debugger(!visible);
- }
- } break;
case HELP_CONTEXTUAL: {
String text = current->get_text_edit()->get_selection_text();
if (text == "")
@@ -2391,6 +2400,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
debug_menu->get_popup()->add_item("Continue",DEBUG_CONTINUE);
debug_menu->get_popup()->add_separator();
debug_menu->get_popup()->add_check_item("Show Debugger",DEBUG_SHOW);
+ debug_menu->get_popup()->add_check_item("Keep Debuger Open",DEBUG_SHOW_KEEP_OPEN);
debug_menu->get_popup()->connect("item_pressed", this,"_menu_option");
debug_menu->get_popup()->set_item_disabled( debug_menu->get_popup()->get_item_index(DEBUG_NEXT), true);
diff --git a/tools/editor/plugins/script_editor_plugin.h b/tools/editor/plugins/script_editor_plugin.h
index 7875b4d144..32c1e7e1c8 100644
--- a/tools/editor/plugins/script_editor_plugin.h
+++ b/tools/editor/plugins/script_editor_plugin.h
@@ -151,7 +151,8 @@ class ScriptEditor : public VBoxContainer {
DEBUG_BREAK,
DEBUG_CONTINUE,
DEBUG_SHOW,
- HELP_CONTEXTUAL,
+ DEBUG_SHOW_KEEP_OPEN,
+ HELP_CONTEXTUAL,
WINDOW_MOVE_LEFT,
WINDOW_MOVE_RIGHT,
WINDOW_NEXT,
diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp
index 6ca949083a..cd265e3704 100644
--- a/tools/editor/script_editor_debugger.cpp
+++ b/tools/editor/script_editor_debugger.cpp
@@ -737,8 +737,12 @@ void ScriptEditorDebugger::stop(){
le_clear->set_disabled(false);
le_set->set_disabled(true);
- if (!always_visible)
+
+ if (hide_on_stop) {
hide();
+ emit_signal("show_debugger",false);
+ }
+
}
@@ -1157,6 +1161,12 @@ void ScriptEditorDebugger:: _error_stack_selected(int p_idx){
}
+<<<<<<< HEAD
+void ScriptEditorDebugger::set_hide_on_stop(bool p_hide) {
+
+ hide_on_stop=p_hide;
+}
+=======
void ScriptEditorDebugger::set_always_visible(bool p_visible) {
always_visible=p_visible;
@@ -1167,6 +1177,7 @@ void ScriptEditorDebugger::set_always_visible(bool p_visible) {
hide();
}
+>>>>>>> c3db5d951c1ee938a0c789c78a9bb8045ef8605b
void ScriptEditorDebugger::_bind_methods() {
@@ -1470,6 +1481,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor){
live_debug=false;
last_path_id=false;
error_count=0;
+ hide_on_stop=true;
last_error_count=0;
diff --git a/tools/editor/script_editor_debugger.h b/tools/editor/script_editor_debugger.h
index 23815ca3bb..906714d13c 100644
--- a/tools/editor/script_editor_debugger.h
+++ b/tools/editor/script_editor_debugger.h
@@ -71,6 +71,8 @@ class ScriptEditorDebugger : public Control {
int error_count;
int last_error_count;
+ bool hide_on_stop;
+
TextureButton *tb;
@@ -183,7 +185,7 @@ public:
void update_live_edit_root();
- void set_always_visible(bool p_visible);
+ void set_hide_on_stop(bool p_hide);
virtual Size2 get_minimum_size() const;
ScriptEditorDebugger(EditorNode *p_editor=NULL);