client.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from sounds import SoundManager
  2. from state import CSGOState
  3. class Client:
  4. def __init__(self, gui) -> None:
  5. self.gui = gui
  6. self.sounds = SoundManager(self)
  7. self.state = CSGOState(self)
  8. async def update_status(self) -> None:
  9. with self.state.lock:
  10. if self.state.old_state is None:
  11. self.gui.SetStatusText("Waiting for CS:GO...")
  12. elif self.state.old_state.is_ingame:
  13. phase = self.state.old_state.phase
  14. if phase == "unknown":
  15. phase = ""
  16. else:
  17. phase = " (%s)" % phase
  18. self.gui.SetStatusText(
  19. f"Round {self.state.old_state.current_round}{phase}"
  20. )
  21. else:
  22. self.gui.SetStatusText("Not in a match.")
  23. async def reload_sounds(self) -> None:
  24. """Reloads all sounds.
  25. Do not call outside of gui, unless you disable the update sounds button first.
  26. """
  27. await self.sounds.reload()
  28. await self.update_status()
  29. self.gui.updateSoundsBtn.Enable()
  30. self.sounds.play("Round start")