Skip to content

Commit

Permalink
Merge pull request #1072 from tabreturn/push
Browse files Browse the repository at this point in the history
Push!
  • Loading branch information
Cebion authored Dec 17, 2024
2 parents 3a46f8b + 2d86e97 commit f991546
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 0 deletions.
80 changes: 80 additions & 0 deletions ports/push/Push!.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions ports/push/README.md
Original file line number Diff line number Diff line change
@@ -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 |
13 changes: 13 additions & 0 deletions ports/push/gameinfo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<gameList>
<game>
<path>./Push!.sh</path>
<name>Push!</name>
<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>
<releasedate>20241212T000000</releasedate>
<developer>yuta</developer>
<publisher>HZ3 Software</publisher>
<genre>Puzzle</genre>
<image>./push/screenshot.png</image>
</game>
</gameList>
28 changes: 28 additions & 0 deletions ports/push/port.json
Original file line number Diff line number Diff line change
@@ -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": []
}
}
Empty file.
14 changes: 14 additions & 0 deletions ports/push/push/patch.py
Original file line number Diff line number Diff line change
@@ -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)
Binary file added ports/push/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f991546

Please sign in to comment.