settings_gui.cpp File Reference

#include "stdafx.h"
#include "openttd.h"
#include "currency.h"
#include "gui.h"
#include "window_gui.h"
#include "textbuf_gui.h"
#include "command_func.h"
#include "engine.h"
#include "screenshot.h"
#include "newgrf.h"
#include "network/network.h"
#include "town.h"
#include "variables.h"
#include "settings_internal.h"
#include "newgrf_townname.h"
#include "strings_func.h"
#include "functions.h"
#include "window_func.h"
#include "vehicle_base.h"
#include "core/alloc_func.hpp"
#include "string_func.h"
#include "gfx_func.h"
#include "waypoint.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
#include "table/sprites.h"
#include "table/strings.h"

Go to the source code of this file.

Data Structures

struct  GameSettingData
struct  difficulty_d
 Carriage for the game settings window data. More...
struct  PatchEntry
struct  PatchPage

Defines

#define DIFF_INGAME_DISABLED_BUTTONS   0x383E
#define NO_SETTINGS_BUTTON   0xFF

Enumerations

enum  GameOptionsWidgets {
  GAMEOPT_CURRENCY_BTN = 4, GAMEOPT_DISTANCE_BTN = 6, GAMEOPT_ROADSIDE_BTN = 8, GAMEOPT_TOWNNAME_BTN = 10,
  GAMEOPT_AUTOSAVE_BTN = 12, GAMEOPT_VEHICLENAME_BTN = 14, GAMEOPT_VEHICLENAME_SAVE, GAMEOPT_LANG_BTN = 17,
  GAMEOPT_RESOLUTION_BTN = 19, GAMEOPT_FULLSCREEN, GAMEOPT_SCREENSHOT_BTN = 22
}
enum  { GAMEDIFF_WND_TOP_OFFSET = 45, GAMEDIFF_WND_ROWSIZE = 9 }
enum  GameDifficultyWidgets {
  GDW_CLOSEBOX = 0, GDW_CAPTION, GDW_UPPER_BG, GDW_LVL_EASY,
  GDW_LVL_MEDIUM, GDW_LVL_HARD, GDW_LVL_CUSTOM, GDW_HIGHSCORE,
  GDW_SETTING_BG, GDW_LOWER_BG, GDW_ACCEPT, GDW_CANCEL
}
enum  PatchesSelectionWidgets {
  PATCHSEL_OPTIONSPANEL = 3, PATCHSEL_INTERFACE, PATCHSEL_CONSTRUCTION, PATCHSEL_VEHICLES,
  PATCHSEL_STATIONS, PATCHSEL_ECONOMY, PATCHSEL_COMPETITORS
}
enum  CustomCurrenciesWidgets {
  CUSTCURR_EXCHANGERATE = 0, CUSTCURR_SEPARATOR, CUSTCURR_PREFIX, CUSTCURR_SUFFIX,
  CUSTCURR_TO_EURO
}
 These are not, strickly speaking, widget enums, since they have been changed as line coordinates. More...

Functions

static StringID * BuildDynamicDropdown (StringID base, int num)
void InitGRFTownGeneratorNames ()
static StringID TownName (int town_name)
static int GetCurRes ()
static bool RoadVehiclesAreBuilt ()
static void ShowTownnameDropdown (Window *w, int sel)
 Update/redraw the townnames dropdown.
static void ShowLangDropdown (Window *w)
 Update/redraw the languages dropdown.
