misc_gui.cpp File Reference

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

#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "landscape.h"
#include "newgrf_text.h"
#include "saveload/saveload.h"
#include "tile_map.h"
#include "gui.h"
#include "station_gui.h"
#include "viewport_func.h"
#include "gfx_func.h"
#include "station_func.h"
#include "command_func.h"
#include "company_func.h"
#include "town.h"
#include "network/network.h"
#include "network/network_content.h"
#include "variables.h"
#include "company_base.h"
#include "texteff.hpp"
#include "cargotype.h"
#include "company_manager_face.h"
#include "strings_func.h"
#include "fileio_func.h"
#include "fios.h"
#include "zoom_func.h"
#include "window_func.h"
#include "string_func.h"
#include "newgrf_cargo.h"
#include "tilehighlight_func.h"
#include "querystring_gui.h"
#include "table/strings.h"

Go to the source code of this file.

Data Structures

class  LandInfoWindow
struct  AboutWindow
struct  ErrmsgWindow
struct  TooltipsWindow
struct  QueryStringWindow
struct  QueryWindow
 Window used for asking the user a YES/NO question. More...
struct  SaveLoadWindow

Defines

#define LANDINFOD_LEVEL   1

Enumerations

enum  QueryStringWidgets { QUERY_STR_WIDGET_TEXT = 3, QUERY_STR_WIDGET_DEFAULT, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK }
enum  QueryWidgets { QUERY_WIDGET_CAPTION = 1, QUERY_WIDGET_NO = 3, QUERY_WIDGET_YES }

Functions

static void Place_LandInfo (TileIndex tile)
void PlaceLandBlockInfo ()
void ShowAboutWindow ()
void ShowErrorMessage (StringID msg_1, StringID msg_2, int x, int y)
void ShowEstimatedCostOrIncome (Money cost, int x, int y)
void ShowCostOrIncomeAnimation (int x, int y, int z, Money cost)
void ShowFeederIncomeAnimation (int x, int y, int z, Money cost)
TextEffectID ShowFillingPercent (int x, int y, int z, uint8 percent, StringID string)
void UpdateFillingPercent (TextEffectID te_id, uint8 percent, StringID string)
void HideFillingPercent (TextEffectID *te_id)
void GuiShowTooltips (StringID str, uint paramcount, const uint64 params[], bool use_left_mouse_button)
 Shows a tooltip.
static int DrawStationCoverageText (const AcceptedCargo cargo, int str_x, int str_y, StationCoverageType sct, bool supplies)
int DrawStationCoverageAreaText (int sx, int sy, StationCoverageType sct, int rad, bool supplies)
 Calculates and draws the accepted or supplied cargo around the selected tile(s).
void CheckRedrawStationCoverage (const Window *w)
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 MoveTextBufferPos (Textbuf *tb, int navmode)
 Handle text navigation with arrow keys left/right.
void InitializeTextBuffer (Textbuf *tb, char *buf, uint16 maxsize, uint16 maxwidth)
 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)
