From f615b65f5e400421323557cf1d332ce375d6d05e Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Tue, 16 Jun 2015 01:45:24 -0500 Subject: [PATCH] Added EmulationViewController, displays ControllerView --- Cores/DeltaCore | 2 +- Delta.xcodeproj/project.pbxproj | 19 ++++++- Delta/EmulationViewController.swift | 77 +++++++++++++++++++++++++++++ Delta/EmulationViewController.xib | 52 +++++++++++++++++++ Delta/GamesViewController.swift | 4 +- 5 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 Delta/EmulationViewController.swift create mode 100644 Delta/EmulationViewController.xib diff --git a/Cores/DeltaCore b/Cores/DeltaCore index 0fe2040..cb3e98f 160000 --- a/Cores/DeltaCore +++ b/Cores/DeltaCore @@ -1 +1 @@ -Subproject commit 0fe20409850d1d4c1b3bd4f40d304eace2346eec +Subproject commit cb3e98f268e615aac3906572fa001ada5e99eadc diff --git a/Delta.xcodeproj/project.pbxproj b/Delta.xcodeproj/project.pbxproj index 874484f..0c51ac2 100644 --- a/Delta.xcodeproj/project.pbxproj +++ b/Delta.xcodeproj/project.pbxproj @@ -19,6 +19,8 @@ BFFA71E21AAC406100EE9DD1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BFFA71E01AAC406100EE9DD1 /* Main.storyboard */; }; BFFA71E41AAC406100EE9DD1 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BFFA71E31AAC406100EE9DD1 /* Images.xcassets */; }; BFFA71E71AAC406100EE9DD1 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = BFFA71E51AAC406100EE9DD1 /* LaunchScreen.xib */; }; + BFFB709F1AF99B1700DE56FE /* EmulationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFFB709E1AF99B1700DE56FE /* EmulationViewController.swift */; }; + BFFB70A11AF99DFB00DE56FE /* EmulationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BFFB70A01AF99DFB00DE56FE /* EmulationViewController.xib */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -49,6 +51,8 @@ BFFA71E11AAC406100EE9DD1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; BFFA71E31AAC406100EE9DD1 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; BFFA71E61AAC406100EE9DD1 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; + BFFB709E1AF99B1700DE56FE /* EmulationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmulationViewController.swift; sourceTree = ""; }; + BFFB70A01AF99DFB00DE56FE /* EmulationViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = EmulationViewController.xib; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -115,6 +119,7 @@ BFFA71DC1AAC406100EE9DD1 /* AppDelegate.swift */, BFFA71E01AAC406100EE9DD1 /* Main.storyboard */, BF46894D1AAC469800A2586D /* Game Selection */, + BFFB709D1AF99ACA00DE56FE /* Emulation */, BFEC732F1AAECCBD00650035 /* Resources */, BFFA71DA1AAC406100EE9DD1 /* Supporting Files */, ); @@ -130,6 +135,15 @@ name = "Supporting Files"; sourceTree = ""; }; + BFFB709D1AF99ACA00DE56FE /* Emulation */ = { + isa = PBXGroup; + children = ( + BFFB709E1AF99B1700DE56FE /* EmulationViewController.swift */, + BFFB70A01AF99DFB00DE56FE /* EmulationViewController.xib */, + ); + name = Emulation; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -157,6 +171,7 @@ BFFA71CF1AAC406100EE9DD1 /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 0700; LastUpgradeCheck = 0630; ORGANIZATIONNAME = "Riley Testut"; TargetAttributes = { @@ -189,6 +204,7 @@ buildActionMask = 2147483647; files = ( BFFA71E21AAC406100EE9DD1 /* Main.storyboard in Resources */, + BFFB70A11AF99DFB00DE56FE /* EmulationViewController.xib in Resources */, BFFA71E71AAC406100EE9DD1 /* LaunchScreen.xib in Resources */, BFFA71E41AAC406100EE9DD1 /* Images.xcassets in Resources */, ); @@ -202,6 +218,7 @@ buildActionMask = 2147483647; files = ( BFFA71DF1AAC406100EE9DD1 /* GamesViewController.swift in Sources */, + BFFB709F1AF99B1700DE56FE /* EmulationViewController.swift in Sources */, BFFA71DD1AAC406100EE9DD1 /* AppDelegate.swift in Sources */, BF46894F1AAC46EF00A2586D /* DirectoryContentsDataSource.swift in Sources */, ); @@ -290,7 +307,7 @@ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; diff --git a/Delta/EmulationViewController.swift b/Delta/EmulationViewController.swift new file mode 100644 index 0000000..2299d13 --- /dev/null +++ b/Delta/EmulationViewController.swift @@ -0,0 +1,77 @@ +// +// EmulationViewController.swift +// Delta +// +// Created by Riley Testut on 5/5/15. +// Copyright (c) 2015 Riley Testut. All rights reserved. +// + +import UIKit +import DeltaCore +import SNESDeltaCore + +class EmulationViewController: UIViewController +{ + let game: Game + let emulatorCore: EmulatorCore + @IBOutlet private(set) var controllerView: ControllerView! + + @IBOutlet private var controllerViewHeightConstraint: NSLayoutConstraint! + + required init(game: Game) + { + self.game = game + self.emulatorCore = SNESEmulatorCore(game: game) + + super.init(nibName: "EmulationViewController", bundle: nil) + } + + required init(coder aDecoder: NSCoder) { + fatalError("initWithCoder: not implemented.") + } + + //MARK: UIViewController + + override func viewDidLoad() + { + super.viewDidLoad() + + let skinURL = self.game.URL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("Standard.deltaskin") + let controllerSkin = ControllerSkin(URL: skinURL!) + + self.controllerView.controllerSkin = controllerSkin + + println(self.controllerView.intrinsicContentSize()) + } + + override func viewDidAppear(animated: Bool) + { + super.viewDidAppear(animated) + + self.emulatorCore.startEmulation() + } + + override func viewDidLayoutSubviews() + { + super.viewDidLayoutSubviews() + + let scale = self.view.bounds.width / self.controllerView.intrinsicContentSize().width + self.controllerViewHeightConstraint.constant = self.controllerView.intrinsicContentSize().height * scale + } + + override func willTransitionToTraitCollection(newCollection: UITraitCollection, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) + { + super.willTransitionToTraitCollection(newCollection, withTransitionCoordinator: coordinator) + + self.controllerView.beginAnimatingUpdateControllerSkin() + + coordinator.animateAlongsideTransition(nil) { (context) in + self.controllerView.finishAnimatingUpdateControllerSkin() + } + } + + override func prefersStatusBarHidden() -> Bool + { + return true + } +} diff --git a/Delta/EmulationViewController.xib b/Delta/EmulationViewController.xib new file mode 100644 index 0000000..a882018 --- /dev/null +++ b/Delta/EmulationViewController.xib @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Delta/GamesViewController.swift b/Delta/GamesViewController.swift index b7f0255..81e50d5 100644 --- a/Delta/GamesViewController.swift +++ b/Delta/GamesViewController.swift @@ -76,8 +76,8 @@ class GamesViewController: UITableViewController { if let URL = self.directoryContentsDataSource?.URLAtIndexPath(indexPath), game = Game(URL: URL) where game.UTI != kUTTypeDeltaGame as String { - println(game.name) - let emulatorCore = EmulatorCore(game: game) + let emulationViewController = EmulationViewController(game: game) + self.presentViewController(emulationViewController, animated: true, completion: nil) } else {