diff options
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/dir_access.cpp | 101 | ||||
-rw-r--r-- | core/os/dir_access.h | 4 | ||||
-rw-r--r-- | core/os/file_access.cpp | 4 | ||||
-rw-r--r-- | core/os/input_event.cpp | 122 | ||||
-rw-r--r-- | core/os/input_event.h | 49 | ||||
-rw-r--r-- | core/os/keyboard.cpp | 43 | ||||
-rw-r--r-- | core/os/keyboard.h | 1 | ||||
-rw-r--r-- | core/os/memory.cpp | 20 | ||||
-rw-r--r-- | core/os/memory.h | 8 | ||||
-rw-r--r-- | core/os/os.cpp | 121 | ||||
-rw-r--r-- | core/os/os.h | 35 |
11 files changed, 454 insertions, 54 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 0875f78478..6d4b46f4da 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -38,7 +38,7 @@ String DirAccess::_get_root_path() const { switch (_access_type) { case ACCESS_RESOURCES: return ProjectSettings::get_singleton()->get_resource_path(); - case ACCESS_USERDATA: return OS::get_singleton()->get_data_dir(); + case ACCESS_USERDATA: return OS::get_singleton()->get_user_data_dir(); default: return ""; } @@ -98,6 +98,7 @@ static Error _erase_recursive(DirAccess *da) { err = _erase_recursive(da); if (err) { print_line("err recurso " + E->get()); + da->change_dir(".."); return err; } err = da->change_dir(".."); @@ -217,7 +218,7 @@ String DirAccess::fix_path(String p_path) const { if (p_path.begins_with("user://")) { - String data_dir = OS::get_singleton()->get_data_dir(); + String data_dir = OS::get_singleton()->get_user_data_dir(); if (data_dir != "") { return p_path.replace_first("user:/", data_dir); @@ -340,6 +341,102 @@ Error DirAccess::copy(String p_from, String p_to, int chmod_flags) { return err; } +// Changes dir for the current scope, returning back to the original dir +// when scope exits +class DirChanger { + DirAccess *da; + String original_dir; + +public: + DirChanger(DirAccess *p_da, String p_dir) { + da = p_da; + original_dir = p_da->get_current_dir(); + p_da->change_dir(p_dir); + } + + ~DirChanger() { + da->change_dir(original_dir); + } +}; + +Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags) { + List<String> dirs; + + String curdir = get_current_dir(); + list_dir_begin(); + String n = get_next(); + while (n != String()) { + + if (n != "." && n != "..") { + + if (current_is_dir()) + dirs.push_back(n); + else { + String rel_path = n; + if (!n.is_rel_path()) { + list_dir_end(); + return ERR_BUG; + } + Error err = copy(get_current_dir() + "/" + n, p_to + rel_path, p_chmod_flags); + if (err) { + list_dir_end(); + return err; + } + } + } + + n = get_next(); + } + + list_dir_end(); + + for (List<String>::Element *E = dirs.front(); E; E = E->next()) { + String rel_path = E->get(); + String target_dir = p_to + rel_path; + if (!p_target_da->dir_exists(target_dir)) { + Error err = p_target_da->make_dir(target_dir); + ERR_FAIL_COND_V(err, err); + } + + Error err = change_dir(E->get()); + ERR_FAIL_COND_V(err, err); + err = _copy_dir(p_target_da, p_to + rel_path + "/", p_chmod_flags); + if (err) { + change_dir(".."); + ERR_PRINT("Failed to copy recursively"); + return err; + } + err = change_dir(".."); + if (err) { + ERR_PRINT("Failed to go back"); + return err; + } + } + + return OK; +} + +Error DirAccess::copy_dir(String p_from, String p_to, int p_chmod_flags) { + ERR_FAIL_COND_V(!dir_exists(p_from), ERR_FILE_NOT_FOUND); + + DirAccess *target_da = DirAccess::create_for_path(p_to); + ERR_FAIL_COND_V(!target_da, ERR_CANT_CREATE); + + if (!target_da->dir_exists(p_to)) { + Error err = target_da->make_dir_recursive(p_to); + if (err) { + memdelete(target_da); + } + ERR_FAIL_COND_V(err, err); + } + + DirChanger dir_changer(this, p_from); + Error err = _copy_dir(target_da, p_to + "/", p_chmod_flags); + memdelete(target_da); + + return err; +} + bool DirAccess::exists(String p_dir) { DirAccess *da = DirAccess::create_for_path(p_dir); diff --git a/core/os/dir_access.h b/core/os/dir_access.h index 7fa3ce5cf1..f3d1320041 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -52,6 +52,9 @@ public: private: AccessType _access_type; static CreateFunc create_func[ACCESS_MAX]; ///< set this to instance a filesystem object + + Error _copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flags); + protected: String _get_root_path() const; String _get_root_string() const; @@ -89,6 +92,7 @@ public: static bool exists(String p_dir); virtual size_t get_space_left() = 0; + Error copy_dir(String p_from, String p_to, int chmod_flags = -1); virtual Error copy(String p_from, String p_to, int chmod_flags = -1); virtual Error rename(String p_from, String p_to) = 0; virtual Error remove(String p_name) = 0; diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index fcb3b58fed..7b2062936b 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -152,7 +152,7 @@ String FileAccess::fix_path(const String &p_path) const { if (r_path.begins_with("user://")) { - String data_dir = OS::get_singleton()->get_data_dir(); + String data_dir = OS::get_singleton()->get_user_data_dir(); if (data_dir != "") { return r_path.replace("user:/", data_dir); @@ -481,7 +481,7 @@ Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path) { ERR_FAIL_COND_V(!f, Vector<uint8_t>()); Vector<uint8_t> data; data.resize(f->get_len()); - f->get_buffer(data.ptr(), data.size()); + f->get_buffer(data.ptrw(), data.size()); memdelete(f); return data; } diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index 6b43f2c63b..9b2bd30868 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -177,6 +177,14 @@ bool InputEventWithModifiers::get_command() const { return command; } +void InputEventWithModifiers::set_modifiers_from_event(const InputEventWithModifiers *event) { + + set_alt(event->get_alt()); + set_shift(event->get_shift()); + set_control(event->get_control()); + set_metakey(event->get_metakey()); +} + void InputEventWithModifiers::_bind_methods() { ClassDB::bind_method(D_METHOD("set_alt", "enable"), &InputEventWithModifiers::set_alt); @@ -270,16 +278,16 @@ String InputEventKey::as_text() const { return kc; if (get_metakey()) { - kc = "Meta+" + kc; + kc = find_keycode_name(KEY_META) + ("+" + kc); } if (get_alt()) { - kc = "Alt+" + kc; + kc = find_keycode_name(KEY_ALT) + ("+" + kc); } if (get_shift()) { - kc = "Shift+" + kc; + kc = find_keycode_name(KEY_SHIFT) + ("+" + kc); } if (get_control()) { - kc = "Ctrl+" + kc; + kc = find_keycode_name(KEY_CONTROL) + ("+" + kc); } return kc; } @@ -436,10 +444,7 @@ Ref<InputEvent> InputEventMouseButton::xformed_by(const Transform2D &p_xform, co mb->set_id(get_id()); mb->set_device(get_device()); - mb->set_alt(get_alt()); - mb->set_shift(get_shift()); - mb->set_control(get_control()); - mb->set_metakey(get_metakey()); + mb->set_modifiers_from_event(this); mb->set_position(l); mb->set_global_position(g); @@ -555,10 +560,7 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co mm->set_id(get_id()); mm->set_device(get_device()); - mm->set_alt(get_alt()); - mm->set_shift(get_shift()); - mm->set_control(get_control()); - mm->set_metakey(get_metakey()); + mm->set_modifiers_from_event(this); mm->set_position(l); mm->set_global_position(g); @@ -930,3 +932,99 @@ void InputEventAction::_bind_methods() { InputEventAction::InputEventAction() { pressed = false; } +///////////////////////////// + +void InputEventGesture::set_position(const Vector2 &p_pos) { + + pos = p_pos; +} + +void InputEventGesture::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_position", "position"), &InputEventGesture::set_position); + ClassDB::bind_method(D_METHOD("get_position"), &InputEventGesture::get_position); + + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position"); +} + +Vector2 InputEventGesture::get_position() const { + + return pos; +} +///////////////////////////// + +void InputEventMagnifyGesture::set_factor(real_t p_factor) { + + factor = p_factor; +} + +real_t InputEventMagnifyGesture::get_factor() const { + + return factor; +} + +Ref<InputEvent> InputEventMagnifyGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { + + Ref<InputEventMagnifyGesture> ev; + ev.instance(); + + ev->set_id(get_id()); + ev->set_device(get_device()); + ev->set_modifiers_from_event(this); + + ev->set_position(p_xform.xform(get_position() + p_local_ofs)); + ev->set_factor(get_factor()); + + return ev; +} + +void InputEventMagnifyGesture::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_factor", "factor"), &InputEventMagnifyGesture::set_factor); + ClassDB::bind_method(D_METHOD("get_factor"), &InputEventMagnifyGesture::get_factor); + + ADD_PROPERTY(PropertyInfo(Variant::REAL, "factor"), "set_factor", "get_factor"); +} + +InputEventMagnifyGesture::InputEventMagnifyGesture() { + + factor = 1.0; +} +///////////////////////////// + +void InputEventPanGesture::set_delta(const Vector2 &p_delta) { + + delta = p_delta; +} + +Vector2 InputEventPanGesture::get_delta() const { + return delta; +} + +Ref<InputEvent> InputEventPanGesture::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { + + Ref<InputEventPanGesture> ev; + ev.instance(); + + ev->set_id(get_id()); + ev->set_device(get_device()); + ev->set_modifiers_from_event(this); + + ev->set_position(p_xform.xform(get_position() + p_local_ofs)); + ev->set_delta(get_delta()); + + return ev; +} + +void InputEventPanGesture::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_delta", "delta"), &InputEventPanGesture::set_delta); + ClassDB::bind_method(D_METHOD("get_delta"), &InputEventPanGesture::get_delta); + + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "delta"), "set_delta", "get_delta"); +} + +InputEventPanGesture::InputEventPanGesture() { + + delta = Vector2(0, 0); +} diff --git a/core/os/input_event.h b/core/os/input_event.h index de3c0232ff..614a3289ba 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -213,6 +213,8 @@ public: void set_command(bool p_enabled); bool get_command() const; + void set_modifiers_from_event(const InputEventWithModifiers *event); + InputEventWithModifiers(); }; @@ -468,4 +470,51 @@ public: InputEventAction(); }; +class InputEventGesture : public InputEventWithModifiers { + + GDCLASS(InputEventGesture, InputEventWithModifiers) + + Vector2 pos; + +protected: + static void _bind_methods(); + +public: + void set_position(const Vector2 &p_pos); + Vector2 get_position() const; +}; + +class InputEventMagnifyGesture : public InputEventGesture { + + GDCLASS(InputEventMagnifyGesture, InputEventGesture) + real_t factor; + +protected: + static void _bind_methods(); + +public: + void set_factor(real_t p_factor); + real_t get_factor() const; + + virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const; + + InputEventMagnifyGesture(); +}; + +class InputEventPanGesture : public InputEventGesture { + + GDCLASS(InputEventPanGesture, InputEventGesture) + Vector2 delta; + +protected: + static void _bind_methods(); + +public: + void set_delta(const Vector2 &p_delta); + Vector2 get_delta() const; + + virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const; + + InputEventPanGesture(); +}; #endif diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp index edf4f3e2f9..dead3b6ac0 100644 --- a/core/os/keyboard.cpp +++ b/core/os/keyboard.cpp @@ -60,7 +60,11 @@ static const _KeyCodeText _keycodes[] = { {KEY_PAGEDOWN ,"PageDown"}, {KEY_SHIFT ,"Shift"}, {KEY_CONTROL ,"Control"}, +#ifdef OSX_ENABLED + {KEY_META ,"Command"}, +#else {KEY_META ,"Meta"}, +#endif {KEY_ALT ,"Alt"}, {KEY_CAPSLOCK ,"CapsLock"}, {KEY_NUMLOCK ,"NumLock"}, @@ -390,14 +394,22 @@ bool keycode_has_unicode(uint32_t p_keycode) { String keycode_get_string(uint32_t p_code) { String codestr; - if (p_code & KEY_MASK_SHIFT) - codestr += "Shift+"; - if (p_code & KEY_MASK_ALT) - codestr += "Alt+"; - if (p_code & KEY_MASK_CTRL) - codestr += "Ctrl+"; - if (p_code & KEY_MASK_META) - codestr += "Meta+"; + if (p_code & KEY_MASK_SHIFT) { + codestr += find_keycode_name(KEY_SHIFT); + codestr += "+"; + } + if (p_code & KEY_MASK_ALT) { + codestr += find_keycode_name(KEY_ALT); + codestr += "+"; + } + if (p_code & KEY_MASK_CTRL) { + codestr += find_keycode_name(KEY_CONTROL); + codestr += "+"; + } + if (p_code & KEY_MASK_META) { + codestr += find_keycode_name(KEY_META); + codestr += "+"; + } p_code &= KEY_CODE_MASK; @@ -433,6 +445,21 @@ int find_keycode(const String &p_code) { return 0; } +const char *find_keycode_name(int p_keycode) { + + const _KeyCodeText *kct = &_keycodes[0]; + + while (kct->text) { + + if (kct->code == p_keycode) { + return kct->text; + } + kct++; + } + + return ""; +} + struct _KeyCodeReplace { int from; int to; diff --git a/core/os/keyboard.h b/core/os/keyboard.h index 509ff23a93..f49cbc6b18 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -326,6 +326,7 @@ enum KeyModifierMask { String keycode_get_string(uint32_t p_code); bool keycode_has_unicode(uint32_t p_keycode); int find_keycode(const String &p_code); +const char *find_keycode_name(int p_keycode); int keycode_get_count(); int keycode_get_value_by_index(int p_index); const char *keycode_get_name_by_index(int p_index); diff --git a/core/os/memory.cpp b/core/os/memory.cpp index 74d5cbbea1..439951f711 100644 --- a/core/os/memory.cpp +++ b/core/os/memory.cpp @@ -44,6 +44,26 @@ void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)) { return p_allocfunc(p_size); } +#ifdef _MSC_VER +void operator delete(void *p_mem, const char *p_description) { + + ERR_EXPLAINC("Call to placement delete should not happen."); + CRASH_NOW(); +} + +void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size)) { + + ERR_EXPLAINC("Call to placement delete should not happen."); + CRASH_NOW(); +} + +void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description) { + + ERR_EXPLAINC("Call to placement delete should not happen."); + CRASH_NOW(); +} +#endif + #ifdef DEBUG_ENABLED uint64_t Memory::mem_usage = 0; uint64_t Memory::max_usage = 0; diff --git a/core/os/memory.h b/core/os/memory.h index f8b3da579b..7801d56837 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -72,6 +72,14 @@ void *operator new(size_t p_size, void *(*p_allocfunc)(size_t p_size)); ///< ope void *operator new(size_t p_size, void *p_pointer, size_t check, const char *p_description); ///< operator new that takes a description and uses a pointer to the preallocated memory +#ifdef _MSC_VER +// When compiling with VC++ 2017, the above declarations of placement new generate many irrelevant warnings (C4291). +// The purpose of the following definitions is to muffle these warnings, not to provide a usable implementation of placement delete. +void operator delete(void *p_mem, const char *p_description); +void operator delete(void *p_mem, void *(*p_allocfunc)(size_t p_size)); +void operator delete(void *p_mem, void *p_pointer, size_t check, const char *p_description); +#endif + #define memalloc(m_size) Memory::alloc_static(m_size) #define memrealloc(m_mem, m_size) Memory::realloc_static(m_mem, m_size) #define memfree(m_size) Memory::free_static(m_size) diff --git a/core/os/os.cpp b/core/os/os.cpp index eb5d5be33d..8088a6fa74 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -33,6 +33,7 @@ #include "input.h" #include "os/file_access.h" #include "project_settings.h" +#include "version_generated.gen.h" #include <stdarg.h> @@ -62,15 +63,21 @@ void OS::debug_break(){ // something }; -void OS::_set_logger(Logger *p_logger) { +void OS::_set_logger(CompositeLogger *p_logger) { if (_logger) { memdelete(_logger); } _logger = p_logger; } -void OS::initialize_logger() { - _set_logger(memnew(StdLogger)); +void OS::add_logger(Logger *p_logger) { + if (!_logger) { + Vector<Logger *> loggers; + loggers.push_back(p_logger); + _logger = memnew(CompositeLogger(loggers)); + } else { + _logger->add_logger(p_logger); + } } 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) { @@ -115,6 +122,16 @@ bool OS::is_in_low_processor_usage_mode() const { return low_processor_usage_mode; } +void OS::set_low_processor_usage_mode_sleep_usec(int p_usec) { + + low_processor_usage_mode_sleep_usec = p_usec; +} + +int OS::get_low_processor_usage_mode_sleep_usec() const { + + return low_processor_usage_mode_sleep_usec; +} + void OS::set_clipboard(const String &p_text) { _local_clipboard = p_text; @@ -262,30 +279,69 @@ String OS::get_locale() const { return "en"; } -String OS::get_resource_dir() const { +// Helper function to ensure that a dir name/path will be valid on the OS +String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separator) const { - return ProjectSettings::get_singleton()->get_resource_path(); + Vector<String> invalid_chars = String(": * ? \" < > |").split(" "); + if (p_allow_dir_separator) { + // Dir separators are allowed, but disallow ".." to avoid going up the filesystem + invalid_chars.push_back(".."); + } else { + invalid_chars.push_back("/"); + } + + String safe_dir_name = p_dir_name.replace("\\", "/").strip_edges(); + for (int i = 0; i < invalid_chars.size(); i++) { + safe_dir_name = safe_dir_name.replace(invalid_chars[i], "-"); + } + return safe_dir_name; } -String OS::get_system_dir(SystemDir p_dir) const { +// Path to data, config, cache, etc. OS-specific folders + +// Get properly capitalized engine name for system paths +String OS::get_godot_dir_name() const { + + // Default to lowercase, so only override when different case is needed + return String(VERSION_SHORT_NAME).to_lower(); +} + +// OS equivalent of XDG_DATA_HOME +String OS::get_data_path() const { return "."; } -String OS::get_safe_application_name() const { - String an = ProjectSettings::get_singleton()->get("application/config/name"); - Vector<String> invalid_char = String("\\ / : * ? \" < > |").split(" "); - for (int i = 0; i < invalid_char.size(); i++) { - an = an.replace(invalid_char[i], "-"); - } - return an; +// OS equivalent of XDG_CONFIG_HOME +String OS::get_config_path() const { + + return "."; +} + +// OS equivalent of XDG_CACHE_HOME +String OS::get_cache_path() const { + + return "."; } -String OS::get_data_dir() const { +// OS specific path for user:// +String OS::get_user_data_dir() const { return "."; }; +// Absolute path to res:// +String OS::get_resource_dir() const { + + return ProjectSettings::get_singleton()->get_resource_path(); +} + +// Access system-specific dirs like Documents, Downloads, etc. +String OS::get_system_dir(SystemDir p_dir) const { + + return "."; +} + Error OS::shell_open(String p_uri) { return ERR_UNAVAILABLE; }; @@ -374,9 +430,9 @@ OS::ScreenOrientation OS::get_screen_orientation() const { return (OS::ScreenOrientation)_orientation; } -void OS::_ensure_data_dir() { +void OS::_ensure_user_data_dir() { - String dd = get_data_dir(); + String dd = get_user_data_dir(); DirAccess *da = DirAccess::open(dd); if (da) { memdelete(da); @@ -516,6 +572,33 @@ bool OS::has_feature(const String &p_feature) { if (sizeof(void *) == 4 && p_feature == "32") { return true; } +#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) + if (p_feature == "x86_64") { + return true; + } +#elif (defined(__i386) || defined(__i386__)) + if (p_feature == "x86") { + return true; + } +#elif defined(__aarch64__) + if (p_feature == "arm64") { + return true; + } +#elif defined(__arm__) +#if defined(__ARM_ARCH_7A__) + if (p_feature == "armv7a" || p_feature == "armv7") { + return true; + } +#endif +#if defined(__ARM_ARCH_7S__) + if (p_feature == "armv7s" || p_feature == "armv7") { + return true; + } +#endif + if (p_feature == "arm") { + return true; + } +#endif if (_check_internal_feature_support(p_feature)) return true; @@ -534,6 +617,7 @@ OS::OS() { singleton = this; _keep_screen_on = true; // set default value to true, because this had been true before godot 2.0. low_processor_usage_mode = false; + low_processor_usage_mode_sleep_usec = 10000; _verbose_stdout = false; _no_window = false; _exit_code = 0; @@ -545,7 +629,10 @@ OS::OS() { _stack_bottom = (void *)(&stack_bottom); _logger = NULL; - _set_logger(memnew(StdLogger)); + + Vector<Logger *> loggers; + loggers.push_back(memnew(StdLogger)); + _set_logger(memnew(CompositeLogger(loggers))); } OS::~OS() { diff --git a/core/os/os.h b/core/os/os.h index f5e479ac0b..91fbf082bf 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -50,6 +50,7 @@ class OS { List<String> _cmdline; bool _keep_screen_on; bool low_processor_usage_mode; + int low_processor_usage_mode_sleep_usec; bool _verbose_stdout; String _local_clipboard; uint64_t _msec_splash; @@ -62,10 +63,10 @@ class OS { void *_stack_bottom; - Logger *_logger; + CompositeLogger *_logger; protected: - void _set_logger(Logger *p_logger); + void _set_logger(CompositeLogger *p_logger); public: typedef void (*ImeCallback)(void *p_inp, String p_text, Point2 p_selection); @@ -90,13 +91,15 @@ public: bool fullscreen; bool resizable; bool borderless_window; + bool maximized; float get_aspect() const { return (float)width / (float)height; } - VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false) { + VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false, bool p_maximized = false) { width = p_width; height = p_height; fullscreen = p_fullscreen; resizable = p_resizable; borderless_window = p_borderless_window; + maximized = p_maximized; } }; @@ -109,12 +112,11 @@ protected: virtual int get_video_driver_count() const = 0; virtual const char *get_video_driver_name(int p_driver) const = 0; - virtual VideoMode get_default_video_mode() const = 0; - virtual int get_audio_driver_count() const = 0; virtual const char *get_audio_driver_name(int p_driver) const = 0; - virtual void initialize_logger(); + void add_logger(Logger *p_logger); + virtual void initialize_core() = 0; virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) = 0; @@ -126,7 +128,7 @@ protected: virtual void set_cmdline(const char *p_execpath, const List<String> &p_args); - void _ensure_data_dir(); + void _ensure_user_data_dir(); virtual bool _check_internal_feature_support(const String &p_feature) = 0; public: @@ -193,7 +195,7 @@ public: virtual void set_ime_position(const Point2 &p_pos) {} virtual void set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_inp) {} - virtual Error open_dynamic_library(const String p_path, void *&p_library_handle) { return ERR_UNAVAILABLE; } + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle,bool p_also_set_library_path=false) { return ERR_UNAVAILABLE; } virtual Error close_dynamic_library(void *p_library_handle) { return ERR_UNAVAILABLE; } virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) { return ERR_UNAVAILABLE; } @@ -201,8 +203,9 @@ public: virtual bool is_keep_screen_on() const; virtual void set_low_processor_usage_mode(bool p_enabled); virtual bool is_in_low_processor_usage_mode() const; + virtual void set_low_processor_usage_mode_sleep_usec(int p_usec); + virtual int get_low_processor_usage_mode_sleep_usec() const; - virtual String get_installed_templates_path() const { return ""; } virtual String get_executable_path() const; virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0; virtual Error kill(const ProcessID &p_pid) = 0; @@ -335,11 +338,15 @@ public: virtual String get_locale() const; - String get_safe_application_name() const; - virtual String get_data_dir() const; - virtual String get_resource_dir() const; + String get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separator = false) const; + virtual String get_godot_dir_name() const; - virtual Error move_to_trash(const String &p_path) { return FAILED; } + virtual String get_data_path() const; + virtual String get_config_path() const; + virtual String get_cache_path() const; + + virtual String get_user_data_dir() const; + virtual String get_resource_dir() const; enum SystemDir { SYSTEM_DIR_DESKTOP, @@ -354,6 +361,8 @@ public: virtual String get_system_dir(SystemDir p_dir) const; + virtual Error move_to_trash(const String &p_path) { return FAILED; } + virtual void set_no_window_mode(bool p_enable); virtual bool is_no_window_mode_enabled() const; |