diff options
31 files changed, 301 insertions, 171 deletions
@@ -11,7 +11,7 @@ Godot has been developed by Juan Linietsky and Ariel Manzur for several years, a ### Documentation -Documentation has been moved to the [GitHub Wiki](https://github.com/okamstudio/godot/wiki). +Documentation has been moved to the [OpenProject Wiki](http://godotengine.org/projects/godot-engine/wiki/Documentation). ### Binary Downloads, Community, etc. @@ -22,4 +22,4 @@ http://www.godotengine.org ### Compiling from Source Compilation instructions for every platform can be found in the Wiki: -https://github.com/okamstudio/godot/wiki/advanced +http://godotengine.org/projects/godot-engine/wiki/Advanced_topics diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 24012660d2..58092efd4b 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -579,7 +579,7 @@ Error HTTPClient::_get_http_data(uint8_t* p_buffer, int p_bytes,int &r_received) void HTTPClient::_bind_methods() { - ObjectTypeDB::bind_method(_MD("connect:Error","host","port","use_ssl"),&HTTPClient::connect,DEFVAL(false),DEFVAL(true)); + ObjectTypeDB::bind_method(_MD("connect:Error","host","port","use_ssl","verify_host"),&HTTPClient::connect,DEFVAL(false),DEFVAL(true)); ObjectTypeDB::bind_method(_MD("set_connection","connection:StreamPeer"),&HTTPClient::set_connection); ObjectTypeDB::bind_method(_MD("request","method","url","headers","body"),&HTTPClient::request,DEFVAL(String())); ObjectTypeDB::bind_method(_MD("send_body_text","body"),&HTTPClient::send_body_text); @@ -601,6 +601,8 @@ void HTTPClient::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_status"),&HTTPClient::get_status); ObjectTypeDB::bind_method(_MD("poll:Error"),&HTTPClient::poll); + ObjectTypeDB::bind_method(_MD("query_string_from_dict:String","fields"),&HTTPClient::query_string_from_dict); + BIND_CONSTANT( METHOD_GET ); BIND_CONSTANT( METHOD_HEAD ); @@ -689,6 +691,16 @@ void HTTPClient::set_read_chunk_size(int p_size) { read_chunk_size=p_size; } +String HTTPClient::query_string_from_dict(const Dictionary& p_dict) { + String query = ""; + Array keys = p_dict.keys(); + for (int i = 0; i < keys.size(); ++i) { + query += "&" + String(keys[i]).http_escape() + "=" + String(p_dict[keys[i]]).http_escape(); + } + query.erase(0, 1); + return query; +} + HTTPClient::HTTPClient(){ tcp_connection = StreamPeerTCP::create_ref(); @@ -710,4 +722,3 @@ HTTPClient::~HTTPClient(){ } - diff --git a/core/io/http_client.h b/core/io/http_client.h index 21281f38c5..b103dc43fc 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -192,6 +192,8 @@ public: Error poll(); + String query_string_from_dict(const Dictionary& p_dict); + HTTPClient(); ~HTTPClient(); }; diff --git a/core/math/math_2d.cpp b/core/math/math_2d.cpp index 88717723ce..ce03f089e5 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -29,7 +29,7 @@ #include "math_2d.h" -real_t Vector2::atan2() const { +real_t Vector2::angle() const { return Math::atan2(x,y); } @@ -165,7 +165,7 @@ Vector2 Vector2::floor() const { Vector2 Vector2::rotated(float p_by) const { Vector2 v; - v.set_rotation(atan2()+p_by); + v.set_rotation(angle()+p_by); v*=length(); return v; } diff --git a/core/math/math_2d.h b/core/math/math_2d.h index 5e6cefd114..3d40e24091 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -133,7 +133,7 @@ struct Vector2 { bool operator<(const Vector2& p_vec2) const { return (x==p_vec2.x)?(y<p_vec2.y):(x<p_vec2.x); } bool operator<=(const Vector2& p_vec2) const { return (x==p_vec2.x)?(y<=p_vec2.y):(x<=p_vec2.x); } - real_t atan2() const; + real_t angle() const; void set_rotation(float p_radians) { diff --git a/core/ustring.cpp b/core/ustring.cpp index 7582376fe0..f3c89a7908 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -44,6 +44,11 @@ #include <stdlib.h> #include <stdio.h> #endif + +#if defined(MINGW_ENABLED) || defined(_MSC_VER) +#define snprintf _snprintf +#endif + /** STRING **/ const char *CharString::get_data() const { @@ -3079,6 +3084,48 @@ String String::world_wrap(int p_chars_per_line) const { return ret; } +String String::http_escape() const { + const CharString temp = utf8(); + String res; + for (int i = 0; i < length(); ++i) { + CharType ord = temp[i]; + if (ord == '.' || ord == '-' || ord == '_' || ord == '~' || + (ord >= 'a' && ord <= 'z') || + (ord >= 'A' && ord <= 'Z') || + (ord >= '0' && ord <= '9')) { + res += ord; + } else { + char h_Val[3]; + snprintf(h_Val, 3, "%.2X", ord); + res += "%"; + res += h_Val; + } + } + return res; +} + +String String::http_unescape() const { + String res; + for (int i = 0; i < length(); ++i) { + if (ord_at(i) == '%' && i+2 < length()) { + CharType ord1 = ord_at(i+1); + if ((ord1 >= '0' && ord1 <= '9') || (ord1 >= 'A' && ord1 <= 'Z')) { + CharType ord2 = ord_at(i+2); + if ((ord2 >= '0' && ord2 <= '9') || (ord2 >= 'A' && ord2 <= 'Z')) { + char bytes[2] = {ord1, ord2}; + res += (char)strtol(bytes, NULL, 16); + i+=2; + } + } else { + res += ord_at(i); + } + } else { + res += ord_at(i); + } + } + return String::utf8(res.ascii()); +} + String String::c_unescape() const { String escaped=*this; diff --git a/core/ustring.h b/core/ustring.h index fa25a07eb0..2f3c4bff4d 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -207,6 +207,8 @@ public: String xml_escape(bool p_escape_quotes=false) const; String xml_unescape() const; + String http_escape() const; + String http_unescape() const; String c_escape() const; String c_unescape() const; String world_wrap(int p_chars_per_line) const; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 7bbb18225d..51d683f1fe 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -333,7 +333,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM1R(Vector2,dot); VCALL_LOCALMEM1R(Vector2,slide); VCALL_LOCALMEM1R(Vector2,reflect); - VCALL_LOCALMEM0R(Vector2,atan2); + VCALL_LOCALMEM0R(Vector2,angle); // VCALL_LOCALMEM1R(Vector2,cross); VCALL_LOCALMEM0R(Rect2,get_area); @@ -1297,7 +1297,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(VECTOR2,VECTOR2,Vector2,normalized,varray()); ADDFUNC0(VECTOR2,REAL,Vector2,length,varray()); - ADDFUNC0(VECTOR2,REAL,Vector2,atan2,varray()); + ADDFUNC0(VECTOR2,REAL,Vector2,angle,varray()); ADDFUNC0(VECTOR2,REAL,Vector2,length_squared,varray()); ADDFUNC1(VECTOR2,REAL,Vector2,distance_to,VECTOR2,"to",varray()); ADDFUNC1(VECTOR2,REAL,Vector2,distance_squared_to,VECTOR2,"to",varray()); diff --git a/doc/base/classes.xml b/doc/base/classes.xml index de22629784..da53cb90a5 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -12518,9 +12518,13 @@ This approximation makes straight segments between each point, then subdivides t </argument> <argument index="2" name="use_ssl" type="bool" default="false"> </argument> - <argument index="3" name="arg3" type="bool" default="true"> + <argument index="3" name="verify_host" type="bool" default="true"> </argument> <description> + Connect to a host. This needs to be done before any requests are sent. +The host should not have http:// prepended but will strip the protocol identifier if provided. + +verify_host will check the SSL identity of the host if set to true. </description> </method> <method name="set_connection"> @@ -12541,6 +12545,20 @@ This approximation makes straight segments between each point, then subdivides t <argument index="3" name="body" type="String" default=""""> </argument> <description> + Sends a request to the connected host. The url is the what is normally behind the hostname, +i.e; +http://somehost.com/index.php +url would be "index.php" + +Headers are HTTP request headers + +To create a POST request with query strings to push to the server, do: +var fields = {"username" : "user", + "password" : "pass"} +var queryString = httpClient.query_string_from_dict(fields) +var headers = ["Content-Type: application/x-www-form-urlencoded", + "Content-Length: " + str(queryString.length())] +var result = httpClient.request(httpClient.METHOD_POST, "index.php", headers, queryString) </description> </method> <method name="send_body_text"> @@ -12548,7 +12566,8 @@ This approximation makes straight segments between each point, then subdivides t </return> <argument index="0" name="body" type="String"> </argument> - <description> + <description> + Stub function </description> </method> <method name="send_body_data"> @@ -12557,6 +12576,7 @@ This approximation makes straight segments between each point, then subdivides t <argument index="0" name="body" type="RawArray"> </argument> <description> + Stub function </description> </method> <method name="close"> @@ -12609,12 +12629,14 @@ This approximation makes straight segments between each point, then subdivides t <argument index="0" name="bytes" type="int"> </argument> <description> + Sets the size of the buffer used and maximum bytes to read per iteration </description> </method> <method name="set_blocking_mode"> <argument index="0" name="enabled" type="bool"> </argument> <description> + If set to true, execute will wait until all data is read from the response. </description> </method> <method name="is_blocking_mode_enabled" qualifiers="const"> @@ -12627,14 +12649,30 @@ This approximation makes straight segments between each point, then subdivides t <return type="int"> </return> <description> + Returns a status string like STATUS_REQUESTING. Need to call [method poll] in order to get status updates. </description> </method> <method name="poll"> <return type="Error"> </return> - <description> - </description> - </method> + <description> + This needs to be called in order to have any request processed. Check results with [method get_status] + </description> + </method> + <method name="query_string_from_dict"> + <return type="String"> + </return> + <argument index="0" name="fields" type="Dictionary"> + </argument> + <description> + Generates a GET/POST application/x-www-form-urlencoded style query string from a provided dictionary. + +var fields = {"username": "user", "password": "pass"} +String queryString = httpClient.query_string_from_dict(fields) + +returns:= "username=user&password=pass" + </description> + </method> </methods> <constants> <constant name="METHOD_GET" value="0"> diff --git a/drivers/unix/packet_peer_udp_posix.cpp b/drivers/unix/packet_peer_udp_posix.cpp index 94b4c35923..2111619080 100644 --- a/drivers/unix/packet_peer_udp_posix.cpp +++ b/drivers/unix/packet_peer_udp_posix.cpp @@ -121,7 +121,7 @@ Error PacketPeerUDPPosix::_poll(bool p_wait) { struct sockaddr_in from = {0}; socklen_t len = sizeof(struct sockaddr_in); int ret; - while ( (ret = recvfrom(sockfd, recv_buffer, MIN(sizeof(recv_buffer),rb.data_left()-12), p_wait?0:MSG_DONTWAIT, (struct sockaddr*)&from, &len)) > 0) { + while ( (ret = recvfrom(sockfd, recv_buffer, MIN((int)sizeof(recv_buffer),MAX(rb.space_left()-12, 0)), p_wait?0:MSG_DONTWAIT, (struct sockaddr*)&from, &len)) > 0) { rb.write((uint8_t*)&from.sin_addr, 4); uint32_t port = ntohs(from.sin_port); rb.write((uint8_t*)&port, 4); @@ -131,6 +131,8 @@ Error PacketPeerUDPPosix::_poll(bool p_wait) { ++queue_count; }; + + // TODO: Should ECONNRESET be handled here? if (ret == 0 || (ret == -1 && errno != EAGAIN) ) { close(); return FAILED; diff --git a/platform/windows/export/export.h b/platform/windows/export/export.h index ada74b9d77..2424efc861 100644 --- a/platform/windows/export/export.h +++ b/platform/windows/export/export.h @@ -29,7 +29,7 @@ protected: void _get_property_list( List<PropertyInfo> *p_list) const; public: - Error export_project(const String& p_path, bool p_debug, int p_flags=0); + Error export_project(const String& p_path, bool p_debug,int p_flags=0); EditorExportPlatformWindows(); }; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index baf85937c6..1fb8e6dbd0 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1765,84 +1765,96 @@ bool OS_Windows::is_window_maximized() const{ } -void OS_Windows::print_error(const char* p_function,const char* p_file,int p_line,const char *p_code,const char*p_rationale,ErrorType p_type) { +void OS_Windows::print_error(const char* p_function, const char* p_file, int p_line, const char* p_code, const char* p_rationale, ErrorType p_type) { - HANDLE hCon=GetStdHandle(STD_OUTPUT_HANDLE); - if (!hCon || hCon==INVALID_HANDLE_VALUE) { + HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE); + if (!hCon || hCon == INVALID_HANDLE_VALUE) { const char* err_details; if (p_rationale && p_rationale[0]) - err_details=p_rationale; + err_details = p_rationale; else - err_details=p_code; + err_details = p_code; switch(p_type) { case ERR_ERROR: - print("\E[1;31mERROR: %s: \E[0m\E[1m%s\n",p_function,err_details); - print("\E[0;31m At: %s:%i.\E[0m\n",p_file,p_line); + print("ERROR: %s: %s\n", p_function, err_details); + print(" At: %s:%i\n", p_file, p_line); break; case ERR_WARNING: - print("\E[1;33mWARNING: %s: \E[0m\E[1m%s\n",p_function,err_details); - print("\E[0;33m At: %s:%i.\E[0m\n",p_file,p_line); + print("WARNING: %s: %s\n", p_function, err_details); + print(" At: %s:%i\n", p_file, p_line); break; case ERR_SCRIPT: - print("\E[1;35mSCRIPT ERROR: %s: \E[0m\E[1m",p_function,err_details); - print("\E[0;35m At: %s:%i.\E[0m\n",p_file,p_line); + print("SCRIPT ERROR: %s: %s\n", p_function, err_details); + print(" At: %s:%i\n", p_file, p_line); break; } + } else { CONSOLE_SCREEN_BUFFER_INFO sbi; //original - GetConsoleScreenBufferInfo(hCon,&sbi); - - SetConsoleTextAttribute(hCon,sbi.wAttributes); + GetConsoleScreenBufferInfo(hCon, &sbi); + WORD current_fg = sbi.wAttributes & (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY); + WORD current_bg = sbi.wAttributes & (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY); - - uint32_t basecol=0; + uint32_t basecol = 0; switch(p_type) { case ERR_ERROR: basecol = FOREGROUND_RED; break; - case ERR_WARNING: basecol = FOREGROUND_RED|FOREGROUND_GREEN; break; - case ERR_SCRIPT: basecol = FOREGROUND_GREEN; break; + case ERR_WARNING: basecol = FOREGROUND_RED | FOREGROUND_GREEN; break; + case ERR_SCRIPT: basecol = FOREGROUND_RED | FOREGROUND_BLUE; break; } - if (p_rationale && p_rationale[0]) { - - SetConsoleTextAttribute(hCon,basecol|FOREGROUND_INTENSITY); + basecol |= current_bg; + if (p_rationale && p_rationale[0]) { + SetConsoleTextAttribute(hCon, basecol | FOREGROUND_INTENSITY); switch(p_type) { case ERR_ERROR: print("ERROR: "); break; case ERR_WARNING: print("WARNING: "); break; case ERR_SCRIPT: print("SCRIPT ERROR: "); break; } - SetConsoleTextAttribute(hCon,FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_INTENSITY); - print(" %s\n",p_rationale); - SetConsoleTextAttribute(hCon,basecol); - print("At: "); - SetConsoleTextAttribute(hCon,FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN); - print(" %s:%i\n",p_file,p_line); + SetConsoleTextAttribute(hCon, current_fg | current_bg | FOREGROUND_INTENSITY); + print("%s\n", p_rationale); + + SetConsoleTextAttribute(hCon, basecol); + switch (p_type) { + case ERR_ERROR: print(" At: "); break; + case ERR_WARNING: print(" At: "); break; + case ERR_SCRIPT: print(" At: "); break; + } + SetConsoleTextAttribute(hCon, current_fg | current_bg); + print("%s:%i\n", p_file, p_line); } else { - SetConsoleTextAttribute(hCon,basecol|FOREGROUND_INTENSITY); + + SetConsoleTextAttribute(hCon, basecol | FOREGROUND_INTENSITY); switch(p_type) { - case ERR_ERROR: print("ERROR: %s: ",p_function); break; - case ERR_WARNING: print("WARNING: %s: ",p_function); break; - case ERR_SCRIPT: print("SCRIPT ERROR: %s: ",p_function); break; + case ERR_ERROR: print("ERROR: %s: ", p_function); break; + case ERR_WARNING: print("WARNING: %s: ", p_function); break; + case ERR_SCRIPT: print("SCRIPT ERROR: %s: ", p_function); break; } - SetConsoleTextAttribute(hCon,FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_INTENSITY); - print(" %s\n",p_code); - SetConsoleTextAttribute(hCon,basecol); - print("At: "); - SetConsoleTextAttribute(hCon,FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN); - print(" %s:%i\n",p_file,p_line); + + SetConsoleTextAttribute(hCon, current_fg | current_bg | FOREGROUND_INTENSITY); + print("%s\n", p_code); + + SetConsoleTextAttribute(hCon, basecol); + switch (p_type) { + case ERR_ERROR: print(" At: "); break; + case ERR_WARNING: print(" At: "); break; + case ERR_SCRIPT: print(" At: "); break; + } + + SetConsoleTextAttribute(hCon, current_fg | current_bg); + print("%s:%i\n", p_file, p_line); } - SetConsoleTextAttribute(hCon,sbi.wAttributes); + SetConsoleTextAttribute(hCon, sbi.wAttributes); } - } diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp index aff92b8fc8..0ca2d358af 100644 --- a/platform/windows/packet_peer_udp_winsock.cpp +++ b/platform/windows/packet_peer_udp_winsock.cpp @@ -121,7 +121,7 @@ Error PacketPeerUDPWinsock::_poll(bool p_wait) { struct sockaddr_in from = {0}; int len = sizeof(struct sockaddr_in); int ret; - while ( (ret = recvfrom(sockfd, (char*)recv_buffer, MIN(sizeof(recv_buffer),rb.data_left()-12), 0, (struct sockaddr*)&from, &len)) > 0) { + while ( (ret = recvfrom(sockfd, (char*)recv_buffer, MIN((int)sizeof(recv_buffer),MAX(rb.space_left()-12, 0)), 0, (struct sockaddr*)&from, &len)) > 0) { rb.write((uint8_t*)&from.sin_addr, 4); uint32_t port = ntohs(from.sin_port); rb.write((uint8_t*)&port, 4); @@ -132,8 +132,25 @@ Error PacketPeerUDPWinsock::_poll(bool p_wait) { ++queue_count; }; + if (ret == SOCKET_ERROR){ + int error = WSAGetLastError(); + + if (error == WSAEWOULDBLOCK){ + // Expected when doing non-blocking sockets, retry later. + } + else if (error == WSAECONNRESET){ + // If the remote target does not accept messages, this error may occur, but is harmless. + // Once the remote target gets available, this message will disappear for new messages. + } + else + { + close(); + return FAILED; + } + } + - if (ret == 0 || (ret == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK) ) { + if (ret == 0) { close(); return FAILED; }; diff --git a/platform/winrt/os_winrt.cpp b/platform/winrt/os_winrt.cpp index 80ed436b85..24be2f47e7 100644 --- a/platform/winrt/os_winrt.cpp +++ b/platform/winrt/os_winrt.cpp @@ -423,26 +423,26 @@ void OSWinrt::get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen) con } -void OSWinrt::print_error(const char* p_function,const char* p_file,int p_line,const char *p_code,const char*p_rationale,ErrorType p_type) { +void OSWinrt::print_error(const char* p_function, const char* p_file, int p_line, const char* p_code, const char* p_rationale, ErrorType p_type) { const char* err_details; if (p_rationale && p_rationale[0]) - err_details=p_rationale; + err_details = p_rationale; else - err_details=p_code; + err_details = p_code; switch(p_type) { case ERR_ERROR: - print("\E[1;31mERROR: %s: \E[0m\E[1m%s\n",p_function,err_details); - print("\E[0;31m At: %s:%i.\E[0m\n",p_file,p_line); + print("ERROR: %s: %s\n", p_function, err_details); + print(" At: %s:%i\n", p_file, p_line); break; case ERR_WARNING: - print("\E[1;33mWARNING: %s: \E[0m\E[1m%s\n",p_function,err_details); - print("\E[0;33m At: %s:%i.\E[0m\n",p_file,p_line); + print("WARNING: %s: %s\n", p_function, err_details); + print(" At: %s:%i\n", p_file, p_line); break; case ERR_SCRIPT: - print("\E[1;35mSCRIPT ERROR: %s: \E[0m\E[1m",p_function,err_details); - print("\E[0;35m At: %s:%i.\E[0m\n",p_file,p_line); + print("SCRIPT ERROR: %s: %s\n", p_function, err_details); + print(" At: %s:%i\n", p_file, p_line); break; } } diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 3218230d0b..74ebad748a 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -34,7 +34,7 @@ #include <stdlib.h> #include "print_string.h" #include "servers/physics/physics_server_sw.h" - +#include "errno.h" #include "X11/Xutil.h" diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 6141b6a09e..52b112f090 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -354,7 +354,7 @@ void Node2D::look_at(const Vector2& p_pos) { float Node2D::get_angle_to(const Vector2& p_pos) const { - return (get_global_transform().affine_inverse().xform(p_pos)).atan2(); + return (get_global_transform().affine_inverse().xform(p_pos)).angle(); } void Node2D::_bind_methods() { diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 7ba1bb28b6..8f110b3931 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -118,7 +118,7 @@ void PathFollow2D::_update_transform() { pos+=n*h_offset; pos+=t*v_offset; - set_rot(t.atan2()); + set_rot(t.angle()); } else { diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index acc4c620e6..4a199e3418 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -131,7 +131,7 @@ void RayCast2D::_notification(int p_what) { if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint()) break; Matrix32 xf; - xf.rotate(cast_to.atan2()); + xf.rotate(cast_to.angle()); xf.translate(Vector2(0,cast_to.length())); //Vector2 tip = Vector2(0,s->get_length()); diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index d7ee7a6b86..49067bb3a0 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -435,8 +435,8 @@ void SplitContainer::_bind_methods() { ADD_SIGNAL( MethodInfo("dragged",PropertyInfo(Variant::INT,"offset"))); ADD_PROPERTY( PropertyInfo(Variant::INT,"split/offset"),_SCS("set_split_offset"),_SCS("get_split_offset")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"split/collapsed"),_SCS("set_collapsed"),_SCS("is_collapsed")); - ADD_PROPERTY( PropertyInfo(Variant::INT,"split/dragger_visible"),_SCS("set_dragger_visible"),_SCS("is_dragger_visible")); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"split/collapsed"),_SCS("set_collapsed"),_SCS("is_collapsed")); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"split/dragger_visible"),_SCS("set_dragger_visible"),_SCS("is_dragger_visible")); } diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index 38835c9a82..3afbbe5455 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -442,7 +442,7 @@ void Body2DSW::integrate_forces(real_t p_step) { //compute motion, angular and etc. velocities from prev transform linear_velocity = (new_transform.elements[2] - get_transform().elements[2])/p_step; - real_t rot = new_transform.affine_inverse().basis_xform(get_transform().elements[1]).atan2(); + real_t rot = new_transform.affine_inverse().basis_xform(get_transform().elements[1]).angle(); angular_velocity = rot / p_step; motion = new_transform.elements[2] - get_transform().elements[2]; diff --git a/tools/doc/doc_data.cpp b/tools/doc/doc_data.cpp index 432f358627..c1d3e5e314 100644 --- a/tools/doc/doc_data.cpp +++ b/tools/doc/doc_data.cpp @@ -189,9 +189,11 @@ void DocData::generate(bool p_basic_types) { arginfo=E->get().return_val; if (arginfo.type==Variant::NIL) continue; +#ifdef DEBUG_METHODS_ENABLED if (m && m->get_return_type()!=StringName()) method.return_type=m->get_return_type(); else +#endif method.return_type=(arginfo.hint==PROPERTY_HINT_RESOURCE_TYPE)?arginfo.hint_string:Variant::get_type_name(arginfo.type); } else { diff --git a/tools/docdump/makehtml.py b/tools/docdump/makehtml.py index d533ca1b8b..9b9c62f33b 100644 --- a/tools/docdump/makehtml.py +++ b/tools/docdump/makehtml.py @@ -1,5 +1,19 @@ import sys import xml.etree.ElementTree as ET +from xml.sax.saxutils import escape, unescape + +html_escape_table = { + '"': """, + "'": "'" +} + +html_unescape_table = {v:k for k, v in html_escape_table.items()} + +def html_escape(text): + return escape(text, html_escape_table) + +def html_unescape(text): + return unescape(text, html_unescape_table) input_list = [] @@ -96,7 +110,7 @@ def make_html_class_list(class_list,columns): idx=0 for n in class_list: - col = idx/col_max + col = int(idx/col_max) if (col>=columns): col=columns-1 fit_columns[col]+=[n] @@ -299,6 +313,7 @@ def make_type(p_type,p_parent): def make_text_def(class_name,parent,text): + text = html_escape(text) pos=0 while(True): pos = text.find("[",pos) @@ -598,7 +613,6 @@ def make_html_class(node): descr=node.find("description") if (descr!=None and descr.text.strip()!=""): - h4=ET.SubElement(div,"h4") h4.text="Description:" @@ -644,7 +658,6 @@ def make_html_class(node): class_names=[] classes={} - for file in input_list: tree = ET.parse(file) doc=tree.getroot() diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index 1bc09c5102..321ac76240 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -1428,7 +1428,8 @@ EditorHelp::EditorHelp() { { Panel *pc = memnew( Panel ); Ref<StyleBoxFlat> style( memnew( StyleBoxFlat ) ); - style->set_bg_color( EditorSettings::get_singleton()->get("text_editor/background_color") ); + style->set_bg_color( EditorSettings::get_singleton()->get("text_editor/background_color") ); + pc->set_v_size_flags(SIZE_EXPAND_FILL); pc->add_style_override("panel", style); //get_stylebox("normal","TextEdit")); vbc->add_child(pc); class_desc = memnew( RichTextLabel ); diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index b8b2a5262c..7d837f3211 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3822,9 +3822,7 @@ void EditorNode::_quick_run(const String& p_resource) { void EditorNode::notify_child_process_exited() { - play_button->set_pressed(false); - play_scene_button->set_pressed(false); - //pause_button->set_pressed(false); + _menu_option_confirm(RUN_STOP,false); stop_button->set_pressed(false); editor_run.stop(); diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index 99dcf4ed28..ca44df269b 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -1814,8 +1814,8 @@ Node* EditorSceneImportPlugin::_fix_node(Node *p_node,Node *p_root,Map<Ref<Mesh> for(int i=0;i<portal_points.size()-1;i++) { - float a = portal_points[i].atan2(); - float b = portal_points[i+1].atan2(); + float a = portal_points[i].angle(); + float b = portal_points[i+1].angle(); if (a>b) { SWAP( portal_points[i], portal_points[i+1] ); diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 90bfe0bfdf..e3f4edf967 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -999,7 +999,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { if (b.button_index==BUTTON_RIGHT) { - if (!b.pressed && tool==TOOL_SELECT && b.mod.alt) { + if (b.pressed && tool==TOOL_SELECT && b.mod.alt) { Point2 click=Point2(b.x,b.y); @@ -1488,7 +1488,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { Matrix32 rot; rot.elements[1] = (dfrom - center).normalized(); rot.elements[0] = rot.elements[1].tangent(); - node->set_rot(snap_angle(rot.xform_inv(dto-center).atan2(), node->get_rot())); + node->set_rot(snap_angle(rot.xform_inv(dto-center).angle(), node->get_rot())); display_rotate_to = dto; display_rotate_from = center; viewport->update(); diff --git a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp index f56b9a2fd9..7e5d52d17d 100644 --- a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -42,6 +42,13 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const { } break; case LINE_SHAPE: { + Ref<LineShape2D> line = node->get_shape(); + + if (idx==0) { + return line->get_d(); + } else { + return line->get_normal(); + } } break; @@ -121,7 +128,7 @@ void CollisionShape2DEditor::set_handle(int idx, Point2& p_point) { if (idx==0){ line->set_d(p_point.length()); }else{ - line->set_normal(p_point/30.0); + line->set_normal(p_point.normalized()); } canvas_item_editor->get_viewport_control()->update(); diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index e2202214dd..7816efe89f 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -862,6 +862,57 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { //VisualServer::get_singleton()->instance_set_transform(cursor_instance,Transform(Matrix3(),cursor.cursor_pos)); } } + + if (b.mod.alt) { + + if (nav_scheme == NAVIGATION_MAYA) + break; + + _find_items_at_pos(Vector2( b.x, b.y ),clicked_includes_current,selection_results,b.mod.shift); + + clicked_wants_append=b.mod.shift; + + if (selection_results.size() == 1) { + + clicked=selection_results[0].item->get_instance_ID(); + selection_results.clear(); + + if (clicked) { + _select_clicked(clicked_wants_append,true); + clicked=0; + } + + } else if (!selection_results.empty()) { + + NodePath root_path = get_tree()->get_edited_scene_root()->get_path(); + StringName root_name = root_path.get_name(root_path.get_name_count()-1); + + for (int i = 0; i < selection_results.size(); i++) { + + Spatial *spat=selection_results[i].item; + + Ref<Texture> icon; + if (spat->has_meta("_editor_icon")) + icon=spat->get_meta("_editor_icon"); + else + icon=get_icon( has_icon(spat->get_type(),"EditorIcons")?spat->get_type():String("Object"),"EditorIcons"); + + String node_path="/"+root_name+"/"+root_path.rel_path_to(spat->get_path()); + + selection_menu->add_item(spat->get_name()); + selection_menu->set_item_icon(i, icon ); + selection_menu->set_item_metadata(i, node_path); + selection_menu->set_item_tooltip(i,String(spat->get_name())+ + "\nType: "+spat->get_type()+"\nPath: "+node_path); + } + + selection_menu->set_global_pos(Vector2( b.global_x, b.global_y )); + selection_menu->popup(); + selection_menu->call_deferred("grab_click_focus"); + + break; + } + } } if (_edit.mode!=TRANSFORM_NONE && b.pressed) { @@ -888,57 +939,6 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { //VisualServer::get_singleton()->poly_clear(indicators); set_message("Transform Aborted.",3); } - - if (!b.pressed && (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_SELECT && b.mod.alt)) { - - if (nav_scheme == NAVIGATION_MAYA) - break; - - _find_items_at_pos(Vector2( b.x, b.y ),clicked_includes_current,selection_results,b.mod.shift); - - clicked_wants_append=b.mod.shift; - - if (selection_results.size() == 1) { - - clicked=selection_results[0].item->get_instance_ID(); - selection_results.clear(); - - if (clicked) { - _select_clicked(clicked_wants_append,true); - clicked=0; - } - - } else if (!selection_results.empty()) { - - NodePath root_path = get_tree()->get_edited_scene_root()->get_path(); - StringName root_name = root_path.get_name(root_path.get_name_count()-1); - - for (int i = 0; i < selection_results.size(); i++) { - - Spatial *spat=selection_results[i].item; - - Ref<Texture> icon; - if (spat->has_meta("_editor_icon")) - icon=spat->get_meta("_editor_icon"); - else - icon=get_icon( has_icon(spat->get_type(),"EditorIcons")?spat->get_type():String("Object"),"EditorIcons"); - - String node_path="/"+root_name+"/"+root_path.rel_path_to(spat->get_path()); - - selection_menu->add_item(spat->get_name()); - selection_menu->set_item_icon(i, icon ); - selection_menu->set_item_metadata(i, node_path); - selection_menu->set_item_tooltip(i,String(spat->get_name())+ - "\nType: "+spat->get_type()+"\nPath: "+node_path); - } - - selection_menu->set_global_pos(Vector2( b.global_x, b.global_y )); - selection_menu->popup(); - selection_menu->call_deferred("grab_click_focus"); - - break; - } - } } break; case BUTTON_MIDDLE: { diff --git a/tools/editor/scenes_dock.cpp b/tools/editor/scenes_dock.cpp index dfd729354d..c9b376ebec 100644 --- a/tools/editor/scenes_dock.cpp +++ b/tools/editor/scenes_dock.cpp @@ -155,7 +155,7 @@ void ScenesDock::_notification(int p_what) { if (initialized) return; - initialized=false; + initialized=true; EditorFileSystem::get_singleton()->connect("filesystem_changed",this,"_fs_changed"); diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp index 4dc9c4f43e..5efca44c7d 100644 --- a/tools/editor/spatial_editor_gizmos.cpp +++ b/tools/editor/spatial_editor_gizmos.cpp @@ -745,7 +745,7 @@ static float _find_closest_angle_to_half_pi_arc(const Vector3& p_from, const Vec } //min_p = p_arc_xform.affine_inverse().xform(min_p); - float a = Vector2(min_p.x,-min_p.z).atan2(); + float a = Vector2(min_p.x,-min_p.z).angle(); return a*180.0/Math_PI; } diff --git a/tools/pe_bliss/utils.cpp b/tools/pe_bliss/utils.cpp index 00a20ef6f2..e6a75d5497 100644 --- a/tools/pe_bliss/utils.cpp +++ b/tools/pe_bliss/utils.cpp @@ -23,9 +23,6 @@ #include "utils.h" #include "pe_exception.h" -#ifndef PE_BLISS_WINDOWS -#include <iconv.h> -#endif namespace pe_bliss { @@ -50,22 +47,13 @@ const u16string pe_utils::to_ucs2(const std::wstring& str) if(str.empty()) return ret; - ret.resize(str.length()); - - iconv_t conv = iconv_open("UCS-2", "WCHAR_T"); - if(conv == reinterpret_cast<iconv_t>(-1)) - throw pe_exception("Error opening iconv", pe_exception::encoding_convertion_error); - - size_t inbytesleft = str.length() * sizeof(wchar_t); - size_t outbytesleft = ret.length() * sizeof(unicode16_t); - const wchar_t* in_pos = str.c_str(); - unicode16_t* out_pos = &ret[0]; - - size_t result = iconv(conv, const_cast<char**>(reinterpret_cast<const char**>(&in_pos)), &inbytesleft, reinterpret_cast<char**>(&out_pos), &outbytesleft); - iconv_close(conv); + int len = str.length(); - if(result == static_cast<size_t>(-1)) - throw pe_exception("Iconv error", pe_exception::encoding_convertion_error); + ret.resize(len); + + for(int i=0;i<len;i++) { + ret[i]=str[i]&0xFFFF; + } return ret; } @@ -76,22 +64,12 @@ const std::wstring pe_utils::from_ucs2(const u16string& str) if(str.empty()) return ret; + int len = str.length(); ret.resize(str.length()); - - iconv_t conv = iconv_open("WCHAR_T", "UCS-2"); - if(conv == reinterpret_cast<iconv_t>(-1)) - throw pe_exception("Error opening iconv", pe_exception::encoding_convertion_error); - - size_t inbytesleft = str.length() * sizeof(unicode16_t); - size_t outbytesleft = ret.length() * sizeof(wchar_t); - const unicode16_t* in_pos = str.c_str(); - wchar_t* out_pos = &ret[0]; - - size_t result = iconv(conv, const_cast<char**>(reinterpret_cast<const char**>(&in_pos)), &inbytesleft, reinterpret_cast<char**>(&out_pos), &outbytesleft); - iconv_close(conv); - - if(result == static_cast<size_t>(-1)) - throw pe_exception("Iconv error", pe_exception::encoding_convertion_error); + + for(int i=0;i<len;i++) { + ret[i]=str[i]; + } return ret; } |