Codechange: migrate all Window-related timers to the new framework
This means we also say goodbye to GUITimers.
This commit is contained in:

committed by
Patric Stout

parent
5e1bcee39b
commit
1ba4dcc924
@@ -22,7 +22,6 @@
|
||||
#include "sound_func.h"
|
||||
#include "window_func.h"
|
||||
#include "company_base.h"
|
||||
#include "guitimer_func.h"
|
||||
#include "zoom_func.h"
|
||||
|
||||
#include "smallmap_gui.h"
|
||||
@@ -1072,7 +1071,7 @@ void SmallMapWindow::SetupWidgetData()
|
||||
this->GetWidget<NWidgetStacked>(WID_SM_SELECT_BUTTONS)->SetDisplayedPlane(plane);
|
||||
}
|
||||
|
||||
SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc), refresh(GUITimer(FORCE_REFRESH_PERIOD))
|
||||
SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc)
|
||||
{
|
||||
_smallmap_industry_highlight = INVALID_INDUSTRYTYPE;
|
||||
this->overlay = new LinkGraphOverlay(this, WID_SM_MAP, 0, this->GetOverlayCompanyMask(), 1);
|
||||
@@ -1416,7 +1415,6 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
|
||||
}
|
||||
if (new_highlight != _smallmap_industry_highlight) {
|
||||
_smallmap_industry_highlight = new_highlight;
|
||||
this->refresh.SetInterval(_smallmap_industry_highlight != INVALID_INDUSTRYTYPE ? BLINK_PERIOD : FORCE_REFRESH_PERIOD);
|
||||
_smallmap_industry_highlight_state = true;
|
||||
this->SetDirty();
|
||||
}
|
||||
@@ -1588,11 +1586,9 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void SmallMapWindow::OnRealtimeTick(uint delta_ms)
|
||||
/** Update all the links on the map. */
|
||||
void SmallMapWindow::UpdateLinks()
|
||||
{
|
||||
/* Update the window every now and then */
|
||||
if (!this->refresh.Elapsed(delta_ms)) return;
|
||||
|
||||
if (this->map_type == SMT_LINKSTATS) {
|
||||
CompanyMask company_mask = this->GetOverlayCompanyMask();
|
||||
if (this->overlay->GetCompanyMask() != company_mask) {
|
||||
@@ -1601,9 +1597,25 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
|
||||
this->overlay->SetDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Blink the industries (if hover over an industry). */
|
||||
void SmallMapWindow::Blink()
|
||||
{
|
||||
if (_smallmap_industry_highlight == INVALID_INDUSTRYTYPE) return;
|
||||
|
||||
_smallmap_industry_highlight_state = !_smallmap_industry_highlight_state;
|
||||
|
||||
this->refresh.SetInterval(_smallmap_industry_highlight != INVALID_INDUSTRYTYPE ? BLINK_PERIOD : FORCE_REFRESH_PERIOD);
|
||||
this->UpdateLinks();
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
/** Force a full refresh of the map. */
|
||||
void SmallMapWindow::ForceRefresh()
|
||||
{
|
||||
if (_smallmap_industry_highlight != INVALID_INDUSTRYTYPE) return;
|
||||
|
||||
this->UpdateLinks();
|
||||
this->SetDirty();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user