-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_level.py
More file actions
98 lines (83 loc) · 2.96 KB
/
Copy pathtest_level.py
File metadata and controls
98 lines (83 loc) · 2.96 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import argparse
import time
from auto_navigate import navigate_to_level
from profiles import (
DEFAULT_TARGET_LEVEL,
WORLD_LABELS,
WORLD_LEVEL_COUNTS,
format_target_level_label,
)
def prompt_for_level_type():
world_options = sorted(WORLD_LABELS.items(), key=lambda item: int(item[0]))
print("Choose a level type:")
for world_id, label in world_options:
count = WORLD_LEVEL_COUNTS.get(world_id, 0)
print(f" {world_id}. {label.title()} ({count} levels)")
while True:
choice = input("Level type: ").strip().lower()
if choice in WORLD_LABELS:
return choice
for world_id, label in world_options:
if choice == label.lower():
return world_id
print("Enter a number like 3 or a name like speed.")
def prompt_for_level_number(world_id):
world_label = WORLD_LABELS.get(world_id, f"mode {world_id}")
max_level = int(WORLD_LEVEL_COUNTS.get(world_id, 1))
print(f"Choose a {world_label} level:")
print(" " + ", ".join(str(level) for level in range(1, max_level + 1)))
while True:
choice = input("Level number: ").strip()
if choice.isdigit():
level = int(choice)
if 1 <= level <= max_level:
return level
print(f"Enter a number from 1 to {max_level}.")
def main():
parser = argparse.ArgumentParser(
description="Launch Fireboy & Watergirl directly into a level for inspection."
)
parser.add_argument("--profile", default="default", help="Named run profile to use")
parser.add_argument("--slot", type=int, help="Window slot for multi-window placement")
parser.add_argument(
"--frame-rate",
type=float,
help="Override the active Ruffle/game FPS for this launch",
)
parser.add_argument(
"--target-level",
help="Level to launch, like 1_1, 2_4, or 3_2",
)
args = parser.parse_args()
target_level = args.target_level
if not target_level:
world_id = prompt_for_level_type()
level_number = prompt_for_level_number(world_id)
target_level = f"{world_id}_{level_number}"
else:
target_level = target_level or DEFAULT_TARGET_LEVEL
process = navigate_to_level(
profile_name=args.profile,
window_slot=args.slot,
frame_rate=args.frame_rate,
target_level=target_level,
)
if not process:
raise SystemExit(1)
print(
f"Preview ready for {format_target_level_label(target_level)}. "
"Leave this window open while you inspect the level. Press Ctrl+C to stop."
)
try:
while process.poll() is None:
time.sleep(1.0)
except KeyboardInterrupt:
if process.poll() is None:
print("Closing the preview window...")
process.terminate()
try:
process.wait(timeout=5)
except Exception:
process.kill()
if __name__ == "__main__":
main()