Skip to content

Commit b98eac3

Browse files
committed
Fix Collapsed Subsplit Delta Coloring
This makes split delta columns color collapsed subsplit group rows based on the full segment range the row represents, matching the already range-aware segment delta path. This prevents a collapsed group from being colored as a best segment just because its ending segment is individually gold while the group as a whole is losing time.
1 parent 09cd4e6 commit b98eac3

3 files changed

Lines changed: 74 additions & 5 deletions

File tree

src/component/splits/column.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{
22
GeneralLayoutSettings, Segment, TimeSpan, TimingMethod,
3-
analysis::{self, possible_time_save, split_color},
3+
analysis::{self, possible_time_save},
44
comparison,
55
component::splits::Settings as SplitsSettings,
66
localization::Lang,
@@ -395,6 +395,7 @@ fn time_column_update_value(
395395
}
396396

397397
let is_live = is_current_split;
398+
let segment_range = column_start_index..=segment_index;
398399

399400
let value = match (column.update_with, is_live) {
400401
(DontUpdate, _) => return None,
@@ -423,7 +424,15 @@ fn time_column_update_value(
423424
};
424425
(
425426
value,
426-
split_color(timer, delta, segment_index, true, true, comparison, method),
427+
analysis::split_color_for_range(
428+
timer,
429+
delta,
430+
segment_range,
431+
true,
432+
true,
433+
comparison,
434+
method,
435+
),
427436
formatter,
428437
)
429438
}
@@ -478,7 +487,7 @@ fn time_column_update_value(
478487
analysis::split_color_for_range(
479488
timer,
480489
delta,
481-
column_start_index..=segment_index,
490+
segment_range,
482491
false,
483492
true,
484493
comparison,

src/component/splits/tests/mod.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use super::{
44
};
55
use crate::{
66
Lang, Run, Segment, TimeSpan, Timer, TimingMethod,
7+
comparison::best_segments,
78
component::splits::{ColumnKind, TimeColumn, english_settings},
89
settings::{Image, ImageCache, SemanticColor, Value},
910
};
@@ -1028,6 +1029,65 @@ fn closed_group_header_segment_delta_can_be_a_best_segment() {
10281029
SemanticColor::BestSegment
10291030
);
10301031
}
1032+
1033+
#[test]
1034+
fn closed_group_header_split_delta_is_not_best_if_only_the_major_split_is_best() {
1035+
let mut run = Run::new();
1036+
for name in ["Intro", "A1", "A2", "A End", "Chapter B", "Outro"] {
1037+
run.push_segment(Segment::new(name));
1038+
}
1039+
for (segment, best_segment_time) in run
1040+
.segments_mut()
1041+
.iter_mut()
1042+
.zip([1.0, 1.0, 2.0, 3.0, 3.0, 1.0])
1043+
{
1044+
segment.best_segment_time_mut()[TimingMethod::GameTime] =
1045+
Some(TimeSpan::from_seconds(best_segment_time));
1046+
}
1047+
run.regenerate_comparisons();
1048+
run.segment_groups_mut()
1049+
.push_lossy(1, 4, Some("Chapter A".into()), 6);
1050+
1051+
let mut timer = Timer::new(run).unwrap();
1052+
timer.set_current_timing_method(TimingMethod::GameTime);
1053+
timer.start().unwrap();
1054+
timer.initialize_game_time().unwrap();
1055+
timer.pause_game_time().unwrap();
1056+
for time in [0.0, 5.0, 18.0, 19.0] {
1057+
timer.set_game_time(TimeSpan::from_seconds(time)).unwrap();
1058+
timer.split().unwrap();
1059+
}
1060+
1061+
let mut component = Component::with_settings(Settings {
1062+
visual_split_count: 0,
1063+
subsplit_display_mode: SubsplitDisplayMode::CurrentGroupExpanded,
1064+
columns: vec![ColumnSettings {
1065+
kind: ColumnKind::Time(TimeColumn {
1066+
update_with: ColumnUpdateWith::Delta,
1067+
comparison_override: Some(best_segments::NAME.into()),
1068+
..Default::default()
1069+
}),
1070+
..Default::default()
1071+
}],
1072+
..english_settings()
1073+
});
1074+
let mut image_cache = ImageCache::new();
1075+
1076+
let state = component.state(
1077+
&mut image_cache,
1078+
&timer.snapshot(),
1079+
&Default::default(),
1080+
Lang::English,
1081+
);
1082+
1083+
assert_eq!(state.splits[1].name, "Chapter A");
1084+
assert_eq!(state.splits[1].columns[0].value, "+12.0");
1085+
assert_eq!(
1086+
state.splits[1].columns[0].semantic_color,
1087+
SemanticColor::BehindLosingTime
1088+
);
1089+
}
1090+
10311091
#[test]
10321092
fn blank_rows_reset_after_groups_collapse() {
10331093
let mut run = Run::new();

tests/rendering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ fn subsplits_layout() {
338338
&layout.state(&mut image_cache, &timer.snapshot(), Lang::English),
339339
&image_cache,
340340
[300, 800],
341-
"7a7662f8e7c73e80",
342-
"165b2051ef19f18d",
341+
"85d2ac8702abc205",
342+
"577b2b51aed1830a",
343343
"subsplits_layout",
344344
);
345345
}

0 commit comments

Comments
 (0)