diff --git a/macos/config/steamshim.xcconfig b/macos/config/steamshim.xcconfig index a07efa28..5af0cb2a 100644 --- a/macos/config/steamshim.xcconfig +++ b/macos/config/steamshim.xcconfig @@ -5,9 +5,9 @@ // Created by ゾロアーク on 1/3/21. // -// Will be used when building releases. Make sure to set it correctly. -// Debug builds require steam_appid.txt -STEAM_APP_ID = 435150 +// If this is set to anything but 0, steamshim will use RestartAppIfNecessary instead of requiring +// a steam_appid.txt +STEAM_APP_ID = 0 STEAMSHIM_DEFINES = "GAME_LAUNCH_NAME=\"Z.steam\"" STEAM_APPID=$(STEAM_APP_ID) diff --git a/macos/mkxp-z.xcodeproj/project.pbxproj b/macos/mkxp-z.xcodeproj/project.pbxproj index 358c6566..a050f00e 100644 --- a/macos/mkxp-z.xcodeproj/project.pbxproj +++ b/macos/mkxp-z.xcodeproj/project.pbxproj @@ -227,7 +227,6 @@ 3B1C242025A1A8660075EF5D /* libsteam_api.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B1C241125A1A7120075EF5D /* libsteam_api.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 3B1C242625A1A90B0075EF5D /* shim in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B1C235625A199370075EF5D /* shim */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 3B1C242B25A1AA1F0075EF5D /* steamshim_child.c in Sources */ = {isa = PBXBuildFile; fileRef = 3B1C236925A19B960075EF5D /* steamshim_child.c */; }; - 3B1C244425A1BD220075EF5D /* steam_appid.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B1C243E25A1B8D20075EF5D /* steam_appid.txt */; }; 3B251DA626DA2CFA00E5D09B /* 3.0.0 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B251DA526DA2CFA00E5D09B /* 3.0.0 */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 3B251DA826DA2E9000E5D09B /* 3.0.0 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B251DA526DA2CFA00E5D09B /* 3.0.0 */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 3B251DAA26DA2EAB00E5D09B /* 3.0.0 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B251DA526DA2CFA00E5D09B /* 3.0.0 */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; @@ -287,6 +286,7 @@ 3B5E1F1E25A8820B0086FFDC /* libGLESv2.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B5E1F0A25A881FB0086FFDC /* libGLESv2.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 3B5E1F1F25A8820D0086FFDC /* libEGL.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B5E1F0925A881FB0086FFDC /* libEGL.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 3B5E1F2025A8820F0086FFDC /* libGLESv2.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B5E1F0A25A881FB0086FFDC /* libGLESv2.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 3B5F5E7D26F1360C00DF792F /* steam_appid.txt in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B1C243E25A1B8D20075EF5D /* steam_appid.txt */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 3B97F77025E6178200A569B5 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B480E9E25DCD16D001686B4 /* GameController.framework */; }; 3BA08E9B256638C900449CFF /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BD2B46925651C1B003DAD8A /* AudioToolbox.framework */; }; 3BA69454263DAB53004194EB /* libnsgif.c in Sources */ = {isa = PBXBuildFile; fileRef = 3BA6944E263DAB53004194EB /* libnsgif.c */; }; @@ -594,6 +594,7 @@ dstSubfolderSpec = 7; files = ( 3B1C23E925A19C600075EF5D /* Assets.bundle in CopyFiles */, + 3B5F5E7D26F1360C00DF792F /* steam_appid.txt in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -632,16 +633,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - 3B1C244325A1BD1D0075EF5D /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 16; - files = ( - 3B1C244425A1BD220075EF5D /* steam_appid.txt in CopyFiles */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; 3B251D9F26DA2C2A00E5D09B /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -1908,7 +1899,6 @@ 3B1C23EA25A19C600075EF5D /* CopyFiles */, 3B251DAB26DA2EBB00E5D09B /* CopyFiles */, 3B1C23EC25A19C600075EF5D /* Embed Frameworks */, - 3B1C244325A1BD1D0075EF5D /* CopyFiles */, ); buildRules = ( ); diff --git a/src/filesystem/filesystemImpl.h b/src/filesystem/filesystemImpl.h index 57d49e55..22b0be69 100644 --- a/src/filesystem/filesystemImpl.h +++ b/src/filesystem/filesystemImpl.h @@ -31,7 +31,7 @@ std::string contentsOfAssetAsString(const char *baseName, const char *ext); std::string getResourcePath(); #ifdef MKXPZ_DEBUG -std::string selectPath(SDL_Window *win); +std::string selectPath(SDL_Window *win, const char *msg, const char *prompt); #endif #endif diff --git a/src/filesystem/filesystemImplApple.mm b/src/filesystem/filesystemImplApple.mm index fe4b038f..059985ac 100644 --- a/src/filesystem/filesystemImplApple.mm +++ b/src/filesystem/filesystemImplApple.mm @@ -101,10 +101,13 @@ std::string filesystemImpl::getResourcePath() { } #ifdef MKXPZ_DEBUG -std::string filesystemImpl::selectPath(SDL_Window *win) { +std::string filesystemImpl::selectPath(SDL_Window *win, const char *msg, const char *prompt) { NSOpenPanel *panel = [NSOpenPanel openPanel]; panel.canChooseDirectories = true; panel.canChooseFiles = false; + + if (msg) panel.message = @(msg); + if (prompt) panel.prompt = @(prompt); //panel.directoryURL = [NSURL fileURLWithPath:NSFileManager.defaultManager.currentDirectoryPath]; SDL_SysWMinfo windowinfo{}; @@ -115,6 +118,9 @@ std::string filesystemImpl::selectPath(SDL_Window *win) { }]; [NSApp runModalForWindow:windowinfo.info.cocoa.window]; + + // The window needs to be brought to the front again after the OpenPanel closes + [NSApplication.sharedApplication activateIgnoringOtherApps:true]; if (panel.URLs.count > 0) return std::string(NSTOPATH(panel.URLs[0].path)); diff --git a/src/main.cpp b/src/main.cpp index 7ec42239..cbb7e818 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -334,9 +334,10 @@ int main(int argc, char *argv[]) { return 0; } -// Temporary fix for easier debugging #if defined(MKXPZ_BUILD_XCODE) && defined(MKXPZ_DEBUG) - std::string dataDirStr = mkxp_fs::selectPath(win); +#define DEBUG_FSELECT_MSG "Select the folder to load game files from. This is the folder containing the INI and/or configuration JSON.\nThis prompt does not appear in release builds." +#define DEBUG_FSELECT_PROMPT "Load Game" + std::string dataDirStr = mkxp_fs::selectPath(win, DEBUG_FSELECT_MSG, DEBUG_FSELECT_PROMPT); if (!dataDirStr.empty()) { conf.gameFolder = dataDirStr; mkxp_fs::setCurrentDirectory(dataDirStr.c_str()); diff --git a/steamshim/steamshim_mac_helpers.h b/steamshim/steamshim_mac_helpers.h index 37fd3433..8b9747e7 100644 --- a/steamshim/steamshim_mac_helpers.h +++ b/steamshim/steamshim_mac_helpers.h @@ -12,5 +12,5 @@ std::string execPath(); -std::string appParentPath(); +std::string appResourcePath(); #endif /* steamshim_mac_helpers_h */ diff --git a/steamshim/steamshim_mac_helpers.mm b/steamshim/steamshim_mac_helpers.mm index be17ddd1..bc96eb77 100644 --- a/steamshim/steamshim_mac_helpers.mm +++ b/steamshim/steamshim_mac_helpers.mm @@ -14,7 +14,6 @@ std::string execPath() { return ret; } -std::string appParentPath() { - std::string ret([NSBundle.mainBundle.bundlePath stringByDeletingLastPathComponent].UTF8String); - return ret; +std::string appResourcePath() { + return std::string(NSBundle.mainBundle.resourcePath.UTF8String); } diff --git a/steamshim/steamshim_parent.cpp b/steamshim/steamshim_parent.cpp index 15df8a8c..459da304 100644 --- a/steamshim/steamshim_parent.cpp +++ b/steamshim/steamshim_parent.cpp @@ -658,12 +658,12 @@ static void deinitSteamworks(void) { static int mainline(void) { -#if (defined(MKXPZ_BUILD_XCODE) && !defined(MKXPZ_DEBUG)) || \ +#if (defined(MKXPZ_BUILD_XCODE) && STEAM_APPID != 0) || \ (!defined(MKXPZ_BUILD_XCODE) && defined(STEAM_APPID)) if (SteamAPI_RestartAppIfNecessary(STEAM_APPID)) return 0; #elif defined(MKXPZ_BUILD_XCODE) && defined(MKXPZ_DEBUG) - chdir(appParentPath().c_str()); + chdir(appResourcePath().c_str()); #endif PipeType pipeParentRead = NULLPIPE;