mirror of https://github.com/OpenTTD/OpenTTD.git
Add: When opening the company infrastructure window highlight in white all pieces of company owned infrastructure in the viewport
This commit is contained in:
parent
bb86023d50
commit
452f25a5dd
|
@ -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<ExpensesType> _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<CompanyInfrastructureWindow>(&_company_infrastructure_desc, company);
|
||||
_infrastructure_window_open = true;
|
||||
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 bool _infrastructure_window_open;
|
||||
|
||||
#endif /* COMPANY_GUI_H */
|
||||
|
|
|
@ -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,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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue