mirror of
https://github.com/HarbourMasters/2ship2harkinian.git
synced 2024-11-23 05:59:40 +00:00
Export as o2r and support multiple extension types (#484)
This commit is contained in:
parent
5e60ece459
commit
01901ddf26
10
.github/workflows/main.yml
vendored
10
.github/workflows/main.yml
vendored
@ -159,8 +159,8 @@ jobs:
|
||||
# cmake --build build-cmake --config Release --target Generate2ShipOtr -j3
|
||||
# - uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: 2ship.zip
|
||||
# path: 2ship.zip
|
||||
# name: 2ship.o2r
|
||||
# path: 2ship.o2r
|
||||
# retention-days: 1
|
||||
|
||||
# build-macos:
|
||||
@ -203,7 +203,7 @@ jobs:
|
||||
# - name: Download 2ship.o2r
|
||||
# uses: actions/download-artifact@v4
|
||||
# with:
|
||||
# name: 2ship.zip
|
||||
# name: 2ship.o2r
|
||||
# path: build-cmake/mm
|
||||
# - name: Build 2Ship
|
||||
# run: |
|
||||
@ -293,7 +293,7 @@ jobs:
|
||||
# - name: Download 2ship.o2r
|
||||
# uses: actions/download-artifact@v4
|
||||
# with:
|
||||
# name: 2ship.zip
|
||||
# name: 2ship.o2r
|
||||
# path: build-cmake/mm
|
||||
- name: Build 2Ship
|
||||
run: |
|
||||
@ -368,7 +368,7 @@ jobs:
|
||||
# - name: Download 2ship.o2r
|
||||
# uses: actions/download-artifact@v4
|
||||
# with:
|
||||
# name: 2ship.zip
|
||||
# name: 2ship.o2r
|
||||
# path: build-windows/mm
|
||||
# - name: Build 2Ship
|
||||
# env:
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,7 @@
|
||||
*.zip
|
||||
*.otr
|
||||
*.o2r
|
||||
.DS_Store
|
||||
.vscode
|
||||
*.swp
|
||||
logs
|
||||
|
@ -111,7 +111,7 @@ set_property(TARGET 2ship PROPERTY APPIMAGE_ICON_FILE "${CMAKE_BINARY_DIR}/2s2hI
|
||||
|
||||
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
install(PROGRAMS "${CMAKE_BINARY_DIR}/linux/2s2h.sh" DESTINATION . COMPONENT appimage)
|
||||
install(FILES "${CMAKE_SOURCE_DIR}/2ship.zip" DESTINATION . COMPONENT ship)
|
||||
install(FILES "${CMAKE_SOURCE_DIR}/2ship.o2r" 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)
|
||||
@ -136,13 +136,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 $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f mm.zip 2ship.zip
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --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} -E $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f mm.zip 2ship.o2r
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --non-interactive --xml-root ../mm/assets/xml --custom-otr-file 2ship.o2r "--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="$<TARGET_FILE_DIR:ZAPD>" -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.zip ${CMAKE_SOURCE_DIR}/mm.zip ${CMAKE_SOURCE_DIR}/2ship.zip
|
||||
BYPRODUCTS mm.zip ${CMAKE_SOURCE_DIR}/mm.o2r ${CMAKE_SOURCE_DIR}/2ship.o2r
|
||||
)
|
||||
|
||||
# Target to generate headers
|
||||
@ -154,15 +154,15 @@ add_custom_target(
|
||||
DEPENDS ZAPD
|
||||
)
|
||||
|
||||
# Target to generate only 2ship.zip
|
||||
# Target to generate only 2ship.o2r
|
||||
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 $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f 2ship.zip
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --norom --custom-otr-file 2ship.zip "--custom-assets-path" ${CMAKE_CURRENT_SOURCE_DIR}/mm/assets/custom --port-ver "${CMAKE_PROJECT_VERSION}"
|
||||
COMMAND ${CMAKE_COMMAND} -E $<IF:$<VERSION_LESS:${CMAKE_VERSION},3.17>,remove,rm> -f 2ship.o2r
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/OTRExporter/extract_assets.py -z "$<TARGET_FILE:ZAPD>" --norom --custom-otr-file 2ship.o2r "--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="$<TARGET_FILE_DIR:ZAPD>" -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.zip..."
|
||||
COMMENT "Generating 2ship.o2r..."
|
||||
DEPENDS ZAPD
|
||||
)
|
||||
|
||||
|
@ -1,29 +1,30 @@
|
||||
message(STATUS "Copying otr files...")
|
||||
|
||||
# Copy and rename mm.zip to mm.o2r
|
||||
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/)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.zip ${SOURCE_DIR}/mm.o2r)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.zip ${BINARY_DIR}/mm/mm.o2r)
|
||||
message(STATUS "Copied mm.zip")
|
||||
endif()
|
||||
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")
|
||||
if(EXISTS ${SOURCE_DIR}/OTRExporter/2ship.o2r)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy 2ship.o2r ${SOURCE_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy 2ship.o2r ${BINARY_DIR}/mm/)
|
||||
message(STATUS "Copied 2ship.o2r")
|
||||
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.zip)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.zip ${TARGET_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy mm.zip ${TARGET_DIR}/mm.o2r)
|
||||
endif()
|
||||
if(EXISTS ${SOURCE_DIR}/OTRExporter/2ship.zip)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy 2ship.zip ${TARGET_DIR})
|
||||
if(EXISTS ${SOURCE_DIR}/OTRExporter/o2r)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy 2ship.o2r ${TARGET_DIR})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT ONLY2SHIPOTR AND (NOT EXISTS ${SOURCE_DIR}/mm.zip))
|
||||
message(FATAL_ERROR "Failed to copy. No ZIP files found.")
|
||||
if(NOT ONLY2SHIPOTR AND (NOT EXISTS ${SOURCE_DIR}/mm.o2r))
|
||||
message(FATAL_ERROR "Failed to copy. No O2R files found.")
|
||||
endif()
|
||||
if(NOT EXISTS ${SOURCE_DIR}/2ship.zip)
|
||||
message(FATAL_ERROR "Failed to copy. No 2ship ZIP found.")
|
||||
if(NOT EXISTS ${SOURCE_DIR}/2ship.o2r)
|
||||
message(FATAL_ERROR "Failed to copy. No 2ship O2R found.")
|
||||
endif()
|
||||
|
@ -109,29 +109,34 @@ Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 };
|
||||
|
||||
OTRGlobals::OTRGlobals() {
|
||||
std::vector<std::string> archiveFiles;
|
||||
std::string mmPath = Ship::Context::LocateFileAcrossAppDirs("mm.zip", appShortName);
|
||||
if (std::filesystem::exists(mmPath)) {
|
||||
archiveFiles.push_back(mmPath);
|
||||
std::string mmPathO2R = Ship::Context::LocateFileAcrossAppDirs("mm.o2r", appShortName);
|
||||
std::string mmPathZIP = Ship::Context::LocateFileAcrossAppDirs("mm.zip", appShortName);
|
||||
if (std::filesystem::exists(mmPathO2R)) {
|
||||
archiveFiles.push_back(mmPathO2R);
|
||||
} else if (std::filesystem::exists(mmPathZIP)) {
|
||||
archiveFiles.push_back(mmPathZIP);
|
||||
} else {
|
||||
mmPath = Ship::Context::LocateFileAcrossAppDirs("mm.otr", appShortName);
|
||||
std::string mmPath = Ship::Context::LocateFileAcrossAppDirs("mm.otr", appShortName);
|
||||
if (std::filesystem::exists(mmPath)) {
|
||||
archiveFiles.push_back(mmPath);
|
||||
}
|
||||
}
|
||||
std::string shipOtrPath = Ship::Context::GetPathRelativeToAppBundle("2ship.zip");
|
||||
|
||||
std::string shipOtrPath = Ship::Context::GetPathRelativeToAppBundle("2ship.o2r");
|
||||
if (std::filesystem::exists(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(), ".zip")) {
|
||||
if (StringHelper::IEquals(p.path().extension().string(), ".o2r")) {
|
||||
archiveFiles.push_back(p.path().generic_string());
|
||||
} else 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());
|
||||
} else {
|
||||
if (StringHelper::IEquals(p.path().extension().string(), ".otr")) {
|
||||
archiveFiles.push_back(p.path().generic_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -451,20 +456,21 @@ void Ben_ProcessDroppedFiles(std::string filePath) {
|
||||
|
||||
extern "C" void InitOTR() {
|
||||
#if not defined(__SWITCH__) && not defined(__WIIU__)
|
||||
if (!std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs("mm.zip", appShortName)) &&
|
||||
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))) {
|
||||
std::string installPath = Ship::Context::GetAppBundlePath();
|
||||
if (!std::filesystem::exists(installPath + "/assets/extractor")) {
|
||||
Extractor::ShowErrorBox(
|
||||
"Extractor assets not found",
|
||||
"No OTR files found. Missing assets/extractor folder needed to generate OTR file. Exiting...");
|
||||
"No game O2R files found. Missing assets/extractor folder needed to generate O2R file. Exiting...");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (Extractor::ShowYesNoBox("No OTR Files", "No OTR files found. Generate one now?") == IDYES) {
|
||||
if (Extractor::ShowYesNoBox("No O2R Files", "No O2R files found. Generate one now?") == IDYES) {
|
||||
Extractor extract;
|
||||
if (!extract.Run()) {
|
||||
Extractor::ShowErrorBox("Error", "An error occured, no OTR file was generated. Exiting...");
|
||||
Extractor::ShowErrorBox("Error", "An error occurred, no OTR file was generated. Exiting...");
|
||||
exit(1);
|
||||
}
|
||||
extract.CallZapd(installPath, Ship::Context::GetAppDirectoryPath(appShortName));
|
||||
|
@ -548,7 +548,7 @@ bool Extractor::CallZapd(std::string installPath, std::string exportdir) {
|
||||
char portVersion[18]; // 5 digits for int16_max (x3) + separators + terminator
|
||||
std::array<const char*, argc> argv;
|
||||
const char* version = GetZapdVerStr();
|
||||
const char* otrFile = "mm.zip";
|
||||
const char* otrFile = "mm.o2r";
|
||||
|
||||
std::string romPath = std::filesystem::absolute(mCurrentRomPath).string();
|
||||
installPath = std::filesystem::absolute(installPath).string();
|
||||
|
@ -694,7 +694,7 @@ endif()
|
||||
|
||||
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
|
||||
INSTALL(FILES $<TARGET_PDB_FILE:2ship> DESTINATION ./debug COMPONENT 2s2h)
|
||||
INSTALL(FILES ${CMAKE_BINARY_DIR}/mm/2ship.zip DESTINATION . COMPONENT 2s2h)
|
||||
INSTALL(FILES ${CMAKE_BINARY_DIR}/mm/2ship.o2r DESTINATION . COMPONENT 2s2h)
|
||||
endif()
|
||||
|
||||
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
|
||||
@ -708,7 +708,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.zip DESTINATION ../Resources COMPONENT 2s2h)
|
||||
INSTALL(FILES ${CMAKE_BINARY_DIR}/mm/2ship.o2r DESTINATION ../Resources COMPONENT 2s2h)
|
||||
elseif(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "NintendoSwitch|CafeOS")
|
||||
INSTALL(FILES ${CMAKE_BINARY_DIR}/gamecontrollerdb.txt DESTINATION . COMPONENT 2s2h)
|
||||
endif()
|
||||
|
@ -18,7 +18,7 @@ if [[ ! -e "$SHIP_HOME"/mods ]]; then
|
||||
touch "$SHIP_HOME"/mods/custom_mod_files_go_here.txt
|
||||
fi
|
||||
|
||||
while [[ (! -e "$SHIP_HOME"/mm.zip) ]]; do
|
||||
while [[ (! -e "$SHIP_HOME"/mm.o2r) ]]; do
|
||||
for romfile in "$SHIP_HOME"/*.*64
|
||||
do
|
||||
if [[ -e "$romfile" ]] || [[ -L "$romfile" ]]; then
|
||||
@ -60,21 +60,21 @@ while [[ (! -e "$SHIP_HOME"/mm.zip) ]]; do
|
||||
|
||||
case "$ROMHASH" in
|
||||
7f5630dbc4d5d61d6276213210c4d5cdd83a47d6) # uncompressed
|
||||
if [[ ! -e "$SHIP_HOME"/mm.zip ]]; then
|
||||
if [[ ! -e "$SHIP_HOME"/mm.o2r ]]; then
|
||||
ROM=N64_US
|
||||
else
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
d6133ace5afaa0882cf214cf88daba39e266c078) # compressed
|
||||
if [[ ! -e "$SHIP_HOME"/mm.zip ]]; then
|
||||
if [[ ! -e "$SHIP_HOME"/mm.o2r ]]; then
|
||||
ROM=N64_US
|
||||
else
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
9743aa026e9269b339eb0e3044cd5830a440c1fd) # compressed
|
||||
if [[ ! -e "$SHIP_HOME"/mm.zip ]]; then
|
||||
if [[ ! -e "$SHIP_HOME"/mm.o2r ]]; then
|
||||
ROM=GC_US
|
||||
else
|
||||
continue
|
||||
@ -84,18 +84,18 @@ while [[ (! -e "$SHIP_HOME"/mm.zip) ]]; do
|
||||
echo -e "\n$romfile - $ROMHASH rom hash does not match\n"
|
||||
continue;;
|
||||
esac
|
||||
if [[ ! -e "$SHIP_HOME"/mm.zip ]]; then
|
||||
if [[ ! -e "$SHIP_HOME"/mm.o2r ]]; then
|
||||
if [ -n "$ZENITY" ]; then
|
||||
(echo "# 25%"; echo "25"; sleep 2; echo "# 50%"; echo "50"; sleep 3; echo "# 75%"; echo "75"; sleep 2; echo "# 100%"; echo "100"; sleep 3) |
|
||||
zenity --progress --title="OTR Generating..." --timeout=10 --percentage=0 --icon-name=2s2h --window-icon=2s2h.png --height=80 --width=400 &
|
||||
else
|
||||
echo "Processing..."
|
||||
fi
|
||||
assets/extractor/ZAPD.out ed -eh -i assets/extractor/xmls/"${ROM}" -b tmp/rom.z64 -fl assets/extractor/filelists -o placeholder -osf placeholder -gsf 1 -rconf assets/extractor/Config_"${ROM}".xml -se OTR --otrfile mm.zip --portVer "@CMAKE_PROJECT_VERSION@" > /dev/null 2>&1
|
||||
cp "$ASSETDIR"/mm.zip "$SHIP_HOME"
|
||||
assets/extractor/ZAPD.out ed -eh -i assets/extractor/xmls/"${ROM}" -b tmp/rom.z64 -fl assets/extractor/filelists -o placeholder -osf placeholder -gsf 1 -rconf assets/extractor/Config_"${ROM}".xml -se OTR --otrfile mm.o2r --portVer "@CMAKE_PROJECT_VERSION@" > /dev/null 2>&1
|
||||
cp "$ASSETDIR"/mm.o2r "$SHIP_HOME"
|
||||
fi
|
||||
else
|
||||
if [[ (! -e "$SHIP_HOME"/mm.zip) ]]; then
|
||||
if [[ (! -e "$SHIP_HOME"/mm.o2r) ]]; then
|
||||
if [ -n "$ZENITY" ]; then
|
||||
zenity --error --timeout=5 --text="Place ROM in $SHIP_HOME" --title="Missing ROM file" --width=500 --width=200
|
||||
else
|
||||
@ -105,7 +105,7 @@ while [[ (! -e "$SHIP_HOME"/mm.zip) ]]; do
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [[ (! -e "$SHIP_HOME"/mm.zip) ]]; then
|
||||
if [[ (! -e "$SHIP_HOME"/mm.o2r) ]]; then
|
||||
if [ -n "$ZENITY" ]; then
|
||||
zenity --error --timeout=10 --text="No valid ROMs were provided, No OTR was generated." --title="Incorrect ROM file" --width=500 --width=200
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user