Skip to content

Commit

Permalink
fixup: timeline split logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisAMJ committed Nov 24, 2024
1 parent 3937a28 commit 4d08918
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/cvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@
|sar_time_demo|cmd|sar_time_demo \<demo_name> - parses a demo and prints some information about it|
|sar_time_demo_dev|0|Printing mode when using sar_time_demo.<br>0 = Default,<br>1 = Console commands,<br>2 = Console commands & packets.|
|sar_time_demos|cmd|sar_time_demos \<demo_name> [demo_name2]... - parses multiple demos and prints the total sum of them|
|sar_timeline_show_completed|0|Only show speedrun starts with matching finishes.|
|sar_timeline_show_completed|0|Only show speedrun starts and splits with matching finishes.|
|sar_timeline_splits|1|Add split markers to the Steam Timeline.|
|sar_timer_always_running|1|Timer will save current value when disconnecting.|
|sar_timer_result|cmd|sar_timer_result - prints result of timer|
Expand Down
11 changes: 6 additions & 5 deletions src/Features/SteamTimeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/* Timeline can get cluttered up (especially at long recording lengths), nice to have an option to disable adding splits. */
Variable sar_timeline_splits("sar_timeline_splits", "1", "Add split markers to the Steam Timeline.\n");
Variable sar_timeline_show_completed("sar_timeline_show_completed", "0", "Only show speedrun starts with matching finishes.\n");
Variable sar_timeline_show_completed("sar_timeline_show_completed", "0", "Only show speedrun starts and splits with matching finishes.\n");

Timeline *timeline;

Expand All @@ -31,12 +31,13 @@ void Timeline::Split(std::string name, std::string time) {
if (!steam->hasLoaded) return;
std::chrono::duration<float> currentOffset = std::chrono::system_clock::now() - g_speedrunStart;
if (sar_timeline_splits.GetBool()) {
steam->g_timeline->AddTimelineEvent("steam_bolt", name.c_str(), time.c_str(), 0, 0.0f, 0.0f, k_ETimelineEventClipPriority_None);
if (sar_timeline_show_completed.GetBool()) {
g_pendingSplits.push_back({name, time, currentOffset.count()});
} else {
steam->g_timeline->AddTimelineEvent("steam_bolt", name.c_str(), time.c_str(), 0, 0.0f, 0.0f, k_ETimelineEventClipPriority_None);
}
}

if (sar_timeline_show_completed.GetBool()) {
g_pendingSplits.push_back({name, time, currentOffset.count()});
}
}

ON_EVENT(SESSION_START) {
Expand Down

0 comments on commit 4d08918

Please sign in to comment.