From 7d431f406f05acea5272c92ce41024db9c9cb9d4 Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Sat, 18 May 2024 14:04:20 -0400 Subject: [PATCH] O2R support (#388) * O2R support * Still look for .otrs * Update submodule * Hotfix for exporter --- .gitignore | 1 + CMakeLists.txt | 16 ++++++++-------- OTRExporter | 2 +- copy-existing-otrs.cmake | 32 ++++++++++++++++---------------- mm/2s2h/BenPort.cpp | 29 +++++++++++++++++++---------- mm/2s2h/Extractor/Extract.cpp | 2 +- mm/CMakeLists.txt | 4 ++-- 7 files changed, 48 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index b6a50cfd2..4049f2f1a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.zip *.otr .vscode *.swp 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..281e6a626 160000 --- a/OTRExporter +++ b/OTRExporter @@ -1 +1 @@ -Subproject commit 55eb1c4250cf3789248c542f81034c6f79f49b03 +Subproject commit 281e6a626d795d3e3fcdefa23edae503ac499f6e 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..c8d7bc1fd 100644 --- a/mm/2s2h/BenPort.cpp +++ b/mm/2s2h/BenPort.cpp @@ -108,25 +108,34 @@ Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 }; OTRGlobals::OTRGlobals() { - std::vector OTRFiles; + std::vector archiveFiles; //std::string mqPath = Ship::Context::LocateFileAcrossAppDirs("oot-mq.otr", appShortName); //if (std::filesystem::exists(mqPath)) { // OTRFiles.push_back(mqPath); //} - std::string ootPath = Ship::Context::LocateFileAcrossAppDirs("mm.otr", appShortName); - if (std::filesystem::exists(ootPath)) { - OTRFiles.push_back(ootPath); + std::string mmPath = Ship::Context::LocateFileAcrossAppDirs("mm.zip", appShortName); + if (std::filesystem::exists(mmPath)) { + archiveFiles.push_back(mmPath); + } else { + mmPath = Ship::Context::LocateFileAcrossAppDirs("mm.otr", appShortName); + if (std::filesystem::exists(mmPath)) { + archiveFiles.push_back(mmPath); + } } - 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); + archiveFiles.push_back(shipOtrPath); } std::string patchesPath = Ship::Context::LocateFileAcrossAppDirs("mods", appShortName); 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")) { - OTRFiles.push_back(p.path().generic_string()); + if (StringHelper::IEquals(p.path().extension().string(), ".zip")) { + archiveFiles.push_back(p.path().generic_string()); + } else { + if (StringHelper::IEquals(p.path().extension().string(), ".otr")) { + archiveFiles.push_back(p.path().generic_string()); + } } } } @@ -136,7 +145,7 @@ OTRGlobals::OTRGlobals() { OOT_PAL_11, OOT_NTSC_JP_GC_CE, OOT_NTSC_JP_GC, OOT_NTSC_US_GC, OOT_PAL_GC, OOT_PAL_GC_DBG1, OOT_PAL_GC_DBG2 }; // tell LUS to reserve 3 SoH specific threads (Game, Audio, Save) - context = Ship::Context::CreateInstance("2 Ship 2 Harkinian", appShortName, "2ship2harkinian.json", OTRFiles, {}, 3); + context = Ship::Context::CreateInstance("2 Ship 2 Harkinian", appShortName, "2ship2harkinian.json", archiveFiles, {}, 3); // Override LUS defaults Ship::Context::GetInstance()->GetLogger()->set_level((spdlog::level::level_enum)CVarGetInteger("gDeveloperTools.LogLevel", 1)); @@ -397,7 +406,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()