static void ShowCustCurrency ()
static void GameOptionsWndProc (Window *w, WindowEvent *e)
CommandCost CmdSetRoadDriveSide (TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 Change the side of the road vehicles drive on (server only).
void ShowGameOptions ()
void SetDifficultyLevel (int mode, GameOptions *gm_opt)
void CheckDifficultyLevels ()
 Checks the difficulty levels read from the configuration and forces them to be correct when invalid.
void StartupEconomy ()
 assert_compile (WINDOW_CUSTOM_SIZE >=sizeof(difficulty_d))
static void GameDifficultyWndProc (Window *w, WindowEvent *e)
void ShowGameDifficulty ()
static void PatchesSelectionWndProc (Window *w, WindowEvent *e)
 The main patches window.
void ShowPatchesSelection ()
void DrawArrowButtons (int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right)
 Draw [<][>] boxes.
static void CustCurrencyWndProc (Window *w, WindowEvent *e)

Variables

static const StringID _units_dropdown []
static const StringID _driveside_dropdown []
static const StringID _autosave_dropdown []
static const StringID _designnames_dropdown []
int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1
static StringID * _grf_names = NULL
static int _nb_grf_names = 0
static const Widget _game_options_widgets []
static const WindowDesc _game_options_desc
static const GameSettingData _game_setting_info []
static const GDType _default_game_diff [3][GAME_DIFFICULTY_NUM]
static GameOptions _opt_mod_temp
static const Widget _game_difficulty_widgets []
static const WindowDesc _game_difficulty_desc
static const char * _patches_ui []
static const char * _patches_construction []
static const char * _patches_stations []
static const char * _patches_economy []
static const char * _patches_ai []
static const char * _patches_vehicles []
static PatchPage _patches_page []
static const Widget _patches_selection_widgets []
static const WindowDesc _patches_selection_desc
static char _str_separator [2]
static const Widget _cust_currency_widgets []
static const WindowDesc _cust_currency_desc


Detailed Description

Definition in file settings_gui.cpp.


Enumeration Type Documentation

These are not, strickly speaking, widget enums, since they have been changed as line coordinates.

So, rather, they are more like order of appearance

Definition at line 1139 of file settings_gui.cpp.


Function Documentation

CommandCost CmdSetRoadDriveSide ( TileIndex  tile,
uint32  flags,
uint32  p1,
uint32  p2 
)

Change the side of the road vehicles drive on (server only).

Parameters:
tile unused
flags operation to perform
p1 the side of the road; 0 = left side and 1 = right side
p2 unused

Definition at line 334 of file settings_gui.cpp.

References CMD_ERROR, and DC_EXEC.

void DrawArrowButtons ( int  x,
int  y,
int  ctab,
byte  state,
bool  clickable_left,
bool  clickable_right 
)

Draw [<][>] boxes.

Parameters:
x the x position to draw
y the y position to draw
ctab the color of the buttons
state 0 = none clicked, 1 = first clicked, 2 = second clicked
clickable_left is the left button clickable?
clickable_right is the right button clickable?

Definition at line 1120 of file settings_gui.cpp.

References _colour_gradient, FR_LOWERED, and PALETTE_MODIFIER_GREYOUT.

Referenced by PatchesSelectionWndProc().

static void PatchesSelectionWndProc ( Window *  w,
WindowEvent *  e 
) [static]

The main patches window.

Shows a number of categories on top and a selection of patches in that category. Uses WP(w, def_d) macro - data_1, data_2, data_3

Definition at line 861 of file settings_gui.cpp.

References _networking, _patches_newgame, CS_NUMERAL, DrawArrowButtons(), FR_LOWERED, GetVariableAddress(), min(), ReadValue(), ResizeWindowForWidget(), SDT_BOOLX, SDT_NUMX, SetPatchValue(), SetWindowDirty(), SGF_0ISDISABLED, SGF_CURRENCY, SGF_MULTISTRING, SGF_NETWORK_ONLY, SGF_NO_NETWORK, SGF_NOCOMMA, ShowQueryString(), and SLF_NETWORK_NO.

static void ShowLangDropdown ( Window *  w  )  [static]

Update/redraw the languages dropdown.

Parameters:
w the window the dropdown belongs to

Definition at line 157 of file settings_gui.cpp.

References DynamicLanguages::curr, and DynamicLanguages::num.

static void ShowTownnameDropdown ( Window *  w,
int  sel 
) [static]

Update/redraw the townnames dropdown.

Parameters:
w the window the dropdown belongs to
sel the currently selected townname generator

Definition at line 134 of file settings_gui.cpp.


Variable Documentation

const StringID _autosave_dropdown[] [static]

Initial value:

 {
  STR_02F7_OFF,
  STR_AUTOSAVE_1_MONTH,
  STR_02F8_EVERY_3_MONTHS,
  STR_02F9_EVERY_6_MONTHS,
  STR_02FA_EVERY_12_MONTHS,
  INVALID_STRING_ID,
}

Definition at line 47 of file settings_gui.cpp.

const WindowDesc _cust_currency_desc [static]

Initial value:

 {
  WDP_CENTER, WDP_CENTER, 230, 120, 230, 120,
  WC_CUSTOM_CURRENCY, WC_NONE,
  WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
  _cust_currency_widgets,
  CustCurrencyWndProc,
}

Definition at line 1323 of file settings_gui.cpp.

const Widget _cust_currency_widgets[] [static]

Initial value:

 {
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   229,     0,    13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS},
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   229,    14,   119, 0x0,                 STR_NULL},
{   WIDGETS_END},
}

