Avoid saving settings if maps are not updating

Fixes #1193
This commit is contained in:
Zakru 2021-06-15 20:52:59 +03:00
parent ad92d4deb0
commit 52c965fb6d
2 changed files with 11 additions and 7 deletions

View File

@ -327,7 +327,9 @@ impl<'a> Widget for Map<'a> {
.sum();
// Drag represents offset of view from the player_pos in chunk coords
let drag_new = drag + dragged / map_size / zoom * max_zoom;
if drag_new != drag {
events.push(Event::SettingsChange(MapDrag(drag_new)));
}
let rect_src = position::Rect::from_xy_dim(
[
@ -392,10 +394,12 @@ impl<'a> Widget for Map<'a> {
.scrolls()
.map(|scroll| scroll.y)
.sum();
if scrolled != 0.0 {
let new_zoom_lvl = (self.global_state.settings.interface.map_zoom
* (scrolled * 0.05 * -1.0).exp2())
.clamped(1.25, max_zoom / 64.0);
events.push(Event::SettingsChange(MapZoom(new_zoom_lvl as f64)));
}
// Icon settings
// Alignment
Rectangle::fill_with([150.0, 200.0], color::TRANSPARENT)

View File

@ -514,6 +514,7 @@ impl<'a> Widget for MiniMap<'a> {
// Set the image dimensions here, rather than recomputing each time.
zoom = min_zoom.max(zoom / ZOOM_FACTOR);
// set_image_dims(zoom);
events.push(Event::SettingsChange(MinimapZoom(zoom)));
}
if Button::image(self.imgs.mmap_plus)
.w_h(18.0 * SCALE, 18.0 * SCALE)
@ -528,6 +529,7 @@ impl<'a> Widget for MiniMap<'a> {
{
zoom = min_zoom.max(zoom * ZOOM_FACTOR);
// set_image_dims(zoom);
events.push(Event::SettingsChange(MinimapZoom(zoom)));
}
// Always northfacing button
@ -555,8 +557,6 @@ impl<'a> Widget for MiniMap<'a> {
events.push(Event::SettingsChange(MinimapFaceNorth(!is_facing_north)));
}
events.push(Event::SettingsChange(MinimapZoom(zoom)));
// Coordinates
let player_pos = self
.client