|
@@ -63,119 +63,120 @@ static const NWidgetPart _nested_land_in
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY, LIW_CLOSE),
|
|
|
NWidget(WWT_CAPTION, COLOUR_GREY, LIW_CAPTION), SetDataTip(STR_LAND_AREA_INFORMATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
|
|
EndContainer(),
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, LIW_BACKGROUND), SetMinimalSize(300, 86), SetResize(0, 1), EndContainer(),
|
|
|
};
|
|
|
|
|
|
static const WindowDesc _land_info_desc(
|
|
|
WDP_AUTO, WDP_AUTO, 300, 100, 300, 100,
|
|
|
WC_LAND_INFO, WC_NONE,
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
|
|
|
_land_info_widgets, _nested_land_info_widgets, lengthof(_nested_land_info_widgets)
|
|
|
);
|
|
|
|
|
|
class LandInfoWindow : public Window {
|
|
|
enum {
|
|
|
LAND_INFO_CENTERED_LINES = 12, ///< Up to 12 centered lines
|
|
|
LAND_INFO_MULTICENTER_LINE = LAND_INFO_CENTERED_LINES, ///< One multicenter line
|
|
|
LAND_INFO_LINE_END,
|
|
|
|
|
|
LAND_INFO_LINE_BUFF_SIZE = 512,
|
|
|
};
|
|
|
|
|
|
public:
|
|
|
char landinfo_data[LAND_INFO_LINE_END][LAND_INFO_LINE_BUFF_SIZE];
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
{
|
|
|
this->DrawWidgets();
|
|
|
|
|
|
uint y = 21;
|
|
|
for (uint i = 0; i < LAND_INFO_CENTERED_LINES; i++) {
|
|
|
if (StrEmpty(this->landinfo_data[i])) break;
|
|
|
|
|
|
DrawString(this->widget[LIW_BACKGROUND].left + 2, this->widget[LIW_BACKGROUND].right - 2, y, this->landinfo_data[i], i == 0 ? TC_LIGHT_BLUE : TC_FROMSTRING, SA_CENTER);
|
|
|
y += i == 0 ? 16 : 12;
|
|
|
}
|
|
|
|
|
|
if (!StrEmpty(this->landinfo_data[LAND_INFO_MULTICENTER_LINE])) {
|
|
|
SetDParamStr(0, this->landinfo_data[LAND_INFO_MULTICENTER_LINE]);
|
|
|
DrawStringMultiLine(this->widget[LIW_BACKGROUND].left + 2, this->widget[LIW_BACKGROUND].right - 2, y, y + 22, STR_JUST_RAW_STRING, TC_FROMSTRING, SA_CENTER);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
|
|
|
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
|
|
|
|
|
|
/* Because build_date is not set yet in every TileDesc, we make sure it is empty */
|
|
|
TileDesc td;
|
|
|
AcceptedCargo ac;
|
|
|
|
|
|
td.build_date = INVALID_DATE;
|
|
|
|
|
|
/* Most tiles have only one owner, but
|
|
|
* - drivethrough roadstops can be build on town owned roads (up to 2 owners) and
|
|
|
* - roads can have up to four owners (railroad, road, tram, 3rd-roadtype "highway").
|
|
|
*/
|
|
|
td.owner_type[0] = STR_LAND_AREA_INFORMATION_OWNER; // At least one owner is displayed, though it might be "N/A".
|
|
|
td.owner_type[1] = STR_NULL; // STR_NULL results in skipping the owner
|
|
|
td.owner_type[2] = STR_NULL;
|
|
|
td.owner_type[3] = STR_NULL;
|
|
|
td.owner[0] = OWNER_NONE;
|
|
|
td.owner[1] = OWNER_NONE;
|
|
|
td.owner[2] = OWNER_NONE;
|
|
|
td.owner[3] = OWNER_NONE;
|
|
|
|
|
|
td.station_class = STR_NULL;
|
|
|
td.station_name = STR_NULL;
|
|
|
|
|
|
td.grf = NULL;
|
|
|
|
|
|
GetAcceptedCargo(tile, ac);
|
|
|
AcceptedCargo ac;
|
|
|
memset(ac, 0, sizeof(AcceptedCargo));
|
|
|
AddAcceptedCargo(tile, ac);
|
|
|
GetTileDesc(tile, &td);
|
|
|
|
|
|
uint line_nr = 0;
|
|
|
|
|
|
/* Tiletype */
|
|
|
SetDParam(0, td.dparam[0]);
|
|
|
GetString(this->landinfo_data[line_nr], td.str, lastof(this->landinfo_data[line_nr]));
|
|
|
line_nr++;
|
|
|
|
|
|
/* Up to four owners */
|
|
|
for (uint i = 0; i < 4; i++) {
|
|
|
if (td.owner_type[i] == STR_NULL) continue;
|
|
|
|
|
|
SetDParam(0, STR_LAND_AREA_INFORMATION_OWNER_N_A);
|
|
|
if (td.owner[i] != OWNER_NONE && td.owner[i] != OWNER_WATER) GetNameOfOwner(td.owner[i], tile);
|
|
|
GetString(this->landinfo_data[line_nr], td.owner_type[i], lastof(this->landinfo_data[line_nr]));
|
|
|
line_nr++;
|
|
|
}
|
|
|
|
|
|
/* Cost to clear/revenue when cleared */
|
|
|
StringID str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A;
|
|
|
Company *c = Company::GetIfValid(_local_company);
|
|
|
if (c != NULL) {
|
|
|
Money old_money = c->money;
|
|
|
c->money = INT64_MAX;
|
|
|
CommandCost costclear = DoCommand(tile, 0, 0, DC_NONE, CMD_LANDSCAPE_CLEAR);
|
|
|
c->money = old_money;
|
|
|
if (CmdSucceeded(costclear)) {
|
|
|
Money cost = costclear.GetCost();
|
|
|
if (cost < 0) {
|
|
|
cost = -cost; // Negate negative cost to a positive revenue
|
|
|
str = STR_REVENUE_WHEN_CLEARED;
|
|
|
} else {
|
|
|
str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR;
|
|
|
}
|
|
|
SetDParam(0, cost);
|
|
|
}
|
|
|
}
|
|
|
GetString(this->landinfo_data[line_nr], str, lastof(this->landinfo_data[line_nr]));
|
|
|
line_nr++;
|
|
|
|
|
|
/* Location */
|
|
|
char tmp[16];
|
|
|
snprintf(tmp, lengthof(tmp), "0x%.4X", tile);
|
|
|
SetDParam(0, TileX(tile));
|
|
|
SetDParam(1, TileY(tile));
|
|
|
SetDParam(2, TileHeight(tile));
|
|
|
SetDParamStr(3, tmp);
|