Match vanilla accessibility controls and hide unavailable Horizon options

This commit is contained in:
rdbtCVS
2026-10-20 16:39:58 +01:00
parent 2469b92e4f
commit 01fcfc9095
4 changed files with 27 additions and 16 deletions
+15 -11
View File
@@ -126,18 +126,16 @@ pub const SECTIONS: &[Section] = &[
name: "Accessibility",
blurb: "Contrast, motion, text backgrounds and notifications.",
rows: |_| {
let mut rows = vec![
HRow::Opt(Opt::Narrator),
HRow::Page(
"Controls",
"Key binds, mouse and controller",
Page::Controls,
),
];
let mut rows = vec![HRow::Page(
"Controls",
"Key binds, mouse and controller",
Page::Controls,
)];
rows.extend(
options_ui::ACCESSIBILITY_OPTIONS[1..]
options_ui::ACCESSIBILITY_OPTIONS
.iter()
.copied()
.filter(|opt| opt.available())
.map(HRow::Opt),
);
rows
@@ -875,7 +873,7 @@ mod tests {
}
#[test]
fn accessibility_section_shares_the_complete_option_list() {
fn accessibility_section_only_shows_available_options() {
let s = Settings::default();
let section = SECTIONS.iter().find(|s| s.name == "Accessibility").unwrap();
let rows = (section.rows)(&s);
@@ -886,7 +884,13 @@ mod tests {
_ => None,
})
.collect();
assert_eq!(options, options_ui::ACCESSIBILITY_OPTIONS);
let expected: Vec<_> = options_ui::ACCESSIBILITY_OPTIONS
.iter()
.copied()
.filter(|opt| opt.available())
.collect();
assert_eq!(options, expected);
assert!(options.iter().all(|opt| opt.available()));
assert!(
rows.iter()
.any(|r| matches!(r, HRow::Page(_, _, Page::Controls)))
+12 -5
View File
@@ -1385,11 +1385,6 @@ impl OptionsUi {
)),
)];
rows.extend(pairs(&ACCESSIBILITY_OPTIONS[1..]));
rows.extend(pairs(&[
Opt::ToggleCrouch,
Opt::ToggleSprint,
Opt::AutoJump,
]));
rows
}
Page::Font => pairs(&[Opt::ForceUnicode, Opt::JapaneseGlyphs]),
@@ -2691,6 +2686,18 @@ mod tests {
let mut ui = OptionsUi::default();
ui.show(Page::Accessibility);
let (widgets, _, _, _) = ui.layout(&s, 480.0, 1200.0);
let options: Vec<_> = widgets
.iter()
.filter_map(|w| match w.kind {
WKind::Button {
act: Act::Cycle(opt),
..
}
| WKind::Slider { opt, .. } => Some(opt),
_ => None,
})
.collect();
assert_eq!(options, ACCESSIBILITY_OPTIONS);
for &opt in ACCESSIBILITY_OPTIONS {
let widget = widgets
.iter()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 63 KiB