-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemulator_grid.py
53 lines (40 loc) · 1.21 KB
/
emulator_grid.py
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
import subprocess
import threading
from pathlib import Path
import pygetwindow as gw
EMULATORS_PER_ROW = 8
SCREEN_X = 2560
SIZE_X = SCREEN_X // EMULATORS_PER_ROW
SIZE_Y = 240
def start_emulator(boss, port, bizhawk_path, ini_path):
lua_client_path = Path("client.lua").resolve()
return subprocess.Popen(
[
bizhawk_path,
f"--config={ini_path}",
f"--lua={lua_client_path}",
f"--load-slot={boss}",
"--socket_ip=127.0.0.1",
f"--socket_port={port}",
]
)
def set_emulator_grid(n):
windows = []
while len(windows) != n:
windows = gw.getWindowsWithTitle("[PlayStation] - BizHawk")
for position, window in enumerate(windows):
thread = threading.Thread(
target=set_single_emulator,
args=(position, window),
daemon=True,
)
thread.start()
def set_single_emulator(position, window: gw.Win32Window, resize=False):
x = (position % EMULATORS_PER_ROW) * SIZE_X
y = (position // EMULATORS_PER_ROW) * SIZE_Y
window.restore()
if resize:
window.resizeTo(SIZE_X, SIZE_Y)
window.moveTo(x, y)
if __name__ == "__main__":
set_emulator_grid()