mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-17 23:15:11 -05:00
7b08f98b8c
* Changes OTR Extraction to have specific mq and nonmq paths. Also updates the game to load resources according to whether or not Master Quest or Vanilla is loaded. * Removes unneeded code from the last commit. * Fixes some weird formatting in ZRom.c * Loads oot-mq.otr and patches oot.otr on top, if both are present. If only one or the other are present, it becomes the only and main OTR. * Adds ImGui Logic for whether or an MQ Checkbox. Checkbox checked only specifies whether new saves should be MQ or not. Checkbox is disabled or force-enabled according to which OTRs are loaded. Also as a necessity includes tracking what game versions have been loaded from the OTRs. * Adds MQ settings logic for Randomizer's ImGui menu. * Writes Master Quest dungeons to the spoiler log * Loads MQ Dungeons from spoiler, persists in save, and loads when appropriate. * Adds logic to prevent loading or creating incompatible rando saves. * Fixdes some linux build issues and new rando save issues * Makes appimage create both vanilla and mq otrs If either rom is present, it makes the corresponding OTR. If both are present, it will make both. If one OTR is present but both roms are present, it will create the missing OTR. * Makes it so a randomized save file will not be marked as MQ. * Refactors to load all OTRs from MainPath or a specific list. Also adds the ability to take a std::unordered_set of hashes to validate each OTR's version file against. * Fixes a syntax error * Makes ExtractAssets output Vanilla and MQ OTRs if both roms are present * Fixes asset generation bug. * Partially working fix for dual OTR extract_assets Currently the cmake ExtractAssets target will return with a 1 if you only end up exporting one type of OTR isntead of both. Haven't found a great way to only attempt to copy a file if it exists from within cmake. It does actually correctly copy the OTR that is generated, despite the error from copying the other one. Pushing as is for now but will keep investigating. * Adds oot-mq.otr to the gitignore. * Makes ExtractAssets not fail on only one rom/OTR. * Removes PatchesPath from the constructors requiring OTRFiles vector. * Renames OOT_UNKNOWN to just UNKNOWN to remove OOT specific reference. * Removes randomizing MQ Dungeons and re-disables MQ rando. Doing this so the PR can get merged quicker with just the Dual OTR support and won't need to wait on rando logic to be updated. That will happen in another PR directly after the merge. * Update mac startup script for dual otr * Update soh/macosx/soh-macos.sh * Update soh/macosx/soh-macos.sh * Update soh/macosx/soh-macos.sh * Implements new BinaryReader to fix Linux build issue. BinaryReader itself comes from https://github.com/Moneyl/BinaryTools I added a wrapper to adapt it to the ABI from ZAPD's Binary Reader and add Endianness checking. I also had to copy a handful of other bits and pieces from ZAPD to make it all function as expected. * A few edits to the updatream BinaryReader to compile it on Linux. * Adds the Endianness to the first byte of the version file. * Fixes Jenkins * Addresses some of Kenix's comments * Renames `ReadNullTerminatedString` to `ReadCString` * Refactors Archive::LoadFile into a private method with more arguments. * Removes BitConverter and extends existing endianness.h instead. * Fixes an endianness issue with the version file. Co-authored-by: Garrett Cox <garrettjcox@gmail.com>
163 lines
5.1 KiB
Bash
Executable File
163 lines
5.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
SNAME="$(dirname $0)"
|
|
export DATA_SHARE="$HOME/Library/Application Support/com.shipofharkinian.soh"
|
|
export SNAME
|
|
export RESPATH="${SNAME%/MacOS*}/Resources"
|
|
export LIBPATH="${SNAME%/MacOS*}/Frameworks"
|
|
export DYLD_FALLBACK_LIBRARY_PATH="$LIBPATH"
|
|
|
|
if [ ! -e "$DATA_SHARE" ]; then mkdir "$DATA_SHARE"; fi
|
|
|
|
# If either OTR doesn't exist kick off the OTR gen process
|
|
if [ ! -e "$DATA_SHARE"/oot.otr ] || [ ! -e "$DATA_SHARE"/oot-mq.otr ]; then
|
|
|
|
# If no ROMs exist kick off the file selection prompts
|
|
while [ ! -e "$DATA_SHARE"/*.*64 ] && [ ! -e "$DATA_SHARE"/oot*.otr ]; do
|
|
|
|
SHOULD_PROMPT_FOR_ROM=1
|
|
while [ $SHOULD_PROMPT_FOR_ROM -eq 1 ]; do
|
|
SHOULD_PROMPT_FOR_ROM=0
|
|
# Use osascript to prompt the user to chose a file
|
|
DROPROM=`osascript <<-EOF
|
|
set romFile to choose file of type {"b64","n64","v64","z64"} with prompt "Please select your ROM:"
|
|
return POSIX path of romFile
|
|
EOF`
|
|
|
|
# If no rom was selected, the user cancelled, so exit
|
|
if [[ -z $DROPROM ]] && [[ -z "$UPLOAD_ANOTHER_RESULT" ]]; then
|
|
echo "No ROM selected. Exiting..."
|
|
exit 1
|
|
elif [[ -z $DROPROM ]]; then
|
|
break;
|
|
fi
|
|
|
|
# If an invalid rom was selected, let the user know and ask to try again
|
|
ROMHASH="$(shasum "$DROPROM" | awk '{ print $1 }')"
|
|
case "$ROMHASH" in
|
|
cee6bc3c2a634b41728f2af8da54d9bf8cc14099)
|
|
ROM_TYPE=0;;
|
|
0227d7c0074f2d0ac935631990da8ec5914597b4)
|
|
ROM_TYPE=0;;
|
|
50bebedad9e0f10746a52b07239e47fa6c284d03)
|
|
ROM_TYPE=1;;
|
|
079b855b943d6ad8bd1eb026c0ed169ecbdac7da)
|
|
ROM_TYPE=1;;
|
|
517bd9714c73cb96c21e7c2ef640d7b55186102f)
|
|
ROM_TYPE=1;;
|
|
*)
|
|
TRY_AGAIN_RESULT=`osascript <<-EOF
|
|
set alertText to "Incompatible ROM hash"
|
|
set alertMessage to "Incompatible ROM provided, would you like to try again?"
|
|
return display alert alertText \
|
|
message alertMessage \
|
|
as critical \
|
|
buttons {"Cancel", "Try Again"}
|
|
EOF`
|
|
if [[ "$TRY_AGAIN_RESULT" == "button returned:Try Again" ]]; then
|
|
SHOULD_PROMPT_FOR_ROM=1
|
|
continue;
|
|
else
|
|
echo "No ROM selected. Exiting..."
|
|
exit 1
|
|
fi
|
|
esac
|
|
|
|
cp "$DROPROM" "$DATA_SHARE"
|
|
|
|
# Ask user if they would also like to select the other variant (MQ/Vanilla)
|
|
if [ $ROM_TYPE -eq 0 ] && [[ -z "$UPLOAD_ANOTHER_RESULT" ]]; then
|
|
UPLOAD_ANOTHER_RESULT=`osascript <<-EOF
|
|
set alertText to "Success"
|
|
set alertMessage to "Would you also like to provide a Master Quest ROM?"
|
|
return display alert alertText \
|
|
message alertMessage \
|
|
buttons {"No", "Yes"}
|
|
EOF`
|
|
elif [[ -z "$UPLOAD_ANOTHER_RESULT" ]]; then
|
|
UPLOAD_ANOTHER_RESULT=`osascript <<-EOF
|
|
set alertText to "Success"
|
|
set alertMessage to "Would you also like to provide a Vanilla (Non Master Quest) ROM?"
|
|
return display alert alertText \
|
|
message alertMessage \
|
|
buttons {"No", "Yes"}
|
|
EOF`
|
|
fi
|
|
|
|
if [[ "$UPLOAD_ANOTHER_RESULT" == "button returned:Yes" ]]; then
|
|
UPLOAD_ANOTHER_RESULT="button returned:No"
|
|
SHOULD_PROMPT_FOR_ROM=1
|
|
continue;
|
|
fi
|
|
break
|
|
done
|
|
done
|
|
|
|
# At this point we should now have 1 or more valid roms in $DATA_SHARE directory
|
|
|
|
# Prepare tmp dir
|
|
for ROMPATH in "$DATA_SHARE"/*.*64
|
|
do
|
|
ASSETDIR="$(mktemp -d /tmp/assets-XXXXX)"
|
|
export ASSETDIR
|
|
cp -r "$RESPATH/assets" "$ASSETDIR"
|
|
mkdir -p "$ASSETDIR"/tmp
|
|
mkdir -p "$ASSETDIR"/Extract
|
|
cp "$ROMPATH" "$ASSETDIR"/tmp/rom.z64
|
|
cp -r "$ASSETDIR"/assets/game "$ASSETDIR"/Extract/assets/
|
|
cd "$ASSETDIR" || return
|
|
|
|
# If an invalid rom was detected, let the user know
|
|
ROMHASH="$(shasum "$ASSETDIR"/tmp/rom.z64 | awk '{ print $1 }')"
|
|
case "$ROMHASH" in
|
|
cee6bc3c2a634b41728f2af8da54d9bf8cc14099)
|
|
ROM=GC_NMQ_D
|
|
OTRNAME="oot.otr";;
|
|
0227d7c0074f2d0ac935631990da8ec5914597b4)
|
|
ROM=GC_NMQ_PAL_F
|
|
OTRNAME="oot.otr";;
|
|
50bebedad9e0f10746a52b07239e47fa6c284d03)
|
|
ROM=GC_MQ_D
|
|
OTRNAME="oot-mq.otr";;
|
|
079b855b943d6ad8bd1eb026c0ed169ecbdac7da)
|
|
ROM=GC_MQ_D
|
|
OTRNAME="oot-mq.otr";;
|
|
517bd9714c73cb96c21e7c2ef640d7b55186102f)
|
|
ROM=GC_MQ_D
|
|
OTRNAME="oot-mq.otr";;
|
|
*)
|
|
osascript -e 'display notification "One or more invalid ROM provided" with title "Ship Of Harkinian"'
|
|
rm -r "$ASSETDIR"
|
|
continue;
|
|
esac
|
|
|
|
# Only generate OTR if we don't have on of this type yet
|
|
if [ -e "$DATA_SHARE"/"$OTRNAME" ]; then
|
|
rm -r "$ASSETDIR"
|
|
continue;
|
|
fi
|
|
|
|
osascript -e 'display notification "Generating OTR..." with title "Ship Of Harkinian"'
|
|
assets/extractor/ZAPD.out ed -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
|
|
if [ -e "$ASSETDIR"/oot.otr ]; then
|
|
osascript -e 'display notification "OTR successfully generated" with title "Ship Of Harkinian"'
|
|
cp "$ASSETDIR"/oot.otr "$DATA_SHARE"/"$OTRNAME"
|
|
rm -r "$ASSETDIR"
|
|
fi
|
|
done
|
|
|
|
if [ ! -e "$DATA_SHARE"/oot*.otr ]; then
|
|
osascript -e 'display notification "OTR failed to generate" with title "Ship Of Harkinian"'
|
|
exit 1;
|
|
fi
|
|
fi
|
|
|
|
arch_name="$(uname -m)"
|
|
launch_arch="arm64"
|
|
if [ "${arch_name}" = "x86_64" ] && [ "$(sysctl -in sysctl.proc_translated)" != "1" ]; then
|
|
launch_arch="x86_64"
|
|
fi
|
|
|
|
arch -${launch_arch} "$RESPATH"/soh-macos
|
|
exit
|