Crate livesplit_core
source ·Expand description
livesplit-core is a library that provides a lot of functionality for creating a speedrun timer.
Examples
use livesplit_core::{Run, Segment, Timer, TimerPhase};
// Create a run object that we can use with at least one segment.
let mut run = Run::new();
run.set_game_name("Super Mario Odyssey");
run.set_category_name("Any%");
run.push_segment(Segment::new("Cap Kingdom"));
// Create the timer from the run.
let mut timer = Timer::new(run).expect("Run with at least one segment provided");
// Start a new attempt.
timer.start();
assert_eq!(timer.current_phase(), TimerPhase::Running);
// Create a split.
timer.split();
// The run should be finished now.
assert_eq!(timer.current_phase(), TimerPhase::Ended);
// Reset the attempt and confirm that we want to store the attempt.
timer.reset(true);
// The attempt is now over.
assert_eq!(timer.current_phase(), TimerPhase::NotRunning);
Re-exports
pub use crate::layout::Editor as LayoutEditor;
pub use crate::layout::Layout;
pub use crate::run::Editor as RunEditor;
pub use crate::run::Run;
pub use livesplit_hotkey as hotkey;
Modules
The analysis module provides a variety of functions for calculating
information about a
Run
.The auto splitting module provides a runtime for running auto splitters that
can control the
Timer
. These auto splitters are
provided as WebAssembly modules.The comparison module provides all the different automatically generated
comparisons, like
BestSegments
and AverageSegments
.
Additionally, functions for dealing with comparisons, like shortening a comparison, are provided.The networking module provides functionality to communicate with various
speedrunning related websites, such as Splits.io to upload and download runs
and Speedrun.com to query and submit to the leaderboards of most games. The
module is optional and is not compiled in by default.
The rendering module provides a
SceneManager
, that when provided with a
LayoutState
, places Entities
into a Scene
and updates it
accordingly as the LayoutState
changes. It is up to a specific renderer
to then take the Scene
and render out the Entities
. There is
a ResourceAllocator
trait that defines the types of resources an
Entity
consists of. A specific renderer can then provide an
implementation that provides the resources it can render out. Those
resources are images, paths, i.e. lines, quadratic and cubic bezier curves,
fonts and labels. An optional software renderer is available behind the
software-rendering
feature that uses tiny-skia to efficiently render the
paths on the CPU. It is surprisingly fast and can be considered the default
renderer.The run module provides everything necessary for working with a
Run
, like parsing and saving or editing them.The
Settings
module provides the ability to customize a
Component
and various other settings.The timing module provides everything necessary for working with times and
measuring them.
Various utilities used in this crate.
Structs
An Atomic Date Time represents a UTC
DateTime
that tries to be as close to
an atomic clock as possible.An
Attempt
describes information about an attempt to run a specific category
by a specific runner in the past. Every time a new attempt is started and
then reset, an Attempt
describing general information about it is created.A
PrimitiveDateTime
with a UtcOffset
.The general settings of a
Layout
that apply to all components.The configuration to use for a
HotkeySystem
. It describes which Hotkey
to use as hotkeys for the different actions.With a
HotkeySystem
the runner can use hotkeys on their keyboard to control
the Timer. The hotkeys are global, so the application doesn’t need to be in
focus. The behavior of the hotkeys depends on the platform and is stubbed
out on platforms that don’t support hotkeys. You can turn off a HotkeySystem
temporarily. By default the HotkeySystem
is activated.The
RunMetadata
struct stores optional information about a run, like the
platform and region of the game.A
Segment
describes a point in a speedrun that is suitable for storing a
split time. This stores the name of that Segment
, an icon, the split times
of different comparisons, and a history of segment times.A time that can store a Real Time and a Game Time. Both of them are
optional.
A
TimeSpan
represents a certain span of time.A
Timer
provides all the capabilities necessary for doing speedrun attempts.Enums
A
Component
provides information about a run in a way that is easy to
visualize. This type can store any of the components provided by this crate.Describes which phase the timer is currently in. This tells you if there’s
an active speedrun attempt and whether it is paused or it ended.
A
TimingMethod
describes which form of timing is used. This can either be
TimingMethod::RealTime
or TimingMethod::GameTime
.Type Definitions
A
SharedTimer
is a wrapper around the Timer
that can be shared across multiple threads with multiple owners.