Data Structures | Defines | 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 "widgets/misc_widget.h"
#include "table/strings.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...

Defines

#define LANDINFOD_LEVEL   1

Functions

bool GetClipboardContents (char *buffer, size_t buff_len)
 Try to retrive the current clipboard contents.
void ShowLandInfo (TileIndex tile)
 Show land information window.
void ShowAboutWindow ()
void ShowEstimatedCostOrIncome (Money cost, int x, int y)
 Display estimated costs.
void ShowCostOrIncomeAnimation (int x, int y, int z, Money cost)
 Display animated income or costs on the map.
void ShowFeederIncomeAnimation (int x, int y, int z, Money transfer, Money income)
 Display animated feeder income.
TextEffectID ShowFillingPercent (int x, int y, int z, uint8 percent, StringID string)
 Display vehicle loading indicators.
void UpdateFillingPercent (TextEffectID te_id, uint8 percent, StringID string)
 Update vehicle loading indicators.
void HideFillingPercent (TextEffectID *te_id)
 Hide vehicle loading indicators.
void GuiShowTooltips (Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
 Shows a tooltip.
static void DelChar (Textbuf *tb, bool backspace)
bool DeleteTextBufferChar (Textbuf *tb, int delmode)
 Delete a character from a textbuffer, either with 'Delete' or 'Backspace' The character is delete from the position the caret is at.
void DeleteTextBufferAll (Textbuf *tb)
 Delete every character in the textbuffer.
bool InsertTextBufferChar (Textbuf *tb, WChar key)
 Insert a character to a textbuffer.
bool InsertTextBufferClipboard (Textbuf *tb)
 Insert a chunk of text from the clipboard onto the textbuffer.
bool MoveTextBufferPos (Textbuf *tb, int navmode)
 Handle text navigation with arrow keys left/right.
void InitializeTextBuffer (Textbuf *tb, char *buf, uint16 max_bytes)
 Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.
void InitializeTextBuffer (Textbuf *tb, char *buf, uint16 max_bytes, uint16 max_chars)
 Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.
void UpdateTextBufferSize (Textbuf *tb)
 Update Textbuf type with its actual physical character and screenlength Get the count of characters in the string as well as the width in pixels.
bool HandleCaret (Textbuf *tb)
 Handle the flashing of the caret.
void ShowQueryString (StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
 Show a query popup window with a textbox in it.
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.

Variables

int _caret_timer
static const NWidgetPart _nested_land_info_widgets []
static const WindowDesc _land_info_desc (WDP_AUTO, 0, 0, WC_LAND_INFO, WC_NONE, 0, _nested_land_info_widgets, lengthof(_nested_land_info_widgets))
static const NWidgetPart _nested_about_widgets []
static const WindowDesc _about_desc (WDP_CENTER, 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 const WindowDesc _tool_tips_desc (WDP_MANUAL, 0, 0, WC_TOOLTIPS, WC_NONE, 0, _nested_tooltips_widgets, lengthof(_nested_tooltips_widgets))
static const NWidgetPart _nested_query_string_widgets []
static const WindowDesc _query_string_desc (WDP_CENTER, 0, 0, WC_QUERY_STRING, WC_NONE, 0, _nested_query_string_widgets, lengthof(_nested_query_string_widgets))
static const NWidgetPart _nested_query_widgets []
static const WindowDesc _query_desc (WDP_CENTER, 0, 0, WC_CONFIRM_POPUP_QUERY, WC_NONE, WDF_UNCLICK_BUTTONS|WDF_MODAL, _nested_query_widgets, lengthof(_nested_query_widgets))

Detailed Description

GUIs for a number of misc windows.

Definition in file misc_gui.cpp.


Function Documentation

void DeleteTextBufferAll ( Textbuf tb  ) 

Delete every character in the textbuffer.

Parameters:
tb Textbuf buffer to be emptied

Definition at line 778 of file misc_gui.cpp.

References Textbuf::buf, Textbuf::bytes, Textbuf::caretpos, Textbuf::caretxoffs, Textbuf::chars, Textbuf::max_bytes, and Textbuf::pixels.

Referenced by IConsoleWindow::OnKeyPress().

bool DeleteTextBufferChar ( Textbuf tb,
int  delmode 
)

Delete a character from a textbuffer, either with 'Delete' or 'Backspace' The character is delete from the position the caret is at.

Parameters:
tb Textbuf type to be changed
delmode Type of deletion, either WKC_BACKSPACE or WKC_DELETE
Returns:
Return true on successful change of Textbuf, or false otherwise

Definition at line 761 of file misc_gui.cpp.

References Textbuf::bytes, and Textbuf::caretpos.

Referenced by OskWindow::OnClick(), and IConsoleWindow::OnKeyPress().

bool GetClipboardContents ( char *  buffer,
size_t  buff_len 
)

Try to retrive the current clipboard contents.

Note:
OS-specific funtion.
Returns:
True if some text could be retrived.

Definition at line 178 of file os2.cpp.

References convert_from_fs(), FS2OTTD(), and ttd_strlcpy().

Referenced by InsertTextBufferClipboard().

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) mousebutton is released

Definition at line 720 of file misc_gui.cpp.

References DeleteWindowById(), and WC_TOOLTIPS.

Referenced by DispatchHoverEvent(), DispatchRightClickEvent(), IndustryCargoesWindow::OnHover(), DepotWindow::OnRightClick(), and ShowMeasurementTooltips().

bool HandleCaret ( Textbuf tb  ) 

Handle the flashing of the caret.

Parameters:
tb The text buffer to handle the caret of.
Returns:
True if the caret state changes.

Definition at line 971 of file misc_gui.cpp.

References Textbuf::caret.

Referenced by IConsoleWindow::OnMouseLoop().

void HideFillingPercent ( TextEffectID *  te_id  ) 

Hide vehicle loading indicators.

Parameters:
*te_id TextEffectID which is supposed to be hidden.

Definition at line 607 of file misc_gui.cpp.

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

void InitializeTextBuffer ( Textbuf tb,
char *  buf,
uint16  max_bytes 
)

Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.

Parameters:
tb Textbuf type which is getting initialized
buf the buffer that will be holding the data for input
max_bytes maximum size in bytes, including terminating ''

Definition at line 914 of file misc_gui.cpp.

References InitializeTextBuffer().

Referenced by AIDebugWindow::AIDebugWindow(), InitializeTextBuffer(), NetworkChatWindow::NetworkChatWindow(), and NetworkContentListWindow::NetworkContentListWindow().

void InitializeTextBuffer ( Textbuf tb,
char *  buf,
uint16  max_bytes,
uint16  max_chars 
)

Initialize the textbuffer by supplying it the buffer to write into and the maximum length of this buffer.

Parameters:
tb Textbuf type which is getting initialized
buf the buffer that will be holding the data for input
max_bytes maximum size in bytes, including terminating ''
max_chars maximum size in chars, including terminating ''

Definition at line 927 of file misc_gui.cpp.

References Textbuf::buf, Textbuf::caret, Textbuf::max_bytes, Textbuf::max_chars, and UpdateTextBufferSize().

bool InsertTextBufferChar ( Textbuf tb,
WChar  key 
)

Insert a character to a textbuffer.

If maxwidth of the Textbuf is zero, we don't care about the visual-length but only about the physical length of the string

Parameters:
tb Textbuf type to be changed
key Character to be inserted
Returns:
Return true on successful change of Textbuf, or false otherwise

Definition at line 793 of file misc_gui.cpp.

References Textbuf::buf, Textbuf::bytes, Textbuf::caretpos, Textbuf::caretxoffs, Textbuf::chars, FS_NORMAL, GetCharacterWidth(), Textbuf::max_chars, Textbuf::pixels, Utf8CharLen(), and Utf8Encode().

Referenced by OskWindow::OnClick(), and IConsoleWindow::OnKeyPress().

bool InsertTextBufferClipboard ( Textbuf tb  ) 

Insert a chunk of text from the clipboard onto the textbuffer.

Get TEXT clipboard and append this up to the maximum length (either absolute or screenlength). If maxlength is zero, we don't care about the screenlength but only about the physical length of the string

Parameters:
tb Textbuf type to be changed
Returns:
true on successful change of Textbuf, or false otherwise

Definition at line 818 of file misc_gui.cpp.

References Textbuf::buf, Textbuf::bytes, Textbuf::caretpos, Textbuf::caretxoffs, Textbuf::chars, FS_NORMAL, GetCharacterWidth(), GetClipboardContents(), lengthof, Textbuf::max_bytes, Textbuf::max_chars, Textbuf::pixels, and Utf8CharLen().

Referenced by IConsoleWindow::OnKeyPress().

bool MoveTextBufferPos ( Textbuf tb,
int  navmode 
)

Handle text navigation with arrow keys left/right.

This defines where the caret will blink and the next characer interaction will occur

Parameters:
tb Textbuf type where navigation occurs
navmode Direction in which navigation occurs WKC_LEFT, WKC_RIGHT, WKC_END, WKC_HOME
Returns:
Return true on successful change of Textbuf, or false otherwise

Definition at line 864 of file misc_gui.cpp.

References Textbuf::buf, Textbuf::bytes, Textbuf::caretpos, Textbuf::caretxoffs, FS_NORMAL, GetCharacterWidth(), Textbuf::pixels, Utf8Decode(), and Utf8PrevChar().

Referenced by OskWindow::OnClick(), and IConsoleWindow::OnKeyPress().

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 532 of file misc_gui.cpp.

References DAY_TICKS, RemapCoords(), SetDParam(), and TE_RISING.

Referenced by DoCommandP(), and VehicleEnterDepot().

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 513 of file misc_gui.cpp.

References INVALID_STRING_ID, SetDParam(), ShowErrorMessage(), and WL_INFO.

Referenced by DoCommandP().

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 553 of file misc_gui.cpp.

References DAY_TICKS, RemapCoords(), SetDParam(), and TE_RISING.

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 580 of file misc_gui.cpp.

References RemapCoords(), SetDParam(), and TE_STATIC.

Referenced by LoadUnloadVehicle().

void ShowLandInfo ( TileIndex  tile  ) 

Show land information window.

Parameters:
tile The tile to show information about.

Definition at line 347 of file misc_gui.cpp.

References DeleteWindowById(), and WC_LAND_INFO.

Referenced by ScenarioEditorToolbarWindow::OnPlaceObject(), and MainToolbarWindow::OnPlaceObject().

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 1395 of file misc_gui.cpp.

References FindWindowById(), Window::parent, QueryWindow::proc, WC_CONFIRM_POPUP_QUERY, WC_MAIN_WINDOW, and Window::window_class.

Referenced by CmdPause(), ScenarioEditorLandscapeGenerationWindow::OnClick(), GenerateProgressWindow::OnClick(), and DepotWindow::OnClick().

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 '') 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 1256 of file misc_gui.cpp.

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

Referenced by WaypointWindow::OnClick(), VehicleDetailsWindow::OnClick(), TownViewWindow::OnClick(), TimetableWindow::OnClick(), StationViewWindow::OnClick(), CustomCurrencyWindow::OnClick(), GameSettingsWindow::OnClick(), OrdersWindow::OnClick(), NewGRFParametersWindow::OnClick(), SpriteAlignerWindow::OnClick(), IndustryViewWindow::OnClick(), CreateScenarioWindow::OnClick(), DepotWindow::OnClick(), CompanyWindow::OnClick(), SelectCompanyManagerFaceWindow::OnClick(), CheatWindow::OnClick(), BuildVehicleWindow::OnClick(), AISettingsWindow::OnClick(), and ToolbarScenDatePanel().

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

Update vehicle loading indicators.

Parameters:
te_id TextEffectID to be updated.
string String wich is printed.

Definition at line 595 of file misc_gui.cpp.

References SetDParam().

Referenced by LoadUnloadVehicle().

void UpdateTextBufferSize ( Textbuf tb  ) 

Update Textbuf type with its actual physical character and screenlength Get the count of characters in the string as well as the width in pixels.

Useful when copying in a larger amount of text at once

Parameters:
tb Textbuf type which length is calculated

Definition at line 945 of file misc_gui.cpp.

References Textbuf::buf, Textbuf::bytes, Textbuf::caretpos, Textbuf::caretxoffs, Textbuf::chars, FS_NORMAL, GetCharacterWidth(), Textbuf::max_bytes, Textbuf::max_chars, Textbuf::pixels, and Utf8CharLen().

Referenced by AIDebugWindow::AIDebugWindow(), NetworkChatWindow::ChatTabCompletion(), SignListWindow::ClearFilterTextWidget(), IConsoleHistoryNavigate(), InitializeTextBuffer(), and OskWindow::OnClick().


Variable Documentation

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(),
}

Definition at line 353 of file misc_gui.cpp.

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(),
}

Definition at line 43 of file misc_gui.cpp.

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(),
}

Definition at line 1224 of file misc_gui.cpp.

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), SetDataTip(STR_QUIT_NO, STR_NULL),
      NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_Q_YES), SetMinimalSize(71, 12), SetDataTip(STR_QUIT_YES, STR_NULL),
    EndContainer(),
  EndContainer(),
}

Definition at line 1365 of file misc_gui.cpp.

const NWidgetPart _nested_tooltips_widgets[] [static]
Initial value:

Definition at line 615 of file misc_gui.cpp.