Commit 60a7945f authored by toby's avatar toby

rename rootviewcontroller, clean up state trans

parent d395992e
......@@ -8,7 +8,7 @@
/* Begin PBXBuildFile section */
DA376F0D1AAD1C4B0071423A /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA376F0C1AAD1C4B0071423A /* AppDelegate.swift */; };
DA376F0F1AAD1C4B0071423A /* WorldViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA376F0E1AAD1C4B0071423A /* WorldViewController.swift */; };
DA376F0F1AAD1C4B0071423A /* RootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA376F0E1AAD1C4B0071423A /* RootViewController.swift */; };
DA376F141AAD1C4B0071423A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DA376F131AAD1C4B0071423A /* Images.xcassets */; };
DA376F171AAD1C4B0071423A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = DA376F151AAD1C4B0071423A /* LaunchScreen.xib */; };
DA376F231AAD1C4B0071423A /* loboTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA376F221AAD1C4B0071423A /* loboTests.swift */; };
......@@ -31,7 +31,7 @@
DA376F071AAD1C4B0071423A /* lobo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = lobo.app; sourceTree = BUILT_PRODUCTS_DIR; };
DA376F0B1AAD1C4B0071423A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
DA376F0C1AAD1C4B0071423A /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
DA376F0E1AAD1C4B0071423A /* WorldViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WorldViewController.swift; sourceTree = "<group>"; };
DA376F0E1AAD1C4B0071423A /* RootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootViewController.swift; sourceTree = "<group>"; };
DA376F131AAD1C4B0071423A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
DA376F161AAD1C4B0071423A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
DA376F1C1AAD1C4B0071423A /* loboTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = loboTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -84,7 +84,7 @@
DA376F0C1AAD1C4B0071423A /* AppDelegate.swift */,
DA6CF1081ABF865500270C05 /* StateMachine.swift */,
DAAE8A521ABE313400DDFA37 /* Utils.swift */,
DA376F0E1AAD1C4B0071423A /* WorldViewController.swift */,
DA376F0E1AAD1C4B0071423A /* RootViewController.swift */,
DAFF0D0F1AE3270000ADC4BF /* ColorDetailViewController.swift */,
DA376F131AAD1C4B0071423A /* Images.xcassets */,
DA376F151AAD1C4B0071423A /* LaunchScreen.xib */,
......@@ -218,7 +218,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
DA376F0F1AAD1C4B0071423A /* WorldViewController.swift in Sources */,
DA376F0F1AAD1C4B0071423A /* RootViewController.swift in Sources */,
DA376F0D1AAD1C4B0071423A /* AppDelegate.swift in Sources */,
DAAE8A531ABE313400DDFA37 /* Utils.swift in Sources */,
DAFF0D101AE3270000ADC4BF /* ColorDetailViewController.swift in Sources */,
......
......@@ -13,10 +13,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let worldViewController = WorldViewController()
let navigationController = UINavigationController(rootViewController: worldViewController)
let rootViewController = RootViewController()
let navigationController = UINavigationController(rootViewController: rootViewController)
window = UIWindow(frame: UIScreen.mainScreen().bounds)
window!.rootViewController = navigationController
window!.makeKeyAndVisible()
......
......@@ -27,41 +27,38 @@ func backgroundStateToString(state: BackgroundState) -> String {
}
enum BackgroundState:StateMachineDataSource{
enum BackgroundState: StateMachineDataSource {
case Ready, AnimatingBackground, AddBlock(UIView), RemoveBlock(UIView), PausedBackground, Finished
func shouldTransitionFrom(from:BackgroundState, to: BackgroundState) -> Should {
func shouldTransitionFrom(from: BackgroundState, to: BackgroundState) -> Should {
switch (from, to){
case (.Ready, .AnimatingBackground):
return .Continue
case (.PausedBackground, .AnimatingBackground):
return .Continue
case (.AnimatingBackground, .PausedBackground):
return .Continue
case (.AnimatingBackground, .Finished):
return .Continue
case (.PausedBackground, .Finished):
return .Continue
case (.Finished, .AnimatingBackground):
return .Continue
case(_, .RemoveBlock(let block)):
return .Continue
case(.RemoveBlock(let block), _):
case(.AnimatingBackground, .AnimatingBackground):
return .Abort
case(.AnimatingBackground, _):
return .Continue
case(.Ready, .AddBlock(let block)):
case(_, .AnimatingBackground):
return .Continue
case(.AnimatingBackground, .AddBlock(let block)):
case(.PausedBackground, .PausedBackground):
return .Abort
case(.PausedBackground, _):
return .Continue
case(.PausedBackground, .AddBlock(let block)):
case(_, .PausedBackground):
return .Continue
case(.Finished, .AddBlock(let block)):
case(.AddBlock, .AddBlock):
return .Abort
case(.AddBlock, _):
return .Continue
case(.AddBlock(let block), .Ready):
case(_, .AddBlock):
return .Continue
case(.AddBlock(let block), .AnimatingBackground):
case(.RemoveBlock(_), .RemoveBlock(_)):
return .Abort
case(_, .RemoveBlock(_)):
return .Continue
case(.AddBlock(let block), .PausedBackground):
case(.RemoveBlock(_), _):
return .Continue
default:
return .Abort
}
......@@ -69,7 +66,7 @@ enum BackgroundState:StateMachineDataSource{
}
extension WorldViewController: StateMachineDelegate {
extension RootViewController: StateMachineDelegate {
typealias StateType = BackgroundState
......@@ -100,12 +97,12 @@ extension WorldViewController: StateMachineDelegate {
}
class WorldViewController: UIViewController {
class RootViewController: UIViewController {
var animator: UIDynamicAnimator!
var gravity: UIGravityBehavior!
var collision: UICollisionBehavior!
var machine: StateMachine<WorldViewController>!
var machine: StateMachine<RootViewController>!
var autoViews = [String: UIView]()
var background: UIView!
......@@ -279,7 +276,6 @@ class WorldViewController: UIViewController {
}
@IBAction func backgroundHeld(hold: UILongPressGestureRecognizer) {
println("machine.state: \(backgroundStateToString(machine.state))")
switch hold.state {
case UIGestureRecognizerState.Began:
machine.state = .AnimatingBackground
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment