@ -47,7 +47,28 @@
# include "safeguards.h"
bool _ignore_restrictions ;
std : : bitset < NUM_INDUSTRYTYPES > _displayed_industries ; ///< Communication from the industry chain window to the smallmap window about what industries to display.
static std : : bitset < NUM_INDUSTRYTYPES > _displayed_industries ; ///< Communication from the industry chain window to the smallmap window about what industries to display.
static std : : bitset < NUM_INDUSTRYTYPES > _displayed_industries_in ;
static std : : bitset < NUM_INDUSTRYTYPES > _displayed_industries_out ;
enum IndustryLinkMode {
ILM_ALL ,
ILM_IN ,
ILM_OUT ,
} ;
static IndustryLinkMode _link_mode = ILM_ALL ;
const std : : bitset < NUM_INDUSTRYTYPES > & GetIndustryLinkDisplayIndustries ( )
{
switch ( _link_mode ) {
case ILM_IN :
return _displayed_industries_in ;
case ILM_OUT :
return _displayed_industries_out ;
default :
return _displayed_industries ;
}
}
/** Cargo suffix type (for which window is it requested) */
enum CargoSuffixType {
@ -1872,7 +1893,7 @@ static const NWidgetPart _nested_industry_cargoes_widgets[] = {
NWidget ( NWID_VERTICAL ) ,
NWidget ( WWT_PANEL , COLOUR_BROWN , WID_IC_PANEL ) , SetResize ( 1 , 10 ) , SetMinimalSize ( 200 , 90 ) , SetScrollbar ( WID_IC_SCROLLBAR ) , EndContainer ( ) ,
NWidget ( NWID_HORIZONTAL ) ,
NWidget ( WWT_TEXTBT N, COLOUR_BROWN , WID_IC_NOTIFY ) ,
NWidget ( NWID_BUTTON_DROPDOW N, COLOUR_BROWN , WID_IC_NOTIFY ) ,
SetDataTip ( STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP , STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP_TOOLTIP ) ,
NWidget ( WWT_PANEL , COLOUR_BROWN ) , SetFill ( 1 , 0 ) , SetResize ( 0 , 0 ) , EndContainer ( ) ,
NWidget ( WWT_DROPDOWN , COLOUR_BROWN , WID_IC_IND_DROPDOWN ) , SetFill ( 0 , 0 ) , SetResize ( 0 , 0 ) ,
@ -2760,7 +2781,11 @@ struct IndustryCargoesWindow : public Window {
this - > GetWidget < NWidgetCore > ( WID_IC_CAPTION ) - > widget_data = STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION ;
this - > ind_cargo = displayed_it ;
_displayed_industries . reset ( ) ;
_displayed_industries_in . reset ( ) ;
_displayed_industries_out . reset ( ) ;
_displayed_industries . set ( displayed_it ) ;
_displayed_industries_in . set ( displayed_it ) ;
_displayed_industries_out . set ( displayed_it ) ;
this - > fields . clear ( ) ;
CargoesRow & row = this - > fields . emplace_back ( ) ;
@ -2805,11 +2830,13 @@ struct IndustryCargoesWindow : public Window {
if ( HasCommonValidCargo ( central_sp - > accepts_cargo , lengthof ( central_sp - > accepts_cargo ) , indsp - > produced_cargo , lengthof ( indsp - > produced_cargo ) ) ) {
this - > PlaceIndustry ( 1 + supp_count * num_indrows / num_supp , 0 , it ) ;
_displayed_industries . set ( it ) ;
_displayed_industries_in . set ( it ) ;
supp_count + + ;
}
if ( HasCommonValidCargo ( central_sp - > produced_cargo , lengthof ( central_sp - > produced_cargo ) , indsp - > accepts_cargo , lengthof ( indsp - > accepts_cargo ) ) ) {
this - > PlaceIndustry ( 1 + cust_count * num_indrows / num_cust , 4 , it ) ;
_displayed_industries . set ( it ) ;
_displayed_industries_out . set ( it ) ;
cust_count + + ;
}
}
@ -2838,6 +2865,8 @@ struct IndustryCargoesWindow : public Window {
this - > GetWidget < NWidgetCore > ( WID_IC_CAPTION ) - > widget_data = STR_INDUSTRY_CARGOES_CARGO_CAPTION ;
this - > ind_cargo = cid + NUM_INDUSTRYTYPES ;
_displayed_industries . reset ( ) ;
_displayed_industries_in . reset ( ) ;
_displayed_industries_out . reset ( ) ;
this - > fields . clear ( ) ;
CargoesRow & row = this - > fields . emplace_back ( ) ;
@ -2873,11 +2902,13 @@ struct IndustryCargoesWindow : public Window {
if ( HasCommonValidCargo ( & cid , 1 , indsp - > produced_cargo , lengthof ( indsp - > produced_cargo ) ) ) {
this - > PlaceIndustry ( 1 + supp_count * num_indrows / num_supp , 0 , it ) ;
_displayed_industries . set ( it ) ;
_displayed_industries_in . set ( it ) ;
supp_count + + ;
}
if ( HasCommonValidCargo ( & cid , 1 , indsp - > accepts_cargo , lengthof ( indsp - > accepts_cargo ) ) ) {
this - > PlaceIndustry ( 1 + cust_count * num_indrows / num_cust , 2 , it ) ;
_displayed_industries . set ( it ) ;
_displayed_industries_out . set ( it ) ;
cust_count + + ;
}
}
@ -3040,13 +3071,28 @@ struct IndustryCargoesWindow : public Window {
}
case WID_IC_NOTIFY :
this - > ToggleWidgetLoweredState ( WID_IC_NOTIFY ) ;
this - > SetWidgetDirty ( WID_IC_NOTIFY ) ;
if ( _settings_client . sound . click_beep ) SndPlayFx ( SND_15_BEEP ) ;
if ( this - > IsWidgetLowered ( WID_IC_NOTIFY ) ) {
if ( FindWindowByClass ( WC_SMALLMAP ) = = nullptr ) ShowSmallMap ( ) ;
this - > NotifySmallmap ( ) ;
if ( this - > GetWidget < NWidgetLeaf > ( widget ) - > ButtonHit ( pt ) ) {
this - > ToggleWidgetLoweredState ( WID_IC_NOTIFY ) ;
this - > SetWidgetDirty ( WID_IC_NOTIFY ) ;
if ( _settings_client . sound . click_beep ) SndPlayFx ( SND_15_BEEP ) ;
if ( this - > IsWidgetLowered ( WID_IC_NOTIFY ) ) {
_link_mode = ILM_ALL ;
if ( FindWindowByClass ( WC_SMALLMAP ) = = nullptr ) ShowSmallMap ( ) ;
this - > NotifySmallmap ( ) ;
}
} else {
DropDownList list ;
auto add_item = [ & ] ( StringID string , int result ) {
std : : unique_ptr < DropDownListStringItem > item ( new DropDownListStringItem ( string , result , false ) ) ;
item - > SetColourFlags ( TC_FORCED ) ;
list . emplace_back ( std : : move ( item ) ) ;
} ;
add_item ( STR_INDUSTRY_CARGOES_NOTIFY_SMALLMAP_ALL , ILM_ALL ) ;
add_item ( STR_INDUSTRY_CARGOES_PRODUCERS , ILM_IN ) ;
add_item ( STR_INDUSTRY_CARGOES_CUSTOMERS , ILM_OUT ) ;
int selected = ( this - > IsWidgetLowered ( WID_IC_NOTIFY ) ) ? ( int ) _link_mode : - 1 ;
ShowDropDownList ( this , std : : move ( list ) , selected , WID_IC_NOTIFY , 0 , true ) ;
}
break ;
@ -3090,6 +3136,14 @@ struct IndustryCargoesWindow : public Window {
case WID_IC_IND_DROPDOWN :
this - > ComputeIndustryDisplay ( index ) ;
break ;
case WID_IC_NOTIFY :
_link_mode = ( IndustryLinkMode ) index ;
this - > LowerWidget ( WID_IC_NOTIFY ) ;
this - > SetWidgetDirty ( WID_IC_NOTIFY ) ;
if ( FindWindowByClass ( WC_SMALLMAP ) = = nullptr ) ShowSmallMap ( ) ;
this - > NotifySmallmap ( ) ;
break ;
}
}