diff options
Diffstat (limited to 'core/os/os.cpp')
-rw-r--r-- | core/os/os.cpp | 245 |
1 files changed, 10 insertions, 235 deletions
diff --git a/core/os/os.cpp b/core/os/os.cpp index 9a65d537ac..425132fbec 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -30,9 +30,9 @@ #include "os.h" +#include "core/input/input.h" #include "core/os/dir_access.h" #include "core/os/file_access.h" -#include "core/os/input.h" #include "core/os/midi_driver.h" #include "core/project_settings.h" #include "core/version_generated.gen.h" @@ -40,7 +40,7 @@ #include <stdarg.h> -OS *OS::singleton = NULL; +OS *OS::singleton = nullptr; OS *OS::get_singleton() { @@ -139,14 +139,6 @@ void OS::printerr(const char *p_format, ...) { va_end(argp); }; -void OS::set_keep_screen_on(bool p_enabled) { - _keep_screen_on = p_enabled; -} - -bool OS::is_keep_screen_on() const { - return _keep_screen_on; -} - void OS::set_low_processor_usage_mode(bool p_enabled) { low_processor_usage_mode = p_enabled; @@ -167,15 +159,6 @@ 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; -} -String OS::get_clipboard() const { - - return _local_clipboard; -} - String OS::get_executable_path() const { return _execpath; @@ -201,7 +184,7 @@ void OS::dump_memory_to_file(const char *p_file) { //Memory::dump_static_mem_to_file(p_file); } -static FileAccess *_OSPRF = NULL; +static FileAccess *_OSPRF = nullptr; static void _OS_printres(Object *p_obj) { @@ -216,31 +199,6 @@ static void _OS_printres(Object *p_obj) { print_line(str); } -bool OS::has_virtual_keyboard() const { - - return false; -} - -void OS::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect, int p_max_input_length) { -} - -void OS::hide_virtual_keyboard() { -} - -int OS::get_virtual_keyboard_height() const { - return 0; -} - -void OS::set_cursor_shape(CursorShape p_shape) { -} - -OS::CursorShape OS::get_cursor_shape() const { - return CURSOR_ARROW; -} - -void OS::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) { -} - void OS::print_all_resources(String p_to_file) { ERR_FAIL_COND(p_to_file != "" && _OSPRF); @@ -249,7 +207,7 @@ void OS::print_all_resources(String p_to_file) { Error err; _OSPRF = FileAccess::open(p_to_file, FileAccess::WRITE, &err); if (err != OK) { - _OSPRF = NULL; + _OSPRF = nullptr; ERR_FAIL_MSG("Can't print all resources to file: " + String(p_to_file) + "."); } } @@ -260,13 +218,13 @@ void OS::print_all_resources(String p_to_file) { if (_OSPRF) memdelete(_OSPRF); - _OSPRF = NULL; + _OSPRF = nullptr; } } void OS::print_resources_in_use(bool p_short) { - ResourceCache::dump(NULL, p_short); + ResourceCache::dump(nullptr, p_short); } void OS::dump_resources_to_file(const char *p_file) { @@ -372,45 +330,6 @@ Error OS::shell_open(String p_uri) { }; // implement these with the canvas? -Error OS::dialog_show(String p_title, String p_description, Vector<String> p_buttons, Object *p_obj, String p_callback) { - - while (true) { - - print("%ls\n--------\n%ls\n", p_title.c_str(), p_description.c_str()); - for (int i = 0; i < p_buttons.size(); i++) { - if (i > 0) print(", "); - print("%i=%ls", i + 1, p_buttons[i].c_str()); - }; - print("\n"); - String res = get_stdin_string().strip_edges(); - if (!res.is_numeric()) - continue; - int n = res.to_int(); - if (n < 0 || n >= p_buttons.size()) - continue; - if (p_obj && p_callback != "") - p_obj->call_deferred(p_callback, n); - break; - }; - return OK; -}; - -Error OS::dialog_input_text(String p_title, String p_description, String p_partial, Object *p_obj, String p_callback) { - - ERR_FAIL_COND_V(!p_obj, FAILED); - ERR_FAIL_COND_V(p_callback == "", FAILED); - print("%ls\n---------\n%ls\n[%ls]:\n", p_title.c_str(), p_description.c_str(), p_partial.c_str()); - - String res = get_stdin_string().strip_edges(); - bool success = true; - if (res == "") { - res = p_partial; - }; - - p_obj->call_deferred(p_callback, success, res); - - return OK; -}; uint64_t OS::get_static_memory_usage() const { @@ -427,12 +346,6 @@ Error OS::set_cwd(const String &p_cwd) { return ERR_CANT_OPEN; } -bool OS::has_touchscreen_ui_hint() const { - - //return false; - return Input::get_singleton() && Input::get_singleton()->is_emulating_touch_from_mouse(); -} - uint64_t OS::get_free_static_memory() const { return Memory::get_mem_available(); @@ -441,17 +354,7 @@ uint64_t OS::get_free_static_memory() const { void OS::yield() { } -void OS::set_screen_orientation(ScreenOrientation p_orientation) { - - _orientation = p_orientation; -} - -OS::ScreenOrientation OS::get_screen_orientation() const { - - return (OS::ScreenOrientation)_orientation; -} - -void OS::_ensure_user_data_dir() { +void OS::ensure_user_data_dir() { String dd = get_user_data_dir(); DirAccess *da = DirAccess::open(dd); @@ -467,12 +370,6 @@ void OS::_ensure_user_data_dir() { memdelete(da); } -void OS::set_native_icon(const String &p_filename) { -} - -void OS::set_icon(const Ref<Image> &p_icon) { -} - String OS::get_model_name() const { return "GenericDevice"; @@ -484,15 +381,6 @@ void OS::set_cmdline(const char *p_execpath, const List<String> &p_args) { _cmdline = p_args; }; -void OS::release_rendering_thread() { -} - -void OS::make_rendering_thread() { -} - -void OS::swap_buffers() { -} - String OS::get_unique_id() const { ERR_FAIL_V(""); @@ -503,31 +391,6 @@ int OS::get_processor_count() const { return 1; } -Error OS::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) { - - return FAILED; -}; - -bool OS::native_video_is_playing() const { - - return false; -}; - -void OS::native_video_pause(){ - -}; - -void OS::native_video_unpause(){ - -}; - -void OS::native_video_stop(){ - -}; - -void OS::set_mouse_mode(MouseMode p_mode) { -} - bool OS::can_use_threads() const { #ifdef NO_THREADS @@ -537,51 +400,6 @@ bool OS::can_use_threads() const { #endif } -OS::MouseMode OS::get_mouse_mode() const { - - return MOUSE_MODE_VISIBLE; -} - -OS::LatinKeyboardVariant OS::get_latin_keyboard_variant() const { - - return LATIN_KEYBOARD_QWERTY; -} - -bool OS::is_joy_known(int p_device) { - return true; -} - -String OS::get_joy_guid(int p_device) const { - return "Default Joypad"; -} - -void OS::set_context(int p_context) { -} - -OS::SwitchVSyncCallbackInThread OS::switch_vsync_function = NULL; - -void OS::set_use_vsync(bool p_enable) { - _use_vsync = p_enable; - if (switch_vsync_function) { //if a function was set, use function - switch_vsync_function(p_enable); - } else { //otherwise just call here - _set_use_vsync(p_enable); - } -} - -bool OS::is_vsync_enabled() const { - - return _use_vsync; -} - -void OS::set_vsync_via_compositor(bool p_enable) { - _vsync_via_compositor = p_enable; -} - -bool OS::is_vsync_via_compositor_enabled() const { - return _vsync_via_compositor; -} - void OS::set_has_server_feature_callback(HasServerFeatureCallback p_callback) { has_server_feature_callback = p_callback; @@ -653,48 +471,6 @@ bool OS::has_feature(const String &p_feature) { return false; } -void OS::center_window() { - - if (is_window_fullscreen()) return; - - Point2 sp = get_screen_position(get_current_screen()); - Size2 scr = get_screen_size(get_current_screen()); - Size2 wnd = get_real_window_size(); - - int x = sp.width + (scr.width - wnd.width) / 2; - int y = sp.height + (scr.height - wnd.height) / 2; - - set_window_position(Vector2(x, y)); -} - -int OS::get_video_driver_count() const { - - return 2; -} - -const char *OS::get_video_driver_name(int p_driver) const { - - switch (p_driver) { - case VIDEO_DRIVER_GLES2: - return "GLES2"; - case VIDEO_DRIVER_VULKAN: - default: - return "Vulkan"; - } -} - -int OS::get_audio_driver_count() const { - - return AudioDriverManager::get_driver_count(); -} - -const char *OS::get_audio_driver_name(int p_driver) const { - - AudioDriver *driver = AudioDriverManager::get_driver(p_driver); - ERR_FAIL_COND_V_MSG(!driver, "", "Cannot get audio driver at index '" + itos(p_driver) + "'."); - return AudioDriverManager::get_driver(p_driver)->get_name(); -} - void OS::set_restart_on_exit(bool p_restart, const List<String> &p_restart_arguments) { restart_on_exit = p_restart; restart_commandline = p_restart_arguments; @@ -740,7 +516,6 @@ OS::OS() { _verbose_stdout = false; _no_window = false; _exit_code = 0; - _orientation = SCREEN_LANDSCAPE; _render_thread_mode = RENDER_THREAD_SAFE; @@ -748,9 +523,9 @@ OS::OS() { _allow_layered = false; _stack_bottom = (void *)(&stack_bottom); - _logger = NULL; + _logger = nullptr; - has_server_feature_callback = NULL; + has_server_feature_callback = nullptr; Vector<Logger *> loggers; loggers.push_back(memnew(StdLogger)); @@ -759,5 +534,5 @@ OS::OS() { OS::~OS() { memdelete(_logger); - singleton = NULL; + singleton = nullptr; } |