diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/bind/core_bind.cpp | 12 | ||||
-rw-r--r-- | core/bind/core_bind.h | 11 | ||||
-rw-r--r-- | core/image.cpp | 25 | ||||
-rw-r--r-- | core/image.h | 1 | ||||
-rw-r--r-- | core/io/file_access_encrypted.cpp | 5 | ||||
-rw-r--r-- | core/io/file_access_pack.cpp | 5 | ||||
-rw-r--r-- | core/io/file_access_pack.h | 1 | ||||
-rw-r--r-- | core/io/ip.cpp | 13 | ||||
-rw-r--r-- | core/io/ip.h | 3 | ||||
-rw-r--r-- | core/io/packet_peer.cpp | 1 | ||||
-rw-r--r-- | core/os/dir_access.h | 2 | ||||
-rw-r--r-- | core/os/file_access.cpp | 2 | ||||
-rw-r--r-- | core/os/input.cpp | 2 | ||||
-rw-r--r-- | core/os/main_loop.cpp | 2 | ||||
-rw-r--r-- | core/script_language.h | 1 |
15 files changed, 83 insertions, 3 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index ec159da00f..73b8c01ee2 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -98,6 +98,13 @@ void _ResourceSaver::_bind_methods() { ObjectTypeDB::bind_method(_MD("save","path","resource:Resource"),&_ResourceSaver::save, DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_recognized_extensions","type"),&_ResourceSaver::get_recognized_extensions); + + BIND_CONSTANT(FLAG_RELATIVE_PATHS); + BIND_CONSTANT(FLAG_BUNDLE_RESOURCES); + BIND_CONSTANT(FLAG_CHANGE_PATH); + BIND_CONSTANT(FLAG_OMIT_EDITOR_PROPERTIES); + BIND_CONSTANT(FLAG_SAVE_BIG_ENDIAN); + BIND_CONSTANT(FLAG_COMPRESS); } _ResourceSaver::_ResourceSaver() { @@ -1340,6 +1347,10 @@ bool _Directory::file_exists(String p_file){ return d->file_exists(p_file); } +bool _Directory::dir_exists(String p_dir) { + ERR_FAIL_COND_V(!d,false); + return d->dir_exists(p_dir); +} int _Directory::get_space_left(){ @@ -1379,6 +1390,7 @@ void _Directory::_bind_methods() { ObjectTypeDB::bind_method(_MD("make_dir:Error","name"),&_Directory::make_dir); ObjectTypeDB::bind_method(_MD("make_dir_recursive:Error","name"),&_Directory::make_dir_recursive); ObjectTypeDB::bind_method(_MD("file_exists","name"),&_Directory::file_exists); + ObjectTypeDB::bind_method(_MD("dir_exists","name"),&_Directory::dir_exists); // ObjectTypeDB::bind_method(_MD("get_modified_time","file"),&_Directory::get_modified_time); ObjectTypeDB::bind_method(_MD("get_space_left"),&_Directory::get_space_left); ObjectTypeDB::bind_method(_MD("copy:Error","from","to"),&_Directory::copy); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 18eb594760..02fe3e8874 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -39,6 +39,16 @@ protected: static _ResourceSaver *singleton; public: + enum SaverFlags { + + FLAG_RELATIVE_PATHS=1, + FLAG_BUNDLE_RESOURCES=2, + FLAG_CHANGE_PATH=4, + FLAG_OMIT_EDITOR_PROPERTIES=8, + FLAG_SAVE_BIG_ENDIAN=16, + FLAG_COMPRESS=32, + }; + static _ResourceSaver *get_singleton() { return singleton; } Error save(const String &p_path,const RES& p_resource, uint32_t p_flags); @@ -340,6 +350,7 @@ public: Error make_dir_recursive(String p_dir); bool file_exists(String p_file); + bool dir_exists(String p_dir); int get_space_left(); diff --git a/core/image.cpp b/core/image.cpp index ccabd04d6f..db20862af5 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1660,6 +1660,31 @@ void Image::set_compress_bc_func(void (*p_compress_func)(Image *)) { } + +void Image::premultiply_alpha() { + + if (data.size()==0) + return; + + if (format!=FORMAT_RGBA) + return; //not needed + + DVector<uint8_t>::Write wp = data.write(); + unsigned char *data_ptr=wp.ptr(); + + + for(int i=0;i<height;i++) { + for(int j=0;j<width;j++) { + + BColor bc = _get_pixel(j,i,data_ptr,0); + bc.r=(int(bc.r)*int(bc.a))>>8; + bc.g=(int(bc.g)*int(bc.a))>>8; + bc.b=(int(bc.b)*int(bc.a))>>8; + _put_pixel(j,i,bc,data_ptr); + } + } +} + void Image::fix_alpha_edges() { if (data.size()==0) diff --git a/core/image.h b/core/image.h index 186aceb1bf..99300fc3af 100644 --- a/core/image.h +++ b/core/image.h @@ -320,6 +320,7 @@ public: void decompress(); void fix_alpha_edges(); + void premultiply_alpha(); void blit_rect(const Image& p_src, const Rect2& p_src_rect,const Point2& p_dest); void brush_transfer(const Image& p_src, const Image& p_brush, const Point2& p_dest); diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index bcd4197e11..29f27dcbda 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -25,6 +25,7 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base,const Vector<uint8_ } else if (p_mode==MODE_READ) { + writing=false; key=p_key; uint32_t magic = p_base->get_32(); print_line("MAGIC: "+itos(magic)); @@ -278,6 +279,10 @@ uint64_t FileAccessEncrypted::_get_modified_time(const String& p_file){ FileAccessEncrypted::FileAccessEncrypted() { file=NULL; + pos=0; + eofed=false; + mode=MODE_MAX; + writing=false; } diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 6a28fa9dae..e2cb300ebc 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -443,6 +443,11 @@ bool DirAccessPack::file_exists(String p_file){ return current->files.has(p_file); } +bool DirAccessPack::dir_exists(String p_dir) { + + return current->subdirs.has(p_dir); +} + Error DirAccessPack::make_dir(String p_dir){ return ERR_UNAVAILABLE; diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index 07ce8cbaf8..a4c750bf3c 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -190,6 +190,7 @@ public: virtual bool file_exists(String p_file); + virtual bool dir_exists(String p_dir); virtual Error make_dir(String p_dir); diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 503a009444..d2a685f6b0 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -188,6 +188,18 @@ void IP::erase_resolve_item(ResolverID p_id) { } +Array IP::_get_local_addresses() const { + + Array addresses; + List<IP_Address> ip_addresses; + get_local_addresses(&ip_addresses); + for(List<IP_Address>::Element *E=ip_addresses.front();E;E=E->next()) { + addresses.push_back(E->get()); + } + + return addresses; +} + void IP::_bind_methods() { ObjectTypeDB::bind_method(_MD("resolve_hostname","host"),&IP::resolve_hostname); @@ -195,6 +207,7 @@ void IP::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_resolve_item_status","id"),&IP::get_resolve_item_status); ObjectTypeDB::bind_method(_MD("get_resolve_item_address","id"),&IP::get_resolve_item_address); ObjectTypeDB::bind_method(_MD("erase_resolve_item","id"),&IP::erase_resolve_item); + ObjectTypeDB::bind_method(_MD("get_local_addresses"),&IP::_get_local_addresses); BIND_CONSTANT( RESOLVER_STATUS_NONE ); BIND_CONSTANT( RESOLVER_STATUS_WAITING ); diff --git a/core/io/ip.h b/core/io/ip.h index f1ef5fe794..0181dc7d12 100644 --- a/core/io/ip.h +++ b/core/io/ip.h @@ -66,16 +66,19 @@ protected: static void _bind_methods(); virtual IP_Address _resolve_hostname(const String& p_hostname)=0; + Array _get_local_addresses() const; static IP* (*_create)(); public: + IP_Address resolve_hostname(const String& p_hostname); // async resolver hostname ResolverID resolve_hostname_queue_item(const String& p_hostname); ResolverStatus get_resolve_item_status(ResolverID p_id) const; IP_Address get_resolve_item_address(ResolverID p_id) const; + virtual void get_local_addresses(List<IP_Address> *r_addresses) const=0; void erase_resolve_item(ResolverID p_id); static IP* get_singleton(); diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index f67a10df2e..37fc9c4a0a 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -112,6 +112,7 @@ void PacketPeer::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_var"),&PacketPeer::_bnd_get_var); ObjectTypeDB::bind_method(_MD("put_var", "var:Variant"),&PacketPeer::put_var); + ObjectTypeDB::bind_method(_MD("get_available_packet_count"),&PacketPeer::get_available_packet_count); }; /***************/ diff --git a/core/os/dir_access.h b/core/os/dir_access.h index 58a925465a..d8672218bd 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -91,7 +91,7 @@ public: virtual Error erase_contents_recursive(); //super dangerous, use with care! virtual bool file_exists(String p_file)=0; - + virtual bool dir_exists(String p_dir)=0; virtual size_t get_space_left()=0; diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 31e7d19bae..ffa0cad8e4 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -100,7 +100,7 @@ FileAccess *FileAccess::open(const String& p_path, int p_mode_flags, Error *r_er FileAccess *ret=NULL; if (!(p_mode_flags&WRITE) && PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled()) { ret = PackedData::get_singleton()->try_open_path(p_path); - if (ret) { + if (ret) { if (r_error) *r_error=OK; return ret; diff --git a/core/os/input.cpp b/core/os/input.cpp index d7c0d86d64..70733aadec 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -211,6 +211,8 @@ void InputDefault::parse_input_event(const InputEvent& p_event) { if (p_event.key.scancode==0) break; + // print_line(p_event); + if (p_event.key.pressed) keys_pressed.insert(p_event.key.scancode); else diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index a8e02526b9..d01331a256 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -37,7 +37,7 @@ void MainLoop::_bind_methods() { BIND_CONSTANT(NOTIFICATION_WM_FOCUS_OUT); BIND_CONSTANT(NOTIFICATION_WM_QUIT_REQUEST); BIND_CONSTANT(NOTIFICATION_WM_UNFOCUS_REQUEST); - + BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING); }; diff --git a/core/script_language.h b/core/script_language.h index 9731273610..560de520ca 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -141,6 +141,7 @@ public: virtual int find_function(const String& p_function,const String& p_code) const=0; virtual String make_function(const String& p_class,const String& p_name,const StringArray& p_args) const=0; virtual Error complete_keyword(const String& p_code, int p_line, const String& p_base_path, const String& p_keyword, List<String>* r_options) { return ERR_UNAVAILABLE; } + virtual void auto_indent_code(String& p_code,int p_from_line,int p_to_line) const=0; /* DEBUGGER FUNCTIONS */ |