From 261a53889fa414c600d0c0964f301d13ffc96bb0 Mon Sep 17 00:00:00 2001 From: nikitalita <69168929+nikitalita@users.noreply.github.com> Date: Fri, 12 Jan 2024 19:39:13 -0800 Subject: [PATCH] Load macos `.app` folders --- utility/gdre_settings.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/utility/gdre_settings.cpp b/utility/gdre_settings.cpp index a5717b54..e126be27 100644 --- a/utility/gdre_settings.cpp +++ b/utility/gdre_settings.cpp @@ -388,8 +388,21 @@ Error GDRESettings::load_pack(const String &p_path) { if (is_pack_loaded()) { return ERR_ALREADY_IN_USE; } - Ref da = DirAccess::open(p_path.get_base_dir()); - if (da->dir_exists(p_path)) { + if (DirAccess::exists(p_path)) { + // This may be a ".app" bundle, so we need to check if it's a valid Godot app + // and if so, load the pck from inside the bundle + if (p_path.get_extension().to_lower() == "app") { + String resources_path = p_path.path_join("Contents").path_join("Resources"); + if (DirAccess::exists(resources_path)) { + auto list = gdreutil::get_recursive_dir_list(resources_path, { "*.pck" }, true); + if (!list.is_empty()) { + if (list.size() > 1) { + WARN_PRINT("Found multiple pck files in bundle, using first one!!!"); + } + return load_pack(list[0]); + } + } + } return load_dir(p_path); } print_line("Opening file: " + p_path);