#!/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 GAMEDIR="/${directory}/ports/straywild" CONFDIR="$GAMEDIR/conf" PORTS_ROOT="${GAMEDIR%/straywild}" SAVEDIR="$PORTS_ROOT/saves/straywild" LEGACY_GAMEDIR="$PORTS_ROOT/netfishing" LEGACY_CONFDIR="$LEGACY_GAMEDIR/conf" LEGACY_SAVEDIR="$PORTS_ROOT/saves/netfishing" DATA_BOOTSTRAP_DIR="$CONFDIR/data/godot/app_userdata/straywild" LEGACY_DATA_BOOTSTRAP_DIR="$CONFDIR/data/godot/app_userdata/NETFISHING" GAME_EXECUTABLE="$GAMEDIR/straywild.aarch64" GAME_LAUNCHER="$GAMEDIR/launch-straywild.sh" GPTOKEYB_CONFIG="$GAMEDIR/straywild.gptk" CONTROLLER_MAPPING_FILE="$CONFDIR/cache/controller_mapping.txt" WESTON_DIR="/tmp/straywild-weston" WESTON_RUNTIME="weston_pkg_0.2" HARBOURMASTER="$controlfolder/harbourmaster" mkdir -p "$CONFDIR/data" "$CONFDIR/config" "$CONFDIR/cache" "$WESTON_DIR" chmod +x "$GAME_EXECUTABLE" # A renamed PortMaster entry installs beside the former NETfishing port. Copy # its device-local configuration once and continue using its established save # root when present. New installations use straywild paths exclusively. if [ -d "$LEGACY_CONFDIR" ] && [ ! -f "$CONFDIR/.netfishing-imported" ]; then cp -a "$LEGACY_CONFDIR/." "$CONFDIR/" touch "$CONFDIR/.netfishing-imported" fi if [ ! -f "$SAVEDIR/straywild_data.json" ] \ && [ ! -f "$SAVEDIR/netfishing_data.json" ] \ && { [ -f "$LEGACY_SAVEDIR/straywild_data.json" ] \ || [ -f "$LEGACY_SAVEDIR/netfishing_data.json" ]; }; then SAVEDIR="$LEGACY_SAVEDIR" fi # straywild uses a predictable save directory beside the port instead of # presenting a folder picker on a small screen. Preserve an established # data-root choice when upgrading an existing installation. straywild_DATA_ENVIRONMENT=() if [ -f "$SAVEDIR/straywild_data.json" ] \ || [ -f "$SAVEDIR/netfishing_data.json" ] || { [ ! -f "$DATA_BOOTSTRAP_DIR/data_root_bootstrap.json" ] && [ ! -f "$DATA_BOOTSTRAP_DIR/data_root_bootstrap.json.backup" ] && [ ! -f "$LEGACY_DATA_BOOTSTRAP_DIR/data_root_bootstrap.json" ] && [ ! -f "$LEGACY_DATA_BOOTSTRAP_DIR/data_root_bootstrap.json.backup" ] }; then mkdir -p "$SAVEDIR" straywild_DATA_ENVIRONMENT+=( "straywild_DATA_DIR=$SAVEDIR" "straywild_CREATE_DATA_DIR=1" ) fi > "$GAMEDIR/log.txt" && exec > >(tee "$GAMEDIR/log.txt") 2>&1 if [ ! -f "$controlfolder/libs/${WESTON_RUNTIME}.squashfs" ]; then if [ ! -x "$HARBOURMASTER" ]; then pm_message "straywild requires the latest PortMaster and WestonPack runtime." sleep 5 exit 1 fi $ESUDO "$HARBOURMASTER" --quiet --no-check runtime_check "${WESTON_RUNTIME}.squashfs" fi if [ ! -f "$controlfolder/libs/${WESTON_RUNTIME}.squashfs" ]; then pm_message "WestonPack could not be installed. Check the network connection and PortMaster runtime manager." sleep 5 exit 1 fi if [[ "$PM_CAN_MOUNT" != "N" ]]; then $ESUDO umount "$WESTON_DIR" 2>/dev/null fi $ESUDO mount "$controlfolder/libs/${WESTON_RUNTIME}.squashfs" "$WESTON_DIR" cd "$GAMEDIR" || exit 1 # Godot 4.7 identifies the muOS H700 virtual controller with a CRC-bearing # GUID and numbers its buttons without the volume keys exposed by SDL2. The # PortMaster SDL2 database entry therefore cannot drive Godot's gamepad layer. GODOT_MUOS_MAPPING="19004ca6010000000100000000010000,muOS-Keys,a:b0,b:b1,x:b3,y:b2,leftshoulder:b4,rightshoulder:b5,lefttrigger:b10,righttrigger:b11,guide:b8,start:b7,back:b6,dpup:h0.1,dpleft:h0.8,dpright:h0.2,dpdown:h0.4,leftx:a0,lefty:a1,leftstick:b9,rightx:a2,righty:a3,rightstick:b12,platform:Linux," MUOS_SDL2_GUID="19000000010000000100000000010000" if [[ "$sdl_controllerconfig" == "${MUOS_SDL2_GUID},"* ]]; then straywild_controllerconfig="$GODOT_MUOS_MAPPING" elif [ -n "$sdl_controllerconfig" ]; then straywild_controllerconfig="$sdl_controllerconfig" else straywild_controllerconfig="$GODOT_MUOS_MAPPING" fi printf '%s\n' "$straywild_controllerconfig" > "$CONTROLLER_MAPPING_FILE" straywild_GODOT_OPTIONS=() straywild_GAME_ENVIRONMENT=() PERFORMANCE_PROFILE="${straywild_PERFORMANCE_PROFILE:-}" PROFILE_PATH="$CONFDIR/performance_profile" if [[ -z "$PERFORMANCE_PROFILE" && -r "$PROFILE_PATH" ]]; then IFS= read -r PERFORMANCE_PROFILE < "$PROFILE_PATH" || true PERFORMANCE_PROFILE="${PERFORMANCE_PROFILE%$'\r'}" fi case "$PERFORMANCE_PROFILE" in normal) straywild_GAME_ENVIRONMENT+=( "straywild_PERFORMANCE_PROFILE=normal" ) ;; light|"") straywild_GAME_ENVIRONMENT+=( "straywild_PERFORMANCE_PROFILE=light" "straywild_LOW_END=1" ) straywild_GODOT_OPTIONS+=( --single-window --disable-vsync --max-fps 30 --audio-output-latency 40 ) ;; *) echo "Unknown performance profile '$PERFORMANCE_PROFILE'; using light." >&2 straywild_GAME_ENVIRONMENT+=( "straywild_PERFORMANCE_PROFILE=light" "straywild_LOW_END=1" ) straywild_GODOT_OPTIONS+=( --single-window --disable-vsync --max-fps 30 --audio-output-latency 40 ) ;; esac # straywild reads gameplay input natively. The explicit no-op map prevents # GPTOKEYB from injecting duplicate keyboard or mouse input while retaining # its device-specific force-quit chord, including on ROCKNIX. $GPTOKEYB "straywild.aarch64" -c "$GPTOKEYB_CONFIG" & pm_platform_helper "$GAME_EXECUTABLE" $ESUDO env CRUSTY_RESOLUTION="${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" \ "$WESTON_DIR/westonwrap.sh" headless noop kiosk crusty_x11egl \ XDG_DATA_HOME="$CONFDIR/data" \ XDG_CONFIG_HOME="$CONFDIR/config" \ XDG_CACHE_HOME="$CONFDIR/cache" \ GODOT_SILENCE_ROOT_WARNING=1 \ "${straywild_DATA_ENVIRONMENT[@]}" \ "${straywild_GAME_ENVIRONMENT[@]}" \ "$GAME_LAUNCHER" \ "$CONTROLLER_MAPPING_FILE" \ "$GAME_EXECUTABLE" \ "${straywild_GODOT_OPTIONS[@]}" \ --resolution "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" \ --fullscreen \ --rendering-driver opengl3_es \ --audio-driver ALSA $ESUDO "$WESTON_DIR/westonwrap.sh" cleanup if [[ "$PM_CAN_MOUNT" != "N" ]]; then $ESUDO umount "$WESTON_DIR" 2>/dev/null fi pm_finish