Fix industry chain window not always updating map-mode viewports

pull/390/head
Jonathan G Rennison 2 years ago
parent 5c2fb5c160
commit 8eb0609541

@ -2748,16 +2748,7 @@ struct IndustryCargoesWindow : public Window {
{
if (!this->IsWidgetLowered(WID_IC_NOTIFY)) return;
/* Only notify the smallmap window if it exists. In particular, do not
* bring it to the front to prevent messing up any nice layout of the user. */
InvalidateWindowClassesData(WC_SMALLMAP, 0);
/* Notify viewports too. */
for (Window *w : Window::IterateFromBack()) {
if (w->viewport != nullptr)
if (w->viewport->zoom >= ZOOM_LVL_DRAW_MAP && w->viewport->map_type == VPMT_INDUSTRY)
w->InvalidateData();
}
UpdateSmallMapSelectedIndustries();
}
/**

@ -165,6 +165,32 @@ static bool _smallmap_industry_highlight_state;
/** For connecting company ID to position in owner list (small map legend) */
uint _company_to_list_pos[MAX_COMPANIES];
static void NotifyAllViewports(ViewportMapType map_type)
{
for (Window *w : Window::IterateFromBack()) {
if (w->viewport != nullptr) {
if (w->viewport->zoom >= ZOOM_LVL_DRAW_MAP && w->viewport->map_type == map_type) {
ClearViewportLandPixelCache(w->viewport);
w->InvalidateData();
}
}
}
}
void UpdateSmallMapSelectedIndustries()
{
extern std::bitset<NUM_INDUSTRYTYPES> _displayed_industries;
for (int i = 0; i != _smallmap_industry_count; i++) {
_legend_from_industries[i].show_on_map = _displayed_industries.test(_legend_from_industries[i].type);
}
NotifyAllViewports(VPMT_INDUSTRY);
/* Only notify the smallmap window if it exists. In particular, do not
* bring it to the front to prevent messing up any nice layout of the user. */
InvalidateWindowClassesData(WC_SMALLMAP, 0);
}
/**
* Fills an array for the industries legends.
*/
@ -592,17 +618,6 @@ static inline uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t)
return MKCOLOUR_XXXX(_legend_land_owners[_company_to_list_pos[o]].colour);
}
static void NotifyAllViewports(ViewportMapType map_type)
{
for (Window *w : Window::IterateFromBack()) {
if (w->viewport != nullptr)
if (w->viewport->zoom >= ZOOM_LVL_DRAW_MAP && w->viewport->map_type == map_type) {
ClearViewportLandPixelCache(w->viewport);
w->InvalidateData();
}
}
}
/** Vehicle colours in #SMT_VEHICLES mode. Indexed by #VehicleType. */
static const byte _vehicle_type_colours[6] = {
PC_RED, PC_YELLOW, PC_LIGHT_BLUE, PC_WHITE, PC_BLACK, PC_RED
@ -1571,12 +1586,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
break;
case 0: {
extern std::bitset<NUM_INDUSTRYTYPES> _displayed_industries;
if (this->map_type != SMT_INDUSTRY) this->SwitchMapType(SMT_INDUSTRY);
for (int i = 0; i != _smallmap_industry_count; i++) {
_legend_from_industries[i].show_on_map = _displayed_industries.test(_legend_from_industries[i].type);
}
break;
}

@ -46,6 +46,7 @@ struct TunnelBridgeToMap {
};
typedef std::vector<TunnelBridgeToMap> TunnelBridgeToMapVector;
void UpdateSmallMapSelectedIndustries();
void BuildIndustriesLegend();
void ShowSmallMap();
void BuildLandLegend();

Loading…
Cancel
Save