Add: Show count of towns and industries in their directory window captions. (#12800)

These windows now show "(<visible> of <total>)" in the caption.
This commit is contained in:
Peter Nelson 2024-06-23 17:55:37 +01:00 committed by GitHub
parent 7116f143d5
commit e802c1a97f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 4 deletions

View File

@ -1233,7 +1233,7 @@ void ShowIndustryViewWindow(int industry)
static constexpr NWidgetPart _nested_industry_directory_widgets[] = { static constexpr NWidgetPart _nested_industry_directory_widgets[] = {
NWidget(NWID_HORIZONTAL), NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_INDUSTRY_DIRECTORY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), NWidget(WWT_CAPTION, COLOUR_BROWN, WID_ID_CAPTION), SetDataTip(STR_INDUSTRY_DIRECTORY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_BROWN), NWidget(WWT_SHADEBOX, COLOUR_BROWN),
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN), NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
NWidget(WWT_STICKYBOX, COLOUR_BROWN), NWidget(WWT_STICKYBOX, COLOUR_BROWN),
@ -1667,6 +1667,11 @@ public:
void SetStringParameters(WidgetID widget) const override void SetStringParameters(WidgetID widget) const override
{ {
switch (widget) { switch (widget) {
case WID_ID_CAPTION:
SetDParam(0, this->vscroll->GetCount());
SetDParam(1, Industry::GetNumItems());
break;
case WID_ID_DROPDOWN_CRITERIA: case WID_ID_DROPDOWN_CRITERIA:
SetDParam(0, IndustryDirectoryWindow::sorter_names[this->industries.SortType()]); SetDParam(0, IndustryDirectoryWindow::sorter_names[this->industries.SortType()]);
break; break;

View File

@ -3616,7 +3616,7 @@ STR_EDIT_SIGN_PREVIOUS_SIGN_TOOLTIP :{BLACK}Go to pr
STR_EDIT_SIGN_SIGN_OSKTITLE :{BLACK}Enter a name for the sign STR_EDIT_SIGN_SIGN_OSKTITLE :{BLACK}Enter a name for the sign
# Town directory window # Town directory window
STR_TOWN_DIRECTORY_CAPTION :{WHITE}Towns STR_TOWN_DIRECTORY_CAPTION :{WHITE}Towns ({COMMA} of {COMMA})
STR_TOWN_DIRECTORY_NONE :{ORANGE}- None - STR_TOWN_DIRECTORY_NONE :{ORANGE}- None -
STR_TOWN_DIRECTORY_TOWN :{ORANGE}{TOWN}{BLACK} ({COMMA}) STR_TOWN_DIRECTORY_TOWN :{ORANGE}{TOWN}{BLACK} ({COMMA})
STR_TOWN_DIRECTORY_CITY :{ORANGE}{TOWN}{YELLOW} (City){BLACK} ({COMMA}) STR_TOWN_DIRECTORY_CITY :{ORANGE}{TOWN}{YELLOW} (City){BLACK} ({COMMA})
@ -3950,7 +3950,7 @@ STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_YEAR :{WHITE}{CURRENC
STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_PERIOD :{WHITE}{CURRENCY_LONG}/period STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_PERIOD :{WHITE}{CURRENCY_LONG}/period
# Industry directory # Industry directory
STR_INDUSTRY_DIRECTORY_CAPTION :{WHITE}Industries STR_INDUSTRY_DIRECTORY_CAPTION :{WHITE}Industries ({COMMA} of {COMMA})
STR_INDUSTRY_DIRECTORY_NONE :{ORANGE}- None - STR_INDUSTRY_DIRECTORY_NONE :{ORANGE}- None -
STR_INDUSTRY_DIRECTORY_ITEM_INFO :{BLACK}{CARGO_LONG}{RAW_STRING}{YELLOW} ({COMMA}% transported){BLACK} STR_INDUSTRY_DIRECTORY_ITEM_INFO :{BLACK}{CARGO_LONG}{RAW_STRING}{YELLOW} ({COMMA}% transported){BLACK}
STR_INDUSTRY_DIRECTORY_ITEM_NOPROD :{ORANGE}{INDUSTRY} STR_INDUSTRY_DIRECTORY_ITEM_NOPROD :{ORANGE}{INDUSTRY}

View File

@ -686,7 +686,7 @@ void ShowTownViewWindow(TownID town)
static constexpr NWidgetPart _nested_town_directory_widgets[] = { static constexpr NWidgetPart _nested_town_directory_widgets[] = {
NWidget(NWID_HORIZONTAL), NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_BROWN), NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_TOWN_DIRECTORY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), NWidget(WWT_CAPTION, COLOUR_BROWN, WID_TD_CAPTION), SetDataTip(STR_TOWN_DIRECTORY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_BROWN), NWidget(WWT_SHADEBOX, COLOUR_BROWN),
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN), NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
NWidget(WWT_STICKYBOX, COLOUR_BROWN), NWidget(WWT_STICKYBOX, COLOUR_BROWN),
@ -819,6 +819,11 @@ public:
void SetStringParameters(WidgetID widget) const override void SetStringParameters(WidgetID widget) const override
{ {
switch (widget) { switch (widget) {
case WID_TD_CAPTION:
SetDParam(0, this->vscroll->GetCount());
SetDParam(1, Town::GetNumItems());
break;
case WID_TD_WORLD_POPULATION: case WID_TD_WORLD_POPULATION:
SetDParam(0, GetWorldPopulation()); SetDParam(0, GetWorldPopulation());
break; break;

View File

@ -33,6 +33,7 @@ enum IndustryViewWidgets : WidgetID {
/** Widgets of the #IndustryDirectoryWindow class. */ /** Widgets of the #IndustryDirectoryWindow class. */
enum IndustryDirectoryWidgets : WidgetID { enum IndustryDirectoryWidgets : WidgetID {
WID_ID_CAPTION, ///< Caption of the window.
WID_ID_DROPDOWN_ORDER, ///< Dropdown for the order of the sort. WID_ID_DROPDOWN_ORDER, ///< Dropdown for the order of the sort.
WID_ID_DROPDOWN_CRITERIA, ///< Dropdown for the criteria of the sort. WID_ID_DROPDOWN_CRITERIA, ///< Dropdown for the criteria of the sort.
WID_ID_FILTER_BY_ACC_CARGO, ///< Accepted cargo filter dropdown list. WID_ID_FILTER_BY_ACC_CARGO, ///< Accepted cargo filter dropdown list.

View File

@ -12,6 +12,7 @@
/** Widgets of the #TownDirectoryWindow class. */ /** Widgets of the #TownDirectoryWindow class. */
enum TownDirectoryWidgets : WidgetID { enum TownDirectoryWidgets : WidgetID {
WID_TD_CAPTION, ///< Caption of the window.
WID_TD_SORT_ORDER, ///< Direction of sort dropdown. WID_TD_SORT_ORDER, ///< Direction of sort dropdown.
WID_TD_SORT_CRITERIA, ///< Criteria of sort dropdown. WID_TD_SORT_CRITERIA, ///< Criteria of sort dropdown.
WID_TD_FILTER, ///< Filter of name. WID_TD_FILTER, ///< Filter of name.