42#include "table/strings.h"
55static constexpr std::initializer_list<NWidgetPart> _nested_land_info_widgets = {
69 _nested_land_info_widgets
72class LandInfoWindow :
public Window {
84 for (
size_t i = 0; i < this->landinfo_data.size(); i++) {
89 if (!this->cargo_acceptance.empty()) {
99 for (
size_t i = 0; i < this->landinfo_data.size(); i++) {
101 size.width = std::max(size.width,
width);
106 if (!this->cargo_acceptance.empty()) {
108 size.width = std::max(size.width, std::min(
static_cast<uint
>(
ScaleGUITrad(300)),
width));
118# define LANDINFOD_LEVEL 0
120# define LANDINFOD_LEVEL 1
123 Debug(misc, LANDINFOD_LEVEL,
"type = 0x{:x}", tile.type());
124 Debug(misc, LANDINFOD_LEVEL,
"height = 0x{:x}", tile.height());
125 Debug(misc, LANDINFOD_LEVEL,
"m1 = 0x{:x}", tile.m1());
126 Debug(misc, LANDINFOD_LEVEL,
"m2 = 0x{:x}", tile.m2());
127 Debug(misc, LANDINFOD_LEVEL,
"m3 = 0x{:x}", tile.m3());
128 Debug(misc, LANDINFOD_LEVEL,
"m4 = 0x{:x}", tile.m4());
129 Debug(misc, LANDINFOD_LEVEL,
"m5 = 0x{:x}", tile.m5());
130 Debug(misc, LANDINFOD_LEVEL,
"m6 = 0x{:x}", tile.m6());
131 Debug(misc, LANDINFOD_LEVEL,
"m7 = 0x{:x}", tile.m7());
132 Debug(misc, LANDINFOD_LEVEL,
"m8 = 0x{:x}", tile.m8());
134 PrintWaterRegionDebugInfo(tile);
135#undef LANDINFOD_LEVEL
143 td.
owner_type[0] = STR_LAND_AREA_INFORMATION_OWNER;
146 AddAcceptedCargo(tile, acceptance,
nullptr);
147 GetTileDesc(tile, td);
149 this->landinfo_data.clear();
155 for (uint i = 0; i < 4; i++) {
159 this->landinfo_data.push_back(
GetString(td.
owner_type[i], STR_LAND_AREA_INFORMATION_OWNER_N_A, std::monostate{}));
172 Money cost = costclear.
GetCost();
176 str = STR_LAND_AREA_INFORMATION_REVENUE_WHEN_CLEARED;
178 str = STR_LAND_AREA_INFORMATION_COST_TO_CLEAR;
180 this->landinfo_data.push_back(
GetString(str, cost));
182 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A));
185 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A));
192 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_LANDINFO_INDEX, tile, tile));
196 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY, STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE, std::monostate{}));
198 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY, STR_TOWN_NAME, t->index));
203 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_BUILD_DATE, td.
build_date));
233 this->landinfo_data.push_back(
GetString(STR_LANG_AREA_INFORMATION_RAIL_TYPE, td.
railtype));
243 this->landinfo_data.push_back(
GetString(STR_LANG_AREA_INFORMATION_ROAD_TYPE, td.
roadtype));
253 this->landinfo_data.push_back(
GetString(STR_LANG_AREA_INFORMATION_TRAM_TYPE, td.
tramtype));
263 this->landinfo_data.push_back(
GetString(td.
town_can_upgrade.value() ? STR_LAND_AREA_INFORMATION_TOWN_CAN_UPGRADE : STR_LAND_AREA_INFORMATION_TOWN_CANNOT_UPGRADE));
267 if (td.
grf.has_value()) {
268 this->landinfo_data.push_back(
GetString(STR_LAND_AREA_INFORMATION_NEWGRF_NAME, std::move(*td.
grf)));
273 if (line.has_value()) {
274 this->cargo_acceptance = std::move(*line);
276 this->cargo_acceptance.clear();
308 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
310 if (!gui_scope)
return;
313 if (data == 1) this->
ReInit();
327static constexpr std::initializer_list<NWidgetPart> _nested_about_widgets = {
347 _nested_about_widgets
350static const std::initializer_list<const std::string_view> _credits = {
351 "Original design by Chris Sawyer",
352 "Original graphics by Simon Foster",
354 "The OpenTTD team (in alphabetical order):",
355 " Matthijs Kooijman (blathijs) - Pathfinder-guru, Debian port (since 0.3)",
356 " Christoph Elsenhans (frosch) - General coding (since 0.6)",
357 " Lo\u00efc Guilloux (glx) - General / Windows Expert (since 0.4.5)",
358 " Koen Bussemaker (Kuhnovic) - General / Ship pathfinder (since 14)",
359 " Charles Pigott (LordAro) - General / Correctness police (since 1.9)",
360 " Michael Lutz (michi_cc) - Path based signals (since 0.7)",
361 " Niels Martin Hansen (nielsm) - Music system, general coding (since 1.9)",
362 " Owen Rudge (orudge) - Forum host, OS/2 port (since 0.1)",
363 " Peter Nelson (peter1138) - Spiritual descendant from NewGRF gods (since 0.4.5)",
364 " Remko Bijker (Rubidium) - Coder and way more (since 0.4.5)",
365 " Patric Stout (TrueBrain) - NoProgrammer (since 0.3), sys op",
366 " Tyler Trahan (2TallTyler) - General / Time Lord (since 13)",
367 " Richard Wheeler (zephyris) - Precision pixel production (since 15)",
369 "Inactive Developers:",
370 " Grzegorz Duczy\u0144ski (adf88) - General coding (1.7 - 1.8)",
371 " Albert Hofkamp (Alberth) - GUI expert (0.7 - 1.9)",
372 " Jean-Fran\u00e7ois Claeys (Belugas) - GUI, NewGRF and more (0.4.5 - 1.0)",
373 " Bjarni Corfitzen (Bjarni) - MacOSX port, coder and vehicles (0.3 - 0.7)",
374 " Victor Fischer (Celestar) - Programming everywhere you need him to (0.3 - 0.6)",
375 " Ulf Hermann (fonsinchen) - Cargo Distribution (1.3 - 1.6)",
376 " Jaroslav Mazanec (KUDr) - YAPG (Yet Another Pathfinder God) ;) (0.4.5 - 0.6)",
377 " Jonathan Coome (Maedhros) - High priest of the NewGRF Temple (0.5 - 0.6)",
378 " Attila B\u00e1n (MiHaMiX) - Developer WebTranslator 1 and 2 (0.3 - 0.5)",
379 " Ingo von Borstel (planetmaker) - General coding, Support (1.1 - 1.9)",
380 " Zden\u011bk Sojka (SmatZ) - Bug finder and fixer (0.6 - 1.3)",
381 " Jos\u00e9 Soler (Terkhen) - General coding (1.0 - 1.4)",
382 " Christoph Mallon (Tron) - Programmer, code correctness police (0.3 - 0.5)",
383 " Thijs Marinussen (Yexo) - AI Framework, General (0.6 - 1.3)",
384 " Leif Linse (Zuu) - AI/Game Script (1.2 - 1.6)",
386 "Retired Developers:",
387 " Tam\u00e1s Farag\u00f3 (Darkvater) - Ex-Lead coder (0.3 - 0.5)",
388 " Dominik Scherer (dominik81) - Lead programmer, GUI expert (0.3 - 0.3)",
389 " Emil Djupfeld (egladil) - MacOSX (0.4.5 - 0.6)",
390 " Simon Sasburg (HackyKid) - Many bugfixes (0.4 - 0.4.5)",
391 " Ludvig Strigeus (ludde) - Original author of OpenTTD, main coder (0.1 - 0.3)",
392 " Cian Duffy (MYOB) - BeOS port / manual writing (0.1 - 0.3)",
393 " Petr Baudi\u0161 (pasky) - Many patches, NewGRF support (0.3 - 0.3)",
394 " Benedikt Br\u00fcggemeier (skidd13) - Bug fixer and code reworker (0.6 - 0.7)",
395 " Serge Paquet (vurlix) - 2nd contributor after ludde (0.1 - 0.3)",
397 "Special thanks go out to:",
398 " Josef Drexler - For his great work on TTDPatch",
399 " Marcin Grzegorczyk - Track foundations and for describing TTD internals",
400 " Stefan Mei\u00dfner (sign_de) - For his work on the console",
401 " Mike Ragsdale - OpenTTD installer",
402 " Christian Rosentreter (tokai) - MorphOS / AmigaOS port",
403 " Richard Kempton (richK) - additional airports, initial TGP implementation",
404 " Alberto Demichelis - Squirrel scripting language \u00a9 2003-2008",
405 " L. Peter Deutsch - MD5 implementation \u00a9 1999, 2000, 2002",
406 " Michael Blunck - Pre-signals and semaphores \u00a9 2003",
407 " George - Canal/Lock graphics \u00a9 2003-2004",
408 " Andrew Parkhouse (andythenorth) - River graphics",
409 " David Dallaston (Pikka) - Tram tracks",
410 " All Translators - Who made OpenTTD a truly international game",
411 " Bug Reporters - Without whom OpenTTD would still be full of bugs!",
414 "And last but not least:",
415 " Chris Sawyer - For an amazing game!"
423 AboutWindow() :
Window(_about_desc)
432 if (widget ==
WID_A_WEBSITE)
return "Website: https://www.openttd.org";
447 for (
const auto &str : _credits) {
457 int y = this->text_position;
460 for (
const auto &str : _credits) {
461 if (y >= r.top + 7 && y < r.bottom - this->
line_height) {
464 y += this->line_height;
474 this->text_position -= count;
483void ShowAboutWindow()
497 StringID msg = STR_MESSAGE_ESTIMATED_COST;
501 msg = STR_MESSAGE_ESTIMATED_INCOME;
519 StringID msg = STR_INCOME_FLOAT_COST;
523 msg = STR_INCOME_FLOAT_INCOME;
546 msg = STR_FEEDER_INCOME;
565 assert(
string != STR_NULL);
578 assert(
string != STR_NULL);
589 if (*te_id == INVALID_TE_ID)
return;
591 RemoveTextEffect(*te_id);
592 *te_id = INVALID_TE_ID;
595static constexpr std::initializer_list<NWidgetPart> _nested_tooltips_widgets = {
603 _nested_tooltips_widgets
615 this->close_cond = close_tooltip;
635 pt.
y =
SoftClamp(_cursor.pos.y + _cursor.total_size.y + _cursor.total_offs.y + 5, scr_top, scr_bot);
636 if (pt.
y + sm_height > scr_bot) pt.
y = std::min(_cursor.pos.y + _cursor.total_offs.y - 5, scr_bot) - sm_height;
637 pt.
x = sm_width >= _screen.width ? 0 :
SoftClamp(_cursor.pos.x - (sm_width >> 1), 0, _screen.width - sm_width);
667 if (!_cursor.in_window) {
674 switch (this->close_cond) {
677 case TCC_NONE:
break;
679 case TCC_EXIT_VIEWPORT: {
698 if (text.empty() || !_cursor.in_window)
return;
713static int GetCaretWidth()
726 const int linewidth = tb.
pixels + GetCaretWidth();
727 const int boxwidth = r.
Width();
728 if (linewidth <= boxwidth)
return r;
734 return r.
Translate(-std::clamp(tb.
caretxoffs - (boxwidth / 2), 0, linewidth - boxwidth), 0);
739 const NWidgetLeaf *wi = w->
GetWidget<NWidgetLeaf>(wid);
744 Dimension sprite_size =
GetScaledSpriteSize(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT);
747 Rect r = wi->GetCurrentRect();
752 DrawSpriteIgnorePadding(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT, PAL_NONE, cr,
SA_CENTER);
766 AutoRestoreBackup dpi_backup(_cur_dpi, &dpi);
770 const Textbuf *tb = &this->text;
778 if (focussed && tb->
caret) {
779 int caret_width = GetCaretWidth();
807 const Textbuf *tb = &this->text;
835 const Textbuf *tb = &this->text;
842 return r.
WithX(
Clamp(r.left + p1.left, r.left, r.right),
Clamp(r.left + p2.right, r.left, r.right));
867 const Textbuf *tb = &this->text;
870 return ::GetCharAtPosition(tb->
GetText(), pt.
x - r.left);
873void QueryString::ClickEditBox(
Window *w,
Point pt,
WidgetID wid,
int click_count,
bool focus_changed)
883 Rect cr = wi->GetCurrentRect().
WithWidth(clearbtn_width, !rtl);
886 if (!this->text.GetText().empty()) {
887 this->text.DeleteAll();
913 this->editbox.text.
Assign(str);
918 this->editbox.caption = caption;
921 this->editbox.text.afilter = afilter;
924 this->CreateNestedTree();
943 if (!this->editbox.orig.has_value() || this->editbox.text.GetText() != this->editbox.orig) {
944 assert(this->
parent !=
nullptr);
967 this->last_user_action = widget;
984 switch (this->last_user_action) {
988 Command<Commands::MoveStationName>::Post(STR_ERROR_CAN_T_MOVE_STATION_NAME,
CcMoveStationName, this->
parent->window_number, tile);
991 Command<Commands::MoveWaypointNAme>::Post(STR_ERROR_CAN_T_MOVE_WAYPOINT_NAME,
CcMoveWaypointName, this->
parent->window_number, tile);
995 default: NOT_REACHED();
1012 void Close([[maybe_unused]]
int data = 0)
override
1014 if (this->
parent !=
nullptr) {
1018 if (!this->editbox.handled) {
1020 this->parent =
nullptr;
1021 parent->OnQueryTextFinished(std::nullopt);
1029static constexpr std::initializer_list<NWidgetPart> _nested_query_string_widgets = {
1035 NWidget(
WWT_EDITBOX, COLOUR_GREY,
WID_QS_TEXT),
SetMinimalSize(256, 0),
SetFill(1, 0),
SetPadding(2, 2, 2, 2),
1053 _nested_query_string_widgets
1067 assert(parent !=
nullptr);
1080 if (w !=
nullptr) w->
editbox.orig = str;
1100 void Close([[maybe_unused]]
int data = 0)
override
1102 if (this->proc !=
nullptr) this->
proc(this->
parent,
false);
1148 this->proc =
nullptr;
1150 if (proc !=
nullptr) {
1168 if (this->proc !=
nullptr) {
1170 this->proc =
nullptr;
1182static constexpr std::initializer_list<NWidgetPart> _nested_query_widgets = {
1202 _nested_query_widgets
1223 assert(qw !=
nullptr);
1224 if (qw->
parent != parent || qw->
proc != callback)
continue;
std::optional< std::string > BuildCargoAcceptanceString(const CargoArray &acceptance, StringID label)
Build comma-separated cargo acceptance string.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Timpl & Reset()
Reset all bits.
Common return value for all commands.
bool Succeeded() const
Did this command succeed?
Money GetCost() const
The costs as made up to this moment.
Container for an encoded string, created by GetEncodedString.
std::string GetDecodedString() const
Decode the encoded string.
An interval timer will fire every interval, and will continue to fire until it is deleted.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
StringList landinfo_data
Info lines to show.
std::string cargo_acceptance
Centered multi-line string for cargo acceptance.
bool IsNewGRFInspectable() const override
Is the data related to this window NewGRF inspectable?
void OnInit() override
Notification that the nested widget tree gets initialized.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void ShowNewGRFInspectWindow() const override
Show the NewGRF inspection window.
static constexpr TimerGameTick::Ticks DAY_TICKS
1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16_t and incremented by 885.
Wrapper class to abstract away the way the tiles are stored.
static constexpr TimerGame< struct Calendar >::Date INVALID_DATE
Functions related to commands.
@ QueryCost
query cost only, don't build.
Definition of stuff that is very close to a company, like the company struct itself.
std::array< StringParameter, 2 > GetParamsForOwnedBy(Owner owner, TileIndex tile)
Set the right DParams for STR_ERROR_OWNED_BY.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
CompanyID _current_company
Company currently doing an action.
Functions related to companies.
static constexpr Owner OWNER_NONE
The tile has no ownership.
static constexpr Owner OWNER_WATER
The tile/execution is done by "water".
Functions related to debugging.
#define Debug(category, level, format_string,...)
Output a line of debugging information.
Functions related to errors.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
int CentreBounds(int min, int max, int size)
Determine where to position a centred object.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
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 _ctrl_pressed
Is Ctrl pressed?
uint8_t GetCharacterWidth(FontSize size, char32_t key)
Return width of character glyph.
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
Calculate string bounding box for multi-line strings.
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.
void GfxFillRect(int left, int top, int right, int bottom, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
bool _right_button_down
Is right mouse button pressed?
Dimension GetScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI.
ParagraphLayouter::Position GetCharPosInString(std::string_view str, size_t pos, FontSize start_fontsize)
Get the leading corner of a character in a single-line string relative to the start of the string.
Functions related to laying out the texts.
@ FS_NORMAL
Index of the normal font in the font tables.
@ SA_LEFT
Left align the text.
@ SA_HOR_CENTER
Horizontally center the text.
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
@ SA_CENTER
Center both horizontally and vertically.
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
void SetDirty() const
Mark entire window as dirty (in need of re-paint).
GUI functions that shouldn't be here.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
Functions related to OTTD's landscape.
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.
Command definitions related to landscape (slopes etc.).
#define Rect
Macro that prevents name conflicts between included headers.
#define Point
Macro that prevents name conflicts between included headers.
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static uint TileX(TileIndex tile)
Get the X component of a tile.
constexpr bool IsInsideMM(const size_t x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
constexpr T SoftClamp(const T a, const T min, const T max)
Clamp a value between an interval.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void GuiShowTooltips(Window *parent, EncodedString &&text, TooltipCloseCondition close_tooltip)
Shows a tooltip.
void ShowQuery(EncodedString &&caption, EncodedString &&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 HideFillingPercent(TextEffectID *te_id)
Hide vehicle loading indicators.
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
Display animated income or costs on the map.
void ShowEstimatedCostOrIncome(Money cost, int x, int y)
Display estimated costs.
OskActivation
Method to open the OSK.
@ OSKA_SINGLE_CLICK
Single click after focus click opens OSK.
@ OSKA_IMMEDIATELY
Focusing click already opens OSK.
@ OSKA_DISABLED
The OSK shall not be activated at all.
@ OSKA_DOUBLE_CLICK
Double click on the edit box opens OSK.
void ShowLandInfo(TileIndex tile)
Show land information window.
void ShowFeederIncomeAnimation(int x, int y, int z, Money transfer, Money income)
Display animated feeder income.
void ShowQueryString(std::string_view str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
void UpdateFillingPercent(TextEffectID te_id, uint8_t percent, StringID string)
Update vehicle loading indicators.
TextEffectID ShowFillingPercent(int x, int y, int z, uint8_t percent, StringID string)
Display vehicle loading indicators.
void UpdateQueryStringDefault(std::string_view str)
Updates default text value of query strign window.
static Rect ScrollEditBoxTextRect(Rect r, const Textbuf &tb)
Reposition edit text box rect based on textbuf length can caret position.
Functions/types related to NewGRF debugging.
GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
Get the GrfSpecFeature associated with the tile.
PixelColour GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
static constexpr PixelColour PC_GREY
Grey palette colour.
static constexpr PixelColour PC_BLACK
Black palette colour.
static constexpr PixelColour PC_LIGHT_YELLOW
Light yellow palette colour.
Base for the GUIs that have an edit box in them.
void ShowOnScreenKeyboard(Window *parent, WidgetID button)
Show the on-screen keyboard (osk) associated with a given textbox.
bool IsOSKOpenedFor(const Window *w, WidgetID button)
Check whether the OSK is opened for a specific editbox.
Declaration of OTTD revision dependent variables.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ClientSettings _settings_client
The current settings for this game.
Base classes/functions for stations.
void CcMoveStationName(Commands, const CommandCost &result, StationID station_id)
Callback function that is called after a name is moved.
Command definitions related to stations.
Definition of base types and functions in a cross-platform compatible way.
Functions related to low-level strings.
CharSetFilter
Valid filter types for IsValidChar.
std::vector< std::string > StringList
Type for a list of strings.
void GetStringWithArgs(StringBuilder &builder, StringID string, StringParameters &args, uint case_index, bool game_script)
Get a parsed string with most special stringcodes replaced by the string parameters.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
TextDirection _current_text_dir
Text direction of the currently selected language.
Functions related to OTTD's strings.
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
@ TD_RTL
Text is written right-to-left by default.
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
const IntervalTimer< TimerWindow > scroll_interval
Scroll the text in the about window slow.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
int text_position
The top of the scrolling text.
static const int num_visible_lines
The number of lines visible simultaneously.
int line_height
The height of a single line.
Class for storing amounts of cargo.
GUISettings gui
settings related to the GUI
Dimensions (a width and height) of a rectangle in 2D.
uint8_t osk_activation
Mouse gesture to trigger the OSK.
static Company * GetIfValid(auto index)
Class for the string query window.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
QueryString editbox
Editbox.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
QueryStringFlags flags
Flags controlling behaviour of the window.
WidgetID last_user_action
Last started user action.
Data stored about a string that can be modified in the GUI.
ptrdiff_t GetCharAtPosition(const Window *w, WidgetID wid, const Point &pt) const
Get the character that is rendered at a position.
Point GetCaretPosition(const Window *w, WidgetID wid) const
Get the current caret position.
Rect GetBoundingRect(const Window *w, WidgetID wid, size_t from, size_t to) const
Get the bounding rectangle for a range of the query string.
Window used for asking the user a YES/NO question.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
QueryCallbackProc * proc
callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' click...
EventState OnKeyPress(char32_t key, uint16_t keycode) override
A key has been pressed.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
EncodedString caption
caption for query window.
EncodedString message
message for query window.
void FindWindowPlacementAndResize(int, int, bool) override
Resize window towards the default size.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
int Width() const
Get width of Rect.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
Rect WithX(int new_left, int new_right) const
Create a new Rect, replacing the left and right coordiates.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
static bool IsExpected(const BaseStation *st)
static Station * Get(auto index)
Helper/buffer for input fields.
uint16_t pixels
the current size of the string in pixels
uint16_t markxoffs
the start position of the marked area in pixels
void DeleteAll()
Delete every character in the textbuffer.
std::string_view GetText() const
Get the current text.
uint16_t caretxoffs
the current position of the caret in pixels
uint16_t marklength
the length of the marked area in pixels
void Assign(std::string_view text)
Copy a string into the textbuffer.
bool caret
is the caret ("_") visible or not
Tile description for the 'land area information' tool.
uint16_t rail_speed
Speed limit of rail (bridges and track).
std::optional< std::string > grf
newGRF used for the tile contents
StringID station_name
Type of station within the class.
StringID str
Description of the tile.
TimerGameCalendar::Date build_date
Date of construction of tile contents.
std::array< Owner, 4 > owner
Name of the owner(s).
uint64_t dparam
Parameter of the str string.
StringID airport_class
Name of the airport class.
StringID airport_name
Name of the airport.
uint16_t tram_speed
Speed limit of tram (bridges and track).
StringID roadtype
Type of road on the tile.
StringID tramtype
Type of tram on the tile.
StringID railtype
Type of rail on the tile.
uint16_t road_speed
Speed limit of road (bridges and track).
std::array< StringID, 4 > owner_type
Type of each owner.
std::optional< bool > town_can_upgrade
Whether the town can upgrade this house during town growth.
StringID airport_tile_name
Name of the airport tile.
StringID station_class
Class of station.
High level window description.
Data structure for an opened window.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
bool IsWidgetGloballyFocused(WidgetID widget_index) const
Check if given widget has user input focus.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing).
Window * parent
Parent window.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
ResizeInfo resize
Resize information.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
WindowClass window_class
Window class.
virtual void OnQueryTextFinished(std::optional< std::string > str)
The query window opened from this window has closed.
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
int left
x position of left edge of the window
virtual void OnEditboxChanged(WidgetID widget)
The text in an editbox has been edited.
int top
y position of top edge of the window
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
WindowFlags flags
Window flags.
AllWindows< false > Iterate
Iterate all windows in whatever order is easiest.
int width
width of the window (number of pixels to the right in x direction)
WindowNumber window_number
Window number within the window class.
@ EnableMove
enable the 'Move' button
@ AcceptUnchanged
return success even when the text didn't change
@ EnableDefault
enable the 'Default' button ("\0" is returned)
@ LengthIsInChars
the length of the string is counted in characters
void QueryCallbackProc(Window *, bool)
Callback procedure for the ShowQuery method.
Functions related to text effects.
@ TE_STATIC
Keep the text effect static.
@ TE_RISING
Make the text effect slowly go upwards.
int GetTileZ(TileIndex tile)
Get bottom height of the tile.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Functions related to tile highlights.
@ HT_RECT
rectangle (stations, depots, ...)
Definition of Interval and OneShot timers.
Definition of the Window system.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
@ VEH_ROAD
Road vehicle type.
@ VEH_TRAIN
Train vehicle type.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
void SetViewportStationRect(const Station *st, bool sel)
Select or deselect station for rectangle area highlight.
Viewport * IsPtInWindowViewport(const Window *w, int x, int y)
Is a xy position inside the viewport of the window?
void SetViewportWaypointRect(const Waypoint *wp, bool sel)
Select or deselect waypoint for rectangle area highlight.
Functions related to (drawing on) viewports.
Handles dividing the water in the map into regions to assist pathfinding.
void CcMoveWaypointName(Commands, const CommandCost &result, StationID waypoint_id)
Callback function that is called after a name is moved.
Command definitions related to waypoints.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Window * GetMainWindow()
Get the main window, i.e.
void SetFocusedWindow(Window *w)
Set the window that has the focus.
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
Window * FindWindowFromPt(int x, int y)
Do a search for a window at specific coordinates.
int GetMainViewTop()
Return the top of the main view available for general use.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
int GetMainViewBottom()
Return the bottom of the main view available for general use.
bool _mouse_hovering
The mouse is hovering over the same point.
Window functions not directly related to making/drawing windows.
@ NoClose
This window can't be interactively closed.
@ NoFocus
This window won't get focus/make any other window lose focus when click.
@ Modal
The window is a modal child of some other window, meaning the parent is 'inactive'.
@ Lowered
If set the frame is lowered and the background colour brighter (ie. buttons when pressed).
@ WhiteBorder
Window white border counter bit mask.
@ WDP_CENTER
Center the window.
@ WDP_AUTO
Find a place automatically.
@ WDP_MANUAL
Manually align the window (so no automatic location finding).
@ WN_QUERY_STRING
Query string.
@ WN_GAME_OPTIONS_ABOUT
About window.
@ WN_CONFIRM_POPUP_QUERY
Query popup confirm.
EventState
State of handling an event.
@ ES_HANDLED
The passed event is handled.
@ ES_NOT_HANDLED
The passed event is not handled.
static constexpr WidgetID INVALID_WIDGET
An invalid widget index.
@ WC_LAND_INFO
Land info window; Window numbers:
@ WC_OSK
On Screen Keyboard; Window numbers:
@ WC_WAYPOINT_VIEW
Waypoint view; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_STATION_VIEW
Station view; Window numbers:
@ WC_CONFIRM_POPUP_QUERY
Popup with confirm question; Window numbers:
@ WC_GAME_OPTIONS
Game options window; Window numbers:
@ WC_QUERY_STRING
Query string window; Window numbers:
@ WC_TOOLTIPS
Tooltip window; Window numbers:
Functions related to zooming.