select_troops.py 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # coding: utf-8
  2. import argparse
  3. import typing
  4. from tkinter import Tk
  5. from synergine2.config import Config
  6. from opencombat.strategy.manager import TroopManager
  7. from opencombat.strategy.selection.gui import SelectTroopsGui
  8. def main(
  9. units_file_path: str,
  10. teams_file_path: str,
  11. countries: typing.List[str],
  12. troops_dir_path: str = '.',
  13. ) -> None:
  14. config = Config()
  15. config.load_yaml('config.yaml')
  16. troop_manager = TroopManager(
  17. config,
  18. units_file_path=units_file_path,
  19. teams_file_path=teams_file_path,
  20. )
  21. master = Tk()
  22. gui = SelectTroopsGui(
  23. config,
  24. master=master,
  25. team_stash=troop_manager.team_stash,
  26. troop_manager=troop_manager,
  27. countries=countries,
  28. troops_dir_path=troops_dir_path,
  29. )
  30. master.mainloop()
  31. if __name__ == '__main__':
  32. parser = argparse.ArgumentParser(
  33. description='Display troops selection gui',
  34. )
  35. parser.add_argument(
  36. '--units',
  37. dest='units_file_path',
  38. default='opencombat/strategy/units.xml',
  39. )
  40. parser.add_argument(
  41. '--teams',
  42. dest='teams_file_path',
  43. default='opencombat/strategy/teams.xml',
  44. )
  45. parser.add_argument(
  46. '--country',
  47. action='append',
  48. dest='countries',
  49. )
  50. parser.add_argument(
  51. '--troops-dir-path',
  52. dest='troops_dir_path',
  53. default='.',
  54. )
  55. args = parser.parse_args()
  56. main(
  57. units_file_path=args.units_file_path,
  58. teams_file_path=args.teams_file_path,
  59. countries=args.countries,
  60. troops_dir_path=args.troops_dir_path,
  61. )