diff options
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/export/export.cpp | 6 | ||||
-rw-r--r-- | platform/osx/os_osx.h | 5 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 40 |
3 files changed, 47 insertions, 4 deletions
diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 8a6f1dc04c..f6922377e3 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -160,7 +160,7 @@ void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_ copy->convert(Image::FORMAT_RGBA8); copy->resize(size, size); it->create_from_image(copy); - String path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/icon.png"; + String path = EditorSettings::get_singleton()->get_cache_dir().plus_file("icon.png"); ResourceSaver::save(path, it); FileAccess *f = FileAccess::open(path, FileAccess::READ); @@ -344,7 +344,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p if (use_dmg()) { // We're on OSX so we can export to DMG, but first we create our application bundle - tmp_app_path_name = EditorSettings::get_singleton()->get_settings_path() + "/tmp/" + pkg_name + ".app"; + tmp_app_path_name = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".app"); print_line("Exporting to " + tmp_app_path_name); DirAccess *tmp_app_path = DirAccess::create_for_path(tmp_app_path_name); if (!tmp_app_path) { @@ -539,7 +539,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p OS::get_singleton()->move_to_trash(tmp_app_path_name); } else { - String pack_path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/" + pkg_name + ".pck"; + String pack_path = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".pck"); Error err = save_pack(p_preset, pack_path); if (err == OK) { diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index 1df847eb79..aa8ee1fe83 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -154,6 +154,11 @@ public: virtual MainLoop *get_main_loop() const; + virtual String get_config_path() const; + virtual String get_data_path() const; + virtual String get_cache_path() const; + virtual String get_godot_dir_name() const; + virtual String get_system_dir(SystemDir p_dir) const; virtual bool can_draw() const; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 8703b8ff16..ec8ec613d3 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -36,6 +36,7 @@ #include "print_string.h" #include "sem_osx.h" #include "servers/visual/visual_server_raster.h" +#include "version_generated.gen.h" #include <Carbon/Carbon.h> #import <Cocoa/Cocoa.h> @@ -1089,7 +1090,7 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au power_manager = memnew(power_osx); - _ensure_data_dir(); + _ensure_user_data_dir(); restore_rect = Rect2(get_window_position(), get_window_size()); } @@ -1334,6 +1335,43 @@ MainLoop *OS_OSX::get_main_loop() const { return main_loop; } +String OS_OSX::get_config_path() const { + + if (has_environment("XDG_CONFIG_HOME")) { + return get_environment("XDG_CONFIG_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file("Library/Application Support"); + } else { + return "."; + } +} + +String OS_OSX::get_data_path() const { + + if (has_environment("XDG_DATA_HOME")) { + return get_environment("XDG_DATA_HOME"); + } else { + return get_config_path(); + } +} + +String OS_OSX::get_cache_path() const { + + if (has_environment("XDG_CACHE_HOME")) { + return get_environment("XDG_CACHE_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file("Library/Caches"); + } else { + return get_config_path(); + } +} + +// Get properly capitalized engine name for system paths +String OS_OSX::get_godot_dir_name() const { + + return String(_MKSTR(VERSION_SHORT_NAME)).capitalize(); +} + String OS_OSX::get_system_dir(SystemDir p_dir) const { NSSearchPathDirectory id = 0; |