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 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
BestSegmentsandAverageSegments. Additionally, functions for dealing with comparisons, like shortening a comparison, are provided. - component
- The component module provides all available components.
A
Componentallows querying different kinds of information from aTimer. 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. ALayoutallows 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 aLayoutState, placesEntitiesinto aSceneand updates it accordingly as theLayoutStatechanges. It is up to a specific renderer to then take theSceneand render out theEntities. There is aResourceAllocatortrait that defines the types of resources anEntityconsists 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 thesoftware-renderingfeature 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
Settingsmodule provides the ability to customize aComponentand 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§
- Date
Time - A
PrimitiveDateTimewith aUtcOffset. - Hotkey
Config - The configuration to use for a
HotkeySystem. It describes whichHotkeyto use as hotkeys for the different actions. - Hotkey
System - With a
HotkeySystemthe 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 aHotkeySystemtemporarily. By default theHotkeySystemis activated.