Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS Game Mode Support for 2Ship2Harkinian #811

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
2 changes: 1 addition & 1 deletion CMake/Packaging-2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ if (CPACK_GENERATOR MATCHES "Bundle")
set(CPACK_BUNDLE_NAME "2s2h")
set(CPACK_BUNDLE_PLIST "macosx/Info.plist")
set(CPACK_BUNDLE_ICON "macosx/2s2h.icns")
set(CPACK_BUNDLE_STARTUP_COMMAND "macosx/2s2h-macos.sh")
set(CPACK_BUNDLE_STARTUP_COMMAND "mm/2s2h-macos")
set(CPACK_BUNDLE_APPLE_CERT_APP "-")
endif()
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_MM.txt" DESTINATION
install(CODE "
include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/2s2h-macos\" \"\" \"${dirs}\")
execute_process(COMMAND rm -f \"\${CMAKE_INSTALL_PREFIX}/2s2h-macos\")
")

endif()
Expand Down
2 changes: 1 addition & 1 deletion libultraship
Submodule libultraship updated 1 files
+14 −1 src/Context.cpp
17 changes: 17 additions & 0 deletions mm/2s2h/BenPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <Fast3D/gfx_rendering_api.h>

#ifdef __APPLE__
#include <unistd.h>
#include <pwd.h>
#include <SDL_scancode.h>
#else
#include <SDL2/SDL_scancode.h>
Expand Down Expand Up @@ -478,8 +480,23 @@ void Ben_ProcessDroppedFiles(std::string filePath) {
}
}

void CheckAndCreateFoldersAndFile() {
#if defined(__APPLE__)
if (const char* fpath = std::getenv("SHIP_HOME")) {
std::string homeDir = getenv("HOME") ? getenv("HOME") : getpwuid(getuid())->pw_dir;
std::string modsPath = (fpath[0] == '~') ? (homeDir + std::string(fpath).substr(1)) : std::string(fpath);
modsPath += "/mods";
std::string filePath = modsPath + "/custom_mod_files_go_here.txt";
if (std::filesystem::create_directories(modsPath) || !std::filesystem::exists(filePath)) {
std::ofstream(filePath).close();
}
}
#endif
}

extern "C" void InitOTR() {
#if not defined(__SWITCH__) && not defined(__WIIU__)
CheckAndCreateFoldersAndFile();
if (!std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("mm.o2r", appShortName)) &&
!std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("mm.zip", appShortName)) &&
!std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("mm.otr", appShortName))) {
Expand Down
1 change: 0 additions & 1 deletion mm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ execute_process(COMMAND ${CURL} -sSfL https://raw.githubusercontent.com/gabomdq/

if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/macosx/Info.plist.in ${CMAKE_BINARY_DIR}/macosx/Info.plist @ONLY)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/macosx/2s2h-macos.sh.in ${CMAKE_BINARY_DIR}/macosx/2s2h-macos.sh @ONLY)
INSTALL(FILES ${CMAKE_BINARY_DIR}/gamecontrollerdb.txt DESTINATION ../MacOS COMPONENT 2s2h)
INSTALL(FILES ${CMAKE_BINARY_DIR}/mm/2ship.o2r DESTINATION ../Resources COMPONENT 2s2h)
elseif(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "NintendoSwitch|CafeOS")
Expand Down
21 changes: 0 additions & 21 deletions mm/macosx/2s2h-macos.sh.in

This file was deleted.

7 changes: 7 additions & 0 deletions mm/macosx/Info.plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
<string>public.app-category.games</string>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
<key>LSEnvironment</key>
<dict>
<key>SHIP_HOME</key>
<string>~/Library/Application Support/com.2ship2harkinian.2s2h</string>
<key>DYLD_LIBRARY_PATH</key>
<string>@executable_path/../Frameworks</string>
</dict>
<key>LSArchitecturePriority</key>
<array>
<string>arm64</string>
Expand Down
Loading