Updates DeltaCore API usage to match massive DeltaCore refactoring
This commit is contained in:
parent
8b97d1badc
commit
1d7ce4b6e6
@ -119,12 +119,12 @@ class DatabaseManager
|
|||||||
if let pathExtension = URL.pathExtension
|
if let pathExtension = URL.pathExtension
|
||||||
{
|
{
|
||||||
let gameCollection = GameCollection.gameSystemCollectionForPathExtension(pathExtension, inManagedObjectContext: managedObjectContext)
|
let gameCollection = GameCollection.gameSystemCollectionForPathExtension(pathExtension, inManagedObjectContext: managedObjectContext)
|
||||||
game.typeIdentifier = gameCollection.identifier
|
game.type = GameType(rawValue: gameCollection.identifier)
|
||||||
game.gameCollections.insert(gameCollection)
|
game.gameCollections.insert(gameCollection)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
game.typeIdentifier = kUTTypeDeltaGame as String
|
game.type = GameType.delta
|
||||||
}
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
|
|||||||
@ -27,38 +27,12 @@ extension Cheat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension CheatType
|
|
||||||
{
|
|
||||||
var rawValue: Int16
|
|
||||||
{
|
|
||||||
switch self
|
|
||||||
{
|
|
||||||
case .actionReplay: return 0
|
|
||||||
case .gameGenie: return 1
|
|
||||||
case .gameShark: return 2
|
|
||||||
case .codeBreaker: return 3
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
init?(rawValue: Int16)
|
|
||||||
{
|
|
||||||
switch rawValue
|
|
||||||
{
|
|
||||||
case 0: self = .actionReplay
|
|
||||||
case 1: self = .gameGenie
|
|
||||||
case 2: self = .gameShark
|
|
||||||
case 3: self = .codeBreaker
|
|
||||||
default: return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc(Cheat)
|
@objc(Cheat)
|
||||||
class Cheat: NSManagedObject, CheatProtocol
|
class Cheat: NSManagedObject, CheatProtocol
|
||||||
{
|
{
|
||||||
//TODO: Change type to String! when Swift 3 allows it
|
|
||||||
@NSManaged var name: String?
|
@NSManaged var name: String?
|
||||||
@NSManaged var code: String
|
@NSManaged var code: String
|
||||||
|
@NSManaged var type: CheatType
|
||||||
@NSManaged var modifiedDate: Date
|
@NSManaged var modifiedDate: Date
|
||||||
@NSManaged var enabled: Bool
|
@NSManaged var enabled: Bool
|
||||||
|
|
||||||
@ -68,23 +42,6 @@ class Cheat: NSManagedObject, CheatProtocol
|
|||||||
// Must be optional relationship to satisfy weird Core Data requirement
|
// Must be optional relationship to satisfy weird Core Data requirement
|
||||||
// https://forums.developer.apple.com/thread/20535
|
// https://forums.developer.apple.com/thread/20535
|
||||||
@NSManaged var game: Game!
|
@NSManaged var game: Game!
|
||||||
|
|
||||||
var type: CheatType
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
self.willAccessValue(forKey: Attributes.type.rawValue)
|
|
||||||
let type = CheatType(rawValue: self.primitiveType.int16Value)!
|
|
||||||
self.didAccessValue(forKey: Attributes.type.rawValue)
|
|
||||||
return type
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
self.willChangeValue(forKey: Attributes.type.rawValue)
|
|
||||||
self.primitiveType = NSNumber(value: newValue.rawValue)
|
|
||||||
self.didChangeValue(forKey: Attributes.type.rawValue)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Cheat
|
extension Cheat
|
||||||
|
|||||||
@ -31,13 +31,13 @@ extension Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc(Game)
|
@objc(Game)
|
||||||
class Game: NSManagedObject
|
class Game: NSManagedObject, GameProtocol
|
||||||
{
|
{
|
||||||
@NSManaged var artworkURL: URL?
|
@NSManaged var artworkURL: URL?
|
||||||
@NSManaged var filename: String
|
@NSManaged var filename: String
|
||||||
@NSManaged var identifier: String
|
@NSManaged var identifier: String
|
||||||
@NSManaged var name: String
|
@NSManaged var name: String
|
||||||
@NSManaged var typeIdentifier: String
|
@NSManaged var type: GameType
|
||||||
|
|
||||||
@NSManaged var gameCollections: Set<GameCollection>
|
@NSManaged var gameCollections: Set<GameCollection>
|
||||||
@NSManaged var previewSaveState: SaveState?
|
@NSManaged var previewSaveState: SaveState?
|
||||||
@ -48,22 +48,19 @@ class Game: NSManagedObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
var preferredFileExtension: String {
|
var preferredFileExtension: String {
|
||||||
switch self.typeIdentifier
|
switch self.type
|
||||||
{
|
{
|
||||||
case kUTTypeSNESGame as String as String: return "smc"
|
case GameType.snes: return "smc"
|
||||||
case kUTTypeGBAGame as String as String: return "gba"
|
case GameType.gba: return "gba"
|
||||||
case kUTTypeDeltaGame as String as String: fallthrough
|
|
||||||
default: return "delta"
|
default: return "delta"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Game: GameType {}
|
|
||||||
|
|
||||||
extension Game
|
extension Game
|
||||||
{
|
{
|
||||||
class func supportedTypeIdentifiers() -> Set<String>
|
class func supportedTypeIdentifiers() -> Set<String>
|
||||||
{
|
{
|
||||||
return [kUTTypeSNESGame as String, kUTTypeGBAGame as String]
|
return [GameType.snes.rawValue, GameType.gba.rawValue]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,9 +36,9 @@ class GameCollection: NSManagedObject
|
|||||||
|
|
||||||
switch self.identifier
|
switch self.identifier
|
||||||
{
|
{
|
||||||
case kUTTypeSNESGame as String as String: return NSLocalizedString("Super Nintendo Entertainment System", comment: "")
|
case GameType.snes.rawValue: return NSLocalizedString("Super Nintendo Entertainment System", comment: "")
|
||||||
case kUTTypeGBAGame as String as String: return NSLocalizedString("Game Boy Advance", comment: "")
|
case GameType.gba.rawValue: return NSLocalizedString("Game Boy Advance", comment: "")
|
||||||
case kUTTypeDeltaGame as String as String: return NSLocalizedString("Unsupported Games", comment: "")
|
case GameType.delta.rawValue: return NSLocalizedString("Unsupported Games", comment: "")
|
||||||
default: return NSLocalizedString("Unknown", comment: "")
|
default: return NSLocalizedString("Unknown", comment: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,9 +47,9 @@ class GameCollection: NSManagedObject
|
|||||||
|
|
||||||
switch self.identifier
|
switch self.identifier
|
||||||
{
|
{
|
||||||
case kUTTypeSNESGame as String as String: return NSLocalizedString("SNES", comment: "")
|
case GameType.snes.rawValue as String as String: return NSLocalizedString("SNES", comment: "")
|
||||||
case kUTTypeGBAGame as String as String: return NSLocalizedString("GBA", comment: "")
|
case GameType.gba.rawValue as String as String: return NSLocalizedString("GBA", comment: "")
|
||||||
case kUTTypeDeltaGame as String as String: return NSLocalizedString("Unsupported", comment: "")
|
case GameType.delta.rawValue as String as String: return NSLocalizedString("Unsupported", comment: "")
|
||||||
default: return NSLocalizedString("Unknown", comment: "")
|
default: return NSLocalizedString("Unknown", comment: "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,15 +64,15 @@ class GameCollection: NSManagedObject
|
|||||||
case "smc": fallthrough
|
case "smc": fallthrough
|
||||||
case "sfc": fallthrough
|
case "sfc": fallthrough
|
||||||
case "fig":
|
case "fig":
|
||||||
identifier = kUTTypeSNESGame as String
|
identifier = GameType.snes.rawValue
|
||||||
index = 1990
|
index = 1990
|
||||||
|
|
||||||
case "gba":
|
case "gba":
|
||||||
identifier = kUTTypeGBAGame as String
|
identifier = GameType.gba.rawValue
|
||||||
index = 2001
|
index = 2001
|
||||||
|
|
||||||
default:
|
default:
|
||||||
identifier = kUTTypeDeltaGame as String
|
identifier = GameType.delta.rawValue
|
||||||
index = Int16(INT16_MAX)
|
index = Int16(INT16_MAX)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<model userDefinedModelVersionIdentifier="1.0" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="10174" systemVersion="15E65" minimumToolsVersion="Xcode 7.0">
|
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="11185.3" systemVersion="15F34" minimumToolsVersion="Xcode 7.0" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="1.0">
|
||||||
<entity name="Cheat" representedClassName="Cheat" syncable="YES">
|
<entity name="Cheat" representedClassName="Cheat" syncable="YES">
|
||||||
<attribute name="code" attributeType="String" syncable="YES"/>
|
<attribute name="code" attributeType="String" syncable="YES"/>
|
||||||
<attribute name="creationDate" attributeType="Date" syncable="YES"/>
|
<attribute name="creationDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||||
<attribute name="enabled" attributeType="Boolean" defaultValueString="YES" syncable="YES"/>
|
<attribute name="enabled" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="NO" syncable="YES"/>
|
||||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||||
<attribute name="modifiedDate" attributeType="Date" syncable="YES"/>
|
<attribute name="modifiedDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||||
<attribute name="name" attributeType="String" syncable="YES"/>
|
<attribute name="name" attributeType="String" syncable="YES"/>
|
||||||
<attribute name="type" attributeType="Integer 16" defaultValueString="0" syncable="YES"/>
|
<attribute name="type" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
|
||||||
<relationship name="game" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Game" inverseName="cheats" inverseEntity="Game" syncable="YES"/>
|
<relationship name="game" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Game" inverseName="cheats" inverseEntity="Game" syncable="YES"/>
|
||||||
<uniquenessConstraints>
|
<uniquenessConstraints>
|
||||||
<uniquenessConstraint>
|
<uniquenessConstraint>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||||
<attribute name="name" attributeType="String" syncable="YES"/>
|
<attribute name="name" attributeType="String" syncable="YES"/>
|
||||||
<attribute name="typeIdentifier" attributeType="String" syncable="YES"/>
|
<attribute name="type" attributeType="String" syncable="YES"/>
|
||||||
<relationship name="cheats" toMany="YES" deletionRule="Cascade" destinationEntity="Cheat" inverseName="game" inverseEntity="Cheat" syncable="YES"/>
|
<relationship name="cheats" toMany="YES" deletionRule="Cascade" destinationEntity="Cheat" inverseName="game" inverseEntity="Cheat" syncable="YES"/>
|
||||||
<relationship name="gameCollections" toMany="YES" deletionRule="Nullify" destinationEntity="GameCollection" inverseName="games" inverseEntity="GameCollection" syncable="YES"/>
|
<relationship name="gameCollections" toMany="YES" deletionRule="Nullify" destinationEntity="GameCollection" inverseName="games" inverseEntity="GameCollection" syncable="YES"/>
|
||||||
<relationship name="previewSaveState" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="SaveState" inverseName="previewGame" inverseEntity="SaveState" syncable="YES"/>
|
<relationship name="previewSaveState" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="SaveState" inverseName="previewGame" inverseEntity="SaveState" syncable="YES"/>
|
||||||
@ -41,7 +41,7 @@
|
|||||||
</entity>
|
</entity>
|
||||||
<entity name="GameCollection" representedClassName="GameCollection" syncable="YES">
|
<entity name="GameCollection" representedClassName="GameCollection" syncable="YES">
|
||||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||||
<attribute name="index" attributeType="Integer 16" defaultValueString="0" syncable="YES"/>
|
<attribute name="index" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
|
||||||
<relationship name="games" toMany="YES" deletionRule="Nullify" destinationEntity="Game" inverseName="gameCollections" inverseEntity="Game" syncable="YES"/>
|
<relationship name="games" toMany="YES" deletionRule="Nullify" destinationEntity="Game" inverseName="gameCollections" inverseEntity="Game" syncable="YES"/>
|
||||||
<uniquenessConstraints>
|
<uniquenessConstraints>
|
||||||
<uniquenessConstraint>
|
<uniquenessConstraint>
|
||||||
@ -50,16 +50,16 @@
|
|||||||
</uniquenessConstraints>
|
</uniquenessConstraints>
|
||||||
</entity>
|
</entity>
|
||||||
<entity name="SaveState" representedClassName="SaveState" syncable="YES">
|
<entity name="SaveState" representedClassName="SaveState" syncable="YES">
|
||||||
<attribute name="creationDate" attributeType="Date" syncable="YES"/>
|
<attribute name="creationDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||||
<attribute name="filename" attributeType="String" syncable="YES">
|
<attribute name="filename" attributeType="String" syncable="YES">
|
||||||
<userInfo>
|
<userInfo>
|
||||||
<entry key="attributeValueClassName" value="NSURL"/>
|
<entry key="attributeValueClassName" value="NSURL"/>
|
||||||
</userInfo>
|
</userInfo>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||||
<attribute name="modifiedDate" attributeType="Date" syncable="YES"/>
|
<attribute name="modifiedDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||||
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
|
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
|
||||||
<attribute name="type" attributeType="Integer 16" defaultValueString="1" syncable="YES"/>
|
<attribute name="type" attributeType="Integer 16" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
|
||||||
<relationship name="game" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Game" inverseName="saveStates" inverseEntity="Game" syncable="YES"/>
|
<relationship name="game" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Game" inverseName="saveStates" inverseEntity="Game" syncable="YES"/>
|
||||||
<relationship name="previewGame" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Game" inverseName="previewSaveState" inverseEntity="Game" syncable="YES"/>
|
<relationship name="previewGame" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Game" inverseName="previewSaveState" inverseEntity="Game" syncable="YES"/>
|
||||||
<uniquenessConstraints>
|
<uniquenessConstraints>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
</entity>
|
</entity>
|
||||||
<elements>
|
<elements>
|
||||||
<element name="Cheat" positionX="-198" positionY="-63" width="128" height="165"/>
|
<element name="Cheat" positionX="-198" positionY="-63" width="128" height="165"/>
|
||||||
<element name="Game" positionX="-378" positionY="-54" width="128" height="178"/>
|
<element name="Game" positionX="-378" positionY="-54" width="128" height="180"/>
|
||||||
<element name="GameCollection" positionX="-585" positionY="-27" width="128" height="90"/>
|
<element name="GameCollection" positionX="-585" positionY="-27" width="128" height="90"/>
|
||||||
<element name="SaveState" positionX="-198" positionY="113" width="128" height="165"/>
|
<element name="SaveState" positionX="-198" positionY="113" width="128" height="165"/>
|
||||||
</elements>
|
</elements>
|
||||||
|
|||||||
@ -37,7 +37,7 @@ extension SaveState
|
|||||||
|
|
||||||
|
|
||||||
@objc(SaveState)
|
@objc(SaveState)
|
||||||
class SaveState: NSManagedObject, SaveStateType
|
class SaveState: NSManagedObject, SaveStateProtocol
|
||||||
{
|
{
|
||||||
@NSManaged var name: String?
|
@NSManaged var name: String?
|
||||||
@NSManaged var modifiedDate: Date
|
@NSManaged var modifiedDate: Date
|
||||||
@ -63,6 +63,10 @@ class SaveState: NSManagedObject, SaveStateType
|
|||||||
let imageFileURL = try! DatabaseManager.saveStatesDirectoryURLForGame(self.game).appendingPathComponent(imageFilename)
|
let imageFileURL = try! DatabaseManager.saveStatesDirectoryURLForGame(self.game).appendingPathComponent(imageFilename)
|
||||||
return imageFileURL
|
return imageFileURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var gameType: GameType {
|
||||||
|
return self.game.type
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SaveState
|
extension SaveState
|
||||||
|
|||||||
@ -61,7 +61,7 @@ class GamePickerController: NSObject
|
|||||||
|
|
||||||
let managedObjectContext = DatabaseManager.sharedManager.backgroundManagedObjectContext()
|
let managedObjectContext = DatabaseManager.sharedManager.backgroundManagedObjectContext()
|
||||||
managedObjectContext.perform() {
|
managedObjectContext.perform() {
|
||||||
let gameURLs = contents.filter({ GameCollection.gameSystemCollectionForPathExtension($0.pathExtension, inManagedObjectContext: managedObjectContext).identifier != kUTTypeDeltaGame as String })
|
let gameURLs = contents.filter({ GameCollection.gameSystemCollectionForPathExtension($0.pathExtension, inManagedObjectContext: managedObjectContext).identifier != GameType.delta.rawValue })
|
||||||
self.importGamesAtURLs(gameURLs)
|
self.importGamesAtURLs(gameURLs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
Subproject commit 1037b675d20acdd847fe960b426785058f4e83aa
|
Subproject commit 455a93e44d323c735f3434c31533aa6dc279fdf1
|
||||||
@ -1 +1 @@
|
|||||||
Subproject commit d006f2bbe8132eced92d0c54b483e7af5a0bc2a8
|
Subproject commit 8c461ea12cc28e8781b4299a07452344a86fe072
|
||||||
@ -1 +1 @@
|
|||||||
Subproject commit 90e901dea3a177cbd0e602567676c6e2d5296b4c
|
Subproject commit c414c1d7e4745b4972f3b243aeddd2b07b5e5c39
|
||||||
@ -30,7 +30,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate
|
|||||||
semaphore.wait(timeout: DispatchTime.distantFuture)
|
semaphore.wait(timeout: DispatchTime.distantFuture)
|
||||||
|
|
||||||
// Controllers
|
// Controllers
|
||||||
ExternalControllerManager.sharedManager.startMonitoringExternalControllers()
|
ExternalControllerManager.shared.startMonitoringExternalControllers()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,13 +70,13 @@ class EmulationViewController: UIViewController
|
|||||||
|
|
||||||
//MARK: - Private Properties
|
//MARK: - Private Properties
|
||||||
private var pauseViewController: PauseViewController?
|
private var pauseViewController: PauseViewController?
|
||||||
private var pausingGameController: GameControllerProtocol?
|
private var pausingGameController: GameController?
|
||||||
|
|
||||||
private var context = CIContext(options: [kCIContextWorkingColorSpace: NSNull()])
|
private var context = CIContext(options: [kCIContextWorkingColorSpace: NSNull()])
|
||||||
|
|
||||||
private var updateSemaphores = Set<DispatchSemaphore>()
|
private var updateSemaphores = Set<DispatchSemaphore>()
|
||||||
|
|
||||||
private var sustainedInputs = [ObjectIdentifier: [InputType]]()
|
private var sustainedInputs = [ObjectIdentifier: [Input]]()
|
||||||
private var reactivateSustainInputsQueue: OperationQueue
|
private var reactivateSustainInputsQueue: OperationQueue
|
||||||
private var choosingSustainedButtons = false
|
private var choosingSustainedButtons = false
|
||||||
|
|
||||||
@ -97,8 +97,8 @@ class EmulationViewController: UIViewController
|
|||||||
|
|
||||||
super.init(coder: aDecoder)
|
super.init(coder: aDecoder)
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(EmulationViewController.updateControllers), name: NSNotification.Name(rawValue: ExternalControllerDidConnectNotification), object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(EmulationViewController.updateControllers), name: .externalControllerDidConnect, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(EmulationViewController.updateControllers), name: NSNotification.Name(rawValue: ExternalControllerDidDisconnectNotification), object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(EmulationViewController.updateControllers), name: .externalControllerDidDisconnect, object: nil)
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(EmulationViewController.willResignActive(_:)), name: NSNotification.Name.UIApplicationWillResignActive, object: UIApplication.shared())
|
NotificationCenter.default.addObserver(self, selector: #selector(EmulationViewController.willResignActive(_:)), name: NSNotification.Name.UIApplicationWillResignActive, object: UIApplication.shared())
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(EmulationViewController.didBecomeActive(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, object: UIApplication.shared())
|
NotificationCenter.default.addObserver(self, selector: #selector(EmulationViewController.didBecomeActive(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, object: UIApplication.shared())
|
||||||
@ -107,7 +107,7 @@ class EmulationViewController: UIViewController
|
|||||||
deinit
|
deinit
|
||||||
{
|
{
|
||||||
// To ensure the emulation stops when cancelling a peek/preview gesture
|
// To ensure the emulation stops when cancelling a peek/preview gesture
|
||||||
self.emulatorCore.stopEmulation()
|
self.emulatorCore.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
//MARK: - Overrides
|
//MARK: - Overrides
|
||||||
@ -124,14 +124,13 @@ class EmulationViewController: UIViewController
|
|||||||
self.controllerViewHeightConstraint.constant = 0
|
self.controllerViewHeightConstraint.constant = 0
|
||||||
|
|
||||||
self.gameView.backgroundColor = UIColor.clear()
|
self.gameView.backgroundColor = UIColor.clear()
|
||||||
self.emulatorCore.addGameView(self.gameView)
|
self.emulatorCore.add(self.gameView)
|
||||||
|
|
||||||
self.backgroundView.textLabel.text = NSLocalizedString("Select Buttons to Sustain", comment: "")
|
self.backgroundView.textLabel.text = NSLocalizedString("Select Buttons to Sustain", comment: "")
|
||||||
self.backgroundView.detailTextLabel.text = NSLocalizedString("Press the Menu button when finished.", comment: "")
|
self.backgroundView.detailTextLabel.text = NSLocalizedString("Press the Menu button when finished.", comment: "")
|
||||||
|
|
||||||
let controllerSkin = ControllerSkin.defaultControllerSkinForGameUTI(self.game.typeIdentifier)
|
let controllerSkin = ControllerSkin.standardControllerSkin(for: self.game.type)
|
||||||
|
|
||||||
self.controllerView.containerView = self.view
|
|
||||||
self.controllerView.controllerSkin = controllerSkin
|
self.controllerView.controllerSkin = controllerSkin
|
||||||
|
|
||||||
self.updateControllers()
|
self.updateControllers()
|
||||||
@ -148,7 +147,7 @@ class EmulationViewController: UIViewController
|
|||||||
switch self.emulatorCore.state
|
switch self.emulatorCore.state
|
||||||
{
|
{
|
||||||
case .stopped:
|
case .stopped:
|
||||||
self.emulatorCore.startEmulation()
|
self.emulatorCore.start()
|
||||||
self.updateCheats()
|
self.updateCheats()
|
||||||
|
|
||||||
case .running: break
|
case .running: break
|
||||||
@ -214,7 +213,7 @@ class EmulationViewController: UIViewController
|
|||||||
|
|
||||||
if segue.identifier == "pauseSegue"
|
if segue.identifier == "pauseSegue"
|
||||||
{
|
{
|
||||||
guard let gameController = sender as? GameControllerProtocol else { fatalError("sender for pauseSegue must be the game controller that pressed the Menu button") }
|
guard let gameController = sender as? GameController else { fatalError("sender for pauseSegue must be the game controller that pressed the Menu button") }
|
||||||
|
|
||||||
self.pausingGameController = gameController
|
self.pausingGameController = gameController
|
||||||
|
|
||||||
@ -250,9 +249,9 @@ class EmulationViewController: UIViewController
|
|||||||
sustainButtonsItem.selected = self.sustainedInputs[ObjectIdentifier(gameController)]?.count > 0
|
sustainButtonsItem.selected = self.sustainedInputs[ObjectIdentifier(gameController)]?.count > 0
|
||||||
|
|
||||||
var fastForwardItem = PauseItem(image: UIImage(named: "FastForward")!, text: NSLocalizedString("Fast Forward", comment: ""), action: { [unowned self] item in
|
var fastForwardItem = PauseItem(image: UIImage(named: "FastForward")!, text: NSLocalizedString("Fast Forward", comment: ""), action: { [unowned self] item in
|
||||||
self.emulatorCore.rate = item.selected ? self.emulatorCore.supportedRates.upperBound : self.emulatorCore.supportedRates.lowerBound
|
self.emulatorCore.rate = item.selected ? self.emulatorCore.configuration.supportedRates.upperBound : self.emulatorCore.configuration.supportedRates.lowerBound
|
||||||
})
|
})
|
||||||
fastForwardItem.selected = self.emulatorCore.rate == self.emulatorCore.supportedRates.lowerBound ? false : true
|
fastForwardItem.selected = self.emulatorCore.rate == self.emulatorCore.configuration.supportedRates.lowerBound ? false : true
|
||||||
|
|
||||||
pauseViewController.items = [saveStateItem, loadStateItem, cheatCodesItem, fastForwardItem, sustainButtonsItem]
|
pauseViewController.items = [saveStateItem, loadStateItem, cheatCodesItem, fastForwardItem, sustainButtonsItem]
|
||||||
|
|
||||||
@ -309,14 +308,14 @@ private extension EmulationViewController
|
|||||||
|
|
||||||
func pauseEmulation() -> Bool
|
func pauseEmulation() -> Bool
|
||||||
{
|
{
|
||||||
return self.emulatorCore.pauseEmulation()
|
return self.emulatorCore.pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
func resumeEmulation() -> Bool
|
func resumeEmulation() -> Bool
|
||||||
{
|
{
|
||||||
guard !self.choosingSustainedButtons && self.pauseViewController == nil else { return false }
|
guard !self.choosingSustainedButtons && self.pauseViewController == nil else { return false }
|
||||||
|
|
||||||
return self.emulatorCore.resumeEmulation()
|
return self.emulatorCore.resume()
|
||||||
}
|
}
|
||||||
|
|
||||||
func emulatorCoreDidUpdate(_ emulatorCore: EmulatorCore)
|
func emulatorCoreDidUpdate(_ emulatorCore: EmulatorCore)
|
||||||
@ -341,17 +340,17 @@ private extension EmulationViewController
|
|||||||
self.controllerView.playerIndex = index
|
self.controllerView.playerIndex = index
|
||||||
}
|
}
|
||||||
|
|
||||||
var controllers = [GameControllerProtocol]()
|
var controllers = [GameController]()
|
||||||
controllers.append(self.controllerView)
|
controllers.append(self.controllerView)
|
||||||
|
|
||||||
// We need to map each item as a GameControllerProtocol due to a Swift bug
|
// We need to map each item as a GameControllerProtocol due to a Swift bug
|
||||||
controllers.append(contentsOf: ExternalControllerManager.sharedManager.connectedControllers.map { $0 as GameControllerProtocol })
|
controllers.append(contentsOf: ExternalControllerManager.shared.connectedControllers.map { $0 as GameController })
|
||||||
|
|
||||||
for controller in controllers
|
for controller in controllers
|
||||||
{
|
{
|
||||||
if let index = controller.playerIndex
|
if let index = controller.playerIndex
|
||||||
{
|
{
|
||||||
self.emulatorCore.setGameController(controller, atIndex: index)
|
self.emulatorCore.setGameController(controller, at: index)
|
||||||
controller.addReceiver(self)
|
controller.addReceiver(self)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -385,7 +384,7 @@ private extension EmulationViewController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func resetSustainedInputs(forGameController gameController: GameControllerProtocol)
|
func resetSustainedInputs(forGameController gameController: GameController)
|
||||||
{
|
{
|
||||||
if let previousInputs = self.sustainedInputs[ObjectIdentifier(gameController)]
|
if let previousInputs = self.sustainedInputs[ObjectIdentifier(gameController)]
|
||||||
{
|
{
|
||||||
@ -405,7 +404,7 @@ private extension EmulationViewController
|
|||||||
self.sustainedInputs[ObjectIdentifier(gameController)] = []
|
self.sustainedInputs[ObjectIdentifier(gameController)] = []
|
||||||
}
|
}
|
||||||
|
|
||||||
func addSustainedInput(_ input: InputType, gameController: GameControllerProtocol)
|
func addSustainedInput(_ input: Input, gameController: GameController)
|
||||||
{
|
{
|
||||||
var inputs = self.sustainedInputs[ObjectIdentifier(gameController)] ?? []
|
var inputs = self.sustainedInputs[ObjectIdentifier(gameController)] ?? []
|
||||||
|
|
||||||
@ -424,7 +423,7 @@ private extension EmulationViewController
|
|||||||
receivers.forEach { gameController.addReceiver($0) }
|
receivers.forEach { gameController.addReceiver($0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
func reactivateSustainedInput(_ input: InputType, gameController: GameControllerProtocol)
|
func reactivateSustainedInput(_ input: Input, gameController: GameController)
|
||||||
{
|
{
|
||||||
// These MUST be performed serially, or else Bad Things Happen™ if multiple inputs are reactivated at once
|
// These MUST be performed serially, or else Bad Things Happen™ if multiple inputs are reactivated at once
|
||||||
self.reactivateSustainInputsQueue.addOperation {
|
self.reactivateSustainInputsQueue.addOperation {
|
||||||
@ -492,7 +491,7 @@ extension EmulationViewController: SaveStatesViewControllerDelegate
|
|||||||
|
|
||||||
var updatingExistingSaveState = true
|
var updatingExistingSaveState = true
|
||||||
|
|
||||||
self.emulatorCore.saveSaveState { temporarySaveState in
|
self.emulatorCore.save { (temporarySaveState) in
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if FileManager.default.fileExists(atPath: filepath)
|
if FileManager.default.fileExists(atPath: filepath)
|
||||||
@ -528,15 +527,15 @@ extension EmulationViewController: SaveStatesViewControllerDelegate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveStatesViewController(_ saveStatesViewController: SaveStatesViewController, loadSaveState saveState: SaveStateType)
|
func saveStatesViewController(_ saveStatesViewController: SaveStatesViewController, loadSaveState saveState: SaveStateProtocol)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
try self.emulatorCore.loadSaveState(saveState)
|
try self.emulatorCore.load(saveState)
|
||||||
}
|
}
|
||||||
catch EmulatorCore.SaveStateError.doesNotExist
|
catch EmulatorCore.SaveStateError.doesNotExist
|
||||||
{
|
{
|
||||||
print("Save State \(saveState.name) does not exist.")
|
print("Save State does not exist.")
|
||||||
}
|
}
|
||||||
catch let error as NSError
|
catch let error as NSError
|
||||||
{
|
{
|
||||||
@ -560,12 +559,12 @@ extension EmulationViewController: CheatsViewControllerDelegate
|
|||||||
|
|
||||||
func cheatsViewController(_ cheatsViewController: CheatsViewController, didActivateCheat cheat: Cheat) throws
|
func cheatsViewController(_ cheatsViewController: CheatsViewController, didActivateCheat cheat: Cheat) throws
|
||||||
{
|
{
|
||||||
try self.emulatorCore.activateCheat(cheat)
|
try self.emulatorCore.activate(cheat)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cheatsViewController(_ cheatsViewController: CheatsViewController, didDeactivateCheat cheat: Cheat)
|
func cheatsViewController(_ cheatsViewController: CheatsViewController, didDeactivateCheat cheat: Cheat)
|
||||||
{
|
{
|
||||||
self.emulatorCore.deactivateCheat(cheat)
|
self.emulatorCore.deactivate(cheat)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateCheats()
|
private func updateCheats()
|
||||||
@ -590,7 +589,7 @@ extension EmulationViewController: CheatsViewControllerDelegate
|
|||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
try self.emulatorCore.activateCheat(cheat)
|
try self.emulatorCore.activate(cheat)
|
||||||
}
|
}
|
||||||
catch EmulatorCore.CheatError.invalid
|
catch EmulatorCore.CheatError.invalid
|
||||||
{
|
{
|
||||||
@ -604,7 +603,7 @@ extension EmulationViewController: CheatsViewControllerDelegate
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
self.emulatorCore.deactivateCheat(cheat)
|
self.emulatorCore.deactivate(cheat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,10 +633,10 @@ private extension EmulationViewController
|
|||||||
|
|
||||||
//MARK: - <GameControllerReceiver> -
|
//MARK: - <GameControllerReceiver> -
|
||||||
/// <GameControllerReceiver>
|
/// <GameControllerReceiver>
|
||||||
extension EmulationViewController: GameControllerReceiverProtocol
|
extension EmulationViewController: GameControllerReceiver
|
||||||
{
|
{
|
||||||
func gameController(_ gameController: GameControllerProtocol, didActivateInput input: InputType)
|
func gameController(_ gameController: GameController, didActivate input: Input)
|
||||||
{
|
{
|
||||||
if gameController is ControllerView && UIDevice.current().isVibrationSupported
|
if gameController is ControllerView && UIDevice.current().isVibrationSupported
|
||||||
{
|
{
|
||||||
UIDevice.current().vibrate()
|
UIDevice.current().vibrate()
|
||||||
@ -673,7 +672,7 @@ extension EmulationViewController: GameControllerReceiverProtocol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func gameController(_ gameController: GameControllerProtocol, didDeactivateInput input: InputType)
|
func gameController(_ gameController: GameController, didDeactivate input: Input)
|
||||||
{
|
{
|
||||||
guard let input = input as? ControllerInput else { return }
|
guard let input = input as? ControllerInput else { return }
|
||||||
|
|
||||||
|
|||||||
@ -132,12 +132,12 @@ class GamesViewController: UIViewController
|
|||||||
|
|
||||||
if let saveState = game.previewSaveState
|
if let saveState = game.previewSaveState
|
||||||
{
|
{
|
||||||
destinationViewController.emulatorCore.startEmulation()
|
destinationViewController.emulatorCore.start()
|
||||||
destinationViewController.emulatorCore.pauseEmulation()
|
destinationViewController.emulatorCore.pause()
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
try destinationViewController.emulatorCore.loadSaveState(saveState)
|
try destinationViewController.emulatorCore.load(saveState)
|
||||||
}
|
}
|
||||||
catch EmulatorCore.SaveStateError.doesNotExist
|
catch EmulatorCore.SaveStateError.doesNotExist
|
||||||
{
|
{
|
||||||
|
|||||||
@ -148,7 +148,7 @@ private extension CheatsViewController
|
|||||||
{
|
{
|
||||||
let editCheatViewController = self.storyboard!.instantiateViewController(withIdentifier: "editCheatViewController") as! EditCheatViewController
|
let editCheatViewController = self.storyboard!.instantiateViewController(withIdentifier: "editCheatViewController") as! EditCheatViewController
|
||||||
editCheatViewController.delegate = self
|
editCheatViewController.delegate = self
|
||||||
editCheatViewController.supportedCheatFormats = self.delegate.cheatsViewControllerActiveEmulatorCore(self).supportedCheatFormats
|
editCheatViewController.supportedCheatFormats = self.delegate.cheatsViewControllerActiveEmulatorCore(self).configuration.supportedCheatFormats
|
||||||
editCheatViewController.cheat = cheat
|
editCheatViewController.cheat = cheat
|
||||||
editCheatViewController.game = self.delegate.cheatsViewControllerActiveEmulatorCore(self).game as! Game
|
editCheatViewController.game = self.delegate.cheatsViewControllerActiveEmulatorCore(self).game as! Game
|
||||||
|
|
||||||
|
|||||||
@ -87,7 +87,7 @@ extension EditCheatViewController
|
|||||||
|
|
||||||
name = self.mutableCheat.name
|
name = self.mutableCheat.name
|
||||||
type = self.mutableCheat.type
|
type = self.mutableCheat.type
|
||||||
code = self.mutableCheat.code.sanitized(characterSet: self.selectedCheatFormat.allowedCodeCharacters)
|
code = self.mutableCheat.code.sanitized(with: self.selectedCheatFormat.allowedCodeCharacters)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ private extension EditCheatViewController
|
|||||||
|
|
||||||
self.mutableCheat.name = self.nameTextField.text ?? ""
|
self.mutableCheat.name = self.nameTextField.text ?? ""
|
||||||
self.mutableCheat.type = self.selectedCheatFormat.type
|
self.mutableCheat.type = self.selectedCheatFormat.type
|
||||||
self.mutableCheat.code = self.codeTextView.text.formatted(cheatFormat: self.selectedCheatFormat)
|
self.mutableCheat.code = self.codeTextView.text.formatted(with: self.selectedCheatFormat)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -386,7 +386,7 @@ extension EditCheatViewController: UITextViewDelegate
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
let sanitizedText = text.sanitized(characterSet: self.selectedCheatFormat.allowedCodeCharacters)
|
let sanitizedText = text.sanitized(with: self.selectedCheatFormat.allowedCodeCharacters)
|
||||||
|
|
||||||
guard sanitizedText != text else { return true }
|
guard sanitizedText != text else { return true }
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ protocol SaveStatesViewControllerDelegate: class
|
|||||||
{
|
{
|
||||||
func saveStatesViewControllerActiveEmulatorCore(_ saveStatesViewController: SaveStatesViewController) -> EmulatorCore
|
func saveStatesViewControllerActiveEmulatorCore(_ saveStatesViewController: SaveStatesViewController) -> EmulatorCore
|
||||||
func saveStatesViewController(_ saveStatesViewController: SaveStatesViewController, updateSaveState saveState: SaveState)
|
func saveStatesViewController(_ saveStatesViewController: SaveStatesViewController, updateSaveState saveState: SaveState)
|
||||||
func saveStatesViewController(_ saveStatesViewController: SaveStatesViewController, loadSaveState saveState: SaveStateType)
|
func saveStatesViewController(_ saveStatesViewController: SaveStatesViewController, loadSaveState saveState: SaveStateProtocol)
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SaveStatesViewController
|
extension SaveStatesViewController
|
||||||
@ -56,7 +56,7 @@ class SaveStatesViewController: UICollectionViewController
|
|||||||
private let imageOperationQueue = RSTOperationQueue()
|
private let imageOperationQueue = RSTOperationQueue()
|
||||||
private let imageCache = Cache<NSURL, UIImage>()
|
private let imageCache = Cache<NSURL, UIImage>()
|
||||||
|
|
||||||
private var currentGameState: SaveStateType?
|
private var currentGameState: SaveStateProtocol?
|
||||||
private var selectedSaveState: SaveState?
|
private var selectedSaveState: SaveState?
|
||||||
|
|
||||||
private let dateFormatter: DateFormatter
|
private let dateFormatter: DateFormatter
|
||||||
@ -275,8 +275,8 @@ private extension SaveStatesViewController
|
|||||||
|
|
||||||
if emulatorCore.state == .stopped
|
if emulatorCore.state == .stopped
|
||||||
{
|
{
|
||||||
emulatorCore.startEmulation()
|
emulatorCore.start()
|
||||||
emulatorCore.pauseEmulation()
|
emulatorCore.pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.delegate?.saveStatesViewController(self, loadSaveState: saveState)
|
self.delegate?.saveStatesViewController(self, loadSaveState: saveState)
|
||||||
@ -425,16 +425,16 @@ private extension SaveStatesViewController
|
|||||||
emulatorCore.videoManager.enabled = false
|
emulatorCore.videoManager.enabled = false
|
||||||
|
|
||||||
// Load the save state we stored a reference to
|
// Load the save state we stored a reference to
|
||||||
emulatorCore.startEmulation()
|
emulatorCore.start()
|
||||||
emulatorCore.pauseEmulation()
|
emulatorCore.pause()
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
try emulatorCore.loadSaveState(saveState)
|
try emulatorCore.load(saveState)
|
||||||
}
|
}
|
||||||
catch EmulatorCore.SaveStateError.doesNotExist
|
catch EmulatorCore.SaveStateError.doesNotExist
|
||||||
{
|
{
|
||||||
print("Save State \(saveState.name) does not exist.")
|
print("Save State does not exist.")
|
||||||
}
|
}
|
||||||
catch let error as NSError
|
catch let error as NSError
|
||||||
{
|
{
|
||||||
@ -533,7 +533,7 @@ extension SaveStatesViewController: UIViewControllerPreviewingDelegate
|
|||||||
// Store reference to current game state before we stop emulation so we can resume it if user decides to not load a save state
|
// Store reference to current game state before we stop emulation so we can resume it if user decides to not load a save state
|
||||||
if self.currentGameState == nil
|
if self.currentGameState == nil
|
||||||
{
|
{
|
||||||
emulatorCore.saveSaveState() { saveState in
|
emulatorCore.save() { saveState in
|
||||||
|
|
||||||
let fileURL = FileManager.uniqueTemporaryURL()
|
let fileURL = FileManager.uniqueTemporaryURL()
|
||||||
|
|
||||||
@ -546,18 +546,18 @@ extension SaveStatesViewController: UIViewControllerPreviewingDelegate
|
|||||||
print(error)
|
print(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.currentGameState = DeltaCore.SaveState(name: nil, fileURL: fileURL)
|
self.currentGameState = DeltaCore.SaveState(fileURL: fileURL, gameType: emulatorCore.game.type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emulatorCore.stopEmulation()
|
emulatorCore.stop()
|
||||||
|
|
||||||
emulationViewController.emulatorCore.startEmulation()
|
emulationViewController.emulatorCore.start()
|
||||||
emulationViewController.emulatorCore.pauseEmulation()
|
emulationViewController.emulatorCore.pause()
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
try emulationViewController.emulatorCore.loadSaveState(saveState)
|
try emulationViewController.emulatorCore.load(saveState)
|
||||||
}
|
}
|
||||||
catch EmulatorCore.SaveStateError.doesNotExist
|
catch EmulatorCore.SaveStateError.doesNotExist
|
||||||
{
|
{
|
||||||
@ -576,17 +576,17 @@ extension SaveStatesViewController: UIViewControllerPreviewingDelegate
|
|||||||
{
|
{
|
||||||
let emulationViewController = viewControllerToCommit as! EmulationViewController
|
let emulationViewController = viewControllerToCommit as! EmulationViewController
|
||||||
|
|
||||||
emulationViewController.emulatorCore.pauseEmulation()
|
emulationViewController.emulatorCore.pause()
|
||||||
emulationViewController.emulatorCore.saveSaveState() { saveState in
|
emulationViewController.emulatorCore.save() { saveState in
|
||||||
|
|
||||||
emulationViewController.emulatorCore.stopEmulation()
|
emulationViewController.emulatorCore.stop()
|
||||||
|
|
||||||
let emulatorCore = self.delegate.saveStatesViewControllerActiveEmulatorCore(self)
|
let emulatorCore = self.delegate.saveStatesViewControllerActiveEmulatorCore(self)
|
||||||
|
|
||||||
emulatorCore.audioManager.stop()
|
emulatorCore.audioManager.stop()
|
||||||
|
|
||||||
emulatorCore.startEmulation()
|
emulatorCore.start()
|
||||||
emulatorCore.pauseEmulation()
|
emulatorCore.pause()
|
||||||
|
|
||||||
self.delegate.saveStatesViewController(self, loadSaveState: saveState)
|
self.delegate.saveStatesViewController(self, loadSaveState: saveState)
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ class ControllersSettingsViewController: UITableViewController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var connectedControllers = ExternalControllerManager.sharedManager.connectedControllers.sorted(isOrderedBefore: { $0.playerIndex ?? NSIntegerMax < $1.playerIndex ?? NSIntegerMax })
|
private var connectedControllers = ExternalControllerManager.shared.connectedControllers.sorted(isOrderedBefore: { $0.playerIndex ?? NSIntegerMax < $1.playerIndex ?? NSIntegerMax })
|
||||||
|
|
||||||
private lazy var localDeviceController: LocalDeviceController = {
|
private lazy var localDeviceController: LocalDeviceController = {
|
||||||
let device = LocalDeviceController()
|
let device = LocalDeviceController()
|
||||||
@ -52,8 +52,8 @@ class ControllersSettingsViewController: UITableViewController
|
|||||||
{
|
{
|
||||||
super.init(coder: aDecoder)
|
super.init(coder: aDecoder)
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(ControllersSettingsViewController.externalControllerDidConnect(_:)), name: NSNotification.Name(rawValue: ExternalControllerDidConnectNotification), object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(ControllersSettingsViewController.externalControllerDidConnect(_:)), name: .externalControllerDidConnect, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(ControllersSettingsViewController.externalControllerDidDisconnect(_:)), name: NSNotification.Name(rawValue: ExternalControllerDidDisconnectNotification), object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(ControllersSettingsViewController.externalControllerDidDisconnect(_:)), name: .externalControllerDidDisconnect, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidLoad()
|
override func viewDidLoad()
|
||||||
|
|||||||
@ -25,8 +25,8 @@ class SettingsViewController: UITableViewController
|
|||||||
{
|
{
|
||||||
super.init(coder: aDecoder)
|
super.init(coder: aDecoder)
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(SettingsViewController.externalControllerDidConnect(_:)), name: NSNotification.Name(rawValue: ExternalControllerDidConnectNotification), object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(SettingsViewController.externalControllerDidConnect(_:)), name: .externalControllerDidConnect, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(SettingsViewController.externalControllerDidDisconnect(_:)), name: NSNotification.Name(rawValue: ExternalControllerDidDisconnectNotification), object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(SettingsViewController.externalControllerDidDisconnect(_:)), name: .externalControllerDidDisconnect, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidLoad()
|
override func viewDidLoad()
|
||||||
@ -96,9 +96,9 @@ extension SettingsViewController
|
|||||||
{
|
{
|
||||||
cell.detailTextLabel?.text = UIDevice.current().name
|
cell.detailTextLabel?.text = UIDevice.current().name
|
||||||
}
|
}
|
||||||
else if let index = ExternalControllerManager.sharedManager.connectedControllers.index(where: { $0.playerIndex == (indexPath as NSIndexPath).row })
|
else if let index = ExternalControllerManager.shared.connectedControllers.index(where: { $0.playerIndex == (indexPath as NSIndexPath).row })
|
||||||
{
|
{
|
||||||
let controller = ExternalControllerManager.sharedManager.connectedControllers[index]
|
let controller = ExternalControllerManager.shared.connectedControllers[index]
|
||||||
cell.detailTextLabel?.text = controller.name
|
cell.detailTextLabel?.text = controller.name
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
2
External/Roxas
vendored
2
External/Roxas
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 17cc7b771ca819cdad14c05ee9cd0529d5df1c91
|
Subproject commit 402032d5d73916f8079aa91a0e325a6878a2124d
|
||||||
Loading…
Reference in New Issue
Block a user