Adds support for WarioWare: Twisted!
This commit is contained in:
parent
803d180a9b
commit
f4374ed54a
@ -1 +1 @@
|
|||||||
Subproject commit 9053c5f295f9d3dd66eb37a1b581a8cdfb6ba3f1
|
Subproject commit acbcf2baf8f01302f2a7c6e60783b887160aa163
|
||||||
@ -9,6 +9,7 @@
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
import DeltaCore
|
import DeltaCore
|
||||||
|
import GBADeltaCore
|
||||||
|
|
||||||
import Roxas
|
import Roxas
|
||||||
|
|
||||||
@ -70,6 +71,8 @@ class GameViewController: DeltaCore.GameViewController
|
|||||||
|
|
||||||
self.updateControllerSkin()
|
self.updateControllerSkin()
|
||||||
self.updateControllers()
|
self.updateControllers()
|
||||||
|
|
||||||
|
self.presentedGyroAlert = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,6 +125,13 @@ class GameViewController: DeltaCore.GameViewController
|
|||||||
private var sustainButtonsBlurView: UIVisualEffectView!
|
private var sustainButtonsBlurView: UIVisualEffectView!
|
||||||
private var sustainButtonsBackgroundView: RSTPlaceholderView!
|
private var sustainButtonsBackgroundView: RSTPlaceholderView!
|
||||||
|
|
||||||
|
private var isGyroActive = false
|
||||||
|
private var presentedGyroAlert = false
|
||||||
|
|
||||||
|
override var shouldAutorotate: Bool {
|
||||||
|
return !self.isGyroActive
|
||||||
|
}
|
||||||
|
|
||||||
required init()
|
required init()
|
||||||
{
|
{
|
||||||
super.init()
|
super.init()
|
||||||
@ -142,9 +152,14 @@ class GameViewController: DeltaCore.GameViewController
|
|||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.updateControllers), name: .externalGameControllerDidConnect, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.updateControllers), name: .externalGameControllerDidConnect, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.updateControllers), name: .externalGameControllerDidDisconnect, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.updateControllers), name: .externalGameControllerDidDisconnect, object: nil)
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.didEnterBackground(with:)), name: UIApplication.didEnterBackgroundNotification, object: UIApplication.shared)
|
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.didEnterBackground(with:)), name: UIApplication.didEnterBackgroundNotification, object: UIApplication.shared)
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.settingsDidChange(with:)), name: .settingsDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.settingsDidChange(with:)), name: .settingsDidChange, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.deepLinkControllerLaunchGame(with:)), name: .deepLinkControllerLaunchGame, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.deepLinkControllerLaunchGame(with:)), name: .deepLinkControllerLaunchGame, object: nil)
|
||||||
|
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.didActivateGyro(with:)), name: GBA.didActivateGyroNotification, object: nil)
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(GameViewController.didDeactivateGyro(with:)), name: GBA.didDeactivateGyroNotification, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit
|
deinit
|
||||||
@ -986,4 +1001,46 @@ private extension GameViewController
|
|||||||
|
|
||||||
self.dismiss(animated: true, completion: nil)
|
self.dismiss(animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func didActivateGyro(with notification: Notification)
|
||||||
|
{
|
||||||
|
self.isGyroActive = true
|
||||||
|
|
||||||
|
guard !self.presentedGyroAlert else { return }
|
||||||
|
|
||||||
|
self.presentedGyroAlert = true
|
||||||
|
|
||||||
|
func presentToastView()
|
||||||
|
{
|
||||||
|
let toastView = RSTToastView(text: NSLocalizedString("Autorotation Disabled", comment: ""), detailText: NSLocalizedString("Pause game to change orientation.", comment: ""))
|
||||||
|
toastView.textLabel.textAlignment = .center
|
||||||
|
toastView.presentationEdge = .bottom
|
||||||
|
|
||||||
|
if let traits = self.controllerView.controllerSkinTraits, traits.orientation == .landscape, self.controllerView?.controllerSkin?.gameScreenFrame(for: traits) == nil
|
||||||
|
{
|
||||||
|
// Only change landscape vertical offset if there is no custom game screen frame for the current controller skin.
|
||||||
|
toastView.edgeOffset.vertical = 30
|
||||||
|
}
|
||||||
|
|
||||||
|
toastView.show(in: self.gameView, duration: 3.0)
|
||||||
|
}
|
||||||
|
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
if let transitionCoordinator = self.transitionCoordinator
|
||||||
|
{
|
||||||
|
transitionCoordinator.animate(alongsideTransition: nil) { (context) in
|
||||||
|
presentToastView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
presentToastView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func didDeactivateGyro(with notification: Notification)
|
||||||
|
{
|
||||||
|
self.isGyroActive = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,10 @@ class LaunchViewController: RSTLaunchViewController
|
|||||||
return self.gameViewController
|
return self.gameViewController
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override var shouldAutorotate: Bool {
|
||||||
|
return self.gameViewController?.shouldAutorotate ?? true
|
||||||
|
}
|
||||||
|
|
||||||
required init?(coder aDecoder: NSCoder)
|
required init?(coder aDecoder: NSCoder)
|
||||||
{
|
{
|
||||||
super.init(coder: aDecoder)
|
super.init(coder: aDecoder)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user