diff --git a/src/lang/english.txt b/src/lang/english.txt index a7df078368..89a5d9d3d5 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -4086,6 +4086,8 @@ STR_PLANS_ADD_LINES :{BLACK}Add line STR_PLANS_ADDING_LINES :{BLACK}Adding... STR_PLANS_HIDE_ALL :{BLACK}Hide all STR_PLANS_HIDE_ALL_TOOLTIP :{BLACK}Set the visibility of all the plans and all their lines to false +STR_PLANS_SHOW_ALL :{BLACK}Show all +STR_PLANS_SHOW_ALL_TOOLTIP :{BLACK}Set the visibility of all the plans and all their lines to true STR_PLANS_VISIBILITY_PRIVATE :{BLACK}Make private STR_PLANS_VISIBILITY_PUBLIC :{BLACK}Make public STR_PLANS_VISIBILITY_TOOLTIP :{BLACK}Toggle the visibility of a plan (private is yellow, public is blue). A public plan will be displayed in the plan window of the other companies but only its owner can add lines to it. diff --git a/src/plans_gui.cpp b/src/plans_gui.cpp index 5d504fb409..d079a605a0 100644 --- a/src/plans_gui.cpp +++ b/src/plans_gui.cpp @@ -51,7 +51,10 @@ static const NWidgetPart _nested_plans_widgets[] = { NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PLN_NEW), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_NEW_PLAN, STR_NULL), NWidget(WWT_TEXTBTN_2, COLOUR_GREY, WID_PLN_ADD_LINES), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_ADD_LINES, STR_PLANS_ADDING_LINES), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_PLN_VISIBILITY), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_VISIBILITY_PUBLIC, STR_PLANS_VISIBILITY_TOOLTIP), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PLN_HIDE_ALL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_HIDE_ALL, STR_NULL), + NWidget(NWID_SELECTION, INVALID_COLOUR, WID_PLN_HIDE_ALL_SEL), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PLN_HIDE_ALL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_HIDE_ALL, STR_PLANS_HIDE_ALL_TOOLTIP), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PLN_SHOW_ALL), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_SHOW_ALL, STR_PLANS_SHOW_ALL_TOOLTIP), + EndContainer(), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PLN_DELETE), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_PLANS_DELETE, STR_PLANS_DELETE_TOOLTIP), NWidget(WWT_RESIZEBOX, COLOUR_GREY), EndContainer(), @@ -73,6 +76,7 @@ struct PlansWindow : Window { } ListItem; Scrollbar *vscroll; + NWidgetStacked *hide_all_sel; std::vector list; ///< The translation table linking panel indices to their related PlanID. int selected; ///< What item is currently selected in the panel. uint vis_btn_left; ///< left offset of visibility button @@ -82,6 +86,8 @@ struct PlansWindow : Window { { this->CreateNestedTree(); this->vscroll = this->GetScrollbar(WID_PLN_SCROLLBAR); + this->hide_all_sel = this->GetWidget(WID_PLN_HIDE_ALL_SEL); + this->hide_all_sel->SetDisplayedPlane(0); this->FinishInitNested(); this->selected = INT_MAX; @@ -120,6 +126,14 @@ struct PlansWindow : Window { this->SetWidgetDirty(WID_PLN_LIST); break; } + case WID_PLN_SHOW_ALL: { + Plan *p; + FOR_ALL_PLANS(p) { + if (p->IsListable()) p->SetVisibility(true); + } + this->SetWidgetDirty(WID_PLN_LIST); + break; + } case WID_PLN_VISIBILITY: if (_current_plan) _current_plan->ToggleVisibilityByAll(); break; @@ -161,9 +175,20 @@ struct PlansWindow : Window { } } + bool AllPlansHidden() const + { + Plan *p; + FOR_ALL_PLANS(p) { + if (p->IsVisible()) return false; + } + return true; + } + virtual void OnPaint() { this->SetWidgetDisabledState(WID_PLN_HIDE_ALL, this->vscroll->GetCount() == 0); + this->SetWidgetDisabledState(WID_PLN_SHOW_ALL, this->vscroll->GetCount() == 0); + this->hide_all_sel->SetDisplayedPlane(this->vscroll->GetCount() != 0 && this->AllPlansHidden() ? 1 : 0); if (_current_plan) { this->SetWidgetsDisabledState(_current_plan->owner != _local_company, WID_PLN_ADD_LINES, WID_PLN_VISIBILITY, WID_PLN_DELETE, WIDGET_LIST_END); this->GetWidget(WID_PLN_VISIBILITY)->widget_data = _current_plan->visible_by_all ? STR_PLANS_VISIBILITY_PRIVATE : STR_PLANS_VISIBILITY_PUBLIC; diff --git a/src/widgets/plans_widget.h b/src/widgets/plans_widget.h index 938ac34649..430abbcbac 100644 --- a/src/widgets/plans_widget.h +++ b/src/widgets/plans_widget.h @@ -21,7 +21,9 @@ enum PlansWidgets { WID_PLN_ADD_LINES, WID_PLN_VISIBILITY, WID_PLN_HIDE_ALL, + WID_PLN_SHOW_ALL, WID_PLN_DELETE, + WID_PLN_HIDE_ALL_SEL, }; #endif /* WIDGETS_PLANS_WIDGET_H */