2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file town_gui.cpp GUI for towns. */
|
2007-04-04 03:21:14 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "town.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "viewport_func.h"
|
2011-12-10 13:54:10 +00:00
|
|
|
#include "error.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "gui.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_func.h"
|
|
|
|
#include "company_base.h"
|
|
|
|
#include "company_gui.h"
|
2007-01-02 17:34:03 +00:00
|
|
|
#include "network/network.h"
|
2011-04-30 14:24:23 +00:00
|
|
|
#include "string_func.h"
|
2007-12-21 19:49:27 +00:00
|
|
|
#include "strings_func.h"
|
2008-03-23 07:35:29 +00:00
|
|
|
#include "sound_func.h"
|
2008-05-07 13:10:15 +00:00
|
|
|
#include "tilehighlight_func.h"
|
2008-05-27 20:05:36 +00:00
|
|
|
#include "sortlist_type.h"
|
2008-10-25 13:51:47 +00:00
|
|
|
#include "road_cmd.h"
|
2009-02-23 20:03:38 +00:00
|
|
|
#include "landscape.h"
|
2009-09-22 13:54:54 +00:00
|
|
|
#include "querystring_gui.h"
|
|
|
|
#include "window_func.h"
|
|
|
|
#include "townname_func.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "core/geometry_func.hpp"
|
2010-07-19 17:17:36 +00:00
|
|
|
#include "genworld.h"
|
2019-07-22 19:27:39 +00:00
|
|
|
#include "stringfilter_type.h"
|
2013-03-17 15:41:40 +00:00
|
|
|
#include "widgets/dropdown_func.h"
|
2019-01-05 13:22:07 +00:00
|
|
|
#include "town_kdtree.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2011-12-15 22:22:55 +00:00
|
|
|
#include "widgets/town_widget.h"
|
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
|
|
|
|
2014-04-23 20:13:33 +00:00
|
|
|
#include "safeguards.h"
|
|
|
|
|
2019-01-05 13:22:07 +00:00
|
|
|
TownKdtree _town_local_authority_kdtree(&Kdtree_TownXYFunc);
|
|
|
|
|
2008-05-27 20:05:36 +00:00
|
|
|
typedef GUIList<const Town*> GUITownList;
|
|
|
|
|
2009-04-12 19:30:47 +00:00
|
|
|
static const NWidgetPart _nested_town_authority_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_TA_CAPTION), SetDataTip(STR_LOCAL_AUTHORITY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2019-01-05 13:22:07 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_TA_ZONE_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_LOCAL_AUTHORITY_ZONE, STR_LOCAL_AUTHORITY_ZONE_TOOLTIP),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
2013-05-26 19:30:07 +00:00
|
|
|
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
|
2009-12-09 17:10:57 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TA_RATING_INFO), SetMinimalSize(317, 92), SetResize(1, 1), EndContainer(),
|
2009-04-12 19:30:47 +00:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TA_COMMAND_LIST), SetMinimalSize(305, 52), SetResize(1, 0), SetDataTip(0x0, STR_LOCAL_AUTHORITY_ACTIONS_TOOLTIP), SetScrollbar(WID_TA_SCROLLBAR), EndContainer(),
|
|
|
|
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_TA_SCROLLBAR),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TA_ACTION_INFO), SetMinimalSize(317, 52), SetResize(1, 0), EndContainer(),
|
2009-11-23 14:04:03 +00:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TA_EXECUTE), SetMinimalSize(317, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_LOCAL_AUTHORITY_DO_IT_BUTTON, STR_LOCAL_AUTHORITY_DO_IT_TOOLTIP),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
|
2009-11-23 14:04:03 +00:00
|
|
|
EndContainer()
|
2009-04-12 19:30:47 +00:00
|
|
|
};
|
|
|
|
|
2009-09-20 10:25:03 +00:00
|
|
|
/** Town authority window. */
|
2008-05-15 22:47:03 +00:00
|
|
|
struct TownAuthorityWindow : Window {
|
2008-05-22 02:03:05 +00:00
|
|
|
private:
|
2009-09-20 10:25:03 +00:00
|
|
|
Town *town; ///< Town being displayed.
|
|
|
|
int sel_index; ///< Currently selected town action, \c 0 to \c TACT_COUNT-1, \c -1 means no action selected.
|
2010-08-12 08:37:01 +00:00
|
|
|
Scrollbar *vscroll;
|
2011-04-09 21:15:24 +00:00
|
|
|
uint displayed_actions_on_previous_painting; ///< Actions that were available on the previous call to OnPaint()
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2008-07-09 02:18:51 +00:00
|
|
|
/**
|
|
|
|
* Get the position of the Nth set bit.
|
|
|
|
*
|
|
|
|
* If there is no Nth bit set return -1
|
|
|
|
*
|
|
|
|
* @param bits The value to search in
|
|
|
|
* @param n The Nth set bit from which we want to know the position
|
|
|
|
* @return The position of the Nth set bit
|
|
|
|
*/
|
|
|
|
static int GetNthSetBit(uint32 bits, int n)
|
|
|
|
{
|
|
|
|
if (n >= 0) {
|
|
|
|
uint i;
|
|
|
|
FOR_EACH_SET_BIT(i, bits) {
|
|
|
|
n--;
|
|
|
|
if (n < 0) return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-05-22 02:03:05 +00:00
|
|
|
public:
|
2013-05-26 19:23:42 +00:00
|
|
|
TownAuthorityWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), sel_index(-1), displayed_actions_on_previous_painting(0)
|
2008-05-15 22:47:03 +00:00
|
|
|
{
|
2009-09-20 14:46:15 +00:00
|
|
|
this->town = Town::Get(window_number);
|
2013-05-26 19:23:42 +00:00
|
|
|
this->InitNested(window_number);
|
2011-12-16 17:23:41 +00:00
|
|
|
this->vscroll = this->GetScrollbar(WID_TA_SCROLLBAR);
|
|
|
|
this->vscroll->SetCapacity((this->GetWidget<NWidgetBase>(WID_TA_COMMAND_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / FONT_HEIGHT_NORMAL);
|
2008-05-15 22:47:03 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnPaint() override
|
2008-05-15 22:47:03 +00:00
|
|
|
{
|
|
|
|
int numact;
|
2008-09-30 20:39:50 +00:00
|
|
|
uint buttons = GetMaskOfTownActions(&numact, _local_company, this->town);
|
2011-04-09 21:15:24 +00:00
|
|
|
if (buttons != displayed_actions_on_previous_painting) this->SetDirty();
|
|
|
|
displayed_actions_on_previous_painting = buttons;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2010-08-12 08:37:01 +00:00
|
|
|
this->vscroll->SetCount(numact + 1);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-15 22:47:03 +00:00
|
|
|
if (this->sel_index != -1 && !HasBit(buttons, this->sel_index)) {
|
|
|
|
this->sel_index = -1;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2019-01-05 13:22:07 +00:00
|
|
|
this->SetWidgetLoweredState(WID_TA_ZONE_BUTTON, this->town->show_zone);
|
2011-12-16 17:23:41 +00:00
|
|
|
this->SetWidgetDisabledState(WID_TA_EXECUTE, this->sel_index == -1);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-17 12:48:06 +00:00
|
|
|
this->DrawWidgets();
|
2009-12-21 16:24:29 +00:00
|
|
|
if (!this->IsShaded()) this->DrawRatings();
|
2009-09-20 14:46:15 +00:00
|
|
|
}
|
2008-04-14 17:06:36 +00:00
|
|
|
|
2009-09-20 14:46:15 +00:00
|
|
|
/** Draw the contents of the ratings panel. May request a resize of the window if the contents does not fit. */
|
|
|
|
void DrawRatings()
|
|
|
|
{
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_TA_RATING_INFO);
|
2009-11-19 10:56:14 +00:00
|
|
|
uint left = nwid->pos_x + WD_FRAMERECT_LEFT;
|
|
|
|
uint right = nwid->pos_x + nwid->current_x - 1 - WD_FRAMERECT_RIGHT;
|
2009-09-20 14:46:15 +00:00
|
|
|
|
|
|
|
uint y = nwid->pos_y + WD_FRAMERECT_TOP;
|
2008-04-14 17:06:36 +00:00
|
|
|
|
2009-11-19 10:56:14 +00:00
|
|
|
DrawString(left, right, y, STR_LOCAL_AUTHORITY_COMPANY_RATINGS);
|
2009-09-20 10:25:03 +00:00
|
|
|
y += FONT_HEIGHT_NORMAL;
|
2008-05-15 22:47:03 +00:00
|
|
|
|
2010-09-02 19:34:44 +00:00
|
|
|
Dimension icon_size = GetSpriteSize(SPR_COMPANY_ICON);
|
|
|
|
int icon_width = icon_size.width;
|
|
|
|
int icon_y_offset = (FONT_HEIGHT_NORMAL - icon_size.height) / 2;
|
|
|
|
|
2010-09-02 20:00:48 +00:00
|
|
|
Dimension exclusive_size = GetSpriteSize(SPR_EXCLUSIVE_TRANSPORT);
|
2010-09-02 19:34:44 +00:00
|
|
|
int exclusive_width = exclusive_size.width;
|
2010-09-02 20:00:48 +00:00
|
|
|
int exclusive_y_offset = (FONT_HEIGHT_NORMAL - exclusive_size.height) / 2;
|
2010-09-02 19:34:44 +00:00
|
|
|
|
2010-11-13 09:56:25 +00:00
|
|
|
bool rtl = _current_text_dir == TD_RTL;
|
2010-09-02 19:34:44 +00:00
|
|
|
uint text_left = left + (rtl ? 0 : icon_width + exclusive_width + 4);
|
|
|
|
uint text_right = right - (rtl ? icon_width + exclusive_width + 4 : 0);
|
|
|
|
uint icon_left = rtl ? right - icon_width : left;
|
2010-05-23 15:17:05 +00:00
|
|
|
uint exclusive_left = rtl ? right - icon_width - exclusive_width - 2 : left + icon_width + 2;
|
2009-11-19 10:56:14 +00:00
|
|
|
|
2009-01-15 12:36:24 +00:00
|
|
|
/* Draw list of companies */
|
2008-09-30 20:39:50 +00:00
|
|
|
const Company *c;
|
|
|
|
FOR_ALL_COMPANIES(c) {
|
|
|
|
if ((HasBit(this->town->have_ratings, c->index) || this->town->exclusivity == c->index)) {
|
2010-09-02 19:34:44 +00:00
|
|
|
DrawCompanyIcon(c->index, icon_left, y + icon_y_offset);
|
2008-05-15 22:47:03 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
SetDParam(0, c->index);
|
|
|
|
SetDParam(1, c->index);
|
2008-05-15 22:47:03 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
int r = this->town->ratings[c->index];
|
2019-03-12 17:08:13 +00:00
|
|
|
StringID str = STR_CARGO_RATING_APPALLING;
|
|
|
|
if (r > RATING_APPALLING) str++;
|
|
|
|
if (r > RATING_VERYPOOR) str++;
|
|
|
|
if (r > RATING_POOR) str++;
|
|
|
|
if (r > RATING_MEDIOCRE) str++;
|
|
|
|
if (r > RATING_GOOD) str++;
|
|
|
|
if (r > RATING_VERYGOOD) str++;
|
|
|
|
if (r > RATING_EXCELLENT) str++;
|
2008-05-15 22:47:03 +00:00
|
|
|
|
|
|
|
SetDParam(2, str);
|
2010-05-23 15:17:05 +00:00
|
|
|
if (this->town->exclusivity == c->index) {
|
2010-09-02 20:00:48 +00:00
|
|
|
DrawSprite(SPR_EXCLUSIVE_TRANSPORT, COMPANY_SPRITE_COLOUR(c->index), exclusive_left, y + exclusive_y_offset);
|
2008-04-14 17:06:36 +00:00
|
|
|
}
|
2008-05-15 22:47:03 +00:00
|
|
|
|
2009-11-19 10:56:14 +00:00
|
|
|
DrawString(text_left, text_right, y, STR_LOCAL_AUTHORITY_COMPANY_RATING);
|
2009-09-20 10:25:03 +00:00
|
|
|
y += FONT_HEIGHT_NORMAL;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-15 22:47:03 +00:00
|
|
|
}
|
2009-01-15 12:50:59 +00:00
|
|
|
|
2009-09-20 14:46:15 +00:00
|
|
|
y = y + WD_FRAMERECT_BOTTOM - nwid->pos_y; // Compute needed size of the widget.
|
|
|
|
if (y > nwid->current_y) {
|
2009-01-15 12:50:59 +00:00
|
|
|
/* If the company list is too big to fit, mark ourself dirty and draw again. */
|
2016-05-22 10:52:02 +00:00
|
|
|
ResizeWindow(this, 0, y - nwid->current_y, false);
|
2009-01-15 12:50:59 +00:00
|
|
|
}
|
2009-09-20 14:46:15 +00:00
|
|
|
}
|
2009-01-15 12:50:59 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void SetStringParameters(int widget) const override
|
2009-09-20 14:46:15 +00:00
|
|
|
{
|
2011-12-16 17:23:41 +00:00
|
|
|
if (widget == WID_TA_CAPTION) SetDParam(0, this->window_number);
|
2009-09-20 14:46:15 +00:00
|
|
|
}
|
2004-08-23 21:12:51 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void DrawWidget(const Rect &r, int widget) const override
|
2009-09-20 14:46:15 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TA_ACTION_INFO:
|
2009-09-20 14:46:15 +00:00
|
|
|
if (this->sel_index != -1) {
|
2010-01-30 16:29:52 +00:00
|
|
|
SetDParam(0, _price[PR_TOWN_ACTION] * _town_action_costs[this->sel_index] >> 8);
|
2009-09-20 14:46:15 +00:00
|
|
|
DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
|
|
|
|
STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + this->sel_index);
|
|
|
|
}
|
|
|
|
break;
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TA_COMMAND_LIST: {
|
2009-09-20 14:46:15 +00:00
|
|
|
int numact;
|
|
|
|
uint buttons = GetMaskOfTownActions(&numact, _local_company, this->town);
|
|
|
|
int y = r.top + WD_FRAMERECT_TOP;
|
2010-08-12 08:37:01 +00:00
|
|
|
int pos = this->vscroll->GetPosition();
|
2009-09-20 14:46:15 +00:00
|
|
|
|
|
|
|
if (--pos < 0) {
|
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_LOCAL_AUTHORITY_ACTIONS_TITLE);
|
|
|
|
y += FONT_HEIGHT_NORMAL;
|
|
|
|
}
|
2005-11-14 19:48:04 +00:00
|
|
|
|
2009-09-20 14:46:15 +00:00
|
|
|
for (int i = 0; buttons; i++, buttons >>= 1) {
|
|
|
|
if (pos <= -5) break; ///< Draw only the 5 fitting lines
|
2008-05-15 22:47:03 +00:00
|
|
|
|
2009-09-20 14:46:15 +00:00
|
|
|
if ((buttons & 1) && --pos < 0) {
|
2010-01-30 16:29:52 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y,
|
|
|
|
STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i, this->sel_index == i ? TC_WHITE : TC_ORANGE);
|
2009-09-20 14:46:15 +00:00
|
|
|
y += FONT_HEIGHT_NORMAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-15 22:47:03 +00:00
|
|
|
}
|
2009-09-20 14:46:15 +00:00
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
2009-09-20 14:46:15 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TA_ACTION_INFO: {
|
2009-09-20 14:46:15 +00:00
|
|
|
assert(size->width > padding.width && size->height > padding.height);
|
|
|
|
size->width -= WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
|
|
|
size->height -= WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
|
|
|
Dimension d = {0, 0};
|
|
|
|
for (int i = 0; i < TACT_COUNT; i++) {
|
2010-01-30 16:29:52 +00:00
|
|
|
SetDParam(0, _price[PR_TOWN_ACTION] * _town_action_costs[i] >> 8);
|
2009-09-20 14:46:15 +00:00
|
|
|
d = maxdim(d, GetStringMultiLineBoundingBox(STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + i, *size));
|
|
|
|
}
|
|
|
|
*size = maxdim(*size, d);
|
|
|
|
size->width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
|
|
|
size->height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
|
|
|
break;
|
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TA_COMMAND_LIST:
|
2009-09-20 14:46:15 +00:00
|
|
|
size->height = WD_FRAMERECT_TOP + 5 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
|
2009-11-23 14:04:03 +00:00
|
|
|
size->width = GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTIONS_TITLE).width;
|
|
|
|
for (uint i = 0; i < TACT_COUNT; i++ ) {
|
|
|
|
size->width = max(size->width, GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i).width);
|
|
|
|
}
|
|
|
|
size->width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
2009-09-20 14:46:15 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TA_RATING_INFO:
|
2009-11-23 14:04:03 +00:00
|
|
|
resize->height = FONT_HEIGHT_NORMAL;
|
2009-09-20 14:46:15 +00:00
|
|
|
size->height = WD_FRAMERECT_TOP + 9 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
|
|
|
|
break;
|
2008-05-15 22:47:03 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
2008-05-15 22:47:03 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2019-01-05 13:22:07 +00:00
|
|
|
case WID_TA_ZONE_BUTTON: {
|
|
|
|
bool new_show_state = !this->town->show_zone;
|
|
|
|
TownID index = this->town->index;
|
|
|
|
|
|
|
|
new_show_state ? _town_local_authority_kdtree.Insert(index) : _town_local_authority_kdtree.Remove(index);
|
|
|
|
|
|
|
|
this->town->show_zone = new_show_state;
|
|
|
|
this->SetWidgetLoweredState(widget, new_show_state);
|
|
|
|
MarkWholeScreenDirty();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TA_COMMAND_LIST: {
|
|
|
|
int y = this->GetRowFromWidget(pt.y, WID_TA_COMMAND_LIST, 1, FONT_HEIGHT_NORMAL);
|
2008-05-15 22:47:03 +00:00
|
|
|
if (!IsInsideMM(y, 0, 5)) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2019-04-10 21:07:06 +00:00
|
|
|
y = GetNthSetBit(GetMaskOfTownActions(nullptr, _local_company, this->town), y + this->vscroll->GetPosition() - 1);
|
2008-05-15 22:47:03 +00:00
|
|
|
if (y >= 0) {
|
|
|
|
this->sel_index = y;
|
|
|
|
this->SetDirty();
|
|
|
|
}
|
2017-08-13 18:38:42 +00:00
|
|
|
/* When double-clicking, continue */
|
2010-01-30 18:34:48 +00:00
|
|
|
if (click_count == 1 || y < 0) break;
|
2017-08-15 15:56:34 +00:00
|
|
|
FALLTHROUGH;
|
2008-04-14 17:06:36 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TA_EXECUTE:
|
2009-04-21 23:40:56 +00:00
|
|
|
DoCommandP(this->town->xy, this->window_number, this->sel_index, CMD_DO_TOWN_ACTION | CMD_MSG(STR_ERROR_CAN_T_DO_THIS));
|
2008-05-15 22:47:03 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-15 22:47:03 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnHundredthTick() override
|
2008-05-15 22:47:03 +00:00
|
|
|
{
|
|
|
|
this->SetDirty();
|
|
|
|
}
|
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
static WindowDesc _town_authority_desc(
|
2013-05-26 19:25:01 +00:00
|
|
|
WDP_AUTO, "view_town_authority", 317, 222,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_TOWN_AUTHORITY, WC_NONE,
|
2012-11-11 16:10:43 +00:00
|
|
|
0,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_town_authority_widgets, lengthof(_nested_town_authority_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2004-11-14 19:44:06 +00:00
|
|
|
static void ShowTownAuthorityWindow(uint town)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-05-15 22:47:03 +00:00
|
|
|
AllocateWindowDescFront<TownAuthorityWindow>(&_town_authority_desc, town);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2009-04-12 19:25:59 +00:00
|
|
|
|
2009-09-18 19:59:05 +00:00
|
|
|
/* Town view window. */
|
2008-05-18 08:13:13 +00:00
|
|
|
struct TownViewWindow : Window {
|
2008-05-22 02:03:05 +00:00
|
|
|
private:
|
2009-09-18 19:59:05 +00:00
|
|
|
Town *town; ///< Town displayed by the window.
|
2008-05-22 02:03:05 +00:00
|
|
|
|
|
|
|
public:
|
2011-12-16 17:23:41 +00:00
|
|
|
static const int WID_TV_HEIGHT_NORMAL = 150;
|
2009-02-23 20:03:38 +00:00
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
TownViewWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
|
2008-05-18 08:13:13 +00:00
|
|
|
{
|
2013-05-26 19:23:42 +00:00
|
|
|
this->CreateNestedTree();
|
2009-09-18 19:59:05 +00:00
|
|
|
|
2009-09-19 10:19:15 +00:00
|
|
|
this->town = Town::Get(window_number);
|
2011-12-16 17:23:41 +00:00
|
|
|
if (this->town->larger_town) this->GetWidget<NWidgetCore>(WID_TV_CAPTION)->widget_data = STR_TOWN_VIEW_CITY_CAPTION;
|
2009-09-18 19:59:05 +00:00
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
this->FinishInitNested(window_number);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2012-01-11 18:47:32 +00:00
|
|
|
this->flags |= WF_DISABLE_VP_SCROLL;
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_TV_VIEWPORT);
|
2009-09-18 19:59:05 +00:00
|
|
|
nvp->InitializeViewport(this, this->town->xy, ZOOM_LVL_NEWS);
|
2008-05-19 01:50:07 +00:00
|
|
|
|
2009-09-18 19:59:05 +00:00
|
|
|
/* disable renaming town in network games if you are not the server */
|
2011-12-16 17:23:41 +00:00
|
|
|
this->SetWidgetDisabledState(WID_TV_CHANGE_NAME, _networking && !_network_server);
|
2008-05-18 08:13:13 +00:00
|
|
|
}
|
2008-03-22 11:27:46 +00:00
|
|
|
|
2019-03-30 16:59:43 +00:00
|
|
|
~TownViewWindow()
|
|
|
|
{
|
|
|
|
SetViewportCatchmentTown(Town::Get(this->window_number), false);
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void SetStringParameters(int widget) const override
|
2009-09-18 19:59:05 +00:00
|
|
|
{
|
2011-12-16 17:23:41 +00:00
|
|
|
if (widget == WID_TV_CAPTION) SetDParam(0, this->town->index);
|
2009-09-18 19:59:05 +00:00
|
|
|
}
|
|
|
|
|
2019-03-30 16:59:43 +00:00
|
|
|
void OnPaint() override
|
|
|
|
{
|
|
|
|
extern const Town *_viewport_highlight_town;
|
|
|
|
this->SetWidgetLoweredState(WID_TV_CATCHMENT, _viewport_highlight_town == this->town);
|
|
|
|
|
|
|
|
this->DrawWidgets();
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void DrawWidget(const Rect &r, int widget) const override
|
2009-09-18 19:59:05 +00:00
|
|
|
{
|
2011-12-16 17:23:41 +00:00
|
|
|
if (widget != WID_TV_INFO) return;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2009-09-18 19:59:05 +00:00
|
|
|
uint y = r.top + WD_FRAMERECT_TOP;
|
2009-02-23 20:03:38 +00:00
|
|
|
|
2012-04-25 20:50:13 +00:00
|
|
|
SetDParam(0, this->town->cache.population);
|
|
|
|
SetDParam(1, this->town->cache.num_houses);
|
2009-09-18 19:59:05 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y, STR_TOWN_VIEW_POPULATION_HOUSES);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2018-06-04 12:14:11 +00:00
|
|
|
SetDParam(0, 1 << CT_PASSENGERS);
|
|
|
|
SetDParam(1, this->town->supplied[CT_PASSENGERS].old_act);
|
|
|
|
SetDParam(2, this->town->supplied[CT_PASSENGERS].old_max);
|
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
|
|
|
|
|
|
|
|
SetDParam(0, 1 << CT_MAIL);
|
|
|
|
SetDParam(1, this->town->supplied[CT_MAIL].old_act);
|
|
|
|
SetDParam(2, this->town->supplied[CT_MAIL].old_max);
|
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_LAST_MONTH_MAX);
|
2009-02-23 20:03:38 +00:00
|
|
|
|
2011-11-23 16:07:14 +00:00
|
|
|
bool first = true;
|
|
|
|
for (int i = TE_BEGIN; i < TE_END; i++) {
|
|
|
|
if (this->town->goal[i] == 0) continue;
|
2012-04-25 20:50:13 +00:00
|
|
|
if (this->town->goal[i] == TOWN_GROWTH_WINTER && (TileHeight(this->town->xy) < LowestSnowLine() || this->town->cache.population <= 90)) continue;
|
|
|
|
if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue;
|
2009-02-23 20:03:38 +00:00
|
|
|
|
2011-11-23 16:07:14 +00:00
|
|
|
if (first) {
|
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH);
|
|
|
|
first = false;
|
|
|
|
}
|
2009-02-23 20:03:38 +00:00
|
|
|
|
2010-11-13 09:56:25 +00:00
|
|
|
bool rtl = _current_text_dir == TD_RTL;
|
2009-11-28 20:15:16 +00:00
|
|
|
uint cargo_text_left = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : 20);
|
|
|
|
uint cargo_text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? 20 : 0);
|
|
|
|
|
2011-11-23 16:07:14 +00:00
|
|
|
const CargoSpec *cargo = FindFirstCargoWithTownEffect((TownEffect)i);
|
2019-04-10 21:07:06 +00:00
|
|
|
assert(cargo != nullptr);
|
2009-12-06 16:15:58 +00:00
|
|
|
|
2011-11-23 16:07:14 +00:00
|
|
|
StringID string;
|
2009-02-23 20:03:38 +00:00
|
|
|
|
2011-11-23 16:07:14 +00:00
|
|
|
if (this->town->goal[i] == TOWN_GROWTH_DESERT || this->town->goal[i] == TOWN_GROWTH_WINTER) {
|
|
|
|
/* For 'original' gameplay, don't show the amount required (you need 1 or more ..) */
|
|
|
|
string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL;
|
2011-12-10 15:41:39 +00:00
|
|
|
if (this->town->received[i].old_act == 0) {
|
2011-11-23 16:07:14 +00:00
|
|
|
string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_GENERAL;
|
2009-02-23 20:03:38 +00:00
|
|
|
|
2011-11-23 16:07:14 +00:00
|
|
|
if (this->town->goal[i] == TOWN_GROWTH_WINTER && TileHeight(this->town->xy) < GetSnowLine()) {
|
|
|
|
string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER;
|
|
|
|
}
|
2009-02-23 20:03:38 +00:00
|
|
|
}
|
2011-11-23 16:07:14 +00:00
|
|
|
|
|
|
|
SetDParam(0, cargo->name);
|
|
|
|
} else {
|
|
|
|
string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED;
|
|
|
|
if (this->town->received[i].old_act < this->town->goal[i]) {
|
|
|
|
string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetDParam(0, cargo->Index());
|
|
|
|
SetDParam(1, this->town->received[i].old_act);
|
|
|
|
SetDParam(2, cargo->Index());
|
|
|
|
SetDParam(3, this->town->goal[i]);
|
2009-02-23 20:03:38 +00:00
|
|
|
}
|
2011-11-23 16:07:14 +00:00
|
|
|
DrawString(cargo_text_left, cargo_text_right, y += FONT_HEIGHT_NORMAL, string);
|
|
|
|
}
|
|
|
|
|
2013-10-28 10:55:34 +00:00
|
|
|
if (HasBit(this->town->flags, TOWN_IS_GROWING)) {
|
2018-05-02 19:01:30 +00:00
|
|
|
SetDParam(0, RoundDivSU(this->town->growth_rate + 1, DAY_TICKS));
|
2011-11-23 16:07:14 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, this->town->fund_buildings_months == 0 ? STR_TOWN_VIEW_TOWN_GROWS_EVERY : STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED);
|
|
|
|
} else {
|
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_TOWN_GROW_STOPPED);
|
2009-02-23 20:03:38 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-24 02:54:47 +00:00
|
|
|
/* only show the town noise, if the noise option is activated. */
|
2008-05-29 15:13:28 +00:00
|
|
|
if (_settings_game.economy.station_noise_level) {
|
2008-05-24 02:54:47 +00:00
|
|
|
SetDParam(0, this->town->noise_reached);
|
|
|
|
SetDParam(1, this->town->MaxTownNoise());
|
2009-09-18 19:59:05 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_LEFT, y += FONT_HEIGHT_NORMAL, STR_TOWN_VIEW_NOISE_IN_TOWN);
|
2008-05-24 02:54:47 +00:00
|
|
|
}
|
2011-12-19 21:00:55 +00:00
|
|
|
|
2019-04-10 21:07:06 +00:00
|
|
|
if (this->town->text != nullptr) {
|
2011-12-19 21:06:06 +00:00
|
|
|
SetDParamStr(0, this->town->text);
|
2014-09-20 11:32:54 +00:00
|
|
|
DrawStringMultiLine(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y += FONT_HEIGHT_NORMAL, UINT16_MAX, STR_JUST_RAW_STRING, TC_BLACK);
|
2011-12-19 21:00:55 +00:00
|
|
|
}
|
2008-05-18 08:13:13 +00:00
|
|
|
}
|
2005-11-14 19:48:04 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
2008-05-18 08:13:13 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TV_CENTER_VIEW: // scroll to location
|
2008-05-18 08:13:13 +00:00
|
|
|
if (_ctrl_pressed) {
|
2008-05-22 02:13:24 +00:00
|
|
|
ShowExtraViewPortWindow(this->town->xy);
|
2008-05-18 08:13:13 +00:00
|
|
|
} else {
|
2008-05-22 02:13:24 +00:00
|
|
|
ScrollMainWindowToTile(this->town->xy);
|
2008-05-18 08:13:13 +00:00
|
|
|
}
|
|
|
|
break;
|
2005-11-14 19:48:04 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TV_SHOW_AUTHORITY: // town authority
|
2008-05-18 08:13:13 +00:00
|
|
|
ShowTownAuthorityWindow(this->window_number);
|
|
|
|
break;
|
2005-11-14 19:48:04 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TV_CHANGE_NAME: // rename
|
2008-05-18 08:13:13 +00:00
|
|
|
SetDParam(0, this->window_number);
|
2011-04-17 18:42:17 +00:00
|
|
|
ShowQueryString(STR_TOWN_NAME, STR_TOWN_VIEW_RENAME_TOWN_BUTTON, MAX_LENGTH_TOWN_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
|
2008-05-18 08:13:13 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2019-03-30 16:59:43 +00:00
|
|
|
case WID_TV_CATCHMENT:
|
|
|
|
SetViewportCatchmentTown(Town::Get(this->window_number), !this->IsWidgetLowered(WID_TV_CATCHMENT));
|
|
|
|
break;
|
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TV_EXPAND: { // expand town - only available on Scenario editor
|
2010-08-02 21:06:06 +00:00
|
|
|
/* Warn the user if towns are not allowed to build roads, but do this only once per OpenTTD run. */
|
|
|
|
static bool _warn_town_no_roads = false;
|
|
|
|
|
|
|
|
if (!_settings_game.economy.allow_town_roads && !_warn_town_no_roads) {
|
|
|
|
ShowErrorMessage(STR_ERROR_TOWN_EXPAND_WARN_NO_ROADS, INVALID_STRING_ID, WL_WARNING);
|
|
|
|
_warn_town_no_roads = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DoCommandP(0, this->window_number, 0, CMD_EXPAND_TOWN | CMD_MSG(STR_ERROR_CAN_T_EXPAND_TOWN));
|
2008-05-18 08:13:13 +00:00
|
|
|
break;
|
2010-08-02 21:25:17 +00:00
|
|
|
}
|
2008-05-18 08:13:13 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TV_DELETE: // delete town - only available on Scenario editor
|
2010-08-02 21:07:23 +00:00
|
|
|
DoCommandP(0, this->window_number, 0, CMD_DELETE_TOWN | CMD_MSG(STR_ERROR_TOWN_CAN_T_DELETE));
|
2008-05-18 08:13:13 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-05-18 08:13:13 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
2009-11-23 21:34:33 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TV_INFO:
|
2011-12-19 21:00:55 +00:00
|
|
|
size->height = GetDesiredInfoHeight(size->width);
|
2009-11-23 21:34:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the desired height for the information panel.
|
|
|
|
* @return the desired height in pixels.
|
|
|
|
*/
|
2011-12-19 21:00:55 +00:00
|
|
|
uint GetDesiredInfoHeight(int width) const
|
2009-02-23 20:03:38 +00:00
|
|
|
{
|
2009-09-18 19:59:05 +00:00
|
|
|
uint aimed_height = 3 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
2009-02-23 20:03:38 +00:00
|
|
|
|
2011-11-23 16:07:14 +00:00
|
|
|
bool first = true;
|
|
|
|
for (int i = TE_BEGIN; i < TE_END; i++) {
|
|
|
|
if (this->town->goal[i] == 0) continue;
|
2012-04-25 20:50:13 +00:00
|
|
|
if (this->town->goal[i] == TOWN_GROWTH_WINTER && (TileHeight(this->town->xy) < LowestSnowLine() || this->town->cache.population <= 90)) continue;
|
|
|
|
if (this->town->goal[i] == TOWN_GROWTH_DESERT && (GetTropicZone(this->town->xy) != TROPICZONE_DESERT || this->town->cache.population <= 60)) continue;
|
2011-11-23 18:55:13 +00:00
|
|
|
|
2011-11-23 16:07:14 +00:00
|
|
|
if (first) {
|
|
|
|
aimed_height += FONT_HEIGHT_NORMAL;
|
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
aimed_height += FONT_HEIGHT_NORMAL;
|
2009-02-23 20:03:38 +00:00
|
|
|
}
|
2011-11-23 16:07:14 +00:00
|
|
|
aimed_height += FONT_HEIGHT_NORMAL;
|
2009-02-23 20:03:38 +00:00
|
|
|
|
2009-09-18 19:59:05 +00:00
|
|
|
if (_settings_game.economy.station_noise_level) aimed_height += FONT_HEIGHT_NORMAL;
|
2009-02-23 20:03:38 +00:00
|
|
|
|
2019-04-10 21:07:06 +00:00
|
|
|
if (this->town->text != nullptr) {
|
2011-12-19 21:00:55 +00:00
|
|
|
SetDParamStr(0, this->town->text);
|
2014-09-20 11:32:54 +00:00
|
|
|
aimed_height += GetStringHeight(STR_JUST_RAW_STRING, width - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT);
|
2011-12-19 21:00:55 +00:00
|
|
|
}
|
|
|
|
|
2009-11-23 21:34:33 +00:00
|
|
|
return aimed_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResizeWindowAsNeeded()
|
|
|
|
{
|
2011-12-16 17:23:41 +00:00
|
|
|
const NWidgetBase *nwid_info = this->GetWidget<NWidgetBase>(WID_TV_INFO);
|
2011-12-19 21:00:55 +00:00
|
|
|
uint aimed_height = GetDesiredInfoHeight(nwid_info->current_x);
|
2009-09-18 19:59:05 +00:00
|
|
|
if (aimed_height > nwid_info->current_y || (aimed_height < nwid_info->current_y && nwid_info->current_y > nwid_info->smallest_y)) {
|
2009-11-23 21:34:33 +00:00
|
|
|
this->ReInit();
|
2009-09-18 19:59:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnResize() override
|
2009-09-18 19:59:05 +00:00
|
|
|
{
|
2019-04-10 21:07:06 +00:00
|
|
|
if (this->viewport != nullptr) {
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidgetViewport *nvp = this->GetWidget<NWidgetViewport>(WID_TV_VIEWPORT);
|
2009-09-18 19:59:05 +00:00
|
|
|
nvp->UpdateViewportCoordinates(this);
|
2010-10-23 21:14:35 +00:00
|
|
|
|
|
|
|
ScrollWindowToTile(this->town->xy, this, true); // Re-center viewport.
|
2009-09-18 19:59:05 +00:00
|
|
|
}
|
2009-02-23 20:03:38 +00:00
|
|
|
}
|
|
|
|
|
2011-03-13 21:31:29 +00:00
|
|
|
/**
|
|
|
|
* Some data on this window has become invalid.
|
|
|
|
* @param data Information about the changed data.
|
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
|
*/
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
2008-05-24 02:54:47 +00:00
|
|
|
{
|
2011-03-13 21:31:29 +00:00
|
|
|
if (!gui_scope) return;
|
2011-12-15 21:56:00 +00:00
|
|
|
/* Called when setting station noise or required cargoes have changed, in order to resize the window */
|
2008-05-24 02:54:47 +00:00
|
|
|
this->SetDirty(); // refresh display for current size. This will allow to avoid glitches when downgrading
|
2009-02-23 20:03:38 +00:00
|
|
|
this->ResizeWindowAsNeeded();
|
2008-05-24 02:54:47 +00:00
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnQueryTextFinished(char *str) override
|
2008-05-18 08:13:13 +00:00
|
|
|
{
|
2019-04-10 21:07:06 +00:00
|
|
|
if (str == nullptr) return;
|
2008-09-15 19:02:50 +00:00
|
|
|
|
2019-04-10 21:07:06 +00:00
|
|
|
DoCommandP(0, this->window_number, 0, CMD_RENAME_TOWN | CMD_MSG(STR_ERROR_CAN_T_RENAME_TOWN), nullptr, str);
|
2008-05-18 08:13:13 +00:00
|
|
|
}
|
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-09-18 19:59:05 +00:00
|
|
|
static const NWidgetPart _nested_town_game_view_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_TV_CAPTION), SetDataTip(STR_TOWN_VIEW_TOWN_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
2013-05-26 19:30:07 +00:00
|
|
|
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
2009-09-18 19:59:05 +00:00
|
|
|
EndContainer(),
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_BROWN),
|
|
|
|
NWidget(WWT_INSET, COLOUR_BROWN), SetPadding(2, 2, 2, 2),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_TV_VIEWPORT), SetMinimalSize(254, 86), SetFill(1, 0), SetResize(1, 1), SetPadding(1, 1, 1, 1),
|
2009-09-18 19:59:05 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TV_INFO), SetMinimalSize(260, 32), SetResize(1, 0), SetFill(1, 0), EndContainer(),
|
2009-11-23 21:34:33 +00:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CENTER_VIEW), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_TOWN_VIEW_CENTER_TOOLTIP),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_SHOW_AUTHORITY), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_TOWN_VIEW_LOCAL_AUTHORITY_BUTTON, STR_TOWN_VIEW_LOCAL_AUTHORITY_TOOLTIP),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CHANGE_NAME), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_RENAME, STR_TOWN_VIEW_RENAME_TOOLTIP),
|
2009-11-23 21:34:33 +00:00
|
|
|
EndContainer(),
|
2019-03-30 16:59:43 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_TV_CATCHMENT), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_BUTTON_CATCHMENT, STR_TOOLTIP_CATCHMENT),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
|
2009-09-18 19:59:05 +00:00
|
|
|
EndContainer(),
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
static WindowDesc _town_game_view_desc(
|
2013-05-26 19:25:01 +00:00
|
|
|
WDP_AUTO, "view_town", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL,
|
2009-09-18 19:59:05 +00:00
|
|
|
WC_TOWN_VIEW, WC_NONE,
|
2012-11-11 16:10:43 +00:00
|
|
|
0,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_town_game_view_widgets, lengthof(_nested_town_game_view_widgets)
|
2009-09-18 19:59:05 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static const NWidgetPart _nested_town_editor_view_widgets[] = {
|
2009-04-12 19:30:47 +00:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_TV_CAPTION), SetDataTip(STR_TOWN_VIEW_TOWN_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CHANGE_NAME), SetMinimalSize(76, 14), SetDataTip(STR_BUTTON_RENAME, STR_TOWN_VIEW_RENAME_TOOLTIP),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
2013-05-26 19:30:07 +00:00
|
|
|
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_BROWN),
|
|
|
|
NWidget(WWT_INSET, COLOUR_BROWN), SetPadding(2, 2, 2, 2),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_TV_VIEWPORT), SetMinimalSize(254, 86), SetFill(1, 1), SetResize(1, 1), SetPadding(1, 1, 1, 1),
|
2009-09-18 19:59:05 +00:00
|
|
|
EndContainer(),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TV_INFO), SetMinimalSize(260, 32), SetResize(1, 0), SetFill(1, 0), EndContainer(),
|
2009-11-23 21:34:33 +00:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_CENTER_VIEW), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_TOWN_VIEW_CENTER_TOOLTIP),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_EXPAND), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_TOWN_VIEW_EXPAND_BUTTON, STR_TOWN_VIEW_EXPAND_TOOLTIP),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_TV_DELETE), SetMinimalSize(80, 12), SetFill(1, 1), SetResize(1, 0), SetDataTip(STR_TOWN_VIEW_DELETE_BUTTON, STR_TOWN_VIEW_DELETE_TOOLTIP),
|
2009-11-23 21:34:33 +00:00
|
|
|
EndContainer(),
|
2019-04-27 08:00:22 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_TV_CATCHMENT), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_BUTTON_CATCHMENT, STR_TOOLTIP_CATCHMENT),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
static WindowDesc _town_editor_view_desc(
|
2013-05-26 19:25:01 +00:00
|
|
|
WDP_AUTO, "view_town_scen", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_TOWN_VIEW, WC_NONE,
|
2012-11-11 16:10:43 +00:00
|
|
|
0,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_town_editor_view_widgets, lengthof(_nested_town_editor_view_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-03-26 22:58:11 +00:00
|
|
|
void ShowTownViewWindow(TownID town)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2009-09-18 19:59:05 +00:00
|
|
|
if (_game_mode == GM_EDITOR) {
|
|
|
|
AllocateWindowDescFront<TownViewWindow>(&_town_editor_view_desc, town);
|
|
|
|
} else {
|
|
|
|
AllocateWindowDescFront<TownViewWindow>(&_town_game_view_desc, town);
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2009-04-12 19:30:47 +00:00
|
|
|
static const NWidgetPart _nested_town_directory_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_TOWN_DIRECTORY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
|
2013-05-26 19:30:07 +00:00
|
|
|
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(NWID_VERTICAL),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2013-03-17 15:41:40 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_TD_SORT_ORDER), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
|
|
|
|
NWidget(WWT_DROPDOWN, COLOUR_BROWN, WID_TD_SORT_CRITERIA), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_SORT_CRITERIA),
|
2019-07-22 19:27:39 +00:00
|
|
|
NWidget(WWT_EDITBOX, COLOUR_BROWN, WID_TD_FILTER), SetFill(35, 12), SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_BROWN, WID_TD_LIST), SetMinimalSize(196, 0), SetDataTip(0x0, STR_TOWN_DIRECTORY_LIST_TOOLTIP),
|
|
|
|
SetFill(1, 0), SetResize(0, 10), SetScrollbar(WID_TD_SCROLLBAR), EndContainer(),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_BROWN),
|
|
|
|
NWidget(WWT_TEXT, COLOUR_BROWN, WID_TD_WORLD_POPULATION), SetPadding(2, 0, 0, 2), SetMinimalSize(196, 12), SetFill(1, 0), SetDataTip(STR_TOWN_POPULATION, STR_NULL),
|
2009-07-25 11:32:53 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_VERTICAL),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_TD_SCROLLBAR),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-06-28 21:23:37 +00:00
|
|
|
/** Town directory window class. */
|
2008-05-27 20:05:36 +00:00
|
|
|
struct TownDirectoryWindow : public Window {
|
|
|
|
private:
|
|
|
|
/* Runtime saved values */
|
|
|
|
static Listing last_sorting;
|
|
|
|
static const Town *last_town;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-27 20:05:36 +00:00
|
|
|
/* Constants for sorting towns */
|
2013-03-17 15:41:40 +00:00
|
|
|
static const StringID sorter_names[];
|
2008-05-27 21:41:00 +00:00
|
|
|
static GUITownList::SortFunction * const sorter_funcs[];
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2019-07-22 19:27:39 +00:00
|
|
|
StringFilter string_filter; ///< Filter for towns
|
|
|
|
QueryString townname_editbox; ///< Filter editbox
|
|
|
|
|
2008-05-27 20:05:36 +00:00
|
|
|
GUITownList towns;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2010-08-12 08:37:01 +00:00
|
|
|
Scrollbar *vscroll;
|
|
|
|
|
2009-07-03 21:38:41 +00:00
|
|
|
void BuildSortTownList()
|
2008-05-27 20:05:36 +00:00
|
|
|
{
|
2009-07-03 21:38:41 +00:00
|
|
|
if (this->towns.NeedRebuild()) {
|
2018-09-20 22:44:14 +00:00
|
|
|
this->towns.clear();
|
2005-01-06 22:31:58 +00:00
|
|
|
|
2009-07-03 21:38:41 +00:00
|
|
|
const Town *t;
|
|
|
|
FOR_ALL_TOWNS(t) {
|
2019-02-18 22:39:06 +00:00
|
|
|
this->towns.push_back(t);
|
2009-07-03 21:38:41 +00:00
|
|
|
}
|
2005-01-06 22:31:58 +00:00
|
|
|
|
2018-09-21 21:45:44 +00:00
|
|
|
this->towns.shrink_to_fit();
|
2009-07-03 21:38:41 +00:00
|
|
|
this->towns.RebuildDone();
|
2019-03-27 23:09:33 +00:00
|
|
|
this->vscroll->SetCount((uint)this->towns.size()); // Update scrollbar as well.
|
2008-05-27 20:05:36 +00:00
|
|
|
}
|
2009-07-03 21:38:41 +00:00
|
|
|
/* Always sort the towns. */
|
2019-04-10 21:07:06 +00:00
|
|
|
this->last_town = nullptr;
|
2008-05-27 20:05:36 +00:00
|
|
|
this->towns.Sort();
|
2013-03-17 15:41:40 +00:00
|
|
|
this->SetWidgetDirty(WID_TD_LIST); // Force repaint of the displayed towns.
|
2008-05-27 20:05:36 +00:00
|
|
|
}
|
2004-08-16 14:48:35 +00:00
|
|
|
|
2008-05-27 20:05:36 +00:00
|
|
|
/** Sort by town name */
|
2019-04-11 19:26:02 +00:00
|
|
|
static bool TownNameSorter(const Town * const &a, const Town * const &b)
|
2008-05-27 20:05:36 +00:00
|
|
|
{
|
2019-07-22 19:27:39 +00:00
|
|
|
static char buf_cache[MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH];
|
|
|
|
char buf[MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH];
|
2008-05-27 20:05:36 +00:00
|
|
|
|
2019-04-11 19:26:02 +00:00
|
|
|
SetDParam(0, a->index);
|
2009-07-20 11:21:57 +00:00
|
|
|
GetString(buf, STR_TOWN_NAME, lastof(buf));
|
2008-05-27 20:05:36 +00:00
|
|
|
|
|
|
|
/* If 'b' is the same town as in the last round, use the cached value
|
|
|
|
* We do this to speed stuff up ('b' is called with the same value a lot of
|
2013-01-08 22:46:42 +00:00
|
|
|
* times after each other) */
|
2019-04-11 19:26:02 +00:00
|
|
|
if (b != last_town) {
|
|
|
|
last_town = b;
|
|
|
|
SetDParam(0, b->index);
|
2009-07-20 11:21:57 +00:00
|
|
|
GetString(buf_cache, STR_TOWN_NAME, lastof(buf_cache));
|
2008-05-27 20:05:36 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2019-04-11 19:26:02 +00:00
|
|
|
return strnatcmp(buf, buf_cache) < 0; // Sort by name (natural sorting).
|
2008-05-27 20:05:36 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2013-03-17 15:44:19 +00:00
|
|
|
/** Sort by population (default descending, as big towns are of the most interest). */
|
2019-04-11 19:26:02 +00:00
|
|
|
static bool TownPopulationSorter(const Town * const &a, const Town * const &b)
|
2008-05-27 20:05:36 +00:00
|
|
|
{
|
2019-04-11 19:26:02 +00:00
|
|
|
uint32 a_population = a->cache.population;
|
|
|
|
uint32 b_population = b->cache.population;
|
2013-03-17 15:44:19 +00:00
|
|
|
if (a_population == b_population) return TownDirectoryWindow::TownNameSorter(a, b);
|
2019-04-11 19:26:02 +00:00
|
|
|
return a_population < b_population;
|
2008-05-27 20:05:36 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2013-03-17 15:45:24 +00:00
|
|
|
/** Sort by town rating */
|
2019-04-11 19:26:02 +00:00
|
|
|
static bool TownRatingSorter(const Town * const &a, const Town * const &b)
|
2013-03-17 15:45:24 +00:00
|
|
|
{
|
2019-04-11 19:26:02 +00:00
|
|
|
bool before = !TownDirectoryWindow::last_sorting.order; // Value to get 'a' before 'b'.
|
2013-03-17 15:45:24 +00:00
|
|
|
|
|
|
|
/* Towns without rating are always after towns with rating. */
|
2019-04-11 19:26:02 +00:00
|
|
|
if (HasBit(a->have_ratings, _local_company)) {
|
|
|
|
if (HasBit(b->have_ratings, _local_company)) {
|
|
|
|
int16 a_rating = a->ratings[_local_company];
|
|
|
|
int16 b_rating = b->ratings[_local_company];
|
2013-03-17 15:45:24 +00:00
|
|
|
if (a_rating == b_rating) return TownDirectoryWindow::TownNameSorter(a, b);
|
2019-04-11 19:26:02 +00:00
|
|
|
return a_rating < b_rating;
|
2013-03-17 15:45:24 +00:00
|
|
|
}
|
|
|
|
return before;
|
|
|
|
}
|
2019-04-11 19:26:02 +00:00
|
|
|
if (HasBit(b->have_ratings, _local_company)) return !before;
|
|
|
|
|
|
|
|
/* Sort unrated towns always on ascending town name. */
|
|
|
|
if (before) return TownDirectoryWindow::TownNameSorter(a, b);
|
|
|
|
return !TownDirectoryWindow::TownNameSorter(a, b);
|
2013-03-17 15:45:24 +00:00
|
|
|
}
|
|
|
|
|
2008-05-22 02:03:05 +00:00
|
|
|
public:
|
2019-07-22 19:27:39 +00:00
|
|
|
TownDirectoryWindow(WindowDesc *desc) : Window(desc), townname_editbox(MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_TOWN_NAME_CHARS)
|
2008-05-19 09:17:26 +00:00
|
|
|
{
|
2013-05-26 19:23:42 +00:00
|
|
|
this->CreateNestedTree();
|
2010-08-12 08:37:01 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
this->vscroll = this->GetScrollbar(WID_TD_SCROLLBAR);
|
2010-08-12 08:37:01 +00:00
|
|
|
|
2008-05-27 20:05:36 +00:00
|
|
|
this->towns.SetListing(this->last_sorting);
|
2009-08-30 14:39:59 +00:00
|
|
|
this->towns.SetSortFuncs(TownDirectoryWindow::sorter_funcs);
|
2008-05-27 20:05:36 +00:00
|
|
|
this->towns.ForceRebuild();
|
2009-07-03 21:38:41 +00:00
|
|
|
this->BuildSortTownList();
|
2009-07-04 14:13:23 +00:00
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
this->FinishInitNested(0);
|
2019-07-22 19:27:39 +00:00
|
|
|
|
|
|
|
this->querystrings[WID_TD_FILTER] = &this->townname_editbox;
|
|
|
|
this->townname_editbox.cancel_button = QueryString::ACTION_CLEAR;
|
2008-05-19 09:17:26 +00:00
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void SetStringParameters(int widget) const override
|
2009-07-25 11:54:53 +00:00
|
|
|
{
|
2013-03-17 15:41:40 +00:00
|
|
|
switch (widget) {
|
|
|
|
case WID_TD_WORLD_POPULATION:
|
|
|
|
SetDParam(0, GetWorldPopulation());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WID_TD_SORT_CRITERIA:
|
|
|
|
SetDParam(0, TownDirectoryWindow::sorter_names[this->towns.SortType()]);
|
|
|
|
break;
|
|
|
|
}
|
2009-07-25 11:54:53 +00:00
|
|
|
}
|
|
|
|
|
2018-06-23 12:02:50 +00:00
|
|
|
/**
|
|
|
|
* Get the string to draw the town name.
|
|
|
|
* @param t Town to draw.
|
|
|
|
* @return The string to use.
|
|
|
|
*/
|
|
|
|
static StringID GetTownString(const Town *t)
|
|
|
|
{
|
|
|
|
return t->larger_town ? STR_TOWN_DIRECTORY_CITY : STR_TOWN_DIRECTORY_TOWN;
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void DrawWidget(const Rect &r, int widget) const override
|
2009-06-28 22:23:26 +00:00
|
|
|
{
|
2009-08-09 14:40:34 +00:00
|
|
|
switch (widget) {
|
2013-03-17 15:41:40 +00:00
|
|
|
case WID_TD_SORT_ORDER:
|
|
|
|
this->DrawSortButtonState(widget, this->towns.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
|
2009-06-28 22:23:26 +00:00
|
|
|
break;
|
2004-09-07 19:01:06 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TD_LIST: {
|
2009-06-28 22:23:26 +00:00
|
|
|
int n = 0;
|
2009-08-30 15:25:20 +00:00
|
|
|
int y = r.top + WD_FRAMERECT_TOP;
|
2018-09-23 11:23:54 +00:00
|
|
|
if (this->towns.size() == 0) { // No towns available.
|
2009-09-05 11:27:28 +00:00
|
|
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right, y, STR_TOWN_DIRECTORY_NONE);
|
|
|
|
break;
|
|
|
|
}
|
2012-04-17 19:44:41 +00:00
|
|
|
|
2009-09-05 11:27:28 +00:00
|
|
|
/* At least one town available. */
|
2012-04-17 19:44:41 +00:00
|
|
|
bool rtl = _current_text_dir == TD_RTL;
|
|
|
|
Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
|
|
|
|
int text_left = r.left + WD_FRAMERECT_LEFT + (rtl ? 0 : icon_size.width + 2);
|
|
|
|
int text_right = r.right - WD_FRAMERECT_RIGHT - (rtl ? icon_size.width + 2 : 0);
|
|
|
|
int icon_x = rtl ? r.right - WD_FRAMERECT_RIGHT - icon_size.width : r.left + WD_FRAMERECT_LEFT;
|
|
|
|
|
2018-09-23 11:23:54 +00:00
|
|
|
for (uint i = this->vscroll->GetPosition(); i < this->towns.size(); i++) {
|
2009-06-28 22:23:26 +00:00
|
|
|
const Town *t = this->towns[i];
|
|
|
|
assert(t->xy != INVALID_TILE);
|
2008-05-19 09:17:26 +00:00
|
|
|
|
2012-04-17 19:44:41 +00:00
|
|
|
/* Draw rating icon. */
|
|
|
|
if (_game_mode == GM_EDITOR || !HasBit(t->have_ratings, _local_company)) {
|
|
|
|
DrawSprite(SPR_TOWN_RATING_NA, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2);
|
|
|
|
} else {
|
|
|
|
SpriteID icon = SPR_TOWN_RATING_APALLING;
|
|
|
|
if (t->ratings[_local_company] > RATING_VERYPOOR) icon = SPR_TOWN_RATING_MEDIOCRE;
|
|
|
|
if (t->ratings[_local_company] > RATING_GOOD) icon = SPR_TOWN_RATING_GOOD;
|
|
|
|
DrawSprite(icon, PAL_NONE, icon_x, y + (this->resize.step_height - icon_size.height) / 2);
|
|
|
|
}
|
|
|
|
|
2009-06-28 22:23:26 +00:00
|
|
|
SetDParam(0, t->index);
|
2012-04-25 20:50:13 +00:00
|
|
|
SetDParam(1, t->cache.population);
|
2018-06-23 12:02:50 +00:00
|
|
|
DrawString(text_left, text_right, y + (this->resize.step_height - FONT_HEIGHT_NORMAL) / 2, GetTownString(t));
|
2008-05-19 09:17:26 +00:00
|
|
|
|
2009-08-30 15:25:20 +00:00
|
|
|
y += this->resize.step_height;
|
2010-08-12 08:37:01 +00:00
|
|
|
if (++n == this->vscroll->GetCapacity()) break; // max number of towns in 1 window
|
2009-06-28 22:23:26 +00:00
|
|
|
}
|
2010-08-01 18:53:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-05-19 09:17:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
2009-07-04 15:35:36 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2013-03-17 15:41:40 +00:00
|
|
|
case WID_TD_SORT_ORDER: {
|
2009-09-19 11:31:12 +00:00
|
|
|
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
|
2014-10-05 11:20:02 +00:00
|
|
|
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
|
2009-07-18 10:46:55 +00:00
|
|
|
d.height += padding.height;
|
|
|
|
*size = maxdim(*size, d);
|
2009-07-04 15:35:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-03-17 15:41:40 +00:00
|
|
|
case WID_TD_SORT_CRITERIA: {
|
|
|
|
Dimension d = {0, 0};
|
|
|
|
for (uint i = 0; TownDirectoryWindow::sorter_names[i] != INVALID_STRING_ID; i++) {
|
|
|
|
d = maxdim(d, GetStringBoundingBox(TownDirectoryWindow::sorter_names[i]));
|
|
|
|
}
|
|
|
|
d.width += padding.width;
|
|
|
|
d.height += padding.height;
|
|
|
|
*size = maxdim(*size, d);
|
|
|
|
break;
|
|
|
|
}
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TD_LIST: {
|
2009-09-05 11:27:28 +00:00
|
|
|
Dimension d = GetStringBoundingBox(STR_TOWN_DIRECTORY_NONE);
|
2018-09-23 11:23:54 +00:00
|
|
|
for (uint i = 0; i < this->towns.size(); i++) {
|
2009-07-04 15:35:36 +00:00
|
|
|
const Town *t = this->towns[i];
|
|
|
|
|
2019-04-10 21:07:06 +00:00
|
|
|
assert(t != nullptr);
|
2009-07-04 15:35:36 +00:00
|
|
|
|
|
|
|
SetDParam(0, t->index);
|
2012-12-08 17:18:51 +00:00
|
|
|
SetDParamMaxDigits(1, 8);
|
2018-06-23 12:02:50 +00:00
|
|
|
d = maxdim(d, GetStringBoundingBox(GetTownString(t)));
|
2009-07-04 15:35:36 +00:00
|
|
|
}
|
2012-04-17 19:44:41 +00:00
|
|
|
Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
|
|
|
|
d.width += icon_size.width + 2;
|
|
|
|
d.height = max(d.height, icon_size.height);
|
2010-08-16 08:33:28 +00:00
|
|
|
resize->height = d.height;
|
|
|
|
d.height *= 5;
|
2009-08-30 15:25:20 +00:00
|
|
|
d.width += padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
2010-08-16 08:33:28 +00:00
|
|
|
d.height += padding.height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
2009-07-18 10:46:55 +00:00
|
|
|
*size = maxdim(*size, d);
|
2009-07-04 15:35:36 +00:00
|
|
|
break;
|
2009-07-18 10:46:55 +00:00
|
|
|
}
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TD_WORLD_POPULATION: {
|
2012-12-08 17:18:51 +00:00
|
|
|
SetDParamMaxDigits(0, 10);
|
2009-07-18 10:46:55 +00:00
|
|
|
Dimension d = GetStringBoundingBox(STR_TOWN_POPULATION);
|
|
|
|
d.width += padding.width;
|
|
|
|
d.height += padding.height;
|
|
|
|
*size = maxdim(*size, d);
|
2009-07-04 15:35:36 +00:00
|
|
|
break;
|
2009-07-18 10:46:55 +00:00
|
|
|
}
|
2009-07-04 15:35:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
2008-05-19 09:17:26 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2013-03-17 15:41:40 +00:00
|
|
|
case WID_TD_SORT_ORDER: // Click on sort order button
|
2013-03-17 15:45:24 +00:00
|
|
|
if (this->towns.SortType() != 2) { // A different sort than by rating.
|
|
|
|
this->towns.ToggleSortOrder();
|
|
|
|
this->last_sorting = this->towns.GetListing(); // Store new sorting order.
|
|
|
|
} else {
|
|
|
|
/* Some parts are always sorted ascending on name. */
|
|
|
|
this->last_sorting.order = !this->last_sorting.order;
|
|
|
|
this->towns.SetListing(this->last_sorting);
|
|
|
|
this->towns.ForceResort();
|
|
|
|
this->towns.Sort();
|
|
|
|
}
|
2008-05-19 09:17:26 +00:00
|
|
|
this->SetDirty();
|
|
|
|
break;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2013-03-17 15:41:40 +00:00
|
|
|
case WID_TD_SORT_CRITERIA: // Click on sort criteria dropdown
|
|
|
|
ShowDropDownMenu(this, TownDirectoryWindow::sorter_names, this->towns.SortType(), WID_TD_SORT_CRITERIA, 0, 0);
|
2008-05-19 09:17:26 +00:00
|
|
|
break;
|
2006-08-15 07:07:17 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TD_LIST: { // Click on Town Matrix
|
|
|
|
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_TD_LIST, WD_FRAMERECT_TOP);
|
2018-09-23 11:23:54 +00:00
|
|
|
if (id_v >= this->towns.size()) return; // click out of town bounds
|
2008-04-14 17:06:36 +00:00
|
|
|
|
2008-05-27 20:05:36 +00:00
|
|
|
const Town *t = this->towns[id_v];
|
2019-04-10 21:07:06 +00:00
|
|
|
assert(t != nullptr);
|
2008-05-19 09:17:26 +00:00
|
|
|
if (_ctrl_pressed) {
|
|
|
|
ShowExtraViewPortWindow(t->xy);
|
|
|
|
} else {
|
|
|
|
ScrollMainWindowToTile(t->xy);
|
|
|
|
}
|
|
|
|
break;
|
2008-04-14 17:06:36 +00:00
|
|
|
}
|
2008-05-19 09:17:26 +00:00
|
|
|
}
|
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnDropdownSelect(int widget, int index) override
|
2013-03-17 15:41:40 +00:00
|
|
|
{
|
|
|
|
if (widget != WID_TD_SORT_CRITERIA) return;
|
|
|
|
|
|
|
|
if (this->towns.SortType() != index) {
|
|
|
|
this->towns.SetSortType(index);
|
2013-03-17 15:42:50 +00:00
|
|
|
this->last_sorting = this->towns.GetListing(); // Store new sorting order.
|
2013-03-17 15:41:40 +00:00
|
|
|
this->BuildSortTownList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnPaint() override
|
2011-03-08 20:52:59 +00:00
|
|
|
{
|
|
|
|
if (this->towns.NeedRebuild()) this->BuildSortTownList();
|
|
|
|
this->DrawWidgets();
|
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnHundredthTick() override
|
2008-05-19 09:17:26 +00:00
|
|
|
{
|
2009-07-03 21:38:41 +00:00
|
|
|
this->BuildSortTownList();
|
2008-05-19 09:17:26 +00:00
|
|
|
this->SetDirty();
|
|
|
|
}
|
2005-01-03 19:45:18 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnResize() override
|
2008-05-19 09:17:26 +00:00
|
|
|
{
|
2011-12-16 17:23:41 +00:00
|
|
|
this->vscroll->SetCapacityFromWidget(this, WID_TD_LIST);
|
2004-09-10 19:02:27 +00:00
|
|
|
}
|
2008-05-27 20:05:36 +00:00
|
|
|
|
2019-07-22 19:27:39 +00:00
|
|
|
virtual void OnEditboxChanged(int wid)
|
|
|
|
{
|
|
|
|
if (wid == WID_TD_FILTER) {
|
|
|
|
this->string_filter.SetFilterTerm(this->townname_editbox.text.buf);
|
|
|
|
this->InvalidateData(TDIWD_FILTER_CHANGES);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-13 21:31:29 +00:00
|
|
|
/**
|
|
|
|
* Some data on this window has become invalid.
|
|
|
|
* @param data Information about the changed data.
|
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
|
*/
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
2008-05-27 20:05:36 +00:00
|
|
|
{
|
2019-07-22 19:27:39 +00:00
|
|
|
char buf[MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH];
|
|
|
|
|
|
|
|
switch (data) {
|
|
|
|
case TDIWD_FORCE_REBUILD:
|
|
|
|
/* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
|
|
|
|
this->towns.ForceRebuild();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TDIWD_FILTER_CHANGES:
|
|
|
|
if (this->string_filter.IsEmpty()) {
|
|
|
|
this->towns.ForceRebuild();
|
|
|
|
} else {
|
|
|
|
this->towns.clear();
|
|
|
|
|
|
|
|
const Town *t;
|
|
|
|
FOR_ALL_TOWNS(t) {
|
|
|
|
this->string_filter.ResetState();
|
|
|
|
|
|
|
|
SetDParam(0, t->index);
|
|
|
|
GetString(buf, STR_TOWN_NAME, lastof(buf));
|
|
|
|
|
|
|
|
this->string_filter.AddLine(buf);
|
|
|
|
if (this->string_filter.GetState()) this->towns.push_back(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->towns.SetListing(this->last_sorting);
|
|
|
|
this->towns.ForceResort();
|
|
|
|
this->towns.Sort();
|
|
|
|
this->towns.shrink_to_fit();
|
|
|
|
this->towns.RebuildDone();
|
|
|
|
this->vscroll->SetCount(this->towns.size()); // Update scrollbar as well.
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
this->towns.ForceResort();
|
2008-05-27 20:05:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Listing TownDirectoryWindow::last_sorting = {false, 0};
|
2019-04-10 21:07:06 +00:00
|
|
|
const Town *TownDirectoryWindow::last_town = nullptr;
|
2008-05-27 20:05:36 +00:00
|
|
|
|
2013-03-17 15:41:40 +00:00
|
|
|
/** Names of the sorting functions. */
|
|
|
|
const StringID TownDirectoryWindow::sorter_names[] = {
|
|
|
|
STR_SORT_BY_NAME,
|
|
|
|
STR_SORT_BY_POPULATION,
|
2013-03-17 15:45:24 +00:00
|
|
|
STR_SORT_BY_RATING,
|
2013-03-17 15:41:40 +00:00
|
|
|
INVALID_STRING_ID
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Available town directory sorting functions. */
|
2008-05-27 21:41:00 +00:00
|
|
|
GUITownList::SortFunction * const TownDirectoryWindow::sorter_funcs[] = {
|
2008-05-27 20:05:36 +00:00
|
|
|
&TownNameSorter,
|
|
|
|
&TownPopulationSorter,
|
2013-03-17 15:45:24 +00:00
|
|
|
&TownRatingSorter,
|
2008-05-19 09:17:26 +00:00
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
static WindowDesc _town_directory_desc(
|
2013-05-26 19:25:01 +00:00
|
|
|
WDP_AUTO, "list_towns", 208, 202,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_TOWN_DIRECTORY, WC_NONE,
|
2012-11-11 16:10:43 +00:00
|
|
|
0,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_town_directory_widgets, lengthof(_nested_town_directory_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void ShowTownDirectory()
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-05-25 15:57:45 +00:00
|
|
|
if (BringWindowToFrontById(WC_TOWN_DIRECTORY, 0)) return;
|
2008-05-19 09:17:26 +00:00
|
|
|
new TownDirectoryWindow(&_town_directory_desc);
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2019-09-07 16:37:01 +00:00
|
|
|
void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2010-01-11 18:46:09 +00:00
|
|
|
if (result.Failed()) return;
|
|
|
|
|
2014-03-23 13:28:32 +00:00
|
|
|
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT_OTHER, tile);
|
2010-01-11 18:46:09 +00:00
|
|
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2019-09-07 16:37:01 +00:00
|
|
|
void CcFoundRandomTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
|
2009-09-21 20:22:56 +00:00
|
|
|
{
|
2010-01-11 18:46:09 +00:00
|
|
|
if (result.Succeeded()) ScrollMainWindowToTile(Town::Get(_new_town_id)->xy);
|
2009-09-21 20:22:56 +00:00
|
|
|
}
|
|
|
|
|
2009-04-12 19:30:47 +00:00
|
|
|
static const NWidgetPart _nested_found_town_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
|
|
|
|
NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_FOUND_TOWN_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
|
|
|
/* Construct new town(s) buttons. */
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
|
2009-04-12 19:30:47 +00:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 2),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_NEW_TOWN), SetMinimalSize(156, 12), SetFill(1, 0),
|
2009-07-03 22:25:59 +00:00
|
|
|
SetDataTip(STR_FOUND_TOWN_NEW_TOWN_BUTTON, STR_FOUND_TOWN_NEW_TOWN_TOOLTIP), SetPadding(0, 2, 1, 2),
|
2012-11-11 16:07:46 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_RANDOM_TOWN), SetMinimalSize(156, 12), SetFill(1, 0),
|
2009-04-21 23:40:56 +00:00
|
|
|
SetDataTip(STR_FOUND_TOWN_RANDOM_TOWN_BUTTON, STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP), SetPadding(0, 2, 1, 2),
|
2012-11-11 16:07:46 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_MANY_RANDOM_TOWNS), SetMinimalSize(156, 12), SetFill(1, 0),
|
2009-08-05 17:59:21 +00:00
|
|
|
SetDataTip(STR_FOUND_TOWN_MANY_RANDOM_TOWNS, STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP), SetPadding(0, 2, 0, 2),
|
2009-09-22 13:54:54 +00:00
|
|
|
/* Town name selection. */
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(156, 14), SetPadding(0, 2, 0, 2), SetDataTip(STR_FOUND_TOWN_NAME_TITLE, STR_NULL),
|
2012-11-14 22:50:53 +00:00
|
|
|
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_TF_TOWN_NAME_EDITBOX), SetMinimalSize(156, 12), SetPadding(0, 2, 3, 2),
|
2009-12-21 21:12:41 +00:00
|
|
|
SetDataTip(STR_FOUND_TOWN_NAME_EDITOR_TITLE, STR_FOUND_TOWN_NAME_EDITOR_HELP),
|
2012-11-11 16:07:46 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_TOWN_NAME_RANDOM), SetMinimalSize(78, 12), SetPadding(0, 2, 0, 2), SetFill(1, 0),
|
2009-09-22 13:54:54 +00:00
|
|
|
SetDataTip(STR_FOUND_TOWN_NAME_RANDOM_BUTTON, STR_FOUND_TOWN_NAME_RANDOM_TOOLTIP),
|
2009-04-12 19:30:47 +00:00
|
|
|
/* Town size selection. */
|
2009-12-21 21:12:41 +00:00
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(148, 14), SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_TITLE, STR_NULL),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
2009-07-03 22:25:59 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(2, 0, 2),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_SIZE_SMALL), SetMinimalSize(78, 12), SetFill(1, 0),
|
2009-07-03 22:25:59 +00:00
|
|
|
SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_SMALL_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_SIZE_MEDIUM), SetMinimalSize(78, 12), SetFill(1, 0),
|
2009-07-03 22:25:59 +00:00
|
|
|
SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_MEDIUM_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 1),
|
2009-07-03 22:25:59 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(2, 0, 2),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_SIZE_LARGE), SetMinimalSize(78, 12), SetFill(1, 0),
|
2009-07-03 22:25:59 +00:00
|
|
|
SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_LARGE_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_SIZE_RANDOM), SetMinimalSize(78, 12), SetFill(1, 0),
|
2009-08-05 17:59:21 +00:00
|
|
|
SetDataTip(STR_FOUND_TOWN_SIZE_RANDOM, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 3),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_CITY), SetPadding(0, 2, 0, 2), SetMinimalSize(156, 12), SetFill(1, 0),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetDataTip(STR_FOUND_TOWN_CITY, STR_FOUND_TOWN_CITY_TOOLTIP), SetFill(1, 0),
|
2009-04-12 19:30:47 +00:00
|
|
|
/* Town roads selection. */
|
2009-12-21 21:12:41 +00:00
|
|
|
NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(148, 14), SetDataTip(STR_FOUND_TOWN_ROAD_LAYOUT, STR_NULL),
|
2009-11-22 18:26:01 +00:00
|
|
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
2009-07-03 22:25:59 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(2, 0, 2),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_LAYOUT_ORIGINAL), SetMinimalSize(78, 12), SetFill(1, 0), SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_ORIGINAL, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_LAYOUT_BETTER), SetMinimalSize(78, 12), SetFill(1, 0), SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_BETTER_ROADS, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 1),
|
2009-07-03 22:25:59 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(2, 0, 2),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_LAYOUT_GRID2), SetMinimalSize(78, 12), SetFill(1, 0), SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_2X2_GRID, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_LAYOUT_GRID3), SetMinimalSize(78, 12), SetFill(1, 0), SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_3X3_GRID, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT),
|
2009-04-12 19:30:47 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 1),
|
2011-12-16 17:23:41 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_TF_LAYOUT_RANDOM), SetPadding(0, 2, 0, 2), SetMinimalSize(0, 12), SetFill(1, 0),
|
2009-11-22 18:26:01 +00:00
|
|
|
SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_RANDOM, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT), SetFill(1, 0),
|
2009-04-12 19:30:47 +00:00
|
|
|
NWidget(NWID_SPACER), SetMinimalSize(0, 2),
|
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-06-28 21:23:37 +00:00
|
|
|
/** Found a town window class. */
|
2012-11-14 22:50:35 +00:00
|
|
|
struct FoundTownWindow : Window {
|
2008-05-22 02:03:05 +00:00
|
|
|
private:
|
2009-09-14 20:40:07 +00:00
|
|
|
TownSize town_size; ///< Selected town size
|
|
|
|
TownLayout town_layout; ///< Selected town layout
|
|
|
|
bool city; ///< Are we building a city?
|
2012-11-14 22:50:35 +00:00
|
|
|
QueryString townname_editbox; ///< Townname editbox
|
2009-09-22 13:54:54 +00:00
|
|
|
bool townnamevalid; ///< Is generated town name valid?
|
|
|
|
uint32 townnameparts; ///< Generated town name
|
|
|
|
TownNameParams params; ///< Town name parameters
|
2009-02-05 15:59:40 +00:00
|
|
|
|
2008-05-22 02:03:05 +00:00
|
|
|
public:
|
2013-05-26 19:23:42 +00:00
|
|
|
FoundTownWindow(WindowDesc *desc, WindowNumber window_number) :
|
|
|
|
Window(desc),
|
2010-03-20 10:55:08 +00:00
|
|
|
town_size(TSZ_MEDIUM),
|
2009-09-14 20:40:07 +00:00
|
|
|
town_layout(_settings_game.economy.town_layout),
|
2012-11-14 22:50:35 +00:00
|
|
|
townname_editbox(MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_TOWN_NAME_CHARS),
|
2009-09-22 13:54:54 +00:00
|
|
|
params(_settings_game.game_creation.town_name)
|
2008-05-18 08:13:13 +00:00
|
|
|
{
|
2013-05-26 19:23:42 +00:00
|
|
|
this->InitNested(window_number);
|
2012-11-14 22:50:35 +00:00
|
|
|
this->querystrings[WID_TF_TOWN_NAME_EDITBOX] = &this->townname_editbox;
|
2009-09-22 13:54:54 +00:00
|
|
|
this->RandomTownName();
|
2009-11-24 21:18:11 +00:00
|
|
|
this->UpdateButtons(true);
|
2009-02-05 16:51:23 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 13:54:54 +00:00
|
|
|
void RandomTownName()
|
|
|
|
{
|
|
|
|
this->townnamevalid = GenerateTownName(&this->townnameparts);
|
|
|
|
|
|
|
|
if (!this->townnamevalid) {
|
2012-11-14 22:50:35 +00:00
|
|
|
this->townname_editbox.text.DeleteAll();
|
2009-09-22 13:54:54 +00:00
|
|
|
} else {
|
2012-11-14 22:50:35 +00:00
|
|
|
GetTownName(this->townname_editbox.text.buf, &this->params, this->townnameparts, &this->townname_editbox.text.buf[this->townname_editbox.text.max_bytes - 1]);
|
|
|
|
this->townname_editbox.text.UpdateSize();
|
2009-09-22 13:54:54 +00:00
|
|
|
}
|
2011-12-16 17:23:41 +00:00
|
|
|
UpdateOSKOriginalText(this, WID_TF_TOWN_NAME_EDITBOX);
|
2009-09-22 13:54:54 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
this->SetWidgetDirty(WID_TF_TOWN_NAME_EDITBOX);
|
2009-09-22 13:54:54 +00:00
|
|
|
}
|
|
|
|
|
2009-11-24 21:18:11 +00:00
|
|
|
void UpdateButtons(bool check_availability)
|
2009-02-05 16:51:23 +00:00
|
|
|
{
|
2009-11-24 21:18:11 +00:00
|
|
|
if (check_availability && _game_mode != GM_EDITOR) {
|
2011-12-16 17:23:41 +00:00
|
|
|
this->SetWidgetsDisabledState(true, WID_TF_RANDOM_TOWN, WID_TF_MANY_RANDOM_TOWNS, WID_TF_SIZE_LARGE, WIDGET_LIST_END);
|
2009-11-24 21:18:11 +00:00
|
|
|
this->SetWidgetsDisabledState(_settings_game.economy.found_town != TF_CUSTOM_LAYOUT,
|
2011-12-16 17:23:41 +00:00
|
|
|
WID_TF_LAYOUT_ORIGINAL, WID_TF_LAYOUT_BETTER, WID_TF_LAYOUT_GRID2, WID_TF_LAYOUT_GRID3, WID_TF_LAYOUT_RANDOM, WIDGET_LIST_END);
|
2009-11-24 21:18:11 +00:00
|
|
|
if (_settings_game.economy.found_town != TF_CUSTOM_LAYOUT) town_layout = _settings_game.economy.town_layout;
|
|
|
|
}
|
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
for (int i = WID_TF_SIZE_SMALL; i <= WID_TF_SIZE_RANDOM; i++) {
|
|
|
|
this->SetWidgetLoweredState(i, i == WID_TF_SIZE_SMALL + this->town_size);
|
2009-02-05 16:51:23 +00:00
|
|
|
}
|
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
this->SetWidgetLoweredState(WID_TF_CITY, this->city);
|
2009-02-05 16:51:23 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
for (int i = WID_TF_LAYOUT_ORIGINAL; i <= WID_TF_LAYOUT_RANDOM; i++) {
|
|
|
|
this->SetWidgetLoweredState(i, i == WID_TF_LAYOUT_ORIGINAL + this->town_layout);
|
2009-02-05 16:51:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this->SetDirty();
|
2008-05-18 08:13:13 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2009-09-21 20:22:56 +00:00
|
|
|
void ExecuteFoundTownCommand(TileIndex tile, bool random, StringID errstr, CommandCallback cc)
|
|
|
|
{
|
2019-04-10 21:07:06 +00:00
|
|
|
const char *name = nullptr;
|
2009-09-22 13:54:54 +00:00
|
|
|
|
|
|
|
if (!this->townnamevalid) {
|
2012-11-14 22:50:35 +00:00
|
|
|
name = this->townname_editbox.text.buf;
|
2009-09-22 13:54:54 +00:00
|
|
|
} else {
|
|
|
|
/* If user changed the name, send it */
|
2010-12-05 22:25:21 +00:00
|
|
|
char buf[MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH];
|
2009-09-22 13:54:54 +00:00
|
|
|
GetTownName(buf, &this->params, this->townnameparts, lastof(buf));
|
2012-11-14 22:50:35 +00:00
|
|
|
if (strcmp(buf, this->townname_editbox.text.buf) != 0) name = this->townname_editbox.text.buf;
|
2009-09-21 20:22:56 +00:00
|
|
|
}
|
|
|
|
|
2009-09-22 13:54:54 +00:00
|
|
|
bool success = DoCommandP(tile, this->town_size | this->city << 2 | this->town_layout << 3 | random << 6,
|
|
|
|
townnameparts, CMD_FOUND_TOWN | CMD_MSG(errstr), cc, name);
|
|
|
|
|
2015-07-26 09:56:43 +00:00
|
|
|
/* Rerandomise name, if success and no cost-estimation. */
|
|
|
|
if (success && !_shift_pressed) this->RandomTownName();
|
2009-09-21 20:22:56 +00:00
|
|
|
}
|
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
2008-05-18 08:13:13 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TF_NEW_TOWN:
|
|
|
|
HandlePlacePushButton(this, WID_TF_NEW_TOWN, SPR_CURSOR_TOWN, HT_RECT);
|
2008-05-18 08:13:13 +00:00
|
|
|
break;
|
2008-04-14 17:06:36 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TF_RANDOM_TOWN:
|
2009-09-21 20:22:56 +00:00
|
|
|
this->ExecuteFoundTownCommand(0, true, STR_ERROR_CAN_T_GENERATE_TOWN, CcFoundRandomTown);
|
|
|
|
break;
|
2008-04-14 17:06:36 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TF_TOWN_NAME_RANDOM:
|
2009-09-22 13:54:54 +00:00
|
|
|
this->RandomTownName();
|
2011-12-16 17:23:41 +00:00
|
|
|
this->SetFocusedWidget(WID_TF_TOWN_NAME_EDITBOX);
|
2009-09-22 13:54:54 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TF_MANY_RANDOM_TOWNS:
|
2008-05-18 08:13:13 +00:00
|
|
|
_generating_world = true;
|
2008-11-18 22:43:59 +00:00
|
|
|
UpdateNearestTownForRoadTiles(true);
|
2009-09-14 20:40:07 +00:00
|
|
|
if (!GenerateTowns(this->town_layout)) {
|
2010-02-24 14:46:15 +00:00
|
|
|
ShowErrorMessage(STR_ERROR_CAN_T_GENERATE_TOWN, STR_ERROR_NO_SPACE_FOR_TOWN, WL_INFO);
|
2008-10-25 13:51:47 +00:00
|
|
|
}
|
2008-11-18 22:43:59 +00:00
|
|
|
UpdateNearestTownForRoadTiles(false);
|
2008-05-18 08:13:13 +00:00
|
|
|
_generating_world = false;
|
|
|
|
break;
|
2008-04-14 17:06:36 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TF_SIZE_SMALL: case WID_TF_SIZE_MEDIUM: case WID_TF_SIZE_LARGE: case WID_TF_SIZE_RANDOM:
|
|
|
|
this->town_size = (TownSize)(widget - WID_TF_SIZE_SMALL);
|
2009-11-24 21:18:11 +00:00
|
|
|
this->UpdateButtons(false);
|
2009-02-05 15:28:01 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TF_CITY:
|
2009-09-14 20:40:07 +00:00
|
|
|
this->city ^= true;
|
2011-12-16 17:23:41 +00:00
|
|
|
this->SetWidgetLoweredState(WID_TF_CITY, this->city);
|
2008-05-18 08:13:13 +00:00
|
|
|
this->SetDirty();
|
|
|
|
break;
|
2009-02-04 22:52:34 +00:00
|
|
|
|
2011-12-16 17:23:41 +00:00
|
|
|
case WID_TF_LAYOUT_ORIGINAL: case WID_TF_LAYOUT_BETTER: case WID_TF_LAYOUT_GRID2:
|
|
|
|
case WID_TF_LAYOUT_GRID3: case WID_TF_LAYOUT_RANDOM:
|
|
|
|
this->town_layout = (TownLayout)(widget - WID_TF_LAYOUT_ORIGINAL);
|
2009-11-24 21:18:11 +00:00
|
|
|
this->UpdateButtons(false);
|
2009-02-04 22:52:34 +00:00
|
|
|
break;
|
2008-05-18 08:13:13 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-14 17:06:36 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnPlaceObject(Point pt, TileIndex tile) override
|
2009-02-05 15:59:40 +00:00
|
|
|
{
|
2009-09-21 20:22:56 +00:00
|
|
|
this->ExecuteFoundTownCommand(tile, false, STR_ERROR_CAN_T_FOUND_TOWN_HERE, CcFoundTown);
|
2009-02-05 15:59:40 +00:00
|
|
|
}
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnPlaceObjectAbort() override
|
2009-09-14 20:40:07 +00:00
|
|
|
{
|
|
|
|
this->RaiseButtons();
|
2009-11-24 21:18:11 +00:00
|
|
|
this->UpdateButtons(false);
|
|
|
|
}
|
|
|
|
|
2011-03-13 21:31:29 +00:00
|
|
|
/**
|
|
|
|
* Some data on this window has become invalid.
|
|
|
|
* @param data Information about the changed data.
|
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
|
*/
|
2019-03-04 07:49:37 +00:00
|
|
|
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
2009-11-24 21:18:11 +00:00
|
|
|
{
|
2011-03-13 21:31:29 +00:00
|
|
|
if (!gui_scope) return;
|
2009-11-24 21:18:11 +00:00
|
|
|
this->UpdateButtons(true);
|
2009-09-14 20:40:07 +00:00
|
|
|
}
|
|
|
|
};
|
2009-02-05 15:59:40 +00:00
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
static WindowDesc _found_town_desc(
|
2013-05-26 19:25:01 +00:00
|
|
|
WDP_AUTO, "build_town", 160, 162,
|
2009-02-17 00:21:08 +00:00
|
|
|
WC_FOUND_TOWN, WC_NONE,
|
2012-11-11 16:10:43 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_found_town_widgets, lengthof(_nested_found_town_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2008-03-23 07:35:29 +00:00
|
|
|
|
2009-09-21 18:16:00 +00:00
|
|
|
void ShowFoundTownWindow()
|
2008-03-23 07:35:29 +00:00
|
|
|
{
|
2009-05-17 01:00:56 +00:00
|
|
|
if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return;
|
2009-02-17 00:21:08 +00:00
|
|
|
AllocateWindowDescFront<FoundTownWindow>(&_found_town_desc, 0);
|
2008-03-23 07:35:29 +00:00
|
|
|
}
|
2019-01-05 13:22:07 +00:00
|
|
|
|
|
|
|
void InitializeTownGui()
|
|
|
|
{
|
|
|
|
_town_local_authority_kdtree.Clear();
|
|
|
|
}
|