Skip to content

Commit e3bd6ec

Browse files
committed
Timer trait: add current_split_index
WebEventSink: current_split_index web-sys, js-sys: 0.3.65 0.3.65 is when web_sys starts re-exporting js_sys, which web_event_sink relies on for use web_sys::js_sys
1 parent 5fede3a commit e3bd6ec

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ log = { version = "0.4.14", default-features = false, optional = true }
9595

9696
[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dependencies]
9797
# WebAssembly in the Web
98-
js-sys = { version = "0.3.55", optional = true }
98+
js-sys = { version = "0.3.65", optional = true }
9999
wasm-bindgen = { version = "0.2.78", optional = true }
100100
wasm-bindgen-futures = { version = "0.4.28", optional = true }
101-
web-sys = { version = "0.3.28", default-features = false, features = [
101+
web-sys = { version = "0.3.65", default-features = false, features = [
102102
"Document",
103103
"Performance",
104104
"VisibilityState",

crates/livesplit-auto-splitting/src/timer.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ pub trait Timer: Send {
4545
fn undo_split(&mut self);
4646
/// Resets the timer.
4747
fn reset(&mut self);
48+
/// Accesses the index of the split the attempt is currently on. If there's
49+
/// no attempt in progress, `None` is returned instead. This returns an
50+
/// index that is equal to the amount of segments when the attempt is
51+
/// finished, but has not been reset. So you need to be careful when using
52+
/// this value for indexing.
53+
fn current_split_index(&self) -> Option<usize>;
4854
/// Sets the game time.
4955
fn set_game_time(&mut self, time: time::Duration);
5056
/// Pauses the game time. This does not pause the timer, only the automatic

crates/livesplit-auto-splitting/tests/sandboxing.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ impl Timer for DummyTimer {
1919
fn skip_split(&mut self) {}
2020
fn undo_split(&mut self) {}
2121
fn reset(&mut self) {}
22+
fn current_split_index(&self) -> Option<usize> {
23+
None
24+
}
2225
fn set_game_time(&mut self, _time: time::Duration) {}
2326
fn pause_game_time(&mut self) {}
2427
fn resume_game_time(&mut self) {}

crates/livesplit-hotkey/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ x11-dl = { version = "2.20.0", optional = true }
3232

3333
[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dependencies]
3434
wasm-bindgen = { version = "0.2.54", optional = true }
35-
web-sys = { version = "0.3.28", default-features = false, features = [
35+
web-sys = { version = "0.3.65", default-features = false, features = [
3636
"EventTarget",
3737
"Gamepad",
3838
"GamepadButton",
3939
"KeyboardEvent",
4040
"Navigator",
4141
"Window",
4242
], optional = true }
43-
js-sys = { version = "0.3.28", default-features = false, optional = true }
43+
js-sys = { version = "0.3.65", default-features = false, optional = true }
4444

4545
[dependencies]
4646
cfg-if = "1.0.0"

src/auto_splitting/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,10 @@ impl<E: event::CommandSink + TimerQuery + Send> AutoSplitTimer for Timer<E> {
807807
drop(self.0.reset(None));
808808
}
809809

810+
fn current_split_index(&self) -> Option<usize> {
811+
self.0.get_timer().current_split_index()
812+
}
813+
810814
fn set_game_time(&mut self, time: time::Duration) {
811815
drop(self.0.set_game_time(time.into()));
812816
}

0 commit comments

Comments
 (0)