Refactors LaunchViewController into RSTLaunchViewController subclass
This commit is contained in:
parent
c1cfdad0a7
commit
4c913d5be0
@ -36,11 +36,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate
|
||||
gestureRecognizer.delaysTouchesBegan = false
|
||||
}
|
||||
|
||||
// Database
|
||||
DatabaseManager.shared.start { (error) in
|
||||
print("Database started with error:", error as Any)
|
||||
}
|
||||
|
||||
// Controllers
|
||||
ExternalGameControllerManager.shared.startMonitoring()
|
||||
|
||||
|
||||
@ -74,6 +74,8 @@ final class DatabaseManager: RSTPersistentContainer
|
||||
else { fatalError("Core Data model cannot be found. Aborting.") }
|
||||
|
||||
super.init(name: "Delta", managedObjectModel: harmonyModel)
|
||||
|
||||
self.shouldAddStoresAsynchronously = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
import UIKit
|
||||
import Roxas
|
||||
|
||||
class LaunchViewController: UIViewController
|
||||
class LaunchViewController: RSTLaunchViewController
|
||||
{
|
||||
@IBOutlet private var gameViewContainerView: UIView!
|
||||
private var gameViewController: GameViewController!
|
||||
@ -37,12 +37,39 @@ class LaunchViewController: UIViewController
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(LaunchViewController.deepLinkControllerLaunchGame(with:)), name: .deepLinkControllerLaunchGame, object: nil)
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool)
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
|
||||
{
|
||||
super.viewDidAppear(animated)
|
||||
guard segue.identifier == "embedGameViewController" else { return }
|
||||
|
||||
if !self.presentedGameViewController
|
||||
self.gameViewController = segue.destination as? GameViewController
|
||||
}
|
||||
}
|
||||
|
||||
extension LaunchViewController
|
||||
{
|
||||
override var launchConditions: [RSTLaunchCondition] {
|
||||
let isDatabaseManagerStarted = RSTLaunchCondition(condition: { DatabaseManager.shared.isStarted }) { (completionHandler) in
|
||||
DatabaseManager.shared.start(completionHandler: completionHandler)
|
||||
}
|
||||
|
||||
return [isDatabaseManagerStarted, isDatabaseManagerStarted]
|
||||
}
|
||||
|
||||
override func handleLaunchError(_ error: Error)
|
||||
{
|
||||
let alertController = UIAlertController(title: NSLocalizedString("Unable to Launch Delta", comment: ""), message: error.localizedDescription, preferredStyle: .alert)
|
||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("Retry", comment: ""), style: .default, handler: { (action) in
|
||||
self.handleLaunchConditions()
|
||||
}))
|
||||
self.present(alertController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
override func finishLaunching()
|
||||
{
|
||||
super.finishLaunching()
|
||||
|
||||
guard !self.presentedGameViewController else { return }
|
||||
|
||||
self.presentedGameViewController = true
|
||||
|
||||
func showGameViewController()
|
||||
@ -69,14 +96,6 @@ class LaunchViewController: UIViewController
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
|
||||
{
|
||||
guard segue.identifier == "embedGameViewController" else { return }
|
||||
|
||||
self.gameViewController = segue.destination as? GameViewController
|
||||
}
|
||||
}
|
||||
|
||||
private extension LaunchViewController
|
||||
|
||||
Loading…
Reference in New Issue
Block a user