From 4262cc0f7f621b19ee2c20147433055316cf6763 Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Tue, 14 May 2024 01:03:03 -0400 Subject: [PATCH] O2R support --- CMakeLists.txt | 16 ++++++++-------- OTRExporter | 2 +- copy-existing-otrs.cmake | 32 ++++++++++++++++---------------- mm/2s2h/BenPort.cpp | 8 ++++---- mm/2s2h/Extractor/Extract.cpp | 2 +- mm/CMakeLists.txt | 4 ++-- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5eb93960..ac1fa8877 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,7 +109,7 @@ set_property(TARGET mm PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/2s2hIcon if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") install(PROGRAMS "${CMAKE_BINARY_DIR}/linux/2s2h.sh" DESTINATION . COMPONENT appimage) -install(FILES "${CMAKE_SOURCE_DIR}/2ship.otr" DESTINATION . COMPONENT ship) +install(FILES "${CMAKE_SOURCE_DIR}/2ship.zip" DESTINATION . COMPONENT ship) install(TARGETS ZAPD DESTINATION ./assets/extractor COMPONENT extractor) install(DIRECTORY "${CMAKE_SOURCE_DIR}/mm/assets/extractor/" DESTINATION ./assets/extractor COMPONENT extractor) install(DIRECTORY "${CMAKE_SOURCE_DIR}/mm/assets/xml/" DESTINATION ./assets/extractor/xmls COMPONENT extractor) @@ -134,13 +134,13 @@ find_package(Python3 COMPONENTS Interpreter) add_custom_target( ExtractAssets # CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions - COMMAND ${CMAKE_COMMAND} -E $,remove,rm> -f mm.otr 2ship.otr - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --non-interactive --xml-root ../mm/assets/xml --custom-otr-file 2ship.otr "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/mm/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}" + COMMAND ${CMAKE_COMMAND} -E $,remove,rm> -f mm.zip 2ship.zip + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --non-interactive --xml-root ../mm/assets/xml --custom-otr-file 2ship.zip "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/mm/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}" COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter COMMENT "Running asset extraction..." DEPENDS ZAPD - BYPRODUCTS mm.otr ${CMAKE_SOURCE_DIR}/mm.otr ${CMAKE_SOURCE_DIR}/2ship.otr + BYPRODUCTS mm.zip ${CMAKE_SOURCE_DIR}/mm.zip ${CMAKE_SOURCE_DIR}/2ship.zip ) # Target to generate headers @@ -152,15 +152,15 @@ add_custom_target( DEPENDS ZAPD ) -# Target to generate only 2ship.otr +# Target to generate only 2ship.zip add_custom_target( Generate2ShipOtr # CMake versions prior to 3.17 do not have the rm command, use remove instead for older versions - COMMAND ${CMAKE_COMMAND} -E $,remove,rm> -f 2ship.otr - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --norom --custom-otr-file 2ship.otr "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/mm/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}" + COMMAND ${CMAKE_COMMAND} -E $,remove,rm> -f 2ship.zip + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$" --norom --custom-otr-file 2ship.zip "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/mm/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}" COMMAND ${CMAKE_COMMAND} -DSYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DTARGET_DIR="$" -DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBINARY_DIR=${CMAKE_BINARY_DIR} -DONLY2SHIPOTR=On -P ${CMAKE_CURRENT_SOURCE_DIR}/copy-existing-otrs.cmake WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter - COMMENT "Generating 2ship.otr..." + COMMENT "Generating 2ship.zip..." DEPENDS ZAPD ) diff --git a/OTRExporter b/OTRExporter index 55eb1c425..14365cd1c 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit 55eb1c4250cf3789248c542f81034c6f79f49b03 +Subproject commit 14365cd1cf1980cf7b8ca74ed32d7005ca942301 diff --git a/copy-existing-otrs.cmake b/copy-existing-otrs.cmake index ae968ab77..3a057cb2a 100644 --- a/copy-existing-otrs.cmake +++ b/copy-existing-otrs.cmake @@ -1,29 +1,29 @@ message(STATUS "Copying otr files...") -if(NOT ONLY2SHIPOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/mm.otr) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.otr ${SOURCE_DIR}) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.otr ${BINARY_DIR}/mm/) - message(STATUS "Copied mm.otr") +if(NOT ONLY2SHIPOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/mm.zip) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.zip ${SOURCE_DIR}) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.zip ${BINARY_DIR}/mm/) + message(STATUS "Copied mm.zip") endif() -if(EXISTS ${SOURCE_DIR}/OTRExporter/2ship.otr) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy 2ship.otr ${SOURCE_DIR}) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy 2ship.otr ${BINARY_DIR}/mm/) - message(STATUS "Copied 2ship.otr") +if(EXISTS ${SOURCE_DIR}/OTRExporter/2ship.zip) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy 2ship.zip ${SOURCE_DIR}) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy 2ship.zip ${BINARY_DIR}/mm/) + message(STATUS "Copied 2ship.zip") endif() # Additionally for Windows, copy the otrs to the target dir, side by side with 2ship.exe if(SYSTEM_NAME MATCHES "Windows") - if(NOT ONLY2SHIPOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/mm.otr) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.otr ${TARGET_DIR}) + if(NOT ONLY2SHIPOTR AND EXISTS ${SOURCE_DIR}/OTRExporter/mm.zip) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.zip ${TARGET_DIR}) endif() - if(EXISTS ${SOURCE_DIR}/OTRExporter/2ship.otr) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy 2ship.otr ${TARGET_DIR}) + if(EXISTS ${SOURCE_DIR}/OTRExporter/2ship.zip) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy 2ship.zip ${TARGET_DIR}) endif() endif() -if(NOT ONLY2SHIPOTR AND (NOT EXISTS ${SOURCE_DIR}/mm.otr)) - message(FATAL_ERROR "Failed to copy. No OTR files found.") +if(NOT ONLY2SHIPOTR AND (NOT EXISTS ${SOURCE_DIR}/mm.zip)) + message(FATAL_ERROR "Failed to copy. No ZIP files found.") endif() -if(NOT EXISTS ${SOURCE_DIR}/2ship.otr) - message(FATAL_ERROR "Failed to copy. No 2ship OTR found.") +if(NOT EXISTS ${SOURCE_DIR}/2ship.zip) + message(FATAL_ERROR "Failed to copy. No 2ship ZIP found.") endif() diff --git a/mm/2s2h/BenPort.cpp b/mm/2s2h/BenPort.cpp index d178aea1e..e8ce418c1 100644 --- a/mm/2s2h/BenPort.cpp +++ b/mm/2s2h/BenPort.cpp @@ -113,11 +113,11 @@ OTRGlobals::OTRGlobals() { //if (std::filesystem::exists(mqPath)) { // OTRFiles.push_back(mqPath); //} - std::string ootPath = Ship::Context::LocateFileAcrossAppDirs("mm.otr", appShortName); + std::string ootPath = Ship::Context::LocateFileAcrossAppDirs("mm.zip", appShortName); if (std::filesystem::exists(ootPath)) { OTRFiles.push_back(ootPath); } - std::string shipOtrPath = Ship::Context::GetPathRelativeToAppBundle("2ship.otr"); + std::string shipOtrPath = Ship::Context::GetPathRelativeToAppBundle("2ship.zip"); if (std::filesystem::exists(shipOtrPath)) { OTRFiles.push_back(shipOtrPath); } @@ -125,7 +125,7 @@ OTRGlobals::OTRGlobals() { if (patchesPath.length() > 0 && std::filesystem::exists(patchesPath)) { if (std::filesystem::is_directory(patchesPath)) { for (const auto& p : std::filesystem::recursive_directory_iterator(patchesPath)) { - if (StringHelper::IEquals(p.path().extension().string(), ".otr")) { + if (StringHelper::IEquals(p.path().extension().string(), ".zip")) { OTRFiles.push_back(p.path().generic_string()); } } @@ -397,7 +397,7 @@ extern "C" void OTRExtScanner() { extern "C" void InitOTR() { #if not defined(__SWITCH__) && not defined(__WIIU__) - if (!std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("mm.otr", appShortName))) { + if (!std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("mm.zip", appShortName))) { std::string installPath = Ship::Context::GetAppBundlePath(); if (!std::filesystem::exists(installPath + "/assets/extractor")) { Extractor::ShowErrorBox( diff --git a/mm/2s2h/Extractor/Extract.cpp b/mm/2s2h/Extractor/Extract.cpp index 928615cb7..95e154522 100644 --- a/mm/2s2h/Extractor/Extract.cpp +++ b/mm/2s2h/Extractor/Extract.cpp @@ -549,7 +549,7 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) { char portVersion[18]; // 5 digits for int16_max (x3) + separators + terminator std::array argv; const char* version = GetZapdVerStr(); - const char* otrFile = "mm.otr"; + const char* otrFile = "mm.zip"; std::string romPath = std::filesystem::absolute(mCurrentRomPath).string(); installPath = std::filesystem::absolute(installPath).string(); diff --git a/mm/CMakeLists.txt b/mm/CMakeLists.txt index f7e2cfcd6..0c1dd90bd 100644 --- a/mm/CMakeLists.txt +++ b/mm/CMakeLists.txt @@ -693,7 +693,7 @@ endif() if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") INSTALL(FILES $ DESTINATION ./debug COMPONENT 2s2h) -INSTALL(FILES ${CMAKE_BINARY_DIR}/mm/2ship.otr DESTINATION . COMPONENT 2s2h) +INSTALL(FILES ${CMAKE_BINARY_DIR}/mm/2ship.zip DESTINATION . COMPONENT 2s2h) endif() if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") @@ -707,7 +707,7 @@ 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.otr DESTINATION ../Resources COMPONENT 2s2h) +INSTALL(FILES ${CMAKE_BINARY_DIR}/mm/2ship.zip DESTINATION ../Resources COMPONENT 2s2h) elseif(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "NintendoSwitch|CafeOS") INSTALL(FILES ${CMAKE_BINARY_DIR}/gamecontrollerdb.txt DESTINATION . COMPONENT 2s2h) endif()