Skip to content

Commit

Permalink
main: Query modpacks to load on startup.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Aug 29, 2023
1 parent f29dcd0 commit f4b0a4b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
21 changes: 21 additions & 0 deletions openage/convert/service/init/modpack_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,24 @@ def get_modpack_info(modpack_dir: Directory) -> dict[str, typing.Any]:
dbg("Cannot parse modpack definition file %s; content is not TOML or malformed",
modpack_def)
raise err


def query_modpack(proposals: set[str]) -> str:
"""
Query interactively for a modpack from a selection of proposals.
"""
print("\nPlease select a modpack before starting.")
print("Insert the index of one of the proposals (Default = 0):")

proposals = sorted(proposals)
for index, proposal in enumerate(proposals):
print(f"({index}) {proposal}")

user_selection = input("> ")
if user_selection.isdecimal() and int(user_selection) < len(proposals):
selection = proposals[int(user_selection)]

else:
selection = proposals[0]

return selection
6 changes: 1 addition & 5 deletions openage/game/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def init_subparser(cli: ArgumentParser) -> None:
help="throw exceptions directly from the OpenGL calls")

cli.add_argument(
"--modpacks", nargs="+", type=bytes,
"--modpacks", nargs="+", type=bytes, required=True,
help="list of modpacks to load")


Expand Down Expand Up @@ -86,9 +86,5 @@ def main(args, error):

args.modpacks = mods

else:
# TODO: Select modpacks
pass

# start the game, continue in main_cpp.pyx!
return run_game(args, root)
5 changes: 5 additions & 0 deletions openage/main/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,10 @@ def main(args, error):

args.modpacks = mods

else:
from ..convert.service.init.modpack_search import enumerate_modpacks, query_modpack
avail_modpacks = enumerate_modpacks(asset_path / "converted")
args.modpacks = [query_modpack(avail_modpacks)]

# start the game, continue in main_cpp.pyx!
return run_game(args, root)

0 comments on commit f4b0a4b

Please sign in to comment.