supertux_arguments.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Flexlay - A Generic 2D Game Editor
  2. # Copyright (C) 2015 Karkus476 <karkus476@yahoo.com>
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. from typing import Optional
  17. from flexlay.util.config import Config
  18. class SuperTuxArguments:
  19. """A container for the various command line arguments of the SuperTux binary (not supertux-editor!)"""
  20. def __init__(self) -> None:
  21. self.run_level: Optional[str] = None
  22. # Not the same as a spawn point
  23. # Currently does nothing.
  24. self.spawn_at: Optional[str] = None
  25. self.record_demo_file: Optional[str] = None
  26. self.play_demo_file: Optional[str] = None
  27. def get_popen_arg(self) -> list[str]:
  28. """Returns a list to be passed straight into subprocess.Popen
  29. :return: A list to be passed as an argument for Popen
  30. """
  31. run_level = [self.run_level]
  32. play_demo = ["--play-demo", self.play_demo_file] if self.record_demo_file is not None else []
  33. record_demo = ["--record-demo", self.record_demo_file] if self.record_demo_file is not None else []
  34. developer_mode = ["--developer"]
  35. # Not implemented in SuperTux!
  36. # spawn_at = ["--spawn-pos",
  37. # str(self.spawn_at.x), ",",
  38. # str(self.spawn_at.y)] \
  39. # if self.spawn_at is not None \
  40. # else []
  41. assert Config.current is not None
  42. return [Config.current.binary] + run_level + play_demo + record_demo + developer_mode # + spawn_at
  43. # EOF #