select_troops.py 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. ) -> None:
  13. config = Config()
  14. config.load_yaml('config.yaml')
  15. troop_manager = TroopManager(
  16. config,
  17. units_file_path=units_file_path,
  18. teams_file_path=teams_file_path,
  19. )
  20. master = Tk()
  21. gui = SelectTroopsGui(
  22. config,
  23. master=master,
  24. troop_manager=troop_manager,
  25. )
  26. master.mainloop()
  27. if __name__ == '__main__':
  28. parser = argparse.ArgumentParser(
  29. description='Display troops selection gui',
  30. )
  31. parser.add_argument(
  32. '--units',
  33. dest='units_file_path',
  34. default='opencombat/strategy/units.xml',
  35. )
  36. parser.add_argument(
  37. '--teams',
  38. dest='teams_file_path',
  39. default='opencombat/strategy/teams.xml',
  40. )
  41. parser.add_argument(
  42. '--country',
  43. action='append',
  44. dest='countries',
  45. default=['URSS', 'DE'],
  46. )
  47. args = parser.parse_args()
  48. main(
  49. units_file_path=args.units_file_path,
  50. teams_file_path=args.teams_file_path,
  51. countries=args.countries,
  52. )