forked from MeloNX/MeloNX
SettingsView changes
This commit is contained in:
parent
ec16e150f6
commit
3e657d7229
Binary file not shown.
@ -124,6 +124,7 @@ struct SettingsView: View {
|
|||||||
// Input Selector
|
// Input Selector
|
||||||
Section {
|
Section {
|
||||||
ForEach(controllersList) { controller in
|
ForEach(controllersList) { controller in
|
||||||
|
|
||||||
var customBinding: Binding<Bool> {
|
var customBinding: Binding<Bool> {
|
||||||
Binding(
|
Binding(
|
||||||
get: { currentControllers.contains(controller) },
|
get: { currentControllers.contains(controller) },
|
||||||
@ -138,10 +139,31 @@ struct SettingsView: View {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Toggle(isOn: customBinding) {
|
|
||||||
labelWithIcon(controller.name, iconName: "")
|
if customBinding.wrappedValue {
|
||||||
|
DisclosureGroup {
|
||||||
|
Toggle(isOn: customBinding) {
|
||||||
|
Text(controller.name)
|
||||||
|
.font(.body)
|
||||||
|
}
|
||||||
|
.tint(.blue)
|
||||||
|
} label: {
|
||||||
|
let controller = String((controllersList.firstIndex(where: { $0.id == controller.id }) ?? 0) + 1)
|
||||||
|
|
||||||
|
|
||||||
|
Text("Player \(controller)")
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Toggle(isOn: customBinding) {
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Text(controller.name)
|
||||||
|
.font(.body)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.tint(.blue)
|
||||||
}
|
}
|
||||||
.tint(.blue)
|
|
||||||
}
|
}
|
||||||
} header: {
|
} header: {
|
||||||
Text("Input Selector")
|
Text("Input Selector")
|
||||||
@ -149,7 +171,7 @@ struct SettingsView: View {
|
|||||||
.textCase(nil)
|
.textCase(nil)
|
||||||
.headerProminence(.increased)
|
.headerProminence(.increased)
|
||||||
} footer: {
|
} footer: {
|
||||||
Text("Select input devices and on-screen controls to play with.")
|
Text("Select input devices and on-screen controls to play with. ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Input Settings
|
// Input Settings
|
||||||
@ -276,6 +298,10 @@ struct SettingsView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func saveSettings() {
|
func saveSettings() {
|
||||||
|
#if targetEnvironment(simulator)
|
||||||
|
|
||||||
|
print("Saving Settings")
|
||||||
|
#else
|
||||||
do {
|
do {
|
||||||
let encoder = JSONEncoder()
|
let encoder = JSONEncoder()
|
||||||
encoder.outputFormatting = .prettyPrinted
|
encoder.outputFormatting = .prettyPrinted
|
||||||
@ -285,10 +311,17 @@ struct SettingsView: View {
|
|||||||
} catch {
|
} catch {
|
||||||
print("Failed to save settings: \(error)")
|
print("Failed to save settings: \(error)")
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Original loadSettings function assumed to exist
|
// Original loadSettings function assumed to exist
|
||||||
func loadSettings() -> Ryujinx.Configuration? {
|
func loadSettings() -> Ryujinx.Configuration? {
|
||||||
|
|
||||||
|
#if targetEnvironment(simulator)
|
||||||
|
print("Running on Simulator")
|
||||||
|
|
||||||
|
return Ryujinx.Configuration(gamepath: "")
|
||||||
|
#else
|
||||||
guard let jsonString = UserDefaults.standard.string(forKey: "config"),
|
guard let jsonString = UserDefaults.standard.string(forKey: "config"),
|
||||||
let data = jsonString.data(using: .utf8) else {
|
let data = jsonString.data(using: .utf8) else {
|
||||||
return nil
|
return nil
|
||||||
@ -301,6 +334,7 @@ struct SettingsView: View {
|
|||||||
print("Failed to load settings: \(error)")
|
print("Failed to load settings: \(error)")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
@ -316,3 +350,4 @@ struct SettingsView: View {
|
|||||||
.font(.body)
|
.font(.body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user