diff options
62 files changed, 964 insertions, 339 deletions
diff --git a/SConstruct b/SConstruct index d168820f66..0652414088 100644 --- a/SConstruct +++ b/SConstruct @@ -16,7 +16,6 @@ platform_list = [] # list of platforms platform_opts = {} # options for each platform platform_flags = {} # flags for each platform - active_platforms=[] active_platform_ids=[] platform_exporters=[] @@ -60,7 +59,7 @@ platform_arg = ARGUMENTS.get("platform", False) if (os.name=="posix"): pass elif (os.name=="nt"): - if (os.getenv("VSINSTALLDIR")==None or platform_arg=="android"): + if (not methods.msvc_is_detected() or platform_arg=="android"): custom_tools=['mingw'] env_base=Environment(tools=custom_tools); @@ -138,7 +137,8 @@ opts.Add('etc1','etc1 Texture compression support (yes/no)','yes') opts.Add('builtin_zlib','Use built-in zlib (yes/no)','yes') opts.Add('openssl','Use OpenSSL (yes/no/builtin)','no') opts.Add('musepack','Musepack Audio (yes/no)','yes') -opts.Add("CXX", "Compiler"); +opts.Add("CXX", "C++ Compiler") +opts.Add("CC", "C Compiler") opts.Add("CCFLAGS", "Custom flags for the C++ compiler"); opts.Add("CFLAGS", "Custom flags for the C compiler"); opts.Add("LINKFLAGS", "Custom flags for the linker"); diff --git a/core/array.cpp b/core/array.cpp index 23792f90fc..683a43e3d0 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -276,16 +276,26 @@ void Array::push_front(const Variant& p_value) { _p->array.insert(0,p_value); } -void Array::pop_back(){ +Variant Array::pop_back(){ - if (!_p->array.empty()) - _p->array.resize( _p->array.size() -1 ); + if (!_p->array.empty()) { + int n = _p->array.size() - 1; + Variant ret = _p->array.get(n); + _p->array.resize(n); + return ret; + } + return Variant(); } -void Array::pop_front(){ - if (!_p->array.empty()) +Variant Array::pop_front(){ + + if (!_p->array.empty()) { + Variant ret = _p->array.get(0); _p->array.remove(0); + return ret; + } + return Variant(); } diff --git a/core/array.h b/core/array.h index dfc902525c..eb79b0cf33 100644 --- a/core/array.h +++ b/core/array.h @@ -80,8 +80,8 @@ public: void erase(const Variant& p_value); void push_front(const Variant& p_value); - void pop_back(); - void pop_front(); + Variant pop_back(); + Variant pop_front(); Array(const Array& p_from); Array(bool p_shared=false); diff --git a/tools/pck/pck_packer.cpp b/core/io/pck_packer.cpp index 04b88ea028..04b88ea028 100644 --- a/tools/pck/pck_packer.cpp +++ b/core/io/pck_packer.cpp diff --git a/tools/pck/pck_packer.h b/core/io/pck_packer.h index b1182335e2..b1182335e2 100644 --- a/tools/pck/pck_packer.h +++ b/core/io/pck_packer.h diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index b4a13d8f6d..fae3831dd6 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -49,13 +49,13 @@ void Vector3::set_axis(int p_axis,real_t p_value) { } real_t Vector3::get_axis(int p_axis) const { - ERR_FAIL_INDEX_V(p_axis,3,0); - return operator[](p_axis); + ERR_FAIL_INDEX_V(p_axis,3,0); + return operator[](p_axis); } int Vector3::min_axis() const { - return x < y ? (x < z ? 0 : 2) : (y < z ? 1 : 2); + return x < y ? (x < z ? 0 : 2) : (y < z ? 1 : 2); } int Vector3::max_axis() const { @@ -71,9 +71,9 @@ void Vector3::snap(float p_val) { } Vector3 Vector3::snapped(float p_val) const { - Vector3 v=*this; - v.snap(p_val); - return v; + Vector3 v=*this; + v.snap(p_val); + return v; } diff --git a/core/math/vector3.h b/core/math/vector3.h index 910446023a..06840be5e7 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -63,77 +63,78 @@ struct Vector3 { return coord[p_axis]; } - void set_axis(int p_axis,real_t p_value); - real_t get_axis(int p_axis) const; + void set_axis(int p_axis,real_t p_value); + real_t get_axis(int p_axis) const; - int min_axis() const; - int max_axis() const; + int min_axis() const; + int max_axis() const; - _FORCE_INLINE_ real_t length() const; - _FORCE_INLINE_ real_t length_squared() const; + _FORCE_INLINE_ real_t length() const; + _FORCE_INLINE_ real_t length_squared() const; - _FORCE_INLINE_ void normalize(); - _FORCE_INLINE_ Vector3 normalized() const; - _FORCE_INLINE_ Vector3 inverse() const; + _FORCE_INLINE_ void normalize(); + _FORCE_INLINE_ Vector3 normalized() const; + _FORCE_INLINE_ Vector3 inverse() const; _FORCE_INLINE_ void zero(); - void snap(float p_val); - Vector3 snapped(float p_val) const; + void snap(float p_val); + Vector3 snapped(float p_val) const; void rotate(const Vector3& p_axis,float p_phi); Vector3 rotated(const Vector3& p_axis,float p_phi) const; - /* Static Methods between 2 vector3s */ + /* Static Methods between 2 vector3s */ - _FORCE_INLINE_ Vector3 linear_interpolate(const Vector3& p_b,float p_t) const; + _FORCE_INLINE_ Vector3 linear_interpolate(const Vector3& p_b,float p_t) const; Vector3 cubic_interpolate(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const; Vector3 cubic_interpolaten(const Vector3& p_b,const Vector3& p_pre_a, const Vector3& p_post_b,float p_t) const; - _FORCE_INLINE_ Vector3 cross(const Vector3& p_b) const; - _FORCE_INLINE_ real_t dot(const Vector3& p_b) const; + _FORCE_INLINE_ Vector3 cross(const Vector3& p_b) const; + _FORCE_INLINE_ real_t dot(const Vector3& p_b) const; - _FORCE_INLINE_ Vector3 abs() const; - _FORCE_INLINE_ Vector3 floor() const; - _FORCE_INLINE_ Vector3 ceil() const; + _FORCE_INLINE_ Vector3 abs() const; + _FORCE_INLINE_ Vector3 floor() const; + _FORCE_INLINE_ Vector3 ceil() const; - _FORCE_INLINE_ real_t distance_to(const Vector3& p_b) const; - _FORCE_INLINE_ real_t distance_squared_to(const Vector3& p_b) const; + _FORCE_INLINE_ real_t distance_to(const Vector3& p_b) const; + _FORCE_INLINE_ real_t distance_squared_to(const Vector3& p_b) const; + _FORCE_INLINE_ real_t angle_to(const Vector3& p_b) const; _FORCE_INLINE_ Vector3 slide(const Vector3& p_vec) const; _FORCE_INLINE_ Vector3 reflect(const Vector3& p_vec) const; - /* Operators */ + /* Operators */ - _FORCE_INLINE_ Vector3& operator+=(const Vector3& p_v); - _FORCE_INLINE_ Vector3 operator+(const Vector3& p_v) const; - _FORCE_INLINE_ Vector3& operator-=(const Vector3& p_v); - _FORCE_INLINE_ Vector3 operator-(const Vector3& p_v) const; - _FORCE_INLINE_ Vector3& operator*=(const Vector3& p_v); - _FORCE_INLINE_ Vector3 operator*(const Vector3& p_v) const; - _FORCE_INLINE_ Vector3& operator/=(const Vector3& p_v); - _FORCE_INLINE_ Vector3 operator/(const Vector3& p_v) const; + _FORCE_INLINE_ Vector3& operator+=(const Vector3& p_v); + _FORCE_INLINE_ Vector3 operator+(const Vector3& p_v) const; + _FORCE_INLINE_ Vector3& operator-=(const Vector3& p_v); + _FORCE_INLINE_ Vector3 operator-(const Vector3& p_v) const; + _FORCE_INLINE_ Vector3& operator*=(const Vector3& p_v); + _FORCE_INLINE_ Vector3 operator*(const Vector3& p_v) const; + _FORCE_INLINE_ Vector3& operator/=(const Vector3& p_v); + _FORCE_INLINE_ Vector3 operator/(const Vector3& p_v) const; - _FORCE_INLINE_ Vector3& operator*=(real_t p_scalar); - _FORCE_INLINE_ Vector3 operator*(real_t p_scalar) const; - _FORCE_INLINE_ Vector3& operator/=(real_t p_scalar); - _FORCE_INLINE_ Vector3 operator/(real_t p_scalar) const; + _FORCE_INLINE_ Vector3& operator*=(real_t p_scalar); + _FORCE_INLINE_ Vector3 operator*(real_t p_scalar) const; + _FORCE_INLINE_ Vector3& operator/=(real_t p_scalar); + _FORCE_INLINE_ Vector3 operator/(real_t p_scalar) const; - _FORCE_INLINE_ Vector3 operator-() const; + _FORCE_INLINE_ Vector3 operator-() const; - _FORCE_INLINE_ bool operator==(const Vector3& p_v) const; - _FORCE_INLINE_ bool operator!=(const Vector3& p_v) const; - _FORCE_INLINE_ bool operator<(const Vector3& p_v) const; + _FORCE_INLINE_ bool operator==(const Vector3& p_v) const; + _FORCE_INLINE_ bool operator!=(const Vector3& p_v) const; + _FORCE_INLINE_ bool operator<(const Vector3& p_v) const; _FORCE_INLINE_ bool operator<=(const Vector3& p_v) const; operator String() const; - _FORCE_INLINE_ Vector3() { x=y=z=0; } - _FORCE_INLINE_ Vector3(real_t p_x,real_t p_y,real_t p_z) { x=p_x; y=p_y; z=p_z; } + _FORCE_INLINE_ Vector3() { x=y=z=0; } + _FORCE_INLINE_ Vector3(real_t p_x,real_t p_y,real_t p_z) { x=p_x; y=p_y; z=p_z; } }; @@ -151,11 +152,12 @@ Vector3 Vector3::cross(const Vector3& p_b) const { (x * p_b.y) - (y * p_b.x) ); - return ret; + return ret; } + real_t Vector3::dot(const Vector3& p_b) const { - return x*p_b.x + y*p_b.y + z*p_b.z; + return x*p_b.x + y*p_b.y + z*p_b.z; } Vector3 Vector3::abs() const { @@ -180,115 +182,119 @@ Vector3 Vector3::linear_interpolate(const Vector3& p_b,float p_t) const { y+(p_t * (p_b.y-y)), z+(p_t * (p_b.z-z)) ); - } - - real_t Vector3::distance_to(const Vector3& p_b) const { + return (p_b-*this).length(); } + real_t Vector3::distance_squared_to(const Vector3& p_b) const { - return (p_b-*this).length_squared(); + return (p_b-*this).length_squared(); +} + +real_t Vector3::angle_to(const Vector3& p_b) const { + + return Math::acos(this->dot(p_b) / Math::sqrt(this->length_squared() * p_b.length_squared())); } /* Operators */ Vector3& Vector3::operator+=(const Vector3& p_v) { - x+=p_v.x; - y+=p_v.y; - z+=p_v.z; - return *this; + x+=p_v.x; + y+=p_v.y; + z+=p_v.z; + return *this; } + Vector3 Vector3::operator+(const Vector3& p_v) const { - return Vector3(x+p_v.x, y+p_v.y, z+ p_v.z); + return Vector3(x+p_v.x, y+p_v.y, z+ p_v.z); } Vector3& Vector3::operator-=(const Vector3& p_v) { - x-=p_v.x; - y-=p_v.y; - z-=p_v.z; - return *this; + x-=p_v.x; + y-=p_v.y; + z-=p_v.z; + return *this; } Vector3 Vector3::operator-(const Vector3& p_v) const { - return Vector3(x-p_v.x, y-p_v.y, z- p_v.z); + return Vector3(x-p_v.x, y-p_v.y, z- p_v.z); } - - Vector3& Vector3::operator*=(const Vector3& p_v) { - x*=p_v.x; - y*=p_v.y; - z*=p_v.z; - return *this; + x*=p_v.x; + y*=p_v.y; + z*=p_v.z; + return *this; } Vector3 Vector3::operator*(const Vector3& p_v) const { - return Vector3(x*p_v.x, y*p_v.y, z* p_v.z); + return Vector3(x*p_v.x, y*p_v.y, z* p_v.z); } Vector3& Vector3::operator/=(const Vector3& p_v) { - x/=p_v.x; - y/=p_v.y; - z/=p_v.z; - return *this; + x/=p_v.x; + y/=p_v.y; + z/=p_v.z; + return *this; } + Vector3 Vector3::operator/(const Vector3& p_v) const { - return Vector3(x/p_v.x, y/p_v.y, z/ p_v.z); + return Vector3(x/p_v.x, y/p_v.y, z/ p_v.z); } Vector3& Vector3::operator*=(real_t p_scalar) { - x*=p_scalar; - y*=p_scalar; - z*=p_scalar; - return *this; + x*=p_scalar; + y*=p_scalar; + z*=p_scalar; + return *this; } _FORCE_INLINE_ Vector3 operator*(real_t p_scalar, const Vector3& p_vec) { + return p_vec * p_scalar; } Vector3 Vector3::operator*(real_t p_scalar) const { - return Vector3( x*p_scalar, y*p_scalar, z*p_scalar); + return Vector3( x*p_scalar, y*p_scalar, z*p_scalar); } Vector3& Vector3::operator/=(real_t p_scalar) { - x/=p_scalar; - y/=p_scalar; - z/=p_scalar; - return *this; + x/=p_scalar; + y/=p_scalar; + z/=p_scalar; + return *this; } Vector3 Vector3::operator/(real_t p_scalar) const { - return Vector3( x/p_scalar, y/p_scalar, z/p_scalar); + return Vector3( x/p_scalar, y/p_scalar, z/p_scalar); } Vector3 Vector3::operator-() const { - return Vector3( -x, -y, -z ); + return Vector3( -x, -y, -z ); } - bool Vector3::operator==(const Vector3& p_v) const { - return (x==p_v.x && y==p_v.y && z==p_v.z); + return (x==p_v.x && y==p_v.y && z==p_v.z); } bool Vector3::operator!=(const Vector3& p_v) const { - return (x!=p_v.x || y!=p_v.y || z!=p_v.z); + return (x!=p_v.x || y!=p_v.y || z!=p_v.z); } bool Vector3::operator<(const Vector3& p_v) const { @@ -298,9 +304,9 @@ bool Vector3::operator<(const Vector3& p_v) const { return z<p_v.z; else return y<p_v.y; - } else + } else { return x<p_v.x; - + } } bool Vector3::operator<=(const Vector3& p_v) const { @@ -310,9 +316,9 @@ bool Vector3::operator<=(const Vector3& p_v) const { return z<=p_v.z; else return y<p_v.y; - } else + } else { return x<p_v.x; - + } } _FORCE_INLINE_ Vector3 vec3_cross(const Vector3& p_a, const Vector3& p_b) { @@ -333,6 +339,7 @@ real_t Vector3::length() const { return Math::sqrt(x2+y2+z2); } + real_t Vector3::length_squared() const { real_t x2=x*x; @@ -340,27 +347,25 @@ real_t Vector3::length_squared() const { real_t z2=z*z; return x2+y2+z2; - } void Vector3::normalize() { - real_t l=length(); - if (l==0) { - + real_t l=length(); + if (l==0) { x=y=z=0; - } else { - + } else { x/=l; y/=l; z/=l; - } + } } + Vector3 Vector3::normalized() const { - Vector3 v=*this; - v.normalize(); - return v; + Vector3 v=*this; + v.normalize(); + return v; } Vector3 Vector3::inverse() const { @@ -377,10 +382,10 @@ Vector3 Vector3::slide(const Vector3& p_vec) const { return p_vec - *this * this->dot(p_vec); } + Vector3 Vector3::reflect(const Vector3& p_vec) const { return p_vec - *this * this->dot(p_vec) * 2.0; - } #endif diff --git a/core/object.cpp b/core/object.cpp index 8cd4e07097..9a1e9be8d5 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -1215,6 +1215,15 @@ void Object::emit_signal(const StringName& p_name,const Variant** p_args,int p_a Signal *s = signal_map.getptr(p_name); if (!s) { +#ifdef DEBUG_ENABLED + bool signal_is_valid = ObjectTypeDB::has_signal(get_type_name(),p_name); + //check in script + if (!signal_is_valid && !script.is_null() && !Ref<Script>(script)->has_script_signal(p_name)) { + ERR_EXPLAIN("Can't emit non-existing signal " + String("\"")+p_name+"\"."); + ERR_FAIL(); + } +#endif + //not connected? just return return; } diff --git a/core/os/input.cpp b/core/os/input.cpp index 401ab7ffe2..4ab57a84ea 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -64,6 +64,10 @@ void Input::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_connected_joysticks"),&Input::get_connected_joysticks); ObjectTypeDB::bind_method(_MD("get_joy_vibration_strength", "device"), &Input::get_joy_vibration_strength); ObjectTypeDB::bind_method(_MD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration); + ObjectTypeDB::bind_method(_MD("get_joy_button_string", "button_index"), &Input::get_joy_button_string); + ObjectTypeDB::bind_method(_MD("get_joy_button_index_from_string", "button"), &Input::get_joy_button_index_from_string); + ObjectTypeDB::bind_method(_MD("get_joy_axis_string", "axis_index"), &Input::get_joy_axis_string); + ObjectTypeDB::bind_method(_MD("get_joy_axis_index_from_string", "axis"), &Input::get_joy_axis_index_from_string); ObjectTypeDB::bind_method(_MD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0)); ObjectTypeDB::bind_method(_MD("stop_joy_vibration", "device"), &Input::stop_joy_vibration); ObjectTypeDB::bind_method(_MD("get_accelerometer"),&Input::get_accelerometer); @@ -90,7 +94,7 @@ void Input::get_argument_options(const StringName& p_function,int p_idx,List<Str #ifdef TOOLS_ENABLED String pf=p_function; - if (p_idx==0 && (pf=="is_action_pressed" || pf=="action_press" || pf=="action_release")) { + if (p_idx==0 && (pf=="is_action_pressed" || pf=="action_press" || pf=="action_release" || pf=="is_action_just_pressed" || pf=="is_action_just_released")) { List<PropertyInfo> pinfo; Globals::get_singleton()->get_property_list(&pinfo); diff --git a/core/os/input.h b/core/os/input.h index 665fb4ad99..d8f3be09df 100644 --- a/core/os/input.h +++ b/core/os/input.h @@ -96,6 +96,11 @@ public: virtual void set_custom_mouse_cursor(const RES& p_cursor,const Vector2& p_hotspot=Vector2())=0; virtual void set_mouse_in_window(bool p_in_window)=0; + virtual String get_joy_button_string(int p_button)=0; + virtual String get_joy_axis_string(int p_axis)=0; + virtual int get_joy_button_index_from_string(String p_button)=0; + virtual int get_joy_axis_index_from_string(String p_axis)=0; + Input(); }; diff --git a/core/os/os.h b/core/os/os.h index 8e9293b3c8..c2b46a5420 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -372,6 +372,7 @@ public: virtual void set_screen_orientation(ScreenOrientation p_orientation); ScreenOrientation get_screen_orientation() const; + virtual void enable_for_stealing_focus(ProcessID pid) {} virtual void move_window_to_foreground() {} virtual void debug_break(); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 7e4ba039c5..c3a127afb9 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -49,6 +49,7 @@ #include "os/input.h" #include "core/io/xml_parser.h" #include "io/http_client.h" +#include "io/pck_packer.h" #include "packed_data_container.h" #include "func_ref.h" #include "input_map.h" @@ -146,6 +147,8 @@ void register_core_types() { ObjectTypeDB::register_type<ConfigFile>(); + ObjectTypeDB::register_type<PCKPacker>(); + ObjectTypeDB::register_type<PackedDataContainer>(); ObjectTypeDB::register_virtual_type<PackedDataContainerRef>(); ObjectTypeDB::register_type<AStar>(); diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 1ac0907967..6d685d3c43 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -134,6 +134,8 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) { ERR_FAIL(); } + OS::get_singleton()->enable_for_stealing_focus(Globals::get_singleton()->get("editor_pid")); + packet_peer_stream->put_var("debug_enter"); packet_peer_stream->put_var(2); packet_peer_stream->put_var(p_can_continue); @@ -273,6 +275,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) { set_depth(-1); set_lines_left(-1); + OS::get_singleton()->move_window_to_foreground(); break; } else if (command=="break") { ERR_PRINT("Got break when already broke!"); diff --git a/core/ustring.cpp b/core/ustring.cpp index 0d887210c3..2e907381f7 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -3073,6 +3073,11 @@ String String::simplify_path() const { } s =s.replace("\\","/"); + while(true){ // in case of using 2 or more slash + String compare = s.replace("//","/"); + if (s==compare) break; + else s=compare; + } Vector<String> dirs = s.split("/",false); for(int i=0;i<dirs.size();i++) { @@ -3173,7 +3178,7 @@ bool String::is_valid_identifier() const { //kind of poor should be rewritten properly -String String::world_wrap(int p_chars_per_line) const { +String String::word_wrap(int p_chars_per_line) const { int from=0; int last_space=0; diff --git a/core/ustring.h b/core/ustring.h index bb57b11d88..09d13a9e64 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -218,7 +218,7 @@ public: String c_escape() const; String c_unescape() const; String json_escape() const; - String world_wrap(int p_chars_per_line) const; + String word_wrap(int p_chars_per_line) const; String percent_encode() const; String percent_decode() const; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 5f052bce8e..51cd4c2399 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -375,6 +375,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM0R(Vector3, ceil); VCALL_LOCALMEM1R(Vector3, distance_to); VCALL_LOCALMEM1R(Vector3, distance_squared_to); + VCALL_LOCALMEM1R(Vector3, angle_to); VCALL_LOCALMEM1R(Vector3, slide); VCALL_LOCALMEM1R(Vector3, reflect); @@ -465,8 +466,8 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var 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_LOCALMEM0R(Array,pop_back); + VCALL_LOCALMEM0R(Array,pop_front); VCALL_LOCALMEM1(Array,append); VCALL_LOCALMEM1(Array,resize); VCALL_LOCALMEM2(Array,insert); @@ -1487,6 +1488,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(VECTOR3,VECTOR3,Vector3,ceil,varray()); ADDFUNC1(VECTOR3,REAL,Vector3,distance_to,VECTOR3,"b",varray()); ADDFUNC1(VECTOR3,REAL,Vector3,distance_squared_to,VECTOR3,"b",varray()); + ADDFUNC1(VECTOR3,REAL,Vector3,angle_to,VECTOR3,"to",varray()); ADDFUNC1(VECTOR3,VECTOR3,Vector3,slide,VECTOR3,"by",varray()); ADDFUNC1(VECTOR3,VECTOR3,Vector3,reflect,VECTOR3,"by",varray()); diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 023605a952..6b3828a572 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -986,7 +986,18 @@ Error VariantParser::parse_value(Token& token,Variant &value,Stream *p_stream,in InputEvent ie; - if (id=="KEY") { + if (id=="NONE") { + + ie.type=InputEvent::NONE; + + get_token(p_stream,token,line,r_err_str); + + if (token.type!=TK_PARENTHESIS_CLOSE) { + r_err_str="Expected ')'"; + return ERR_PARSE_ERROR; + } + + } else if (id=="KEY") { get_token(p_stream,token,line,r_err_str); if (token.type!=TK_COMMA) { @@ -2093,6 +2104,9 @@ Error VariantWriter::write(const Variant& p_variant, StoreStringFunc p_store_str case InputEvent::JOYSTICK_MOTION: { str+="JAXIS,"+itos(ev.joy_motion.axis)+","+itos(ev.joy_motion.axis_value); } break; + case InputEvent::NONE: { + str+="NONE"; + } break; default: {} } diff --git a/doc/base/classes.xml b/doc/base/classes.xml index ab4610d4f7..c18cba09a4 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -2153,6 +2153,120 @@ <constants> </constants> </class> +<class name="AStar" inherits="Reference" category="Core"> + <brief_description> + </brief_description> + <description> + </description> + <methods> + <method name="add_point"> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="pos" type="Vector3"> + </argument> + <argument index="2" name="weight_scale" type="float" default="1"> + </argument> + <description> + </description> + </method> + <method name="are_points_connected" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + </description> + </method> + <method name="clear"> + <description> + </description> + </method> + <method name="connect_points"> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + </description> + </method> + <method name="disconnect_points"> + <argument index="0" name="id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + </description> + </method> + <method name="get_available_point_id" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> + <method name="get_closest_point" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="to_pos" type="Vector3"> + </argument> + <description> + </description> + </method> + <method name="get_closest_pos_in_segment" qualifiers="const"> + <return type="Vector3"> + </return> + <argument index="0" name="to_pos" type="Vector3"> + </argument> + <description> + </description> + </method> + <method name="get_id_path"> + <return type="IntArray"> + </return> + <argument index="0" name="from_id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + </description> + </method> + <method name="get_point_path"> + <return type="Vector3Array"> + </return> + <argument index="0" name="from_id" type="int"> + </argument> + <argument index="1" name="to_id" type="int"> + </argument> + <description> + </description> + </method> + <method name="get_point_pos" qualifiers="const"> + <return type="Vector3"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + </description> + </method> + <method name="get_point_weight_scale" qualifiers="const"> + <return type="float"> + </return> + <argument index="0" name="id" type="int"> + </argument> + <description> + </description> + </method> + <method name="remove_point"> + <argument index="0" name="id" type="int"> + </argument> + <description> + </description> + </method> + </methods> + <constants> + </constants> +</class> <class name="AcceptDialog" inherits="WindowDialog" category="Core"> <brief_description> Base dialog for user notification. @@ -4024,7 +4138,7 @@ </argument> <argument index="2" name="area_shape" type="int"> </argument> - <argument index="3" name="area_shape" type="int"> + <argument index="3" name="self_shape" type="int"> </argument> <description> This signal triggers only once when an area enters this area. The first parameter is the area's [RID]. The second one is the area as an object. The third one is the index of the shape entering this area, and the fourth one is the index of the shape in this area that reported the entering. @@ -4044,7 +4158,7 @@ </argument> <argument index="2" name="area_shape" type="int"> </argument> - <argument index="3" name="area_shape" type="int"> + <argument index="3" name="self_shape" type="int"> </argument> <description> This signal triggers only once when an area exits this area. The first parameter is the area's [RID]. The second one is the area as an object. The third one is the index of the shape entering this area, and the fourth one is the index of the shape in this area that reported the entering. @@ -4366,7 +4480,7 @@ </argument> <argument index="2" name="area_shape" type="int"> </argument> - <argument index="3" name="area_shape" type="int"> + <argument index="3" name="self_shape" type="int"> </argument> <description> This signal triggers only once when an area enters this area. The first parameter is the area's [RID]. The second one is the area as an object. The third one is the index of the shape entering this area, and the fourth one is the index of the shape in this area that reported the entering. @@ -4386,7 +4500,7 @@ </argument> <argument index="2" name="area_shape" type="int"> </argument> - <argument index="3" name="area_shape" type="int"> + <argument index="3" name="self_shape" type="int"> </argument> <description> This signal triggers only once when an area exits this area. The first parameter is the area's [RID]. The second one is the area as an object. The third one is the index of the shape entering this area, and the fourth one is the index of the shape in this area that reported the entering. @@ -6755,6 +6869,12 @@ <description> </description> </method> + <method name="get_custom_viewport" qualifiers="const"> + <return type="Viewport"> + </return> + <description> + </description> + </method> <method name="get_drag_margin" qualifiers="const"> <return type="float"> </return> @@ -6858,6 +6978,12 @@ <description> </description> </method> + <method name="set_custom_viewport"> + <argument index="0" name="viewport" type="Viewport"> + </argument> + <description> + </description> + </method> <method name="set_drag_margin"> <argument index="0" name="margin" type="int"> </argument> @@ -7560,6 +7686,12 @@ Canvas Item layer. [CanvasItem] nodes that are direct or indirect children of a [CanvasLayer] will be drawn in that layer. The layer is a numeric index that defines the draw order. The default 2D scene renders with index 0, so a [CanvasLayer] with index -1 will be drawn below, and one with index 1 will be drawn above. This is very useful for HUDs (in layer 1+ or above), or backgrounds (in layer -1 or below). </description> <methods> + <method name="get_custom_viewport" qualifiers="const"> + <return type="Viewport"> + </return> + <description> + </description> + </method> <method name="get_layer" qualifiers="const"> <return type="int"> </return> @@ -7602,13 +7734,6 @@ Return the base transform for this layer. </description> </method> - <method name="get_viewport" qualifiers="const"> - <return type="RID"> - </return> - <description> - Return the viewport RID for this layer. - </description> - </method> <method name="get_world_2d" qualifiers="const"> <return type="World2D"> </return> @@ -7616,6 +7741,12 @@ Return the [World2D] used by this layer. </description> </method> + <method name="set_custom_viewport"> + <argument index="0" name="viewport" type="Viewport"> + </argument> + <description> + </description> + </method> <method name="set_layer"> <argument index="0" name="layer" type="int"> </argument> @@ -8678,6 +8809,28 @@ <constants> </constants> </class> +<class name="ColorFrame" inherits="Control" category="Core"> + <brief_description> + </brief_description> + <description> + </description> + <methods> + <method name="get_frame_color" qualifiers="const"> + <return type="Color"> + </return> + <description> + </description> + </method> + <method name="set_frame_color"> + <argument index="0" name="color" type="Color"> + </argument> + <description> + </description> + </method> + </methods> + <constants> + </constants> +</class> <class name="ColorPicker" inherits="BoxContainer" category="Core"> <brief_description> Color picker control. @@ -11769,6 +11922,10 @@ Return true if this is a main screen editor plugin (it goes in the main screen selector together with 2D, 3D, Script). </description> </method> + <method name="hide_bottom_panel"> + <description> + </description> + </method> <method name="inspect_object"> <argument index="0" name="object" type="Object"> </argument> @@ -11778,6 +11935,12 @@ Inspect an object in the inspector. </description> </method> + <method name="make_bottom_panel_item_visible"> + <argument index="0" name="item" type="Control"> + </argument> + <description> + </description> + </method> <method name="make_visible" qualifiers="virtual"> <argument index="0" name="visible" type="bool"> </argument> @@ -12076,7 +12239,7 @@ <return type="Array"> </return> <description> - Get the list of selected nodes, optimized for transform operations (ie, moving them, rotating, etc). This list avoids situations where a node is selected and also chid/grandchild. + Get the list of selected nodes, optimized for transform operations (ie, moving them, rotating, etc). This list avoids situations where a node is selected and also chid/grandchild. </description> </method> <method name="remove_node"> @@ -16487,6 +16650,38 @@ Returns the current value of the joystick axis at given index (see JOY_* constants in [@Global Scope]) </description> </method> + <method name="get_joy_axis_index_from_string"> + <return type="int"> + </return> + <argument index="0" name="axis" type="String"> + </argument> + <description> + </description> + </method> + <method name="get_joy_axis_string"> + <return type="String"> + </return> + <argument index="0" name="axis_index" type="int"> + </argument> + <description> + </description> + </method> + <method name="get_joy_button_index_from_string"> + <return type="int"> + </return> + <argument index="0" name="button" type="String"> + </argument> + <description> + </description> + </method> + <method name="get_joy_button_string"> + <return type="String"> + </return> + <argument index="0" name="button_index" type="int"> + </argument> + <description> + </description> + </method> <method name="get_joy_guid" qualifiers="const"> <return type="String"> </return> @@ -31666,14 +31861,21 @@ </class> <class name="RayCast" inherits="Spatial" category="Core"> <brief_description> + Query the closest object intersecting a ray. </brief_description> <description> + A RayCast represents a line from its origin to its destination position [code]cast_to[/code], it is used to query the 3D space in order to find the closest object intersecting with the ray. + + RayCast can ignore some objects by adding them to the exception list via [code]add_exception[/code], setting proper filtering with layers, or by filtering object types with type masks. + + Only enabled raycasts will be able to query the space and report collisions! </description> <methods> <method name="add_exception"> <argument index="0" name="node" type="Object"> </argument> <description> + Adds a collision exception so the ray does not report collisions with the specified [code]node[/code]. </description> </method> <method name="add_exception_rid"> @@ -31684,30 +31886,35 @@ </method> <method name="clear_exceptions"> <description> + Removes all collision exception for this ray. </description> </method> <method name="get_cast_to" qualifiers="const"> <return type="Vector3"> </return> <description> + Return the destination point of this ray object. </description> </method> <method name="get_collider" qualifiers="const"> <return type="Object"> </return> <description> + Return the closest object the ray is pointing to. Note that this does not consider the length of the vector, so you must also use [method is_colliding] to check if the object returned is actually colliding with the ray. </description> </method> <method name="get_collider_shape" qualifiers="const"> <return type="int"> </return> <description> + Returns the collision shape of the closest object the ray is pointing to. </description> </method> <method name="get_collision_normal" qualifiers="const"> <return type="Vector3"> </return> <description> + Returns the normal of the intersecting object shape face containing the collision point. </description> </method> <method name="get_collision_point" qualifiers="const"> @@ -31721,30 +31928,35 @@ <return type="int"> </return> <description> + Returns the layer mask for this ray. </description> </method> <method name="get_type_mask" qualifiers="const"> <return type="int"> </return> <description> + Returns the type mask (types of objects to detect) for this ray. The value is a sum (bitwise OR'd) of constants available for [PhysicsDirectSpaceState]. </description> </method> <method name="is_colliding" qualifiers="const"> <return type="bool"> </return> <description> + Return whether the closest object the ray is pointing to is colliding with the vector (considering the vector length). </description> </method> <method name="is_enabled" qualifiers="const"> <return type="bool"> </return> <description> + Returns whether this raycast is enabled or not. </description> </method> <method name="remove_exception"> <argument index="0" name="node" type="Object"> </argument> <description> + Removes a collision exception so the ray does report collisions with the specified [code]node[/code]. </description> </method> <method name="remove_exception_rid"> @@ -31764,18 +31976,21 @@ <argument index="0" name="enabled" type="bool"> </argument> <description> + Enables the RayCast2D. Only enabled raycasts will be able to query the space and report collisions. </description> </method> <method name="set_layer_mask"> <argument index="0" name="mask" type="int"> </argument> <description> + Set the mask to filter objects. Only objects with at least the same mask element set will be detected. </description> </method> <method name="set_type_mask"> <argument index="0" name="mask" type="int"> </argument> <description> + Set the types of objects to detect. For [code]mask[/code] use a logic sum (OR operation) of constants defined in [PhysicsDirectSpaceState], eg. [code]PhysicsDirectSpaceState.TYPE_MASK_STATIC_BODY | PhysicsDirectSpaceState.TYPE_MASK_KINEMATIC_BODY[/code] to detect only those two types. </description> </method> </methods> @@ -31784,10 +31999,14 @@ </class> <class name="RayCast2D" inherits="Node2D" category="Core"> <brief_description> - Query the closest object intersecting a ray + Query the closest object intersecting a ray. </brief_description> <description> A RayCast2D represents a line from its origin to its destination position [code]cast_to[/code], it is used to query the 2D space in order to find the closest object intersecting with the ray. + + RayCast2D can ignore some objects by adding them to the exception list via [code]add_exception[/code], setting proper filtering with layers, or by filtering object types with type masks. + + Only enabled raycasts will be able to query the space and report collisions! </description> <methods> <method name="add_exception"> @@ -31812,7 +32031,7 @@ <return type="Vector2"> </return> <description> - Return the destination point of this ray object + Return the destination point of this ray object. </description> </method> <method name="get_collider" qualifiers="const"> @@ -31840,13 +32059,14 @@ <return type="Vector2"> </return> <description> - Returns the collision point in which the ray intersects the closest object. + Returns the collision point in which the ray intersects the closest object. This point is in [b]global[/b] coordinate system. </description> </method> <method name="get_exclude_parent_body" qualifiers="const"> <return type="bool"> </return> <description> + Returns whether this ray should hit your parent node, if it's a body. </description> </method> <method name="get_layer_mask" qualifiers="const"> @@ -31860,6 +32080,7 @@ <return type="int"> </return> <description> + Returns the type mask (types of objects to detect) for this ray. The value is a sum (bitwise OR'd) of constants available for [Physics2DDirectSpaceState]. </description> </method> <method name="is_colliding" qualifiers="const"> @@ -31873,7 +32094,7 @@ <return type="bool"> </return> <description> - Returns whether this raycast is enabled or not + Returns whether this raycast is enabled or not. </description> </method> <method name="remove_exception"> @@ -31907,18 +32128,21 @@ <argument index="0" name="mask" type="bool"> </argument> <description> + Toggle whether this ray should hit your parent node, if it's a body. </description> </method> <method name="set_layer_mask"> <argument index="0" name="mask" type="int"> </argument> <description> + Set the mask to filter objects. Only objects with at least the same mask element set will be detected. </description> </method> <method name="set_type_mask"> <argument index="0" name="mask" type="int"> </argument> <description> + Set the types of objects to detect. For [code]mask[/code] use a logic sum (OR operation) of constants defined in [Physics2DDirectSpaceState], eg. [code]Physics2DDirectSpaceState.TYPE_MASK_STATIC_BODY | Physics2DDirectSpaceState.TYPE_MASK_KINEMATIC_BODY[/code] to detect only those two types. </description> </method> </methods> @@ -40910,6 +41134,16 @@ <description> </description> </signal> + <signal name="symbol_lookup"> + <argument index="0" name="symbol" type="String"> + </argument> + <argument index="1" name="row" type="int"> + </argument> + <argument index="2" name="column" type="int"> + </argument> + <description> + </description> + </signal> <signal name="text_changed"> <description> Emitted when the text changes. @@ -44541,6 +44775,14 @@ do_property]. Returns the angle in radians between the line connecting the two points and the x coordinate. </description> </method> + <method name="clamped"> + <return type="Vector2"> + </return> + <argument index="0" name="length" type="float"> + </argument> + <description> + </description> + </method> <method name="cubic_interpolate"> <return type="Vector2"> </return> @@ -45627,6 +45869,12 @@ do_property]. Return the 3D world of the viewport. </description> </method> + <method name="get_world_2d" qualifiers="const"> + <return type="World2D"> + </return> + <description> + </description> + </method> <method name="gui_get_drag_data" qualifiers="const"> <return type="Variant"> </return> @@ -45850,6 +46098,12 @@ do_property]. Change the 3D world of the viewport. </description> </method> + <method name="set_world_2d"> + <argument index="0" name="world_2d" type="World2D"> + </argument> + <description> + </description> + </method> <method name="unhandled_input"> <argument index="0" name="local_event" type="InputEvent"> </argument> @@ -46170,12 +46424,24 @@ do_property]. <description> </description> <methods> + <method name="get_aabb" qualifiers="const"> + <return type="AABB"> + </return> + <description> + </description> + </method> <method name="get_layer_mask" qualifiers="const"> <return type="int"> </return> <description> </description> </method> + <method name="get_transformed_aabb" qualifiers="const"> + <return type="AABB"> + </return> + <description> + </description> + </method> <method name="set_base"> <argument index="0" name="base" type="RID"> </argument> diff --git a/drivers/builtin_openssl2/SCsub b/drivers/builtin_openssl2/SCsub index a28bc2922c..0c035cc4a5 100644 --- a/drivers/builtin_openssl2/SCsub +++ b/drivers/builtin_openssl2/SCsub @@ -656,7 +656,8 @@ if "platform" in env and env["platform"] == "winrt": # Workaround for compilation error with GCC/Clang when -Werror is too greedy (GH-4517) import os -if not (os.name=="nt" and os.getenv("VSINSTALLDIR")!=None): # not Windows and not MSVC +import methods +if not (os.name=="nt" and methods.msvc_is_detected() ): # not Windows and not MSVC env_drivers.Append(CFLAGS=["-Wno-error=implicit-function-declaration"]) env_drivers.add_source_files(env.drivers_sources,openssl_sources) diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index cb137294d8..a7edc8d935 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -36,6 +36,7 @@ #include "servers/visual/particle_system_sw.h" #include "gl_context/context_gl.h" #include <string.h> +#include <stdlib.h> #ifdef GLEW_ENABLED #define _GL_HALF_FLOAT_OES 0x140B @@ -5455,9 +5456,16 @@ void RasterizerGLES2::_setup_light(uint16_t p_light) { } - light_data[VL_LIGHT_ATTENUATION][0]=l->vars[VS::LIGHT_PARAM_ENERGY]; - light_data[VL_LIGHT_ATTENUATION][1]=l->vars[VS::LIGHT_PARAM_RADIUS]; - light_data[VL_LIGHT_ATTENUATION][2]=l->vars[VS::LIGHT_PARAM_ATTENUATION]; + light_data[VL_LIGHT_ATTENUATION][0] = l->vars[VS::LIGHT_PARAM_ENERGY]; + + if (l->type == VS::LIGHT_DIRECTIONAL) { + light_data[VL_LIGHT_ATTENUATION][1] = l->directional_shadow_param[VS::LIGHT_DIRECTIONAL_SHADOW_PARAM_MAX_DISTANCE]; + } + else{ + light_data[VL_LIGHT_ATTENUATION][1] = l->vars[VS::LIGHT_PARAM_RADIUS]; + } + + light_data[VL_LIGHT_ATTENUATION][2] = l->vars[VS::LIGHT_PARAM_ATTENUATION]; light_data[VL_LIGHT_SPOT_ATTENUATION][0]=Math::cos(Math::deg2rad(l->vars[VS::LIGHT_PARAM_SPOT_ANGLE])); light_data[VL_LIGHT_SPOT_ATTENUATION][1]=l->vars[VS::LIGHT_PARAM_SPOT_ATTENUATION]; @@ -7018,6 +7026,10 @@ void RasterizerGLES2::_process_glow_bloom() { void RasterizerGLES2::_process_hdr() { + if (framebuffer.luminance.empty()) { + return; + } + glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.luminance[0].fbo); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, framebuffer.color ); @@ -10850,11 +10862,11 @@ void RasterizerGLES2::init() { // Check for GL 2.1 compatibility, if not bail out if (!(glewIsSupported("GL_VERSION_2_1") && framebuffer_object_is_supported)) { ERR_PRINT("Your system's graphic drivers seem not to support OpenGL 2.1 / GLES 2.0, sorry :(\n" - "Try a drivers update, buy a new GPU or try software rendering on Linux; Godot will now crash with a segmentation fault."); + "Try a drivers update, buy a new GPU or try software rendering on Linux; Godot is now going to terminate."); OS::get_singleton()->alert("Your system's graphic drivers seem not to support OpenGL 2.1 / GLES 2.0, sorry :(\n" "Godot Engine will self-destruct as soon as you acknowledge this error message.", "Fatal error: Insufficient OpenGL / GLES drivers"); - // TODO: If it's even possible, we should stop the execution without segfault and memory leaks :) + exit(1); } #endif diff --git a/drivers/gles2/shaders/material.glsl b/drivers/gles2/shaders/material.glsl index 477a451f2f..e5be25757d 100644 --- a/drivers/gles2/shaders/material.glsl +++ b/drivers/gles2/shaders/material.glsl @@ -980,6 +980,12 @@ FRAGMENT_SHADER_CODE #ifdef LIGHT_USE_SHADOW #ifdef LIGHT_TYPE_DIRECTIONAL + float shadow_fade_exponent=5.0; //hardcoded for now + float shadow_fade=pow(length(vertex_interp)/light_attenuation.g,shadow_fade_exponent); + +// optimization - skip shadows outside visible range + if(shadow_fade<1.0){ + #ifdef LIGHT_USE_PSSM @@ -1105,6 +1111,12 @@ FRAGMENT_SHADER_CODE shadow_attenuation=SAMPLE_SHADOW_TEX(shadow_coord.xy,shadow_coord.z); #endif + + shadow_attenuation=mix(shadow_attenuation,1.0,shadow_fade); + }else{ + shadow_attenuation=1.0; + }; + #endif #ifdef LIGHT_TYPE_OMNI diff --git a/drivers/theora/SCsub b/drivers/theora/SCsub index fa85b49804..94477d2827 100644 --- a/drivers/theora/SCsub +++ b/drivers/theora/SCsub @@ -1,11 +1,11 @@ Import('env') sources = [ - "theora/analyze.c", - "theora/apiwrapper.c", + #"theora/analyze.c", + #"theora/apiwrapper.c", "theora/bitpack.c", "theora/cpu.c", - "theora/decapiwrapper.c", + #"theora/decapiwrapper.c", "theora/decinfo.c", "theora/decode.c", "theora/dequant.c", @@ -13,55 +13,53 @@ sources = [ #"theora/encfrag.c", #"theora/encinfo.c", #"theora/encode.c", - "theora/encoder_disabled.c", - "theora/enquant.c", - "theora/fdct.c", + #"theora/encoder_disabled.c", + #"theora/enquant.c", + #"theora/fdct.c", "theora/fragment.c", "theora/huffdec.c", - "theora/huffenc.c", + #"theora/huffenc.c", "theora/idct.c", "theora/info.c", "theora/internal.c", - "theora/mathops.c", - "theora/mcenc.c", + #"theora/mathops.c", + #"theora/mcenc.c", "theora/quant.c", - "theora/rate.c", + #"theora/rate.c", "theora/state.c", - "theora/tokenize.c", + #"theora/tokenize.c", "theora/video_stream_theora.cpp", ] sources_x86 = [ - "theora/x86/mmxencfrag.c", - "theora/x86/mmxfdct.c", + #"theora/x86/mmxencfrag.c", + #"theora/x86/mmxfdct.c", "theora/x86/mmxfrag.c", "theora/x86/mmxidct.c", "theora/x86/mmxstate.c", - "theora/x86/sse2fdct.c", - "theora/x86/x86enc.c", + #"theora/x86/sse2fdct.c", + #"theora/x86/x86enc.c", "theora/x86/x86state.c", ] sources_x86_vc = [ - "theora/x86_vc/mmxencfrag.c", - "theora/x86_vc/mmxfdct.c", + #"theora/x86_vc/mmxencfrag.c", + #"theora/x86_vc/mmxfdct.c", "theora/x86_vc/mmxfrag.c", "theora/x86_vc/mmxidct.c", "theora/x86_vc/mmxstate.c", - "theora/x86_vc/x86enc.c", + #"theora/x86_vc/x86enc.c", "theora/x86_vc/x86state.c", ] env.drivers_sources += sources if (env["x86_opt_gcc"]): - env.Append(CCFLAGS=["-DOC_X86_ASM"]) env.drivers_sources += sources_x86 if (env["x86_opt_vc"]): - env.Append(CCFLAGS=["-DOC_X86_ASM"]) env.drivers_sources += sources_x86_vc - - - +if (env["x86_opt_gcc"] or env["x86_opt_vc"]): + Import('env_drivers') + env_drivers.Append(CCFLAGS=["-DOC_X86_ASM"]) diff --git a/main/input_default.cpp b/main/input_default.cpp index 2020f7a5ad..92f4a6fb72 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -1159,3 +1159,61 @@ Array InputDefault::get_connected_joysticks() { } return ret; } + +static const char* _buttons[] = { + "Face Button Bottom", + "Face Button Right", + "Face Button Left", + "Face Button Top", + "L", + "R", + "L2", + "R2", + "L3", + "R3", + "Select", + "Start", + "DPAD Up", + "DPAD Down", + "DPAD Left", + "DPAD Right" +}; + +static const char* _axes[] = { + "Left Stick X", + "Left Stick Y", + "Right Stick X", + "Right Stick Y", + "", + "", + "L2", + "R2" +}; + +String InputDefault::get_joy_button_string(int p_button) { + ERR_FAIL_INDEX_V(p_button, JOY_BUTTON_MAX, ""); + return _buttons[p_button]; +} + +int InputDefault::get_joy_button_index_from_string(String p_button) { + for (int i = 0; i < JOY_BUTTON_MAX; i++) { + if (p_button == _buttons[i]) { + return i; + } + } + ERR_FAIL_V(-1); +} + +String InputDefault::get_joy_axis_string(int p_axis) { + ERR_FAIL_INDEX_V(p_axis, JOY_AXIS_MAX, ""); + return _axes[p_axis]; +} + +int InputDefault::get_joy_axis_index_from_string(String p_axis) { + for (int i = 0; i < JOY_AXIS_MAX; i++) { + if (p_axis == _axes[i]) { + return i; + } + } + ERR_FAIL_V(-1); +} diff --git a/main/input_default.h b/main/input_default.h index fbf7837b3b..2db6d28abf 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -235,6 +235,11 @@ public: virtual bool is_joy_known(int p_device); virtual String get_joy_guid(int p_device) const; + virtual String get_joy_button_string(int p_button); + virtual String get_joy_axis_string(int p_axis); + virtual int get_joy_axis_index_from_string(String p_axis); + virtual int get_joy_button_index_from_string(String p_button); + bool is_joy_mapped(int p_device); String get_joy_guid_remapped(int p_device) const; void set_fallback_mapping(String p_guid); diff --git a/main/main.cpp b/main/main.cpp index d2ba38b094..912e8adf4f 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -57,7 +57,6 @@ #include "tools/editor/editor_node.h" #include "tools/editor/project_manager.h" -#include "tools/pck/pck_packer.h" #endif #include "io/file_access_network.h" @@ -560,6 +559,16 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas goto error; } + } else if (I->get()=="-epid") { + if (I->next()) { + + int editor_pid=I->next()->get().to_int(); + Globals::get_singleton()->set("editor_pid",editor_pid); + N=I->next()->next(); + } else { + goto error; + + } } else { //test for game path @@ -996,7 +1005,7 @@ Error Main::setup2() { #ifdef TOOLS_ENABLED ObjectTypeDB::set_current_api(ObjectTypeDB::API_EDITOR); EditorNode::register_editor_types(); - ObjectTypeDB::register_type<PCKPacker>(); // todo: move somewhere else + ObjectTypeDB::set_current_api(ObjectTypeDB::API_CORE); #endif @@ -1755,4 +1764,3 @@ void Main::cleanup() { } - diff --git a/methods.py b/methods.py index c28ed55dda..c4951c69bd 100755 --- a/methods.py +++ b/methods.py @@ -1516,6 +1516,12 @@ def detect_visual_c_compiler_version(tools_env): return vc_chosen_compiler_str +def msvc_is_detected() : + # looks for VisualStudio env variable + # or for Visual C++ Build Tools (which is a standalone MSVC) + return os.getenv("VSINSTALLDIR") or os.getenv("VS100COMNTOOLS") or os.getenv("VS110COMNTOOLS") or os.getenv("VS120COMNTOOLS") or os.getenv("VS140COMNTOOLS"); + + def precious_program(env, program, sources, **args): program = env.ProgramOriginal(program, sources, **args) env.Precious(program) diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index 18a4347edf..4134ed037f 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -359,7 +359,7 @@ Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer,int &r_buffe incoming_packets.pop_front(); *r_buffer=(const uint8_t*)(¤t_packet.packet->data[12]); - r_buffer_size=current_packet.packet->dataLength; + r_buffer_size=current_packet.packet->dataLength-12; return OK; } diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 4e395a6f9f..862709fc7d 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -132,15 +132,10 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_ AudioDriverManagerSW::add_driver(&audio_driver_android); - if (true) { - RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,use_reload_hooks,false,use_reload_hooks ) ); - if (gl_extensions) - rasterizer_gles22->set_extensions(gl_extensions); - rasterizer = rasterizer_gles22; - } else { - //rasterizer = memnew( RasterizerGLES1(use_reload_hooks, use_reload_hooks) ); - - } + RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,use_reload_hooks,false,use_reload_hooks ) ); + if (gl_extensions) + rasterizer_gles22->set_extensions(gl_extensions); + rasterizer = rasterizer_gles22; rasterizer->set_force_16_bits_fbo(use_16bits_fbo); diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 0548b84cfa..12ea5a93ee 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -1,10 +1,11 @@ # -# tested on | Windows native | Linux cross-compilation -# ------------------------+-------------------+--------------------------- -# MSVS C++ 2010 Express | WORKS | n/a -# Mingw-w64 | WORKS | WORKS -# Mingw-w32 | WORKS | WORKS -# MinGW | WORKS | untested +# tested on | Windows native | Linux cross-compilation +# ----------------------------+-------------------+--------------------------- +# MSVS C++ 2010 Express | WORKS | n/a +# Visual C++ Build Tools 2015 | WORKS | n/a +# Mingw-w64 | WORKS | WORKS +# Mingw-w32 | WORKS | WORKS +# MinGW | WORKS | untested # ##### # Notes about MSVS C++ : @@ -12,6 +13,12 @@ # - MSVC2010-Express compiles to 32bits only. # ##### +# Note about Visual C++ Build Tools : +# +# - Visual C++ Build Tools is the standalone MSVC compiler : +# http://landinghub.visualstudio.com/visual-cpp-build-tools +# +##### # Notes about Mingw-w64 and Mingw-w32 under Windows : # # - both can be installed using the official installer : @@ -78,7 +85,7 @@ ##### # TODO : -# +# # - finish to cleanup this script to remove all the remains of previous hacks and workarounds # - make it work with the Windows7 SDK that is supposed to enable 64bits compilation for MSVC2010-Express # - confirm it works well with other Visual Studio versions. @@ -102,7 +109,7 @@ def can_build(): if (os.name=="nt"): #building natively on windows! - if (os.getenv("VSINSTALLDIR")): + if ( methods.msvc_is_detected() ): return True else: print("\nMSVC not detected, attempting Mingw.") @@ -197,7 +204,7 @@ def configure(env): env.Append(CPPPATH=['#platform/windows']) env['is_mingw']=False - if (os.name=="nt" and os.getenv("VSINSTALLDIR")!=None): + if (os.name=="nt" and methods.msvc_is_detected() ): #build using visual studio env['ENV']['TMP'] = os.environ['TMP'] env.Append(CPPPATH=['#platform/windows/include']) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index cebafdabce..35d90a8308 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1312,10 +1312,13 @@ void OS_Windows::finalize_core() { void OS_Windows::vprint(const char* p_format, va_list p_list, bool p_stderr) { - char buf[16384+1]; - int len = vsnprintf(buf,16384,p_format,p_list); + const unsigned int BUFFER_SIZE = 16384; + char buf[BUFFER_SIZE+1]; // +1 for the terminating character + int len = vsnprintf(buf,BUFFER_SIZE,p_format,p_list); if (len<=0) return; + if(len >= BUFFER_SIZE) + len = BUFFER_SIZE; // Output is too big, will be truncated buf[len]=0; @@ -2154,10 +2157,15 @@ String OS_Windows::get_stdin_string(bool p_block) { } +void OS_Windows::enable_for_stealing_focus(ProcessID pid) { + + AllowSetForegroundWindow(pid); + +} + void OS_Windows::move_window_to_foreground() { SetForegroundWindow(hWnd); - BringWindowToTop(hWnd); } diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index e3e037e57b..70ef694957 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -269,6 +269,7 @@ public: virtual String get_locale() const; virtual LatinKeyboardVariant get_latin_keyboard_variant() const; + virtual void enable_for_stealing_focus(ProcessID pid); virtual void move_window_to_foreground(); virtual String get_data_dir() const; virtual String get_system_dir(SystemDir p_dir) const; diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 71728966fd..e8954b7e98 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -650,8 +650,8 @@ void Area2D::_bind_methods() { ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"))); ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body",PROPERTY_HINT_RESOURCE_TYPE,"PhysicsBody2D"))); - ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape"))); - ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape"))); + ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape"))); + ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape"))); ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"))); ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area2D"))); diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index a8a4122016..c1d0d1a97c 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -640,8 +640,8 @@ void Area::_bind_methods() { ADD_SIGNAL( MethodInfo("body_enter",PropertyInfo(Variant::OBJECT,"body"))); ADD_SIGNAL( MethodInfo("body_exit",PropertyInfo(Variant::OBJECT,"body"))); - ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape"))); - ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"area_shape"))); + ADD_SIGNAL( MethodInfo("area_enter_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape"))); + ADD_SIGNAL( MethodInfo("area_exit_shape",PropertyInfo(Variant::INT,"area_id"),PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"),PropertyInfo(Variant::INT,"area_shape"),PropertyInfo(Variant::INT,"self_shape"))); ADD_SIGNAL( MethodInfo("area_enter",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"))); ADD_SIGNAL( MethodInfo("area_exit",PropertyInfo(Variant::OBJECT,"area",PROPERTY_HINT_RESOURCE_TYPE,"Area"))); diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 89cd509fbd..f69ad8fa7e 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -959,7 +959,23 @@ void ItemList::_notification(int p_what) { shape_changed=false; } + //ensure_selected_visible needs to be checked before we draw the list. + if (ensure_selected_visible && current>=0 && current <=items.size()) { + Rect2 r = items[current].rect_cache; + int from = scroll_bar->get_val(); + int to = from + scroll_bar->get_page(); + + if (r.pos.y < from) { + scroll_bar->set_val(r.pos.y); + } else if (r.pos.y+r.size.y > to) { + scroll_bar->set_val(r.pos.y+r.size.y - (to-from)); + } + + + } + + ensure_selected_visible=false; Vector2 base_ofs = bg->get_offset(); base_ofs.y-=int(scroll_bar->get_val()); @@ -1147,25 +1163,6 @@ void ItemList::_notification(int p_what) { for(int i=0;i<separators.size();i++) { draw_line(Vector2(bg->get_margin(MARGIN_LEFT),base_ofs.y+separators[i]),Vector2(size.width-bg->get_margin(MARGIN_LEFT),base_ofs.y+separators[i]),guide_color); } - - - if (ensure_selected_visible && current>=0 && current <=items.size()) { - - Rect2 r = items[current].rect_cache; - int from = scroll_bar->get_val(); - int to = from + scroll_bar->get_page(); - - if (r.pos.y < from) { - scroll_bar->set_val(r.pos.y); - } else if (r.pos.y+r.size.y > to) { - scroll_bar->set_val(r.pos.y+r.size.y - (to-from)); - } - - - } - - ensure_selected_visible=false; - } } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 9e58199f35..f7d74b2b49 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -639,6 +639,7 @@ void LineEdit::_notification(int p_what) { if(text.empty()) font_color.a *= placeholder_alpha; + int caret_height = font->get_height() > y_area ? y_area : font->get_height(); while(true) { //end of string, break! @@ -657,14 +658,14 @@ void LineEdit::_notification(int p_what) { bool selected=selection.enabled && char_ofs>=selection.begin && char_ofs<selection.end; if (selected) - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, y_area)), selection_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, caret_height)), selection_color); font->draw_char(ci, Point2(x_ofs, y_ofs + font_ascent), cchar, next, selected ? font_color_selected : font_color); if (char_ofs==cursor_pos && draw_caret) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2( - Point2( x_ofs , y_ofs ), Size2( 1, y_area ) ), cursor_color ); + Point2( x_ofs , y_ofs ), Size2( 1, caret_height ) ), cursor_color ); } x_ofs+=char_width; @@ -673,7 +674,7 @@ void LineEdit::_notification(int p_what) { if (char_ofs==cursor_pos && draw_caret) {//may be at the end VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2( - Point2( x_ofs , y_ofs ), Size2( 1, y_area ) ), cursor_color ); + Point2( x_ofs , y_ofs ), Size2( 1, caret_height ) ), cursor_color ); } } break; case NOTIFICATION_FOCUS_ENTER: { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 8a9ed98a5f..14508e07a8 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1651,7 +1651,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) { update(); } - if (mb.button_index==BUTTON_RIGHT) { + if (mb.button_index==BUTTON_RIGHT && context_menu_enabled) { menu->set_pos(get_global_transform().xform(get_local_mouse_pos())); menu->set_size(Vector2(1,1)); @@ -4569,6 +4569,9 @@ bool TextEdit::is_selecting_identifiers_on_hover_enabled() const { return select_identifiers_enabled; } +void TextEdit::set_context_menu_enabled(bool p_enable) { + context_menu_enabled = p_enable; +} PopupMenu *TextEdit::get_menu() const { return menu; @@ -4789,6 +4792,7 @@ TextEdit::TextEdit() { window_has_focus=true; select_identifiers_enabled=false; + context_menu_enabled=true; menu = memnew( PopupMenu ); add_child(menu); menu->add_item(TTR("Cut"),MENU_CUT,KEY_MASK_CMD|KEY_X); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index cb49618f18..37477e3b7e 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -269,6 +269,8 @@ class TextEdit : public Control { int search_result_line; int search_result_col; + bool context_menu_enabled; + int get_visible_rows() const; int get_char_count(); @@ -319,8 +321,6 @@ class TextEdit : public Control { void _confirm_completion(); void _update_completion_candidates(); - void _get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const; - protected: virtual String get_tooltip(const Point2& p_pos) const; @@ -360,6 +360,8 @@ public: virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const; + void _get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const; + //void delete_char(); //void delete_line(); @@ -499,6 +501,7 @@ public: void set_select_identifiers_on_hover(bool p_enable); bool is_selecting_identifiers_on_hover_enabled() const; + void set_context_menu_enabled(bool p_enable); PopupMenu *get_menu() const; String get_text_for_completion(); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 20794b2faa..5a614fb1b2 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -32,6 +32,7 @@ #include "os/keyboard.h" #include "globals.h" #include "os/input.h" +#include "scene/main/viewport.h" @@ -829,6 +830,8 @@ void Tree::update_cache() { cache.guide_width=get_constant("guide_width"); cache.draw_relationship_lines=get_constant("draw_relationship_lines"); cache.relationship_line_color=get_color("relationship_line_color"); + cache.scroll_border=get_constant("scroll_border"); + cache.scroll_speed=get_constant("scroll_speed"); cache.title_button = get_stylebox("title_button_normal"); cache.title_button_pressed = get_stylebox("title_button_pressed"); @@ -2681,11 +2684,17 @@ void Tree::_notification(int p_what) { if (p_what==NOTIFICATION_DRAG_END) { drop_mode_flags=0; + scrolling = false; + set_fixed_process(false); update(); } if (p_what==NOTIFICATION_DRAG_BEGIN) { single_select_defer=NULL; + if (cache.scroll_speed > 0 && get_rect().has_point(get_viewport()->get_mouse_pos() - get_global_pos())) { + scrolling = true; + set_fixed_process(true); + } } if (p_what==NOTIFICATION_FIXED_PROCESS) { @@ -2731,6 +2740,28 @@ void Tree::_notification(int p_what) { } } + + if (scrolling) { + Point2 point = get_viewport()->get_mouse_pos() - get_global_pos(); + if (point.x < cache.scroll_border) { + point.x -= cache.scroll_border; + } else if (point.x > get_size().width - cache.scroll_border) { + point.x -= get_size().width - cache.scroll_border; + } else { + point.x = 0; + } + if (point.y < cache.scroll_border) { + point.y -= cache.scroll_border; + } else if (point.y > get_size().height - cache.scroll_border) { + point.y -= get_size().height - cache.scroll_border; + } else { + point.y = 0; + } + point *= cache.scroll_speed * get_fixed_process_delta_time(); + point += get_scroll(); + h_scroll->set_val(point.x); + v_scroll->set_val(point.y); + } } if (p_what==NOTIFICATION_DRAW) { diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 2124dce749..6c2f1dae40 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -390,6 +390,8 @@ friend class TreeItem; int button_margin; Point2 offset; int draw_relationship_lines; + int scroll_border; + int scroll_speed; enum ClickType { CLICK_NONE, @@ -448,6 +450,7 @@ friend class TreeItem; bool drag_touching_deaccel; bool click_handled; bool allow_rmb_select; + bool scrolling; bool force_select_on_already_selected; diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 1be847929d..335672126c 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -248,7 +248,7 @@ void VideoPlayer::stop() { playback->stop(); AudioServer::get_singleton()->stream_set_active(stream_rid,false); - resampler.clear(); + resampler.flush(); set_process(false); last_audio_time=0; }; @@ -426,5 +426,6 @@ VideoPlayer::~VideoPlayer() { if (stream_rid.is_valid()) AudioServer::get_singleton()->free(stream_rid); + resampler.clear(); //Not necessary here, but make in consistent with other "stream_player" classes }; diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp index f3a0eaa8c4..55ad23ba93 100644 --- a/scene/io/resource_format_image.cpp +++ b/scene/io/resource_format_image.cpp @@ -136,61 +136,7 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin #endif - uint32_t flags=0; - - FileAccess *f2 = FileAccess::open(p_path+".flags",FileAccess::READ); - Map<String,bool> flags_found; - if (f2) { - - while(!f2->eof_reached()) { - String l2 = f2->get_line(); - int eqpos = l2.find("="); - if (eqpos!=-1) { - String flag=l2.substr(0,eqpos).strip_edges(); - String val=l2.substr(eqpos+1,l2.length()).strip_edges().to_lower(); - flags_found[flag]=(val=="true" || val=="1")?true:false; - } - } - memdelete(f2); - } - - - if (flags_found.has("filter")) { - if (flags_found["filter"]) - flags|=Texture::FLAG_FILTER; - } else if (bool(GLOBAL_DEF("image_loader/filter",true))) { - flags|=Texture::FLAG_FILTER; - } - - - if (flags_found.has("gen_mipmaps")) { - if (flags_found["gen_mipmaps"]) - flags|=Texture::FLAG_MIPMAPS; - } else if (bool(GLOBAL_DEF("image_loader/gen_mipmaps",true))) { - flags|=Texture::FLAG_MIPMAPS; - } - - if (flags_found.has("repeat")) { - if (flags_found["repeat"]) - flags|=Texture::FLAG_REPEAT; - } else if (bool(GLOBAL_DEF("image_loader/repeat",true))) { - flags|=Texture::FLAG_REPEAT; - } - - if (flags_found.has("anisotropic")) { - if (flags_found["anisotropic"]) - flags|=Texture::FLAG_ANISOTROPIC_FILTER; - } - - if (flags_found.has("tolinear")) { - if (flags_found["tolinear"]) - flags|=Texture::FLAG_CONVERT_TO_LINEAR; - } - - if (flags_found.has("mirroredrepeat")) { - if (flags_found["mirroredrepeat"]) - flags|=Texture::FLAG_MIRRORED_REPEAT; - } + uint32_t flags=load_image_flags(p_path); if (debug_load_times) begtime=OS::get_singleton()->get_ticks_usec(); @@ -214,6 +160,68 @@ RES ResourceFormatLoaderImage::load(const String &p_path, const String& p_origin } +uint32_t ResourceFormatLoaderImage::load_image_flags(const String &p_path) { + + + FileAccess *f2 = FileAccess::open(p_path+".flags",FileAccess::READ); + Map<String,bool> flags_found; + if (f2) { + + while(!f2->eof_reached()) { + String l2 = f2->get_line(); + int eqpos = l2.find("="); + if (eqpos!=-1) { + String flag=l2.substr(0,eqpos).strip_edges(); + String val=l2.substr(eqpos+1,l2.length()).strip_edges().to_lower(); + flags_found[flag]=(val=="true" || val=="1")?true:false; + } + } + memdelete(f2); + } + + + uint32_t flags=0; + + if (flags_found.has("filter")) { + if (flags_found["filter"]) + flags|=Texture::FLAG_FILTER; + } else if (bool(GLOBAL_DEF("image_loader/filter",true))) { + flags|=Texture::FLAG_FILTER; + } + + + if (flags_found.has("gen_mipmaps")) { + if (flags_found["gen_mipmaps"]) + flags|=Texture::FLAG_MIPMAPS; + } else if (bool(GLOBAL_DEF("image_loader/gen_mipmaps",true))) { + flags|=Texture::FLAG_MIPMAPS; + } + + if (flags_found.has("repeat")) { + if (flags_found["repeat"]) + flags|=Texture::FLAG_REPEAT; + } else if (bool(GLOBAL_DEF("image_loader/repeat",true))) { + flags|=Texture::FLAG_REPEAT; + } + + if (flags_found.has("anisotropic")) { + if (flags_found["anisotropic"]) + flags|=Texture::FLAG_ANISOTROPIC_FILTER; + } + + if (flags_found.has("tolinear")) { + if (flags_found["tolinear"]) + flags|=Texture::FLAG_CONVERT_TO_LINEAR; + } + + if (flags_found.has("mirroredrepeat")) { + if (flags_found["mirroredrepeat"]) + flags|=Texture::FLAG_MIRRORED_REPEAT; + } + + return flags; +} + bool ResourceFormatLoaderImage::handles_type(const String& p_type) const { return ObjectTypeDB::is_type(p_type,"Texture") || ObjectTypeDB::is_type(p_type,"CubeMap"); diff --git a/scene/io/resource_format_image.h b/scene/io/resource_format_image.h index 6388aa641f..cce6ffab83 100644 --- a/scene/io/resource_format_image.h +++ b/scene/io/resource_format_image.h @@ -39,8 +39,8 @@ class ResourceFormatLoaderImage : public ResourceFormatLoader { bool debug_load_times; int max_texture_size; public: - virtual RES load(const String &p_path,const String& p_original_path="",Error *r_error=NULL); + static uint32_t load_image_flags(const String &p_path); 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; diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index dea612735c..0740b591c4 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -714,6 +714,8 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref t->set_constant("item_margin","Tree",12 *scale); t->set_constant("button_margin","Tree",4 *scale); t->set_constant("draw_relationship_lines", "Tree", 0); + t->set_constant("scroll_border", "Tree", 4); + t->set_constant("scroll_speed", "Tree", 12); // ItemList diff --git a/tools/SCsub b/tools/SCsub index aaebab724a..67b1f20e72 100644 --- a/tools/SCsub +++ b/tools/SCsub @@ -117,7 +117,6 @@ if (env["tools"]!="no"): SConscript('editor/SCsub'); SConscript('collada/SCsub'); SConscript('doc/SCsub') - SConscript('pck/SCsub') lib = env.Library("tool",env.tool_sources) diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index 2f67df1fc3..a556031e5e 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -1933,12 +1933,20 @@ void AnimationKeyEditor::_track_editor_input_event(const InputEvent& p_input) { if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) { - v_scroll->set_val( v_scroll->get_val() - v_scroll->get_page() / 8 ); + if (mb.mod.command) { + zoom->set_val(zoom->get_val() + zoom->get_step()); + } else { + v_scroll->set_val( v_scroll->get_val() - v_scroll->get_page() / 8 ); + } } if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) { - v_scroll->set_val( v_scroll->get_val() + v_scroll->get_page() / 8 ); + if (mb.mod.command) { + zoom->set_val(zoom->get_val() - zoom->get_step()); + } else { + v_scroll->set_val( v_scroll->get_val() + v_scroll->get_page() / 8 ); + } } if (mb.button_index==BUTTON_RIGHT && mb.pressed) { diff --git a/tools/editor/editor_log.cpp b/tools/editor/editor_log.cpp index 20613467d3..02af9712a8 100644 --- a/tools/editor/editor_log.cpp +++ b/tools/editor/editor_log.cpp @@ -161,7 +161,7 @@ void EditorLog::_undo_redo_cbk(void *p_self,const String& p_name) { void EditorLog::_bind_methods() { ObjectTypeDB::bind_method(_MD("_clear_request"),&EditorLog::_clear_request ); - + ObjectTypeDB::bind_method("_override_logger_styles",&EditorLog::_override_logger_styles ); //ObjectTypeDB::bind_method(_MD("_dragged"),&EditorLog::_dragged ); ADD_SIGNAL( MethodInfo("clear_request")); } @@ -193,11 +193,10 @@ EditorLog::EditorLog() { ec->set_custom_minimum_size(Size2(0,180)); ec->set_v_size_flags(SIZE_EXPAND_FILL); - - PanelContainer *pc = memnew( PanelContainer ); - pc->add_style_override("panel",get_stylebox("normal","TextEdit")); + pc = memnew( PanelContainer ); ec->add_child(pc); pc->set_area_as_parent_rect(); + pc->connect("enter_tree", this, "_override_logger_styles"); log = memnew( RichTextLabel ); log->set_scroll_follow(true); @@ -224,6 +223,11 @@ void EditorLog::deinit() { } +void EditorLog::_override_logger_styles() { + + pc->add_style_override("panel",get_stylebox("normal","TextEdit")); + +} EditorLog::~EditorLog() { diff --git a/tools/editor/editor_log.h b/tools/editor/editor_log.h index 699be710d8..bbf35b63cb 100644 --- a/tools/editor/editor_log.h +++ b/tools/editor/editor_log.h @@ -50,6 +50,7 @@ class EditorLog : public VBoxContainer { HBoxContainer *title_hb; // PaneDrag *pd; Control *ec; + PanelContainer *pc; static void _error_handler(void *p_self, const char*p_func, const char*p_file,int p_line, const char*p_error,const char*p_errorexp,ErrorHandlerType p_type); @@ -64,6 +65,7 @@ protected: static void _bind_methods(); void _notification(int p_what); + void _override_logger_styles(); public: void add_message(const String& p_msg, bool p_error=false); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index fe97fe2881..8274272a7e 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -2678,7 +2678,7 @@ void EditorNode::_menu_option_confirm(int p_option,bool p_confirmed) { } break; case RUN_PLAY_NATIVE: { - + bool autosave = EDITOR_DEF("run/auto_save_before_running",true); if (autosave) { _menu_option_confirm(FILE_SAVE_ALL_SCENES, false); diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 2fae5daced..0393cd19a9 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -700,6 +700,7 @@ public: void notify_child_process_exited(); + OS::ProcessID get_child_process_id() const { return editor_run.get_pid(); } void stop_child_process(); Ref<Theme> get_editor_theme() const { return theme; } diff --git a/tools/editor/editor_run.cpp b/tools/editor/editor_run.cpp index fb0f24c084..5fbb4ae2a0 100644 --- a/tools/editor/editor_run.cpp +++ b/tools/editor/editor_run.cpp @@ -52,6 +52,9 @@ Error EditorRun::run(const String& p_scene,const String p_custom_args,const List args.push_back("localhost:"+String::num(GLOBAL_DEF("debug/debug_port", 6007))); } + args.push_back("-epid"); + args.push_back(String::num(OS::get_singleton()->get_process_ID())); + if (p_custom_args!="") { Vector<String> cargs=p_custom_args.split(" ",false); @@ -132,6 +135,7 @@ Error EditorRun::run(const String& p_scene,const String p_custom_args,const List } + if (p_breakpoints.size()) { args.push_back("-bp"); diff --git a/tools/editor/editor_run.h b/tools/editor/editor_run.h index 0b96a2c91c..5aa2adf801 100644 --- a/tools/editor/editor_run.h +++ b/tools/editor/editor_run.h @@ -53,6 +53,8 @@ public: void run_native_notify() { status=STATUS_PLAY; } void stop(); + OS::ProcessID get_pid() const { return pid; } + void set_debug_collisions(bool p_debug); bool get_debug_collisions() const; diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 60642999f2..2935ea8fe2 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -38,6 +38,7 @@ #include "scene/gui/check_button.h" #include "scene/gui/button_group.h" #include "scene/gui/margin_container.h" +#include "scene/io/resource_format_image.h" static const char *flag_names[]={ ("Streaming Format"), @@ -1589,16 +1590,9 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c } break; //use default } + String validated_path=EditorImportPlugin::validate_source_path(p_path); - int flags=0; - - if (Globals::get_singleton()->get("image_loader/filter")) - flags|=IMAGE_FLAG_FILTER; - if (!Globals::get_singleton()->get("image_loader/gen_mipmaps")) - flags|=IMAGE_FLAG_NO_MIPMAPS; - if (!Globals::get_singleton()->get("image_loader/repeat")) - flags|=IMAGE_FLAG_REPEAT; - + int flags=texture_flags_to_export_flags(ResourceFormatLoaderImage::load_image_flags(validated_path)); flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; print_line("group format"+itos(group_format)); @@ -1607,7 +1601,7 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c rimd->set_option("quality",group_lossy_quality); rimd->set_option("atlas",false); rimd->set_option("shrink",group_shrink); - rimd->add_source(EditorImportPlugin::validate_source_path(p_path),FileAccess::get_md5(p_path)); + rimd->add_source(validated_path,FileAccess::get_md5(p_path)); } else if (EditorImportExport::get_singleton()->get_image_formats().has(p_path.extension().to_lower()) && EditorImportExport::get_singleton()->get_export_image_action()!=EditorImportExport::IMAGE_ACTION_NONE) { //handled by general image export settings @@ -1619,22 +1613,16 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c case EditorImportExport::IMAGE_ACTION_COMPRESS_RAM: rimd->set_option("format",IMAGE_FORMAT_COMPRESS_RAM); break; } - int flags=0; - - if (Globals::get_singleton()->get("image_loader/filter")) - flags|=IMAGE_FLAG_FILTER; - if (!Globals::get_singleton()->get("image_loader/gen_mipmaps")) - flags|=IMAGE_FLAG_NO_MIPMAPS; - if (!Globals::get_singleton()->get("image_loader/repeat")) - flags|=IMAGE_FLAG_REPEAT; + String validated_path=EditorImportPlugin::validate_source_path(p_path); + int flags=texture_flags_to_export_flags(ResourceFormatLoaderImage::load_image_flags(validated_path)); flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; rimd->set_option("shrink",EditorImportExport::get_singleton()->get_export_image_shrink()); rimd->set_option("flags",flags); rimd->set_option("quality",EditorImportExport::get_singleton()->get_export_image_quality()); rimd->set_option("atlas",false); - rimd->add_source(EditorImportPlugin::validate_source_path(p_path),FileAccess::get_md5(p_path)); + rimd->add_source(validated_path,FileAccess::get_md5(p_path)); } else { return Vector<uint8_t>(); @@ -1726,6 +1714,33 @@ Vector<uint8_t> EditorTextureImportPlugin::custom_export(const String& p_path, c return ret; } +uint32_t EditorTextureImportPlugin::texture_flags_to_export_flags(uint32_t p_tex_flags) const { + + uint32_t flags=0; + + if (!(p_tex_flags&Texture::FLAG_MIPMAPS)) { + flags|=IMAGE_FLAG_NO_MIPMAPS; + } + if (p_tex_flags&Texture::FLAG_REPEAT) { + flags|=IMAGE_FLAG_REPEAT; + } + if (p_tex_flags&Texture::FLAG_FILTER) { + flags|=IMAGE_FLAG_FILTER; + } + if (p_tex_flags&Texture::FLAG_ANISOTROPIC_FILTER) { + flags|=IMAGE_FLAG_USE_ANISOTROPY; + } + if (p_tex_flags&Texture::FLAG_CONVERT_TO_LINEAR) { + flags|=IMAGE_FLAG_CONVERT_TO_LINEAR; + } + /* // no correspondence yet + if (p_tex_flags&Texture::TEXTURE_FLAG_MIRRORED_REPEAT) { + flags|=; + }*/ + + return flags; +} + void EditorTextureImportPlugin::import_from_drop(const Vector<String>& p_drop,const String& p_dest_path) { Vector<String> valid; diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.h b/tools/editor/io_plugins/editor_texture_import_plugin.h index 5c8abd10a4..22c10a1a3a 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.h +++ b/tools/editor/io_plugins/editor_texture_import_plugin.h @@ -72,6 +72,8 @@ private: Error _process_texture_data(Ref<ImageTexture> &texture, int format, float quality, int flags,EditorExportPlatform::ImageCompression p_compr,int tex_flags,float shrink); void compress_image(EditorExportPlatform::ImageCompression p_mode,Image& image,bool p_smaller); + + uint32_t texture_flags_to_export_flags(uint32_t p_tex_flags) const; public: diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index fd25843de9..3cd6d8336a 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -755,29 +755,10 @@ void ScriptEditor::_menu_option(int p_option) { } break; case FILE_SAVE_ALL: { - if (!_test_script_times_on_disk()) + if (_test_script_times_on_disk()) return; save_all_scripts(); - -#if 0 - for(int i=0;i<tab_container->get_child_count();i++) { - - ScriptTextEditor *se = tab_container->get_child(i)->cast_to<ScriptTextEditor>(); - if (!se) - continue; - - - Ref<Script> script = se->get_edited_script(); - - if (script->get_path()=="" || script->get_path().find("local://")!=-1 || script->get_path().find("::")!=-1) - continue; //internal script, who cares - - - editor->save_resource( script ); - } - -#endif } break; case FILE_IMPORT_THEME: { file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); diff --git a/tools/editor/plugins/script_text_editor.cpp b/tools/editor/plugins/script_text_editor.cpp index ca0398f069..2f807eaa19 100644 --- a/tools/editor/plugins/script_text_editor.cpp +++ b/tools/editor/plugins/script_text_editor.cpp @@ -498,6 +498,7 @@ void ScriptTextEditor::_code_complete_scripts(void* p_ud,const String& p_code, L void ScriptTextEditor::_code_complete_script(const String& p_code, List<String>* r_options) { + if (color_panel->is_visible()) return; Node *base = get_tree()->get_edited_scene_root(); if (base) { base = _find_node_for_script(base,base,script); @@ -882,6 +883,9 @@ void ScriptTextEditor::_edit_option(int p_op) { case EDIT_TRIM_TRAILING_WHITESAPCE: { trim_trailing_whitespace(); } break; + case EDIT_PICK_COLOR: { + color_panel->popup(); + } break; case SEARCH_FIND: { @@ -989,7 +993,8 @@ void ScriptTextEditor::_bind_methods() { ObjectTypeDB::bind_method("_edit_option",&ScriptTextEditor::_edit_option); ObjectTypeDB::bind_method("_goto_line",&ScriptTextEditor::_goto_line); ObjectTypeDB::bind_method("_lookup_symbol",&ScriptTextEditor::_lookup_symbol); - + ObjectTypeDB::bind_method("_text_edit_input_event", &ScriptTextEditor::_text_edit_input_event); + ObjectTypeDB::bind_method("_color_changed", &ScriptTextEditor::_color_changed); ObjectTypeDB::bind_method("get_drag_data_fw",&ScriptTextEditor::get_drag_data_fw); @@ -1168,6 +1173,96 @@ void ScriptTextEditor::drop_data_fw(const Point2& p_point,const Variant& p_data, } +void ScriptTextEditor::_text_edit_input_event(const InputEvent& ev) { + if (ev.type == InputEvent::MOUSE_BUTTON) { + InputEventMouseButton mb = ev.mouse_button; + if (mb.button_index == BUTTON_RIGHT && !mb.pressed) { + + int col, row; + TextEdit* tx = code_editor->get_text_edit(); + tx->_get_mouse_pos(Point2i(mb.global_x, mb.global_y)-tx->get_global_pos(), row, col); + Vector2 mpos = Vector2(mb.global_x, mb.global_y)-tx->get_global_pos(); + bool have_selection = (tx->get_selection_text().length() > 0); + bool have_color = (tx->get_word_at_pos(mpos) == "Color"); + if (have_color) { + + String line = tx->get_line(row); + color_line = row; + int begin = 0; + int end = 0; + bool valid = false; + for (int i = col; i < line.length(); i++) { + if (line[i] == '(') { + begin = i; + continue; + } + else if (line[i] == ')') { + end = i+1; + valid = true; + break; + } + } + if (valid) { + color_args = line.substr(begin, end-begin); + String stripped = color_args.replace(" ", "").replace("(", "").replace(")", ""); + Vector<float> color = stripped.split_floats(","); + if (color.size() > 2) { + float alpha = color.size() > 3 ? color[3] : 1.0f; + color_picker->set_color(Color(color[0], color[1], color[2], alpha)); + } + color_panel->set_pos(get_global_transform().xform(get_local_mouse_pos())); + Size2 ms = Size2(300, color_picker->get_combined_minimum_size().height+10); + color_panel->set_size(ms); + } else { + have_color = false; + } + } + _make_context_menu(have_selection, have_color); + } + } +} + +void ScriptTextEditor::_color_changed(const Color& p_color) { + String new_args; + if (p_color.a == 1.0f) { + new_args = String("("+rtos(p_color.r)+", "+rtos(p_color.g)+", "+rtos(p_color.b)+")"); + } else { + new_args = String("("+rtos(p_color.r)+", "+rtos(p_color.g)+", "+rtos(p_color.b)+", "+rtos(p_color.a)+")"); + } + + String line = code_editor->get_text_edit()->get_line(color_line); + String new_line = line.replace(color_args, new_args); + color_args = new_args; + code_editor->get_text_edit()->set_line(color_line, new_line); +} + +void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) { + + context_menu->clear(); + if (p_selection) { + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/copy")); + } + + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/paste")); + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/select_all")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo")); + + if (p_selection) { + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right")); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment")); + } + if (p_color) { + context_menu->add_separator(); + context_menu->add_item(TTR("Pick Color"), EDIT_PICK_COLOR); + } + context_menu->set_pos(get_global_transform().xform(get_local_mouse_pos())); + context_menu->set_size(Vector2(1, 1)); + context_menu->popup(); +} ScriptTextEditor::ScriptTextEditor() { @@ -1197,6 +1292,19 @@ ScriptTextEditor::ScriptTextEditor() { EditorSettings::get_singleton()->get("text_editor/callhint_tooltip_offset")); code_editor->get_text_edit()->set_select_identifiers_on_hover(true); + code_editor->get_text_edit()->set_context_menu_enabled(false); + code_editor->get_text_edit()->connect("input_event", this, "_text_edit_input_event"); + + context_menu = memnew(PopupMenu); + add_child(context_menu); + context_menu->connect("item_pressed", this, "_edit_option"); + + color_panel = memnew(PopupPanel); + add_child(color_panel); + color_picker = memnew(ColorPicker); + color_panel->add_child(color_picker); + color_panel->set_child_rect(color_picker); + color_picker->connect("color_changed", this, "_color_changed"); edit_hb = memnew (HBoxContainer); @@ -1279,8 +1387,8 @@ void ScriptTextEditor::register_editor() { ED_SHORTCUT("script_text_editor/select_all", TTR("Select All"), KEY_MASK_CMD|KEY_A); ED_SHORTCUT("script_text_editor/move_up", TTR("Move Up"), KEY_MASK_ALT|KEY_UP); ED_SHORTCUT("script_text_editor/move_down", TTR("Move Down"), KEY_MASK_ALT|KEY_DOWN); - ED_SHORTCUT("script_text_editor/indent_left", TTR("Indent Left"), 0); - ED_SHORTCUT("script_text_editor/indent_right", TTR("Indent Right"), 0); + ED_SHORTCUT("script_text_editor/indent_left", TTR("Indent Left"), KEY_MASK_ALT|KEY_LEFT); + ED_SHORTCUT("script_text_editor/indent_right", TTR("Indent Right"), KEY_MASK_ALT|KEY_RIGHT); ED_SHORTCUT("script_text_editor/toggle_comment", TTR("Toggle Comment"), KEY_MASK_CMD|KEY_K); ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_CMD|KEY_B); #ifdef OSX_ENABLED diff --git a/tools/editor/plugins/script_text_editor.h b/tools/editor/plugins/script_text_editor.h index 2c7eac6095..ceef50f0bc 100644 --- a/tools/editor/plugins/script_text_editor.h +++ b/tools/editor/plugins/script_text_editor.h @@ -30,6 +30,7 @@ #define SCRIPT_TEXT_EDITOR_H #include "script_editor_plugin.h" +#include "scene/gui/color_picker.h" class ScriptTextEditor : public ScriptEditorBase { @@ -47,10 +48,16 @@ class ScriptTextEditor : public ScriptEditorBase { MenuButton *edit_menu; MenuButton *search_menu; + PopupMenu *context_menu; GotoLineDialog *goto_line_dialog; ScriptEditorQuickOpen *quick_open; + PopupPanel *color_panel; + ColorPicker *color_picker; + int color_line; + String color_args; + enum { EDIT_UNDO, EDIT_REDO, @@ -67,6 +74,7 @@ class ScriptTextEditor : public ScriptEditorBase { EDIT_INDENT_RIGHT, EDIT_INDENT_LEFT, EDIT_CLONE_DOWN, + EDIT_PICK_COLOR, SEARCH_FIND, SEARCH_FIND_NEXT, SEARCH_FIND_PREV, @@ -96,6 +104,9 @@ protected: static void _bind_methods(); void _edit_option(int p_op); + void _make_context_menu(bool p_selection, bool p_color); + void _text_edit_input_event(const InputEvent& ev); + void _color_changed(const Color& p_color); void _goto_line(int p_line) { goto_line(p_line); } void _lookup_symbol(const String& p_symbol,int p_row, int p_column); diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp index 5db331ba45..84568aa8c0 100644 --- a/tools/editor/plugins/theme_editor_plugin.cpp +++ b/tools/editor/plugins/theme_editor_plugin.cpp @@ -668,7 +668,7 @@ ThemeEditor::ThemeEditor() { theme_menu = memnew( MenuButton ); - theme_menu->set_text("Theme"); + theme_menu->set_text(TTR("Theme")); theme_menu->get_popup()->add_item(TTR("Add Item"),POPUP_ADD); theme_menu->get_popup()->add_item(TTR("Add Class Items"),POPUP_CLASS_ADD); theme_menu->get_popup()->add_item(TTR("Remove Item"),POPUP_REMOVE); diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index b2eae2f6d1..18a4e845a0 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -506,7 +506,7 @@ void ProjectManager::_panel_draw(Node *p_hb) { hb->draw_line(Point2(0,hb->get_size().y+1),Point2(hb->get_size().x-10,hb->get_size().y+1),get_color("guide_color","Tree")); if (selected_list.has(hb->get_meta("name"))) { - hb->draw_style_box(get_stylebox("selected","Tree"),Rect2(Point2(),hb->get_size()-Size2(10,0))); + hb->draw_style_box( gui_base->get_stylebox("selected","Tree"),Rect2(Point2(),hb->get_size()-Size2(10,0))); } } @@ -753,7 +753,7 @@ void ProjectManager::_load_recent_projects() { List<PropertyInfo> properties; EditorSettings::get_singleton()->get_property_list(&properties); - Color font_color = get_color("font_color","Tree"); + Color font_color = gui_base->get_color("font_color","Tree"); List<ProjectItem> projects; List<ProjectItem> favorite_projects; @@ -864,6 +864,7 @@ void ProjectManager::_load_recent_projects() { hb->set_meta("favorite",is_favorite); hb->connect("draw",this,"_panel_draw",varray(hb)); hb->connect("input_event",this,"_panel_input",varray(hb)); + hb->add_constant_override("separation",10*EDSCALE); VBoxContainer *favorite_box = memnew( VBoxContainer ); TextureButton *favorite = memnew( TextureButton ); @@ -885,7 +886,7 @@ void ProjectManager::_load_recent_projects() { ec->set_custom_minimum_size(Size2(0,1)); vb->add_child(ec); Label *title = memnew( Label(project_name) ); - title->add_font_override("font",get_font("large","Fonts")); + title->add_font_override("font", gui_base->get_font("large","Fonts")); title->add_color_override("font_color",font_color); vb->add_child(title); Label *fpath = memnew( Label(path) ); @@ -1205,6 +1206,7 @@ ProjectManager::ProjectManager() { gui_base = memnew( Control ); add_child(gui_base); gui_base->set_area_as_parent_rect(); + gui_base->set_theme(create_custom_theme()); Panel *panel = memnew( Panel ); gui_base->add_child(panel); @@ -1227,7 +1229,7 @@ ProjectManager::ProjectManager() { CenterContainer *ccl = memnew( CenterContainer ); Label *l = memnew( Label ); l->set_text(_MKSTR(VERSION_NAME)+String(" - ")+TTR("Project Manager")); - l->add_font_override("font",get_font("doc","EditorFonts")); + l->add_font_override("font", gui_base->get_font("doc","EditorFonts")); ccl->add_child(l); top_hb->add_child(ccl); top_hb->add_spacer(); @@ -1263,7 +1265,7 @@ ProjectManager::ProjectManager() { search_tree_vb->add_child(search_box); PanelContainer *pc = memnew( PanelContainer); - pc->add_style_override("panel",get_stylebox("bg","Tree")); + pc->add_style_override("panel", gui_base->get_stylebox("bg","Tree")); search_tree_vb->add_child(pc); pc->set_v_size_flags(SIZE_EXPAND_FILL); @@ -1392,8 +1394,6 @@ ProjectManager::ProjectManager() { last_clicked = ""; SceneTree::get_singleton()->connect("files_dropped", this, "_files_dropped"); - - gui_base->set_theme(create_custom_theme()); } diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 1a8d373f7f..7163836f73 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -3049,7 +3049,7 @@ void PropertyEditor::update_tree() { if (E) { descr=E->get().brief_description; } - class_descr_cache[type]=descr.world_wrap(80); + class_descr_cache[type]=descr.word_wrap(80); } @@ -3142,7 +3142,7 @@ void PropertyEditor::update_tree() { if (E) { for(int i=0;i<E->get().methods.size();i++) { if (E->get().methods[i].name==setter.operator String()) { - descr=E->get().methods[i].description.strip_edges().world_wrap(80); + descr=E->get().methods[i].description.strip_edges().word_wrap(80); } } } @@ -3182,6 +3182,7 @@ void PropertyEditor::update_tree() { item->set_cell_mode( 1, TreeItem::CELL_MODE_CHECK ); item->set_text(1,TTR("On")); + item->set_tooltip(1, obj->get(p.name) ? "True" : "False"); item->set_checked( 1, obj->get( p.name ) ); if (show_type_icons) item->set_icon( 0, get_icon("Bool","EditorIcons") ); @@ -3828,6 +3829,7 @@ void PropertyEditor::_item_edited() { case Variant::BOOL: { _edit_set(name,item->is_checked(1)); + item->set_tooltip(1, item->is_checked(1) ? "True" : "False"); } break; case Variant::INT: case Variant::REAL: { diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index e5a97fa26e..53bfe8cc57 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -254,7 +254,7 @@ void SceneTreeEditor::_cell_button_pressed(Object *p_item,int p_column,int p_id) String config_err = n->get_configuration_warning(); if (config_err==String()) return; - config_err=config_err.world_wrap(80); + config_err=config_err.word_wrap(80); warning->set_text(config_err); warning->popup_centered_minsize(); diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index 7fba73ca08..c8170ca9a3 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -216,6 +216,8 @@ void ScriptEditorDebugger::debug_continue() { ERR_FAIL_COND(connection.is_null()); ERR_FAIL_COND(!connection->is_connected()); + OS::get_singleton()->enable_for_stealing_focus(EditorNode::get_singleton()->get_child_process_id()); + Array msg; msg.push_back("continue"); ppeer->put_var(msg); diff --git a/tools/pck/SCsub b/tools/pck/SCsub deleted file mode 100644 index cf98ae145d..0000000000 --- a/tools/pck/SCsub +++ /dev/null @@ -1,4 +0,0 @@ -Import('env') - -if env["tools"] == "yes": - env.add_source_files(env.tool_sources, "*.cpp") |