SDL: Read assets from Resources on macOS like on iOS

closes #15041
This commit is contained in:
vit9696 2021-11-06 09:22:08 +03:00
parent c99e19c194
commit 1066224b6f
3 changed files with 21 additions and 7 deletions

View file

@ -2337,11 +2337,11 @@ if(TargetBin)
file(GLOB_RECURSE DEBUGGER_FILES assets/debugger/*)
if(NOT IOS)
set_source_files_properties(${NativeAssets} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets")
set_source_files_properties(${FLASH0_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets/flash0/font")
set_source_files_properties(${LANG_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets/lang")
set_source_files_properties(${SHADER_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets/shaders")
set_source_files_properties(${DEBUGGER_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "MacOS/assets/debugger")
set_source_files_properties(${NativeAssets} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets")
set_source_files_properties(${FLASH0_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/flash0/font")
set_source_files_properties(${LANG_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/lang")
set_source_files_properties(${SHADER_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/shaders")
set_source_files_properties(${DEBUGGER_FILES} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/assets/debugger")
endif()
if(IOS)

View file

@ -684,7 +684,17 @@ int main(int argc, char *argv[]) {
if (strlen(path) > 0 && path[strlen(path) - 1] != '/')
strcat(path, "/");
NativeInit(remain_argc, (const char **)remain_argv, path, "/tmp", nullptr);
#if PPSSPP_PLATFORM(MAC)
std::string external_dir_str;
if (SDL_GetBasePath())
external_dir_str = std::string(SDL_GetBasePath()) + "/assets";
else
external_dir_str = "/tmp";
const char *external_dir = external_dir_str.c_str();
#else
const char *external_dir = "/tmp";
#endif
NativeInit(remain_argc, (const char **)remain_argv, path, external_dir, nullptr);
// Use the setting from the config when initing the window.
if (g_Config.bFullScreen)

View file

@ -475,7 +475,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
// on iOS it's even the path to bundled app assets. It's a mess.
// We want this to be FIRST.
#if PPSSPP_PLATFORM(IOS)
#if PPSSPP_PLATFORM(IOS) || PPSSPP_PLATFORM(MAC)
// Packed assets are included in app
VFSRegister("", new DirectoryAssetReader(Path(external_dir)));
#endif
@ -556,6 +556,10 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
g_Config.defaultCurrentDirectory = g_Config.internalDataDirectory;
g_Config.memStickDirectory = Path(user_data_path);
g_Config.flash0Directory = Path(std::string(external_dir)) / "flash0";
#elif PPSSPP_PLATFORM(MAC)
g_Config.defaultCurrentDirectory = Path(getenv("HOME"));
g_Config.memStickDirectory = g_Config.defaultCurrentDirectory / ".config/ppsspp";
g_Config.flash0Directory = Path(std::string(external_dir)) / "flash0";
#elif PPSSPP_PLATFORM(SWITCH)
g_Config.memStickDirectory = g_Config.internalDataDirectory / "config/ppsspp";
g_Config.flash0Directory = g_Config.internalDataDirectory / "assets/flash0";