Skip to content

Commit

Permalink
macOS Game Mode Support for 2Ship2Harkinian (#811)
Browse files Browse the repository at this point in the history
* final commit(hopefully)

* Moving directory creation logic out of LUS

* Update BenPort.cpp

* move Ternary operator one line down to keep to the clang limit

* I have no idea how clang works

* Using ChatGPT to hopefully fix the formatting because I'm tired

* ChatGPT is useless, it's brain time

* Will Putin become the next Miss America?

* I hope this works for slimming down 2s2h(Mac) as well

My builds have gotten double their original size since I started taking care of them and I feel bad about it :(

* Some final pre merge cleanup

Removed the bash script and its references

* Updated to follow Archez's new conventions

* Parity with upstream

* updated git ignore

* update git ignore again

* Re-added the folder creation function

* I should pay more attention to what I am doing

* Update mm/macosx/Info.plist.in

Co-authored-by: Archez <[email protected]>

* Update CMakeLists.txt

* desperation

* Revert "desperation"

This reverts commit 6aea78d.

* Update .gitignore

* does this do the trick?

* Revert "does this do the trick?"

This reverts commit 267fbfb.

* Revert "Parity with upstream"

This reverts commit 6bfdee8.

* Update libultraship

* Revert "Update libultraship"

This reverts commit e9e0747.

---------

Co-authored-by: Archez <[email protected]>
  • Loading branch information
larsy1995 and Archez authored Feb 5, 2025
1 parent a36b4aa commit ac1ad42
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 25 deletions.
1 change: 0 additions & 1 deletion CMake/Packaging-2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ 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_APPLE_CERT_APP "-")
endif()
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,11 @@ install(FILES "${CMAKE_SOURCE_DIR}/OTRExporter/CFG/SymbolMap_MM.txt" DESTINATION
# PERMISSIONS ${PROGRAM_PERMISSIONS_EXECUTE}
# )

# Rename the installed soh binary to drop the macos suffix
INSTALL(CODE "FILE(RENAME \${CMAKE_INSTALL_PREFIX}/../MacOS/2s2h-macos \${CMAKE_INSTALL_PREFIX}/../MacOS/2s2h)")
install(CODE "
include(BundleUtilities)
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/2s2h-macos\" \"\" \"${dirs}\")
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/../MacOS/2s2h\" \"\" \"${dirs}\")
")

endif()
Expand Down
18 changes: 18 additions & 0 deletions mm/2s2h/BenPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,23 @@ void DetectArchiveVersion(std::string fileName, bool isO2rType) {
}
}

void CheckAndCreateModFolder() {
try {
std::string modsPath = Ship::Context::LocateFileAcrossAppDirs("mods", appShortName);
if (!std::filesystem::exists(modsPath)) {
// Create mods folder relative to app dir
modsPath = Ship::Context::GetPathRelativeToAppDirectory("mods", appShortName);
std::string filePath = modsPath + "/custom_mod_files_go_here.txt";
if (std::filesystem::create_directories(modsPath)) {
std::ofstream(filePath).close();
}
}
} catch (std::filesystem::filesystem_error const& ex) {
// Couldn't make the folder, continue silently
return;
}
}

extern "C" void InitOTR() {

#ifdef __SWITCH__
Expand All @@ -639,6 +656,7 @@ extern "C" void InitOTR() {
}

#if not defined(__SWITCH__) && not defined(__WIIU__)
CheckAndCreateModFolder();
if (!std::filesystem::exists(mmPathO2R) && !std::filesystem::exists(mmPathZIP) &&
!std::filesystem::exists(mmPathOtr)) {
std::string installPath = Ship::Context::GetAppBundlePath();
Expand Down
4 changes: 2 additions & 2 deletions mm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ else()
)
endif()

if(NOT CMAKE_SYSTEM_NAME MATCHES "NintendoSwitch|CafeOS")
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|NintendoSwitch|CafeOS")
INSTALL(TARGETS 2ship DESTINATION . COMPONENT 2s2h)
endif()

Expand All @@ -622,7 +622,7 @@ 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(TARGETS 2ship DESTINATION ../MacOS COMPONENT 2s2h)
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.

5 changes: 5 additions & 0 deletions mm/macosx/Info.plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<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>
</dict>
<key>LSArchitecturePriority</key>
<array>
<string>arm64</string>
Expand Down

0 comments on commit ac1ad42

Please sign in to comment.