Skip to content

Commit e1616e1

Browse files
Add more events
1 parent ffa98d8 commit e1616e1

File tree

6 files changed

+121
-22
lines changed

6 files changed

+121
-22
lines changed

README.md

+53-10
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ Launching and using SwiftSplit is fairly simple, with only three broad steps.
3232
5. Click "Connect to Server" in LiveSplit One and paste that URL
3333
- Note: navigating away from the timer screen may make the server button say it isn't connected any more. This is a
3434
bug. You can check that it's still connected with the "LiveSplit clients" field in SwiftSplit, which should read
35-
"1". If that field reads "0", you need to connect. If it reads "2" or higher then you've connected multiple times
36-
and will need to save your splits and reload LiveSplit One, otherwise each split will count multiple times.
35+
"1". If that field reads "0", you need to connect. If it reads "2" or higher then you will need to save your splits
36+
and reload the LiveSplit One tab, otherwise each split will trigger multiple times.
3737

3838
### Loading the Run
3939
6. Load up your splits in LiveSplit One
@@ -66,16 +66,59 @@ Here's an example for Old Site Any%:
6666
}
6767
```
6868

69-
The currently defined events are (`<...>` indicates a fill-in parameter):
70-
- `start chapter <n>` - Triggered when the specified chapter number is started
71-
- `reset chapter` - Triggered when the current chapter is reset (either by restarting the chapter or exiting to the map)
72-
- `complete chapter <n>` - Triggered when the specified chapter number is completed
73-
- `<from screen> > <to screen>` - Triggered when transitioning between two screens (you can find the screen IDS by
74-
looking at the `Level: Name:` when connected to Celeste, or by enabling debug and hovering over the screen in the map
75-
editor.
69+
## Events
70+
Events are triggered when SwiftSplit observes a change in the game state, which is checked 10 times every second. A
71+
single state change frequently causes multiple events, generally with differing levels of specificity.
7672

77-
Note that the *exact* text is important. Spaces and capitalization have to match, with a couple additions:
73+
Note that the *exact* text of an event is important. Spaces and capitalization have to match, with a couple additions:
7874
- Inserting an exclamation point (`!`) at the beginning of an event will cause that event to not trigger a split. This
7975
can be useful when your route passes between two screens multiple times but you only want one split.
8076
- Anything after a ` ##` (*exactly* one space and two pound signs) will be trimmed off. This can be useful for
8177
explaining events.
78+
79+
SwiftSplit has an "Event Stream" panel that displays events as they are triggered, which can be useful when creating
80+
route files. (You can copy the text out of the panel to paste directly into the route file too).
81+
82+
### Chapter start/end events
83+
- `reset chapter` - Triggered when any chapter is reset (either by restarting the chapter or exiting to the map)
84+
- `start chapter <n>` - Triggered when chapter `<n>` is started
85+
- `reset chapter <n>` - Triggered when chapter `<n>` is reset
86+
- `complete chapter <n>` - Triggered when chapter `<n>` is completed
87+
- **A-side specific:**
88+
- `start a-side <n>` - Triggered when chapter `<n>`'s A-side is started
89+
- `reset a-side <n>` - Triggered when chapter `<n>`'s A-side is reset
90+
- `complete a-side <n>` - Triggered when chapter `<n>`'s A-side is completed
91+
- **B-side specific:**
92+
- `start b-side <n>` - Triggered when chapter `<n>`'s B-side is started
93+
- `reset b-side <n>` - Triggered when chapter `<n>`'s B-side is reset
94+
- `complete b-side <n>` - Triggered when chapter `<n>`'s B-side is completed
95+
- **C-side specific:**
96+
- `start c-side <n>` - Triggered when chapter `<n>`'s C-side is started
97+
- `reset c-side <n>` - Triggered when chapter `<n>`'s C-side is reset
98+
- `complete c-side <n>` - Triggered when chapter `<n>`'s C-side is completed
99+
100+
### Screen transition event
101+
- `<from screen> > <to screen>` - Triggered when transitioning between two screens (you can find the screen IDs by
102+
enabling debug and hovering over the screen in the map editor.)
103+
104+
### Collectable events
105+
- **Cassettes:**
106+
- `cassette` - Triggered when any cassette is collected
107+
- `chapter <n> cassette` - Triggered when the cassette in the specified chapter is collected
108+
- `<n> total cassettes` - Triggered when a cassette is collected. `<n>` is the total number of cassettes collected in
109+
the current file
110+
- **Heart Gems:**
111+
- `heart` - Triggered when any heart gem is collected
112+
- `chapter <n> heart` - Triggered when the heart gem in the specified chapter is collected
113+
- `<n> total hearts` - Triggered when a heart gem is collected. `<n>` is the total number of heart gems collected in
114+
the current file
115+
- **Strawberries:**
116+
- `strawberry` - Triggered when any strawberry is collected
117+
- `<n> chapter strawberries` - Triggered when a total of `<n>` strawberries are collected in a chapter
118+
- `<n> file strawberries` - Triggered when a total of `<n>` strawberries are collected in the file
119+
120+
### Some nuances regarding resets:
121+
122+
If the next expected event in the route is the same as the reset event, the route will take precedence and the run
123+
won't be reset. However, if the first event in the route is then detected (though again route takes precedence), the
124+
run will reset and start over.

