diff options
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/file_access.cpp | 2 | ||||
-rw-r--r-- | core/os/file_access.h | 1 | ||||
-rw-r--r-- | core/os/os.cpp | 49 | ||||
-rw-r--r-- | core/os/os.h | 30 |
4 files changed, 51 insertions, 31 deletions
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index b969b58bfb..fcb3b58fed 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -55,7 +55,7 @@ FileAccess *FileAccess::create(AccessType p_access) { bool FileAccess::exists(const String &p_name) { - if (PackedData::get_singleton()->has_path(p_name)) + if (PackedData::get_singleton() && PackedData::get_singleton()->has_path(p_name)) return true; FileAccess *f = open(p_name, READ); diff --git a/core/os/file_access.h b/core/os/file_access.h index 34e7549fa3..455dd1ea99 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -119,6 +119,7 @@ public: virtual Error get_error() const = 0; ///< get last error + virtual void flush() = 0; virtual void store_8(uint8_t p_dest) = 0; ///< store a byte virtual void store_16(uint16_t p_dest); ///< store 16 bits uint virtual void store_32(uint32_t p_dest); ///< store 32 bits uint diff --git a/core/os/os.cpp b/core/os/os.cpp index 437ce01a5e..eb5d5be33d 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -62,20 +62,20 @@ void OS::debug_break(){ // something }; -void OS::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type) { - - const char *err_type = "**ERROR**"; - switch (p_type) { - case ERR_ERROR: err_type = "**ERROR**"; break; - case ERR_WARNING: err_type = "**WARNING**"; break; - case ERR_SCRIPT: err_type = "**SCRIPT ERROR**"; break; - case ERR_SHADER: err_type = "**SHADER ERROR**"; break; - default: ERR_PRINT("Unknown error type"); break; +void OS::_set_logger(Logger *p_logger) { + if (_logger) { + memdelete(_logger); } + _logger = p_logger; +} + +void OS::initialize_logger() { + _set_logger(memnew(StdLogger)); +} + +void OS::print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, Logger::ErrorType p_type) { - if (p_rationale && *p_rationale) - print("%s: %s\n ", err_type, p_rationale); - print("%s: At: %s:%i:%s() - %s\n", err_type, p_file, p_line, p_function, p_code); + _logger->log_error(p_function, p_file, p_line, p_code, p_rationale, p_type); } void OS::print(const char *p_format, ...) { @@ -83,17 +83,16 @@ void OS::print(const char *p_format, ...) { va_list argp; va_start(argp, p_format); - vprint(p_format, argp); + _logger->logv(p_format, argp, false); va_end(argp); }; void OS::printerr(const char *p_format, ...) { - va_list argp; va_start(argp, p_format); - vprint(p_format, argp, true); + _logger->logv(p_format, argp, true); va_end(argp); }; @@ -194,6 +193,10 @@ void OS::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_scr void OS::hide_virtual_keyboard() { } +int OS::get_virtual_keyboard_height() const { + return 0; +} + void OS::print_all_resources(String p_to_file) { ERR_FAIL_COND(p_to_file != "" && _OSPRF); @@ -495,7 +498,7 @@ int OS::get_power_percent_left() { return -1; } -bool OS::check_feature_support(const String &p_feature) { +bool OS::has_feature(const String &p_feature) { if (p_feature == get_name()) return true; @@ -507,6 +510,13 @@ bool OS::check_feature_support(const String &p_feature) { return true; #endif + if (sizeof(void *) == 8 && p_feature == "64") { + return true; + } + if (sizeof(void *) == 4 && p_feature == "32") { + return true; + } + if (_check_internal_feature_support(p_feature)) return true; @@ -531,11 +541,14 @@ OS::OS() { _render_thread_mode = RENDER_THREAD_SAFE; - _allow_hidpi = true; + _allow_hidpi = false; _stack_bottom = (void *)(&stack_bottom); + + _logger = NULL; + _set_logger(memnew(StdLogger)); } OS::~OS() { - + memdelete(_logger); singleton = NULL; } diff --git a/core/os/os.h b/core/os/os.h index 38bbbc0a57..6fcfd71332 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -32,6 +32,7 @@ #include "engine.h" #include "image.h" +#include "io/logger.h" #include "list.h" #include "os/main_loop.h" #include "ustring.h" @@ -61,6 +62,11 @@ class OS { void *_stack_bottom; + Logger *_logger; + +protected: + void _set_logger(Logger *p_logger); + public: typedef void (*ImeCallback)(void *p_inp, String p_text, Point2 p_selection); @@ -108,6 +114,7 @@ protected: virtual int get_audio_driver_count() const = 0; virtual const char *get_audio_driver_name(int p_driver) const = 0; + virtual void initialize_logger(); virtual void initialize_core() = 0; virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) = 0; @@ -127,18 +134,10 @@ public: static OS *get_singleton(); - enum ErrorType { - ERR_ERROR, - ERR_WARNING, - ERR_SCRIPT, - ERR_SHADER - }; - - virtual void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR); + void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, Logger::ErrorType p_type = Logger::ERR_ERROR); + void print(const char *p_format, ...); + void printerr(const char *p_format, ...); - virtual void print(const char *p_format, ...); - virtual void printerr(const char *p_format, ...); - virtual void vprint(const char *p_format, va_list p_list, bool p_stderr = false) = 0; virtual void alert(const String &p_alert, const String &p_title = "ALERT!") = 0; virtual String get_stdin_string(bool p_block = true) = 0; @@ -284,6 +283,8 @@ public: virtual bool can_draw() const = 0; + virtual bool is_userfs_persistent() const { return true; } + bool is_stdout_verbose() const; virtual void disable_crash_handler() {} @@ -314,6 +315,9 @@ public: virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2()); virtual void hide_virtual_keyboard(); + // returns height of the currently shown virtual keyboard (0 if keyboard is hidden) + virtual int get_virtual_keyboard_height() const; + virtual void set_cursor_shape(CursorShape p_shape) = 0; virtual bool get_swap_ok_cancel() { return false; } @@ -335,6 +339,8 @@ public: virtual String get_data_dir() const; virtual String get_resource_dir() const; + virtual Error move_to_trash(const String &p_path) { return FAILED; } + enum SystemDir { SYSTEM_DIR_DESKTOP, SYSTEM_DIR_DCIM, @@ -424,7 +430,7 @@ public: virtual int get_power_seconds_left(); virtual int get_power_percent_left(); - bool check_feature_support(const String &p_feature); + bool has_feature(const String &p_feature); /** * Returns the stack bottom of the main thread of the application. |