void ShowQueryString (StringID str, StringID caption, uint maxsize, uint maxwidth, 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.
void BuildFileList ()
static void DrawFiosTexts (uint maxw)
static void MakeSortedSaveGameList ()
void StartupEngines ()
void ShowSaveLoadDialog (SaveLoadDialogMode mode)
void RedrawAutosave ()
void SetFiosType (const byte fiostype)

Variables

SaveLoadDialogMode _saveload_mode
 defined in misc_gui.cpp
static bool _fios_path_changed
static bool _savegame_sort_dirty
int _caret_timer
static const Widget _land_info_widgets []
static const WindowDesc _land_info_desc (WDP_AUTO, WDP_AUTO, 300, 100, 300, 100, WC_LAND_INFO, WC_NONE, WDF_STD_TOOLTIPS|WDF_STD_BTN|WDF_DEF_WIDGET, _land_info_widgets)
static const Widget _about_widgets []
static const WindowDesc _about_desc (WDP_CENTER, WDP_CENTER, 420, 272, 420, 272, WC_GAME_OPTIONS, WC_NONE, WDF_STD_TOOLTIPS|WDF_STD_BTN|WDF_DEF_WIDGET, _about_widgets)
static const Widget _errmsg_widgets []
static const Widget _errmsg_face_widgets []
static const Widget _tooltips_widgets []
static const Widget _query_string_widgets []
static const WindowDesc _query_string_desc (190, 219, 260, 42, 260, 42, WC_QUERY_STRING, WC_NONE, WDF_STD_TOOLTIPS|WDF_STD_BTN|WDF_DEF_WIDGET, _query_string_widgets)
static const Widget _query_widgets []
static const WindowDesc _query_desc (WDP_CENTER, WDP_CENTER, 210, 82, 210, 82, WC_CONFIRM_POPUP_QUERY, WC_NONE, WDF_STD_TOOLTIPS|WDF_STD_BTN|WDF_UNCLICK_BUTTONS|WDF_DEF_WIDGET|WDF_MODAL, _query_widgets)
static const Widget _load_dialog_widgets []
static const Widget _save_dialog_widgets []
const TextColour _fios_colours []
static const WindowDesc _load_dialog_desc (WDP_CENTER, WDP_CENTER, 257, 154, 257, 294, WC_SAVELOAD, WC_NONE, WDF_STD_TOOLTIPS|WDF_DEF_WIDGET|WDF_STD_BTN|WDF_UNCLICK_BUTTONS|WDF_RESIZABLE, _load_dialog_widgets)
static const WindowDesc _save_dialog_desc (WDP_CENTER, WDP_CENTER, 257, 180, 257, 320, WC_SAVELOAD, WC_NONE, WDF_STD_TOOLTIPS|WDF_DEF_WIDGET|WDF_STD_BTN|WDF_UNCLICK_BUTTONS|WDF_RESIZABLE, _save_dialog_widgets)
static const FileType _file_modetotype []
 These values are used to convert the file/operations mode into a corresponding file type.


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

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

int DrawStationCoverageAreaText ( int  sx,
int  sy,
StationCoverageType  sct,
int  rad,
bool  supplies 
)

Calculates and draws the accepted or supplied cargo around the selected tile(s).

Parameters:
sx x position where the string is to be drawn
sy y position where the string is to be drawn
sct which type of cargo is to be displayed (passengers/non-passengers)
rad radius around selected tile(s) to be searched
supplies if supplied cargos should be drawn, else accepted cargos
Returns:
Returns the y value below the string that was drawn

Definition at line 750 of file misc_gui.cpp.

References GetAcceptanceAroundTiles(), GetProductionAroundTiles(), MapSize(), and TILE_SIZE.

void GuiShowTooltips ( StringID  str,
uint  paramcount,
const uint64  params[],
bool  use_left_mouse_button 
)

Shows a tooltip.

Parameters:
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 671 of file misc_gui.cpp.

References Clamp(), DeleteWindowById(), GetStringBoundingBox(), Dimension::height, lastof, CursorVars::offs, CursorVars::pos, CursorVars::size, Dimension::width, Point::x, and Point::y.

Referenced by DispatchRightClickEvent(), and ShowMeasurementTooltips().

void InitializeTextBuffer ( Textbuf *  tb,
char *  buf,
uint16  maxsize,
uint16  maxwidth 
)

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
maxsize maximum size in bytes, including terminating ''
maxwidth maximum length in pixels of this buffer. If reached, buffer cannot grow, even if maxsize would allow because there is space. Width of zero '0' means the buffer is only restricted by maxsize

Definition at line 913 of file misc_gui.cpp.

References UpdateTextBufferSize().

Referenced by ShowQueryString().

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

References GetCharacterWidth(), and Utf8CharLen().

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

References GetCharacterWidth(), and Utf8PrevChar().

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.

NOTE: You cannot use BindCString as parameter for this window!

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

Referenced by CmdPause(), and NewGRFWindow::OnClick().

void ShowQueryString ( StringID  str,
StringID  caption,
uint  maxsize,
uint  maxwidth,
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 (including terminating '')
maxwidth maximum width in pixels allowed
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 1200 of file misc_gui.cpp.

References DeleteWindowById(), InitializeTextBuffer(), QSF_ACCEPT_UNCHANGED, and QSF_ENABLE_DEFAULT.

Referenced by StationViewWindow::OnClick(), NewGRFWindow::OnClick(), CompanyWindow::OnClick(), and AISettingsWindow::OnClick().

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

References buf, GetCharacterWidth(), and Utf8CharLen().

Referenced by IConsoleHistoryNavigate(), and InitializeTextBuffer().


Variable Documentation

const Widget _about_widgets[] [static]

Initial value:

 {
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   419,     0,    13, STR_015B_OPENTTD, STR_NULL},
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   419,    14,   271, 0x0,              STR_NULL},
{      WWT_FRAME,   RESIZE_NONE,  COLOUR_GREY,     5,   414,    40,   245, STR_NULL,         STR_NULL},
{    WIDGETS_END},
}

Definition at line 278 of file misc_gui.cpp.