Definition at line 1316 of file settings_gui.cpp.

const GDType _default_game_diff[3][GAME_DIFFICULTY_NUM] [static]

Initial value:

 { 
  {2, 2, 2, 4, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, 
  {4, 1, 2, 3, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, 
  {7, 0, 3, 3, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, 
}

Definition at line 442 of file settings_gui.cpp.

const StringID _designnames_dropdown[] [static]

Initial value:

 {
  STR_02BE_DEFAULT,
  STR_02BF_CUSTOM,
  INVALID_STRING_ID
}

Definition at line 56 of file settings_gui.cpp.

const StringID _driveside_dropdown[] [static]

Initial value:

 {
  STR_02E9_DRIVE_ON_LEFT,
  STR_02EA_DRIVE_ON_RIGHT,
  INVALID_STRING_ID
}

Definition at line 41 of file settings_gui.cpp.

const WindowDesc _game_difficulty_desc [static]

Initial value:

 {
  WDP_CENTER, WDP_CENTER, 370, 279, 370, 279,
  WC_GAME_OPTIONS, WC_NONE,
  WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
  _game_difficulty_widgets,
  GameDifficultyWndProc
}

Definition at line 686 of file settings_gui.cpp.

const Widget _game_difficulty_widgets[] [static]

Initial value:

 {
{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},           
{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_6800_DIFFICULTY_LEVEL,    STR_018C_WINDOW_TITLE_DRAG_THIS}, 
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                          STR_NULL},                        
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_6801_EASY,                STR_NULL},                        
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_6802_MEDIUM,              STR_NULL},                        
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_6803_HARD,                STR_NULL},                        
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_6804_CUSTOM,              STR_NULL},                        
{    WWT_TEXTBTN,   RESIZE_NONE,     6,    10,   357,    28,    39, STR_6838_SHOW_HI_SCORE_CHART, STR_NULL},                        
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   262, 0x0,                          STR_NULL},                        
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,   263,   278, 0x0,                          STR_NULL},                        
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   105,   185,   265,   276, STR_OPTIONS_SAVE_CHANGES,     STR_NULL},                        
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   186,   266,   265,   276, STR_012E_CANCEL,              STR_NULL},                        
{   WIDGETS_END},
}

Definition at line 669 of file settings_gui.cpp.

const WindowDesc _game_options_desc [static]

Initial value:

 {
  WDP_CENTER, WDP_CENTER, 370, 239, 370, 239,
  WC_GAME_OPTIONS, WC_NONE,
  WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
  _game_options_widgets,
  GameOptionsWndProc
}

Definition at line 379 of file settings_gui.cpp.

const GameSettingData _game_setting_info[] [static]

Initial value:

 {
  {  0,   7,  1, STR_NULL},
  {  0,   3,  1, STR_6830_IMMEDIATE},
  {  0,   3,  1, STR_NUM_VERY_LOW},
  {  0,   4,  1, STR_NONE},
  {100, 500, 50, STR_NULL},
  {  2,   4,  1, STR_NULL},
  {  0,   2,  1, STR_6820_LOW},
  {  0,   4,  1, STR_681B_VERY_SLOW},
  {  0,   2,  1, STR_6820_LOW},
  {  0,   2,  1, STR_6823_NONE},
  {  0,   3,  1, STR_6826_X1_5},
  {  0,   2,  1, STR_6820_LOW},
  {  0,   3,  1, STR_682A_VERY_FLAT},
  {  0,   3,  1, STR_VERY_LOW},
  {  0,   1,  1, STR_682E_STEADY},
  {  0,   1,  1, STR_6834_AT_END_OF_LINE_AND_AT_STATIONS},
  {  0,   1,  1, STR_6836_OFF},
  {  0,   2,  1, STR_PERMISSIVE},
}

Definition at line 401 of file settings_gui.cpp.

const char* _patches_ai[] [static]

Initial value:

 {
  "ainew_active",
  "ai_in_multiplayer",
  "ai_disable_veh_train",
  "ai_disable_veh_roadveh",
  "ai_disable_veh_aircraft",
  "ai_disable_veh_ship",
}

