mirror of https://github.com/OpenTTD/OpenTTD.git
Merge 945561ada8
into ac6a945e26
This commit is contained in:
commit
cac9307818
|
@ -55,6 +55,7 @@
|
|||
/** Company GUI constants. */
|
||||
static void DoSelectCompanyManagerFace(Window *parent);
|
||||
static void ShowCompanyInfrastructure(CompanyID company);
|
||||
CompanyID _viewport_company_to_highlight_infrastructure = INVALID_OWNER;
|
||||
|
||||
/** List of revenues. */
|
||||
static const std::initializer_list<ExpensesType> _expenses_list_revenue = {
|
||||
|
@ -1757,6 +1758,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(),
|
||||
};
|
||||
|
@ -1771,6 +1773,20 @@ struct CompanyInfrastructureWindow : Window
|
|||
|
||||
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
|
||||
{
|
||||
|
||||
if(_viewport_company_to_highlight_infrastructure == (CompanyID)this->window_number){
|
||||
_viewport_company_to_highlight_infrastructure = INVALID_OWNER;
|
||||
MarkWholeScreenDirty();
|
||||
}
|
||||
this->Window::Close();
|
||||
}
|
||||
|
||||
CompanyInfrastructureWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
|
||||
{
|
||||
this->UpdateRailRoadTypes();
|
||||
|
@ -1967,7 +1983,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);
|
||||
|
@ -2066,6 +2086,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.
|
||||
|
@ -2090,12 +2126,15 @@ static WindowDesc _company_infrastructure_desc(
|
|||
|
||||
/**
|
||||
* 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<CompanyInfrastructureWindow>(&_company_infrastructure_desc, company);
|
||||
|
||||
MarkWholeScreenDirty();
|
||||
}
|
||||
|
||||
static constexpr NWidgetPart _nested_company_widgets[] = {
|
||||
|
|
|
@ -26,4 +26,6 @@ void InvalidateCompanyWindows(const Company *c);
|
|||
void CloseCompanyWindows(CompanyID company);
|
||||
void DirtyCompanyInfrastructureWindows(CompanyID company);
|
||||
|
||||
extern CompanyID _viewport_company_to_highlight_infrastructure;
|
||||
|
||||
#endif /* COMPANY_GUI_H */
|
||||
|
|
|
@ -3943,6 +3943,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
|
||||
|
|
|
@ -3943,6 +3943,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
|
||||
|
|
|
@ -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 <forward_list>
|
||||
#include <stack>
|
||||
|
@ -1036,6 +1038,37 @@ static TileHighlightType GetTileHighlightType(TileIndex t)
|
|||
}
|
||||
}
|
||||
|
||||
/* Highlight infrastructure owned by the company with the most recently currently opened infrastructure window */
|
||||
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_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_company_to_highlight_infrastructure)){
|
||||
return THT_WHITE;
|
||||
}
|
||||
}
|
||||
[[fallthrough]];
|
||||
case MP_RAILWAY:
|
||||
case MP_TUNNELBRIDGE:
|
||||
case MP_WATER:
|
||||
if (GetTileOwner(t) == _viewport_company_to_highlight_infrastructure) {
|
||||
return THT_WHITE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return THT_NONE;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
return THT_NONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -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. */
|
||||
|
|
Loading…
Reference in New Issue