const Widget _errmsg_face_widgets[] [static]

Initial value:

 {
{   WWT_CLOSEBOX,   RESIZE_NONE,    COLOUR_RED,     0,    10,     0,    13, STR_00C5,              STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,   RESIZE_NONE,    COLOUR_RED,    11,   333,     0,    13, STR_00B3_MESSAGE_FROM, STR_NULL},
{      WWT_PANEL,   RESIZE_BOTTOM,  COLOUR_RED,     0,   333,    14,   136, 0x0,                   STR_NULL},
{   WIDGETS_END},
}

Definition at line 411 of file misc_gui.cpp.

const Widget _errmsg_widgets[] [static]

Initial value:

 {
{   WWT_CLOSEBOX,   RESIZE_NONE,    COLOUR_RED,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,   RESIZE_NONE,    COLOUR_RED,    11,   239,     0,    13, STR_00B2_MESSAGE, STR_NULL},
{      WWT_PANEL,   RESIZE_BOTTOM,  COLOUR_RED,     0,   239,    14,    45, 0x0,              STR_NULL},
{    WIDGETS_END},
}

Definition at line 404 of file misc_gui.cpp.

const FileType _file_modetotype[] [static]

Initial value:

 {
  FT_SAVEGAME,  
  FT_SCENARIO,  
  FT_SAVEGAME,  
  FT_SCENARIO,  
  FT_HEIGHTMAP, 
  FT_SAVEGAME,  
}
These values are used to convert the file/operations mode into a corresponding file type.

So each entry, as expressed by the related comment, is based on the enum

Definition at line 1754 of file misc_gui.cpp.

const TextColour _fios_colours[]

Initial value:

 {
  TC_LIGHT_BLUE, TC_DARK_GREEN,  TC_DARK_GREEN, TC_ORANGE, TC_LIGHT_BROWN,
  TC_ORANGE,     TC_LIGHT_BROWN, TC_ORANGE,     TC_ORANGE, TC_YELLOW
}

Definition at line 1379 of file misc_gui.cpp.

const Widget _land_info_widgets[] [static]

Initial value:

 {
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   299,     0,    13, STR_01A3_LAND_AREA_INFORMATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
{      WWT_PANEL, RESIZE_BOTTOM,  COLOUR_GREY,     0,   299,    14,    99, 0x0,                            STR_NULL},
{    WIDGETS_END},
}

Definition at line 47 of file misc_gui.cpp.

const Widget _load_dialog_widgets[] [static]

Initial value:

 {
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,                 STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,  RESIZE_RIGHT,  COLOUR_GREY,    11,   256,     0,    13, STR_NULL,                 STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,   127,    14,    25, STR_SORT_BY_NAME,         STR_SORT_ORDER_TIP},
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   128,   256,    14,    25, STR_SORT_BY_DATE,         STR_SORT_ORDER_TIP},
{      WWT_PANEL,  RESIZE_RIGHT,  COLOUR_GREY,     0,   256,    26,    47, 0x0,                      STR_NULL},
{      WWT_PANEL,     RESIZE_RB,  COLOUR_GREY,     0,   256,    48,   153, 0x0,                      STR_NULL},
{ WWT_PUSHIMGBTN,     RESIZE_LR,  COLOUR_GREY,   245,   256,    48,    59, SPR_HOUSE_ICON,           STR_SAVELOAD_HOME_BUTTON},
{      WWT_INSET,     RESIZE_RB,  COLOUR_GREY,     2,   243,    50,   139, 0x0,                      STR_400A_LIST_OF_DRIVES_DIRECTORIES},
{  WWT_SCROLLBAR,    RESIZE_LRB,  COLOUR_GREY,   245,   256,    60,   141, 0x0,                      STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PUSHTXTBTN,    RESIZE_RTB,  COLOUR_GREY,     0,   243,   142,   153, STR_CONTENT_INTRO_BUTTON, STR_CONTENT_INTRO_BUTTON_TIP},
{  WWT_RESIZEBOX,   RESIZE_LRTB,  COLOUR_GREY,   245,   256,   142,   153, 0x0,                      STR_RESIZE_BUTTON},
{   WIDGETS_END},
}

Definition at line 1345 of file misc_gui.cpp.

const Widget _query_string_widgets[] [static]

Initial value:

 {
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,        STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,   RESIZE_NONE,  COLOUR_GREY,    11,   259,     0,    13, STR_012D,        STR_NULL},
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   259,    14,    29, 0x0,             STR_NULL},
{    WWT_EDITBOX,   RESIZE_NONE,  COLOUR_GREY,     2,   257,    16,    27, 0x0,             STR_NULL}, 
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,    86,    30,    41, STR_DEFAULT,     STR_NULL}, 
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,    87,   172,    30,    41, STR_012E_CANCEL, STR_NULL}, 
{    WWT_TEXTBTN,   RESIZE_NONE,  COLOUR_GREY,   173,   259,    30,    41, STR_012F_OK,     STR_NULL}, 
{   WIDGETS_END},
}

Definition at line 1172 of file misc_gui.cpp.

const Widget _query_widgets[] [static]

Initial value:

 {
{  WWT_CLOSEBOX, RESIZE_NONE,  COLOUR_RED,      0,  10,   0,  13, STR_00C5,        STR_018B_CLOSE_WINDOW},
{   WWT_CAPTION, RESIZE_NONE,  COLOUR_RED,     11, 209,   0,  13, STR_NULL,        STR_NULL},
{     WWT_PANEL, RESIZE_NONE,  COLOUR_RED,      0, 209,  14,  81, 0x0, STR_NULL},
{WWT_PUSHTXTBTN, RESIZE_NONE,  COLOUR_YELLOW,  20,  90,  62,  73, STR_00C9_NO,     STR_NULL},
{WWT_PUSHTXTBTN, RESIZE_NONE,  COLOUR_YELLOW, 120, 190,  62,  73, STR_00C8_YES,    STR_NULL},
{   WIDGETS_END },
}

Definition at line 1314 of file misc_gui.cpp.

const Widget _save_dialog_widgets[] [static]

Initial value:

 {
{   WWT_CLOSEBOX,   RESIZE_NONE,  COLOUR_GREY,     0,    10,     0,    13, STR_00C5,         STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,  RESIZE_RIGHT,  COLOUR_GREY,    11,   256,     0,    13, STR_NULL,         STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,     0,   127,    14,    25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP},
{ WWT_PUSHTXTBTN,   RESIZE_NONE,  COLOUR_GREY,   128,   256,    14,    25, STR_SORT_BY_DATE, STR_SORT_ORDER_TIP},
{      WWT_PANEL,  RESIZE_RIGHT,  COLOUR_GREY,     0,   256,    26,    47, 0x0,              STR_NULL},
{      WWT_PANEL,     RESIZE_RB,  COLOUR_GREY,     0,   256,    48,   167, 0x0,              STR_NULL},
{ WWT_PUSHIMGBTN,     RESIZE_LR,  COLOUR_GREY,   245,   256,    48,    59, SPR_HOUSE_ICON,   STR_SAVELOAD_HOME_BUTTON},
{      WWT_INSET,     RESIZE_RB,  COLOUR_GREY,     2,   243,    50,   150, 0x0,              STR_400A_LIST_OF_DRIVES_DIRECTORIES},
{  WWT_SCROLLBAR,    RESIZE_LRB,  COLOUR_GREY,   245,   256,    60,   151, 0x0,              STR_0190_SCROLL_BAR_SCROLLS_LIST},
{      WWT_PANEL,    RESIZE_RTB,  COLOUR_GREY,     0,   256,   152,     0, 0x0,              STR_NULL},
{    WWT_EDITBOX,    RESIZE_RTB,  COLOUR_GREY,     2,   254,   154,   165, STR_SAVE_OSKTITLE, STR_400B_CURRENTLY_SELECTED_NAME},
{ WWT_PUSHTXTBTN,     RESIZE_TB,  COLOUR_GREY,     0,   127,   168,   179, STR_4003_DELETE,  STR_400C_DELETE_THE_CURRENTLY_SELECTED},
{ WWT_PUSHTXTBTN,     RESIZE_TB,  COLOUR_GREY,   128,   244,   168,   179, STR_4002_SAVE,    STR_400D_SAVE_THE_CURRENT_GAME_USING},
{  WWT_RESIZEBOX,   RESIZE_LRTB,  COLOUR_GREY,   245,   256,   168,   179, 0x0,              STR_RESIZE_BUTTON},
{   WIDGETS_END},
}

Definition at line 1360 of file misc_gui.cpp.

const Widget _tooltips_widgets[] [static]

Initial value:

 {
{      WWT_PANEL,   RESIZE_NONE,  COLOUR_GREY,     0,   199,     0,    31, 0x0, STR_NULL},
{   WIDGETS_END},
}

Definition at line 616 of file misc_gui.cpp.


Generated on Thu Oct 1 11:03:22 2009 for OpenTTD by  doxygen 1.5.6