mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Remove map drag from the settings file since it is always reset when closing the map leaving little reason to persist it
This commit is contained in:
parent
2983ab60ed
commit
58c690f1d2
@ -103,6 +103,7 @@ pub struct Map<'a> {
|
||||
rot_imgs: &'a ImgsRot,
|
||||
tooltip_manager: &'a mut TooltipManager,
|
||||
location_marker: Option<Vec2<f32>>,
|
||||
map_drag: Vec2<f64>,
|
||||
}
|
||||
impl<'a> Map<'a> {
|
||||
#[allow(clippy::too_many_arguments)] // TODO: Pending review in #587
|
||||
@ -118,6 +119,7 @@ impl<'a> Map<'a> {
|
||||
global_state: &'a GlobalState,
|
||||
tooltip_manager: &'a mut TooltipManager,
|
||||
location_marker: Option<Vec2<f32>>,
|
||||
map_drag: Vec2<f64>,
|
||||
) -> Self {
|
||||
Self {
|
||||
show,
|
||||
@ -132,6 +134,7 @@ impl<'a> Map<'a> {
|
||||
global_state,
|
||||
tooltip_manager,
|
||||
location_marker,
|
||||
map_drag,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -145,6 +148,7 @@ pub enum Event {
|
||||
Close,
|
||||
RequestSiteInfo(SiteId),
|
||||
SetLocationMarker(Vec2<f32>),
|
||||
MapDrag(Vec2<f64>),
|
||||
ToggleMarker,
|
||||
}
|
||||
|
||||
@ -197,7 +201,6 @@ impl<'a> Widget for Map<'a> {
|
||||
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
|
||||
common_base::prof_span!("Map::update");
|
||||
let widget::UpdateArgs { state, ui, .. } = args;
|
||||
let drag = self.global_state.settings.interface.map_drag;
|
||||
let zoom = self.global_state.settings.interface.map_zoom;
|
||||
let show_difficulty = self.global_state.settings.interface.map_show_difficulty;
|
||||
let show_towns = self.global_state.settings.interface.map_show_towns;
|
||||
@ -318,7 +321,7 @@ impl<'a> Widget for Map<'a> {
|
||||
player_pos.xy().map(|x| x as f64) / TerrainChunkSize::RECT_SIZE.map(|x| x as f64);
|
||||
let min_drag = player_pos_chunks - worldsize.map(|x| x as f64);
|
||||
let max_drag = player_pos_chunks;
|
||||
let drag = drag.clamped(min_drag, max_drag);
|
||||
let drag = self.map_drag.clamped(min_drag, max_drag);
|
||||
|
||||
let handle_widget_mouse_events = |widget,
|
||||
wpos: Option<Vec2<f32>>,
|
||||
@ -360,7 +363,7 @@ impl<'a> Widget for Map<'a> {
|
||||
let mouse_pos = Vec2::from_slice(&cursor_pos);
|
||||
let drag_new = drag + mouse_pos * (1.0 / new_zoom_lvl - 1.0 / zoom);
|
||||
if drag_new != drag {
|
||||
events.push(Event::SettingsChange(MapDrag(drag_new)));
|
||||
events.push(Event::MapDrag(drag_new));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -375,7 +378,7 @@ impl<'a> Widget for Map<'a> {
|
||||
// Drag represents offset of view from the player_pos in chunk coords
|
||||
let drag_new = drag + dragged / zoom;
|
||||
if drag_new != drag {
|
||||
events.push(Event::SettingsChange(MapDrag(drag_new)));
|
||||
events.push(Event::MapDrag(drag_new));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1238,7 +1241,7 @@ impl<'a> Widget for Map<'a> {
|
||||
.set(state.ids.recenter_button, ui)
|
||||
.was_clicked()
|
||||
{
|
||||
events.push(Event::SettingsChange(MapDrag(Vec2::zero())));
|
||||
events.push(Event::MapDrag(Vec2::zero()));
|
||||
};
|
||||
|
||||
Image::new(self.imgs.m_move_ico)
|
||||
|
@ -930,6 +930,7 @@ pub struct Hud {
|
||||
crosshair_opacity: f32,
|
||||
floaters: Floaters,
|
||||
voxel_minimap: VoxelMinimap,
|
||||
map_drag: Vec2<f64>,
|
||||
}
|
||||
|
||||
impl Hud {
|
||||
@ -1052,6 +1053,7 @@ impl Hud {
|
||||
combo_floaters: VecDeque::new(),
|
||||
block_floaters: Vec::new(),
|
||||
},
|
||||
map_drag: Vec2::zero(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -3064,6 +3066,7 @@ impl Hud {
|
||||
global_state,
|
||||
tooltip_manager,
|
||||
self.show.location_marker,
|
||||
self.map_drag,
|
||||
)
|
||||
.set(self.ids.map, ui_widgets)
|
||||
{
|
||||
@ -3082,6 +3085,9 @@ impl Hud {
|
||||
map::Event::SetLocationMarker(pos) => {
|
||||
self.show.location_marker = Some(pos);
|
||||
},
|
||||
map::Event::MapDrag(new_drag) => {
|
||||
self.map_drag = new_drag;
|
||||
},
|
||||
map::Event::ToggleMarker => {
|
||||
self.show.map_marker = !self.show.map_marker;
|
||||
},
|
||||
@ -3089,12 +3095,7 @@ impl Hud {
|
||||
}
|
||||
} else {
|
||||
// Reset the map position when it's not showing
|
||||
let drag = &global_state.settings.interface.map_drag;
|
||||
if drag.x != 0.0 || drag.y != 0.0 {
|
||||
events.push(Event::SettingsChange(
|
||||
InterfaceChange::MapDrag(Vec2::zero()).into(),
|
||||
))
|
||||
}
|
||||
self.map_drag = Vec2::zero();
|
||||
}
|
||||
|
||||
if self.show.esc_menu {
|
||||
|
@ -15,7 +15,6 @@ use crate::{
|
||||
GlobalState,
|
||||
};
|
||||
use i18n::{LanguageMetadata, LocalizationHandle};
|
||||
use vek::*;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Audio {
|
||||
@ -118,7 +117,6 @@ pub enum Interface {
|
||||
MinimapZoom(f64),
|
||||
//Map settings
|
||||
MapZoom(f64),
|
||||
MapDrag(Vec2<f64>),
|
||||
MapShowTopoMap(bool),
|
||||
MapShowDifficulty(bool),
|
||||
MapShowTowns(bool),
|
||||
@ -497,9 +495,6 @@ impl SettingsChange {
|
||||
Interface::MapZoom(map_zoom) => {
|
||||
settings.interface.map_zoom = map_zoom;
|
||||
},
|
||||
Interface::MapDrag(map_drag) => {
|
||||
settings.interface.map_drag = map_drag;
|
||||
},
|
||||
Interface::MapShowTopoMap(map_show_topo_map) => {
|
||||
settings.interface.map_show_topo_map = map_show_topo_map;
|
||||
},
|
||||
|
@ -3,7 +3,6 @@ use crate::{
|
||||
ui::ScaleMode,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use vek::*;
|
||||
|
||||
/// `InterfaceSettings` contains UI, HUD and Map options.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
@ -29,7 +28,6 @@ pub struct InterfaceSettings {
|
||||
pub always_show_bars: bool,
|
||||
pub ui_scale: ScaleMode,
|
||||
pub map_zoom: f64,
|
||||
pub map_drag: Vec2<f64>,
|
||||
pub map_show_topo_map: bool,
|
||||
pub map_show_difficulty: bool,
|
||||
pub map_show_towns: bool,
|
||||
@ -68,7 +66,6 @@ impl Default for InterfaceSettings {
|
||||
always_show_bars: false,
|
||||
ui_scale: ScaleMode::RelativeToWindow([1920.0, 1080.0].into()),
|
||||
map_zoom: 10.0,
|
||||
map_drag: Vec2 { x: 0.0, y: 0.0 },
|
||||
map_show_topo_map: true,
|
||||
map_show_difficulty: true,
|
||||
map_show_towns: true,
|
||||
|
Loading…
Reference in New Issue
Block a user