diff --git a/TowerForge/TowerForge/AppMain/Application/AppDelegate.swift b/TowerForge/TowerForge/AppMain/Application/AppDelegate.swift index 8c99fa3..504e322 100644 --- a/TowerForge/TowerForge/AppMain/Application/AppDelegate.swift +++ b/TowerForge/TowerForge/AppMain/Application/AppDelegate.swift @@ -39,6 +39,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // Games should use this method to pause the game. /// TODO: ADD PAUSE METHOD HERE + guard let navigationController = window?.rootViewController as? UINavigationController, + let gameViewController = navigationController.topViewController as? GameViewController else { + return + } + + if gameViewController.roomId != nil { + gameViewController.onMenu() + } else { + gameViewController.pause() + } } func applicationDidEnterBackground(_ application: UIApplication) { diff --git a/TowerForge/TowerForge/GameViewController.swift b/TowerForge/TowerForge/GameViewController.swift index 5db75a8..7c94b7e 100644 --- a/TowerForge/TowerForge/GameViewController.swift +++ b/TowerForge/TowerForge/GameViewController.swift @@ -19,8 +19,7 @@ class GameViewController: UIViewController { @IBOutlet private var gamePopupButton: UIButton! @IBAction private func onStatePressed(_ sender: Any) { - isPaused = (roomId == nil && currentPlayer == nil) // Allow pausing only on singleplayer. - gameWorld?.presentStatePopup() + self.pause() } override func viewDidLoad() { @@ -64,6 +63,11 @@ class GameViewController: UIViewController { self.gameWorld?.delegate = self self.gameWorld?.statePopupDelegate = self } + + func pause() { + isPaused = (roomId == nil && currentPlayer == nil) // Allow pausing only on singleplayer. + gameWorld?.presentStatePopup() + } } extension GameViewController: SceneUpdateDelegate {