SwiftSplit.xcodeproj/project.pbxproj

+4-2
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,15 @@
386386
CODE_SIGN_IDENTITY = "Apple Development";
387387
CODE_SIGN_STYLE = Automatic;
388388
COMBINE_HIDPI_IMAGES = YES;
389+
CURRENT_PROJECT_VERSION = 1;
389390
DEVELOPMENT_TEAM = V2EPDFA9PV;
390391
ENABLE_HARDENED_RUNTIME = YES;
391392
INFOPLIST_FILE = SwiftSplit/Info.plist;
392393
LD_RUNPATH_SEARCH_PATHS = (
393394
"$(inherited)",
394395
"@executable_path/../Frameworks",
395396
);
396-
MARKETING_VERSION = 1.0.0;
397+
MARKETING_VERSION = 1.1.0;
397398
PRODUCT_BUNDLE_IDENTIFIER = dev.thecodewarrior.SwiftSplit;
398399
PRODUCT_NAME = "$(TARGET_NAME)";
399400
SWIFT_OBJC_BRIDGING_HEADER = "SwiftSplit/SwiftSplit-Bridging-Header.h";
@@ -412,14 +413,15 @@
412413
CODE_SIGN_IDENTITY = "Apple Development";
413414
CODE_SIGN_STYLE = Automatic;
414415
COMBINE_HIDPI_IMAGES = YES;
416+
CURRENT_PROJECT_VERSION = 1;
415417
DEVELOPMENT_TEAM = V2EPDFA9PV;
416418
ENABLE_HARDENED_RUNTIME = YES;
417419
INFOPLIST_FILE = SwiftSplit/Info.plist;
418420
LD_RUNPATH_SEARCH_PATHS = (
419421
"$(inherited)",
420422
"@executable_path/../Frameworks",
421423
);
422-
MARKETING_VERSION = 1.0.0;
424+
MARKETING_VERSION = 1.1.0;
423425
PRODUCT_BUNDLE_IDENTIFIER = dev.thecodewarrior.SwiftSplit;
424426
PRODUCT_NAME = "$(TARGET_NAME)";
425427
SWIFT_OBJC_BRIDGING_HEADER = "SwiftSplit/SwiftSplit-Bridging-Header.h";

SwiftSplit/CelesteScanner.swift

