Adds basic implementation + support for rewritten PauseViewController
This commit is contained in:
parent
60bc9dcfbc
commit
8450149184
@ -103,6 +103,9 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<connections>
|
||||
<segue destination="Yrw-9v-Pcr" kind="presentation" identifier="pause" customClass="PauseStoryboardSegue" customModule="Delta" customModuleProvider="target" id="FLq-Zt-HDv"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="gxI-00-NlJ" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
@ -153,7 +156,7 @@
|
||||
<viewControllerPlaceholder storyboardName="PauseMenu" id="Yrw-9v-Pcr" sceneMemberID="viewController"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="BDU-Ql-OgK" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="2470" y="1338"/>
|
||||
<point key="canvasLocation" x="2470" y="1441"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="Dt0-nV-isV">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11163.2" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Dt0-nV-isV">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11133"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Pause View Controller-->
|
||||
@ -14,23 +16,20 @@
|
||||
<viewControllerLayoutGuide type="bottom" id="gF0-0U-kR7"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="oOH-ea-jcb">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="p2M-dE-BJs" userLabel="Blur View">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="eyD-0d-RHe" userLabel="Blur Content View">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<frame key="frameInset"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<visualEffectView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Rcd-Nl-fKP" userLabel="Vibrancy View">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="3hz-aG-NZy" userLabel="Vibrancy Content View">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<frame key="frameInset"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rqN-NB-jbb">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<connections>
|
||||
<segue destination="sWv-Ky-VGs" kind="embed" identifier="embedNavigationController" id="1Ja-XW-uoT"/>
|
||||
</connections>
|
||||
@ -98,9 +97,9 @@
|
||||
<objects>
|
||||
<collectionViewController id="0jA-NY-mvB" customClass="PauseMenuViewController" customModule="Delta" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" delaysContentTouches="NO" dataMode="prototypes" id="scc-uc-vaJ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="20" minimumInteritemSpacing="10" id="yXv-zl-idO" customClass="GridCollectionViewLayout" customModule="Delta" customModuleProvider="target">
|
||||
<size key="itemSize" width="60" height="80"/>
|
||||
<size key="headerReferenceSize" width="0.0" height="0.0"/>
|
||||
@ -109,12 +108,11 @@
|
||||
</collectionViewFlowLayout>
|
||||
<cells>
|
||||
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="Cell" id="6XS-Ne-nGZ" customClass="GridCollectionViewCell" customModule="Delta" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="64" width="60" height="80"/>
|
||||
<frame key="frameInset" minY="84" width="60" height="80"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="60" height="80"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</collectionViewCell>
|
||||
</cells>
|
||||
@ -125,7 +123,7 @@
|
||||
</collectionView>
|
||||
<navigationItem key="navigationItem" title="Paused" id="rY7-Wx-NaD">
|
||||
<barButtonItem key="leftBarButtonItem" title="Main Menu" style="done" id="2yt-vB-uMF">
|
||||
<color key="tintColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="tintColor" red="1" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<connections>
|
||||
<segue destination="WU3-gG-BA5" kind="unwind" unwindAction="unwindFromEmulationViewController:" id="SdW-CX-n27"/>
|
||||
</connections>
|
||||
@ -147,9 +145,9 @@
|
||||
<objects>
|
||||
<collectionViewController storyboardIdentifier="saveStatesViewController" id="OOk-k7-INg" customClass="SaveStatesViewController" customModule="Delta" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" id="XgF-OF-CVf">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="20" minimumInteritemSpacing="20" id="tvW-q1-PD8" customClass="GridCollectionViewLayout" customModule="Delta" customModuleProvider="target">
|
||||
<size key="itemSize" width="50" height="50"/>
|
||||
<size key="headerReferenceSize" width="50" height="50"/>
|
||||
@ -158,17 +156,16 @@
|
||||
</collectionViewFlowLayout>
|
||||
<cells>
|
||||
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="Cell" id="c3N-1A-ryV" customClass="GridCollectionViewCell" customModule="Delta" customModuleProvider="target">
|
||||
<rect key="frame" x="20" y="124" width="50" height="50"/>
|
||||
<frame key="frameInset" minX="20" minY="124" width="50" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
</collectionViewCell>
|
||||
</cells>
|
||||
<collectionReusableView key="sectionHeaderView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="Header" id="YeY-W9-CC6" customClass="SaveStatesCollectionHeaderView" customModule="Delta" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="64" width="600" height="50"/>
|
||||
<frame key="frameInset" minY="64" width="375" height="50"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</collectionReusableView>
|
||||
<connections>
|
||||
@ -194,19 +191,19 @@
|
||||
<objects>
|
||||
<tableViewController id="wb8-5o-1jE" customClass="CheatsViewController" customModule="Delta" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" id="f5S-hV-1yV">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" id="e8g-ZW-5lQ">
|
||||
<rect key="frame" x="0.0" y="92" width="600" height="44"/>
|
||||
<frame key="frameInset" minY="92" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="e8g-ZW-5lQ" id="AHE-Jk-ULE">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
|
||||
<frame key="frameInset" width="375" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</tableViewCellContentView>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
@ -232,21 +229,20 @@
|
||||
<objects>
|
||||
<tableViewController storyboardIdentifier="editCheatViewController" id="jTR-Oe-YUJ" customClass="EditCheatViewController" customModule="Delta" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" keyboardDismissMode="interactive" dataMode="static" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="BV9-ff-x83">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<sections>
|
||||
<tableViewSection headerTitle="Name" id="QT6-DZ-g70">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="ZeC-rg-QFa">
|
||||
<rect key="frame" x="0.0" y="113.5" width="600" height="44"/>
|
||||
<rect key="frame" x="0.0" y="119.5" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" tableViewCell="ZeC-rg-QFa" id="UIF-fK-ApW">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
|
||||
<frame key="frameInset" width="375" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Cheat Name" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="DD1-X0-hg7">
|
||||
<rect key="frame" x="15" y="0.0" width="570" height="43.5"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="words" autocorrectionType="no" returnKeyType="done"/>
|
||||
<connections>
|
||||
@ -268,14 +264,13 @@
|
||||
<tableViewSection headerTitle="Type" footerTitle="Description" id="rvn-VK-2uH">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="Tst-zn-e04">
|
||||
<rect key="frame" x="0.0" y="207.5" width="600" height="44"/>
|
||||
<rect key="frame" x="0.0" y="227" width="375" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" tableViewCell="Tst-zn-e04" id="gwV-zS-RWQ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
|
||||
<frame key="frameInset" width="375" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="xrD-ue-96Q">
|
||||
<rect key="frame" x="15" y="7" width="570" height="29"/>
|
||||
<segments>
|
||||
<segment title="First"/>
|
||||
<segment title="Second"/>
|
||||
@ -297,15 +292,14 @@
|
||||
<tableViewSection headerTitle="Code" footerTitle="Description" id="rHC-nA-ga0">
|
||||
<cells>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" rowHeight="210" id="xxc-cz-sb7">
|
||||
<rect key="frame" x="0.0" y="318" width="600" height="210"/>
|
||||
<rect key="frame" x="0.0" y="346.5" width="375" height="210"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" tableViewCell="xxc-cz-sb7" id="agU-SE-fNa">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="209.5"/>
|
||||
<frame key="frameInset" width="375" height="209.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" text="XXXXXXXX YYYYYYYY" translatesAutoresizingMaskIntoConstraints="NO" id="a17-LB-QXD" customClass="CheatTextView" customModule="Delta" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="209.5"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<fontDescription key="fontDescription" name="Menlo-Regular" family="Menlo" pointSize="26"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="allCharacters" autocorrectionType="no" spellCheckingType="no" returnKeyType="done"/>
|
||||
<connections>
|
||||
|
||||
@ -12,6 +12,7 @@ import DeltaCore
|
||||
|
||||
class GameViewController: DeltaCore.GameViewController
|
||||
{
|
||||
/// Assumed to be Delta.Game instance
|
||||
override var game: GameProtocol? {
|
||||
didSet {
|
||||
guard let emulatorCore = self.emulatorCore else { return }
|
||||
@ -22,6 +23,10 @@ class GameViewController: DeltaCore.GameViewController
|
||||
// If non-nil, will override the default preview action items returned in previewActionItems()
|
||||
var overridePreviewActionItems: [UIPreviewActionItem]?
|
||||
|
||||
//MARK: - Private Properties -
|
||||
private var pauseViewController: PauseViewController?
|
||||
private var pausingGameController: GameController?
|
||||
|
||||
required init()
|
||||
{
|
||||
super.init()
|
||||
@ -94,6 +99,39 @@ extension GameViewController
|
||||
}
|
||||
return [launchGameAction]
|
||||
}
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?)
|
||||
{
|
||||
guard let identifier = segue.identifier where identifier == "pause" else { return }
|
||||
|
||||
guard let gameController = sender as? GameController else {
|
||||
fatalError("sender for pauseSegue must be the game controller that pressed the Menu button")
|
||||
}
|
||||
|
||||
self.pausingGameController = gameController
|
||||
|
||||
let pauseViewController = segue.destinationViewController as! PauseViewController
|
||||
pauseViewController.pauseText = (self.game as? Game)?.name ?? NSLocalizedString("Delta", comment: "")
|
||||
pauseViewController.emulatorCore = self.emulatorCore
|
||||
self.pauseViewController = pauseViewController
|
||||
}
|
||||
|
||||
@IBAction private func unwindFromPauseViewController(_ segue: UIStoryboardSegue)
|
||||
{
|
||||
self.pauseViewController = nil
|
||||
self.pausingGameController = nil
|
||||
|
||||
if self.resumeEmulation()
|
||||
{
|
||||
// Temporarily disable audioManager to prevent delayed audio bug when using 3D Touch Peek & Pop
|
||||
self.emulatorCore?.audioManager.enabled = false
|
||||
|
||||
// Re-enable after delay
|
||||
DispatchQueue.main.after(when: .now() + 0.1) {
|
||||
self.emulatorCore?.audioManager.enabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: Controllers -
|
||||
@ -141,13 +179,11 @@ extension GameViewController: GameViewControllerDelegate
|
||||
{
|
||||
self.pauseEmulation()
|
||||
|
||||
let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: { (action) in
|
||||
self.resumeEmulation()
|
||||
}))
|
||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("Stop Emulation", comment: ""), style: .destructive, handler: { (action) in
|
||||
self.dismiss(animated: true)
|
||||
}))
|
||||
self.present(alertController, animated: true)
|
||||
self.performSegue(withIdentifier: "pause", sender: gameController)
|
||||
}
|
||||
|
||||
func gameViewControllerShouldResumeEmulation(gameViewController: DeltaCore.GameViewController) -> Bool
|
||||
{
|
||||
return self.pauseViewController == nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,18 +8,31 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
class PauseViewController: UIViewController, PauseInfoProvidable
|
||||
import DeltaCore
|
||||
|
||||
class PauseViewController: UIViewController, PauseInfoProviding
|
||||
{
|
||||
var emulatorCore: EmulatorCore? {
|
||||
didSet {
|
||||
self.updatePauseItems()
|
||||
}
|
||||
}
|
||||
|
||||
var pauseItems: [PauseItem] {
|
||||
return [self.saveStateItem, self.loadStateItem, self.cheatCodesItem, self.sustainButtonsItem, self.fastForwardItem].flatMap { $0 }
|
||||
}
|
||||
|
||||
/// Pause Items
|
||||
var items = [PauseItem]()
|
||||
private(set) var saveStateItem: PauseItem?
|
||||
private(set) var loadStateItem: PauseItem?
|
||||
private(set) var cheatCodesItem: PauseItem?
|
||||
private(set) var sustainButtonsItem: PauseItem?
|
||||
private(set) var fastForwardItem: PauseItem?
|
||||
|
||||
/// <PauseInfoProvidable>
|
||||
var pauseText: String? = nil
|
||||
/// PauseInfoProviding
|
||||
var pauseText: String?
|
||||
|
||||
private weak var saveStatesViewControllerDelegate: SaveStatesViewControllerDelegate?
|
||||
private var saveStatesViewControllerMode = SaveStatesViewController.Mode.saving
|
||||
|
||||
private weak var cheatsViewControllerDelegate: CheatsViewControllerDelegate?
|
||||
private var pauseNavigationController: UINavigationController!
|
||||
|
||||
/// UIViewController
|
||||
override var preferredContentSize: CGSize {
|
||||
@ -39,22 +52,10 @@ class PauseViewController: UIViewController, PauseInfoProvidable
|
||||
override var navigationController: UINavigationController? {
|
||||
return self.pauseNavigationController
|
||||
}
|
||||
|
||||
private var pauseNavigationController: UINavigationController!
|
||||
}
|
||||
|
||||
extension PauseViewController
|
||||
{
|
||||
override func viewDidLoad()
|
||||
{
|
||||
super.viewDidLoad()
|
||||
}
|
||||
|
||||
override func didReceiveMemoryWarning()
|
||||
{
|
||||
super.didReceiveMemoryWarning()
|
||||
}
|
||||
|
||||
override func preferredStatusBarStyle() -> UIStatusBarStyle
|
||||
{
|
||||
return .lightContent
|
||||
@ -68,69 +69,49 @@ extension PauseViewController
|
||||
self.pauseNavigationController.navigationBar.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.pauseNavigationController.navigationBar.bounds.height)
|
||||
}
|
||||
|
||||
override func targetViewController(forAction action: Selector, sender: AnyObject?) -> UIViewController? {
|
||||
override func targetViewController(forAction action: Selector, sender: AnyObject?) -> UIViewController?
|
||||
{
|
||||
return self.pauseNavigationController
|
||||
}
|
||||
|
||||
override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?)
|
||||
{
|
||||
switch segue.identifier ?? ""
|
||||
guard let identifier = segue.identifier else { return }
|
||||
|
||||
switch identifier
|
||||
{
|
||||
case "embedNavigationController":
|
||||
self.pauseNavigationController = segue.destinationViewController as! UINavigationController
|
||||
self.pauseNavigationController.delegate = self
|
||||
self.pauseNavigationController.navigationBar.tintColor = UIColor.deltaLightPurpleColor()
|
||||
self.pauseNavigationController.view.backgroundColor = UIColor.clear()
|
||||
|
||||
let pauseMenuViewController = self.pauseNavigationController.topViewController as! PauseMenuViewController
|
||||
pauseMenuViewController.items = self.items
|
||||
pauseMenuViewController.items = self.pauseItems
|
||||
|
||||
// Keep navigation bar outside the UIVisualEffectView's
|
||||
self.view.addSubview(self.pauseNavigationController.navigationBar)
|
||||
|
||||
case "saveStates":
|
||||
let saveStatesViewController = segue.destinationViewController as! SaveStatesViewController
|
||||
saveStatesViewController.delegate = self.saveStatesViewControllerDelegate
|
||||
saveStatesViewController.mode = self.saveStatesViewControllerMode
|
||||
|
||||
case "cheats":
|
||||
let cheatsViewController = segue.destinationViewController as! CheatsViewController
|
||||
cheatsViewController.delegate = self.cheatsViewControllerDelegate
|
||||
|
||||
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension PauseViewController
|
||||
private extension PauseViewController
|
||||
{
|
||||
func dismiss()
|
||||
func updatePauseItems()
|
||||
{
|
||||
self.performSegue(withIdentifier: "unwindFromPauseMenu", sender: self)
|
||||
}
|
||||
|
||||
func presentSaveStateViewControllerWithMode(_ mode: SaveStatesViewController.Mode, delegate: SaveStatesViewControllerDelegate)
|
||||
{
|
||||
self.saveStatesViewControllerMode = mode
|
||||
self.saveStatesViewControllerDelegate = delegate
|
||||
self.saveStateItem = nil
|
||||
self.loadStateItem = nil
|
||||
self.cheatCodesItem = nil
|
||||
self.sustainButtonsItem = nil
|
||||
self.fastForwardItem = nil
|
||||
|
||||
self.performSegue(withIdentifier: "saveStates", sender: self)
|
||||
}
|
||||
|
||||
func presentCheatsViewController(delegate: CheatsViewControllerDelegate)
|
||||
{
|
||||
self.cheatsViewControllerDelegate = delegate
|
||||
guard self.emulatorCore != nil else { return }
|
||||
|
||||
self.performSegue(withIdentifier: "cheats", sender: self)
|
||||
}
|
||||
}
|
||||
|
||||
extension PauseViewController: UINavigationControllerDelegate
|
||||
{
|
||||
func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
|
||||
{
|
||||
let transitionCoordinator = PauseTransitionCoordinator(presentationController: self.presentationController!)
|
||||
transitionCoordinator.presenting = (operation == .push)
|
||||
return transitionCoordinator
|
||||
self.saveStateItem = PauseItem(image: UIImage(named: "SaveSaveState")!, text: NSLocalizedString("Save State", comment: ""), action: { _ in })
|
||||
self.loadStateItem = PauseItem(image: UIImage(named: "LoadSaveState")!, text: NSLocalizedString("Load State", comment: ""), action: { _ in })
|
||||
self.cheatCodesItem = PauseItem(image: UIImage(named: "SmallPause")!, text: NSLocalizedString("Cheat Codes", comment: ""), action: { _ in })
|
||||
self.sustainButtonsItem = PauseItem(image: UIImage(named: "SmallPause")!, text: NSLocalizedString("Sustain Buttons", comment: ""), action: { _ in })
|
||||
self.fastForwardItem = PauseItem(image: UIImage(named: "FastForward")!, text: NSLocalizedString("Fast Forward", comment: ""), action: { _ in })
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ import UIKit
|
||||
|
||||
import Roxas
|
||||
|
||||
protocol PauseInfoProvidable
|
||||
protocol PauseInfoProviding
|
||||
{
|
||||
var pauseText: String? { get }
|
||||
}
|
||||
@ -57,11 +57,11 @@ class PausePresentationController: UIPresentationController
|
||||
|
||||
override func presentationTransitionWillBegin()
|
||||
{
|
||||
if let provider = self.presentedViewController as? PauseInfoProvidable
|
||||
if let provider = self.presentedViewController as? PauseInfoProviding
|
||||
{
|
||||
self.pauseLabel.text = provider.pauseText
|
||||
}
|
||||
else if let navigationController = self.presentedViewController as? UINavigationController, provider = navigationController.topViewController as? PauseInfoProvidable
|
||||
else if let navigationController = self.presentedViewController as? UINavigationController, provider = navigationController.topViewController as? PauseInfoProviding
|
||||
{
|
||||
self.pauseLabel.text = provider.pauseText
|
||||
}
|
||||
@ -160,7 +160,10 @@ class PausePresentationController: UIPresentationController
|
||||
self.presentedView()?.setNeedsLayout()
|
||||
self.presentedView()?.layoutIfNeeded()
|
||||
|
||||
self.presentedView()?.frame = self.frameOfPresentedViewInContainerView()
|
||||
if self.presentingViewController.transitionCoordinator() == nil
|
||||
{
|
||||
self.presentedView()?.frame = self.frameOfPresentedViewInContainerView()
|
||||
}
|
||||
|
||||
// Unhide pauseIconImageView so its height is involved with layout calculations
|
||||
self.pauseIconImageView.isHidden = false
|
||||
|
||||
@ -10,10 +10,14 @@ import UIKit
|
||||
|
||||
class PauseStoryboardSegue: UIStoryboardSegue
|
||||
{
|
||||
private let animator: UIViewPropertyAnimator
|
||||
private let presentationController: PausePresentationController
|
||||
|
||||
override init(identifier: String?, source: UIViewController, destination: UIViewController)
|
||||
{
|
||||
let timingParameters = UISpringTimingParameters(mass: 3.0, stiffness: 750, damping: 65, initialVelocity: CGVector(dx: 0, dy: 0))
|
||||
self.animator = UIViewPropertyAnimator(duration: 0, timingParameters: timingParameters)
|
||||
|
||||
self.presentationController = PausePresentationController(presentedViewController: destination, presenting: source)
|
||||
|
||||
super.init(identifier: identifier, source: source, destination: destination)
|
||||
@ -25,6 +29,11 @@ class PauseStoryboardSegue: UIStoryboardSegue
|
||||
self.destinationViewController.modalPresentationStyle = .custom
|
||||
self.destinationViewController.modalPresentationCapturesStatusBarAppearance = true
|
||||
|
||||
// We need to force layout of destinationViewController.view _before_ animateTransition(using:)
|
||||
// Otherwise, we'll get "Unable to simultaneously satisfy constraints" errors
|
||||
self.destinationViewController.view.frame = self.sourceViewController.view.frame
|
||||
self.destinationViewController.view.layoutIfNeeded()
|
||||
|
||||
super.perform()
|
||||
}
|
||||
}
|
||||
@ -51,29 +60,26 @@ extension PauseStoryboardSegue: UIViewControllerAnimatedTransitioning
|
||||
{
|
||||
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval
|
||||
{
|
||||
return 0.65
|
||||
return self.animator.duration
|
||||
}
|
||||
|
||||
func animateTransition(using transitionContext: UIViewControllerContextTransitioning)
|
||||
{
|
||||
let destinationViewController = transitionContext.viewController(forKey: UITransitionContextToViewControllerKey)!
|
||||
let presentedView = transitionContext.view(forKey: UITransitionContextToViewKey)!
|
||||
let presentedViewController = transitionContext.viewController(forKey: UITransitionContextToViewControllerKey)!
|
||||
|
||||
destinationViewController.view.frame = transitionContext.finalFrame(for: destinationViewController)
|
||||
destinationViewController.view.frame.origin.y = transitionContext.containerView().bounds.height
|
||||
transitionContext.containerView().addSubview(destinationViewController.view)
|
||||
presentedView.frame = transitionContext.finalFrame(for: presentedViewController)
|
||||
presentedView.frame.origin.y = transitionContext.containerView().bounds.height
|
||||
transitionContext.containerView().addSubview(presentedView)
|
||||
|
||||
UIView.animate(withDuration: self.transitionDuration(using: transitionContext), delay: 0.0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.0, options: [], animations: {
|
||||
|
||||
// Calling layoutIfNeeded before the animation block for some reason prevents the blur from fading in
|
||||
// Additionally, if it's animated, it looks weird
|
||||
// So we need to wrap it in a no-animation block, inside an animation block. Blech.
|
||||
UIView.performWithoutAnimation({
|
||||
destinationViewController.view.layoutIfNeeded()
|
||||
})
|
||||
|
||||
destinationViewController.view.frame = self.presentationController.frameOfPresentedViewInContainerView()
|
||||
}, completion: { finished in
|
||||
transitionContext.completeTransition(finished)
|
||||
})
|
||||
self.animator.addAnimations { [unowned self] in
|
||||
presentedView.frame = self.presentationController.frameOfPresentedViewInContainerView()
|
||||
}
|
||||
|
||||
self.animator.addCompletion { position in
|
||||
transitionContext.completeTransition(position == .end)
|
||||
}
|
||||
|
||||
self.animator.startAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user