1:1 source port of the engine and game code; Windows build and system layer; docs. No game files or SDK headers.

This commit is contained in:
CRTkafa 2026-10-22 16:30:40 +08:00
parent c3b032a45a
commit 0ecb47e9cb
3871 changed files with 91080 additions and 1640063 deletions

View file

@ -0,0 +1,50 @@
"""Replay a parity script against the original game running under Wine.
usage: python3 orig_replay.py SCRIPT OUTDIR
Script commands: move x y | click x y | down x y | up x y | key NAME | text STR | wait MS | shot NAME
Input goes through pfinput.exe (window messages + virtual cursor); the host mouse is never touched.
Shots are raw 1600x1200 (Retina) PNGs captured from the game window with screencapture.
"""
import os, subprocess, sys
HERE = os.path.dirname(os.path.abspath(__file__))
PREFIX = os.path.expanduser('~/.wine-choc3')
WINE = os.path.expanduser('~/Applications/Wine Devel.app/Contents/Resources/wine/bin/wine')
ENV = dict(os.environ, WINEPREFIX=PREFIX, WINEDEBUG='-all', MVK_CONFIG_LOG_LEVEL='0')
VK = {'escape': 27, 'return': 13, 'backspace': 8, 'space': 32}
def window_id():
out = subprocess.run(['swift', os.path.join(HERE, 'wins.swift')], capture_output=True, text=True).stdout
for line in out.splitlines():
if 'Chocolatier: Decadence by Design' in line:
return line.split()[0]
sys.exit('original game window not found')
def send(args):
if args:
subprocess.run([WINE, 'C:\\Games\\pfinput.exe', *args], env=ENV, capture_output=True)
def shot(outdir, name):
path = os.path.join(outdir, name + '.png')
subprocess.run(['screencapture', '-x', '-o', '-l', window_id(), path], check=True)
def main(script, outdir):
os.makedirs(outdir, exist_ok=True)
pending = ['activate', 'wait', '300'] # the game ignores input until it believes it is active
for raw in open(script):
cmd = raw.split()
if not cmd or cmd[0].startswith('#'):
continue
if cmd[0] == 'shot':
send(pending); pending = []
shot(outdir, cmd[1])
elif cmd[0] == 'key':
pending += ['key', str(VK[cmd[1]])]
elif cmd[0] == 'activate':
pending += ['activate']
else:
pending += cmd
send(pending)
if __name__ == '__main__':
main(sys.argv[1], sys.argv[2])