Skip to content

Commit

Permalink
WebEventSink: current_split_index
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKnauth committed Jun 12, 2024
1 parent 6e28128 commit 3562c09
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions capi/src/web_event_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct WebEventSink {
resume_game_time: Option<Function>,
set_custom_variable: Option<Function>,
current_phase: Function,
current_split_index: Option<Function>,
}

#[wasm_bindgen]
Expand All @@ -64,6 +65,7 @@ impl WebEventSink {
resume_game_time: get_func(&obj, "resumeGameTime"),
set_custom_variable: get_func(&obj, "setCustomVariable"),
current_phase: get_func(&obj, "currentPhase").unwrap(),
current_split_index: get_func(&obj, "currentSplitIndex"),
obj,
}
}
Expand Down Expand Up @@ -216,4 +218,17 @@ impl TimerQuery for WebEventSink {
_ => panic!("Unknown TimerPhase"),
}
}
fn current_split_index(&self) -> Option<usize> {
let i = self
.current_split_index
.as_ref()?
.call0(&self.obj)
.ok()?
.as_f64()?;
if i >= 0.0 {
Some(i as usize)
} else {
None
}
}
}

0 comments on commit 3562c09

Please sign in to comment.