Go to the documentation of this file.
33 #include "table/strings.h"
46 static const NWidgetPart _nested_land_info_widgets[] = {
60 _nested_land_info_widgets,
lengthof(_nested_land_info_widgets)
70 static const uint LAND_INFO_LINE_BUFF_SIZE = 512;
73 char landinfo_data[LAND_INFO_LINE_END][LAND_INFO_LINE_BUFF_SIZE];
82 if (
StrEmpty(this->landinfo_data[i]))
break;
101 if (
StrEmpty(this->landinfo_data[i]))
break;
104 size->width = std::max(size->width,
width);
107 if (i == 0) size->height += 4;
112 size->width = std::max(size->width, std::min(300u,
width));
123 # define LANDINFOD_LEVEL 0
125 # define LANDINFOD_LEVEL 1
127 DEBUG(misc, LANDINFOD_LEVEL,
"TILE: %#x (%i,%i)", tile,
TileX(tile),
TileY(tile));
128 DEBUG(misc, LANDINFOD_LEVEL,
"type = %#x",
_m[tile].type);
129 DEBUG(misc, LANDINFOD_LEVEL,
"height = %#x",
_m[tile].
height);
130 DEBUG(misc, LANDINFOD_LEVEL,
"m1 = %#x",
_m[tile].m1);
131 DEBUG(misc, LANDINFOD_LEVEL,
"m2 = %#x",
_m[tile].m2);
132 DEBUG(misc, LANDINFOD_LEVEL,
"m3 = %#x",
_m[tile].m3);
133 DEBUG(misc, LANDINFOD_LEVEL,
"m4 = %#x",
_m[tile].m4);
134 DEBUG(misc, LANDINFOD_LEVEL,
"m5 = %#x",
_m[tile].m5);
135 DEBUG(misc, LANDINFOD_LEVEL,
"m6 = %#x",
_me[tile].m6);
136 DEBUG(misc, LANDINFOD_LEVEL,
"m7 = %#x",
_me[tile].m7);
137 DEBUG(misc, LANDINFOD_LEVEL,
"m8 = %#x",
_me[tile].m8);
138 #undef LANDINFOD_LEVEL
154 td.
owner_type[0] = STR_LAND_AREA_INFORMATION_OWNER;
178 AddAcceptedCargo(tile, acceptance,
nullptr);
179 GetTileDesc(tile, &td);
185 GetString(this->landinfo_data[line_nr], td.
str,
lastof(this->landinfo_data[line_nr]));
189 for (uint i = 0; i < 4; i++) {
192 SetDParam(0, STR_LAND_AREA_INFORMATION_OWNER_N_A);
194 GetString(this->landinfo_data[line_nr], td.
owner_type[i],
lastof(this->landinfo_data[line_nr]));
199 StringID str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A;
208 str = STR_LAND_AREA_INFORMATION_REVENUE_WHEN_CLEARED;
210 str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR;
215 GetString(this->landinfo_data[line_nr], str,
lastof(this->landinfo_data[line_nr]));
225 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_LANDINFO_COORDS,
lastof(this->landinfo_data[line_nr]));
229 SetDParam(0, STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE);
234 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY,
lastof(this->landinfo_data[line_nr]));
240 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_BUILD_DATE,
lastof(this->landinfo_data[line_nr]));
247 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_STATION_CLASS,
lastof(this->landinfo_data[line_nr]));
254 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_STATION_TYPE,
lastof(this->landinfo_data[line_nr]));
261 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_AIRPORT_CLASS,
lastof(this->landinfo_data[line_nr]));
268 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_AIRPORT_NAME,
lastof(this->landinfo_data[line_nr]));
275 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_AIRPORTTILE_NAME,
lastof(this->landinfo_data[line_nr]));
282 GetString(this->landinfo_data[line_nr], STR_LANG_AREA_INFORMATION_RAIL_TYPE,
lastof(this->landinfo_data[line_nr]));
289 GetString(this->landinfo_data[line_nr], STR_LANG_AREA_INFORMATION_RAIL_SPEED_LIMIT,
lastof(this->landinfo_data[line_nr]));
296 GetString(this->landinfo_data[line_nr], STR_LANG_AREA_INFORMATION_ROAD_TYPE,
lastof(this->landinfo_data[line_nr]));
303 GetString(this->landinfo_data[line_nr], STR_LANG_AREA_INFORMATION_ROAD_SPEED_LIMIT,
lastof(this->landinfo_data[line_nr]));
310 GetString(this->landinfo_data[line_nr], STR_LANG_AREA_INFORMATION_TRAM_TYPE,
lastof(this->landinfo_data[line_nr]));
317 GetString(this->landinfo_data[line_nr], STR_LANG_AREA_INFORMATION_TRAM_SPEED_LIMIT,
lastof(this->landinfo_data[line_nr]));
322 if (td.
grf !=
nullptr) {
324 GetString(this->landinfo_data[line_nr], STR_LAND_AREA_INFORMATION_NEWGRF_NAME,
lastof(this->landinfo_data[line_nr]));
331 this->landinfo_data[line_nr][0] =
'\0';
338 if (acceptance[i] > 0) {
344 if (acceptance[i] < 8) {
386 if (!gui_scope)
return;
406 static const NWidgetPart _nested_about_widgets[] = {
426 _nested_about_widgets,
lengthof(_nested_about_widgets)
429 static const char *
const _credits[] = {
430 u8
"Original design by Chris Sawyer",
431 u8
"Original graphics by Simon Foster",
433 u8
"The OpenTTD team (in alphabetical order):",
434 u8
" Grzegorz Duczy\u0144ski (adf88) - General coding (since 1.7.2)",
435 u8
" Albert Hofkamp (Alberth) - GUI expert (since 0.7)",
436 u8
" Matthijs Kooijman (blathijs) - Pathfinder-guru, Debian port (since 0.3)",
437 u8
" Ulf Hermann (fonsinchen) - Cargo Distribution (since 1.3)",
438 u8
" Christoph Elsenhans (frosch) - General coding (since 0.6)",
439 u8
" Lo\u00efc Guilloux (glx) - General / Windows Expert (since 0.4.5)",
440 u8
" Charles Pigott (LordAro) - General / Correctness police (since 1.9)",
441 u8
" Michael Lutz (michi_cc) - Path based signals (since 0.7)",
442 u8
" Niels Martin Hansen (nielsm) - Music system, general coding (since 1.9)",
443 u8
" Owen Rudge (orudge) - Forum host, OS/2 port (since 0.1)",
444 u8
" Peter Nelson (peter1138) - Spiritual descendant from NewGRF gods (since 0.4.5)",
445 u8
" Ingo von Borstel (planetmaker) - General, Support (since 1.1)",
446 u8
" Remko Bijker (Rubidium) - Lead coder and way more (since 0.4.5)",
447 u8
" Jos\u00e9 Soler (Terkhen) - General coding (since 1.0)",
448 u8
" Leif Linse (Zuu) - AI/Game Script (since 1.2)",
450 u8
"Inactive Developers:",
451 u8
" Jean-Fran\u00e7ois Claeys (Belugas) - GUI, NewGRF and more (0.4.5 - 1.0)",
452 u8
" Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles (0.3 - 0.7)",
453 u8
" Victor Fischer (Celestar) - Programming everywhere you need him to (0.3 - 0.6)",
454 u8
" Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;) (0.4.5 - 0.6)",
455 u8
" Jonathan Coome (Maedhros) - High priest of the NewGRF Temple (0.5 - 0.6)",
456 u8
" Attila B\u00e1n (MiHaMiX) - Developer WebTranslator 1 and 2 (0.3 - 0.5)",
457 u8
" Zden\u011bk Sojka (SmatZ) - Bug finder and fixer (0.6 - 1.3)",
458 u8
" Christoph Mallon (Tron) - Programmer, code correctness police (0.3 - 0.5)",
459 u8
" Patric Stout (TrueBrain) - NoAI, NoGo, Network (0.3 - 1.2), sys op (active)",
460 u8
" Thijs Marinussen (Yexo) - AI Framework, General (0.6 - 1.3)",
462 u8
"Retired Developers:",
463 u8
" Tam\u00e1s Farag\u00f3 (Darkvater) - Ex-Lead coder (0.3 - 0.5)",
464 u8
" Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3 - 0.3)",
465 u8
" Emil Djupfeld (egladil) - MacOSX (0.4.5 - 0.6)",
466 u8
" Simon Sasburg (HackyKid) - Many bugfixes (0.4 - 0.4.5)",
467 u8
" Ludvig Strigeus (ludde) - Original author of OpenTTD, main coder (0.1 - 0.3)",
468 u8
" Cian Duffy (MYOB) - BeOS port / manual writing (0.1 - 0.3)",
469 u8
" Petr Baudi\u0161 (pasky) - Many patches, NewGRF support (0.3 - 0.3)",
470 u8
" Benedikt Br\u00fcggemeier (skidd13) - Bug fixer and code reworker (0.6 - 0.7)",
471 u8
" Serge Paquet (vurlix) - 2nd contributor after ludde (0.1 - 0.3)",
473 u8
"Special thanks go out to:",
474 u8
" Josef Drexler - For his great work on TTDPatch",
475 u8
" Marcin Grzegorczyk - Track foundations and for describing TTD internals",
476 u8
" Stefan Mei\u00dfner (sign_de) - For his work on the console",
477 u8
" Mike Ragsdale - OpenTTD installer",
478 u8
" Christian Rosentreter (tokai) - MorphOS / AmigaOS port",
479 u8
" Richard Kempton (richK) - additional airports, initial TGP implementation",
480 u8
" Chrnan6710 - title game",
482 u8
" Alberto Demichelis - Squirrel scripting language \u00a9 2003-2008",
483 u8
" L. Peter Deutsch - MD5 implementation \u00a9 1999, 2000, 2002",
484 u8
" Michael Blunck - Pre-signals and semaphores \u00a9 2003",
485 u8
" George - Canal/Lock graphics \u00a9 2003-2004",
486 u8
" Andrew Parkhouse (andythenorth) - River graphics",
487 u8
" David Dallaston (Pikka) - Tram tracks",
488 u8
" All Translators - Who made OpenTTD a truly international game",
489 u8
" Bug Reporters - Without whom OpenTTD would still be full of bugs!",
492 u8
"And last but not least:",
493 u8
" Chris Sawyer - For an amazing game!"
527 for (uint i = 0; i <
lengthof(_credits); i++) {
544 for (uint i = 0; i <
lengthof(_credits); i++) {
545 if (y >= r.top + 7 && y < r.bottom - this->
line_height) {
556 this->text_position -= count;
566 void ShowAboutWindow()
580 StringID msg = STR_MESSAGE_ESTIMATED_COST;
584 msg = STR_MESSAGE_ESTIMATED_INCOME;
600 StringID msg = STR_INCOME_FLOAT_COST;
604 msg = STR_INCOME_FLOAT_INCOME;
629 msg = STR_FEEDER_INCOME;
649 assert(
string != STR_NULL);
652 return AddTextEffect(
string, pt.x, pt.y, 0,
TE_STATIC);
662 assert(
string != STR_NULL);
665 UpdateTextEffect(te_id,
string);
674 if (*te_id == INVALID_TE_ID)
return;
676 RemoveTextEffect(*te_id);
677 *te_id = INVALID_TE_ID;
680 static const NWidgetPart _nested_tooltips_widgets[] = {
688 _nested_tooltips_widgets,
lengthof(_nested_tooltips_widgets)
702 this->string_id = str;
703 static_assert(
sizeof(this->params[0]) ==
sizeof(
params[0]));
707 this->close_cond = close_tooltip;
727 pt.y =
Clamp(_cursor.
pos.y + _cursor.
total_size.y + _cursor.total_offs.y + 5, scr_top, scr_bot);
728 if (pt.y + sm_height > scr_bot) pt.y = std::min(_cursor.
pos.y + _cursor.total_offs.y - 5, scr_bot) - sm_height;
729 pt.x = sm_width >= _screen.width ? 0 :
Clamp(_cursor.
pos.x - (sm_width >> 1), 0, _screen.width - sm_width);
753 for (uint arg = 0; arg < this->
paramcount; arg++) {
769 switch (this->close_cond) {
772 case TCC_NONE:
break;
774 case TCC_EXIT_VIEWPORT: {
795 if (str == STR_NULL || !_cursor.
in_window)
return;
797 new TooltipsWindow(parent, str, paramcount, params, close_tooltip);
800 void QueryString::HandleEditBox(
Window *w,
int wid)
810 void QueryString::DrawEditBox(
const Window *w,
int wid)
const
820 int clearbtn_left = wi->
pos_x + (rtl ? 0 : wi->
current_x - clearbtn_width);
821 int clearbtn_right = wi->
pos_x + (rtl ? clearbtn_width : wi->
current_x) - 1;
822 int left = wi->
pos_x + (rtl ? clearbtn_width : 0);
844 const Textbuf *tb = &this->text;
845 int delta = std::min(0, (right - left) - tb->
pixels - 10);
854 if (focussed && tb->
caret) {
878 int left = wi->
pos_x + (rtl ? clearbtn_width : 0);
882 const Textbuf *tb = &this->text;
883 int delta = std::min(0, (right - left) - tb->
pixels - 10);
908 int left = wi->
pos_x + (rtl ? clearbtn_width : 0);
915 const Textbuf *tb = &this->text;
916 int delta = std::min(0, (right - left) - tb->
pixels - 10);
945 int left = wi->
pos_x + (rtl ? clearbtn_width : 0);
951 if (!
IsInsideMM(pt.y, top, bottom))
return nullptr;
954 const Textbuf *tb = &this->text;
955 int delta = std::min(0, (right - left) - tb->
pixels - 10);
961 void QueryString::ClickEditBox(
Window *w,
Point pt,
int wid,
int click_count,
bool focus_changed)
968 int clearbtn_width =
GetSpriteSize(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT).width;
970 int clearbtn_left = wi->
pos_x + (rtl ? 0 : wi->
current_x - clearbtn_width);
972 if (
IsInsideBS(pt.x, clearbtn_left, clearbtn_width)) {
973 if (this->text.
bytes > 1) {
999 char *last_of = &this->editbox.text.
buf[this->editbox.text.
max_bytes - 1];
1000 GetString(this->editbox.text.
buf, str, last_of);
1014 this->editbox.caption = caption;
1017 this->editbox.text.
afilter = afilter;
1018 this->flags =
flags;
1021 this->UpdateWarningStringSize();
1028 void UpdateWarningStringSize()
1033 this->warning_size.height =
GetStringHeight(STR_WARNING_PASSWORD_SECURITY, this->warning_size.width);
1063 STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING,
SA_CENTER);
1074 if (this->editbox.orig ==
nullptr || strcmp(this->editbox.text.
buf, this->editbox.orig) != 0) {
1075 assert(this->
parent !=
nullptr);
1078 this->editbox.handled =
true;
1101 if (!this->editbox.handled && this->parent !=
nullptr) {
1103 this->parent =
nullptr;
1109 static const NWidgetPart _nested_query_string_widgets[] = {
1115 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_QS_TEXT),
SetMinimalSize(256, 12),
SetFill(1, 1),
SetPadding(2, 2, 2, 2),
1129 _nested_query_string_widgets,
lengthof(_nested_query_string_widgets)
1143 assert(parent !=
nullptr);
1165 this->proc = callback;
1173 if (this->proc !=
nullptr) this->
proc(this->
parent,
false);
1213 this->message, TC_FROMSTRING,
SA_CENTER);
1225 this->proc =
nullptr;
1227 if (
proc !=
nullptr) {
1245 if (this->proc !=
nullptr) {
1247 this->proc =
nullptr;
1259 static const NWidgetPart _nested_query_widgets[] = {
1277 _nested_query_widgets,
lengthof(_nested_query_widgets)
1294 FOR_ALL_WINDOWS_FROM_BACK(w) {
1298 if (qw->
parent != parent || qw->
proc != callback)
continue;
1304 new QueryWindow(&_query_desc, caption, message, parent, callback);
@ ES_HANDLED
The passed event is handled.
StringID airport_class
Name of the airport class.
static const uint TIMER_INTERVAL
Scrolling interval, scaled by line text line height. This value chosen to maintain parity: 2100 / FON...
const char * grf
newGRF used for the tile contents
void FindWindowPlacementAndResize(int def_width, int def_height) override
Resize window towards the default size.
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
uint32 TileIndex
The index/ID of a Tile.
Window * FindWindowFromPt(int x, int y)
Do a search for a window at specific coordinates.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
int ok_button
Widget button of parent window to simulate when pressing OK in OSK.
char32_t WChar
Type for wide characters, i.e.
void CopyOutDParam(uint64 *dst, int offs, int num)
Copy num string parameters from the global string parameter array to the dst array.
virtual void OnEditboxChanged(int widget)
The text in an editbox has been edited.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
uint16 max_bytes
the maximum size of the buffer in bytes (including terminating '\0')
@ QSF_PASSWORD
password entry box, show warning about password security
Dimensions (a width and height) of a rectangle in 2D.
@ TE_RISING
Make the text effect slowly go upwards.
NWidgetBase * nested_root
Root of the nested tree.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
void str_validate(char *str, const char *last, StringValidationSettings settings)
Scans the string for valid characters and if it finds invalid ones, replaces them with a question mar...
@ WC_LAND_INFO
Land info window; Window numbers:
@ QSF_ACCEPT_UNCHANGED
return success even when the text didn't change
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
StringID railtype
Type of rail on the tile.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
@ LAND_INFO_CENTERED_LINES
Up to 32 centered lines (arbitrary limit)
Owner owner[4]
Name of the owner(s)
static Point RemapCoords(int x, int y, int z)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap.
StringID station_class
Class of station.
@ SA_LEFT
Left align the text.
Tindex index
Index of this pool item.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
@ TE_STATIC
Keep the text effect static.
Class for storing amounts of cargo.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
@ OSKA_DISABLED
The OSK shall not be activated at all.
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.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
uint16 tram_speed
Speed limit of tram (bridges and track)
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
TileExtended * _me
Extended Tiles of the map.
void HideFillingPercent(TextEffectID *te_id)
Hide vehicle loading indicators.
@ WDF_NO_FOCUS
This window won't get focus/make any other window lose focus when click.
bool _ctrl_pressed
Is Ctrl pressed?
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
uint16 caretxoffs
the current position of the caret in pixels
@ WD_FRAMETEXT_TOP
Top offset of the text of the frame.
void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string)
Update vehicle loading indicators.
ClientSettings _settings_client
The current settings for this game.
@ WC_OSK
On Screen Keyboard; 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.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
StringID airport_tile_name
Name of the airport tile.
bool IsOSKOpenedFor(const Window *w, int button)
Check whether the OSK is opened for a specific editbox.
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
@ SA_CENTER
Center both horizontally and vertically.
const char * GetCharAtPosition(const Window *w, int wid, const Point &pt) const
Get the character that is rendered at a position.
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
@ SA_HOR_CENTER
Horizontally center the text.
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Tile description for the 'land area information' tool.
int text_position
The top of the scrolling text.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
StringID airport_name
Name of the airport.
Data stored about a string that can be modified in the GUI.
QueryStringFlags flags
Flags controlling behaviour of the window.
uint16 pixels
the current size of the string in pixels
bool Succeeded() const
Did this command succeed?
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
QueryString editbox
Editbox.
char *const buf
buffer in which text is saved
static uint TileX(TileIndex tile)
Get the X component of a tile.
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
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 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.
@ QSF_LEN_IN_CHARS
the length of the string is counted in characters
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
StringID caption
title of window
High level window description.
GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
Get the GrfSpecFeature associated with the tile.
Date build_date
Date of construction of tile contents.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
size_t Utf8StringLength(const char *s)
Get the length of an UTF-8 encoded string in number of characters and thus not the number of bytes th...
const NWID * GetWidget(uint widnum) const
Get the nested widget with number widnum from the nested widget tree.
@ WC_CONFIRM_POPUP_QUERY
Popup with confirm question; Window numbers:
TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID string)
Display vehicle loading indicators.
@ WC_QUERY_STRING
Query string window; Window numbers:
@ WDP_AUTO
Find a place automatically.
ResizeInfo resize
Resize information.
Common return value for all commands.
void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
Shows a tooltip.
@ WN_QUERY_STRING
Query string.
@ FS_NORMAL
Index of the normal font in the font tables.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
int height
Height of the window (number of pixels down in y direction)
@ WF_WHITE_BORDER
Window white border counter bit mask.
QueryStringFlags
Flags used in ShowQueryString() call.
uint16 marklength
the length of the marked area in pixels
#define DEBUG(name, level,...)
Output a line of debugging information.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
StringID roadtype
Type of road on the tile.
static bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
Rect GetBoundingRect(const Window *w, int wid, const char *from, const char *to) const
Get the bounding rectangle for a range of the query string.
@ WN_CONFIRM_POPUP_QUERY
Query popup confirm.
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
@ ES_NOT_HANDLED
The passed event is not handled.
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
QueryCallbackProc * proc
callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' click...
@ WD_FRAMETEXT_BOTTOM
Bottom offset of the text of the frame.
@ LAND_INFO_MULTICENTER_LINE
One multicenter line.
void GetNameOfOwner(Owner owner, TileIndex tile)
Set the right DParams to get the name of an owner.
Class for the string query window.
int GetMainViewTop()
Return the top of the main view available for general use.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Point total_size
union of sprite properties
EconomySettings economy
settings to change the economy
const char * GetCharAtPosition(const char *str, int x, FontSize start_fontsize)
Get the character from a string that is drawn at a specific position.
Window * parent
Parent window.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
bool IsWidgetGloballyFocused(byte widget_index) const
Check if given widget has user input focus.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
int left
x position of left edge of the window
WindowFlags flags
Window flags.
Money GetCost() const
The costs as made up to this moment.
void OnInit() override
Notification that the nested widget tree gets initialized.
bool caret
is the caret ("_") visible or not
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
bool _mouse_hovering
The mouse is hovering over the same point.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
@ WDF_MODAL
The window is a modal child of some other window, meaning the parent is 'inactive'.
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
Coordinates of a point in 2D.
CharSetFilter afilter
Allowed characters.
StringID station_name
Type of station within the class.
uint64 dparam[2]
Parameters of the str string.
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
Display animated income or costs on the map.
static const uint8 PC_BLACK
Black palette colour.
WindowNumber window_number
Window number within the window class.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
static const uint8 PC_GREY
Grey palette colour.
EventState OnKeyPress(WChar key, uint16 keycode) override
A key has been pressed.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
byte dist_local_authority
distance for town local authority, default 20
uint64 params[10]
local copy of #_global_string_params
OskActivation
Method to open the OSK.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
uint16 bytes
the current size of the string in bytes (including terminating '\0')
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
CompanyID _current_company
Company currently doing an action.
@ WC_GAME_OPTIONS
Game options window; Window numbers:
bool IsNewGRFInspectable() const override
Is the data related to this window NewGRF inspectable?
void ShowFeederIncomeAnimation(int x, int y, int z, Money transfer, Money income)
Display animated feeder income.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
static const Date INVALID_DATE
Representation of an invalid date.
static const uint8 PC_LIGHT_YELLOW
Light yellow palette colour.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
@ WC_TOOLTIPS
Tooltip window; Window numbers:
void UpdateSize()
Update Textbuf type with its actual physical character and screenlength Get the count of characters i...
void ShowNewGRFInspectWindow() const override
Show the NewGRF inspection window.
@ OWNER_NONE
The tile has no ownership.
Window used for asking the user a YES/NO question.
Dimension warning_size
How much space to use for the warning text.
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.
@ NUM_CARGO
Maximal number of cargo types in a game.
static const int num_visible_lines
The number of lines visible simultaneously.
@ OSKA_SINGLE_CLICK
Single click after focus click opens OSK.
EventState
State of handling an event.
void ShowLandInfo(TileIndex tile)
Show land information window.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
uint8 osk_activation
Mouse gesture to trigger the OSK.
uint CountElapsed(uint delta)
Count how many times the interval has elapsed.
WindowClass window_class
Window class.
int CDECL seprintf(char *str, const char *last, const char *format,...)
Safer implementation of snprintf; same as snprintf except:
StringID str
Description of the tile.
@ WC_MAIN_WINDOW
Main window; Window numbers:
@ OSKA_DOUBLE_CLICK
Double click on the edit box opens OSK.
int top
y position of top edge of the window
@ SVS_NONE
Allow nothing and replace nothing.
char * stredup(const char *s, const char *last)
Create a duplicate of the given string.
Viewport * IsPtInWindowViewport(const Window *w, int x, int y)
Is a xy position inside the viewport of the window?
#define lengthof(x)
Return the length of an fixed size array.
int width
width of the window (number of pixels to the right in x direction)
uint16 rail_speed
Speed limit of rail (bridges and track)
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
@ FR_DARKENED
If set the background is darker, allows for lowered frames with normal background colour when used wi...
byte CargoID
Cargo slots to indicate a cargo type within a game.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Point GetCaretPosition(const Window *w, int wid) const
Get the current caret position.
bool IsNewGRFInspectable(GrfSpecFeature feature, uint index)
Can we inspect the data given a certain feature and index.
StringID owner_type[4]
Type of each owner.
void ShowOnScreenKeyboard(Window *parent, int button)
Show the on-screen keyboard (osk) associated with a given textbox.
Data structure for an opened window.
void QueryCallbackProc(Window *, bool)
Callback procedure for the ShowQuery method.
StringID tramtype
Type of tram on the tile.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
@ DC_QUERY_COST
query cost only, don't build.
@ WD_IMGBTN_LEFT
Left offset of the image in the button.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
int GetMainViewBottom()
Return the bottom of the main view available for general use.
Specification of a rectangle with absolute coordinates of all edges.
Point pos
logical mouse position
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.
StringID message
message shown for query window
int line_height
The height of a single line.
@ OWNER_WATER
The tile/execution is done by "water".
Point GetCharPosInString(const char *str, const char *ch, FontSize start_fontsize)
Get the leading corner of a character in a single-line string relative to the start of the string.
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
bool in_window
mouse inside this window, determines drawing logic
#define CLRBITS(x, y)
Clears several bits in a variable.
#define lastof(x)
Get the last element of an fixed size array.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
@ WD_IMGBTN_RIGHT
Right offset of the image in the button.
@ WDP_CENTER
Center the window.
@ OSKA_IMMEDIATELY
Focusing click already opens OSK.
void CDECL void DeleteAll()
Delete every character in the textbuffer.
@ TD_RTL
Text is written right-to-left by default.
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
Tile * _m
Tiles of the map.
TextDirection _current_text_dir
Text direction of the currently selected language.
CharSetFilter
Valid filter types for IsValidChar.
@ CMD_LANDSCAPE_CLEAR
demolish a tile
@ WD_TEXTPANEL_BOTTOM
Offset at bottom to draw below the text.
bool _right_button_down
Is right mouse button pressed?
void CopyInDParam(int offs, const uint64 *src, int num)
Copy num string parameters from array src into the global string parameter array.
@ WN_GAME_OPTIONS_ABOUT
About window.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
static char * Utf8PrevChar(char *s)
Retrieve the previous UNICODE character in an UTF-8 encoded string.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
GUISettings gui
settings related to the GUI
void ShowEstimatedCostOrIncome(Money cost, int x, int y)
Display estimated costs.
Data about how and where to blit pixels.
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.
@ WD_TEXTPANEL_TOP
Offset at top to draw above the text.
Helper/buffer for input fields.
uint16 road_speed
Speed limit of road (bridges and track)
uint16 markxoffs
the start position of the marked area in pixels