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::Component;
pub use crate::layout::Editor as LayoutEditor;
pub use crate::layout::GeneralSettings as GeneralLayoutSettings;
pub use crate::layout::Layout;
pub use crate::run::Attempt;
pub use crate::run::Editor as RunEditor;
pub use crate::run::Run;
pub use crate::run::RunMetadata;
pub use crate::run::Segment;
pub use crate::run::SegmentHistory;
pub use crate::timing::AtomicDateTime;
pub use crate::timing::GameTime;
pub use crate::timing::RealTime;
pub use crate::timing::Time;
pub use crate::timing::TimeSpan;
pub use crate::timing::TimeStamp;
pub use crate::timing::Timer;
pub use crate::timing::TimerPhase;
pub use crate::timing::TimingMethod;
pub use crate::timing::SharedTimer;
pub use livesplit_hotkey as hotkey;

Modules§

analysis
The analysis module provides a variety of functions for calculating information about a Run.
auto_splitting
The auto splitting module provides a runtime for running auto splitters that can control the Timer. These auto splitters are provided as WebAssembly modules.
comparison
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.
component
The component module provides all available components. A Component allows querying different kinds of information from a Timer. This information is provided as state objects in a way that can easily be visualized by any kind of User Interface.
layout
The layout module provides everything necessary for working with a Layout. A Layout allows you to combine multiple components together to visualize a variety of information the runner is interested in.
networking
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.
rendering
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.
run
The run module provides everything necessary for working with a Run, like parsing and saving or editing them.
settings
The Settings module provides the ability to customize a Component and various other settings.
timing
The timing module provides everything necessary for working with times and measuring them.
util
Various utilities used in this crate.

Structs§

DateTime
A PrimitiveDateTime with a UtcOffset.
HotkeyConfig
The configuration to use for a HotkeySystem. It describes which Hotkey to use as hotkeys for the different actions.
HotkeySystem
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.