about summary refs log tree commit diff stats
path: root/apworld/__init__.py
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2025-09-25 14:14:22 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2025-09-25 14:14:22 -0400
commitcb2eca4fed1eb3692eaa13715f65ebcaf8472b64 (patch)
tree7d11ad1db462c0af4de9da02bde8e44899e0e282 /apworld/__init__.py
parent72b9d1f0952aee6e72b9478118dc99e08ff1fa54 (diff)
downloadlingo2-archipelago-cb2eca4fed1eb3692eaa13715f65ebcaf8472b64.tar.gz
lingo2-archipelago-cb2eca4fed1eb3692eaa13715f65ebcaf8472b64.tar.bz2
lingo2-archipelago-cb2eca4fed1eb3692eaa13715f65ebcaf8472b64.zip
Client can be run from zipped apworld now
Diffstat (limited to 'apworld/__init__.py')
-rw-r--r--apworld/__init__.py68
1 files changed, 45 insertions, 23 deletions
diff --git a/apworld/__init__.py b/apworld/__init__.py index 9d7d149..523c00c 100644 --- a/apworld/__init__.py +++ b/apworld/__init__.py
@@ -3,6 +3,7 @@ Archipelago init file for Lingo 2
3""" 3"""
4import asyncio 4import asyncio
5import os.path 5import os.path
6import pkgutil
6import subprocess 7import subprocess
7from typing import ClassVar 8from typing import ClassVar
8 9
@@ -20,29 +21,6 @@ from .version import APWORLD_VERSION
20from ..LauncherComponents import Component, Type, components 21from ..LauncherComponents import Component, Type, components
21 22
22 23
23async def run_game():
24 exe_file = settings.get_settings().lingo2_options.exe_file
25
26 subprocess.Popen(
27 [
28 exe_file,
29 "--scene",
30 Utils.local_path("worlds", "lingo2", "client", "run_from_source.tscn"),
31 "--",
32 Utils.local_path("worlds", "lingo2", "client"),
33 ],
34 cwd=os.path.dirname(exe_file),
35 )
36
37
38async def client_main():
39 Utils.async_start(run_game())
40
41
42def launch_client(*args):
43 asyncio.run(client_main())
44
45
46class Lingo2WebWorld(WebWorld): 24class Lingo2WebWorld(WebWorld):
47 rich_text_options_doc = True 25 rich_text_options_doc = True
48 theme = "grass" 26 theme = "grass"
@@ -183,6 +161,50 @@ class Lingo2World(World):
183 # we are using re_gen_passthrough over modifying the world here due to complexities with ER 161 # we are using re_gen_passthrough over modifying the world here due to complexities with ER
184 return slot_data 162 return slot_data
185 163
164
165async def run_game():
166 exe_file = settings.get_settings().lingo2_options.exe_file
167
168 if Lingo2World.zip_path is not None:
169 # This is a packaged apworld.
170 init_scene = pkgutil.get_data(__name__, "client/run_from_apworld.tscn")
171 init_path = Utils.local_path("data", "lingo2_init.tscn")
172
173 with open(init_path, "wb") as file_handle:
174 file_handle.write(init_scene)
175
176 subprocess.Popen(
177 [
178 exe_file,
179 "--scene",
180 init_path,
181 "--",
182 str(Lingo2World.zip_path.absolute()),
183 ],
184 cwd=os.path.dirname(exe_file),
185 )
186 else:
187 # The world is unzipped and being run in source.
188 subprocess.Popen(
189 [
190 exe_file,
191 "--scene",
192 Utils.local_path("worlds", "lingo2", "client", "run_from_source.tscn"),
193 "--",
194 Utils.local_path("worlds", "lingo2", "client"),
195 ],
196 cwd=os.path.dirname(exe_file),
197 )
198
199
200async def client_main():
201 Utils.async_start(run_game())
202
203
204def launch_client(*args):
205 asyncio.run(client_main())
206
207
186component = Component("Lingo 2 Client", component_type=Type.CLIENT, func=launch_client, 208component = Component("Lingo 2 Client", component_type=Type.CLIENT, func=launch_client,
187 description="Open Lingo 2.") 209 description="Open Lingo 2.")
188components.append(component) 210components.append(component)