Restore missing accessibility settings and disable unfinished features
This commit is contained in:
@@ -1010,6 +1010,7 @@ struct Game<'a> {
|
||||
/// `FogRenderer`'s evolving state.
|
||||
fog: horizon_client::fog::FogState,
|
||||
screen_fx: horizon_client::screen_effects::ScreenEffects,
|
||||
panorama_rotation: horizon_client::gfx::panorama::Rotation,
|
||||
world: World,
|
||||
streaming: Streaming,
|
||||
lod: Option<horizon_client::lod::Lod>,
|
||||
@@ -9151,7 +9152,7 @@ impl Game<'_> {
|
||||
};
|
||||
horizon_client::environment::apply_weather(&mut sky, rain, thunder);
|
||||
self.end_flash_sky(&mut sky, alpha);
|
||||
if self.flash > 0 {
|
||||
if self.flash > 0 && !self.settings.file.bool("hideLightningFlashes") {
|
||||
// Lightning flash brightens the sky (LevelRenderer skyFlashTime).
|
||||
sky.sky_color = [0.9, 0.9, 1.0];
|
||||
sky.sky_light_factor = 1.0;
|
||||
@@ -9222,7 +9223,13 @@ impl Game<'_> {
|
||||
(view_yaw, view_pitch)
|
||||
} else if title {
|
||||
// PanoramaRenderer: the title cube spins at 0.1 degrees per tick, pitched 10 degrees.
|
||||
(-(self.started.elapsed().as_secs_f32() * 2.0) % 360.0, 10.0)
|
||||
(
|
||||
self.panorama_rotation.update(
|
||||
self.started.elapsed().as_secs_f32(),
|
||||
self.settings.file.double("panoramaScrollSpeed") as f32,
|
||||
),
|
||||
10.0,
|
||||
)
|
||||
} else {
|
||||
(view_yaw, view_pitch)
|
||||
};
|
||||
@@ -10842,6 +10849,7 @@ impl<'a> Game<'a> {
|
||||
gui,
|
||||
fog: Default::default(),
|
||||
screen_fx: Default::default(),
|
||||
panorama_rotation: Default::default(),
|
||||
world,
|
||||
streaming,
|
||||
lod: None,
|
||||
@@ -11880,6 +11888,7 @@ struct Loading {
|
||||
vanilla_root: PathBuf,
|
||||
pack_error: Option<String>,
|
||||
started: Instant,
|
||||
panorama_rotation: horizon_client::gfx::panorama::Rotation,
|
||||
progress: Progress,
|
||||
receiver: Receiver<LoaderMsg>,
|
||||
loaded: Option<std::result::Result<Loaded, String>>,
|
||||
@@ -12006,7 +12015,11 @@ impl Loading {
|
||||
};
|
||||
let mut batch = HudBatch::new(size);
|
||||
self.draw_menu(&mut batch);
|
||||
let frame = loading_frame(&batch);
|
||||
let mut frame = loading_frame(&batch);
|
||||
frame.yaw = self.panorama_rotation.update(
|
||||
self.started.elapsed().as_secs_f32(),
|
||||
self.settings.file.double("panoramaScrollSpeed") as f32,
|
||||
);
|
||||
if let Some(renderer) = &mut self.renderer {
|
||||
match renderer.render(&frame) {
|
||||
Ok(true) if self.gui.is_some() && self.menu.pending.is_none() => {
|
||||
@@ -12076,6 +12089,7 @@ impl Loading {
|
||||
game.renderer = Some(renderer);
|
||||
game.world_renderer_ready = true;
|
||||
game.fullscreen = self.fullscreen;
|
||||
game.panorama_rotation = self.panorama_rotation;
|
||||
self.menu.handoff(&mut game);
|
||||
game.settings = self.settings.clone();
|
||||
game.apply_settings();
|
||||
@@ -12184,6 +12198,7 @@ fn run_loading(
|
||||
vanilla_root,
|
||||
pack_error,
|
||||
started,
|
||||
panorama_rotation: Default::default(),
|
||||
progress,
|
||||
receiver,
|
||||
loaded: None,
|
||||
|
||||
@@ -1157,11 +1157,11 @@ impl Game<'_> {
|
||||
/// `LightmapRenderStateExtractor`: (brightness taken off the gamma
|
||||
/// option, the pulsing light scale).
|
||||
pub(super) fn darkness_lighting(&self, partial: f32) -> (f32, f32) {
|
||||
// options.darknessEffectScale is at its default of 100%.
|
||||
let modifier = self.darkness_blend(partial);
|
||||
let scale = self.settings.file.double("darknessEffectScale") as f32;
|
||||
let modifier = self.darkness_blend(partial) * scale;
|
||||
let pulse =
|
||||
((self.ticks as f32 - partial) * std::f32::consts::PI * 0.025).cos() * 0.45 * modifier;
|
||||
(modifier, pulse.max(0.0))
|
||||
(modifier, pulse.max(0.0) * scale)
|
||||
}
|
||||
|
||||
/// `LightmapRenderStateExtractor`: the night vision effect's intensity
|
||||
|
||||
@@ -688,6 +688,7 @@ mod tests {
|
||||
vanilla_root: PathBuf::new(),
|
||||
pack_error: None,
|
||||
started: Instant::now(),
|
||||
panorama_rotation: Default::default(),
|
||||
progress: Progress::new(),
|
||||
receiver,
|
||||
loaded: None,
|
||||
|
||||
@@ -230,6 +230,21 @@ impl Panorama {
|
||||
}
|
||||
}
|
||||
|
||||
/// `PanoramaRenderer`: accumulate rotation so changing speed does not jump
|
||||
/// back to a different point on the cube. `now` is monotonic seconds.
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
pub struct Rotation {
|
||||
last: f32,
|
||||
yaw: f32,
|
||||
}
|
||||
impl Rotation {
|
||||
pub fn update(&mut self, now: f32, speed: f32) -> f32 {
|
||||
self.yaw = (self.yaw - (now - self.last).max(0.0) * 2.0 * speed) % 360.0;
|
||||
self.last = now;
|
||||
self.yaw
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -282,6 +297,15 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rotation_speed_changes_preserve_position() {
|
||||
let mut rotation = Rotation::default();
|
||||
assert_eq!(rotation.update(5.0, 1.0), -10.0);
|
||||
assert_eq!(rotation.update(10.0, 0.0), -10.0);
|
||||
assert_eq!(rotation.update(12.0, 0.5), -12.0);
|
||||
assert_eq!(rotation.update(13.0, 1.0), -14.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn original_resolution_texels_and_vanilla_cube_orientation_are_preserved() {
|
||||
let f = Fixture::new(1024);
|
||||
|
||||
@@ -126,17 +126,21 @@ pub const SECTIONS: &[Section] = &[
|
||||
name: "Accessibility",
|
||||
blurb: "Contrast, motion, text backgrounds and notifications.",
|
||||
rows: |_| {
|
||||
[
|
||||
Opt::HighContrast,
|
||||
Opt::MenuBlur,
|
||||
Opt::TextBackgroundOpacity,
|
||||
Opt::NotificationDisplayTime,
|
||||
Opt::ShowSubtitles,
|
||||
Opt::ViewBobbing,
|
||||
Opt::ChatLineSpacing,
|
||||
]
|
||||
.map(HRow::Opt)
|
||||
.to_vec()
|
||||
let mut rows = vec![
|
||||
HRow::Opt(Opt::Narrator),
|
||||
HRow::Page(
|
||||
"Controls",
|
||||
"Key binds, mouse and controller",
|
||||
Page::Controls,
|
||||
),
|
||||
];
|
||||
rows.extend(
|
||||
options_ui::ACCESSIBILITY_OPTIONS[1..]
|
||||
.iter()
|
||||
.copied()
|
||||
.map(HRow::Opt),
|
||||
);
|
||||
rows
|
||||
},
|
||||
},
|
||||
Section {
|
||||
@@ -225,6 +229,8 @@ pub(crate) fn searchable_section(section: usize) -> bool {
|
||||
/// Whether an option is an on/off switch, and its value.
|
||||
fn switch_value(opt: Opt, s: &Settings) -> Option<bool> {
|
||||
Some(match opt {
|
||||
Opt::HideLightningFlashes => s.file.bool("hideLightningFlashes"),
|
||||
Opt::HideSplashTexts => s.file.bool("hideSplashTexts"),
|
||||
Opt::InvertY => s.invert_y,
|
||||
Opt::DiscreteScroll => s.discrete_scroll,
|
||||
Opt::ViewBobbing => s.view_bobbing,
|
||||
@@ -392,7 +398,18 @@ impl OptionsUi {
|
||||
HRow::Opt(opt) => {
|
||||
let (caption, value) = caption_value(opt, s);
|
||||
let cy = y + ROW_H / 2.0;
|
||||
if let Some(on) = switch_value(opt, s) {
|
||||
if !opt.available() {
|
||||
ui.row(x, y, &caption, "", 0.0);
|
||||
let label = "Unavailable";
|
||||
let bw = ui.button_width(label, false).max(96.0);
|
||||
ui.button(
|
||||
ROW + i as u64,
|
||||
[control_x - bw, y + 12.0, bw, CONTROL],
|
||||
label,
|
||||
Button::Secondary,
|
||||
false,
|
||||
);
|
||||
} else if let Some(on) = switch_value(opt, s) {
|
||||
ui.row(x, y, &caption, "", 0.0);
|
||||
ui.switch(ROW + i as u64, control_x, cy, on);
|
||||
} else if let Kind::Slider(v) = opt.kind(s) {
|
||||
@@ -768,7 +785,7 @@ impl OptionsUi {
|
||||
Some(Target::Row(i)) => {
|
||||
let section = self.section.min(SECTIONS.len() - 1);
|
||||
match self.horizon_rows(s, section).get(i) {
|
||||
Some(HRow::Opt(opt)) => {
|
||||
Some(HRow::Opt(opt)) if opt.available() => {
|
||||
opt.cycle(s, right, framebuffer);
|
||||
if *opt == Opt::Preset {
|
||||
apply_preset(s);
|
||||
@@ -857,6 +874,25 @@ mod tests {
|
||||
(point.0 * gui_per_dp, point.1 * gui_per_dp)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn accessibility_section_shares_the_complete_option_list() {
|
||||
let s = Settings::default();
|
||||
let section = SECTIONS.iter().find(|s| s.name == "Accessibility").unwrap();
|
||||
let rows = (section.rows)(&s);
|
||||
let options: Vec<_> = rows
|
||||
.iter()
|
||||
.filter_map(|row| match row {
|
||||
HRow::Opt(opt) => Some(*opt),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(options, options_ui::ACCESSIBILITY_OPTIONS);
|
||||
assert!(
|
||||
rows.iter()
|
||||
.any(|r| matches!(r, HRow::Page(_, _, Page::Controls)))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn horizon_scrollbar_track_drag_is_bounded_and_stops_on_release() {
|
||||
let atlas = atlas();
|
||||
|
||||
@@ -68,6 +68,22 @@ pub enum Opt {
|
||||
HighContrast,
|
||||
ShowSubtitles,
|
||||
NotificationDisplayTime,
|
||||
Narrator,
|
||||
TextBackground,
|
||||
ChatDelay,
|
||||
DistortionEffects,
|
||||
FovEffects,
|
||||
DarknessPulsing,
|
||||
DamageTilt,
|
||||
GlintSpeed,
|
||||
GlintStrength,
|
||||
HideLightningFlashes,
|
||||
MonochromeLogo,
|
||||
PanoramaSpeed,
|
||||
HideSplashTexts,
|
||||
NarratorHotkey,
|
||||
RotateWithMinecarts,
|
||||
HighContrastBlockOutlines,
|
||||
ForceUnicode,
|
||||
JapaneseGlyphs,
|
||||
/// Horizon's controller settings (`horizon-controller.txt`).
|
||||
@@ -114,7 +130,72 @@ pub(crate) enum Kind {
|
||||
Slider(f32),
|
||||
Cycle,
|
||||
}
|
||||
/// Options shared by the Classic page and Horizon's Accessibility section.
|
||||
/// `AccessibilityOptionsScreen.options`, with the Controls link inserted separately.
|
||||
pub(crate) const ACCESSIBILITY_OPTIONS: &[Opt] = &[
|
||||
Opt::Narrator,
|
||||
Opt::ShowSubtitles,
|
||||
Opt::HighContrast,
|
||||
Opt::MenuBlur,
|
||||
Opt::TextBackgroundOpacity,
|
||||
Opt::TextBackground,
|
||||
Opt::ChatOpacity,
|
||||
Opt::ChatLineSpacing,
|
||||
Opt::ChatDelay,
|
||||
Opt::NotificationDisplayTime,
|
||||
Opt::ViewBobbing,
|
||||
Opt::DistortionEffects,
|
||||
Opt::FovEffects,
|
||||
Opt::DarknessPulsing,
|
||||
Opt::DamageTilt,
|
||||
Opt::GlintSpeed,
|
||||
Opt::GlintStrength,
|
||||
Opt::HideLightningFlashes,
|
||||
Opt::MonochromeLogo,
|
||||
Opt::PanoramaSpeed,
|
||||
Opt::HideSplashTexts,
|
||||
Opt::NarratorHotkey,
|
||||
Opt::RotateWithMinecarts,
|
||||
Opt::HighContrastBlockOutlines,
|
||||
];
|
||||
impl Opt {
|
||||
/// Keep controls visible while their underlying systems are still missing.
|
||||
pub(crate) fn available(self) -> bool {
|
||||
!matches!(
|
||||
self,
|
||||
Opt::Narrator
|
||||
| Opt::NarratorHotkey
|
||||
| Opt::ChatDelay
|
||||
| Opt::DistortionEffects
|
||||
| Opt::GlintSpeed
|
||||
| Opt::GlintStrength
|
||||
| Opt::MonochromeLogo
|
||||
| Opt::RotateWithMinecarts
|
||||
| Opt::HighContrastBlockOutlines
|
||||
)
|
||||
}
|
||||
fn file_key(self) -> Option<&'static str> {
|
||||
Some(match self {
|
||||
Opt::Narrator => "narrator",
|
||||
Opt::TextBackground => "backgroundForChatOnly",
|
||||
Opt::ChatDelay => "chatDelay",
|
||||
Opt::DistortionEffects => "screenEffectScale",
|
||||
Opt::FovEffects => "fovEffectScale",
|
||||
Opt::DarknessPulsing => "darknessEffectScale",
|
||||
Opt::DamageTilt => "damageTiltStrength",
|
||||
Opt::GlintSpeed => "glintSpeed",
|
||||
Opt::GlintStrength => "glintStrength",
|
||||
Opt::HideLightningFlashes => "hideLightningFlashes",
|
||||
Opt::MonochromeLogo => "darkMojangStudiosBackground",
|
||||
Opt::PanoramaSpeed => "panoramaScrollSpeed",
|
||||
Opt::HideSplashTexts => "hideSplashTexts",
|
||||
Opt::NarratorHotkey => "narratorHotkey",
|
||||
Opt::RotateWithMinecarts => "rotateWithMinecart",
|
||||
Opt::HighContrastBlockOutlines => "highContrastBlockOutline",
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn caption(self) -> &'static str {
|
||||
match self {
|
||||
Opt::Fov => "options.fov",
|
||||
@@ -168,6 +249,22 @@ impl Opt {
|
||||
Opt::HighContrast => "options.accessibility.high_contrast",
|
||||
Opt::ShowSubtitles => "options.showSubtitles",
|
||||
Opt::NotificationDisplayTime => "options.notifications.display_time",
|
||||
Opt::Narrator => "options.narrator",
|
||||
Opt::TextBackground => "options.accessibility.text_background",
|
||||
Opt::ChatDelay => "Chat Delay",
|
||||
Opt::DistortionEffects => "options.screenEffectScale",
|
||||
Opt::FovEffects => "options.fovEffectScale",
|
||||
Opt::DarknessPulsing => "options.darknessEffectScale",
|
||||
Opt::DamageTilt => "options.damageTiltStrength",
|
||||
Opt::GlintSpeed => "options.glintSpeed",
|
||||
Opt::GlintStrength => "options.glintStrength",
|
||||
Opt::HideLightningFlashes => "options.hideLightningFlashes",
|
||||
Opt::MonochromeLogo => "options.darkMojangStudiosBackgroundColor",
|
||||
Opt::PanoramaSpeed => "options.accessibility.panorama_speed",
|
||||
Opt::HideSplashTexts => "options.hideSplashTexts",
|
||||
Opt::NarratorHotkey => "options.accessibility.narrator_hotkey",
|
||||
Opt::RotateWithMinecarts => "options.rotateWithMinecart",
|
||||
Opt::HighContrastBlockOutlines => "options.accessibility.high_contrast_block_outline",
|
||||
Opt::ForceUnicode => "options.forceUnicodeFont",
|
||||
Opt::JapaneseGlyphs => "options.japaneseGlyphVariants",
|
||||
// Horizon's own options: English captions (no vanilla keys).
|
||||
@@ -189,6 +286,14 @@ impl Opt {
|
||||
pub(crate) fn kind(self, s: &Settings) -> Kind {
|
||||
let unit = |v: f32, lo: f32, hi: f32| Kind::Slider(((v - lo) / (hi - lo)).clamp(0.0, 1.0));
|
||||
match self {
|
||||
Opt::FovEffects | Opt::DarknessPulsing => {
|
||||
Kind::Slider(s.file.double(self.file_key().unwrap()).sqrt() as f32)
|
||||
}
|
||||
Opt::DistortionEffects
|
||||
| Opt::DamageTilt
|
||||
| Opt::GlintSpeed
|
||||
| Opt::GlintStrength
|
||||
| Opt::PanoramaSpeed => Kind::Slider(s.file.double(self.file_key().unwrap()) as f32),
|
||||
Opt::Fov => unit(s.fov, 30.0, 110.0),
|
||||
Opt::RenderDistance => unit(s.render_distance as f32, 2.0, 64.0),
|
||||
Opt::SimulationDistance => unit(s.simulation_distance as f32, 5.0, 32.0),
|
||||
@@ -253,6 +358,21 @@ impl Opt {
|
||||
pub fn label(self, s: &Settings) -> Text {
|
||||
let c = self.caption();
|
||||
match self {
|
||||
Opt::ChatDelay => tr("options.chat.delay_none"),
|
||||
Opt::FovEffects
|
||||
| Opt::DarknessPulsing
|
||||
| Opt::DistortionEffects
|
||||
| Opt::DamageTilt
|
||||
| Opt::GlintSpeed
|
||||
| Opt::GlintStrength => {
|
||||
let value = s.file.double(self.file_key().unwrap()) as f32;
|
||||
if value == 0.0 {
|
||||
generic(c, tr("options.off"))
|
||||
} else {
|
||||
percent(c, value)
|
||||
}
|
||||
}
|
||||
Opt::PanoramaSpeed => percent(c, s.file.double("panoramaScrollSpeed") as f32),
|
||||
Opt::Fov => match s.fov as i32 {
|
||||
70 => generic(c, tr("options.fov.min")),
|
||||
110 => generic(c, tr("options.fov.max")),
|
||||
@@ -386,6 +506,19 @@ impl Opt {
|
||||
}
|
||||
fn value_text(self, s: &Settings) -> Text {
|
||||
match self {
|
||||
Opt::TextBackground => tr(if s.file.bool("backgroundForChatOnly") {
|
||||
"options.accessibility.text_background.chat"
|
||||
} else {
|
||||
"options.accessibility.text_background.everywhere"
|
||||
}),
|
||||
Opt::Narrator => tr("options.narrator.off"),
|
||||
Opt::ChatDelay => tr("options.chat.delay_none"),
|
||||
Opt::HideLightningFlashes => on_off(s.file.bool("hideLightningFlashes")),
|
||||
Opt::MonochromeLogo => on_off(s.file.bool("darkMojangStudiosBackground")),
|
||||
Opt::HideSplashTexts => on_off(s.file.bool("hideSplashTexts")),
|
||||
Opt::NarratorHotkey => on_off(s.file.bool("narratorHotkey")),
|
||||
Opt::RotateWithMinecarts => on_off(s.file.bool("rotateWithMinecart")),
|
||||
Opt::HighContrastBlockOutlines => on_off(s.file.bool("highContrastBlockOutline")),
|
||||
Opt::InvertY => on_off(s.invert_y),
|
||||
Opt::DiscreteScroll => on_off(s.discrete_scroll),
|
||||
Opt::ViewBobbing => on_off(s.view_bobbing),
|
||||
@@ -481,8 +614,20 @@ impl Opt {
|
||||
}
|
||||
/// Set a slider from its 0..1 position (OptionInstance value sets).
|
||||
pub fn set_slider(self, s: &mut Settings, v: f32) {
|
||||
if !self.available() {
|
||||
return;
|
||||
}
|
||||
let v = v.clamp(0.0, 1.0);
|
||||
let step = |lo: f32, hi: f32| (lo + v * (hi - lo)).round();
|
||||
match self {
|
||||
Opt::FovEffects | Opt::DarknessPulsing => s.file.set(
|
||||
self.file_key().unwrap(),
|
||||
crate::options_file::V::Double(f64::from(v).powi(2)),
|
||||
),
|
||||
Opt::DamageTilt | Opt::PanoramaSpeed => s.file.set(
|
||||
self.file_key().unwrap(),
|
||||
crate::options_file::V::Double(f64::from(v)),
|
||||
),
|
||||
Opt::Fov => s.fov = step(30.0, 110.0),
|
||||
Opt::RenderDistance => s.render_distance = step(2.0, 64.0) as i32,
|
||||
Opt::SimulationDistance => s.simulation_distance = step(5.0, 32.0) as i32,
|
||||
@@ -538,6 +683,9 @@ impl Opt {
|
||||
}
|
||||
/// Advance a cycle button (CycleButton.cycleValue).
|
||||
pub fn cycle(self, s: &mut Settings, back: bool, framebuffer: [i32; 2]) {
|
||||
if !self.available() {
|
||||
return;
|
||||
}
|
||||
let next = |n: u8, count: u8| {
|
||||
if back {
|
||||
(n + count - 1) % count
|
||||
@@ -557,6 +705,11 @@ impl Opt {
|
||||
value + 1
|
||||
};
|
||||
}
|
||||
Opt::TextBackground | Opt::HideLightningFlashes | Opt::HideSplashTexts => {
|
||||
let key = self.file_key().unwrap();
|
||||
s.file
|
||||
.set(key, crate::options_file::V::Bool(!s.file.bool(key)));
|
||||
}
|
||||
Opt::InvertY => s.invert_y = !s.invert_y,
|
||||
Opt::DiscreteScroll => s.discrete_scroll = !s.discrete_scroll,
|
||||
Opt::ViewBobbing => s.view_bobbing = !s.view_bobbing,
|
||||
@@ -896,6 +1049,9 @@ fn inactive(mut w: Widget) -> Widget {
|
||||
w
|
||||
}
|
||||
fn option_widget(s: &Settings, opt: Opt, x: f32, y: f32, w: f32) -> Widget {
|
||||
if !opt.available() {
|
||||
return inactive(button(x, y, w, opt.label(s), Act::Cycle(opt)));
|
||||
}
|
||||
match opt.kind(s) {
|
||||
Kind::Slider(v) => Widget {
|
||||
x,
|
||||
@@ -1217,19 +1373,25 @@ impl OptionsUi {
|
||||
Opt::AutoSuggestions,
|
||||
Opt::ReducedDebugInfo,
|
||||
]),
|
||||
Page::Accessibility => pairs(&[
|
||||
Opt::ShowSubtitles,
|
||||
Opt::HighContrast,
|
||||
Opt::MenuBlur,
|
||||
Opt::TextBackgroundOpacity,
|
||||
Opt::ChatOpacity,
|
||||
Opt::ChatLineSpacing,
|
||||
Opt::NotificationDisplayTime,
|
||||
Opt::ViewBobbing,
|
||||
Opt::ToggleCrouch,
|
||||
Opt::ToggleSprint,
|
||||
Opt::AutoJump,
|
||||
]),
|
||||
Page::Accessibility => {
|
||||
let mut rows = vec![Row::Buttons(
|
||||
option_widget(s, Opt::Narrator, 0.0, 0.0, 150.0),
|
||||
Some(button(
|
||||
0.0,
|
||||
0.0,
|
||||
150.0,
|
||||
tr("options.controls"),
|
||||
Act::Push(Page::Controls),
|
||||
)),
|
||||
)];
|
||||
rows.extend(pairs(&ACCESSIBILITY_OPTIONS[1..]));
|
||||
rows.extend(pairs(&[
|
||||
Opt::ToggleCrouch,
|
||||
Opt::ToggleSprint,
|
||||
Opt::AutoJump,
|
||||
]));
|
||||
rows
|
||||
}
|
||||
Page::Font => pairs(&[Opt::ForceUnicode, Opt::JapaneseGlyphs]),
|
||||
Page::Mods => {
|
||||
if s.mods.installed.is_empty() {
|
||||
@@ -1820,6 +1982,17 @@ impl OptionsUi {
|
||||
if let Some(key) = key.filter(|key| lang::has(key)) {
|
||||
tooltip = Some(atlas.font.split(&tr(&key), 170.0));
|
||||
}
|
||||
if let WKind::Button {
|
||||
act: Act::Cycle(opt),
|
||||
..
|
||||
} = &wd.kind
|
||||
&& !opt.available()
|
||||
{
|
||||
tooltip = Some(atlas.font.split(
|
||||
&Text::literal("This feature is not yet available in Horizon."),
|
||||
170.0,
|
||||
));
|
||||
}
|
||||
if let WKind::Button {
|
||||
act: Act::ToggleMod(i),
|
||||
..
|
||||
@@ -2475,6 +2648,78 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::ui_theme::{MenuStyle, set_style, style};
|
||||
|
||||
#[test]
|
||||
fn accessibility_sliders_and_toggles_survive_options_round_trip() {
|
||||
let mut s = Settings::default();
|
||||
for opt in [
|
||||
Opt::FovEffects,
|
||||
Opt::DarknessPulsing,
|
||||
Opt::DamageTilt,
|
||||
Opt::PanoramaSpeed,
|
||||
] {
|
||||
for position in [0.0, 0.5, 1.0] {
|
||||
opt.set_slider(&mut s, position);
|
||||
let loaded = Settings::parse(&s.serialize());
|
||||
assert_eq!(opt.slider_position(&loaded), Some(position));
|
||||
let expected = if matches!(opt, Opt::FovEffects | Opt::DarknessPulsing) {
|
||||
f64::from(position).powi(2)
|
||||
} else {
|
||||
f64::from(position)
|
||||
};
|
||||
assert_eq!(loaded.file.double(opt.file_key().unwrap()), expected);
|
||||
}
|
||||
}
|
||||
for opt in [
|
||||
Opt::TextBackground,
|
||||
Opt::HideLightningFlashes,
|
||||
Opt::HideSplashTexts,
|
||||
] {
|
||||
let key = opt.file_key().unwrap();
|
||||
let before = s.file.bool(key);
|
||||
opt.cycle(&mut s, false, [854, 480]);
|
||||
assert_eq!(Settings::parse(&s.serialize()).file.bool(key), !before);
|
||||
}
|
||||
Opt::TextBackground.cycle(&mut s, false, [854, 480]);
|
||||
let chat_only = s.text_background(0.0);
|
||||
Opt::TextBackground.cycle(&mut s, false, [854, 480]);
|
||||
assert_ne!(s.text_background(0.0), chat_only);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn accessibility_has_all_options_and_disabled_placeholders() {
|
||||
let mut s = Settings::default();
|
||||
let mut ui = OptionsUi::default();
|
||||
ui.show(Page::Accessibility);
|
||||
let (widgets, _, _, _) = ui.layout(&s, 480.0, 1200.0);
|
||||
for &opt in ACCESSIBILITY_OPTIONS {
|
||||
let widget = widgets
|
||||
.iter()
|
||||
.find(|w| match w.kind {
|
||||
WKind::Button {
|
||||
act: Act::Cycle(o), ..
|
||||
}
|
||||
| WKind::Slider { opt: o, .. } => o == opt,
|
||||
_ => false,
|
||||
})
|
||||
.expect("every accessibility option has a control");
|
||||
if !opt.available() {
|
||||
assert!(matches!(widget.kind, WKind::Button { active: false, .. }));
|
||||
let before = s.serialize();
|
||||
opt.cycle(&mut s, false, [854, 480]);
|
||||
opt.set_slider(&mut s, 0.0);
|
||||
assert_eq!(s.serialize(), before);
|
||||
}
|
||||
}
|
||||
assert!(widgets.iter().any(|w| matches!(
|
||||
w.kind,
|
||||
WKind::Button {
|
||||
act: Act::Push(Page::Controls),
|
||||
active: true,
|
||||
..
|
||||
}
|
||||
)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn render_distance_slider_round_trips_through_extended_options_range() {
|
||||
let mut s = Settings::default();
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 96 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
Reference in New Issue
Block a user