From 9406cfe6cc47ca87dbb29f59ea2c8d75c9a406a4 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 13 Apr 2023 15:41:55 -0500 Subject: [PATCH] [Features] Moves Settings.Name + Settings.NotificationUserInfoKey to DeltaFeatures Also refactors from enums to RawRepresentable structs to support arbitrary values. --- Delta.xcodeproj/project.pbxproj | 16 +++++++ Delta/Emulation/GameViewController.swift | 2 + Delta/Settings/Settings.swift | 42 +++++++++---------- Delta/Settings/SettingsViewController.swift | 1 + DeltaFeatures/Types/SettingsName.swift | 24 +++++++++++ DeltaFeatures/Types/SettingsUserInfoKey.swift | 30 +++++++++++++ 6 files changed, 93 insertions(+), 22 deletions(-) create mode 100644 DeltaFeatures/Types/SettingsName.swift create mode 100644 DeltaFeatures/Types/SettingsUserInfoKey.swift diff --git a/Delta.xcodeproj/project.pbxproj b/Delta.xcodeproj/project.pbxproj index 3c619ed..47a6583 100644 --- a/Delta.xcodeproj/project.pbxproj +++ b/Delta.xcodeproj/project.pbxproj @@ -166,6 +166,7 @@ BFFDF03723E3BB2600931B96 /* libSnes9x.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BFFDF03623E3BB2600931B96 /* libSnes9x.a */; }; BFFDF03F23E3C28A00931B96 /* libGambatte.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BFFDF03D23E3C0F000931B96 /* libGambatte.a */; }; BFFDF04623E3D3A600931B96 /* libMupen64Plus.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BFFDF04523E3D3A600931B96 /* libMupen64Plus.a */; }; + D517F6BA29E730DA000D14D0 /* SettingsName.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5A9C01929DDFBDD00A8D610 /* SettingsName.swift */; }; D524F4A1273DE9A100D500B2 /* AltKit in Frameworks */ = {isa = PBXBuildFile; productRef = D524F4A0273DE9A100D500B2 /* AltKit */; }; D524F4A3273DE9C000D500B2 /* ProcessInfo+JIT.swift in Sources */ = {isa = PBXBuildFile; fileRef = D524F4A2273DE9C000D500B2 /* ProcessInfo+JIT.swift */; }; D524F4A5273DEBB400D500B2 /* ServerManager+Delta.swift in Sources */ = {isa = PBXBuildFile; fileRef = D524F4A4273DEBB400D500B2 /* ServerManager+Delta.swift */; }; @@ -174,6 +175,7 @@ D53415A7298C78BC00FD67B1 /* Contributors.plist in Resources */ = {isa = PBXBuildFile; fileRef = D53415A6298C78BC00FD67B1 /* Contributors.plist */; }; D539103229E88B6C0006B350 /* DeltaPreviews.h in Headers */ = {isa = PBXBuildFile; fileRef = D539103129E88B6C0006B350 /* DeltaPreviews.h */; settings = {ATTRIBUTES = (Public, ); }; }; D539104029E88BC40006B350 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D539103F29E88BC40006B350 /* ContentView.swift */; }; + D54F710229E89DCB009C069A /* SettingsUserInfoKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = D54F710129E89DCB009C069A /* SettingsUserInfoKey.swift */; }; D5864970297734280081477E /* CheatMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = D586496F297734280081477E /* CheatMetadata.swift */; }; D586497229774ABD0081477E /* CheatBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D586497129774ABD0081477E /* CheatBase.swift */; }; D5864978297756CE0081477E /* CheatBaseView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5864977297756CE0081477E /* CheatBaseView.swift */; }; @@ -404,11 +406,13 @@ D539102F29E88B6B0006B350 /* DeltaPreviews.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DeltaPreviews.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D539103129E88B6C0006B350 /* DeltaPreviews.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeltaPreviews.h; sourceTree = ""; }; D539103F29E88BC40006B350 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + D54F710129E89DCB009C069A /* SettingsUserInfoKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsUserInfoKey.swift; sourceTree = ""; }; D586496F297734280081477E /* CheatMetadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheatMetadata.swift; sourceTree = ""; }; D586497129774ABD0081477E /* CheatBase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheatBase.swift; sourceTree = ""; }; D5864977297756CE0081477E /* CheatBaseView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheatBaseView.swift; sourceTree = ""; }; D5A98CE1284EF14B00E023E5 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; D5A9BFFD29DDECF100A8D610 /* Feature.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Feature.swift; sourceTree = ""; }; + D5A9C01929DDFBDD00A8D610 /* SettingsName.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsName.swift; sourceTree = ""; }; D5AAF27629884F8600F21ACF /* CheatDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheatDevice.swift; sourceTree = ""; }; D5D797E5298D946200738869 /* Contributor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Contributor.swift; sourceTree = ""; }; D5D797E7298DC9E200738869 /* cheatbase.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = cheatbase.zip; sourceTree = ""; }; @@ -963,6 +967,15 @@ path = Launch; sourceTree = ""; }; + D517F6BB29E737F5000D14D0 /* Types */ = { + isa = PBXGroup; + children = ( + D5A9C01929DDFBDD00A8D610 /* SettingsName.swift */, + D54F710129E89DCB009C069A /* SettingsUserInfoKey.swift */, + ); + path = Types; + sourceTree = ""; + }; D539103029E88B6C0006B350 /* DeltaPreviews */ = { isa = PBXGroup; children = ( @@ -997,6 +1010,7 @@ isa = PBXGroup; children = ( D5A9BFFD29DDECF100A8D610 /* Feature.swift */, + D517F6BB29E737F5000D14D0 /* Types */, ); path = DeltaFeatures; sourceTree = ""; @@ -1479,7 +1493,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + D517F6BA29E730DA000D14D0 /* SettingsName.swift in Sources */, D5D7C20429E60F2000663793 /* Feature.swift in Sources */, + D54F710229E89DCB009C069A /* SettingsUserInfoKey.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Delta/Emulation/GameViewController.swift b/Delta/Emulation/GameViewController.swift index 83a3147..0089c6a 100644 --- a/Delta/Emulation/GameViewController.swift +++ b/Delta/Emulation/GameViewController.swift @@ -1212,6 +1212,8 @@ private extension GameViewController self.updateAudio() case .syncingService, .isAltJITEnabled: break + + default: break } } diff --git a/Delta/Settings/Settings.swift b/Delta/Settings/Settings.swift index 7dfcc81..81fbe1b 100644 --- a/Delta/Settings/Settings.swift +++ b/Delta/Settings/Settings.swift @@ -9,6 +9,7 @@ import Foundation import DeltaCore +import DeltaFeatures import MelonDSDeltaCore import Roxas @@ -18,29 +19,23 @@ extension Notification.Name static let settingsDidChange = Notification.Name("SettingsDidChangeNotification") } -extension Settings +extension Settings.NotificationUserInfoKey { - enum NotificationUserInfoKey: String - { - case name - - case system - case traits - - case core - } - - enum Name: String - { - case localControllerPlayerIndex - case translucentControllerSkinOpacity - case preferredControllerSkin - case syncingService - case isButtonHapticFeedbackEnabled - case isThumbstickHapticFeedbackEnabled - case isAltJITEnabled - case respectSilentMode - } + static let system: Settings.NotificationUserInfoKey = "system" + static let traits: Settings.NotificationUserInfoKey = "traits" + static let core: Settings.NotificationUserInfoKey = "core" +} + +extension Settings.Name +{ + static let localControllerPlayerIndex: Settings.Name = "localControllerPlayerIndex" + static let translucentControllerSkinOpacity: Settings.Name = "translucentControllerSkinOpacity" + static let preferredControllerSkin: Settings.Name = "preferredControllerSkin" + static let syncingService: Settings.Name = "syncingService" + static let isButtonHapticFeedbackEnabled: Settings.Name = "isButtonHapticFeedbackEnabled" + static let isThumbstickHapticFeedbackEnabled: Settings.Name = "isThumbstickHapticFeedbackEnabled" + static let isAltJITEnabled: Settings.Name = "isAltJITEnabled" + static let respectSilentMode: Settings.Name = "respectSilentMode" } extension Settings @@ -50,6 +45,9 @@ extension Settings case recent case manual } + + typealias Name = SettingsName + typealias NotificationUserInfoKey = SettingsUserInfoKey } struct Settings diff --git a/Delta/Settings/SettingsViewController.swift b/Delta/Settings/SettingsViewController.swift index b59c4e2..abaeb91 100644 --- a/Delta/Settings/SettingsViewController.swift +++ b/Delta/Settings/SettingsViewController.swift @@ -309,6 +309,7 @@ private extension SettingsViewController } case .localControllerPlayerIndex, .preferredControllerSkin, .translucentControllerSkinOpacity, .respectSilentMode, .isButtonHapticFeedbackEnabled, .isThumbstickHapticFeedbackEnabled, .isAltJITEnabled: break + default: break } } diff --git a/DeltaFeatures/Types/SettingsName.swift b/DeltaFeatures/Types/SettingsName.swift new file mode 100644 index 0000000..96d0b04 --- /dev/null +++ b/DeltaFeatures/Types/SettingsName.swift @@ -0,0 +1,24 @@ +// +// SettingsTypes.swift +// Delta +// +// Created by Riley Testut on 4/5/23. +// Copyright © 2023 Riley Testut. All rights reserved. +// + +import Foundation + +public struct SettingsName: RawRepresentable, Hashable, ExpressibleByStringLiteral +{ + public let rawValue: String + + public init(rawValue: String) + { + self.rawValue = rawValue + } + + public init(stringLiteral rawValue: String) + { + self.rawValue = rawValue + } +} diff --git a/DeltaFeatures/Types/SettingsUserInfoKey.swift b/DeltaFeatures/Types/SettingsUserInfoKey.swift new file mode 100644 index 0000000..73f2543 --- /dev/null +++ b/DeltaFeatures/Types/SettingsUserInfoKey.swift @@ -0,0 +1,30 @@ +// +// SettingsUserInfoKey.swift +// DeltaFeatures +// +// Created by Riley Testut on 4/13/23. +// Copyright © 2023 Riley Testut. All rights reserved. +// + +import Foundation + +public extension SettingsUserInfoKey +{ + public static let name: SettingsUserInfoKey = "name" + public static let value: SettingsUserInfoKey = "value" +} + +public struct SettingsUserInfoKey: RawRepresentable, Hashable, ExpressibleByStringLiteral +{ + public let rawValue: String + + public init(rawValue: String) + { + self.rawValue = rawValue + } + + public init(stringLiteral rawValue: String) + { + self.rawValue = rawValue + } +}