+21-5
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ class CelesteScanner {
169169
10b212968c7f0000 00000000 00000000 b83c632d01000000 f1aaaa1f f1bbbb1f 01010100 00000000 - placeholders
170170
--------######## -------- ######## --------######## -------- ######## -------- ########
171171
0 4 8 12 16 20 24 28 32 36
172-
10e28b84a07f0000 00000000 00000000 b009150f01000000 ffffffff ffffffff 00000000 00000000 - AUTOSPLIT save state
172+
10e28b84a07f0000 00000000 00000000 b009150f01000000 ffffffff ffffffff 00000000 00000000 - Fresh launch state
173173

174174
11ffeeddccbbaa11 f1cccc1f 01010000 11addeefbeadde11 f1dddd1f f1eeee1f f1ffff1f 00000000 - placeholders
175175
--------######## -------- ######## --------######## -------- ######## -------- ########
176176
40 44 48 52 56 60 64 68 72 76
177-
0000000000000000 00000000 00000000 11addeefbeadde11 00000000 00000000 00000000 00000000 - AUTOSPLIT save state
177+
0000000000000000 00000000 00000000 0000000000000000 00000000 00000000 00000000 00000000 - Fresh launch state
178178
```
179179
*/
180180
struct AutoSplitterData: Equatable {
@@ -243,14 +243,21 @@ struct AutoSplitterData: Equatable {
243243
}
244244
}
245245

246+
enum ChapterMode {
247+
case Normal
248+
case BSide
249+
case CSide
250+
case Other(value: Int)
251+
}
252+
246253
/**
247254
A swift representation of the C# AutoSplitterInfo
248255
*/
249256
class AutoSplitterInfo {
250257
let data: AutoSplitterData
251258

252259
let chapter: Int
253-
let mode: Int
260+
let mode: ChapterMode
254261
let level: String
255262
let timerActive: Bool
256263
let chapterStarted: Bool
@@ -268,7 +275,7 @@ class AutoSplitterInfo {
268275
self.data = AutoSplitterData()
269276

270277
self.chapter = 0
271-
self.mode = 0
278+
self.mode = .Normal
272279
self.level = ""
273280
self.timerActive = false
274281
self.chapterStarted = false
@@ -287,7 +294,16 @@ class AutoSplitterInfo {
287294
self.data = data
288295

289296
self.chapter = Int(data.chapter)
290-
self.mode = Int(data.mode)
297+
switch data.mode {
298+
case 0:
299+
self.mode = .Normal
300+
case 1:
301+
self.mode = .BSide
302+
case 2:
303+
self.mode = .CSide
304+
default:
305+
self.mode = .Other(value: Int(data.mode))
306+
}
291307
self.level = try AutoSplitterData.parseCSharpString(at: data.levelPointer, target: target)
292308
self.timerActive = data.timerActive != 0
293309
self.chapterStarted = data.chapterStarted != 0

SwiftSplit/CelesteSplitter.swift

+39-3
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,54 @@ class CelesteSplitter {
6767

6868
func getEvents(from old: AutoSplitterInfo, to new: AutoSplitterInfo) -> [String] {
6969
var events: [String] = []
70-
if new.level != old.level && old.level != "" && new.level != "" {
71-
events.append("\(old.level) > \(new.level)")
72-
}
70+
7371
// if we don't check `new.chapterComplete`, the summit credits trigger the autosplitter
7472
if new.chapterStarted && !old.chapterStarted && !new.chapterComplete {
7573
events.append("start chapter \(new.chapter)")
74+
switch new.mode {
75+
case .Normal: events.append("start a-side \(new.chapter)")
76+
case .BSide: events.append("start b-side \(new.chapter)")
77+
case .CSide: events.append("start c-side \(new.chapter)")
78+
default: break
79+
}
7680
}
7781
if !new.chapterStarted && old.chapterStarted && !old.chapterComplete {
7882
events.append("reset chapter")
83+
events.append("reset chapter \(old.chapter)")
84+
switch new.mode {
85+
case .Normal: events.append("reset a-side \(old.chapter)")
86+
case .BSide: events.append("reset b-side \(old.chapter)")
87+
case .CSide: events.append("reset c-side \(old.chapter)")
88+
default: break
89+
}
7990
}
8091
if new.chapterComplete && !old.chapterComplete {
8192
events.append("complete chapter \(old.chapter)")
93+
switch new.mode {
94+
case .Normal: events.append("complete a-side \(old.chapter)")
95+
case .BSide: events.append("complete b-side \(old.chapter)")
96+
case .CSide: events.append("complete c-side \(old.chapter)")
97+
default: break
98+
}
99+
}
100+
101+
if new.level != old.level && old.level != "" && new.level != "" {
102+
events.append("\(old.level) > \(new.level)")
103+
}
104+
if new.chapterCassette && !old.chapterCassette {
105+
events.append("cassette")
106+
events.append("chapter \(new.chapter) cassette")
107+
events.append("\(new.fileCassettes) total cassettes")
108+
}
109+
if new.chapterHeart && !old.chapterHeart {
110+
events.append("heart")
111+
events.append("chapter \(new.chapter) heart")
112+
events.append("\(new.fileHearts) total hearts")
113+
}
114+
if new.chapterStrawberries > old.chapterStrawberries {
115+
events.append("strawberry")
116+
events.append("\(new.chapterStrawberries) chapter strawberries")
117+
events.append("\(new.fileStrawberries) file strawberries")
82118
}
83119
return events
84120
}

SwiftSplit/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>$(MARKETING_VERSION)</string>
2121
<key>CFBundleVersion</key>
22-
<string>1</string>
22+
<string>$(CURRENT_PROJECT_VERSION)</string>
2323
<key>LSMinimumSystemVersion</key>
2424
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
2525
<key>NSHumanReadableCopyright</key>

SwiftSplit/ViewController.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ class ViewController: NSViewController, RouteBoxDelegate {
216216

217217
gameTimeLabel.stringValue = timeString
218218

219-
nextEventLabel.stringValue = splitter.routeIndex < routeConfig.route.count ? "\"\(routeConfig.route[splitter.routeIndex])\"" : "<none>"
219+
nextEventLabel.stringValue = splitter.routeIndex < routeConfig.route.count ?
220+
"\"\(routeConfig.route[splitter.routeIndex])\" (\(splitter.routeIndex + 1)/\(routeConfig.route.count))"
221+
: "<none>"
220222
}
221223

222224
func openRouteFile(url: URL) {

0 commit comments

Comments
 (0)