38 #include "table/strings.h" 44 static const NWidgetPart _nested_town_authority_widgets[] = {
54 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(),
59 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),
106 if (buttons != displayed_actions_on_previous_painting) this->
SetDirty();
107 displayed_actions_on_previous_painting = buttons;
109 this->vscroll->
SetCount(numact + 1);
111 if (this->sel_index != -1 && !
HasBit(buttons, this->sel_index)) {
112 this->sel_index = -1;
130 DrawString(left, right, y, STR_LOCAL_AUTHORITY_COMPANY_RATINGS);
134 int icon_width = icon_size.width;
138 int exclusive_width = exclusive_size.width;
142 uint text_left = left + (rtl ? 0 : icon_width + exclusive_width + 4);
143 uint text_right = right - (rtl ? icon_width + exclusive_width + 4 : 0);
144 uint icon_left = rtl ? right - icon_width :
left;
145 uint exclusive_left = rtl ? right - icon_width - exclusive_width - 2 : left + icon_width + 2;
149 FOR_ALL_COMPANIES(c) {
158 (str = STR_CARGO_RATING_APPALLING, r <= RATING_APPALLING) ||
159 (str++, r <= RATING_VERYPOOR) ||
160 (str++, r <= RATING_POOR) ||
161 (str++, r <= RATING_MEDIOCRE) ||
162 (str++, r <= RATING_GOOD) ||
163 (str++, r <= RATING_VERYGOOD) ||
164 (str++, r <= RATING_EXCELLENT) ||
169 DrawSprite(SPR_EXCLUSIVE_TRANSPORT, COMPANY_SPRITE_COLOUR(c->
index), exclusive_left, y + exclusive_y_offset);
172 DrawString(text_left, text_right, y, STR_LOCAL_AUTHORITY_COMPANY_RATING);
193 if (this->sel_index != -1) {
196 STR_LOCAL_AUTHORITY_ACTION_TOOLTIP_SMALL_ADVERTISING + this->sel_index);
210 for (
int i = 0; buttons; i++, buttons >>= 1) {
211 if (pos <= -5)
break;
213 if ((buttons & 1) && --pos < 0) {
215 STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i, this->sel_index == i ? TC_WHITE : TC_ORANGE);
228 assert(size->width > padding.width && size->height > padding.height);
271 if (click_count == 1 || y < 0)
break;
288 WDP_AUTO,
"view_town_authority", 317, 222,
291 _nested_town_authority_widgets,
lengthof(_nested_town_authority_widgets)
294 static void ShowTownAuthorityWindow(uint
town)
296 AllocateWindowDescFront<TownAuthorityWindow>(&_town_authority_desc,
town);
306 static const int WID_TV_HEIGHT_NORMAL = 150;
351 for (
int i = TE_BEGIN; i <
TE_END; i++) {
352 if (this->town->
goal[i] == 0)
continue;
366 assert(cargo != NULL);
372 string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL;
374 string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_GENERAL;
377 string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER;
383 string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED;
385 string = STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED;
410 if (this->town->
text != NULL) {
438 static bool _warn_town_no_roads =
false;
442 _warn_town_no_roads =
true;
459 size->height = GetDesiredInfoHeight(size->width);
473 for (
int i = TE_BEGIN; i <
TE_END; i++) {
474 if (this->town->
goal[i] == 0)
continue;
488 if (this->town->
text != NULL) {
496 void ResizeWindowAsNeeded()
499 uint aimed_height = GetDesiredInfoHeight(nwid_info->
current_x);
522 if (!gui_scope)
return;
525 this->ResizeWindowAsNeeded();
530 if (str == NULL)
return;
536 static const NWidgetPart _nested_town_game_view_widgets[] = {
546 NWidget(
NWID_VIEWPORT, INVALID_COLOUR,
WID_TV_VIEWPORT),
SetMinimalSize(254, 86),
SetFill(1, 0),
SetResize(1, 1),
SetPadding(1, 1, 1, 1),
549 NWidget(
WWT_PANEL, COLOUR_BROWN,
WID_TV_INFO),
SetMinimalSize(260, 32),
SetResize(1, 0),
SetFill(1, 0),
EndContainer(),
552 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),
553 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),
554 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),
561 WDP_AUTO,
"view_town", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL,
564 _nested_town_game_view_widgets,
lengthof(_nested_town_game_view_widgets)
567 static const NWidgetPart _nested_town_editor_view_widgets[] = {
578 NWidget(
NWID_VIEWPORT, INVALID_COLOUR,
WID_TV_VIEWPORT),
SetMinimalSize(254, 86),
SetFill(1, 1),
SetResize(1, 1),
SetPadding(1, 1, 1, 1),
581 NWidget(
WWT_PANEL, COLOUR_BROWN,
WID_TV_INFO),
SetMinimalSize(260, 32),
SetResize(1, 0),
SetFill(1, 0),
EndContainer(),
584 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),
585 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),
586 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),
593 WDP_AUTO,
"view_town_scen", 260, TownViewWindow::WID_TV_HEIGHT_NORMAL,
596 _nested_town_editor_view_widgets,
lengthof(_nested_town_editor_view_widgets)
599 void ShowTownViewWindow(TownID
town)
601 if (_game_mode == GM_EDITOR) {
602 AllocateWindowDescFront<TownViewWindow>(&_town_editor_view_desc,
town);
604 AllocateWindowDescFront<TownViewWindow>(&_town_game_view_desc,
town);
608 static const NWidgetPart _nested_town_directory_widgets[] = {
626 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),
641 static const Town *last_town;
651 void BuildSortTownList()
658 *this->towns.
Append() = t;
666 this->last_town = NULL;
674 static char buf_cache[64];
680 GetString(buf, STR_TOWN_NAME,
lastof(buf));
685 if (tb != last_town) {
688 GetString(buf_cache, STR_TOWN_NAME,
lastof(buf_cache));
697 uint32 a_population = (*a)->cache.population;
698 uint32 b_population = (*b)->cache.population;
700 return (a_population < b_population) ? -1 : 1;
706 int before = TownDirectoryWindow::last_sorting.
order ? 1 : -1;
714 return (a_rating < b_rating) ? -1 : 1;
732 this->BuildSortTownList();
757 return t->
larger_town ? STR_TOWN_DIRECTORY_CITY : STR_TOWN_DIRECTORY_TOWN;
770 if (this->towns.
Length() == 0) {
783 const Town *t = this->towns[i];
790 SpriteID icon = SPR_TOWN_RATING_APALLING;
814 d.height += padding.height;
823 d.width += padding.width;
824 d.height += padding.height;
830 for (uint i = 0; i < this->towns.
Length(); i++) {
831 const Town *t = this->towns[i];
840 d.width += icon_size.width + 2;
841 d.height =
max(d.height, icon_size.height);
842 resize->height = d.height;
852 d.width += padding.width;
853 d.height += padding.height;
866 this->last_sorting = this->towns.
GetListing();
869 this->last_sorting.
order = !this->last_sorting.
order;
883 if (id_v >= this->towns.
Length())
return;
885 const Town *t = this->towns[id_v];
901 if (this->towns.
SortType() != index) {
903 this->last_sorting = this->towns.
GetListing();
904 this->BuildSortTownList();
910 if (this->towns.
NeedRebuild()) this->BuildSortTownList();
916 this->BuildSortTownList();
941 Listing TownDirectoryWindow::last_sorting = {
false, 0};
942 const Town *TownDirectoryWindow::last_town = NULL;
947 STR_SORT_BY_POPULATION,
955 &TownPopulationSorter,
963 _nested_town_directory_widgets,
lengthof(_nested_town_directory_widgets)
966 void ShowTownDirectory()
974 if (result.
Failed())
return;
980 void CcFoundRandomTown(
const CommandCost &result,
TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
985 static const NWidgetPart _nested_found_town_widgets[] = {
996 SetDataTip(STR_FOUND_TOWN_NEW_TOWN_BUTTON, STR_FOUND_TOWN_NEW_TOWN_TOOLTIP),
SetPadding(0, 2, 1, 2),
998 SetDataTip(STR_FOUND_TOWN_RANDOM_TOWN_BUTTON, STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP),
SetPadding(0, 2, 1, 2),
1000 SetDataTip(STR_FOUND_TOWN_MANY_RANDOM_TOWNS, STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP),
SetPadding(0, 2, 0, 2),
1002 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(156, 14),
SetPadding(0, 2, 0, 2),
SetDataTip(STR_FOUND_TOWN_NAME_TITLE, STR_NULL),
1004 SetDataTip(STR_FOUND_TOWN_NAME_EDITOR_TITLE, STR_FOUND_TOWN_NAME_EDITOR_HELP),
1005 NWidget(
WWT_PUSHTXTBTN, COLOUR_GREY,
WID_TF_TOWN_NAME_RANDOM),
SetMinimalSize(78, 12),
SetPadding(0, 2, 0, 2),
SetFill(1, 0),
1006 SetDataTip(STR_FOUND_TOWN_NAME_RANDOM_BUTTON, STR_FOUND_TOWN_NAME_RANDOM_TOOLTIP),
1015 SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_SMALL_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
1017 SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_MEDIUM_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
1022 SetDataTip(STR_FOUND_TOWN_INITIAL_SIZE_LARGE_BUTTON, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
1024 SetDataTip(STR_FOUND_TOWN_SIZE_RANDOM, STR_FOUND_TOWN_INITIAL_SIZE_TOOLTIP),
1027 NWidget(
WWT_TEXTBTN, COLOUR_GREY,
WID_TF_CITY),
SetPadding(0, 2, 0, 2),
SetMinimalSize(156, 12),
SetFill(1, 0),
1045 NWidget(
WWT_TEXTBTN, COLOUR_GREY,
WID_TF_LAYOUT_RANDOM),
SetPadding(0, 2, 0, 2),
SetMinimalSize(0, 12),
SetFill(1, 0),
1046 SetDataTip(STR_FOUND_TOWN_SELECT_LAYOUT_RANDOM, STR_FOUND_TOWN_SELECT_TOWN_ROAD_LAYOUT),
SetFill(1, 0),
1072 this->RandomTownName();
1073 this->UpdateButtons(
true);
1076 void RandomTownName()
1080 if (!this->townnamevalid) {
1081 this->townname_editbox.text.
DeleteAll();
1083 GetTownName(this->townname_editbox.text.
buf, &this->params, this->townnameparts, &this->townname_editbox.text.buf[this->townname_editbox.text.max_bytes - 1]);
1091 void UpdateButtons(
bool check_availability)
1093 if (check_availability && _game_mode != GM_EDITOR) {
1115 const char *name = NULL;
1117 if (!this->townnamevalid) {
1118 name = this->townname_editbox.text.
buf;
1123 if (strcmp(buf, this->townname_editbox.text.
buf) != 0) name = this->townname_editbox.text.
buf;
1126 bool success =
DoCommandP(tile, this->town_size | this->city << 2 | this->town_layout << 3 | random << 6,
1141 this->ExecuteFoundTownCommand(0,
true, STR_ERROR_CAN_T_GENERATE_TOWN, CcFoundRandomTown);
1145 this->RandomTownName();
1161 this->UpdateButtons(
false);
1173 this->UpdateButtons(
false);
1180 this->ExecuteFoundTownCommand(tile,
false, STR_ERROR_CAN_T_FOUND_TOWN_HERE, CcFoundTown);
1186 this->UpdateButtons(
false);
1196 if (!gui_scope)
return;
1197 this->UpdateButtons(
true);
1205 _nested_found_town_widgets,
lengthof(_nested_found_town_widgets)
1208 void ShowFoundTownWindow()
1211 AllocateWindowDescFront<FoundTownWindow>(&_found_town_desc, 0);
Functions related to OTTD's strings.
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?
static TropicZone GetTropicZone(TileIndex tile)
Get the tropic zone.
virtual void OnHundredthTick()
Called once every 100 (game) ticks.
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.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
TownFoundingByte found_town
town founding,
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.
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
CompanyByte exclusivity
which company has exclusivity
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.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
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.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Specification of a cargo type.
static int CDECL TownPopulationSorter(const Town *const *a, const Town *const *b)
Sort by population (default descending, as big towns are of the most interest).
Default zoom level for the news messages.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
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.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
TownSize town_size
Selected town size.
void Clear()
Remove all items from the list.
TownLayoutByte town_layout
select town layout,
void Compact()
Compact the list down to the smallest block size boundary.
bool city
Are we building a city?
Tindex index
Index of this pool item.
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.
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.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
#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.
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 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.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
T * Append(uint to_add=1)
Append an item and return it.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
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.
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 InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=NULL, uint textref_stack_size=0, const uint32 *textref_stack=NULL)
Display an error message in a window.
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)
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
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.
virtual void OnResize()
Called after the window got resized.
static int CDECL TownRatingSorter(const Town *const *a, const Town *const *b)
Sort by town rating.
TileIndex xy
town center tile
Functions related to errors.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
uint Length() const
Get the number of items in the list.
This window is used for construction; close it whenever changing company.
TownSize
Supported initial town sizes.
bool townnamevalid
Is generated town name valid?
SoundSettings sound
sound effect settings
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
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.
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.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
rectangle (stations, depots, ...)
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.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
const CargoSpec * FindFirstCargoWithTownEffect(TownEffect effect)
Determines the first cargo with a certain town effect.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
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.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
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.
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.
static int CDECL TownNameSorter(const Town *const *a, const Town *const *b)
Sort by town name.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
bool Failed() const
Did this command fail?
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
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.
virtual void OnPaint()
The window must be repainted.
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.
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
virtual void OnPlaceObject(Point pt, TileIndex tile)
The user clicked some place on the map when a tile highlight mode has been set.
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.
virtual void OnResize()
Called after the window got resized.
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...
virtual void OnPaint()
The window must be repainted.
Town * town
Town displayed by the window.
int CDECL SortFunction(const T *, const T *)
Signature of sort function.
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:
TownCache cache
Container for all cacheable data.
TownLayout town_layout
Selected town layout.
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 succesful 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.
Allowed, with custom town layout.
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-NULL) 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).
static const uint MAX_LENGTH_TOWN_NAME_CHARS
The maximum length of a town name in characters including '\0'.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Window does not do autoscroll,.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
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.
int width
width of the window (number of pixels to the right in x direction)
virtual void OnHundredthTick()
Called once every 100 (game) ticks.
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.
#define CMD_MSG(x)
Used to combine a StringID with the command.
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.
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.
ViewportData * viewport
Pointer to viewport data, if present.
GUI functions that shouldn't be here.
static int GetNthSetBit(uint32 bits, int n)
Get the position of the Nth set bit.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
uint GetDesiredInfoHeight(int width) const
Gets the desired height for the information panel.
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
Found a town window class.
Dimensions (a width and height) of a rectangle in 2D.
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.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Tstorage old_act
Actually transported last month.
CompanyMask have_ratings
which companies have a rating
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.