mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Voxygen: Add support for map zoom with keybind
This commit is contained in:
parent
0b80e8ac5d
commit
7589331785
@ -3094,6 +3094,21 @@ impl Hud {
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_map_zoom(
|
||||
change: f64,
|
||||
world_size: Vec2<u32>,
|
||||
global_state: &mut GlobalState,
|
||||
) -> bool {
|
||||
let max_zoom = world_size.reduce_partial_max() as f64;
|
||||
|
||||
let new_zoom_lvl =
|
||||
(global_state.settings.interface.map_zoom + change).clamped(1.25, max_zoom / 64.0);
|
||||
|
||||
global_state.settings.interface.map_zoom = new_zoom_lvl;
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
let cursor_grabbed = global_state.window.is_cursor_grabbed();
|
||||
let handled = match event {
|
||||
WinEvent::Ui(event) => {
|
||||
@ -3220,6 +3235,12 @@ impl Hud {
|
||||
self.show.ingame = !self.show.ingame;
|
||||
true
|
||||
},
|
||||
GameInput::MapZoomIn if state && self.show.map => {
|
||||
handle_map_zoom(1.0, self.world_map.1, global_state)
|
||||
},
|
||||
GameInput::MapZoomOut if state && self.show.map => {
|
||||
handle_map_zoom(-1.0, self.world_map.1, global_state)
|
||||
},
|
||||
// Skillbar
|
||||
input => {
|
||||
if let Some(slot) = try_hotbar_slot_from_input(input) {
|
||||
|
@ -166,6 +166,8 @@ impl ControlSettings {
|
||||
GameInput::Select => KeyMouse::Key(VirtualKeyCode::Y),
|
||||
GameInput::AcceptGroupInvite => KeyMouse::Key(VirtualKeyCode::U),
|
||||
GameInput::DeclineGroupInvite => KeyMouse::Key(VirtualKeyCode::I),
|
||||
GameInput::MapZoomIn => KeyMouse::Key(VirtualKeyCode::Plus),
|
||||
GameInput::MapZoomOut => KeyMouse::Key(VirtualKeyCode::Minus),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,8 @@ pub enum GameInput {
|
||||
Select,
|
||||
AcceptGroupInvite,
|
||||
DeclineGroupInvite,
|
||||
MapZoomIn,
|
||||
MapZoomOut,
|
||||
}
|
||||
|
||||
impl GameInput {
|
||||
@ -138,6 +140,8 @@ impl GameInput {
|
||||
GameInput::Select => "gameinput.select",
|
||||
GameInput::AcceptGroupInvite => "gameinput.acceptgroupinvite",
|
||||
GameInput::DeclineGroupInvite => "gameinput.declinegroupinvite",
|
||||
GameInput::MapZoomIn => "gameinput.mapzoomin",
|
||||
GameInput::MapZoomOut => "gameinput.mapzoomout",
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,6 +204,8 @@ impl GameInput {
|
||||
GameInput::Select,
|
||||
GameInput::AcceptGroupInvite,
|
||||
GameInput::DeclineGroupInvite,
|
||||
GameInput::MapZoomIn,
|
||||
GameInput::MapZoomOut,
|
||||
]
|
||||
.iter()
|
||||
.copied()
|
||||
|
Loading…
Reference in New Issue
Block a user