-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ship of Harkinian 2.sh
98 lines (84 loc) · 3.01 KB
/
Ship of Harkinian 2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
if [ -d "/opt/system/Tools/PortMaster/" ]; then
controlfolder="/opt/system/Tools/PortMaster"
elif [ -d "/opt/tools/PortMaster/" ]; then
controlfolder="/opt/tools/PortMaster"
elif [ -d "$XDG_DATA_HOME/PortMaster/" ]; then
controlfolder="$XDG_DATA_HOME/PortMaster"
else
controlfolder="/roms/ports/PortMaster"
fi
source $controlfolder/control.txt
[ -f "${controlfolder}/mod_${CFW_NAME}.txt" ] && source "${controlfolder}/mod_${CFW_NAME}.txt"
get_controls
# Set variables
GAMEDIR="/$directory/ports/soh2"
# Exports
export LD_LIBRARY_PATH="$GAMEDIR/libs:$LD_LIBRARY_PATH"
export SDL_GAMECONTROLLERCONFIG=$sdl_controllerconfig
export PATCHER_FILE="$GAMEDIR/assets/extractor/otrgen"
export PATCHER_GAME="$(basename "${0%.*}")" # This gets the current script filename without the extension
export PATCHER_TIME="5 to 10 minutes"
# CD and set permissions
cd $GAMEDIR
> "$GAMEDIR/log.txt" && exec > >(tee "$GAMEDIR/log.txt") 2>&1
$ESUDO chmod +x -R $GAMEDIR/*
# Check imgui.ini and modify if needed
input_file="imgui.ini"
temp_file="imgui_temp.ini"
skip_section=0
# Loop through each line in the input file
while IFS= read -r line; do
# Check if the line is a window header
if [[ "$line" =~ ^\[Window\]\[Main\ Game\] || "$line" =~ ^\[Window\]\[Main\ -\ Deck\] ]]; then
skip_section=1 # Set the flag to skip modifications for this section
elif [[ "$line" =~ ^\[Window\] ]]; then
skip_section=0 # Reset the flag for other windows
fi
# Modify Pos and Size only if the current section is not skipped
if [[ $skip_section -eq 0 ]]; then
if [[ "$line" =~ ^Pos=.* ]]; then
echo "Pos=30,30" >> "$temp_file"
elif [[ "$line" =~ ^Size=.* ]]; then
echo "Size=400,300" >> "$temp_file"
else
echo "$line" >> "$temp_file"
fi
else
# If skipping, write the line unchanged
echo "$line" >> "$temp_file"
fi
done < "$input_file"
# Replace the original file with the modified one
mv "$temp_file" "$input_file"
# List of compatibility firmwares
CFW_NAMES="ArkOS:ArkOS wuMMLe:ArkOS AeUX:knulli:TrimUI"
# Check if we need to generate any o2r files
if [ ! -f "mm.o2r" ]; then
# Ensure we have a rom file before attempting to generate o2r
if ls *.*64 1> /dev/null 2>&1; then
if [ -f "$controlfolder/utils/patcher.txt" ]; then
source "$controlfolder/utils/patcher.txt"
$ESUDO kill -9 $(pidof gptokeyb)
else
echo "This port requires the latest version of PortMaster." > $CUR_TTY
fi
else
echo "Missing ROM files! Can't generate o2r!"
fi
fi
# Check if OTR files were generated
if [ ! -f "mm.o2r" ]; then
echo "No o2r found, can't run the game!"
exit 1
fi
# Run the game
echo "Loading, please wait... (might take a while!)" > $CUR_TTY
$GPTOKEYB "2s2h.elf" -c "soh2.gptk" &
./2s2h.elf
# Cleanup
rm -rf "$GAMEDIR/logs/"
$ESUDO systemctl restart oga_events &
printf "\033c" >> /dev/tty1
printf "\033c" > /dev/tty0