|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
36 #include "table/strings.h"
52 static constexpr
NWidgetPart _nested_land_info_widgets[] = {
62 static WindowDesc _land_info_desc(__FILE__, __LINE__,
66 std::begin(_nested_land_info_widgets), std::end(_nested_land_info_widgets)
76 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
81 for (
size_t i = 0; i < this->landinfo_data.size(); i++) {
86 if (!this->cargo_acceptance.empty()) {
97 for (
size_t i = 0; i < this->landinfo_data.size(); i++) {
99 size->width = std::max(size->width,
width);
104 if (!this->cargo_acceptance.empty()) {
106 size->width = std::max(size->width, std::min(
static_cast<uint
>(
ScaleGUITrad(300)),
width));
117 # define LANDINFOD_LEVEL 0
119 # define LANDINFOD_LEVEL 1
122 Debug(misc, LANDINFOD_LEVEL,
"type = 0x{:x}", tile.type());
123 Debug(misc, LANDINFOD_LEVEL,
"height = 0x{:x}", tile.height());
124 Debug(misc, LANDINFOD_LEVEL,
"m1 = 0x{:x}", tile.m1());
125 Debug(misc, LANDINFOD_LEVEL,
"m2 = 0x{:x}", tile.m2());
126 Debug(misc, LANDINFOD_LEVEL,
"m3 = 0x{:x}", tile.m3());
127 Debug(misc, LANDINFOD_LEVEL,
"m4 = 0x{:x}", tile.m4());
128 Debug(misc, LANDINFOD_LEVEL,
"m5 = 0x{:x}", tile.m5());
129 Debug(misc, LANDINFOD_LEVEL,
"m6 = 0x{:x}", tile.m6());
130 Debug(misc, LANDINFOD_LEVEL,
"m7 = 0x{:x}", tile.m7());
131 Debug(misc, LANDINFOD_LEVEL,
"m8 = 0x{:x}", tile.m8());
133 PrintWaterRegionDebugInfo(tile);
134 #undef LANDINFOD_LEVEL
150 td.
owner_type[0] = STR_LAND_AREA_INFORMATION_OWNER;
174 AddAcceptedCargo(tile, acceptance,
nullptr);
175 GetTileDesc(tile, &td);
177 this->landinfo_data.clear();
184 for (uint i = 0; i < 4; i++) {
187 SetDParam(0, STR_LAND_AREA_INFORMATION_OWNER_N_A);
193 StringID str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A;
202 str = STR_LAND_AREA_INFORMATION_REVENUE_WHEN_CLEARED;
204 str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR;
209 this->landinfo_data.push_back(
GetString(str));
212 std::stringstream tile_ss;
213 tile_ss <<
"0x" << std::setfill(
'0') << std::setw(4) << std::hex << std::uppercase << tile.base();
219 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_LANDINFO_COORDS));
222 SetDParam(0, STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE);
227 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY));
232 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_BUILD_DATE));
238 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_STATION_CLASS));
244 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_STATION_TYPE));
250 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_AIRPORT_CLASS));
256 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_AIRPORT_NAME));
262 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_AIRPORTTILE_NAME));
268 this->landinfo_data.push_back(
GetString(STR_LANG_AREA_INFORMATION_RAIL_TYPE));
274 this->landinfo_data.push_back(
GetString(STR_LANG_AREA_INFORMATION_RAIL_SPEED_LIMIT));
280 this->landinfo_data.push_back(
GetString(STR_LANG_AREA_INFORMATION_ROAD_TYPE));
286 this->landinfo_data.push_back(
GetString(STR_LANG_AREA_INFORMATION_ROAD_SPEED_LIMIT));
292 this->landinfo_data.push_back(
GetString(STR_LANG_AREA_INFORMATION_TRAM_TYPE));
298 this->landinfo_data.push_back(
GetString(STR_LANG_AREA_INFORMATION_TRAM_SPEED_LIMIT));
302 if (td.
grf !=
nullptr) {
304 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_NEWGRF_NAME));
308 std::stringstream line;
309 line <<
GetString(STR_LAND_AREA_INFORMATION_CARGO_ACCEPTED);
314 if (acceptance[cid] > 0) {
316 if (found) line <<
", ";
320 if (acceptance[cid] < 8) {
323 line <<
GetString(STR_LAND_AREA_INFORMATION_CARGO_EIGHTS);
330 this->cargo_acceptance = line.str();
332 this->cargo_acceptance.clear();
346 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
364 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
366 if (!gui_scope)
return;
369 if (data == 1) this->
ReInit();
383 static constexpr
NWidgetPart _nested_about_widgets[] = {
399 static WindowDesc _about_desc(__FILE__, __LINE__,
403 std::begin(_nested_about_widgets), std::end(_nested_about_widgets)
406 static const char *
const _credits[] = {
407 "Original design by Chris Sawyer",
408 "Original graphics by Simon Foster",
410 "The OpenTTD team (in alphabetical order):",
411 " Matthijs Kooijman (blathijs) - Pathfinder-guru, Debian port (since 0.3)",
412 " Christoph Elsenhans (frosch) - General coding (since 0.6)",
413 " Lo\u00efc Guilloux (glx) - General / Windows Expert (since 0.4.5)",
414 " Charles Pigott (LordAro) - General / Correctness police (since 1.9)",
415 " Michael Lutz (michi_cc) - Path based signals (since 0.7)",
416 " Niels Martin Hansen (nielsm) - Music system, general coding (since 1.9)",
417 " Owen Rudge (orudge) - Forum host, OS/2 port (since 0.1)",
418 " Peter Nelson (peter1138) - Spiritual descendant from NewGRF gods (since 0.4.5)",
419 " Remko Bijker (Rubidium) - Coder and way more (since 0.4.5)",
420 " Patric Stout (TrueBrain) - NoProgrammer (since 0.3), sys op",
421 " Tyler Trahan (2TallTyler) - General coding (since 13)",
423 "Inactive Developers:",
424 " Grzegorz Duczy\u0144ski (adf88) - General coding (1.7 - 1.8)",
425 " Albert Hofkamp (Alberth) - GUI expert (0.7 - 1.9)",
426 " Jean-Fran\u00e7ois Claeys (Belugas) - GUI, NewGRF and more (0.4.5 - 1.0)",
427 " Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles (0.3 - 0.7)",
428 " Victor Fischer (Celestar) - Programming everywhere you need him to (0.3 - 0.6)",
429 " Ulf Hermann (fonsinchen) - Cargo Distribution (1.3 - 1.6)",
430 " Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;) (0.4.5 - 0.6)",
431 " Jonathan Coome (Maedhros) - High priest of the NewGRF Temple (0.5 - 0.6)",
432 " Attila B\u00e1n (MiHaMiX) - Developer WebTranslator 1 and 2 (0.3 - 0.5)",
433 " Ingo von Borstel (planetmaker) - General coding, Support (1.1 - 1.9)",
434 " Zden\u011bk Sojka (SmatZ) - Bug finder and fixer (0.6 - 1.3)",
435 " Jos\u00e9 Soler (Terkhen) - General coding (1.0 - 1.4)",
436 " Christoph Mallon (Tron) - Programmer, code correctness police (0.3 - 0.5)",
437 " Thijs Marinussen (Yexo) - AI Framework, General (0.6 - 1.3)",
438 " Leif Linse (Zuu) - AI/Game Script (1.2 - 1.6)",
440 "Retired Developers:",
441 " Tam\u00e1s Farag\u00f3 (Darkvater) - Ex-Lead coder (0.3 - 0.5)",
442 " Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3 - 0.3)",
443 " Emil Djupfeld (egladil) - MacOSX (0.4.5 - 0.6)",
444 " Simon Sasburg (HackyKid) - Many bugfixes (0.4 - 0.4.5)",
445 " Ludvig Strigeus (ludde) - Original author of OpenTTD, main coder (0.1 - 0.3)",
446 " Cian Duffy (MYOB) - BeOS port / manual writing (0.1 - 0.3)",
447 " Petr Baudi\u0161 (pasky) - Many patches, NewGRF support (0.3 - 0.3)",
448 " Benedikt Br\u00fcggemeier (skidd13) - Bug fixer and code reworker (0.6 - 0.7)",
449 " Serge Paquet (vurlix) - 2nd contributor after ludde (0.1 - 0.3)",
451 "Special thanks go out to:",
452 " Josef Drexler - For his great work on TTDPatch",
453 " Marcin Grzegorczyk - Track foundations and for describing TTD internals",
454 " Stefan Mei\u00dfner (sign_de) - For his work on the console",
455 " Mike Ragsdale - OpenTTD installer",
456 " Christian Rosentreter (tokai) - MorphOS / AmigaOS port",
457 " Richard Kempton (richK) - additional airports, initial TGP implementation",
458 " Alberto Demichelis - Squirrel scripting language \u00a9 2003-2008",
459 " L. Peter Deutsch - MD5 implementation \u00a9 1999, 2000, 2002",
460 " Michael Blunck - Pre-signals and semaphores \u00a9 2003",
461 " George - Canal/Lock graphics \u00a9 2003-2004",
462 " Andrew Parkhouse (andythenorth) - River graphics",
463 " David Dallaston (Pikka) - Tram tracks",
464 " All Translators - Who made OpenTTD a truly international game",
465 " Bug Reporters - Without whom OpenTTD would still be full of bugs!",
468 "And last but not least:",
469 " Chris Sawyer - For an amazing game!"
484 void SetStringParameters(
WidgetID widget)
const override
500 for (uint i = 0; i <
lengthof(_credits); i++) {
506 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
513 for (uint i = 0; i <
lengthof(_credits); i++) {
514 if (y >= r.top + 7 && y < r.bottom - this->
line_height) {
527 this->text_position -= count;
536 void ShowAboutWindow()
550 StringID msg = STR_MESSAGE_ESTIMATED_COST;
554 msg = STR_MESSAGE_ESTIMATED_INCOME;
573 StringID msg = STR_INCOME_FLOAT_COST;
577 msg = STR_INCOME_FLOAT_INCOME;
602 msg = STR_FEEDER_INCOME;
622 assert(
string != STR_NULL);
625 return AddTextEffect(
string, pt.x, pt.y, 0,
TE_STATIC);
635 assert(
string != STR_NULL);
638 UpdateTextEffect(te_id,
string);
647 if (*te_id == INVALID_TE_ID)
return;
649 RemoveTextEffect(*te_id);
650 *te_id = INVALID_TE_ID;
653 static constexpr
NWidgetPart _nested_tooltips_widgets[] = {
657 static WindowDesc _tool_tips_desc(__FILE__, __LINE__,
661 std::begin(_nested_tooltips_widgets), std::end(_nested_tooltips_widgets)
668 std::vector<StringParameterBackup>
params;
674 this->string_id = str;
676 this->close_cond = close_tooltip;
683 Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]]
int window_number)
override
697 if (pt.y + sm_height > scr_bot) pt.y = std::min(_cursor.
pos.y + _cursor.total_offs.y - 5, scr_bot) - sm_height;
698 pt.x = sm_width >= _screen.width ? 0 :
SoftClamp(_cursor.
pos.x - (sm_width >> 1), 0, _screen.width - sm_width);
716 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
736 switch (this->close_cond) {
739 case TCC_NONE:
break;
741 case TCC_EXIT_VIEWPORT: {
761 if (str == STR_NULL || !_cursor.
in_window)
return;
776 static int GetCaretWidth()
781 void QueryString::DrawEditBox(
const Window *w,
WidgetID wid)
const
791 Rect r = wi->GetCurrentRect();
796 DrawSpriteIgnorePadding(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT, PAL_NONE, cr,
SA_CENTER);
811 const Textbuf *tb = &this->text;
812 int delta = std::min(0, (fr.right - fr.left) - tb->
pixels - GetCaretWidth());
821 if (focussed && tb->
caret) {
846 const Textbuf *tb = &this->text;
847 int delta = std::min(0, (r.right - r.left) - tb->
pixels - GetCaretWidth());
875 const Textbuf *tb = &this->text;
876 int delta = std::min(0, r.
Width() - tb->
pixels - GetCaretWidth());
883 return {
Clamp(r.left + p1.x + delta, r.left, r.right), r.top,
Clamp(r.left + p2.x + delta, r.left, r.right), r.bottom };
905 if (!
IsInsideMM(pt.y, r.top, r.bottom))
return -1;
908 const Textbuf *tb = &this->text;
909 int delta = std::min(0, r.
Width() - tb->
pixels - GetCaretWidth());
915 void QueryString::ClickEditBox(
Window *w,
Point pt,
WidgetID wid,
int click_count,
bool focus_changed)
925 Rect cr = wi->GetCurrentRect().
WithWidth(clearbtn_width, !rtl);
928 if (this->text.
bytes > 1) {
954 this->editbox.text.
Assign(str);
959 this->editbox.caption = caption;
962 this->editbox.text.
afilter = afilter;
966 this->UpdateWarningStringSize();
973 void UpdateWarningStringSize()
978 this->warning_size.height =
GetStringHeight(STR_WARNING_PASSWORD_SECURITY, this->warning_size.width);
1001 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1007 STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING,
SA_CENTER);
1011 void SetStringParameters(
WidgetID widget)
const override
1018 if (!this->editbox.orig.has_value() || this->editbox.text.buf != this->editbox.orig) {
1019 assert(this->
parent !=
nullptr);
1022 this->editbox.handled =
true;
1026 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1043 void Close([[maybe_unused]]
int data = 0)
override
1045 if (!this->editbox.handled && this->parent !=
nullptr) {
1047 this->parent =
nullptr;
1054 static constexpr
NWidgetPart _nested_query_string_widgets[] = {
1060 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_QS_TEXT),
SetMinimalSize(256, 12),
SetFill(1, 1),
SetPadding(2, 2, 2, 2),
1070 static WindowDesc _query_string_desc(__FILE__, __LINE__,
1074 std::begin(_nested_query_string_widgets), std::end(_nested_query_string_widgets)
1088 assert(parent !=
nullptr);
1108 this->proc = callback;
1112 this->GetWidget<NWidgetCore>(
WID_Q_CAPTION)->SetDataTip(caption, STR_NULL);
1116 void Close([[maybe_unused]]
int data = 0)
override
1118 if (this->proc !=
nullptr) this->
proc(this->
parent,
false);
1122 void FindWindowPlacementAndResize([[maybe_unused]]
int def_width, [[maybe_unused]]
int def_height)
override
1130 void SetStringParameters(
WidgetID widget)
const override
1147 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1154 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1163 this->proc =
nullptr;
1165 if (
proc !=
nullptr) {
1177 EventState OnKeyPress([[maybe_unused]] char32_t key, uint16_t keycode)
override
1183 if (this->proc !=
nullptr) {
1185 this->proc =
nullptr;
1197 static constexpr
NWidgetPart _nested_query_widgets[] = {
1213 static WindowDesc _query_desc(__FILE__, __LINE__,
1217 std::begin(_nested_query_widgets), std::end(_nested_query_widgets)
1238 if (qw->
parent != parent || qw->
proc != callback)
continue;
@ ES_HANDLED
The passed event is handled.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
StringID airport_class
Name of the airport class.
const char * grf
newGRF used for the tile contents
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Window * FindWindowFromPt(int x, int y)
Do a search for a window at specific coordinates.
void CopyInDParam(const std::span< const StringParameterBackup > backup)
Copy the parameters from the backup into the global string parameter array.
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.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
void SetFocusedWindow(Window *w)
Set the window that has the focus.
@ QSF_PASSWORD
password entry box, show warning about password security
Dimensions (a width and height) of a rectangle in 2D.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
@ WC_LAND_INFO
Land info window; Window numbers:
@ QSF_ACCEPT_UNCHANGED
return success even when the text didn't change
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
void UpdateFillingPercent(TextEffectID te_id, uint8_t percent, StringID string)
Update vehicle loading indicators.
StringID railtype
Type of rail on the tile.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
Owner owner[4]
Name of the owner(s)
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void ShowOnScreenKeyboard(Window *parent, WidgetID button)
Show the on-screen keyboard (osk) associated with a given textbox.
void Assign(StringID string)
Render a string into the textbuffer.
StringID station_class
Class of station.
uint16_t road_speed
Speed limit of road (bridges and track)
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Tindex index
Index of this pool item.
uint16_t pixels
the current size of the string in pixels
Class for storing amounts of cargo.
@ OSKA_DISABLED
The OSK shall not be activated at all.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
byte GetCharacterWidth(FontSize size, char32_t key)
Return width of character glyph.
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.
constexpr T SoftClamp(const T a, const T min, const T max)
Clamp a value between an interval.
Wrapper class to abstract away the way the tiles are stored.
ClientSettings _settings_client
The current settings for this game.
@ WC_OSK
On Screen Keyboard; Window numbers:
Specification of a cargo type.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
StringID airport_tile_name
Name of the airport tile.
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
@ VEH_ROAD
Road vehicle type.
Tile description for the 'land area information' tool.
int text_position
The top of the scrolling text.
StringID airport_name
Name of the airport.
bool IsOSKOpenedFor(const Window *w, WidgetID button)
Check whether the OSK is opened for a specific editbox.
Data stored about a string that can be modified in the GUI.
QueryStringFlags flags
Flags controlling behaviour of the window.
virtual void OnEditboxChanged([[maybe_unused]] WidgetID widget)
The text in an editbox has been edited.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
bool Succeeded() const
Did this command succeed?
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
QueryString editbox
Editbox.
char *const buf
buffer in which text is saved
@ 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.
High level window description.
GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
Get the GrfSpecFeature associated with the tile.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
TimerGameCalendar::Date build_date
Date of construction of tile contents.
@ WC_CONFIRM_POPUP_QUERY
Popup with confirm question; Window numbers:
@ WC_QUERY_STRING
Query string window; Window numbers:
uint16_t markxoffs
the start position of the marked area in pixels
@ WDP_AUTO
Find a place automatically.
bool IsWidgetGloballyFocused(WidgetID widget_index) const
Check if given widget has user input focus.
TextEffectID ShowFillingPercent(int x, int y, int z, uint8_t percent, StringID string)
Display vehicle loading indicators.
ResizeInfo resize
Resize information.
Common return value for all commands.
@ 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.
std::unique_ptr< NWidgetBase > nested_root
Root of the nested tree.
uint8_t osk_activation
Mouse gesture to trigger the OSK.
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
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.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
uint16_t bytes
the current size of the string in bytes (including terminating '\0')
StringID roadtype
Type of road on the tile.
@ WN_CONFIRM_POPUP_QUERY
Query popup confirm.
@ ES_NOT_HANDLED
The passed event is not handled.
ptrdiff_t GetCharAtPosition(const Window *w, WidgetID wid, const Point &pt) const
Get the character that is rendered at a position.
QueryCallbackProc * proc
callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' click...
Class for the string query window.
Rect GetBoundingRect(const Window *w, WidgetID wid, const char *from, const char *to) const
Get the bounding rectangle for a range of the query string.
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.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
Point total_size
union of sprite properties
EconomySettings economy
settings to change the economy
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.
std::vector< std::string > StringList
Type for a list of strings.
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.
void CopyOutDParam(std::vector< StringParameterBackup > &backup, size_t num)
Copy num string parameters from the global string parameter array to the backup.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
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
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
bool _mouse_hovering
The mouse is hovering over the same point.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
@ 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.
void SetDParamsForOwnedBy(Owner owner, TileIndex tile)
Set the right DParams for STR_ERROR_OWNED_BY.
byte CargoID
Cargo slots to indicate a cargo type within a game.
Coordinates of a point in 2D.
CharSetFilter afilter
Allowed characters.
StringID station_name
Type of station within the class.
@ WDF_NO_CLOSE
This window can't be interactively closed.
Point GetCaretPosition(const Window *w, WidgetID wid) const
Get the current caret position.
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
Display animated income or costs on the map.
WindowNumber window_number
Window number within the window class.
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
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.
@ TE_STATIC
Keep the text effect static.
@ SA_HOR_CENTER
Horizontally center the text.
Iterable ensemble of all valid Windows.
StringList landinfo_data
Info lines to show.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
static const uint8_t PC_LIGHT_YELLOW
Light yellow palette colour.
std::vector< StringParameterBackup > params
local copy of #_global_string_params
byte dist_local_authority
distance for town local authority, default 20
uint16_t tram_speed
Speed limit of tram (bridges and track)
OskActivation
Method to open the OSK.
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
CompanyID _current_company
Company currently doing an action.
void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount)
Shows a tooltip.
@ 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.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
uint64_t dparam
Parameter of the str string.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Window * GetMainWindow()
Get the main window, i.e.
@ WC_TOOLTIPS
Tooltip window; Window numbers:
virtual void OnQueryTextFinished([[maybe_unused]] char *str)
The query window opened from this window has closed.
void ShowNewGRFInspectWindow() const override
Show the NewGRF inspection window.
@ OWNER_NONE
The tile has no ownership.
uint16_t marklength
the length of the marked area in pixels
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Window used for asking the user a YES/NO question.
static constexpr TimerGame< struct Calendar >::Date INVALID_DATE
Representation of an invalid date.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Dimension warning_size
How much space to use for the warning text.
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.
static const uint8_t PC_GREY
Grey palette colour.
WindowClass window_class
Window class.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
@ TE_RISING
Make the text effect slowly go upwards.
StringID str
Description of the tile.
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
static const uint8_t PC_BLACK
Black palette colour.
@ OSKA_DOUBLE_CLICK
Double click on the edit box opens OSK.
int top
y position of top edge of the window
Viewport * IsPtInWindowViewport(const Window *w, int x, int y)
Is a xy position inside the viewport of the window?
@ SA_LEFT
Left align the text.
@ SA_CENTER
Center both horizontally and vertically.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
#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)
@ 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...
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
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.
Point GetCharPosInString(std::string_view 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.
ptrdiff_t GetCharAtPosition(std::string_view str, int x, FontSize start_fontsize)
Get the character from a string that is drawn at a specific position.
Data structure for an opened window.
uint16_t rail_speed
Speed limit of rail (bridges and track)
static constexpr TimerGameTick::Ticks DAY_TICKS
1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16_t and incremented by 885.
@ VEH_TRAIN
Train vehicle type.
void QueryCallbackProc(Window *, bool)
Callback procedure for the ShowQuery method.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
StringID tramtype
Type of tram on the tile.
@ DC_QUERY_COST
query cost only, don't build.
int Width() const
Get width of Rect.
Dimension GetScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI.
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
uint16_t caretxoffs
the current position of the caret in pixels
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".
@ 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.
IntervalTimer< TimerWindow > scroll_interval
Scroll the text in the about window slow.
@ WDP_CENTER
Center the window.
@ OSKA_IMMEDIATELY
Focusing click already opens OSK.
void DeleteAll()
Delete every character in the textbuffer.
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
CharSetFilter
Valid filter types for IsValidChar.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
bool _right_button_down
Is right mouse button pressed?
@ WN_GAME_OPTIONS_ABOUT
About window.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
std::string cargo_acceptance
Centered multi-line string for cargo acceptance.
GUISettings gui
settings related to the GUI
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.
void ShowEstimatedCostOrIncome(Money cost, int x, int y)
Display estimated costs.
Data about how and where to blit pixels.
Helper/buffer for input fields.
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.