From af368b7e1accb27afdd958af59ef515413590823 Mon Sep 17 00:00:00 2001 From: hurikhan Date: Fri, 3 Apr 2015 15:00:55 -0400 Subject: set screen parameter names for gdscript --- core/bind/core_bind.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 5839467388..439855fbb7 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -709,13 +709,13 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_screen_count"),&_OS::get_screen_count); ObjectTypeDB::bind_method(_MD("get_current_screen"),&_OS::get_current_screen); - ObjectTypeDB::bind_method(_MD("set_current_screen"),&_OS::set_current_screen); - ObjectTypeDB::bind_method(_MD("get_screen_position"),&_OS::get_screen_position,DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("get_screen_size"),&_OS::get_screen_size,DEFVAL(0)); + ObjectTypeDB::bind_method(_MD("set_current_screen","screen"),&_OS::set_current_screen); + ObjectTypeDB::bind_method(_MD("get_screen_position","screen"),&_OS::get_screen_position,DEFVAL(0)); + ObjectTypeDB::bind_method(_MD("get_screen_size","screen"),&_OS::get_screen_size,DEFVAL(0)); ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position); - ObjectTypeDB::bind_method(_MD("set_window_position"),&_OS::set_window_position); + ObjectTypeDB::bind_method(_MD("set_window_position","position"),&_OS::set_window_position); ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size); - ObjectTypeDB::bind_method(_MD("set_window_size"),&_OS::set_window_size); + ObjectTypeDB::bind_method(_MD("set_window_size","size"),&_OS::set_window_size); ObjectTypeDB::bind_method(_MD("set_window_fullscreen","enabled"),&_OS::set_window_fullscreen); ObjectTypeDB::bind_method(_MD("is_window_fullscreen"),&_OS::is_window_fullscreen); ObjectTypeDB::bind_method(_MD("set_window_resizable","enabled"),&_OS::set_window_resizable); -- cgit v1.2.3 From 3e20391bf607dc7c452b056854aed4a8c99ba0f6 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 12 Apr 2015 17:55:01 -0300 Subject: -Changed bootsplash option to use a file, fixes #1539 -Added OS.get_splash_tick_msec() to query when splash appeared --- core/bind/core_bind.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 439855fbb7..cde328bc6f 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -500,6 +500,10 @@ uint32_t _OS::get_ticks_msec() const { return OS::get_singleton()->get_ticks_msec(); } +uint32_t _OS::get_splash_tick_msec() const { + + return OS::get_singleton()->get_splash_tick_msec(); +} bool _OS::can_use_threads() const { @@ -765,6 +769,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("delay_usec","usec"),&_OS::delay_usec); ObjectTypeDB::bind_method(_MD("delay_msec","msec"),&_OS::delay_msec); ObjectTypeDB::bind_method(_MD("get_ticks_msec"),&_OS::get_ticks_msec); + ObjectTypeDB::bind_method(_MD("get_splash_tick_msec"),&_OS::get_splash_tick_msec); ObjectTypeDB::bind_method(_MD("get_locale"),&_OS::get_locale); ObjectTypeDB::bind_method(_MD("get_model_name"),&_OS::get_model_name); -- cgit v1.2.3 From e72717e3738ea7fe1a2a6c9447ad0090bdf297ec Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 17 May 2015 13:11:55 -0300 Subject: properly save external resources, fixes #1924 added API to get scancode names to OS --- core/bind/core_bind.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index cde328bc6f..06b71f05c0 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -5,7 +5,7 @@ #include "io/base64.h" #include "core/globals.h" #include "io/file_access_encrypted.h" - +#include "os/keyboard.h" _ResourceLoader *_ResourceLoader::singleton=NULL; Ref _ResourceLoader::load_interactive(const String& p_path,const String& p_type_hint) { @@ -694,6 +694,20 @@ String _OS::get_custom_level() const { return OS::get_singleton()->get_custom_level(); } + +String _OS::get_scancode_string(uint32_t p_code) const { + + return keycode_get_string(p_code); +} +bool _OS::is_scancode_unicode(uint32_t p_unicode) const { + + return keycode_has_unicode(p_unicode); +} +int _OS::find_scancode_from_string(const String& p_code) const { + + return find_keycode(p_code); +} + _OS *_OS::singleton=NULL; void _OS::_bind_methods() { @@ -810,6 +824,9 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("native_video_stop"),&_OS::native_video_stop); ObjectTypeDB::bind_method(_MD("native_video_pause"),&_OS::native_video_pause); + ObjectTypeDB::bind_method(_MD("get_scancode_string","code"),&_OS::get_scancode_string); + ObjectTypeDB::bind_method(_MD("is_scancode_unicode","code"),&_OS::is_scancode_unicode); + ObjectTypeDB::bind_method(_MD("find_scancode_from_string","string"),&_OS::find_scancode_from_string); ObjectTypeDB::bind_method(_MD("set_use_file_access_save_and_swap","enabled"),&_OS::set_use_file_access_save_and_swap); -- cgit v1.2.3 From f220183e40cb100cdfb8158c5217076377a62980 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 18 May 2015 12:45:53 -0300 Subject: fix a crash situation when starting a thread and other small fixes --- core/bind/core_bind.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 06b71f05c0..be3ce4f44b 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1757,7 +1757,9 @@ _Mutex::~_Mutex(){ void _Thread::_start_func(void *ud) { - _Thread *t=(_Thread*)ud; + Ref<_Thread>* tud=(Ref<_Thread>*)ud; + Ref<_Thread> t=*tud; + memdelete(tud); Variant::CallError ce; const Variant* arg[1]={&t->userdata}; t->ret=t->target_instance->call(t->target_method,arg,1,ce); @@ -1804,9 +1806,11 @@ Error _Thread::start(Object *p_instance,const StringName& p_method,const Variant userdata=p_userdata; active=true; + Ref<_Thread> *ud = memnew( Ref<_Thread>(this) ); + Thread::Settings s; s.priority=(Thread::Priority)p_priority; - thread = Thread::create(_start_func,this,s); + thread = Thread::create(_start_func,ud,s); if (!thread) { active=false; target_method=StringName(); @@ -1867,5 +1871,8 @@ _Thread::_Thread() { _Thread::~_Thread() { + if (active) { + ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running..") + } ERR_FAIL_COND(active==true); } -- cgit v1.2.3 From 1e5067759420393344ce439fdea1e80e2983579a Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 19 May 2015 23:37:04 -0300 Subject: fixes on sample importing --- core/bind/core_bind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index be3ce4f44b..128bc94989 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1872,7 +1872,7 @@ _Thread::_Thread() { _Thread::~_Thread() { if (active) { - ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running..") + ERR_EXPLAIN("Reference to a Thread object object was lost while the thread is still running.."); } ERR_FAIL_COND(active==true); } -- cgit v1.2.3 From 803069886ebca492c0d5f47133ccf7833c716e5a Mon Sep 17 00:00:00 2001 From: est31 Date: Sat, 6 Jun 2015 03:40:56 +0200 Subject: Add utc param to get_time and get_date methods If utc == false, we return the local time, like before. Otherwise, we return UTC time. utc defaults to false to not break behaviour. --- core/bind/core_bind.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 128bc94989..700856ab6f 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -457,9 +457,9 @@ void _OS::set_icon(const Image& p_icon) { OS::get_singleton()->set_icon(p_icon); } -Dictionary _OS::get_date() const { +Dictionary _OS::get_date(bool utc) const { - OS::Date date = OS::get_singleton()->get_date(); + OS::Date date = OS::get_singleton()->get_date(utc); Dictionary dated; dated["year"]=date.year; dated["month"]=date.month; @@ -470,9 +470,9 @@ Dictionary _OS::get_date() const { } -Dictionary _OS::get_time() const { +Dictionary _OS::get_time(bool utc) const { - OS::Time time = OS::get_singleton()->get_time(); + OS::Time time = OS::get_singleton()->get_time(utc); Dictionary timed; timed["hour"]=time.hour; timed["minute"]=time.min; @@ -774,8 +774,8 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_cmdline_args"),&_OS::get_cmdline_args); ObjectTypeDB::bind_method(_MD("get_main_loop"),&_OS::get_main_loop); - ObjectTypeDB::bind_method(_MD("get_date"),&_OS::get_date); - ObjectTypeDB::bind_method(_MD("get_time"),&_OS::get_time); + ObjectTypeDB::bind_method(_MD("get_date","utc"),&_OS::get_date,DEFVAL(false)); + ObjectTypeDB::bind_method(_MD("get_time","utc"),&_OS::get_time,DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_unix_time"),&_OS::get_unix_time); ObjectTypeDB::bind_method(_MD("set_icon"),&_OS::set_icon); -- cgit v1.2.3 From c5338fd6c40d08472b680809cfa04d47826bdcf5 Mon Sep 17 00:00:00 2001 From: est31 Date: Sat, 6 Jun 2015 05:35:38 +0200 Subject: Add OS.get_time_zone_info function The returned dictionary maps "name" to the name of the current time zone, and "bias" to a bias from UTC in minutes. --- core/bind/core_bind.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 700856ab6f..26b1dac6f1 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -480,6 +480,15 @@ Dictionary _OS::get_time(bool utc) const { return timed; } + +Dictionary _OS::get_time_zone_info() const { + OS::TimeZoneInfo info = OS::get_singleton()->get_time_zone_info(); + Dictionary infod; + infod["bias"] = info.bias; + infod["name"] = info.name; + return infod; +} + uint64_t _OS::get_unix_time() const { return OS::get_singleton()->get_unix_time(); @@ -776,6 +785,7 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_date","utc"),&_OS::get_date,DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_time","utc"),&_OS::get_time,DEFVAL(false)); + ObjectTypeDB::bind_method(_MD("get_time_zone_info"),&_OS::get_time_zone_info); ObjectTypeDB::bind_method(_MD("get_unix_time"),&_OS::get_unix_time); ObjectTypeDB::bind_method(_MD("set_icon"),&_OS::set_icon); -- cgit v1.2.3 From 95047562d743b1c1fdc007432c8a0c145a455c5d Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Mon, 29 Jun 2015 00:29:49 -0300 Subject: Several performance improvements, mainly in loading and instancing scenes and resources. A general speedup should be apparent, with even more peformance increase when compiling optimized. WARNING: Tested and it seems to work, but if something breaks, please report. --- core/bind/core_bind.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 26b1dac6f1..120cb0000b 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1772,6 +1772,7 @@ void _Thread::_start_func(void *ud) { memdelete(tud); Variant::CallError ce; const Variant* arg[1]={&t->userdata}; + t->ret=t->target_instance->call(t->target_method,arg,1,ce); if (ce.error!=Variant::CallError::CALL_OK) { @@ -1796,6 +1797,7 @@ void _Thread::_start_func(void *ud) { default: {} } + ERR_EXPLAIN("Could not call function '"+t->target_method.operator String()+"'' starting thread ID: "+t->get_id()+" Reason: "+reason); ERR_FAIL(); } -- cgit v1.2.3 From 922356b903061cda7591090bf19e8346c3a78cf5 Mon Sep 17 00:00:00 2001 From: punto- Date: Tue, 28 Jul 2015 12:50:52 +0200 Subject: adding some base64 marshalls --- core/bind/core_bind.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'core/bind/core_bind.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 120cb0000b..95cafdb36d 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -1678,12 +1678,89 @@ Variant _Marshalls::base64_to_variant(const String& p_str) { return v; }; +String _Marshalls::raw_to_base64(const DVector &p_arr) { + + int len = p_arr.size(); + DVector::Read r = p_arr.read(); + + int b64len = len / 3 * 4 + 4 + 1; + DVector b64buff; + b64buff.resize(b64len); + DVector::Write w64 = b64buff.write(); + + int strlen = base64_encode((char*)(&w64[0]), (char*)(&r[0]), len); + w64[strlen] = 0; + String ret = (char*)&w64[0]; + + return ret; +}; + +DVector _Marshalls::base64_to_raw(const String &p_str) { + + int strlen = p_str.length(); + CharString cstr = p_str.ascii(); + + int arr_len; + DVector buf; + { + buf.resize(strlen / 4 * 3 + 1); + DVector::Write w = buf.write(); + + arr_len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen); + }; + buf.resize(arr_len); + + // conversion from DVector to raw array? + return buf; +}; + +String _Marshalls::utf8_to_base64(const String& p_str) { + + CharString cstr = p_str.utf8(); + int len = cstr.length(); + + int b64len = len / 3 * 4 + 4 + 1; + DVector b64buff; + b64buff.resize(b64len); + DVector::Write w64 = b64buff.write(); + + int strlen = base64_encode((char*)(&w64[0]), (char*)cstr.get_data(), len); + + w64[strlen] = 0; + String ret = (char*)&w64[0]; + + return ret; +}; + +String _Marshalls::base64_to_utf8(const String& p_str) { + + int strlen = p_str.length(); + CharString cstr = p_str.ascii(); + + DVector buf; + buf.resize(strlen / 4 * 3 + 1 + 1); + DVector::Write w = buf.write(); + + int len = base64_decode((char*)(&w[0]), (char*)cstr.get_data(), strlen); + + w[len] = 0; + String ret = String::utf8((char*)&w[0]); + + return ret; +}; + void _Marshalls::_bind_methods() { ObjectTypeDB::bind_method(_MD("variant_to_base64:String","variant"),&_Marshalls::variant_to_base64); ObjectTypeDB::bind_method(_MD("base64_to_variant:Variant","base64_str"),&_Marshalls::base64_to_variant); + ObjectTypeDB::bind_method(_MD("raw_to_base64:String","array"),&_Marshalls::raw_to_base64); + ObjectTypeDB::bind_method(_MD("base64_to_raw:RawArray","base64_str"),&_Marshalls::base64_to_raw); + + ObjectTypeDB::bind_method(_MD("utf8_to_base64:String","utf8_str"),&_Marshalls::utf8_to_base64); + ObjectTypeDB::bind_method(_MD("base64_to_utf8:String","base64_str"),&_Marshalls::base64_to_utf8); + }; -- cgit v1.2.3