diff --git a/ports/push/Push!.sh b/ports/push/Push!.sh new file mode 100755 index 000000000..51af595a3 --- /dev/null +++ b/ports/push/Push!.sh @@ -0,0 +1,80 @@ +#!/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" +getcontrols + +GAMEDIR="/$directory/ports/push" +CONFDIR="$GAMEDIR/conf" +PYXEL_PKG="main.py" + +cd "${GAMEDIR}" + +> "${GAMEDIR}/log.txt" && exec > >(tee "${GAMEDIR}/log.txt") 2>&1 + +mkdir -p "$GAMEDIR/conf" +bind_directories "$HOME/.config/.pyxel/push" "$CONFDIR" + +# Load Pyxel runtime +runtime="pyxel_2.2.8_python_3.11" +export pyxel_dir="$HOME/pyxel" +mkdir -p "${pyxel_dir}" + +# Patch game +if [ -f "./gamedata/push.pyxapp" ]; then + pm_message "Patching game files ..." + unzip "./gamedata/push.pyxapp" -d "./gamedata" + mv ./gamedata/push/{*,.*} ./gamedata/ 2>/dev/null + rmdir ./gamedata/push + rm ./gamedata/push.pyxapp + python patch.py + pm_message "Patching complete" +fi + +if [ ! -f "$controlfolder/libs/${runtime}.squashfs" ]; then + # Check for runtime if not downloaded via PM + if [ ! -f "$controlfolder/harbourmaster" ]; then + pm_message "This port requires the latest PortMaster to run, please go to https://portmaster.games/ for more info." + sleep 5 + exit 1 + fi + + $ESUDO $controlfolder/harbourmaster --quiet --no-check runtime_check "${runtime}.squashfs" +fi + +if [[ "$PM_CAN_MOUNT" != "N" ]]; then + $ESUDO umount "${pyxel_dir}" +fi + +$ESUDO mount "$controlfolder/libs/${runtime}.squashfs" "${pyxel_dir}" + +export SDL_GAMECONTROLLERCONFIG="$sdl_controllerconfig" + +$GPTOKEYB "pyxel" & + +pm_platform_helper "${pyxel_dir}/bin/pyxel" + +# Enable Pyxel virtual env +source "${pyxel_dir}/bin/activate" +export PYTHONHOME="${pyxel_dir}" +export PYTHONPYCACHEPREFIX="${GAMEDIR}/${runtime}.cache" + +"${pyxel_dir}/bin/pyxel" run "${GAMEDIR}/gamedata/${PYXEL_PKG}" + +if [[ "$PM_CAN_MOUNT" != "N" ]]; then + $ESUDO umount "${pyxel_dir}" +fi + +pm_finish diff --git a/ports/push/README.md b/ports/push/README.md new file mode 100644 index 000000000..e06befec0 --- /dev/null +++ b/ports/push/README.md @@ -0,0 +1,12 @@ +## Notes + +Thanks [yuta](https://helpcomputer.itch.io) (HZ3 Software) for creating this fantastic game, which you can download free at [https://yyuta342.itch.io/push](https://yyuta342.itch.io/push) + + +## Controls + +| Button | Action | +| ------ | -------- | +| D-PAD | Movement | +| A | Select | +| Y | Menu | diff --git a/ports/push/gameinfo.xml b/ports/push/gameinfo.xml new file mode 100644 index 000000000..20d6c0849 --- /dev/null +++ b/ports/push/gameinfo.xml @@ -0,0 +1,13 @@ + + + + ./Push!.sh + Push! + A simple game in which you control a rabbit and eat carrots. If there is a hole, you cannot pass through it as it is, so push the rocks to fill the hole and make a path. + 20241212T000000 + yuta + HZ3 Software + Puzzle + ./push/screenshot.png + + diff --git a/ports/push/port.json b/ports/push/port.json new file mode 100644 index 000000000..f42239f04 --- /dev/null +++ b/ports/push/port.json @@ -0,0 +1,28 @@ +{ + "version": 3, + "name": "push.zip", + "items": [ + "Push!.sh", + "push" + ], + "items_opt": null, + "attr": { + "title": "Push!", + "porter": [ + "tabreturn" + ], + "desc": "A simple game in which you control a rabbit and eat carrots. If there is a hole, you cannot pass through it as it is, so push the rocks to fill the hole and make a path.", + "desc_md": null, + "inst": "Download the game free at https://yyuta342.itch.io/push, and place the push.pyxapp file in the push/gamedata folder.", + "inst_md": "Download the game free at [https://yyuta342.itch.io/push](https://yyuta342.itch.io/push), and place the *push.pyxapp* file in the `push/gamedata` folder.", + "genres": [ + "puzzle" + ], + "image": {}, + "rtr": false, + "exp": false, + "runtime": "pyxel_2.2.8_python_3.11.squashfs", + "reqs": [], + "arch": [] + } +} diff --git a/ports/push/push/gamedata/place push.pyxapp here b/ports/push/push/gamedata/place push.pyxapp here new file mode 100644 index 000000000..e69de29bb diff --git a/ports/push/push/patch.py b/ports/push/push/patch.py new file mode 100644 index 000000000..6fc5b4a0d --- /dev/null +++ b/ports/push/push/patch.py @@ -0,0 +1,14 @@ +import re + +s_levels = "./gamedata/s_levels.py" +with open(s_levels, "r") as file: + content = file.read() + +content = re.sub( + r'self\.level_title = f"LEVEL {self\.map_json\[self\.level_index\]\["title"\]}"', + 'level_data = self.map_json[self.level_index]; self.level_title = f"LEVEL {level_data[\'title\']}"', + content, +) + +with open(s_levels, "w") as file: + file.write(content) diff --git a/ports/push/screenshot.png b/ports/push/screenshot.png new file mode 100644 index 000000000..4c7112206 Binary files /dev/null and b/ports/push/screenshot.png differ