Adds Preview Save States
This commit is contained in:
parent
d242589bde
commit
5434143988
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model userDefinedModelVersionIdentifier="1.0" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="9525" systemVersion="15D21" minimumToolsVersion="Xcode 7.0">
|
||||
<model userDefinedModelVersionIdentifier="1.0" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="10174" systemVersion="15E65" minimumToolsVersion="Xcode 7.0">
|
||||
<entity name="Game" representedClassName="Game" syncable="YES">
|
||||
<attribute name="artworkURL" optional="YES" attributeType="Transformable" syncable="YES">
|
||||
<userInfo>
|
||||
@ -40,6 +40,7 @@
|
||||
</userInfo>
|
||||
</attribute>
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="isPreview" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
|
||||
<attribute name="modifiedDate" attributeType="Date" syncable="YES"/>
|
||||
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
|
||||
<attribute name="type" attributeType="Integer 16" defaultValueString="1" syncable="YES"/>
|
||||
@ -53,6 +54,6 @@
|
||||
<elements>
|
||||
<element name="Game" positionX="-200" positionY="-72" width="128" height="148"/>
|
||||
<element name="GameCollection" positionX="-198" positionY="-207" width="128" height="90"/>
|
||||
<element name="SaveState" positionX="-198" positionY="113" width="128" height="150"/>
|
||||
<element name="SaveState" positionX="-198" positionY="113" width="128" height="165"/>
|
||||
</elements>
|
||||
</model>
|
||||
@ -17,6 +17,7 @@ extension SaveState
|
||||
{
|
||||
case filename
|
||||
case identifier
|
||||
case isPreview
|
||||
case name
|
||||
case creationDate
|
||||
case modifiedDate
|
||||
@ -39,6 +40,7 @@ class SaveState: NSManagedObject, SaveStateType
|
||||
@NSManaged var name: String?
|
||||
@NSManaged var modifiedDate: NSDate
|
||||
@NSManaged var type: Type
|
||||
@NSManaged var isPreview: Bool
|
||||
|
||||
@NSManaged private(set) var filename: String
|
||||
@NSManaged private(set) var identifier: String
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="wKV-3d-NIY">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="wKV-3d-NIY">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
<capability name="Segues with Peek and Pop" minToolsVersion="7.1"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
@ -75,7 +75,7 @@
|
||||
<connections>
|
||||
<segue destination="hx4-Ze-0Jw" kind="presentation" id="Ila-yL-N8w">
|
||||
<segue key="commit" inheritsFrom="parent" id="0B7-vE-k6Z"/>
|
||||
<segue key="preview" inheritsFrom="commit" id="Jd4-q3-dNr"/>
|
||||
<segue key="preview" destination="hx4-Ze-0Jw" identifier="peekEmulationViewController" id="Jd4-q3-dNr"/>
|
||||
</segue>
|
||||
</connections>
|
||||
</collectionViewCell>
|
||||
@ -210,6 +210,6 @@
|
||||
<image name="Settings_Button" width="22" height="22"/>
|
||||
</resources>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="Jd4-q3-dNr"/>
|
||||
<segue reference="Ila-yL-N8w"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
</document>
|
||||
|
||||
@ -104,6 +104,7 @@ class EmulationViewController: UIViewController
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
self.deferredPreparationHandler?()
|
||||
self.deferredPreparationHandler = nil
|
||||
|
||||
switch self.emulatorCore.state
|
||||
{
|
||||
|
||||
@ -125,6 +125,21 @@ class GamesViewController: UIViewController
|
||||
let game = sourceViewController.dataSource.fetchedResultsController.objectAtIndexPath(indexPath!) as! Game
|
||||
|
||||
destinationViewController.game = game
|
||||
|
||||
if segue.identifier == "peekEmulationViewController"
|
||||
{
|
||||
destinationViewController.deferredPreparationHandler = { [unowned destinationViewController] in
|
||||
|
||||
let predicate = NSPredicate(format: "%K == %@ AND %K == YES", SaveState.Attributes.game.rawValue, game, SaveState.Attributes.isPreview.rawValue)
|
||||
|
||||
if let saveState = SaveState.instancesWithPredicate(predicate, inManagedObjectContext: DatabaseManager.sharedManager.managedObjectContext, type: SaveState.self).first
|
||||
{
|
||||
destinationViewController.emulatorCore.startEmulation()
|
||||
destinationViewController.emulatorCore.pauseEmulation()
|
||||
destinationViewController.emulatorCore.loadSaveState(saveState)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func unwindFromSettingsViewController(segue: UIStoryboardSegue)
|
||||
|
||||
@ -253,6 +253,23 @@ private extension SaveStatesViewController
|
||||
self.renameSaveState(saveState)
|
||||
}))
|
||||
|
||||
if self.traitCollection.forceTouchCapability == .Available
|
||||
{
|
||||
if !saveState.isPreview
|
||||
{
|
||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("Set as Preview Save State", comment: ""), style: .Default, handler: { action in
|
||||
self.updatePreviewSaveState(saveState)
|
||||
}))
|
||||
}
|
||||
else
|
||||
{
|
||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("Remove as Preview Save State", comment: ""), style: .Default, handler: { action in
|
||||
self.updatePreviewSaveState(nil)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let section = self.correctedSectionForSectionIndex(indexPath.section)
|
||||
switch section
|
||||
{
|
||||
@ -302,7 +319,7 @@ private extension SaveStatesViewController
|
||||
|
||||
func deleteSaveState(saveState: SaveState)
|
||||
{
|
||||
let confirmationAlertController = UIAlertController(title: NSLocalizedString("Confirm Deletion", comment: ""), message: NSLocalizedString("Are you sure you want to delete this save state? This cannot be undone.", comment: ""), preferredStyle: .Alert)
|
||||
let confirmationAlertController = UIAlertController(title: NSLocalizedString("Delete Save State?", comment: ""), message: NSLocalizedString("Are you sure you want to delete this save state? This cannot be undone.", comment: ""), preferredStyle: .Alert)
|
||||
confirmationAlertController.addAction(UIAlertAction(title: NSLocalizedString("Delete", comment: ""), style: .Default, handler: { action in
|
||||
|
||||
let backgroundContext = DatabaseManager.sharedManager.backgroundManagedObjectContext()
|
||||
@ -363,6 +380,37 @@ private extension SaveStatesViewController
|
||||
self.selectedSaveState = nil
|
||||
}
|
||||
|
||||
func updatePreviewSaveState(saveState: SaveState?)
|
||||
{
|
||||
let alertController = UIAlertController(title: NSLocalizedString("Change Preview Save State?", comment: ""), message: NSLocalizedString("The Preview Save State is loaded whenever you preview this game from the Main Menu with 3D Touch. Are you sure you want to change it?", comment: ""), preferredStyle: .Alert)
|
||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .Cancel, handler: nil))
|
||||
alertController.addAction(UIAlertAction(title: NSLocalizedString("Change", comment: ""), style: .Default, handler: { (action) in
|
||||
|
||||
let backgroundContext = DatabaseManager.sharedManager.backgroundManagedObjectContext()
|
||||
backgroundContext.performBlock {
|
||||
|
||||
var game = self.delegate.saveStatesViewControllerActiveEmulatorCore(self).game as! Game
|
||||
game = backgroundContext.objectWithID(game.objectID) as! Game
|
||||
|
||||
let predicate = NSPredicate(format: "%K == %@ AND %K == YES", SaveState.Attributes.game.rawValue, game, SaveState.Attributes.isPreview.rawValue)
|
||||
|
||||
let previousPreviewSaveState = SaveState.instancesWithPredicate(predicate, inManagedObjectContext: backgroundContext, type: SaveState.self).first
|
||||
previousPreviewSaveState?.isPreview = false
|
||||
|
||||
if let saveState = saveState
|
||||
{
|
||||
let previewSaveState = backgroundContext.objectWithID(saveState.objectID) as! SaveState
|
||||
previewSaveState.isPreview = true
|
||||
}
|
||||
|
||||
backgroundContext.saveWithErrorLogging()
|
||||
}
|
||||
|
||||
}))
|
||||
|
||||
self.presentViewController(alertController, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
func lockSaveState(saveState: SaveState)
|
||||
{
|
||||
let backgroundContext = DatabaseManager.sharedManager.backgroundManagedObjectContext()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user