Changeset - r28270:e1c58c0b0dd0
[Not reviewed]
master
0 1 0
Peter Nelson - 12 months ago 2023-12-09 20:55:10
peter1138@openttd.org
Codechange: Use return value of SetDisplayedPlane to simplify CompanyWindow.
1 file changed with 8 insertions and 38 deletions:
0 comments (0 inline, 0 general)
src/company_gui.cpp
Show inline comments
 
@@ -2259,54 +2259,24 @@ struct CompanyWindow : Window
 
			bool reinit = false;
 

	
 
			/* Button bar selection. */
 
			int plane = local ? 0 : SZSP_NONE;
 
			NWidgetStacked *wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_BUTTONS);
 
			if (plane != wi->shown_plane) {
 
				wi->SetDisplayedPlane(plane);
 
				this->InvalidateData();
 
				reinit = true;
 
			}
 
			reinit |= this->GetWidget<NWidgetStacked>(WID_C_SELECT_BUTTONS)->SetDisplayedPlane(local ? 0 : SZSP_NONE);
 

	
 
			/* Build HQ button handling. */
 
			plane = (local && c->location_of_HQ == INVALID_TILE) ? CWP_VB_BUILD : CWP_VB_VIEW;
 
			wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_VIEW_BUILD_HQ);
 
			if (plane != wi->shown_plane) {
 
				wi->SetDisplayedPlane(plane);
 
				reinit = true;
 
			}
 
			reinit |= this->GetWidget<NWidgetStacked>(WID_C_SELECT_VIEW_BUILD_HQ)->SetDisplayedPlane((local && c->location_of_HQ == INVALID_TILE) ? CWP_VB_BUILD : CWP_VB_VIEW);
 

	
 
			this->SetWidgetDisabledState(WID_C_VIEW_HQ, c->location_of_HQ == INVALID_TILE);
 

	
 
			/* Enable/disable 'Relocate HQ' button. */
 
			plane = (!local || c->location_of_HQ == INVALID_TILE) ? CWP_RELOCATE_HIDE : CWP_RELOCATE_SHOW;
 
			wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_RELOCATE);
 
			if (plane != wi->shown_plane) {
 
				wi->SetDisplayedPlane(plane);
 
				reinit = true;
 
			}
 
			reinit |= this->GetWidget<NWidgetStacked>(WID_C_SELECT_RELOCATE)->SetDisplayedPlane((!local || c->location_of_HQ == INVALID_TILE) ? CWP_RELOCATE_HIDE : CWP_RELOCATE_SHOW);
 
			/* Enable/disable 'Give money' button. */
 
			plane = ((local || _local_company == COMPANY_SPECTATOR || !_settings_game.economy.give_money) ? SZSP_NONE : 0);
 
			wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_GIVE_MONEY);
 
			if (plane != wi->shown_plane) {
 
				wi->SetDisplayedPlane(plane);
 
				reinit = true;
 
			}
 
			reinit |= this->GetWidget<NWidgetStacked>(WID_C_SELECT_GIVE_MONEY)->SetDisplayedPlane((local || _local_company == COMPANY_SPECTATOR || !_settings_game.economy.give_money) ? SZSP_NONE : 0);
 
			/* Enable/disable 'Hostile Takeover' button. */
 
			plane = ((local || _local_company == COMPANY_SPECTATOR || !c->is_ai || _networking) ? SZSP_NONE : 0);
 
			wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_HOSTILE_TAKEOVER);
 
			if (plane != wi->shown_plane) {
 
				wi->SetDisplayedPlane(plane);
 
				reinit = true;
 
			}
 
			reinit |= this->GetWidget<NWidgetStacked>(WID_C_SELECT_HOSTILE_TAKEOVER)->SetDisplayedPlane((local || _local_company == COMPANY_SPECTATOR || !c->is_ai || _networking) ? SZSP_NONE : 0);
 

	
 
			/* Multiplayer buttons. */
 
			plane = ((!_networking) ? (int)SZSP_NONE : (int)(local ? CWP_MP_C_PWD : CWP_MP_C_JOIN));
 
			wi = this->GetWidget<NWidgetStacked>(WID_C_SELECT_MULTIPLAYER);
 
			if (plane != wi->shown_plane) {
 
				wi->SetDisplayedPlane(plane);
 
				reinit = true;
 
			}
 
			this->SetWidgetDisabledState(WID_C_COMPANY_JOIN,   c->is_ai);
 
			reinit |= this->GetWidget<NWidgetStacked>(WID_C_SELECT_MULTIPLAYER)->SetDisplayedPlane((!_networking) ? (int)SZSP_NONE : (int)(local ? CWP_MP_C_PWD : CWP_MP_C_JOIN));
 

	
 
			this->SetWidgetDisabledState(WID_C_COMPANY_JOIN, c->is_ai);
 

	
 
			if (reinit) {
 
				this->ReInit();
0 comments (0 inline, 0 general)