38 #include "table/strings.h" 42 TownKdtree _town_local_authority_kdtree(&Kdtree_TownXYFunc);
46 static const NWidgetPart _nested_town_authority_widgets[] = {
57 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(),
62 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),
109 if (buttons != displayed_actions_on_previous_painting) this->
SetDirty();
110 displayed_actions_on_previous_painting = buttons;
112 this->vscroll->
SetCount(numact + 1);
114 if (this->sel_index != -1 && !
HasBit(buttons, this->sel_index)) {
115 this->sel_index = -1;
134 DrawString(left, right, y, STR_LOCAL_AUTHORITY_COMPANY_RATINGS);
138 int icon_width = icon_size.width;
142 int exclusive_width = exclusive_size.width;
146 uint text_left = left + (rtl ? 0 : icon_width + exclusive_width + 4);
147 uint text_right = right - (rtl ? icon_width + exclusive_width + 4 : 0);
148 uint icon_left = rtl ? right - icon_width :
left;
149 uint exclusive_left = rtl ? right - icon_width - exclusive_width - 2 : left + icon_width + 2;
159 int r = this->town->
ratings[c->index];
160 StringID str = STR_CARGO_RATING_APPALLING;
161 if (r > RATING_APPALLING) str++;
162 if (r > RATING_VERYPOOR) str++;
163 if (r > RATING_POOR) str++;
164 if (r > RATING_MEDIOCRE) str++;
165 if (r > RATING_GOOD) str++;
166 if (r > RATING_VERYGOOD) str++;
167 if (r > RATING_EXCELLENT) str++;
171 DrawSprite(SPR_EXCLUSIVE_TRANSPORT, COMPANY_SPRITE_COLOUR(c->index), exclusive_left, y + exclusive_y_offset);
174 DrawString(text_left, text_right, y, STR_LOCAL_AUTHORITY_COMPANY_RATING);
195 if (this->sel_index != -1) {
198 STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + this->sel_index);
212 for (
int i = 0; buttons; i++, buttons >>= 1) {
213 if (pos <= -5)
break;
215 if ((buttons & 1) && --pos < 0) {
217 STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i, this->sel_index == i ? TC_WHITE : TC_ORANGE);
230 assert(size->width > padding.width && size->height > padding.height);
264 bool new_show_state = !this->town->
show_zone;
265 TownID index = this->town->
index;
267 new_show_state ? _town_local_authority_kdtree.
Insert(index) : _town_local_authority_kdtree.
Remove(index);
285 if (click_count == 1 || y < 0)
break;
302 WDP_AUTO,
"view_town_authority", 317, 222,
305 _nested_town_authority_widgets,
lengthof(_nested_town_authority_widgets)
308 static void ShowTownAuthorityWindow(uint
town)
310 AllocateWindowDescFront<TownAuthorityWindow>(&_town_authority_desc,
town);
320 static const int WID_TV_HEIGHT_NORMAL = 150;
378 for (
int i = TE_BEGIN; i <
TE_END; i++) {
379 if (this->town->
goal[i] == 0)
continue;
393 assert(cargo !=
nullptr);
399 string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL;
401 string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_GENERAL;
404 string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER;
410 string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED;
412 string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED;
437 if (this->town->
text !=
nullptr) {
469 static bool _warn_town_no_roads =
false;
473 _warn_town_no_roads =
true;
490 size->height = GetDesiredInfoHeight(size->width);
504 for (
int i = TE_BEGIN; i <
TE_END; i++) {
505 if (this->town->
goal[i] == 0)
continue;
519 if (this->town->
text !=
nullptr) {
527 void ResizeWindowAsNeeded()
530 uint aimed_height = GetDesiredInfoHeight(nwid_info->
current_x);
553 if (!gui_scope)
return;
556 this->ResizeWindowAsNeeded();
561 if (str ==
nullptr)
return;
567 static const NWidgetPart _nested_town_game_view_widgets[] = {
577 NWidget(
NWID_VIEWPORT, INVALID_COLOUR,
WID_TV_VIEWPORT),
SetMinimalSize(254, 86),
SetFill(1, 0),
SetResize(1, 1),
SetPadding(1, 1, 1, 1),
580 NWidget(
WWT_PANEL, COLOUR_BROWN,
WID_TV_INFO),
SetMinimalSize(260, 32),
SetResize(1, 0),
SetFill(1, 0),
EndContainer(),
583 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),
584 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),
585 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),
593 WDP_AUTO,
"view_town", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL,
596 _nested_town_game_view_widgets,
lengthof(_nested_town_game_view_widgets)
599 static const NWidgetPart _nested_town_editor_view_widgets[] = {
610 NWidget(
NWID_VIEWPORT, INVALID_COLOUR,
WID_TV_VIEWPORT),
SetMinimalSize(254, 86),
SetFill(1, 1),
SetResize(1, 1),
SetPadding(1, 1, 1, 1),
613 NWidget(
WWT_PANEL, COLOUR_BROWN,
WID_TV_INFO),
SetMinimalSize(260, 32),
SetResize(1, 0),
SetFill(1, 0),
EndContainer(),
616 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),
617 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),
618 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),
626 WDP_AUTO,
"view_town_scen", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL,
629 _nested_town_editor_view_widgets,
lengthof(_nested_town_editor_view_widgets)
632 void ShowTownViewWindow(TownID
town)
634 if (_game_mode == GM_EDITOR) {
635 AllocateWindowDescFront<TownViewWindow>(&_town_editor_view_desc,
town);
637 AllocateWindowDescFront<TownViewWindow>(&_town_game_view_desc,
town);
641 static const NWidgetPart _nested_town_directory_widgets[] = {
659 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),
674 static const Town *last_town;
687 void BuildSortTownList()
693 this->towns.push_back(t);
696 this->towns.shrink_to_fit();
698 this->vscroll->
SetCount((uint)this->towns.size());
701 this->last_town =
nullptr;
713 GetString(buf, STR_TOWN_NAME,
lastof(buf));
718 if (b != last_town) {
721 GetString(buf_cache, STR_TOWN_NAME,
lastof(buf_cache));
733 return a_population < b_population;
739 bool before = !TownDirectoryWindow::last_sorting.
order;
747 return a_rating < b_rating;
768 this->BuildSortTownList();
796 return t->
larger_town ? STR_TOWN_DIRECTORY_CITY : STR_TOWN_DIRECTORY_TOWN;
809 if (this->towns.size() == 0) {
821 for (uint i = this->vscroll->
GetPosition(); i < this->towns.size(); i++) {
822 const Town *t = this->towns[i];
829 SpriteID icon = SPR_TOWN_RATING_APALLING;
853 d.height += padding.height;
862 d.width += padding.width;
863 d.height += padding.height;
869 for (uint i = 0; i < this->towns.size(); i++) {
870 const Town *t = this->towns[i];
872 assert(t !=
nullptr);
879 d.width += icon_size.width + 2;
880 d.height =
max(d.height, icon_size.height);
881 resize->height = d.height;
891 d.width += padding.width;
892 d.height += padding.height;
905 this->last_sorting = this->towns.
GetListing();
908 this->last_sorting.
order = !this->last_sorting.
order;
922 if (id_v >= this->towns.size())
return;
924 const Town *t = this->towns[id_v];
925 assert(t !=
nullptr);
940 if (this->towns.
SortType() != index) {
942 this->last_sorting = this->towns.
GetListing();
943 this->BuildSortTownList();
949 if (this->towns.
NeedRebuild()) this->BuildSortTownList();
955 this->BuildSortTownList();
982 case TDIWD_FORCE_REBUILD:
988 if (this->string_filter.
IsEmpty()) {
997 GetString(buf, STR_TOWN_NAME,
lastof(buf));
999 this->string_filter.
AddLine(buf);
1000 if (this->string_filter.
GetState()) this->towns.push_back(t);
1006 this->towns.shrink_to_fit();
1008 this->vscroll->
SetCount((
int)this->towns.size());
1017 Listing TownDirectoryWindow::last_sorting = {
false, 0};
1018 const Town *TownDirectoryWindow::last_town =
nullptr;
1023 STR_SORT_BY_POPULATION,
1031 &TownPopulationSorter,
1039 _nested_town_directory_widgets,
lengthof(_nested_town_directory_widgets)
1042 void ShowTownDirectory()
1050 if (result.
Failed())
return;
1056 void CcFoundRandomTown(
const CommandCost &result,
TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
1061 static const NWidgetPart _nested_found_town_widgets[] = {
1072 SetDataTip(STR_FOUND_TOWN_NEW_TOWN_BUTTON, STR_FOUND_TOWN_NEW_TOWN_TOOLTIP),
SetPadding(0, 2, 1, 2),
1074 SetDataTip(STR_FOUND_TOWN_RANDOM_TOWN_BUTTON, STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP),
SetPadding(0, 2, 1, 2),
1076 SetDataTip(STR_FOUND_TOWN_MANY_RANDOM_TOWNS, STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP),
SetPadding(0, 2, 0, 2),
1078 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(156, 14),
SetPadding(0, 2, 0, 2),
SetDataTip(STR_FOUND_TOWN_NAME_TITLE, STR_NULL),
1080 SetDataTip(STR_FOUND_TOWN_NAME_EDITOR_TITLE, STR_FOUND_TOWN_NAME_EDITOR_HELP),
1081 NWidget(
WWT_PUSHTXTBTN, COLOUR_GREY,
WID_TF_TOWN_NAME_RANDOM),
SetMinimalSize(78, 12),
SetPadding(0, 2, 0, 2),
SetFill(1, 0),
1082 SetDataTip(STR_FOUND_TOWN_NAME_RANDOM_BUTTON, STR_FOUND_TOWN_NAME_RANDOM_TOOLTIP),
1091 SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_SMALL_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
1093 SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_MEDIUM_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
1098 SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_LARGE_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
1100 SetDataTip(STR_FOUND_TOWN_SIZE_RANDOM, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
1103 NWidget(
WWT_TEXTBTN, COLOUR_GREY,
WID_TF_CITY),
SetPadding(0, 2, 0, 2),
SetMinimalSize(156, 12),
SetFill(1, 0),
1121 NWidget(
WWT_TEXTBTN, COLOUR_GREY,
WID_TF_LAYOUT_RANDOM),
SetPadding(0, 2, 0, 2),
SetMinimalSize(0, 12),
SetFill(1, 0),
1122 SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_RANDOM, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT),
SetFill(1, 0),
1148 this->RandomTownName();
1149 this->UpdateButtons(
true);
1152 void RandomTownName()
1156 if (!this->townnamevalid) {
1157 this->townname_editbox.text.
DeleteAll();
1159 GetTownName(this->townname_editbox.text.
buf, &this->params, this->townnameparts, &this->townname_editbox.text.buf[this->townname_editbox.text.max_bytes - 1]);
1167 void UpdateButtons(
bool check_availability)
1169 if (check_availability && _game_mode != GM_EDITOR) {
1191 const char *name =
nullptr;
1193 if (!this->townnamevalid) {
1194 name = this->townname_editbox.text.
buf;
1199 if (strcmp(buf, this->townname_editbox.text.
buf) != 0) name = this->townname_editbox.text.
buf;
1202 bool success =
DoCommandP(tile, this->town_size | this->city << 2 | this->town_layout << 3 | random << 6,
1217 this->ExecuteFoundTownCommand(0,
true, STR_ERROR_CAN_T_GENERATE_TOWN, CcFoundRandomTown);
1221 this->RandomTownName();
1237 this->UpdateButtons(
false);
1249 this->UpdateButtons(
false);
1256 this->ExecuteFoundTownCommand(tile,
false, STR_ERROR_CAN_T_FOUND_TOWN_HERE, CcFoundTown);
1262 this->UpdateButtons(
false);
1272 if (!gui_scope)
return;
1273 this->UpdateButtons(
true);
1281 _nested_found_town_widgets,
lengthof(_nested_found_town_widgets)
1284 void ShowFoundTownWindow()
1287 AllocateWindowDescFront<FoundTownWindow>(&_found_town_desc, 0);
1290 void InitializeTownGui()
1292 _town_local_authority_kdtree.
Clear();
Functions related to OTTD's strings.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
static const uint TOWN_GROWTH_WINTER
The town only needs this cargo in the winter (any amount)
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
Base types for having sorted lists in GUIs.
void RebuildDone()
Notify the sortlist that the rebuild is done.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of stuff that is very close to a company, like the company struct itself.
void UpdateNearestTownForRoadTiles(bool invalidate)
Updates cached nearest town for all road tiles.
bool _networking
are we in networking mode?
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
TransportedCargoStat< uint16 > received[NUM_TE]
Cargo statistics about received cargotypes.
ResizeInfo resize
Resize information.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
uint displayed_actions_on_previous_painting
Actions that were available on the previous call to OnPaint()
byte LowestSnowLine()
Get the lowest possible snow line height, either variable or static.
High level window description.
EconomySettings economy
settings to change the economy
WindowFlags flags
Window flags.
int left
x position of left edge of the window
void DrawWidgets() const
Paint all widgets of a window.
static Titem * Get(size_t index)
Returns Titem with given index.
Declarations for accessing the k-d tree of towns.
void DrawRatings()
Draw the contents of the ratings panel.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Offset at top to draw the frame rectangular area.
void ResetState()
Reset the matching state to process a new item.
int sel_index
Currently selected town action, 0 to TACT_COUNT-1, -1 means no action selected.
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
bool GetState() const
Get the matching state of the current item.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Specification of a cargo type.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
void OnHundredthTick() override
Called once every 100 (game) ticks.
void CDECL void DeleteAll()
Delete every character in the textbuffer.
bool GenerateTownName(uint32 *townnameparts, TownNames *town_names)
Generates valid town name.
QueryString townname_editbox
Townname editbox.
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
static const int ACTION_CLEAR
Clear editbox.
TownSize town_size
Selected town size.
TownFounding found_town
town founding.
bool city
Are we building a city?
Tindex index
Index of this pool item.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
bool show_zone
NOSAVE: mark town to show the local authority zone in the viewports.
static bool TownRatingSorter(const Town *const &a, const Town *const &b)
Sort by town rating.
void SetViewportCatchmentTown(const Town *t, bool sel)
Select or deselect town for coverage area highlight.
TownLayout town_layout
select town layout,
do a action from the town detail window (like advertises or bribe)
#define lastof(x)
Get the last element of an fixed size array.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Functions related to world/map generation.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
#define FOR_EACH_SET_BIT(bitpos_var, bitset_value)
Do an operation for each set set bit in a value.
bool persistent_buildingtools
keep the building tools active after usage
Common return value for all commands.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
bool GenerateTowns(TownLayout layout)
This function will generate a certain amount of towns, with a certain layout It can be called from th...
uint32 GetWorldPopulation()
Determines the world population Basically, count population of all towns, one by one.
static T max(const T a, const T b)
Returns the maximum of two values.
Town directory; Window numbers:
bool allow_town_roads
towns are allowed to build roads (always allowed when generating world / in SE)
uint32 population
Current population of people.
void OnPaint() override
The window must be repainted.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
void SetListing(Listing l)
Import sort conditions.
uint16 noise_reached
level of noise that all the airports are generating
static GUITownList::SortFunction *const sorter_funcs[]
Available town directory sorting functions.
const byte _town_action_costs[TACT_COUNT]
Factor in the cost of each town action.
static int RoundDivSU(int a, uint b)
Computes round(a / b) for signed a and unsigned b.
bool NeedRebuild() const
Check if a rebuild is needed.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Functions related to (drawing on) viewports.
void ForceRebuild()
Force that a rebuild is needed.
Base for the GUIs that have an edit box in them.
StringFilter string_filter
Filter for towns.
uint32 goal[NUM_TE]
Amount of cargo required for the town to grow.
Data structure for an opened window.
bool _ctrl_pressed
Is Ctrl pressed?
void UpdateOSKOriginalText(const Window *parent, int button)
Updates the original text of the OSK so when the 'parent' changes the original and you press on cance...
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void SetFilterTerm(const char *str)
Set the term to filter on.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
enable the 'Default' button ("\0" is returned)
void OnResize() override
Called after the window got resized.
TownEffect
Town growth effect when delivering cargo.
Functions related to low-level strings.
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Define a callback function for the client, after the command is finished.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
TileIndex xy
town center tile
Functions related to errors.
QueryString townname_editbox
Filter editbox.
This window is used for construction; close it whenever changing company.
TownSize
Supported initial town sizes.
const Town * _viewport_highlight_town
Currently selected town for coverage area highlight.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
bool townnamevalid
Is generated town name valid?
SoundSettings sound
sound effect settings
Listing GetListing() const
Export current sort conditions.
bool order
Ascending/descending.
int16 ratings[MAX_COMPANIES]
ratings of each company for this town
Town * town
Town being displayed.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
void OnPaint() override
The window must be repainted.
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
char * GetTownName(char *buff, const TownNameParams *par, uint32 townnameparts, const char *last)
Fills buffer with specified town name.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Data stored about a string that can be modified in the GUI.
ClientSettings _settings_client
The current settings for this game.
bool Succeeded() const
Did this command succeed?
Definition of base types and functions in a cross-platform compatible way.
the length of the string is counted in characters
A number of safeguards to prevent using unsafe methods.
rectangle (stations, depots, ...)
Allowed, with custom town layout.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
uint step_height
Step-size of height resize changes.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
GUI Functions related to companies.
Number of available town actions.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
const CargoSpec * FindFirstCargoWithTownEffect(TownEffect effect)
Determines the first cargo with a certain town effect.
void SetDParamMaxDigits(uint n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
int GetRowFromWidget(int clickpos, int widget, int padding, int line_height=-1) const
Compute the row of a widget that a user clicked in.
Offset at bottom to draw the frame rectangular area.
Found a town; Window numbers:
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Basic functions/variables used all over the place.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
#define lengthof(x)
Return the length of an fixed size array.
bool ScrollWindowToTile(TileIndex tile, Window *w, bool instant)
Scrolls the viewport in a window to a given location.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
Functions related to sound.
void SetSortType(uint8 n_type)
Set the sorttype of the list.
bool Sort(SortFunction *compare)
Sort the list.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
bool Failed() const
Did this command fail?
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
The filename filter has changed (via the editbox)
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
uint16 MaxTownNoise() const
Calculate the max town noise.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
bool _shift_pressed
Is Shift pressed?
void ShowExtraViewPortWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
No window, redirects to WC_MAIN_WINDOW.
static StringID GetTownString(const Town *t)
Get the string to draw the town name.
char * text
General text with additional information.
void OnHundredthTick() override
Called once every 100 (game) ticks.
static const uint TOWN_GROWTH_DESERT
The town needs the cargo for growth when on desert (any amount)
uint16 growth_rate
town growth rate
Functions related to companies.
char *const buf
buffer in which text is saved
Tstorage old_max
Maximum amount last month.
bool _generating_world
Whether we are generating the map or not.
Town directory window class.
Both numeric and alphabetic and spaces and stuff.
Town authority; Window numbers:
GUISettings gui
settings related to the GUI
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
bool station_noise_level
build new airports when the town noise level is still within accepted limits
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
uint32 TileIndex
The index/ID of a Tile.
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
void OnPaint() override
The window must be repainted.
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
TextDirection _current_text_dir
Text direction of the currently selected language.
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here...
void Remove(const T &element)
Remove a single element from the tree, if it exists.
Searching and filtering using a stringterm.
Town * town
Town displayed by the window.
uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t)
Get a list of available actions to do at a town.
uint32 townnameparts
Generated town name.
Town view; Window numbers:
void OnResize() override
Called after the window got resized.
TownCache cache
Container for all cacheable data.
TownLayout town_layout
Selected town layout.
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Functions related to the drop down widget.
bool confirm
Play sound effect on successful constructions or other actions.
Functions related to OTTD's landscape.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Non-water non-rail construction.
static bool TownNameSorter(const Town *const &a, const Town *const &b)
Sort by town name.
Functions related to commands.
bool larger_town
if this is a larger town and should grow more quickly
bool _network_server
network-server is active
Coordinates of a point in 2D.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Struct holding parameters used to generate town name.
byte GetSnowLine()
Get the current snow line, either variable or static.
TownNameParams params
Town name parameters.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static uint TileHeight(TileIndex tile)
Returns the height of a tile.
Data structure describing how to show the list (what sort direction and criteria).
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
static const uint MAX_LENGTH_TOWN_NAME_CHARS
The maximum length of a town name in characters including '\0'.
Window does not do autoscroll,.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
K-dimensional tree, specialised for 2-dimensional space.
static const StringID sorter_names[]
Names of the sorting functions.
Offset at right to draw the frame rectangular area.
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
void Clear()
Clear the tree.
int width
width of the window (number of pixels to the right in x direction)
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Town name generator stuff.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
bool IsDescSortOrder() const
Check if the sort order is descending.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
#define CMD_MSG(x)
Used to combine a StringID with the command.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
int32 WindowNumber
Number to differentiate different windows of the same class.
TransportedCargoStat< uint32 > supplied[NUM_CARGO]
Cargo statistics about supplied cargo.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Specification of a rectangle with absolute coordinates of all edges.
static bool TownPopulationSorter(const Town *const &a, const Town *const &b)
Sort by population (default descending, as big towns are of the most interest).
bool IsShaded() const
Is window shaded currently?
Text is written right-to-left by default.
WindowNumber window_number
Window number within the window class.
Functions related to tile highlights.
Window functions not directly related to making/drawing windows.
uint32 num_houses
Amount of houses.
Find a place automatically.
Conditions for town growth are met. Grow according to Town::growth_rate.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
ViewportData * viewport
Pointer to viewport data, if present.
GUI functions that shouldn't be here.
bool SortFunction(const T &, const T &)
Signature of sort function.
static int GetNthSetBit(uint32 bits, int n)
Get the position of the Nth set bit.
uint GetDesiredInfoHeight(int width) const
Gets the desired height for the information panel.
void Insert(const T &element)
Insert a single element in the tree.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
CompanyID exclusivity
which company has exclusivity
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Found a town window class.
Dimensions (a width and height) of a rectangle in 2D.
bool IsEmpty() const
Check whether any filter words were entered.
Offset at left to draw the frame rectangular area.
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Default zoom level for the news messages.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Tstorage old_act
Actually transported last month.
CompanyMask have_ratings
which companies have a rating
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
void UpdateSize()
Update Textbuf type with its actual physical character and screenlength Get the count of characters i...
uint8 SortType() const
Get the sorttype of the list.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.