Extras: classic switches two to a row; settings nest under their switch

Classic Extras laid every setting out as a full-width button. Pair each
section's buttons as vanilla's OptionsList.addSmall does (the same layout as
Video Settings), and shorten "Lower sensitivity while zoomed" to "Slower
turning" so it fits a half-width button.

Horizon's Extras page shows a switch's own settings (Zoom key, Minimap size,
FPS corner...) only while that switch is on, so it stays one row per extra
as the list grows. Classic keeps every button, as vanilla screens do.

Fixes #812
Fixes #815

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-21 23:30:51 +02:00
parent e1d39b9787
commit 7e82252f12
4 changed files with 99 additions and 18 deletions
+16 -1
View File
@@ -505,7 +505,7 @@ impl Item {
Item::ZoomKey => "Zoom key",
Item::ZoomLevel => "Starting zoom",
Item::ZoomSmooth => "Smooth zoom",
Item::ZoomSensitivity => "Lower sensitivity while zoomed",
Item::ZoomSensitivity => "Slower turning",
Item::Fps => "FPS counter",
Item::FpsCorner | Item::KeystrokesCorner | Item::MinimapCorner => "Corner",
Item::Minimap => "Minimap",
@@ -523,6 +523,21 @@ impl Item {
Item::KeystrokesCps => "Clicks per second",
}
}
/// The switch this setting belongs to: it does nothing while that is off.
pub fn parent(self) -> Option<Item> {
use Item::*;
Some(match self {
ZoomKey | ZoomLevel | ZoomSmooth | ZoomSensitivity => Zoom,
MinimapCorner | MinimapSize | MinimapShape | MinimapZoom | MinimapRotate => Minimap,
FpsCorner | FpsLows => Fps,
KeystrokesCorner | KeystrokesCps => Keystrokes,
MouseTweaksWheel => MouseTweaks,
SortKey => Sort,
Fullbright | Zoom | Minimap | Fps | Keystrokes | MouseTweaks | Sort | AutoReconnect => {
return None;
}
})
}
/// What the row says under its caption.
pub fn description(self) -> &'static str {
match self {
+44 -1
View File
@@ -185,9 +185,17 @@ pub const SECTIONS: &[Section] = &[
Section {
name: "Extras",
blurb: "Optional additions, all off by default: the game stays vanilla until you turn one on.",
rows: |_| {
// A switch's own settings nest under it and show while it is on, so
// the page stays one row per extra until one is turned on.
rows: |s| {
extras::rows()
.into_iter()
.filter(|r| {
r.map_or(true, |item| {
item.parent()
.is_none_or(|parent| parent.switch(&s.extras) == Some(true))
})
})
.map(|r| r.map_or_else(HRow::Header, HRow::Extra))
.collect()
},
@@ -872,6 +880,41 @@ mod tests {
(point.0 * gui_per_dp, point.1 * gui_per_dp)
}
#[test]
fn extras_settings_nest_under_their_switch() {
let mut s = Settings::default();
let section = SECTIONS.iter().find(|s| s.name == "Extras").unwrap();
let items = |s: &Settings| -> Vec<extras::Item> {
(section.rows)(s)
.iter()
.filter_map(|row| match row {
HRow::Extra(item) => Some(*item),
_ => None,
})
.collect()
};
// Everything off: one row per extra.
assert!(items(&s).iter().all(|item| item.parent().is_none()));
s.extras.zoom = true;
let zoom_on = items(&s);
assert!(zoom_on.contains(&extras::Item::ZoomKey));
assert!(zoom_on.contains(&extras::Item::ZoomSensitivity));
assert!(!zoom_on.contains(&extras::Item::MinimapSize));
// Every setting shows once its switch is on.
for item in extras::rows().into_iter().flatten() {
if let Some(on) = item.switch(&s.extras)
&& item.parent().is_none()
&& !on
{
item.cycle(&mut s.extras, false);
}
}
assert_eq!(
items(&s).len(),
extras::rows().into_iter().flatten().count()
);
}
#[test]
fn accessibility_section_only_shows_available_options() {
let s = Settings::default();
+34 -15
View File
@@ -1209,22 +1209,41 @@ impl OptionsUi {
fn list_rows(&self, s: &Settings) -> Vec<Row> {
match self.page() {
Page::Extras => crate::extras::rows()
.into_iter()
.map(|row| match row {
Err(header) => Row::Header(header),
Ok(item) => {
let value = format!("{}: {}", item.caption(), item.value(&s.extras));
let label =
if item.key_name().is_some() && self.selected_key == item.key_name() {
Text::literal(format!("> {value} <")).with_color(text::YELLOW)
} else {
Text::literal(value)
};
Row::Buttons(button(0.0, 0.0, 310.0, label, Act::Extra(item)), None)
Page::Extras => {
// Each section's switches two to a row, as vanilla's
// OptionsList.addSmall lays out an options screen.
let extra = |item: crate::extras::Item| {
let value = format!("{}: {}", item.caption(), item.value(&s.extras));
let label = if item.key_name().is_some() && self.selected_key == item.key_name()
{
Text::literal(format!("> {value} <")).with_color(text::YELLOW)
} else {
Text::literal(value)
};
button(0.0, 0.0, 150.0, label, Act::Extra(item))
};
let mut rows = Vec::new();
let mut section = Vec::new();
let flush = |rows: &mut Vec<Row>, section: &mut Vec<crate::extras::Item>| {
rows.extend(
section
.chunks(2)
.map(|c| Row::Buttons(extra(c[0]), c.get(1).map(|&b| extra(b)))),
);
section.clear();
};
for row in crate::extras::rows() {
match row {
Err(header) => {
flush(&mut rows, &mut section);
rows.push(Row::Header(header));
}
Ok(item) => section.push(item),
}
})
.collect(),
}
flush(&mut rows, &mut section);
rows
}
Page::Video => {
// Horizon's graphics screens, Simple and Advanced.
let mut rows = vec![Row::Buttons(
+5 -1
View File
@@ -20,6 +20,10 @@ again restores vanilla's behaviour completely.
| Sort order and its clicks | `crates/horizon-client/src/inv_sort.rs` (pure, unit tested) |
| The settings page | `options_horizon.rs`: the **Extras** section of Horizon's Options |
The settings are grouped by extra. On Horizon's page an extra's own settings
(its key, corner, size...) show under its switch while it is on (`Item::parent`);
Classic's Horizon Extras screen lists them all, two buttons to a row.
`game.rs` only gets one-line hooks (key, wheel, mouse, frame, HUD), so the
extras stay out of the way of other input and options work.
@@ -58,7 +62,7 @@ Horizon category in Controls, and adding one would put a non-vanilla mapping int
Off applies the zoom to the final FOV with no easing.
- While scoping with a spyglass the zoom does nothing: the spyglass view and its
overlay stay exactly vanilla's.
- **Lower sensitivity** (default on) divides mouse turning by the zoom factor.
- **Slower turning** (default on) divides mouse turning by the zoom factor.
- With zoom off (or the key up) the FOV target and mouse are vanilla's, bit for
bit; the FOV harness covers this.