summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/image.cpp9
-rw-r--r--core/image.h5
-rw-r--r--core/io/ip_address.h6
-rw-r--r--core/io/packet_peer_udp.cpp20
-rw-r--r--core/io/packet_peer_udp.h4
-rw-r--r--core/script_language.cpp7
-rw-r--r--core/script_language.h2
-rw-r--r--core/variant_call.cpp2
8 files changed, 51 insertions, 4 deletions
diff --git a/core/image.cpp b/core/image.cpp
index ae9fb0adc4..17ee569b6b 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -34,6 +34,7 @@
#include "print_string.h"
#include <stdio.h>
+SavePNGFunc Image::save_png_func = NULL;
void Image::_put_pixel(int p_x,int p_y, const BColor& p_color, unsigned char *p_data) {
@@ -1200,6 +1201,14 @@ Error Image::load(const String& p_path) {
return ImageLoader::load_image(p_path, this);
}
+Error Image::save_png(const String& p_path) {
+
+ if (save_png_func == NULL)
+ return ERR_UNAVAILABLE;
+
+ return save_png_func(p_path, *this);
+};
+
bool Image::operator==(const Image& p_image) const {
if (data.size() == 0 && p_image.data.size() == 0)
diff --git a/core/image.h b/core/image.h
index 0084a3616f..f4c96703b9 100644
--- a/core/image.h
+++ b/core/image.h
@@ -40,7 +40,9 @@
* Images can be loaded from a file, or registered into the Render object as textures.
*/
+class Image;
+typedef Error (*SavePNGFunc)(const String &p_path, Image& p_img);
class Image {
@@ -50,6 +52,8 @@ class Image {
};
public:
+ static SavePNGFunc save_png_func;
+
enum Format {
FORMAT_GRAYSCALE, ///< one byte per pixel, 0-255
FORMAT_INTENSITY, ///< one byte per pixel, 0-255
@@ -278,6 +282,7 @@ public:
DVector<uint8_t> get_data() const;
Error load(const String& p_path);
+ Error save_png(const String& p_path);
/**
* create an empty image
diff --git a/core/io/ip_address.h b/core/io/ip_address.h
index cd39aa6c81..3cd8bb7733 100644
--- a/core/io/ip_address.h
+++ b/core/io/ip_address.h
@@ -39,6 +39,12 @@ struct IP_Address {
};
//operator Variant() const;
+ bool operator==(const IP_Address& p_ip) const {
+ return host==p_ip.host;
+ }
+ bool operator!=(const IP_Address& p_ip) const {
+ return host!=p_ip.host;
+ }
operator String() const;
IP_Address(const String& p_string);
IP_Address(uint8_t p_a,uint8_t p_b,uint8_t p_c,uint8_t p_d);
diff --git a/core/io/packet_peer_udp.cpp b/core/io/packet_peer_udp.cpp
index f301370944..83217ffc41 100644
--- a/core/io/packet_peer_udp.cpp
+++ b/core/io/packet_peer_udp.cpp
@@ -1,5 +1,5 @@
#include "packet_peer_udp.h"
-
+#include "io/ip.h"
PacketPeerUDP* (*PacketPeerUDP::_create)()=NULL;
@@ -15,17 +15,31 @@ String PacketPeerUDP::_get_packet_ip() const {
return get_packet_address();
}
+Error PacketPeerUDP::_set_send_address(const String& p_address,int p_port) {
+
+ IP_Address ip;
+ if (p_address.is_valid_ip_address()) {
+ ip=p_address;
+ } else {
+ ip=IP::get_singleton()->resolve_hostname(p_address);
+ if (ip==IP_Address())
+ return ERR_CANT_RESOLVE;
+ }
+
+ set_send_address(ip,p_port);
+ return OK;
+}
void PacketPeerUDP::_bind_methods() {
ObjectTypeDB::bind_method(_MD("listen:Error","port","recv_buf_size"),&PacketPeerUDP::listen,DEFVAL(65536));
ObjectTypeDB::bind_method(_MD("close"),&PacketPeerUDP::close);
- ObjectTypeDB::bind_method(_MD("poll:Error"),&PacketPeerUDP::poll);
+ ObjectTypeDB::bind_method(_MD("wait:Error"),&PacketPeerUDP::wait);
ObjectTypeDB::bind_method(_MD("is_listening"),&PacketPeerUDP::is_listening);
ObjectTypeDB::bind_method(_MD("get_packet_ip"),&PacketPeerUDP::_get_packet_ip);
ObjectTypeDB::bind_method(_MD("get_packet_address"),&PacketPeerUDP::_get_packet_address);
ObjectTypeDB::bind_method(_MD("get_packet_port"),&PacketPeerUDP::get_packet_port);
- ObjectTypeDB::bind_method(_MD("set_send_address","address","port"),&PacketPeerUDP::set_send_address);
+ ObjectTypeDB::bind_method(_MD("set_send_address","host","port"),&PacketPeerUDP::_set_send_address);
}
diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h
index 049ac0132f..73ff487b19 100644
--- a/core/io/packet_peer_udp.h
+++ b/core/io/packet_peer_udp.h
@@ -15,11 +15,13 @@ protected:
int _get_packet_address() const;
String _get_packet_ip() const;
+ virtual Error _set_send_address(const String& p_address,int p_port);
+
public:
virtual Error listen(int p_port,int p_recv_buffer_size=65536)=0;
virtual void close()=0;
- virtual Error poll()=0;
+ virtual Error wait()=0;
virtual bool is_listening() const=0;
virtual IP_Address get_packet_address() const=0;
virtual int get_packet_port() const=0;
diff --git a/core/script_language.cpp b/core/script_language.cpp
index ad93fca4b5..81a9e2b062 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -85,6 +85,13 @@ void ScriptServer::register_language(ScriptLanguage *p_language) {
_languages[_language_count++]=p_language;
}
+void ScriptServer::init_languages() {
+
+ for(int i=0;i<_language_count;i++) {
+ _languages[i]->init();
+ }
+}
+
Variant ScriptInstance::call(const StringName& p_method,VARIANT_ARG_DECLARE) {
VARIANT_ARGPTRS;
diff --git a/core/script_language.h b/core/script_language.h
index 1e0dcc678f..d62e9849a1 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -54,6 +54,8 @@ public:
static int get_language_count();
static ScriptLanguage *get_language(int p_idx);
static void register_language(ScriptLanguage *p_language);
+
+ static void init_languages();
};
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 28953a535f..93a9e6475f 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -544,6 +544,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_PTR0R(Image,get_used_rect);
VCALL_PTR3R(Image,brushed);
VCALL_PTR1R(Image,load);
+ VCALL_PTR1R(Image,save_png);
VCALL_PTR3(Image,brush_transfer);
VCALL_PTR1R(Image,get_rect);
VCALL_PTR1R(Image,compressed);
@@ -1326,6 +1327,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC4(IMAGE, NIL, Image, put_pixel, INT, "x", INT, "y", COLOR, "color", INT, "mipmap_level", varray(0));
ADDFUNC3(IMAGE, IMAGE, Image, brushed, IMAGE, "src", IMAGE, "brush", VECTOR2, "pos", varray(0));
ADDFUNC1(IMAGE, INT, Image, load, STRING, "path", varray(0));
+ ADDFUNC1(IMAGE, INT, Image, save_png, STRING, "path", varray(0));
ADDFUNC3(IMAGE, NIL, Image, brush_transfer, IMAGE, "src", IMAGE, "brush", VECTOR2, "pos", varray(0));
ADDFUNC0(IMAGE, RECT2, Image, get_used_rect, varray(0));
ADDFUNC1(IMAGE, IMAGE, Image, get_rect, RECT2, "area", varray(0));