Definition at line 783 of file settings_gui.cpp.

const char* _patches_construction[] [static]

Initial value:

 {
  "build_on_slopes",
  "autoslope",
  "extra_dynamite",
  "longbridges",
  "signal_side",
  "always_small_airport",
  "enable_signal_gui",
  "drag_signals_density",
  "oil_refinery_limit",
  "semaphore_build_before",
}

Definition at line 736 of file settings_gui.cpp.

const char* _patches_economy[] [static]

Initial value:

 {
  "inflation",
  "raw_industry_construction",
  "multiple_industry_per_town",
  "same_industry_close",
  "bribe",
  "exclusive_rights",
  "give_money",
  "colored_news_year",
  "ending_year",
  "smooth_economy",
  "allow_shares",
  "town_layout",
  "mod_road_rebuild",
  "town_growth_rate",
  "larger_towns",
  "initial_city_size",
}

Definition at line 764 of file settings_gui.cpp.

PatchPage _patches_page[] [static]

Initial value:

 {
  {_patches_ui,           NULL, lengthof(_patches_ui)},
  {_patches_construction, NULL, lengthof(_patches_construction)},
  {_patches_vehicles,     NULL, lengthof(_patches_vehicles)},
  {_patches_stations,     NULL, lengthof(_patches_stations)},
  {_patches_economy,      NULL, lengthof(_patches_economy)},
  {_patches_ai,           NULL, lengthof(_patches_ai)},
}

Definition at line 839 of file settings_gui.cpp.

const WindowDesc _patches_selection_desc [static]

Initial value:

 {
  WDP_CENTER, WDP_CENTER, 370, 51, 370, 51,
  WC_GAME_OPTIONS, WC_NONE,
  WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
  _patches_selection_widgets,
  PatchesSelectionWndProc,
}

Definition at line 1096 of file settings_gui.cpp.

const Widget _patches_selection_widgets[] [static]

Initial value:

 {
{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_CONFIG_PATCHES_CAPTION,      STR_018C_WINDOW_TITLE_DRAG_THIS},
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                             STR_NULL},
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,    50, 0x0,                             STR_NULL},

{    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_CONFIG_PATCHES_GUI,          STR_NULL},
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL},
{    WWT_TEXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_CONFIG_PATCHES_VEHICLES,     STR_NULL},
{    WWT_TEXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_CONFIG_PATCHES_STATIONS,     STR_NULL},
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    28,    39, STR_CONFIG_PATCHES_ECONOMY,      STR_NULL},
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    97,   183,    28,    39, STR_CONFIG_PATCHES_AI,           STR_NULL},
{   WIDGETS_END},
}

Definition at line 1081 of file settings_gui.cpp.

const char* _patches_stations[] [static]

Initial value:

 {
  "join_stations",
  "full_load_any",
  "improved_load",
  "selectgoods",
  "new_nonstop",
  "nonuniform_stations",
  "station_spread",
  "serviceathelipad",
  "modified_catchment",
  "gradual_loading",
  "road_stop_on_town_road",
  "adjacent_stations",
}

Definition at line 749 of file settings_gui.cpp.

const char* _patches_ui[] [static]

Initial value:

 {
  "vehicle_speed",
  "status_long_date",
  "show_finances",
  "autoscroll",
  "reverse_scroll",
  "smooth_scroll",
  "errmsg_duration",
  "toolbar_pos",
  "measure_tooltip",
  "window_snap_radius",
  "invisible_trees",
  "population_in_label",
  "link_terraform_toolbar",
  "liveries",
  "prefer_teamchat",
  
  "scrollwheel_scrolling",
  "scrollwheel_multiplier",




  "pause_on_newgame",
  "advanced_vehicle_list",
  "loading_indicators",
  "timetable_in_ticks",
  "default_rail_type",
  "always_build_infrastructure",
}

Definition at line 703 of file settings_gui.cpp.

const StringID _units_dropdown[] [static]

Initial value:

 {
  STR_UNITS_IMPERIAL,
  STR_UNITS_METRIC,
  STR_UNITS_SI,
  INVALID_STRING_ID
}

Definition at line 34 of file settings_gui.cpp.


Generated on Wed Oct 1 17:03:30 2008 for openttd by  doxygen 1.5.6