summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/globals.cpp7
-rw-r--r--core/io/packet_peer.cpp21
-rw-r--r--core/io/packet_peer.h8
-rw-r--r--core/math/math_2d.h23
4 files changed, 58 insertions, 1 deletions
diff --git a/core/globals.cpp b/core/globals.cpp
index 0315ff0c24..8a7d66b68a 100644
--- a/core/globals.cpp
+++ b/core/globals.cpp
@@ -1397,6 +1397,13 @@ Globals::Globals() {
set("input/ui_accept",va);
va=Array();
+ key.key.scancode=KEY_SPACE;
+ va.push_back(key);
+ joyb.joy_button.button_index=JOY_BUTTON_3;
+ va.push_back(joyb);
+ set("input/ui_select",va);
+
+ va=Array();
key.key.scancode=KEY_ESCAPE;
va.push_back(key);
joyb.joy_button.button_index=JOY_BUTTON_1;
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 7b5ea65a4b..be566471a8 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -36,7 +36,7 @@
PacketPeer::PacketPeer() {
-
+ last_get_error=OK;
}
Error PacketPeer::get_packet_buffer(DVector<uint8_t> &r_buffer) const {
@@ -108,10 +108,29 @@ Variant PacketPeer::_bnd_get_var() const {
return var;
};
+Error PacketPeer::_put_packet(const DVector<uint8_t> &p_buffer) {
+ return put_packet_buffer(p_buffer);
+}
+DVector<uint8_t> PacketPeer::_get_packet() const {
+
+ DVector<uint8_t> raw;
+ last_get_error=get_packet_buffer(raw);
+ return raw;
+}
+
+Error PacketPeer::_get_packet_error() const {
+
+ return last_get_error;
+}
+
+
void PacketPeer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_var"),&PacketPeer::_bnd_get_var);
ObjectTypeDB::bind_method(_MD("put_var", "var:var"),&PacketPeer::put_var);
+ ObjectTypeDB::bind_method(_MD("get_packet:Error"),&PacketPeer::_get_packet);
+ ObjectTypeDB::bind_method(_MD("put_packet", "buffer"),&PacketPeer::_get_packet);
+ ObjectTypeDB::bind_method(_MD("get_packet_error:Error"),&PacketPeer::_get_packet_error);
ObjectTypeDB::bind_method(_MD("get_available_packet_count"),&PacketPeer::get_available_packet_count);
};
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index 3448ebde1b..76d1eb22b5 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -41,6 +41,14 @@ class PacketPeer : public Reference {
static void _bind_methods();
+
+ Error _put_packet(const DVector<uint8_t> &p_buffer);
+ DVector<uint8_t> _get_packet() const;
+ Error _get_packet_error() const;
+
+
+ mutable Error last_get_error;
+
public:
virtual int get_available_packet_count() const=0;
diff --git a/core/math/math_2d.h b/core/math/math_2d.h
index ac315fddb7..5e6cefd114 100644
--- a/core/math/math_2d.h
+++ b/core/math/math_2d.h
@@ -226,6 +226,29 @@ struct Rect2 {
return true;
}
+ inline float distance_to(const Vector2& p_point) const {
+
+ float dist = 1e20;
+
+ if (p_point.x < pos.x) {
+ dist=MIN(dist,pos.x-p_point.x);
+ }
+ if (p_point.y < pos.y) {
+ dist=MIN(dist,pos.y-p_point.y);
+ }
+ if (p_point.x >= (pos.x+size.x) ) {
+ dist=MIN(p_point.x-(pos.x+size.x),dist);
+ }
+ if (p_point.y >= (pos.y+size.y) ) {
+ dist=MIN(p_point.y-(pos.y+size.y),dist);
+ }
+
+ if (dist==1e20)
+ return 0;
+ else
+ return dist;
+ }
+
_FORCE_INLINE_ bool intersects_transformed(const Matrix32& p_xform, const Rect2& p_rect) const;
bool intersects_segment(const Point2& p_from, const Point2& p_to, Point2* r_pos=NULL, Point2* r_normal=NULL) const;