Options: add Java 26.3 mouse settings
This commit is contained in:
@@ -5694,17 +5694,22 @@ impl Game<'_> {
|
||||
fn apply_cursor_icon(&mut self) {
|
||||
use horizon_client::widgets::Cursor;
|
||||
let wanted = horizon_client::widgets::take_cursor();
|
||||
if wanted == self.cursor_icon {
|
||||
let effective = if self.settings.allow_cursor_changes {
|
||||
wanted
|
||||
} else {
|
||||
Cursor::Arrow
|
||||
};
|
||||
if effective == self.cursor_icon {
|
||||
return;
|
||||
}
|
||||
if let Some(window) = &self.window {
|
||||
window.set_cursor(match wanted {
|
||||
window.set_cursor(match effective {
|
||||
Cursor::Arrow => winit::window::CursorIcon::Default,
|
||||
Cursor::PointingHand => winit::window::CursorIcon::Pointer,
|
||||
Cursor::NotAllowed => winit::window::CursorIcon::NotAllowed,
|
||||
});
|
||||
}
|
||||
self.cursor_icon = wanted;
|
||||
self.cursor_icon = effective;
|
||||
}
|
||||
/// LevelLoadingScreen.onClose -> Gui.setScreen(null) -> grabMouse.
|
||||
fn capture_loaded_world(&mut self) {
|
||||
|
||||
@@ -73,6 +73,17 @@ pub(crate) const ACCESSIBILITY_OPTIONS: &[Opt] = &[
|
||||
Opt::RotateWithMinecarts,
|
||||
Opt::HighContrastBlockOutlines,
|
||||
];
|
||||
|
||||
/// `MouseSettingsScreen.options` in Java Edition 26.3, in vanilla order.
|
||||
pub(crate) const MOUSE_OPTIONS: &[Opt] = &[
|
||||
Opt::Sensitivity,
|
||||
Opt::WheelSensitivity,
|
||||
Opt::DiscreteScroll,
|
||||
Opt::InvertX,
|
||||
Opt::InvertY,
|
||||
Opt::AllowCursorChanges,
|
||||
];
|
||||
|
||||
impl Opt {
|
||||
/// Keep controls visible while their underlying systems are still missing.
|
||||
pub(crate) fn available(self) -> bool {
|
||||
@@ -129,8 +140,10 @@ impl Opt {
|
||||
Opt::SimulationDistance => "options.simulationDistance",
|
||||
Opt::Sensitivity => "options.sensitivity",
|
||||
Opt::WheelSensitivity => "options.mouseWheelSensitivity",
|
||||
Opt::InvertX => "options.invertMouseX",
|
||||
Opt::InvertY => "options.invertMouseY",
|
||||
Opt::DiscreteScroll => "options.discrete_mouse_scroll",
|
||||
Opt::AllowCursorChanges => "options.allowCursorChanges",
|
||||
Opt::Volume(_) => "soundCategory.master",
|
||||
Opt::GuiScale => "options.guiScale",
|
||||
Opt::ViewBobbing => "options.viewBobbing",
|
||||
@@ -454,8 +467,10 @@ impl Opt {
|
||||
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::InvertX => on_off(s.invert_x),
|
||||
Opt::InvertY => on_off(s.invert_y),
|
||||
Opt::DiscreteScroll => on_off(s.discrete_scroll),
|
||||
Opt::AllowCursorChanges => on_off(s.allow_cursor_changes),
|
||||
Opt::ViewBobbing => on_off(s.view_bobbing),
|
||||
Opt::Vsync => on_off(s.vsync),
|
||||
Opt::Fullscreen => on_off(s.fullscreen),
|
||||
@@ -659,8 +674,10 @@ impl Opt {
|
||||
s.file
|
||||
.set(key, crate::options_file::V::Bool(!s.file.bool(key)));
|
||||
}
|
||||
Opt::InvertX => s.invert_x = !s.invert_x,
|
||||
Opt::InvertY => s.invert_y = !s.invert_y,
|
||||
Opt::DiscreteScroll => s.discrete_scroll = !s.discrete_scroll,
|
||||
Opt::AllowCursorChanges => s.allow_cursor_changes = !s.allow_cursor_changes,
|
||||
Opt::ViewBobbing => s.view_bobbing = !s.view_bobbing,
|
||||
Opt::Vsync => s.vsync = !s.vsync,
|
||||
Opt::Fullscreen => s.fullscreen = !s.fullscreen,
|
||||
@@ -1434,12 +1451,7 @@ impl OptionsUi {
|
||||
]));
|
||||
rows
|
||||
}
|
||||
Page::Mouse => pairs(&[
|
||||
Opt::Sensitivity,
|
||||
Opt::WheelSensitivity,
|
||||
Opt::DiscreteScroll,
|
||||
Opt::InvertY,
|
||||
]),
|
||||
Page::Mouse => pairs(MOUSE_OPTIONS),
|
||||
Page::Chat => pairs(&[
|
||||
Opt::ChatVisibility,
|
||||
Opt::ChatColors,
|
||||
@@ -2876,6 +2888,45 @@ mod tests {
|
||||
assert_ne!(s.text_background(0.0), chat_only);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mouse_settings_match_java_26_3_option_order() {
|
||||
let mut ui = OptionsUi::default();
|
||||
ui.show(Page::Mouse);
|
||||
let mut options = Vec::new();
|
||||
for row in ui.list_rows(&Settings::default()) {
|
||||
if let Row::Pair(a, b) = row {
|
||||
options.push(a);
|
||||
if let Some(b) = b {
|
||||
options.push(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert_eq!(
|
||||
options,
|
||||
vec![
|
||||
Opt::Sensitivity,
|
||||
Opt::WheelSensitivity,
|
||||
Opt::DiscreteScroll,
|
||||
Opt::InvertX,
|
||||
Opt::InvertY,
|
||||
Opt::AllowCursorChanges,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mouse_settings_round_trip_with_java_defaults() {
|
||||
let mut settings = Settings::default();
|
||||
assert!(!settings.invert_x);
|
||||
assert!(settings.allow_cursor_changes);
|
||||
Opt::InvertX.cycle(&mut settings, false, [854, 480]);
|
||||
Opt::AllowCursorChanges.cycle(&mut settings, false, [854, 480]);
|
||||
let loaded = Settings::parse(&settings.serialize());
|
||||
assert!(loaded.invert_x);
|
||||
assert!(!loaded.allow_cursor_changes);
|
||||
assert!(!loaded.file.bool("allowCursorChanges"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn accessibility_has_all_options_and_disabled_placeholders() {
|
||||
let mut s = Settings::default();
|
||||
|
||||
@@ -167,6 +167,8 @@ pub struct Settings {
|
||||
/// Every option in its stored form (the typed fields above mirror it).
|
||||
pub file: OptionsFile,
|
||||
pub invert_x: bool,
|
||||
/// Allow widgets to replace the default mouse cursor icon.
|
||||
pub allow_cursor_changes: bool,
|
||||
pub toggle_attack: bool,
|
||||
pub toggle_use: bool,
|
||||
/// Taps of the sprint key counted as double taps (sprintWindow).
|
||||
@@ -222,6 +224,7 @@ impl Default for Settings {
|
||||
invert_y: false,
|
||||
mouse_wheel_sensitivity: 1.0,
|
||||
discrete_scroll: false,
|
||||
allow_cursor_changes: true,
|
||||
toggle_crouch: false,
|
||||
toggle_sprint: false,
|
||||
auto_jump: false,
|
||||
@@ -408,6 +411,7 @@ impl Settings {
|
||||
invert_y: f.bool("invertYMouse"),
|
||||
mouse_wheel_sensitivity: f.double("mouseWheelSensitivity") as f32,
|
||||
discrete_scroll: f.bool("discrete_mouse_scroll"),
|
||||
allow_cursor_changes: f.bool("allowCursorChanges"),
|
||||
toggle_crouch: f.bool("toggleCrouch"),
|
||||
toggle_sprint: f.bool("toggleSprint"),
|
||||
toggle_attack: f.bool("toggleAttack"),
|
||||
@@ -497,6 +501,7 @@ impl Settings {
|
||||
self.mouse_wheel_sensitivity,
|
||||
);
|
||||
put_b(&mut f, "discrete_mouse_scroll", self.discrete_scroll);
|
||||
put_b(&mut f, "allowCursorChanges", self.allow_cursor_changes);
|
||||
put_b(&mut f, "toggleCrouch", self.toggle_crouch);
|
||||
put_b(&mut f, "toggleSprint", self.toggle_sprint);
|
||||
put_b(&mut f, "toggleAttack", self.toggle_attack);
|
||||
@@ -616,8 +621,10 @@ pub enum Opt {
|
||||
SimulationDistance,
|
||||
Sensitivity,
|
||||
WheelSensitivity,
|
||||
InvertY,
|
||||
DiscreteScroll,
|
||||
InvertX,
|
||||
InvertY,
|
||||
AllowCursorChanges,
|
||||
Volume(usize),
|
||||
GuiScale,
|
||||
ViewBobbing,
|
||||
|
||||
Reference in New Issue
Block a user