Fix smallmap not refreshing at all when paused

This commit is contained in:
Jonathan G Rennison
2020-10-25 17:47:38 +00:00
parent 890e0c1198
commit 9909f9ab54
2 changed files with 20 additions and 4 deletions

View File

@@ -1499,10 +1499,10 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
/* virtual */ void SmallMapWindow::OnRealtimeTick(uint delta_ms) /* virtual */ void SmallMapWindow::OnRealtimeTick(uint delta_ms)
{ {
if (_pause_mode == PM_UNPAUSED) this->unpaused_since_last_redraw = true; if (_pause_mode != PM_UNPAUSED) delta_ms = this->PausedAdjustRefreshTimeDelta(delta_ms);
/* Update the window every now and then */ /* Update the window every now and then */
if (!this->unpaused_since_last_redraw || !this->refresh.Elapsed(delta_ms)) return; if (!this->refresh.Elapsed(delta_ms)) return;
if (this->map_type == SMT_LINKSTATS) { if (this->map_type == SMT_LINKSTATS) {
uint32 company_mask = this->GetOverlayCompanyMask(); uint32 company_mask = this->GetOverlayCompanyMask();
@@ -1516,7 +1516,6 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
this->refresh.SetInterval(this->GetRefreshPeriod()); this->refresh.SetInterval(this->GetRefreshPeriod());
this->SetDirty(); this->SetDirty();
this->unpaused_since_last_redraw = false;
} }
uint SmallMapWindow::GetRefreshPeriod() const uint SmallMapWindow::GetRefreshPeriod() const
@@ -1536,6 +1535,23 @@ uint SmallMapWindow::GetRefreshPeriod() const
} }
} }
uint SmallMapWindow::PausedAdjustRefreshTimeDelta(uint delta_ms) const
{
if (_smallmap_industry_highlight != INVALID_INDUSTRYTYPE) return delta_ms;
switch (map_type) {
case SMT_CONTOUR:
case SMT_VEHICLES:
return CeilDivT<uint>(delta_ms, 4);
case SMT_LINKSTATS:
return delta_ms;
default:
return CeilDivT<uint>(delta_ms, 2);
}
}
/** /**
* Set new #scroll_x, #scroll_y, and #subscroll values after limiting them such that the center * Set new #scroll_x, #scroll_y, and #subscroll values after limiting them such that the center
* of the smallmap always contains a part of the map. * of the smallmap always contains a part of the map.

View File

@@ -105,7 +105,6 @@ protected:
int zoom; ///< Zoom level. Bigger number means more zoom-out (further away). int zoom; ///< Zoom level. Bigger number means more zoom-out (further away).
GUITimer refresh; ///< Refresh timer. GUITimer refresh; ///< Refresh timer.
bool unpaused_since_last_redraw = false;
LinkGraphOverlay *overlay; LinkGraphOverlay *overlay;
static void BreakIndustryChainLink(); static void BreakIndustryChainLink();
@@ -179,6 +178,7 @@ protected:
void SwitchMapType(SmallMapType map_type); void SwitchMapType(SmallMapType map_type);
void SetNewScroll(int sx, int sy, int sub); void SetNewScroll(int sx, int sy, int sub);
uint GetRefreshPeriod() const; uint GetRefreshPeriod() const;
uint PausedAdjustRefreshTimeDelta(uint delta_ms) const;
void DrawMapIndicators() const; void DrawMapIndicators() const;
void DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch, int reps, int start_pos, int end_pos, Blitter *blitter) const; void DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch, int reps, int start_pos, int end_pos, Blitter *blitter) const;