Adds supportConfigurations property to ControllerSkin model
Allows database querying of controller skins based on configurations they support
This commit is contained in:
parent
023fe13c6a
commit
dc9cb367de
@ -65,9 +65,8 @@ private extension DatabaseManager
|
||||
let controllerSkin = ControllerSkin(context: context)
|
||||
controllerSkin.isStandard = true
|
||||
controllerSkin.filename = deltaControllerSkin.fileURL.lastPathComponent
|
||||
controllerSkin.name = deltaControllerSkin.name
|
||||
controllerSkin.identifier = deltaControllerSkin.identifier
|
||||
controllerSkin.gameType = deltaControllerSkin.gameType
|
||||
|
||||
controllerSkin.configure(with: deltaControllerSkin)
|
||||
}
|
||||
|
||||
do
|
||||
@ -100,14 +99,10 @@ extension DatabaseManager
|
||||
guard let deltaControllerSkin = DeltaCore.ControllerSkin(fileURL: url) else { continue }
|
||||
|
||||
let controllerSkin = ControllerSkin(context: context)
|
||||
|
||||
// Manually copy values to be stored in database.
|
||||
// Remaining ControllerSkinProtocol requirements will be provided by the ControllerSkin's private DeltaCore.ControllerSkin instance.
|
||||
controllerSkin.filename = deltaControllerSkin.identifier + ".deltaskin"
|
||||
controllerSkin.name = deltaControllerSkin.name
|
||||
controllerSkin.identifier = deltaControllerSkin.identifier
|
||||
controllerSkin.gameType = deltaControllerSkin.gameType
|
||||
|
||||
controllerSkin.configure(with: deltaControllerSkin)
|
||||
|
||||
do
|
||||
{
|
||||
if FileManager.default.fileExists(atPath: controllerSkin.fileURL.path)
|
||||
|
||||
@ -10,6 +10,45 @@ import Foundation
|
||||
|
||||
import DeltaCore
|
||||
|
||||
extension ControllerSkinConfigurations
|
||||
{
|
||||
init(traits: DeltaCore.ControllerSkin.Traits)
|
||||
{
|
||||
switch traits.deviceType
|
||||
{
|
||||
case .iphone:
|
||||
|
||||
switch traits.orientation
|
||||
{
|
||||
case .portrait: self = .fullScreenPortrait
|
||||
case .landscape: self = .fullScreenLandscape
|
||||
}
|
||||
|
||||
case .ipad:
|
||||
|
||||
switch traits.displayMode
|
||||
{
|
||||
case .fullScreen:
|
||||
|
||||
switch traits.orientation
|
||||
{
|
||||
case .portrait: self = .fullScreenPortrait
|
||||
case .landscape: self = .fullScreenLandscape
|
||||
}
|
||||
|
||||
case .splitView:
|
||||
|
||||
switch traits.orientation
|
||||
{
|
||||
case .portrait: self = .splitViewPortrait
|
||||
case .landscape: self = .splitViewLandscape
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc(ControllerSkin)
|
||||
public class ControllerSkin: _ControllerSkin
|
||||
{
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="11232" systemVersion="16A320" minimumToolsVersion="Xcode 7.0" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="1.0">
|
||||
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="11542" systemVersion="16B2555" minimumToolsVersion="Xcode 7.0" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="1.0">
|
||||
<entity name="Cheat" representedClassName="Cheat" syncable="YES">
|
||||
<attribute name="code" attributeType="String" syncable="YES"/>
|
||||
<attribute name="creationDate" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
|
||||
@ -29,6 +29,11 @@
|
||||
<attribute name="identifier" attributeType="String" syncable="YES"/>
|
||||
<attribute name="isStandard" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
|
||||
<attribute name="name" attributeType="String" syncable="YES"/>
|
||||
<attribute name="supportedConfigurations" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES" syncable="YES">
|
||||
<userInfo>
|
||||
<entry key="attributeValueScalarType" value="ControllerSkinConfigurations"/>
|
||||
</userInfo>
|
||||
</attribute>
|
||||
<uniquenessConstraints>
|
||||
<uniquenessConstraint>
|
||||
<constraint value="identifier"/>
|
||||
@ -99,7 +104,7 @@
|
||||
</entity>
|
||||
<elements>
|
||||
<element name="Cheat" positionX="-198" positionY="-63" width="128" height="165"/>
|
||||
<element name="ControllerSkin" positionX="-387" positionY="90" width="128" height="120"/>
|
||||
<element name="ControllerSkin" positionX="-387" positionY="90" width="128" height="135"/>
|
||||
<element name="Game" positionX="-378" positionY="-54" width="128" height="180"/>
|
||||
<element name="GameCollection" positionX="-585" positionY="-27" width="128" height="90"/>
|
||||
<element name="SaveState" positionX="-198" positionY="113" width="128" height="165"/>
|
||||
|
||||
21
Common/Database/Model/Misc/ControllerSkinConfigurations.h
Normal file
21
Common/Database/Model/Misc/ControllerSkinConfigurations.h
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// ControllerSkinConfigurations.h
|
||||
// Delta
|
||||
//
|
||||
// Created by Riley Testut on 11/1/16.
|
||||
// Copyright © 2016 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef ControllerSkinConfigurations_h
|
||||
#define ControllerSkinConfigurations_h
|
||||
|
||||
typedef NS_OPTIONS(int16_t, ControllerSkinConfigurations)
|
||||
{
|
||||
ControllerSkinConfigurationFullScreenPortrait = 1 << 0,
|
||||
ControllerSkinConfigurationFullScreenLandscape = 1 << 1,
|
||||
|
||||
ControllerSkinConfigurationSplitViewPortrait = 1 << 2,
|
||||
ControllerSkinConfigurationSplitViewLandscape = 1 << 3,
|
||||
};
|
||||
|
||||
#endif /* ControllerSkinConfigurations_h */
|
||||
@ -24,6 +24,8 @@ public class _ControllerSkin: NSManagedObject
|
||||
|
||||
@NSManaged public var name: String
|
||||
|
||||
@NSManaged public var supportedConfigurations: ControllerSkinConfigurations
|
||||
|
||||
// MARK: - Relationships
|
||||
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
BF3540081C5DAFAD00C1184C /* PauseTransitionCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3540071C5DAFAD00C1184C /* PauseTransitionCoordinator.swift */; };
|
||||
BF5E7F441B9A650B00AE44F8 /* SettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF5E7F431B9A650B00AE44F8 /* SettingsViewController.swift */; };
|
||||
BF5E7F461B9A652600AE44F8 /* Settings.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF5E7F451B9A652600AE44F8 /* Settings.storyboard */; };
|
||||
BF6866171DCAC8B900BF2D06 /* ControllerSkin+Configuring.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF6866161DCAC8B900BF2D06 /* ControllerSkin+Configuring.swift */; };
|
||||
BF696B801D9B2B02009639E0 /* Theme.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF696B7F1D9B2B02009639E0 /* Theme.swift */; };
|
||||
BF70798C1B6B464B0019077C /* ZipZap.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF70798B1B6B464B0019077C /* ZipZap.framework */; };
|
||||
BF70798D1B6B464B0019077C /* ZipZap.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BF70798B1B6B464B0019077C /* ZipZap.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
@ -108,6 +109,7 @@
|
||||
BF090CF11B490D8300DCAB45 /* Delta-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Delta-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
BF090CF21B490D8300DCAB45 /* UIDevice+Vibration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIDevice+Vibration.h"; sourceTree = "<group>"; };
|
||||
BF090CF31B490D8300DCAB45 /* UIDevice+Vibration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIDevice+Vibration.m"; sourceTree = "<group>"; };
|
||||
BF0A81C41DC915C800443EF0 /* ControllerSkinConfigurations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ControllerSkinConfigurations.h; path = Misc/ControllerSkinConfigurations.h; sourceTree = "<group>"; };
|
||||
BF0CDDAC1C8155D200640168 /* LoadImageOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LoadImageOperation.swift; path = Components/LoadImageOperation.swift; sourceTree = "<group>"; };
|
||||
BF107EC31BF413F000E0C32C /* GamesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GamesViewController.swift; sourceTree = "<group>"; };
|
||||
BF11734C1DA32A5200047DF8 /* GameType+Localization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "GameType+Localization.swift"; sourceTree = "<group>"; };
|
||||
@ -143,6 +145,7 @@
|
||||
BF5E7F431B9A650B00AE44F8 /* SettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsViewController.swift; sourceTree = "<group>"; };
|
||||
BF5E7F451B9A652600AE44F8 /* Settings.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Settings.storyboard; sourceTree = "<group>"; };
|
||||
BF63BDE91D389EEB00FCB040 /* GameViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameViewController.swift; sourceTree = "<group>"; };
|
||||
BF6866161DCAC8B900BF2D06 /* ControllerSkin+Configuring.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ControllerSkin+Configuring.swift"; sourceTree = "<group>"; };
|
||||
BF696B7F1D9B2B02009639E0 /* Theme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Theme.swift; path = Theming/Theme.swift; sourceTree = "<group>"; };
|
||||
BF6BB2451BB73FE800CCF94A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
BF70798B1B6B464B0019077C /* ZipZap.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ZipZap.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@ -213,10 +216,19 @@
|
||||
BFCEA67D1D56FF640061A534 /* UIViewControllerContextTransitioning+Conveniences.swift */,
|
||||
BF13A7571D5D2FD9000BB055 /* EmulatorCore+Cheats.swift */,
|
||||
BF11734C1DA32A5200047DF8 /* GameType+Localization.swift */,
|
||||
BF6866161DCAC8B900BF2D06 /* ControllerSkin+Configuring.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BF0A81C31DC915A100443EF0 /* Misc */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BF0A81C41DC915C800443EF0 /* ControllerSkinConfigurations.h */,
|
||||
);
|
||||
name = Misc;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BF11734E1DA32CEC00047DF8 /* Controllers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -302,6 +314,7 @@
|
||||
BF28980B1DAAFB640023D8E9 /* Delta.xcdatamodeld */,
|
||||
BF28980F1DAAFC0E0023D8E9 /* Human */,
|
||||
BF2898101DAAFC120023D8E9 /* Machine */,
|
||||
BF0A81C31DC915A100443EF0 /* Misc */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
@ -698,6 +711,7 @@
|
||||
BFC853351DB039AD00E8C372 /* _ControllerSkin.swift in Sources */,
|
||||
BFC853371DB039B500E8C372 /* ControllerSkin.swift in Sources */,
|
||||
BF13A7561D5D29B0000BB055 /* PreviewGameViewController.swift in Sources */,
|
||||
BF6866171DCAC8B900BF2D06 /* ControllerSkin+Configuring.swift in Sources */,
|
||||
BFDD04EF1D5E27DB002D450E /* NSFetchedResultsController+Conveniences.m in Sources */,
|
||||
BFCEA67E1D56FF640061A534 /* UIViewControllerContextTransitioning+Conveniences.swift in Sources */,
|
||||
BF2898161DAAFC2A0023D8E9 /* Game.swift in Sources */,
|
||||
|
||||
76
Delta/Extensions/ControllerSkin+Configuring.swift
Normal file
76
Delta/Extensions/ControllerSkin+Configuring.swift
Normal file
@ -0,0 +1,76 @@
|
||||
//
|
||||
// ControllerSkin+Configuring.swift
|
||||
// Delta
|
||||
//
|
||||
// Created by Riley Testut on 11/2/16.
|
||||
// Copyright © 2016 Riley Testut. All rights reserved.
|
||||
//
|
||||
|
||||
import DeltaCore
|
||||
|
||||
extension ControllerSkin
|
||||
{
|
||||
func configure(with skin: DeltaCore.ControllerSkin)
|
||||
{
|
||||
// Manually copy values to be stored in database.
|
||||
// Remaining ControllerSkinProtocol requirements will be provided by the ControllerSkin's private DeltaCore.ControllerSkin instance.
|
||||
self.name = skin.name
|
||||
self.identifier = skin.identifier
|
||||
self.gameType = skin.gameType
|
||||
|
||||
var configurations = ControllerSkinConfigurations()
|
||||
|
||||
if UIDevice.current.userInterfaceIdiom == .pad
|
||||
{
|
||||
var portraitTraits = DeltaCore.ControllerSkin.Traits(deviceType: .ipad, displayMode: .fullScreen, orientation: .portrait)
|
||||
|
||||
var landscapeTraits = portraitTraits
|
||||
landscapeTraits.orientation = .landscape
|
||||
|
||||
|
||||
if skin.supports(portraitTraits)
|
||||
{
|
||||
configurations.formUnion(.fullScreenPortrait)
|
||||
}
|
||||
|
||||
if skin.supports(landscapeTraits)
|
||||
{
|
||||
configurations.formUnion(.fullScreenLandscape)
|
||||
}
|
||||
|
||||
|
||||
portraitTraits.displayMode = .splitView
|
||||
landscapeTraits.displayMode = .splitView
|
||||
|
||||
|
||||
if skin.supports(portraitTraits)
|
||||
{
|
||||
configurations.formUnion(.splitViewPortrait)
|
||||
}
|
||||
|
||||
if skin.supports(landscapeTraits)
|
||||
{
|
||||
configurations.formUnion(.splitViewLandscape)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
let portraitTraits = DeltaCore.ControllerSkin.Traits(deviceType: .iphone, displayMode: .fullScreen, orientation: .portrait)
|
||||
|
||||
var landscapeTraits = portraitTraits
|
||||
landscapeTraits.orientation = .landscape
|
||||
|
||||
if skin.supports(portraitTraits)
|
||||
{
|
||||
configurations.formUnion(.fullScreenPortrait)
|
||||
}
|
||||
|
||||
if skin.supports(landscapeTraits)
|
||||
{
|
||||
configurations.formUnion(.fullScreenLandscape)
|
||||
}
|
||||
}
|
||||
|
||||
self.supportedConfigurations = configurations
|
||||
}
|
||||
}
|
||||
@ -4,3 +4,4 @@
|
||||
|
||||
#import "UIDevice+Vibration.h"
|
||||
#import "NSFetchedResultsController+Conveniences.h"
|
||||
#import "ControllerSkinConfigurations.h"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user