From fdaa2920eb21fff3320a17e9239e04dfadecdb00 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sat, 18 Apr 2015 14:38:54 -0300 Subject: Updated copyright year in all headers --- drivers/unix/os_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/unix/os_unix.cpp') diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index d51a7c74e..d558aadc8 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ -- cgit v1.2.3-70-g09d2 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 ++++++------ core/bind/core_bind.h | 4 ++-- core/os/os.h | 4 ++-- drivers/unix/os_unix.cpp | 17 ++++++++++++----- drivers/unix/os_unix.h | 4 ++-- platform/nacl/os_nacl.cpp | 16 ++++++++++++---- platform/nacl/os_nacl.h | 4 ++-- platform/windows/os_windows.cpp | 14 ++++++++++---- platform/windows/os_windows.h | 4 ++-- platform/winrt/os_winrt.cpp | 14 ++++++++++---- platform/winrt/os_winrt.h | 4 ++-- 11 files changed, 62 insertions(+), 35 deletions(-) (limited to 'drivers/unix/os_unix.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 128bc9498..700856ab6 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); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 05f54dd64..2400ba3fd 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -204,8 +204,8 @@ public: void set_use_file_access_save_and_swap(bool p_enable); void set_icon(const Image& p_icon); - Dictionary get_date() const; - Dictionary get_time() const; + Dictionary get_date(bool utc) const; + Dictionary get_time(bool utc) const; uint64_t get_unix_time() const; int get_static_memory_usage() const; diff --git a/core/os/os.h b/core/os/os.h index 2f9957c2f..75a0a4eea 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -245,8 +245,8 @@ public: int sec; }; - virtual Date get_date() const=0; - virtual Time get_time() const=0; + virtual Date get_date(bool local=false) const=0; + virtual Time get_time(bool local=false) const=0; virtual uint64_t get_unix_time() const; virtual void delay_usec(uint32_t p_usec) const=0; diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index d558aadc8..afb85e49e 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -218,10 +218,14 @@ uint64_t OS_Unix::get_unix_time() const { }; -OS::Date OS_Unix::get_date() const { +OS::Date OS_Unix::get_date(bool utc) const { time_t t=time(NULL); - struct tm *lt=localtime(&t); + struct tm *lt; + if (utc) + lt=gmtime(&t); + else + lt=localtime(&t); Date ret; ret.year=1900+lt->tm_year; ret.month=(Month)lt->tm_mon; @@ -231,10 +235,13 @@ OS::Date OS_Unix::get_date() const { return ret; } -OS::Time OS_Unix::get_time() const { - +OS::Time OS_Unix::get_time(bool utc) const { time_t t=time(NULL); - struct tm *lt=localtime(&t); + struct tm *lt; + if (utc) + lt=gmtime(&t); + else + lt=localtime(&t); Time ret; ret.hour=lt->tm_hour; ret.min=lt->tm_min; diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 65df11395..bafa590d5 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -88,8 +88,8 @@ public: virtual String get_name(); - virtual Date get_date() const; - virtual Time get_time() const; + virtual Date get_date(bool utc) const; + virtual Time get_time(bool utc) const; virtual uint64_t get_unix_time() const; diff --git a/platform/nacl/os_nacl.cpp b/platform/nacl/os_nacl.cpp index ffa991525..ecace5880 100644 --- a/platform/nacl/os_nacl.cpp +++ b/platform/nacl/os_nacl.cpp @@ -240,10 +240,14 @@ MainLoop *OSNacl::get_main_loop() const { return main_loop; }; -OS::Date OSNacl::get_date() const { +OS::Date OSNacl::get_date(bool utc) const { time_t t=time(NULL); - struct tm *lt=localtime(&t); + struct tm *lt; + if (utc) + lt=gmtime(&t); + else + lt=localtime(&t); Date ret; ret.year=lt->tm_year; ret.month=(Month)lt->tm_mon; @@ -254,10 +258,14 @@ OS::Date OSNacl::get_date() const { return ret; }; -OS::Time OSNacl::get_time() const { +OS::Time OSNacl::get_time(bool utc) const { time_t t=time(NULL); - struct tm *lt=localtime(&t); + struct tm *lt; + if (utc) + lt=gmtime(&t); + else + lt=localtime(&t); Time ret; ret.hour=lt->tm_hour; ret.min=lt->tm_min; diff --git a/platform/nacl/os_nacl.h b/platform/nacl/os_nacl.h index 1150b12ed..e033abb68 100644 --- a/platform/nacl/os_nacl.h +++ b/platform/nacl/os_nacl.h @@ -137,8 +137,8 @@ public: virtual MainLoop *get_main_loop() const; - virtual Date get_date() const; - virtual Time get_time() const; + virtual Date get_date(bool utc) const; + virtual Time get_time(bool utc) const; virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 4bf4fea84..16b9e9b32 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1832,7 +1832,10 @@ String OS_Windows::get_name() { OS::Date OS_Windows::get_date() const { SYSTEMTIME systemtime; - GetLocalTime(&systemtime); + if (local) + GetSystemTime(&systemtime); + else + GetLocalTime(&systemtime); Date date; date.day=systemtime.wDay; date.month=Month(systemtime.wMonth); @@ -1841,10 +1844,13 @@ OS::Date OS_Windows::get_date() const { date.dst=false; return date; } -OS::Time OS_Windows::get_time() const { +OS::Time OS_Windows::get_time(bool utc) const { SYSTEMTIME systemtime; - GetLocalTime(&systemtime); + if (utc) + GetSystemTime(&systemtime); + else + GetLocalTime(&systemtime); Time time; time.hour=systemtime.wHour; @@ -1853,7 +1859,7 @@ OS::Time OS_Windows::get_time() const { return time; } -uint64_t OS_Windows::get_unix_time() const { +uint64_t OS_Windows::get_unix_time(bool local) const { FILETIME ft; SYSTEMTIME st; diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index 64fbbf23c..6b2eb19a7 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -259,8 +259,8 @@ public: virtual String get_name(); - virtual Date get_date() const; - virtual Time get_time() const; + virtual Date get_date(bool utc) const; + virtual Time get_time(bool utc) const; virtual uint64_t get_unix_time() const; virtual bool can_draw() const; diff --git a/platform/winrt/os_winrt.cpp b/platform/winrt/os_winrt.cpp index 74909c6dd..a84e54ee0 100644 --- a/platform/winrt/os_winrt.cpp +++ b/platform/winrt/os_winrt.cpp @@ -454,10 +454,13 @@ OS::Date OSWinrt::get_date() const { date.dst=false; return date; } -OS::Time OSWinrt::get_time() const { +OS::Time OSWinrt::get_time(bool utc) const { SYSTEMTIME systemtime; - GetLocalTime(&systemtime); + if (utc) + GetSystemTime(&systemtime); + else + GetLocalTime(&systemtime); Time time; time.hour=systemtime.wHour; @@ -466,11 +469,14 @@ OS::Time OSWinrt::get_time() const { return time; } -uint64_t OSWinrt::get_unix_time() const { +uint64_t OSWinrt::get_unix_time(bool utc) const { FILETIME ft; SYSTEMTIME st; - GetSystemTime(&st); + if (utc) + GetSystemTime(&systemtime); + else + GetLocalTime(&systemtime); SystemTimeToFileTime(&st, &ft); SYSTEMTIME ep; diff --git a/platform/winrt/os_winrt.h b/platform/winrt/os_winrt.h index 68236309a..af44bd338 100644 --- a/platform/winrt/os_winrt.h +++ b/platform/winrt/os_winrt.h @@ -198,8 +198,8 @@ public: virtual String get_name(); - virtual Date get_date() const; - virtual Time get_time() const; + virtual Date get_date(bool utc) const; + virtual Time get_time(bool utc) const; virtual uint64_t get_unix_time() const; virtual bool can_draw() const; -- cgit v1.2.3-70-g09d2 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 ++++++++++ core/bind/core_bind.h | 1 + core/os/os.h | 8 +++++++- drivers/unix/os_unix.cpp | 29 ++++++++++++++++++++++++++++- drivers/unix/os_unix.h | 1 + platform/nacl/os_nacl.cpp | 26 ++++++++++++++++++++++++++ platform/windows/os_windows.cpp | 30 ++++++++++++++++++++++++++++++ platform/winrt/os_winrt.cpp | 16 ++++++++++++++++ 8 files changed, 119 insertions(+), 2 deletions(-) (limited to 'drivers/unix/os_unix.cpp') diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 700856ab6..26b1dac6f 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); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 2400ba3fd..74f29c23e 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -206,6 +206,7 @@ public: void set_icon(const Image& p_icon); Dictionary get_date(bool utc) const; Dictionary get_time(bool utc) const; + Dictionary get_time_zone_info() const; uint64_t get_unix_time() const; int get_static_memory_usage() const; diff --git a/core/os/os.h b/core/os/os.h index 75a0a4eea..0230a75ca 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -244,9 +244,15 @@ public: int min; int sec; }; - + + struct TimeZoneInfo { + int bias; + String name; + }; + virtual Date get_date(bool local=false) const=0; virtual Time get_time(bool local=false) const=0; + virtual TimeZoneInfo get_time_zone_info() const=0; virtual uint64_t get_unix_time() const; virtual void delay_usec(uint32_t p_usec) const=0; diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index afb85e49e..8ba56490d 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -246,9 +246,36 @@ OS::Time OS_Unix::get_time(bool utc) const { ret.hour=lt->tm_hour; ret.min=lt->tm_min; ret.sec=lt->tm_sec; + get_time_zone_info(); return ret; } - + +OS::TimeZoneInfo OS_Unix::get_time_zone_info() const { + time_t t = time(NULL); + struct tm *lt = localtime(&t); + char name[16]; + strftime(name, 16, "%Z", lt); + name[15] = 0; + TimeZoneInfo ret; + ret.name = name; + + char bias_buf[16]; + strftime(bias_buf, 16, "%z", lt); + int bias; + bias_buf[15] = 0; + sscanf(bias_buf, "%d", &bias); + + // convert from ISO 8601 (1 minute=1, 1 hour=100) to minutes + int hour = (int)bias / 100; + int minutes = bias % 100; + if (bias < 0) + ret.bias = hour * 60 - minutes; + else + ret.bias = hour * 60 + minutes; + + return ret; +} + void OS_Unix::delay_usec(uint32_t p_usec) const { usleep(p_usec); diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index bafa590d5..8bb57eda1 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -90,6 +90,7 @@ public: virtual Date get_date(bool utc) const; virtual Time get_time(bool utc) const; + virtual TimeZoneInfo get_time_zone_info() const; virtual uint64_t get_unix_time() const; diff --git a/platform/nacl/os_nacl.cpp b/platform/nacl/os_nacl.cpp index ecace5880..b282209d7 100644 --- a/platform/nacl/os_nacl.cpp +++ b/platform/nacl/os_nacl.cpp @@ -273,6 +273,32 @@ OS::Time OSNacl::get_time(bool utc) const { return ret; }; +OS::TimeZoneInfo OS_Unix::get_time_zone_info() const { + time_t t = time(NULL); + struct tm *lt = localtime(&t); + char name[16]; + strftime(name, 16, "%Z", lt); + name[15] = 0; + TimeZoneInfo ret; + ret.name = name; + + char bias_buf[16]; + strftime(bias_buf, 16, "%z", lt); + int bias; + bias_buf[15] = 0; + sscanf(bias_buf, "%d", &bias); + + // convert from ISO 8601 (1 minute=1, 1 hour=100) to minutes + int hour = (int)bias / 100; + int minutes = bias % 100; + if (bias < 0) + ret.bias = hour * 60 - minutes; + else + ret.bias = hour * 60 + minutes; + + return ret; +}; + void OSNacl::delay_usec(uint32_t p_usec) const { //usleep(p_usec); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 16b9e9b32..cdf9b007d 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -1858,6 +1858,36 @@ OS::Time OS_Windows::get_time(bool utc) const { time.sec=systemtime.wSecond; return time; } +OS::Time OS_Windows::get_time(bool utc) const { + + SYSTEMTIME systemtime; + if (utc) + GetSystemTime(&systemtime); + else + GetLocalTime(&systemtime); + + Time time; + time.hour=systemtime.wHour; + time.min=systemtime.wMinute; + time.sec=systemtime.wSecond; + return time; +} + +OS::TimeZoneInfo OS_Windows::get_time_zone_info() const { + TIME_ZONE_INFORMATION info; + bool daylight = false; + if (GetTimeZoneInformation(info) == TIME_ZONE_ID_DAYLIGHT) + daylight = true; + + if (daylight) { + ret.name = info.DaylightName; + } else { + ret.name = info.StandardName; + } + + ret.bias = info.Bias; + return ret; +} uint64_t OS_Windows::get_unix_time(bool local) const { diff --git a/platform/winrt/os_winrt.cpp b/platform/winrt/os_winrt.cpp index a84e54ee0..24037f05d 100644 --- a/platform/winrt/os_winrt.cpp +++ b/platform/winrt/os_winrt.cpp @@ -469,6 +469,22 @@ OS::Time OSWinrt::get_time(bool utc) const { return time; } +OS::TimeZoneInfo OS_Windows::get_time_zone_info() const { + TIME_ZONE_INFORMATION info; + bool daylight = false; + if (GetTimeZoneInformation(info) == TIME_ZONE_ID_DAYLIGHT) + daylight = true; + + if (daylight) { + ret.name = info.DaylightName; + } else { + ret.name = info.StandardName; + } + + ret.bias = info.Bias; + return ret; +} + uint64_t OSWinrt::get_unix_time(bool utc) const { FILETIME ft; -- cgit v1.2.3-70-g09d2 From 55b34e05b3d735a84e1af9833e19c0b816c18252 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 30 Jun 2015 11:28:43 -0300 Subject: -some changes by okam --- core/globals.cpp | 9 +++++++++ core/globals.h | 1 + core/io/file_access_encrypted.cpp | 4 +++- core/print_string.cpp | 1 + core/print_string.h | 1 + drivers/speex/audio_stream_speex.cpp | 2 +- drivers/unix/os_unix.cpp | 6 ++++++ main/main.cpp | 3 +++ modules/gdscript/gd_script.cpp | 8 ++++++++ modules/gdscript/gd_script.h | 2 ++ platform/iphone/app_delegate.mm | 23 +++++++++++++++++++++++ scene/resources/animation.cpp | 16 +++++++++++++--- scene/resources/animation.h | 2 +- 13 files changed, 72 insertions(+), 6 deletions(-) (limited to 'drivers/unix/os_unix.cpp') diff --git a/core/globals.cpp b/core/globals.cpp index 062adc21f..731c5b7df 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -1149,6 +1149,12 @@ Error Globals::_save_settings_text(const String& p_file,const Map& p_ignore_masks) { ERR_FAIL_COND_V(p_path=="",ERR_INVALID_PARAMETER); @@ -1361,6 +1367,9 @@ void Globals::_bind_methods() { ObjectTypeDB::bind_method(_MD("has_singleton"),&Globals::has_singleton); ObjectTypeDB::bind_method(_MD("get_singleton"),&Globals::get_singleton_object); ObjectTypeDB::bind_method(_MD("load_resource_pack"),&Globals::_load_resource_pack); + + ObjectTypeDB::bind_method(_MD("save_custom"),&Globals::_save_custom_bnd); + } Globals::Globals() { diff --git a/core/globals.h b/core/globals.h index f739bcfb9..2ec56966f 100644 --- a/core/globals.h +++ b/core/globals.h @@ -86,6 +86,7 @@ protected: List singletons; + Error _save_custom_bnd(const String& p_file); bool _load_resource_pack(const String& p_pack); diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index 29f27dcbd..65b1ca520 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -5,10 +5,12 @@ #include "print_string.h" #define COMP_MAGIC 0x43454447 +#include "core/variant.h" +#include Error FileAccessEncrypted::open_and_parse(FileAccess *p_base,const Vector& p_key,Mode p_mode) { - print_line("open and parse!"); + //print_line("open and parse!"); ERR_FAIL_COND_V(file!=NULL,ERR_ALREADY_IN_USE); ERR_FAIL_COND_V(p_key.size()!=32,ERR_INVALID_PARAMETER); diff --git a/core/print_string.cpp b/core/print_string.cpp index a06d4de23..42e018f30 100644 --- a/core/print_string.cpp +++ b/core/print_string.cpp @@ -32,6 +32,7 @@ static PrintHandlerList *print_handler_list=NULL; bool _print_line_enabled=true; +bool _print_error_enabled = true; void add_print_handler(PrintHandlerList *p_handler) { diff --git a/core/print_string.h b/core/print_string.h index 854f8ec2e..4ea389b3a 100644 --- a/core/print_string.h +++ b/core/print_string.h @@ -52,6 +52,7 @@ void add_print_handler(PrintHandlerList *p_handler); void remove_print_handler(PrintHandlerList *p_handler); extern bool _print_line_enabled; +extern bool _print_error_enabled; extern void print_line(String p_string); #endif diff --git a/drivers/speex/audio_stream_speex.cpp b/drivers/speex/audio_stream_speex.cpp index a6bac78b4..bcf4c515f 100644 --- a/drivers/speex/audio_stream_speex.cpp +++ b/drivers/speex/audio_stream_speex.cpp @@ -21,7 +21,7 @@ void AudioStreamSpeex::update() { //printf("update, loops %i, read ofs %i\n", (int)loops, read_ofs); //printf("playing %i, paused %i\n", (int)playing, (int)paused); - if (!playing || paused || !data.size()) + if (!active || !playing || paused || !data.size()) return; /* diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 8ba56490d..f6d9e0fb4 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -57,8 +57,14 @@ #include #include #include "globals.h" + +extern bool _print_error_enabled; + void OS_Unix::print_error(const char* p_function,const char* p_file,int p_line,const char *p_code,const char*p_rationale,ErrorType p_type) { + if (!_print_error_enabled) + return; + if (p_rationale && p_rationale[0]) { print("\E[1;31;40mERROR: %s: \E[1;37;40m%s\n",p_function,p_rationale); diff --git a/main/main.cpp b/main/main.cpp index f68bde003..4cf4f3c7c 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -605,6 +605,9 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (bool(Globals::get_singleton()->get("application/disable_stdout"))) { quiet_stdout=true; } + if (bool(Globals::get_singleton()->get("application/disable_stderr"))) { + _print_error_enabled = false; + }; if (quiet_stdout) _print_line_enabled=false; diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp index 63bb44784..53ae0c870 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gd_script.cpp @@ -1977,9 +1977,17 @@ void GDScript::_bind_methods() { ObjectTypeDB::bind_native_method(METHOD_FLAGS_DEFAULT,"new",&GDScript::_new,MethodInfo("new")); + ObjectTypeDB::bind_method(_MD("get_as_byte_code"),&GDScript::get_as_byte_code); + } +Vector GDScript::get_as_byte_code() const { + + GDTokenizerBuffer tokenizer; + return tokenizer.parse_code_string(source); +}; + Error GDScript::load_byte_code(const String& p_path) { diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h index 4672f3b8b..1e1279d5f 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gd_script.h @@ -349,6 +349,8 @@ public: Error load_source_code(const String& p_path); Error load_byte_code(const String& p_path); + Vector get_as_byte_code() const; + virtual ScriptLanguage *get_language() const; GDScript(); diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 2c7a0a079..dba37ab1b 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -138,6 +138,29 @@ static int frame_count = 0; Main::setup2(); ++frame_count; + // this might be necessary before here + for (NSString* key in [[NSBundle mainBundle] infoDictionary]) { + NSObject* value = [xyz objectForKey:key]; + String ukey = String::utf8([key UTF8String]); + + // we need a NSObject to Variant conversor + + if ([value isKindOfClass:[NSString class]]) { + NSString* str = (NSString*)value; + String uval = String::utf8([str UTF8String]); + + Globals::get_singleton()->set("Info.plist/"+ukey, uval); + + } else if ([value isKindOfClass:[NSNumber class]]) { + + NSNumber* n = (NSNumber*)value; + double dval = [n doubleValue]; + + Globals::get_singleton()->set("Info.plist/"+ukey, dval); + }; + // do stuff + } + } break; /* case 3: { diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 9d668a571..afd4dc530 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1718,7 +1718,7 @@ void Animation::clear() { -bool Animation::_transform_track_optimize_key(const TKey &t0,const TKey &t1, const TKey &t2, float p_alowed_linear_err,float p_alowed_angular_err,float p_max_optimizable_angle) { +bool Animation::_transform_track_optimize_key(const TKey &t0,const TKey &t1, const TKey &t2, float p_alowed_linear_err,float p_alowed_angular_err,float p_max_optimizable_angle,const Vector3& p_norm) { real_t c = (t1.time-t0.time)/(t2.time-t0.time); @@ -1754,6 +1754,9 @@ bool Animation::_transform_track_optimize_key(const TKey &t0,const return false; //beyond allowed error for colinearity } + if (p_norm!=Vector3() && Math::acos(pd.normalized().dot(p_norm))>p_alowed_angular_err) + return false; + t[0] = (d1-d0)/(d2-d0); } } @@ -1905,16 +1908,21 @@ void Animation::_transform_track_optimize(int p_idx,float p_alowed_linear_err,fl bool prev_erased=false; TKey first_erased; + Vector3 norm; + for(int i=1;itransforms.size()-1;i++) { TKey &t0 = tt->transforms[i-1]; TKey &t1 = tt->transforms[i]; TKey &t2 = tt->transforms[i+1]; - bool erase = _transform_track_optimize_key(t0,t1,t2,p_alowed_linear_err,p_alowed_angular_err,p_max_optimizable_angle); + bool erase = _transform_track_optimize_key(t0,t1,t2,p_alowed_linear_err,p_alowed_angular_err,p_max_optimizable_angle,norm); + if (erase && !prev_erased) { + norm=(t2.value.loc-t1.value.loc).normalized(); + } - if (prev_erased && !_transform_track_optimize_key(t0,first_erased,t2,p_alowed_linear_err,p_alowed_angular_err,p_max_optimizable_angle)) { + if (prev_erased && !_transform_track_optimize_key(t0,first_erased,t2,p_alowed_linear_err,p_alowed_angular_err,p_max_optimizable_angle,norm)) { //avoid error to go beyond first erased key erase=false; } @@ -1932,9 +1940,11 @@ void Animation::_transform_track_optimize(int p_idx,float p_alowed_linear_err,fl } else { prev_erased=false; + norm=Vector3(); } + // print_line(itos(i)+" could be eliminated: "+rtos(tr)); //} } diff --git a/scene/resources/animation.h b/scene/resources/animation.h index d4042646f..256826a4b 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -204,7 +204,7 @@ private: return idxr; } - bool _transform_track_optimize_key(const TKey &t0,const TKey &t1, const TKey &t2, float p_alowed_linear_err,float p_alowed_angular_err,float p_max_optimizable_angle); + bool _transform_track_optimize_key(const TKey &t0,const TKey &t1, const TKey &t2, float p_alowed_linear_err,float p_alowed_angular_err,float p_max_optimizable_angle,const Vector3& p_norm); void _transform_track_optimize(int p_idx, float p_allowed_err=0.05, float p_alowed_angular_err=0.01,float p_max_optimizable_angle=Math_PI*0.125); protected: -- cgit v1.2.3-70-g09d2