@@ -14,16 +14,10 @@ final class TestingScenariosTableViewController: RadioSelectionTableViewControll
14
14
15
15
private let scenariosManager : TestingScenariosManager
16
16
17
- private var scenarioURLs : [ URL ] = [ ] {
17
+ private var scenarios : [ LoopScenario ] = [ ] {
18
18
didSet {
19
- options = scenarioURLs. map {
20
- $0 // /Scenarios/HF-1-Scenario_1.json
21
- . deletingPathExtension ( ) // /Scenarios/HF-1-Scenario_1
22
- . lastPathComponent // HF-1-Scenario_1
23
- . replacingOccurrences ( of: " HF-1- " , with: " " ) // Scenario_1
24
- . replacingOccurrences ( of: " HF-2- " , with: " " ) // Scenario_1
25
- . replacingOccurrences ( of: " _ " , with: " " ) // Scenario 1
26
- }
19
+ options = scenarios. map ( \. name)
20
+
27
21
if isViewLoaded {
28
22
DispatchQueue . main. async {
29
23
self . updateLoadButtonEnabled ( )
@@ -65,14 +59,14 @@ final class TestingScenariosTableViewController: RadioSelectionTableViewControll
65
59
contextHelp = " The scenarios directory location is available in the debug output of the Xcode console. "
66
60
67
61
if let activeScenarioURL = scenariosManager. activeScenarioURL {
68
- selectedIndex = scenarioURLs . firstIndex ( of : activeScenarioURL)
62
+ selectedIndex = scenarios . firstIndex ( where : { $0 . url == activeScenarioURL } )
69
63
}
70
64
71
65
updateLoadButtonEnabled ( )
72
66
}
73
67
74
68
override func tableView( _ tableView: UITableView , leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath ) -> UISwipeActionsConfiguration ? {
75
- let url = scenarioURLs [ indexPath. row]
69
+ let url = scenarios [ indexPath. row] . url
76
70
77
71
let rewindScenario = contextualAction (
78
72
rowTitle: " ⏮ Rewind " ,
@@ -86,7 +80,7 @@ final class TestingScenariosTableViewController: RadioSelectionTableViewControll
86
80
}
87
81
88
82
override func tableView( _ tableView: UITableView , trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath ) -> UISwipeActionsConfiguration ? {
89
- let url = scenarioURLs [ indexPath. row]
83
+ let url = scenarios [ indexPath. row] . url
90
84
91
85
let advanceScenario = contextualAction (
92
86
rowTitle: " Advance ⏭ " ,
@@ -137,7 +131,7 @@ final class TestingScenariosTableViewController: RadioSelectionTableViewControll
137
131
}
138
132
139
133
private func updateLoadButtonEnabled( ) {
140
- loadButtonItem. isEnabled = !scenarioURLs . isEmpty && selectedIndex != nil
134
+ loadButtonItem. isEnabled = !scenarios . isEmpty && selectedIndex != nil
141
135
}
142
136
143
137
@objc private func loadSelectedScenario( ) {
@@ -146,7 +140,7 @@ final class TestingScenariosTableViewController: RadioSelectionTableViewControll
146
140
return
147
141
}
148
142
149
- let url = scenarioURLs [ selectedIndex]
143
+ let url = scenarios [ selectedIndex] . url
150
144
151
145
loadButtonItem. isEnabled = false
152
146
loadButtonItem. title = " Loading... "
@@ -170,13 +164,13 @@ final class TestingScenariosTableViewController: RadioSelectionTableViewControll
170
164
171
165
extension TestingScenariosTableViewController : TestingScenariosManagerDelegate {
172
166
func testingScenariosManager( _ manager: TestingScenariosManager , didUpdateScenarioURLs scenarioURLs: [ URL ] ) {
173
- var filteredURLs = Set < URL > ( )
167
+ var filteredScenarios = Set < LoopScenario > ( )
174
168
manager. pluginManager. availableSupports. forEach { supportUI in
175
- supportUI. filterScenarios ( scenarioURLs: scenarioURLs) . forEach { scenarioURL in
176
- filteredURLs . insert ( scenarioURL )
169
+ supportUI. filteredScenarios ( scenarioURLs: scenarioURLs) . forEach { scenario in
170
+ filteredScenarios . insert ( scenario )
177
171
}
178
172
}
179
173
180
- self . scenarioURLs = Array ( filteredURLs ) . sorted ( by: { $0. lastPathComponent < $1. lastPathComponent } )
174
+ self . scenarios = Array ( filteredScenarios ) . sorted ( by: { $0. name < $1. name } )
181
175
}
182
176
}
0 commit comments