OpenTTD

Data Structures | Macros | Enumerations | Functions | Variables
misc_gui.cpp File Reference

GUIs for a number of misc windows. More...

`#include "stdafx.h"`
`#include "debug.h"`
`#include "landscape.h"`
`#include "error.h"`
`#include "gui.h"`
`#include "command_func.h"`
`#include "company_func.h"`
`#include "town.h"`
`#include "string_func.h"`
`#include "company_base.h"`
`#include "texteff.hpp"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "querystring_gui.h"`
`#include "core/geometry_func.hpp"`
`#include "newgrf_debug.h"`
`#include "zoom_func.h"`
`#include "widgets/misc_widget.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
class | LandInfoWindow
struct | AboutWindow
struct | TooltipsWindow
| Window for displaying a tooltip. More...
struct | QueryStringWindow
| Class for the string query window. More...
struct | QueryWindow
| Window used for asking the user a YES/NO question. More...

## Macros
#define | LANDINFOD_LEVEL 1

## Enumerations
enum | OskActivation { OSKA_DISABLED, OSKA_DOUBLE_CLICK, OSKA_SINGLE_CLICK, OSKA_IMMEDIATELY }
| Method to open the OSK. More...

## Functions
void | ShowLandInfo (TileIndex tile)
| Show land information window. More...
void | ShowAboutWindow ()
void | ShowEstimatedCostOrIncome (Money cost, int x, int y)
| Display estimated costs. More...
void | ShowCostOrIncomeAnimation (int x, int y, int z, Money cost)
| Display animated income or costs on the map. More...
void | ShowFeederIncomeAnimation (int x, int y, int z, Money transfer, Money income)
| Display animated feeder income. More...
TextEffectID | ShowFillingPercent (int x, int y, int z, uint8 percent, StringID string)
| Display vehicle loading indicators. More...
void | UpdateFillingPercent (TextEffectID te_id, uint8 percent, StringID string)
| Update vehicle loading indicators. More...
void | HideFillingPercent (TextEffectID *te_id)
| Hide vehicle loading indicators. More...
void | GuiShowTooltips (Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
| Shows a tooltip. More...
void | ShowQueryString (StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
| Show a query popup window with a textbox in it. More...
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 centre of its parent. More...

## Variables
static const NWidgetPart | _nested_land_info_widgets []
static WindowDesc | _land_info_desc (WDP_AUTO, "land_info", 0, 0, WC_LAND_INFO, WC_NONE, 0, _nested_land_info_widgets, lengthof(_nested_land_info_widgets))
static const NWidgetPart | _nested_about_widgets []
static WindowDesc | _about_desc (WDP_CENTER, NULL, 0, 0, WC_GAME_OPTIONS, WC_NONE, 0, _nested_about_widgets, lengthof(_nested_about_widgets))
static const char *const | _credits []
static const NWidgetPart | _nested_tooltips_widgets []
static WindowDesc | _tool_tips_desc (WDP_MANUAL, NULL, 0, 0, WC_TOOLTIPS, WC_NONE, WDF_NO_FOCUS, _nested_tooltips_widgets, lengthof(_nested_tooltips_widgets))
static const NWidgetPart | _nested_query_string_widgets []
static WindowDesc | _query_string_desc (WDP_CENTER, "query_string", 0, 0, WC_QUERY_STRING, WC_NONE, 0, _nested_query_string_widgets, lengthof(_nested_query_string_widgets))
static const NWidgetPart | _nested_query_widgets []
static WindowDesc | _query_desc (WDP_CENTER, NULL, 0, 0, WC_CONFIRM_POPUP_QUERY, WC_NONE, WDF_MODAL, _nested_query_widgets, lengthof(_nested_query_widgets))

## Detailed Description

GUIs for a number of misc windows.

Definition in file misc_gui.cpp.

## Enumeration Type Documentation

## ◆ OskActivation

enum OskActivation

Method to open the OSK.

Enumerator
OSKA_DISABLED | The OSK shall not be activated at all.
OSKA_DOUBLE_CLICK | Double click on the edit box opens OSK.
OSKA_SINGLE_CLICK | Single click after focus click opens OSK.
OSKA_IMMEDIATELY | Focusing click already opens OSK.

Definition at line 37 of file misc_gui.cpp.

## Function Documentation

## ◆ GuiShowTooltips()

void GuiShowTooltips | ( | Window * | parent,
|  | StringID | str,
|  | uint | paramcount,
|  | const uint64 | params[],
|  | TooltipCloseCondition | close_tooltip
| ) |  |

Shows a tooltip.

Parameters

  parent | The window this tooltip is related to.
  str | String to be displayed
  paramcount | number of params to deal with
  params | (optional) up to 5 pieces of additional information that may be added to a tooltip
  use_left_mouse_button | close the tooltip when the left (true) or right (false) mouse button is released

Definition at line 743 of file misc_gui.cpp.

References DeleteWindowById(), Window::GetWidget(), Window::InvalidateData(), Window::IsWidgetGloballyFocused(), Window::SetWidgetDirty(), WC_OSK, WC_TOOLTIPS, and Window::window_class.

Referenced by IndustryCargoesWindow::OnHover().

## ◆ HideFillingPercent()

void HideFillingPercent | ( | TextEffectID * | te_id | ) |

Hide vehicle loading indicators.

Parameters

  *te_id | TextEffectID which is supposed to be hidden.

Definition at line 630 of file misc_gui.cpp.

Referenced by Train::Crash(), and Vehicle::PreDestructor().

## ◆ ShowCostOrIncomeAnimation()

void ShowCostOrIncomeAnimation | ( | int | x,
|  | int | y,
|  | int | z,
|  | Money | cost
| ) |  |

Display animated income or costs on the map.

Parameters

  x | World X position of the animation location.
  y | World Y position of the animation location.
  z | World Z position of the animation location.
  cost | Estimated cost (or income if negative).

Definition at line 555 of file misc_gui.cpp.

## ◆ ShowEstimatedCostOrIncome()

void ShowEstimatedCostOrIncome | ( | Money | cost,
|  | int | x,
|  | int | y
| ) |  |

Display estimated costs.

Parameters

  cost | Estimated cost (or income if negative).
  x | X position of the notification window.
  y | Y position of the notification window.

Definition at line 536 of file misc_gui.cpp.

## ◆ ShowFeederIncomeAnimation()

void ShowFeederIncomeAnimation | ( | int | x,
|  | int | y,
|  | int | z,
|  | Money | transfer,
|  | Money | income
| ) |  |

Display animated feeder income.

Parameters

  x | World X position of the animation location.
  y | World Y position of the animation location.
  z | World Z position of the animation location.
  transfer | Estimated feeder income.
  income | Real income from goods being delivered to their final destination.

Definition at line 576 of file misc_gui.cpp.

## ◆ ShowFillingPercent()

TextEffectID ShowFillingPercent | ( | int | x,
|  | int | y,
|  | int | z,
|  | uint8 | percent,
|  | StringID | string
| ) |  |

Display vehicle loading indicators.

Parameters

  x | World X position of the animation location.
  y | World Y position of the animation location.
  z | World Z position of the animation location.
  percent | Estimated feeder income.
  string | String which is drawn on the map.

Returns
  TextEffectID to be used for future updates of the loading indicators.

Definition at line 603 of file misc_gui.cpp.

## ◆ ShowLandInfo()

void ShowLandInfo | ( | TileIndex | tile | ) |

Show land information window.

Parameters

  tile | The tile to show information about.

Definition at line 366 of file misc_gui.cpp.

References DeleteWindowById(), and WC_LAND_INFO.

## ◆ ShowQuery()

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 centre of its parent.

Parameters

  caption | string shown as window caption
  message | string that will be shown for the window
  parent | pointer to parent window, if this pointer is NULL the parent becomes the main window WC_MAIN_WINDOW
  callback | callback function pointer to set in the window descriptor

Definition at line 1207 of file misc_gui.cpp.

References FindWindowById(), and WC_MAIN_WINDOW.

Referenced by CmdPause(), MenuClickLargeWorldScreenshot(), and GenerateProgressWindow::OnClick().

## ◆ ShowQueryString()

void ShowQueryString | ( | StringID | str,
|  | StringID | caption,
|  | uint | maxsize,
|  | Window * | parent,
|  | CharSetFilter | afilter,
|  | QueryStringFlags | flags
| ) |  |

Show a query popup window with a textbox in it.

Parameters

  str | StringID for the text shown in the textbox
  caption | StringID of text shown in caption of querywindow
  maxsize | maximum size in bytes or characters (including terminating '\0') depending on flags
  parent | pointer to a Window that will handle the events (ok/cancel) of this window. If NULL, results are handled by global function HandleOnEditText
  afilter | filters out unwanted character input
  flags | various flags,

See also
  QueryStringFlags

Definition at line 1066 of file misc_gui.cpp.

References DeleteWindowByClass(), MAX_CHAR_LENGTH, QSF_LEN_IN_CHARS, and WC_QUERY_STRING.

Referenced by WaypointWindow::OnClick(), NewGRFInspectWindow::OnClick(), SpriteAlignerWindow::OnClick(), SelectCompanyManagerFaceWindow::OnClick(), StationViewWindow::OnClick(), VehicleDetailsWindow::OnClick(), CompanyWindow::OnClick(), GenerateLandscapeWindow::OnDropdownSelect(), and ToolbarScenDatePanel().

## ◆ UpdateFillingPercent()

void UpdateFillingPercent | ( | TextEffectID | te_id,
|  | uint8 | percent,
|  | StringID | string
| ) |  |

Update vehicle loading indicators.

Parameters

  te_id | TextEffectID to be updated.
  string | String which is printed.

Definition at line 618 of file misc_gui.cpp.

## Variable Documentation

## ◆ _nested_about_widgets

const NWidgetPart _nested_about_widgets[]
| static

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_ABOUT_OPENTTD, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY), SetPIP(4, 2, 4),
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_ABOUT_ORIGINAL_COPYRIGHT, STR_NULL),
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_ABOUT_VERSION, STR_NULL),
NWidget(WWT_FRAME, COLOUR_GREY), SetPadding(0, 5, 1, 5),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_A_SCROLLING_TEXT),
EndContainer(),
NWidget(WWT_LABEL, COLOUR_GREY, WID_A_WEBSITE), SetDataTip(STR_BLACK_RAW_STRING, STR_NULL),
NWidget(WWT_LABEL, COLOUR_GREY), SetDataTip(STR_ABOUT_COPYRIGHT_OPENTTD, STR_NULL),
EndContainer(),
}
WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:48
WWT_LABEL
Centered label.
Definition: widget_type.h:57
NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1046
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
WWT_FRAME
Frame.
Definition: widget_type.h:60
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
WID_A_SCROLLING_TEXT
The actually scrolling text.
Definition: misc_widget.h:27
WID_A_WEBSITE
URL of OpenTTD website.
Definition: misc_widget.h:28
WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1076

Definition at line 372 of file misc_gui.cpp.

## ◆ _nested_land_info_widgets

const NWidgetPart _nested_land_info_widgets[]
| static

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_LAND_AREA_INFORMATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_DEBUGBOX, COLOUR_GREY),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_LI_BACKGROUND), EndContainer(),
}
NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
WWT_DEBUGBOX
NewGRF debug box (at top-right of a window, between WWT_CAPTION and WWT_SHADEBOX) ...
Definition: widget_type.h:63
WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69
WID_LI_BACKGROUND
Background of the window.
Definition: misc_widget.h:17
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999

Definition at line 45 of file misc_gui.cpp.

## ◆ _nested_query_string_widgets

const NWidgetPart _nested_query_string_widgets[]
| static

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_QS_CAPTION), SetDataTip(STR_WHITE_STRING, STR_NULL),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QS_TEXT), SetMinimalSize(256, 12), SetFill(1, 1), SetPadding(2, 2, 2, 2),
EndContainer(),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_DEFAULT), SetMinimalSize(87, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_DEFAULT, STR_NULL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_CANCEL), SetMinimalSize(86, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_OK), SetMinimalSize(87, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_OK, STR_NULL),
EndContainer(),
}
NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
WID_QS_OK
OK button.
Definition: misc_widget.h:37
WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:71
WID_QS_TEXT
Text of the query.
Definition: misc_widget.h:34
WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69
WID_QS_CAPTION
Caption of the window.
Definition: misc_widget.h:33
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1046
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
WID_QS_DEFAULT
Default button.
Definition: misc_widget.h:35
WID_QS_CANCEL
Cancel button.
Definition: misc_widget.h:36
WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:429
WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:55

Definition at line 1034 of file misc_gui.cpp.

## ◆ _nested_query_widgets

const NWidgetPart _nested_query_widgets[]
| static

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_RED),
NWidget(WWT_CAPTION, COLOUR_RED, WID_Q_CAPTION), SetDataTip(STR_JUST_STRING, STR_NULL),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_RED), SetPIP(8, 15, 8),
NWidget(WWT_TEXT, COLOUR_RED, WID_Q_TEXT), SetMinimalSize(200, 12),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(20, 29, 20),
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_Q_NO), SetMinimalSize(71, 12), SetFill(1, 1), SetDataTip(STR_QUIT_NO, STR_NULL),
NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_Q_YES), SetMinimalSize(71, 12), SetFill(1, 1), SetDataTip(STR_QUIT_YES, STR_NULL),
EndContainer(),
EndContainer(),
}
NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
WID_Q_TEXT
Text of the query.
Definition: misc_widget.h:43
WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69
WWT_TEXT
Pure simple text.
Definition: widget_type.h:58
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
WID_Q_YES
No button.
Definition: misc_widget.h:45
WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
WID_Q_NO
Yes button.
Definition: misc_widget.h:44
WID_Q_CAPTION
Caption of the window.
Definition: misc_widget.h:42
NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:429
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1076

Definition at line 1177 of file misc_gui.cpp.

## ◆ _nested_tooltips_widgets

const NWidgetPart _nested_tooltips_widgets[]
| static

Initial value:
= {
NWidget(WWT_PANEL, COLOUR_GREY, WID_TT_BACKGROUND), SetMinimalSize(200, 32), EndContainer(),
}
WID_TT_BACKGROUND
Background of the window.
Definition: misc_widget.h:22
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999

Definition at line 638 of file misc_gui.cpp.