Fix industry chain window not always updating map-mode viewports
This commit is contained in:
@@ -2748,16 +2748,7 @@ struct IndustryCargoesWindow : public Window {
|
|||||||
{
|
{
|
||||||
if (!this->IsWidgetLowered(WID_IC_NOTIFY)) return;
|
if (!this->IsWidgetLowered(WID_IC_NOTIFY)) return;
|
||||||
|
|
||||||
/* Only notify the smallmap window if it exists. In particular, do not
|
UpdateSmallMapSelectedIndustries();
|
||||||
* 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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -165,6 +165,32 @@ static bool _smallmap_industry_highlight_state;
|
|||||||
/** For connecting company ID to position in owner list (small map legend) */
|
/** For connecting company ID to position in owner list (small map legend) */
|
||||||
uint _company_to_list_pos[MAX_COMPANIES];
|
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.
|
* 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);
|
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. */
|
/** Vehicle colours in #SMT_VEHICLES mode. Indexed by #VehicleType. */
|
||||||
static const byte _vehicle_type_colours[6] = {
|
static const byte _vehicle_type_colours[6] = {
|
||||||
PC_RED, PC_YELLOW, PC_LIGHT_BLUE, PC_WHITE, PC_BLACK, PC_RED
|
PC_RED, PC_YELLOW, PC_LIGHT_BLUE, PC_WHITE, PC_BLACK, PC_RED
|
||||||
@@ -1571,12 +1586,7 @@ int SmallMapWindow::GetPositionOnLegend(Point pt)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 0: {
|
case 0: {
|
||||||
extern std::bitset<NUM_INDUSTRYTYPES> _displayed_industries;
|
|
||||||
if (this->map_type != SMT_INDUSTRY) this->SwitchMapType(SMT_INDUSTRY);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,6 +46,7 @@ struct TunnelBridgeToMap {
|
|||||||
};
|
};
|
||||||
typedef std::vector<TunnelBridgeToMap> TunnelBridgeToMapVector;
|
typedef std::vector<TunnelBridgeToMap> TunnelBridgeToMapVector;
|
||||||
|
|
||||||
|
void UpdateSmallMapSelectedIndustries();
|
||||||
void BuildIndustriesLegend();
|
void BuildIndustriesLegend();
|
||||||
void ShowSmallMap();
|
void ShowSmallMap();
|
||||||
void BuildLandLegend();
|
void BuildLandLegend();
|
||||||
|
Reference in New Issue
Block a user