From 452f25a5dd30589b115d9b2a97a978f373e3f0e0 Mon Sep 17 00:00:00 2001 From: Anthony Lazar Date: Fri, 23 Feb 2024 00:36:28 -0500 Subject: [PATCH 1/5] Add: When opening the company infrastructure window highlight in white all pieces of company owned infrastructure in the viewport --- src/company_gui.cpp | 14 ++++++++++++++ src/company_gui.h | 2 ++ src/viewport.cpp | 29 +++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/src/company_gui.cpp b/src/company_gui.cpp index f15e66ce7c..3c7aa4a67f 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -53,6 +53,7 @@ /** Company GUI constants. */ static void DoSelectCompanyManagerFace(Window *parent); static void ShowCompanyInfrastructure(CompanyID company); +bool _infrastructure_window_open = false; /** List of revenues. */ static const std::initializer_list _expenses_list_revenue = { @@ -1830,6 +1831,16 @@ struct CompanyInfrastructureWindow : Window RoadTypes roadtypes; ///< Valid roadtypes. uint total_width; ///< String width of the total cost line. + /** + * Hide the window and all its child windows, and mark them for a later deletion. + * Stop white highlight of company owned infrastructure + */ + void Close([[maybe_unused]] int data) override + { + _infrastructure_window_open = false; + MarkWholeScreenDirty(); + this->Window::Close(); + } CompanyInfrastructureWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) { @@ -2150,12 +2161,15 @@ static WindowDesc _company_infrastructure_desc(__FILE__, __LINE__, /** * Open the infrastructure window of a company. + * Signal to the viewport to highlight company owned infrastructure * @param company Company to show infrastructure of. */ static void ShowCompanyInfrastructure(CompanyID company) { if (!Company::IsValidID(company)) return; AllocateWindowDescFront(&_company_infrastructure_desc, company); + _infrastructure_window_open = true; + MarkWholeScreenDirty(); } static constexpr NWidgetPart _nested_company_widgets[] = { diff --git a/src/company_gui.h b/src/company_gui.h index f6149b05fb..d2633d74d3 100644 --- a/src/company_gui.h +++ b/src/company_gui.h @@ -26,4 +26,6 @@ void InvalidateCompanyWindows(const Company *c); void CloseCompanyWindows(CompanyID company); void DirtyCompanyInfrastructureWindows(CompanyID company); +extern bool _infrastructure_window_open; + #endif /* COMPANY_GUI_H */ diff --git a/src/viewport.cpp b/src/viewport.cpp index 0c40926e81..9cb465756e 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -90,6 +90,8 @@ #include "network/network_func.h" #include "framerate_type.h" #include "viewport_cmd.h" +#include "company_gui.h" +#include "road_map.h" #include #include @@ -1036,6 +1038,33 @@ static TileHighlightType GetTileHighlightType(TileIndex t) } } + if (_current_company < MAX_COMPANIES && _infrastructure_window_open) { + /* Edge case of company owned tramway on non-company owned tile */ + if (IsTileType(t, MP_ROAD) && !IsRoadDepot(t) && HasTileRoadType(t, RTT_TRAM)) { + if (IsRoadOwner(t, RTT_TRAM, _current_company)) { + return THT_WHITE; + } + } + + switch (GetTileType(t)) { + case MP_ROAD: + case MP_RAILWAY: + case MP_TUNNELBRIDGE: + case MP_WATER: + { + CommandCost ret = CheckTileOwnership(t); + if (!ret.Failed()) { + return THT_WHITE; + } + break; + } + default: + { + return THT_NONE; + break; + } + } + } return THT_NONE; } From 804557721c20f6351194fe6b99353fcb64a13afd Mon Sep 17 00:00:00 2001 From: Anthony Lazar Date: Fri, 23 Feb 2024 23:55:34 -0500 Subject: [PATCH 2/5] Codechange: Keep track of all open infrastructure windows in a vector highlight the infrastructure of the most recently opened company. Changed code style base on comments. --- src/company_gui.cpp | 13 ++++++++++--- src/company_gui.h | 2 +- src/viewport.cpp | 25 +++++++++++-------------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 3c7aa4a67f..f4e81740fb 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -53,7 +53,7 @@ /** Company GUI constants. */ static void DoSelectCompanyManagerFace(Window *parent); static void ShowCompanyInfrastructure(CompanyID company); -bool _infrastructure_window_open = false; +std::vector _viewport_infrastructure_window_order; /** List of revenues. */ static const std::initializer_list _expenses_list_revenue = { @@ -1831,13 +1831,20 @@ struct CompanyInfrastructureWindow : Window RoadTypes roadtypes; ///< Valid roadtypes. uint total_width; ///< String width of the total cost line. + /** * Hide the window and all its child windows, and mark them for a later deletion. * Stop white highlight of company owned infrastructure */ void Close([[maybe_unused]] int data) override { - _infrastructure_window_open = false; + auto to_remove_from_order = std::find(_viewport_infrastructure_window_order.begin(), _viewport_infrastructure_window_order.end(), (CompanyID)this->window_number); + + /* Cautious error checking */ + if (to_remove_from_order != _viewport_infrastructure_window_order.end()) { + _viewport_infrastructure_window_order.erase(to_remove_from_order); + } + MarkWholeScreenDirty(); this->Window::Close(); } @@ -2168,7 +2175,7 @@ static void ShowCompanyInfrastructure(CompanyID company) { if (!Company::IsValidID(company)) return; AllocateWindowDescFront(&_company_infrastructure_desc, company); - _infrastructure_window_open = true; + _viewport_infrastructure_window_order.push_back(company); MarkWholeScreenDirty(); } diff --git a/src/company_gui.h b/src/company_gui.h index d2633d74d3..c49e75607a 100644 --- a/src/company_gui.h +++ b/src/company_gui.h @@ -26,6 +26,6 @@ void InvalidateCompanyWindows(const Company *c); void CloseCompanyWindows(CompanyID company); void DirtyCompanyInfrastructureWindows(CompanyID company); -extern bool _infrastructure_window_open; +extern std::vector _viewport_infrastructure_window_order; #endif /* COMPANY_GUI_H */ diff --git a/src/viewport.cpp b/src/viewport.cpp index 9cb465756e..31cf35647d 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1038,31 +1038,28 @@ static TileHighlightType GetTileHighlightType(TileIndex t) } } - if (_current_company < MAX_COMPANIES && _infrastructure_window_open) { - /* Edge case of company owned tramway on non-company owned tile */ - if (IsTileType(t, MP_ROAD) && !IsRoadDepot(t) && HasTileRoadType(t, RTT_TRAM)) { - if (IsRoadOwner(t, RTT_TRAM, _current_company)) { - return THT_WHITE; - } - } - + /* Highlight infrastructure owned by the company with the most recently currently opened infrastructure window */ + if (!_viewport_infrastructure_window_order.empty()) { switch (GetTileType(t)) { case MP_ROAD: + /* Edge case of company owned tramway on non-company owned tile */ + if (IsTileType(t, MP_ROAD) && !IsRoadDepot(t) && HasTileRoadType(t, RTT_TRAM)) { + if (IsRoadOwner(t, RTT_TRAM, _viewport_infrastructure_window_order.back())) { + return THT_WHITE; + } + } + [[fallthrough]]; case MP_RAILWAY: case MP_TUNNELBRIDGE: case MP_WATER: - { - CommandCost ret = CheckTileOwnership(t); - if (!ret.Failed()) { + if (GetTileOwner(t) == _viewport_infrastructure_window_order.back()) { return THT_WHITE; } break; - } default: - { return THT_NONE; break; - } + } } return THT_NONE; From fb44f5a074c47e5b07b9d974da6356ea607052e4 Mon Sep 17 00:00:00 2001 From: Anthony Lazar Date: Sat, 24 Feb 2024 00:43:59 -0500 Subject: [PATCH 3/5] Fix: Bug where highlight would stay if you click multiple times on the open infrastructure button. Show owned road on level crossings --- src/company_gui.cpp | 9 +++++++++ src/viewport.cpp | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/company_gui.cpp b/src/company_gui.cpp index f4e81740fb..7909e5eb44 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -2175,6 +2175,15 @@ static void ShowCompanyInfrastructure(CompanyID company) { if (!Company::IsValidID(company)) return; AllocateWindowDescFront(&_company_infrastructure_desc, company); + + /* Check if already open then move up in the order */ + auto to_moveup_in_order = std::find(_viewport_infrastructure_window_order.begin(), _viewport_infrastructure_window_order.end(), company); + + /* Cautious error checking */ + if (to_moveup_in_order != _viewport_infrastructure_window_order.end()) { + _viewport_infrastructure_window_order.erase(to_moveup_in_order); + } + _viewport_infrastructure_window_order.push_back(company); MarkWholeScreenDirty(); } diff --git a/src/viewport.cpp b/src/viewport.cpp index 31cf35647d..0e3838944a 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1042,12 +1042,19 @@ static TileHighlightType GetTileHighlightType(TileIndex t) if (!_viewport_infrastructure_window_order.empty()) { switch (GetTileType(t)) { case MP_ROAD: - /* Edge case of company owned tramway on non-company owned tile */ - if (IsTileType(t, MP_ROAD) && !IsRoadDepot(t) && HasTileRoadType(t, RTT_TRAM)) { + /* Edge case of company owned tramway on non-company owned road/rail tile */ + if (!IsRoadDepot(t) && HasTileRoadType(t, RTT_TRAM)) { if (IsRoadOwner(t, RTT_TRAM, _viewport_infrastructure_window_order.back())) { return THT_WHITE; } } + + /* Edge case of company owned road on non-company owned rail tile */ + if (!IsRoadDepot(t) && HasTileRoadType(t, RTT_ROAD)) { + if (IsRoadOwner(t, RTT_ROAD, _viewport_infrastructure_window_order.back())) { + return THT_WHITE; + } + } [[fallthrough]]; case MP_RAILWAY: case MP_TUNNELBRIDGE: From 945561ada8809a621fc830962a5a5ff9b6dbc057 Mon Sep 17 00:00:00 2001 From: Anthony Lazar Date: Tue, 2 Apr 2024 20:08:41 -0400 Subject: [PATCH 4/5] Codechange: Added UI, simplified functionality --- src/company_gui.cpp | 43 ++++++++++++++++++++++-------------- src/company_gui.h | 2 +- src/lang/english.txt | 2 ++ src/lang/english_US.txt | 2 ++ src/viewport.cpp | 8 +++---- src/widgets/company_widget.h | 1 + 6 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 7909e5eb44..474d08c42d 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -53,7 +53,7 @@ /** Company GUI constants. */ static void DoSelectCompanyManagerFace(Window *parent); static void ShowCompanyInfrastructure(CompanyID company); -std::vector _viewport_infrastructure_window_order; +CompanyID _viewport_company_to_highlight_infrastructure = INVALID_OWNER; /** List of revenues. */ static const std::initializer_list _expenses_list_revenue = { @@ -1818,6 +1818,7 @@ static constexpr NWidgetPart _nested_company_infrastructure_widgets[] = { NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_TOTAL_DESC), SetFill(1, 0), NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_TOTAL), SetFill(0, 1), EndContainer(), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CI_HIGHLIGHT_INFRASTRUCTURE), SetFill(1, 0), SetDataTip(STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE, STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE_TOOLTIP), EndContainer(), EndContainer(), }; @@ -1838,14 +1839,11 @@ struct CompanyInfrastructureWindow : Window */ void Close([[maybe_unused]] int data) override { - auto to_remove_from_order = std::find(_viewport_infrastructure_window_order.begin(), _viewport_infrastructure_window_order.end(), (CompanyID)this->window_number); - /* Cautious error checking */ - if (to_remove_from_order != _viewport_infrastructure_window_order.end()) { - _viewport_infrastructure_window_order.erase(to_remove_from_order); + if(_viewport_company_to_highlight_infrastructure == (CompanyID)this->window_number){ + _viewport_company_to_highlight_infrastructure = INVALID_OWNER; + MarkWholeScreenDirty(); } - - MarkWholeScreenDirty(); this->Window::Close(); } @@ -2045,7 +2043,11 @@ struct CompanyInfrastructureWindow : Window TC_FROMSTRING, SA_RIGHT); } } - + void OnPaint() override + { + this->SetWidgetLoweredState(WID_CI_HIGHLIGHT_INFRASTRUCTURE, _viewport_company_to_highlight_infrastructure == (CompanyID)this->window_number); + this->DrawWidgets(); + } void DrawWidget(const Rect &r, WidgetID widget) const override { const Company *c = Company::Get((CompanyID)this->window_number); @@ -2144,6 +2146,22 @@ struct CompanyInfrastructureWindow : Window break; } } + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override + { + switch (widget) { + case WID_CI_HIGHLIGHT_INFRASTRUCTURE: + CompanyID window_company_id = (CompanyID)this->window_number; + if(_viewport_company_to_highlight_infrastructure != window_company_id) { + _viewport_company_to_highlight_infrastructure = window_company_id; + MarkWholeScreenDirty(); + } + else { + _viewport_company_to_highlight_infrastructure = INVALID_OWNER; + MarkWholeScreenDirty(); + } + break; + } + } /** * Some data on this window has become invalid. @@ -2176,15 +2194,6 @@ static void ShowCompanyInfrastructure(CompanyID company) if (!Company::IsValidID(company)) return; AllocateWindowDescFront(&_company_infrastructure_desc, company); - /* Check if already open then move up in the order */ - auto to_moveup_in_order = std::find(_viewport_infrastructure_window_order.begin(), _viewport_infrastructure_window_order.end(), company); - - /* Cautious error checking */ - if (to_moveup_in_order != _viewport_infrastructure_window_order.end()) { - _viewport_infrastructure_window_order.erase(to_moveup_in_order); - } - - _viewport_infrastructure_window_order.push_back(company); MarkWholeScreenDirty(); } diff --git a/src/company_gui.h b/src/company_gui.h index c49e75607a..94e59c5fb0 100644 --- a/src/company_gui.h +++ b/src/company_gui.h @@ -26,6 +26,6 @@ void InvalidateCompanyWindows(const Company *c); void CloseCompanyWindows(CompanyID company); void DirtyCompanyInfrastructureWindows(CompanyID company); -extern std::vector _viewport_infrastructure_window_order; + extern CompanyID _viewport_company_to_highlight_infrastructure; #endif /* COMPANY_GUI_H */ diff --git a/src/lang/english.txt b/src/lang/english.txt index e04b85a6da..6333bd43a2 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3933,6 +3933,8 @@ STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS :{WHITE}Station STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS :{WHITE}Airports STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_YEAR :{WHITE}{CURRENCY_LONG}/year STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_PERIOD :{WHITE}{CURRENCY_LONG}/period +STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE :{BLACK}Highlight infrastructure +STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE_TOOLTIP:{BLACK}Highlight all infrastructure tiles the company currently owns # Industry directory STR_INDUSTRY_DIRECTORY_CAPTION :{WHITE}Industries diff --git a/src/lang/english_US.txt b/src/lang/english_US.txt index 73fac4bfc2..9d314d0e20 100644 --- a/src/lang/english_US.txt +++ b/src/lang/english_US.txt @@ -3930,6 +3930,8 @@ STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS :{WHITE}Station STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS :{WHITE}Airports STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_YEAR :{WHITE}{CURRENCY_LONG}/year STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_PERIOD :{WHITE}{CURRENCY_LONG}/period +STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE :{BLACK}Highlight infrastructure +STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE_TOOLTIP:{BLACK}Highlight all infrastructure tiles the company currently owns # Industry directory STR_INDUSTRY_DIRECTORY_CAPTION :{WHITE}Industries diff --git a/src/viewport.cpp b/src/viewport.cpp index 0e3838944a..bd5d266666 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1039,19 +1039,19 @@ static TileHighlightType GetTileHighlightType(TileIndex t) } /* Highlight infrastructure owned by the company with the most recently currently opened infrastructure window */ - if (!_viewport_infrastructure_window_order.empty()) { + if (_viewport_company_to_highlight_infrastructure != INVALID_OWNER) { switch (GetTileType(t)) { case MP_ROAD: /* Edge case of company owned tramway on non-company owned road/rail tile */ if (!IsRoadDepot(t) && HasTileRoadType(t, RTT_TRAM)) { - if (IsRoadOwner(t, RTT_TRAM, _viewport_infrastructure_window_order.back())) { + if (IsRoadOwner(t, RTT_TRAM, _viewport_company_to_highlight_infrastructure)) { return THT_WHITE; } } /* Edge case of company owned road on non-company owned rail tile */ if (!IsRoadDepot(t) && HasTileRoadType(t, RTT_ROAD)) { - if (IsRoadOwner(t, RTT_ROAD, _viewport_infrastructure_window_order.back())) { + if (IsRoadOwner(t, RTT_ROAD, _viewport_company_to_highlight_infrastructure)){ return THT_WHITE; } } @@ -1059,7 +1059,7 @@ static TileHighlightType GetTileHighlightType(TileIndex t) case MP_RAILWAY: case MP_TUNNELBRIDGE: case MP_WATER: - if (GetTileOwner(t) == _viewport_infrastructure_window_order.back()) { + if (GetTileOwner(t) == _viewport_company_to_highlight_infrastructure) { return THT_WHITE; } break; diff --git a/src/widgets/company_widget.h b/src/widgets/company_widget.h index f53f83a494..9c92d53429 100644 --- a/src/widgets/company_widget.h +++ b/src/widgets/company_widget.h @@ -184,6 +184,7 @@ enum CompanyInfrastructureWidgets : WidgetID { WID_CI_STATION_COUNT, ///< Count of station. WID_CI_TOTAL_DESC, ///< Description of total. WID_CI_TOTAL, ///< Count of total. + WID_CI_HIGHLIGHT_INFRASTRUCTURE, }; /** Widgets of the #BuyCompanyWindow class. */ From 7530529653949a6f1888b162ed852137a8987799 Mon Sep 17 00:00:00 2001 From: Anthony Lazar Date: Mon, 1 Jul 2024 00:34:03 -0400 Subject: [PATCH 5/5] Codechange: Added Comments, fixed code style, added highlights to HQ and owned lands (MP_objects) and Airports and stations (MP_stations) --- src/company_gui.cpp | 36 ++++++++++++++++++------------------ src/lang/english.txt | 2 +- src/lang/english_US.txt | 2 -- src/viewport.cpp | 4 +++- src/widgets/company_widget.h | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 474d08c42d..6680c3a0b5 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -1818,8 +1818,8 @@ static constexpr NWidgetPart _nested_company_infrastructure_widgets[] = { NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_TOTAL_DESC), SetFill(1, 0), NWidget(WWT_EMPTY, COLOUR_GREY, WID_CI_TOTAL), SetFill(0, 1), EndContainer(), - NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CI_HIGHLIGHT_INFRASTRUCTURE), SetFill(1, 0), SetDataTip(STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE, STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE_TOOLTIP), EndContainer(), + NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CI_HIGHLIGHT_INFRASTRUCTURE), SetFill(1, 0), SetDataTip(STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE, STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE_TOOLTIP), EndContainer(), }; @@ -1839,8 +1839,8 @@ struct CompanyInfrastructureWindow : Window */ void Close([[maybe_unused]] int data) override { - - if(_viewport_company_to_highlight_infrastructure == (CompanyID)this->window_number){ + /* Clear highlights if the infrastructure window is closed */ + if (_viewport_company_to_highlight_infrastructure == (CompanyID)this->window_number) { _viewport_company_to_highlight_infrastructure = INVALID_OWNER; MarkWholeScreenDirty(); } @@ -2043,11 +2043,13 @@ struct CompanyInfrastructureWindow : Window TC_FROMSTRING, SA_RIGHT); } } + void OnPaint() override { this->SetWidgetLoweredState(WID_CI_HIGHLIGHT_INFRASTRUCTURE, _viewport_company_to_highlight_infrastructure == (CompanyID)this->window_number); this->DrawWidgets(); } + void DrawWidget(const Rect &r, WidgetID widget) const override { const Company *c = Company::Get((CompanyID)this->window_number); @@ -2146,20 +2148,21 @@ struct CompanyInfrastructureWindow : Window break; } } + void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override { - switch (widget) { - case WID_CI_HIGHLIGHT_INFRASTRUCTURE: - CompanyID window_company_id = (CompanyID)this->window_number; - if(_viewport_company_to_highlight_infrastructure != window_company_id) { - _viewport_company_to_highlight_infrastructure = window_company_id; - MarkWholeScreenDirty(); - } - else { - _viewport_company_to_highlight_infrastructure = INVALID_OWNER; - MarkWholeScreenDirty(); - } - break; + if (widget != WID_CI_HIGHLIGHT_INFRASTRUCTURE) return; + + /* Toggle between highlight and clear */ + CompanyID window_company_id = (CompanyID)this->window_number; + if(_viewport_company_to_highlight_infrastructure != window_company_id) { + /* highlight tiles of this company */ + _viewport_company_to_highlight_infrastructure = window_company_id; + MarkWholeScreenDirty(); + } else { + /* Clear tile highlights */ + _viewport_company_to_highlight_infrastructure = INVALID_OWNER; + MarkWholeScreenDirty(); } } @@ -2186,15 +2189,12 @@ static WindowDesc _company_infrastructure_desc(__FILE__, __LINE__, /** * Open the infrastructure window of a company. - * Signal to the viewport to highlight company owned infrastructure * @param company Company to show infrastructure of. */ static void ShowCompanyInfrastructure(CompanyID company) { if (!Company::IsValidID(company)) return; AllocateWindowDescFront(&_company_infrastructure_desc, company); - - MarkWholeScreenDirty(); } static constexpr NWidgetPart _nested_company_widgets[] = { diff --git a/src/lang/english.txt b/src/lang/english.txt index 6333bd43a2..8ff92f7f97 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -3934,7 +3934,7 @@ STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS :{WHITE}Airports STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_YEAR :{WHITE}{CURRENCY_LONG}/year STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_PERIOD :{WHITE}{CURRENCY_LONG}/period STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE :{BLACK}Highlight infrastructure -STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE_TOOLTIP:{BLACK}Highlight all infrastructure tiles the company currently owns +STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE_TOOLTIP:{BLACK}Highlight all infrastructure tiles owned by this company # Industry directory STR_INDUSTRY_DIRECTORY_CAPTION :{WHITE}Industries diff --git a/src/lang/english_US.txt b/src/lang/english_US.txt index 9d314d0e20..73fac4bfc2 100644 --- a/src/lang/english_US.txt +++ b/src/lang/english_US.txt @@ -3930,8 +3930,6 @@ STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS :{WHITE}Station STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS :{WHITE}Airports STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_YEAR :{WHITE}{CURRENCY_LONG}/year STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_PERIOD :{WHITE}{CURRENCY_LONG}/period -STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE :{BLACK}Highlight infrastructure -STR_COMPANY_INFRASTRUCTURE_VIEW_HIGHLIGHT_INFRASTRUCTURE_TOOLTIP:{BLACK}Highlight all infrastructure tiles the company currently owns # Industry directory STR_INDUSTRY_DIRECTORY_CAPTION :{WHITE}Industries diff --git a/src/viewport.cpp b/src/viewport.cpp index bd5d266666..01d4bcdfa5 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1038,7 +1038,7 @@ static TileHighlightType GetTileHighlightType(TileIndex t) } } - /* Highlight infrastructure owned by the company with the most recently currently opened infrastructure window */ + /* Highlight infrastructure of selected company */ if (_viewport_company_to_highlight_infrastructure != INVALID_OWNER) { switch (GetTileType(t)) { case MP_ROAD: @@ -1059,6 +1059,8 @@ static TileHighlightType GetTileHighlightType(TileIndex t) case MP_RAILWAY: case MP_TUNNELBRIDGE: case MP_WATER: + case MP_STATION: + case MP_OBJECT: if (GetTileOwner(t) == _viewport_company_to_highlight_infrastructure) { return THT_WHITE; } diff --git a/src/widgets/company_widget.h b/src/widgets/company_widget.h index 9c92d53429..faed62f06c 100644 --- a/src/widgets/company_widget.h +++ b/src/widgets/company_widget.h @@ -184,7 +184,7 @@ enum CompanyInfrastructureWidgets : WidgetID { WID_CI_STATION_COUNT, ///< Count of station. WID_CI_TOTAL_DESC, ///< Description of total. WID_CI_TOTAL, ///< Count of total. - WID_CI_HIGHLIGHT_INFRASTRUCTURE, + WID_CI_HIGHLIGHT_INFRASTRUCTURE, ///< Button to highlight infrastructure of this company. }; /** Widgets of the #BuyCompanyWindow class. */