src/settings_gui.cpp
author glx
Thu, 17 Jan 2008 02:10:26 +0000
changeset 8819 86c6ce890d61
parent 8817 9df6e6b40d12
child 8832 e1fcfd2e6d75
permissions -rw-r--r--
(svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6916
e87d54a598ea (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6704
diff changeset
     3
/** @file settings_gui.cpp */
e87d54a598ea (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6704
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1806
diff changeset
     6
#include "openttd.h"
2291
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents: 2231
diff changeset
     7
#include "currency.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
#include "gui.h"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
     9
#include "window_gui.h"
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8602
diff changeset
    10
#include "textbuf_gui.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
    11
#include "command_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "engine.h"
430
75820dedf4f1 (svn r631) Merge r440, r444, r485, r630 to trunk:
tron
parents: 350
diff changeset
    13
#include "screenshot.h"
478
19987403ee5d (svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents: 430
diff changeset
    14
#include "newgrf.h"
5720
cc0ceeafaa55 (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5682
diff changeset
    15
#include "network/network.h"
835
a22d6bc16a51 (svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents: 833
diff changeset
    16
#include "town.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2140
diff changeset
    17
#include "variables.h"
8704
2857ec554839 (svn r11771) -Codechange: split settings.h into better separated headers.
rubidium
parents: 8687
diff changeset
    18
#include "settings_internal.h"
7452
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    19
#include "newgrf_townname.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8603
diff changeset
    20
#include "strings_func.h"
8627
448ebf3a8291 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8626
diff changeset
    21
#include "functions.h"
448ebf3a8291 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8626
diff changeset
    22
#include "window_func.h"
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    23
#include "vehicle_base.h"
8709
4187ad809fe7 (svn r11776) -Codechange: more header splittings to reduce the dependencies.
rubidium
parents: 8704
diff changeset
    24
#include "core/alloc_func.hpp"
8710
52015340050c (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8709
diff changeset
    25
#include "string_func.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8710
diff changeset
    26
#include "gfx_func.h"
8817
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
    27
#include "widgets/dropdown_type.h"
8780
6f3f3ec6c69a (svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents: 8760
diff changeset
    28
#include "widgets/dropdown_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8720
diff changeset
    30
#include "table/sprites.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8720
diff changeset
    31
#include "table/strings.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8720
diff changeset
    32
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
static uint32 _difficulty_click_a;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
static uint32 _difficulty_click_b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
static byte _difficulty_timeout;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    37
static const StringID _units_dropdown[] = {
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    38
	STR_UNITS_IMPERIAL,
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    39
	STR_UNITS_METRIC,
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    40
	STR_UNITS_SI,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
	INVALID_STRING_ID
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
static const StringID _driveside_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
	STR_02E9_DRIVE_ON_LEFT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
	STR_02EA_DRIVE_ON_RIGHT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
	INVALID_STRING_ID
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
static const StringID _autosave_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
	STR_02F7_OFF,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
	STR_AUTOSAVE_1_MONTH,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
	STR_02F8_EVERY_3_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
	STR_02F9_EVERY_6_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
	STR_02FA_EVERY_12_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	INVALID_STRING_ID,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
static const StringID _designnames_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
	STR_02BE_DEFAULT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
	STR_02BF_CUSTOM,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
	INVALID_STRING_ID
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
static StringID *BuildDynamicDropdown(StringID base, int num)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	static StringID buf[32 + 1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
	StringID *p = buf;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
	while (--num>=0) *p++ = base++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
	*p = INVALID_STRING_ID;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
	return buf;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
7452
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    74
int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1;
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    75
static StringID *_grf_names = NULL;
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    76
static int _nb_grf_names = 0;
7293
e5b1b6ef83db (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 7226
diff changeset
    77
8819
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
    78
void InitGRFTownGeneratorNames()
7293
e5b1b6ef83db (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 7226
diff changeset
    79
{
7452
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    80
	free(_grf_names);
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    81
	_grf_names = GetGRFTownNameList();
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    82
	_nb_grf_names = 0;
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    83
	for (StringID *s = _grf_names; *s != INVALID_STRING_ID; s++) _nb_grf_names++;
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    84
}
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    85
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    86
static inline StringID TownName(int town_name)
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    87
{
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    88
	if (town_name < _nb_orig_names) return STR_TOWNNAME_ORIGINAL_ENGLISH + town_name;
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    89
	town_name -= _nb_orig_names;
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    90
	if (town_name < _nb_grf_names) return _grf_names[town_name];
f6fd23727af0 (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 7446
diff changeset
    91
	return STR_UNDEFINED;
7293
e5b1b6ef83db (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 7226
diff changeset
    92
}
e5b1b6ef83db (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 7226
diff changeset
    93
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6338
diff changeset
    94
static int GetCurRes()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	int i;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    97
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    98
	for (i = 0; i != _num_resolutions; i++) {
306
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 298
diff changeset
    99
		if (_resolutions[i][0] == _screen.width &&
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   100
				_resolutions[i][1] == _screen.height) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
			break;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   102
		}
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   103
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
	return i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6338
diff changeset
   107
static inline bool RoadVehiclesAreBuilt()
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   108
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   109
	const Vehicle* v;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   110
915
013cb2d74800 (svn r1402) Trim trailing whitespace
tron
parents: 893
diff changeset
   111
	FOR_ALL_VEHICLES(v) {
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6581
diff changeset
   112
		if (v->type == VEH_ROAD) return true;
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   113
	}
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   114
	return false;
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   115
}
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   116
2817
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
   117
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   118
enum GameOptionsWidgets {
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   119
	GAMEOPT_CURRENCY_TXT    =  4,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   120
	GAMEOPT_CURRENCY_BTN,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   121
	GAMEOPT_DISTANCE_TXT    =  7,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   122
	GAMEOPT_DISTANCE_BTN,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   123
	GAMEOPT_ROADSIDE_TXT    = 10,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   124
	GAMEOPT_ROADSIDE_BTN,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   125
	GAMEOPT_TOWNNAME_TXT    = 13,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   126
	GAMEOPT_TOWNNAME_BTN,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   127
	GAMEOPT_AUTOSAVE_TXT    = 16,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   128
	GAMEOPT_AUTOSAVE_BTN,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   129
	GAMEOPT_VEHICLENAME_TXT = 19,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   130
	GAMEOPT_VEHICLENAME_BTN,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   131
	GAMEOPT_VEHICLENAME_SAVE,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   132
	GAMEOPT_LANG_TXT        = 23,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   133
	GAMEOPT_LANG_BTN,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   134
	GAMEOPT_RESOLUTION_TXT  = 26,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   135
	GAMEOPT_RESOLUTION_BTN,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   136
	GAMEOPT_FULLSCREEN,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   137
	GAMEOPT_SCREENSHOT_TXT  = 30,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   138
	GAMEOPT_SCREENSHOT_BTN,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   139
};
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   140
8817
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   141
/**
8819
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   142
 * Update/redraw the townnames dropdown
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   143
 * @param w   the window the dropdown belongs to
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   144
 * @param sel the currently selected townname generator
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   145
 */
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   146
static void ShowTownnameDropdown(Window *w, int sel)
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   147
{
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   148
	typedef std::map<StringID, int, StringIDCompare> TownList;
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   149
	TownList townnames;
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   150
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   151
	/* Add and sort original townnames generators */
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   152
	for (int i = 0; i < _nb_orig_names; i++) townnames[STR_TOWNNAME_ORIGINAL_ENGLISH + i] = i;
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   153
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   154
	/* Add and sort newgrf townnames generators */
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   155
	for (int i = 0; i < _nb_grf_names; i++) townnames[_grf_names[i]] = _nb_orig_names + i;
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   156
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   157
	DropDownList *list = new DropDownList();
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   158
	for (TownList::iterator it = townnames.begin(); it != townnames.end(); it++) {
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   159
		list->push_back(new DropDownListStringItem((*it).first, (*it).second, !(_game_mode == GM_MENU || (*it).second == sel)));
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   160
	}
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   161
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   162
	ShowDropDownList(w, list, sel, GAMEOPT_TOWNNAME_BTN);
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   163
}
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   164
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   165
/**
8817
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   166
 * Update/redraw the languages dropdown
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   167
 * @param w   the window the dropdown belongs to
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   168
 */
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   169
static void ShowLangDropdown(Window *w)
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   170
{
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   171
	typedef std::map<StringID, int, StringIDCompare> LangList;
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   172
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   173
	/* Sort language names */
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   174
	LangList langs;
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   175
	for (int i = 0; i < _dynlang.num; i++) langs[SPECSTR_LANGUAGE_START + i] = i;
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   176
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   177
	DropDownList *list = new DropDownList();
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   178
	for (LangList::iterator it = langs.begin(); it != langs.end(); it++) {
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   179
		list->push_back(new DropDownListStringItem((*it).first, (*it).second, false));
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   180
	}
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   181
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   182
	ShowDropDownList(w, list, _dynlang.curr, GAMEOPT_LANG_BTN);
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   183
}
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   184
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6338
diff changeset
   185
static void ShowCustCurrency();
2817
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
   186
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
static void GameOptionsWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
{
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   189
	switch (e->event) {
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   190
		case WE_PAINT: {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   191
			int i;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   192
			StringID str = STR_02BE_DEFAULT;
298
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   193
8815
d7e27012df64 (svn r11884) -Cleanup: leftover use of widget numbers instead of enum
peter1138
parents: 8780
diff changeset
   194
			w->SetWidgetDisabledState(GAMEOPT_VEHICLENAME_SAVE, !(_vehicle_design_names & 1));
d7e27012df64 (svn r11884) -Cleanup: leftover use of widget numbers instead of enum
peter1138
parents: 8780
diff changeset
   195
			if (!w->IsWidgetDisabled(GAMEOPT_VEHICLENAME_SAVE)) str = STR_02BF_CUSTOM;
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   196
			SetDParam(0, str);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   197
			SetDParam(1, _currency_specs[_opt_ptr->currency].name);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   198
			SetDParam(2, STR_UNITS_IMPERIAL + _opt_ptr->units);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   199
			SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_ptr->road_side);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   200
			SetDParam(4, TownName(_opt_ptr->town_name));
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   201
			SetDParam(5, _autosave_dropdown[_opt_ptr->autosave]);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   202
			SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   203
			i = GetCurRes();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   204
			SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   205
			SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   206
			w->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen);
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   207
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   208
			DrawWindowWidgets(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   209
			DrawString(20, 175, STR_OPTIONS_FULLSCREEN, TC_FROMSTRING); // fullscreen
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   210
		} break;
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   211
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   212
		case WE_CLICK:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   213
			switch (e->we.click.widget) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   214
				case GAMEOPT_CURRENCY_TXT: case GAMEOPT_CURRENCY_BTN: /* Setup currencies dropdown */
8687
0446dbc05291 (svn r11754) -Fix(r11753): One too much command separator (;). Thanks glx for spotting
belugas
parents: 8686
diff changeset
   215
					ShowDropDownMenu(w, BuildCurrencyDropdown(), _opt_ptr->currency, GAMEOPT_CURRENCY_BTN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);
7293
e5b1b6ef83db (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 7226
diff changeset
   216
					break;
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   217
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   218
				case GAMEOPT_DISTANCE_TXT: case GAMEOPT_DISTANCE_BTN: /* Setup distance unit dropdown */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   219
					ShowDropDownMenu(w, _units_dropdown, _opt_ptr->units, GAMEOPT_DISTANCE_BTN, 0, 0);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   220
					break;
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   221
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   222
				case GAMEOPT_ROADSIDE_TXT: case GAMEOPT_ROADSIDE_BTN: { /* Setup road-side dropdown */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   223
					int i = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   225
					/* You can only change the drive side if you are in the menu or ingame with
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   226
					 * no vehicles present. In a networking game only the server can change it */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   227
					if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server))
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   228
						i = (-1) ^ (1 << _opt_ptr->road_side); // disable the other value
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   229
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   230
					ShowDropDownMenu(w, _driveside_dropdown, _opt_ptr->road_side, GAMEOPT_ROADSIDE_BTN, i, 0);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   231
				} break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   232
8819
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   233
				case GAMEOPT_TOWNNAME_TXT: case GAMEOPT_TOWNNAME_BTN: /* Setup townname dropdown */
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   234
					ShowTownnameDropdown(w, _opt_ptr->town_name);
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   235
					break;
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   236
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   237
				case GAMEOPT_AUTOSAVE_TXT: case GAMEOPT_AUTOSAVE_BTN: /* Setup autosave dropdown */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   238
					ShowDropDownMenu(w, _autosave_dropdown, _opt_ptr->autosave, GAMEOPT_AUTOSAVE_BTN, 0, 0);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   239
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   240
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   241
				case GAMEOPT_VEHICLENAME_TXT: case GAMEOPT_VEHICLENAME_BTN: /* Setup customized vehicle-names dropdown */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   242
					ShowDropDownMenu(w, _designnames_dropdown, (_vehicle_design_names & 1) ? 1 : 0, GAMEOPT_VEHICLENAME_BTN, (_vehicle_design_names & 2) ? 0 : 2, 0);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   243
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   244
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   245
				case GAMEOPT_VEHICLENAME_SAVE: /* Save customized vehicle-names to disk */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   246
					break;  // not implemented
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   247
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   248
				case GAMEOPT_LANG_TXT: case GAMEOPT_LANG_BTN: /* Setup interface language dropdown */
8817
9df6e6b40d12 (svn r11886) -Add: sort the strings in languages dropdown
glx
parents: 8815
diff changeset
   249
					ShowLangDropdown(w);
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   250
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   251
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   252
				case GAMEOPT_RESOLUTION_TXT: case GAMEOPT_RESOLUTION_BTN: /* Setup resolution dropdown */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   253
					ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), GAMEOPT_RESOLUTION_BTN, 0, 0);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   254
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   255
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   256
				case GAMEOPT_FULLSCREEN: /* Click fullscreen on/off */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   257
					/* try to toggle full-screen on/off */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   258
					if (!ToggleFullScreen(!_fullscreen)) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   259
						ShowErrorMessage(INVALID_STRING_ID, STR_FULLSCREEN_FAILED, 0, 0);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   260
					}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   261
					w->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   262
					SetWindowDirty(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   263
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   264
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   265
				case GAMEOPT_SCREENSHOT_TXT: case GAMEOPT_SCREENSHOT_BTN: /* Setup screenshot format dropdown */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   266
					ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, GAMEOPT_SCREENSHOT_BTN, 0, 0);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   267
					break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
			break;
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   270
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   271
		case WE_DROPDOWN_SELECT:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   272
			switch (e->we.dropdown.button) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   273
				case GAMEOPT_VEHICLENAME_BTN: /* Vehicle design names */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   274
					if (e->we.dropdown.index == 0) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   275
						DeleteCustomEngineNames();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   276
						MarkWholeScreenDirty();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   277
					} else if (!(_vehicle_design_names & 1)) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   278
						LoadCustomEngineNames();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   279
						MarkWholeScreenDirty();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   280
					}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   281
					break;
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   282
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   283
				case GAMEOPT_CURRENCY_BTN: /* Currency */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   284
					if (e->we.dropdown.index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   285
					_opt_ptr->currency = e->we.dropdown.index;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   286
					MarkWholeScreenDirty();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   287
					break;
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   288
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   289
				case GAMEOPT_DISTANCE_BTN: /* Measuring units */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   290
					_opt_ptr->units = e->we.dropdown.index;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   291
					MarkWholeScreenDirty();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   292
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   293
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   294
				case GAMEOPT_ROADSIDE_BTN: /* Road side */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   295
					if (_opt_ptr->road_side != e->we.dropdown.index) { // only change if setting changed
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   296
						DoCommandP(0, e->we.dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   297
						MarkWholeScreenDirty();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   298
					}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   299
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   300
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   301
				case GAMEOPT_TOWNNAME_BTN: /* Town names */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   302
					if (_game_mode == GM_MENU) {
8819
86c6ce890d61 (svn r11888) -Codechange: simplify sorting of the strings in town names dropdown
glx
parents: 8817
diff changeset
   303
						_opt_ptr->town_name = e->we.dropdown.index;
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   304
						InvalidateWindow(WC_GAME_OPTIONS, 0);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   305
					}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   306
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   307
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   308
				case GAMEOPT_AUTOSAVE_BTN: /* Autosave options */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   309
					_opt.autosave = _opt_newgame.autosave = e->we.dropdown.index;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   310
					SetWindowDirty(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   311
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   312
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   313
				case GAMEOPT_LANG_BTN: /* Change interface language */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   314
					ReadLanguagePack(e->we.dropdown.index);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   315
					CheckForMissingGlyphsInLoadedLanguagePack();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   316
					UpdateAllStationVirtCoord();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   317
					MarkWholeScreenDirty();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   318
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   319
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   320
				case GAMEOPT_RESOLUTION_BTN: /* Change resolution */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   321
					if (e->we.dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->we.dropdown.index][0],_resolutions[e->we.dropdown.index][1]))
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   322
						SetWindowDirty(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   323
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   324
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   325
				case GAMEOPT_SCREENSHOT_BTN: /* Change screenshot format */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   326
					SetScreenshotFormat(e->we.dropdown.index);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   327
					SetWindowDirty(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   328
					break;
1113
8c4c1e1ba4c5 (svn r1614) Fix: Signals were not updated correctly when the vehicle drive side was changed
dominik
parents: 1095
diff changeset
   329
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   330
			break;
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   331
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   332
		case WE_DESTROY:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   333
			DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   335
	}
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   336
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   338
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   339
/** Change the side of the road vehicles drive on (server only).
3491
4c8427796c64 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3342
diff changeset
   340
 * @param tile unused
6979
d194d25020e7 (svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents: 6968
diff changeset
   341
 * @param flags operation to perform
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   342
 * @param p1 the side of the road; 0 = left side and 1 = right side
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   343
 * @param p2 unused
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   344
 */
7439
0c0e2945c890 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 7294
diff changeset
   345
CommandCost CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   346
{
1803
24a94314cfa9 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents: 1796
diff changeset
   347
	/* Check boundaries and you can only change this if NO vehicles have been built yet,
24a94314cfa9 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents: 1796
diff changeset
   348
	 * except in the intro-menu where of course it's always possible to do so. */
24a94314cfa9 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents: 1796
diff changeset
   349
	if (p1 > 1 || (_game_mode != GM_MENU && RoadVehiclesAreBuilt())) return CMD_ERROR;
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   350
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   351
	if (flags & DC_EXEC) {
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   352
		_opt_ptr->road_side = p1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   353
		InvalidateWindow(WC_GAME_OPTIONS,0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   354
	}
7446
1c4d469f986e (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 7439
diff changeset
   355
	return CommandCost();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
static const Widget _game_options_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   359
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   360
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   369,     0,    13, STR_00B1_GAME_OPTIONS,             STR_018C_WINDOW_TITLE_DRAG_THIS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   361
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   369,    14,   238, 0x0,                               STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   362
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,    20,    55, STR_02E0_CURRENCY_UNITS,           STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   363
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,    34,    45, STR_02E1,                          STR_02E2_CURRENCY_UNITS_SELECTION},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   364
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,    35,    44, STR_0225,                          STR_02E2_CURRENCY_UNITS_SELECTION},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   365
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,    20,    55, STR_MEASURING_UNITS,               STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   366
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,    34,    45, STR_02E4,                          STR_MEASURING_UNITS_SELECTION},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   367
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   338,   348,    35,    44, STR_0225,                          STR_MEASURING_UNITS_SELECTION},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   368
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,    62,    97, STR_02E6_ROAD_VEHICLES,            STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   369
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,    76,    87, STR_02E7,                          STR_02E8_SELECT_SIDE_OF_ROAD_FOR},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   370
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,    77,    86, STR_0225,                          STR_02E8_SELECT_SIDE_OF_ROAD_FOR},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   371
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,    62,    97, STR_02EB_TOWN_NAMES,               STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   372
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,    76,    87, STR_02EC,                          STR_02ED_SELECT_STYLE_OF_TOWN_NAMES},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   373
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   338,   348,    77,    86, STR_0225,                          STR_02ED_SELECT_STYLE_OF_TOWN_NAMES},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   374
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,   104,   139, STR_02F4_AUTOSAVE,                 STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   375
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,   118,   129, STR_02F5,                          STR_02F6_SELECT_INTERVAL_BETWEEN},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   376
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,   119,   128, STR_0225,                          STR_02F6_SELECT_INTERVAL_BETWEEN},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   377
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   378
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   359,   194,   228, STR_02BC_VEHICLE_DESIGN_NAMES,     STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   379
{      WWT_INSET,   RESIZE_NONE,    14,    20,   119,   207,   218, STR_02BD,                          STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   380
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   108,   118,   208,   217, STR_0225,                          STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   381
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   130,   349,   207,   218, STR_02C0_SAVE_CUSTOM_NAMES,        STR_02C2_SAVE_CUSTOMIZED_VEHICLE},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   383
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,   104,   139, STR_OPTIONS_LANG,                  STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   384
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,   118,   129, STR_OPTIONS_LANG_CBO,              STR_OPTIONS_LANG_TIP},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   385
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   338,   348,   119,   128, STR_0225,                          STR_OPTIONS_LANG_TIP},
298
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   386
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   387
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,   146,   190, STR_OPTIONS_RES,                   STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   388
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,   160,   171, STR_OPTIONS_RES_CBO,               STR_OPTIONS_RES_TIP},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   389
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,   161,   170, STR_0225,                          STR_OPTIONS_RES_TIP},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   390
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   149,   169,   176,   184, STR_EMPTY,                         STR_OPTIONS_FULLSCREEN_TIP},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   391
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   392
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,   146,   190, STR_OPTIONS_SCREENSHOT_FORMAT,     STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   393
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,   160,   171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO, STR_OPTIONS_SCREENSHOT_FORMAT_TIP},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   394
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   338,   348,   161,   170, STR_0225,                          STR_OPTIONS_SCREENSHOT_FORMAT_TIP},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 164
diff changeset
   396
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
static const WindowDesc _game_options_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7673
diff changeset
   400
	WDP_CENTER, WDP_CENTER, 370, 239, 370, 239,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5939
diff changeset
   401
	WC_GAME_OPTIONS, WC_NONE,
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   402
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
	_game_options_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
	GameOptionsWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   407
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6338
diff changeset
   408
void ShowGameOptions()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
	DeleteWindowById(WC_GAME_OPTIONS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
	AllocateWindowDesc(&_game_options_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   413
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   414
struct GameSettingData {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   415
	int16 min;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   416
	int16 max;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   417
	int16 step;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
	StringID str;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   419
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   420
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
static const GameSettingData _game_setting_info[] = {
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   422
	{  0,   7,  1, STR_NULL},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   423
	{  0,   3,  1, STR_6830_IMMEDIATE},
7056
b4f146586c97 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 7041
diff changeset
   424
	{  0,   3,  1, STR_NUM_VERY_LOW},
b4f146586c97 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 7041
diff changeset
   425
	{  0,   4,  1, STR_26816_NONE},
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   426
	{100, 500, 50, STR_NULL},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   427
	{  2,   4,  1, STR_NULL},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   428
	{  0,   2,  1, STR_6820_LOW},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   429
	{  0,   4,  1, STR_681B_VERY_SLOW},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   430
	{  0,   2,  1, STR_6820_LOW},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   431
	{  0,   2,  1, STR_6823_NONE},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   432
	{  0,   3,  1, STR_6826_X1_5},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   433
	{  0,   2,  1, STR_6820_LOW},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   434
	{  0,   3,  1, STR_682A_VERY_FLAT},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   435
	{  0,   3,  1, STR_VERY_LOW},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   436
	{  0,   1,  1, STR_682E_STEADY},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   437
	{  0,   1,  1, STR_6834_AT_END_OF_LINE_AND_AT_STATIONS},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   438
	{  0,   1,  1, STR_6836_OFF},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   439
	{  0,   2,  1, STR_6839_PERMISSIVE},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   441
1385
324d3d06a930 (svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents: 1363
diff changeset
   442
/*
4549
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   443
 * A: competitors
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   444
 * B: start time in months / 3
7056
b4f146586c97 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 7041
diff changeset
   445
 * C: town count (2 = high, 0 = very low)
b4f146586c97 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 7041
diff changeset
   446
 * D: industry count (4 = high, 0 = none)
4549
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   447
 * E: inital loan / 1000 (in GBP)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   448
 * F: interest rate
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   449
 * G: running costs (0 = low, 2 = high)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   450
 * H: construction speed of competitors (0 = very slow, 4 = very fast)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   451
 * I: intelligence (0-2)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   452
 * J: breakdowns (0 = off, 2 = normal)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   453
 * K: subsidy multiplier (0 = 1.5, 3 = 4.0)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   454
 * L: construction cost (0-2)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   455
 * M: terrain type (0 = very flat, 3 = mountainous)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   456
 * N: amount of water (0 = very low, 3 = high)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   457
 * O: economy (0 = steady, 1 = fluctuating)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   458
 * P: Train reversing (0 = end of line + stations, 1 = end of line)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   459
 * Q: disasters
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   460
 * R: area restructuring (0 = permissive, 2 = hostile)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   461
 */
8238
29844a206bbe (svn r11279) -Codechange: use a typedeffed type for all magic with GameDifficulty instead on relying ints to always be 32 bits, which they are not.
rubidium
parents: 8153
diff changeset
   462
static const GDType _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /*
1385
324d3d06a930 (svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents: 1363
diff changeset
   463
	 A, B, C, D,   E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/
7056
b4f146586c97 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 7041
diff changeset
   464
	{2, 2, 1, 4, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, ///< easy
b4f146586c97 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 7041
diff changeset
   465
	{4, 1, 1, 3, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, ///< medium
b4f146586c97 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 7041
diff changeset
   466
	{7, 0, 0, 2, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, ///< hard
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
void SetDifficultyLevel(int mode, GameOptions *gm_opt)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
	assert(mode <= 3);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
	gm_opt->diff_level = mode;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
	if (mode != 3) { // not custom
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   476
		for (i = 0; i != GAME_DIFFICULTY_NUM; i++)
8238
29844a206bbe (svn r11279) -Codechange: use a typedeffed type for all magic with GameDifficulty instead on relying ints to always be 32 bits, which they are not.
rubidium
parents: 8153
diff changeset
   477
			((GDType*)&gm_opt->diff)[i] = _default_game_diff[mode][i];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
6704
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   481
/**
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   482
 * Checks the difficulty levels read from the configuration and
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   483
 * forces them to be correct when invalid.
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   484
 */
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   485
void CheckDifficultyLevels()
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   486
{
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   487
	if (_opt_newgame.diff_level != 3) {
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   488
		SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame);
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   489
	} else {
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   490
		for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) {
8238
29844a206bbe (svn r11279) -Codechange: use a typedeffed type for all magic with GameDifficulty instead on relying ints to always be 32 bits, which they are not.
rubidium
parents: 8153
diff changeset
   491
			GDType *diff = ((GDType*)&_opt_newgame.diff) + i;
8418
b49fc6be1ab9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 8397
diff changeset
   492
			*diff = Clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max);
6704
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   493
			*diff -= *diff % _game_setting_info[i].step;
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   494
		}
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   495
	}
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   496
}
1d7e67bc3f7c (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6622
diff changeset
   497
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6338
diff changeset
   498
extern void StartupEconomy();
46
c9bdf1d58df6 (svn r47) -Fix StartupEconomy warning in settings_gui.c
darkvater
parents: 42
diff changeset
   499
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   500
enum {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   501
	GAMEDIFF_WND_TOP_OFFSET = 45,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   502
	GAMEDIFF_WND_ROWSIZE    = 9
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   503
};
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   504
6916
e87d54a598ea (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6704
diff changeset
   505
/* Temporary holding place of values in the difficulty window until 'Save' is clicked */
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   506
static GameOptions _opt_mod_temp;
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   507
// 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   508
#define DIFF_INGAME_DISABLED_BUTTONS 0x383E
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   509
8632
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   510
/* Names of the game difficulty settings window */
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   511
enum GameDifficultyWidgets {
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   512
	GDW_CLOSEBOX = 0,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   513
	GDW_CAPTION,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   514
	GDW_UPPER_BG,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   515
	GDW_LVL_EASY,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   516
	GDW_LVL_MEDIUM,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   517
	GDW_LVL_HARD,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   518
	GDW_LVL_CUSTOM,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   519
	GDW_HIGHSCORE,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   520
	GDW_SETTING_BG,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   521
	GDW_LOWER_BG,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   522
	GDW_ACCEPT,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   523
	GDW_CANCEL,
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   524
};
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   525
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
static void GameDifficultyWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   527
{
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   528
	switch (e->event) {
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   529
		case WE_CREATE:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   530
			/* Hide the closebox to make sure that the user aborts or confirms his changes */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   531
			w->HideWidget(GDW_CLOSEBOX);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   532
			w->widget[GDW_CAPTION].left = 0;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   533
			/* Setup disabled buttons when creating window
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   534
			 * disable all other difficulty buttons during gameplay except for 'custom' */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   535
			w->SetWidgetsDisabledState(_game_mode == GM_NORMAL,
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   536
				GDW_LVL_EASY,
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   537
				GDW_LVL_MEDIUM,
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   538
				GDW_LVL_HARD,
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   539
				GDW_LVL_CUSTOM,
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   540
				WIDGET_LIST_END);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   541
			w->SetWidgetDisabledState(GDW_HIGHSCORE, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   542
			w->SetWidgetDisabledState(GDW_ACCEPT, _networking && !_network_server); // Save-button in multiplayer (and if client)
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   543
			w->LowerWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   544
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   546
		case WE_PAINT: {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   547
			DrawWindowWidgets(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   549
			/* XXX - Disabled buttons in normal gameplay or during muliplayer as non server.
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   550
			 *       Bitshifted for each button to see if that bit is set. If it is set, the
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   551
			 *       button is disabled */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   552
			uint32 disabled = 0;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   553
			if (_networking && !_network_server) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   554
				disabled = MAX_UVALUE(uint32); // Disable all
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   555
			} else if (_game_mode == GM_NORMAL) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   556
				disabled = DIFF_INGAME_DISABLED_BUTTONS;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   557
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   559
			int value;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   560
			int y = GAMEDIFF_WND_TOP_OFFSET;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   561
			for (uint i = 0; i != GAME_DIFFICULTY_NUM; i++) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   562
				const GameSettingData *gsd = &_game_setting_info[i];
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   563
				value = ((GDType*)&_opt_mod_temp.diff)[i];
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   564
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   565
				DrawArrowButtons(5, y, 3,
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   566
						!!HasBit(_difficulty_click_a, i) | !!HasBit(_difficulty_click_b, i) << 1,
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   567
						!(HasBit(disabled, i) || gsd->min == value),
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   568
						!(HasBit(disabled, i) || gsd->max == value));
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   569
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   570
				value += _game_setting_info[i].str;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   571
				if (i == 4) value *= 1000; // XXX - handle currency option
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   572
				SetDParam(0, value);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   573
				DrawString(30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, TC_FROMSTRING);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   574
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   575
				y += GAMEDIFF_WND_ROWSIZE + 2; // space items apart a bit
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   576
			}
6988
76eba6a9cc6f (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6982
diff changeset
   577
		} break;
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   578
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   579
		case WE_CLICK:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   580
			switch (e->we.click.widget) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   581
				case GDW_SETTING_BG: { /* Difficulty settings widget, decode click */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   582
					/* Don't allow clients to make any changes */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   583
					if (_networking && !_network_server) return;
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   584
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   585
					const int x = e->we.click.pt.x - 5;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   586
					if (!IsInsideMM(x, 0, 21)) // Button area
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   587
						return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   588
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   589
					const int y = e->we.click.pt.y - GAMEDIFF_WND_TOP_OFFSET;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   590
					if (y < 0) return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   591
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   592
					/* Get button from Y coord. */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   593
					const uint btn = y / (GAMEDIFF_WND_ROWSIZE + 2);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   594
					if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9)
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   595
						return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   596
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   597
					/* Clicked disabled button? */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   598
					if (_game_mode == GM_NORMAL && HasBit(DIFF_INGAME_DISABLED_BUTTONS, btn))
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   599
						return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   600
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   601
					_difficulty_timeout = 5;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   602
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   603
					int16 val = ((GDType*)&_opt_mod_temp.diff)[btn];
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   604
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   605
					const GameSettingData *info = &_game_setting_info[btn]; // get information about the difficulty setting
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   606
					if (x >= 10) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   607
						/* Increase button clicked */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   608
						val = min(val + info->step, info->max);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   609
						SetBit(_difficulty_click_b, btn);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   610
					} else {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   611
						/* Decrease button clicked */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   612
						val -= info->step;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   613
						val = max(val,  info->min);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   614
						SetBit(_difficulty_click_a, btn);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   615
					}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   616
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   617
					/* save value in temporary variable */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   618
					((GDType*)&_opt_mod_temp.diff)[btn] = val;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   619
					w->RaiseWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   620
					SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   621
					w->LowerWidget(GDW_LVL_CUSTOM);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   622
					SetWindowDirty(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   623
				} break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   624
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   625
				case GDW_LVL_EASY:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   626
				case GDW_LVL_MEDIUM:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   627
				case GDW_LVL_HARD:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   628
				case GDW_LVL_CUSTOM:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   629
					/* temporarily change difficulty level */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   630
					w->RaiseWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   631
					SetDifficultyLevel(e->we.click.widget - GDW_LVL_EASY, &_opt_mod_temp);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   632
					w->LowerWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   633
					SetWindowDirty(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   634
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   635
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   636
				case GDW_HIGHSCORE: // Highscore Table
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   637
					ShowHighscoreTable(_opt_mod_temp.diff_level, -1);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   638
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   639
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   640
				case GDW_ACCEPT: { // Save button - save changes
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   641
					GDType btn, val;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   642
					for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   643
						val = ((GDType*)&_opt_mod_temp.diff)[btn];
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   644
						/* if setting has changed, change it */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   645
						if (val != ((GDType*)&_opt_ptr->diff)[btn])
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   646
							DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   647
					}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   648
					DoCommandP(0, UINT_MAX, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   649
					DeleteWindow(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   650
					/* If we are in the editor, we should reload the economy.
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   651
					 * This way when you load a game, the max loan and interest rate
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   652
					 * are loaded correctly. */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   653
					if (_game_mode == GM_EDITOR) StartupEconomy();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   654
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   655
				}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   656
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   657
				case GDW_CANCEL: // Cancel button - close window, abandon changes
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   658
					DeleteWindow(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   659
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   660
			} break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   661
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   662
		case WE_MOUSELOOP: /* Handle the visual 'clicking' of the buttons */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   663
			if (_difficulty_timeout != 0 && !--_difficulty_timeout) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   664
				_difficulty_click_a = 0;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   665
				_difficulty_click_b = 0;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   666
				SetWindowDirty(w);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   667
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   668
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   669
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   670
}
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   671
#undef DIFF_INGAME_DISABLED_BUTTONS
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   672
8632
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   673
/* Widget definition for the game difficulty settings window */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   674
static const Widget _game_difficulty_widgets[] = {
8632
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   675
{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},           // GDW_CLOSEBOX
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   676
{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_6800_DIFFICULTY_LEVEL,    STR_018C_WINDOW_TITLE_DRAG_THIS}, // GDW_CAPTION
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   677
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                          STR_NULL},                        // GDW_UPPER_BG
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   678
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_6801_EASY,                STR_NULL},                        // GDW_LVL_EASY
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   679
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_6802_MEDIUM,              STR_NULL},                        // GDW_LVL_MEDIUM
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   680
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_6803_HARD,                STR_NULL},                        // GDW_LVL_HARD
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   681
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_6804_CUSTOM,              STR_NULL},                        // GDW_LVL_CUSTOM
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   682
{    WWT_TEXTBTN,   RESIZE_NONE,     6,    10,   357,    28,    39, STR_6838_SHOW_HI_SCORE_CHART, STR_NULL},                        // GDW_HIGHSCORE
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   683
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   262, 0x0,                          STR_NULL},                        // GDW_SETTING_BG
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   684
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,   263,   278, 0x0,                          STR_NULL},                        // GDW_LOWER_BG
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   685
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   105,   185,   265,   276, STR_OPTIONS_SAVE_CHANGES,     STR_NULL},                        // GDW_ACCEPT
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   686
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   186,   266,   265,   276, STR_012E_CANCEL,              STR_NULL},                        // GDW_CANCEL
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 164
diff changeset
   687
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   688
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   689
8632
f407b7a80d2d (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8627
diff changeset
   690
/* Window definition for the game difficulty settings window */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   691
static const WindowDesc _game_difficulty_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7673
diff changeset
   692
	WDP_CENTER, WDP_CENTER, 370, 279, 370, 279,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5939
diff changeset
   693
	WC_GAME_OPTIONS, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   694
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   695
	_game_difficulty_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   696
	GameDifficultyWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   697
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   698
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6338
diff changeset
   699
void ShowGameDifficulty()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   700
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   701
	DeleteWindowById(WC_GAME_OPTIONS, 0);
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   702
	/* Copy current settings (ingame or in intro) to temporary holding place
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   703
	 * change that when setting stuff, copy back on clicking 'OK' */
5024
f13f2f2d43f9 (svn r7065) Use simple assignment instead of memcpy()
tron
parents: 4939
diff changeset
   704
	_opt_mod_temp = *_opt_ptr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
	AllocateWindowDesc(&_game_difficulty_desc);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   706
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   707
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   708
static const char *_patches_ui[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   709
	"vehicle_speed",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   710
	"status_long_date",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   711
	"show_finances",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   712
	"autoscroll",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   713
	"reverse_scroll",
7226
a8650d6ecb53 (svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents: 7170
diff changeset
   714
	"smooth_scroll",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   715
	"errmsg_duration",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   716
	"toolbar_pos",
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4727
diff changeset
   717
	"measure_tooltip",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   718
	"window_snap_radius",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   719
	"invisible_trees",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   720
	"population_in_label",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   721
	"link_terraform_toolbar",
4616
baa9d4436b9e (svn r6474) - Add a patch option to control display of liveries, allowing none, your
peter1138
parents: 4552
diff changeset
   722
	"liveries",
5107
8791beb0ae51 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
   723
	"prefer_teamchat",
6615
96d30d65ed35 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6585
diff changeset
   724
	/* While the horizontal scrollwheel scrolling is written as general code, only
96d30d65ed35 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6585
diff changeset
   725
	 *  the cocoa (OSX) driver generates input for it.
6622
2ce7ffa9db00 (svn r9126) -Feature: "Function of scrollwheel" can now be set to off as well
bjarni
parents: 6619
diff changeset
   726
	 *  Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
6615
96d30d65ed35 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6585
diff changeset
   727
	"scrollwheel_scrolling",
96d30d65ed35 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6585
diff changeset
   728
	"scrollwheel_multiplier",
7981
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7837
diff changeset
   729
#ifdef __APPLE__
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7837
diff changeset
   730
	/* We might need to emulate a right mouse button on mac */
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7837
diff changeset
   731
	"right_mouse_btn_emulation",
506461241c0e (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7837
diff changeset
   732
#endif
7039
a20ddaf4dc97 (svn r9734) -Feature: Add an option to automatically pause when starting a new game.
maedhros
parents: 6988
diff changeset
   733
	"pause_on_newgame",
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 7067
diff changeset
   734
	"advanced_vehicle_list",
7494
99eac2a2cd8b (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 7476
diff changeset
   735
	"loading_indicators",
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7452
diff changeset
   736
	"timetable_in_ticks",
7560
f7b5ab184882 (svn r10329) -Feature [FS#812]: (patch) option to select the "default" rail type when you start a new game or load a game. This is done either static, i.e. rail, electrified rail, monorail and maglev, or dynamic which takes either the first or last available railtype or the railtype that is used most on the map.
rubidium
parents: 7494
diff changeset
   737
	"default_rail_type",
7582
9f23c01ae23d (svn r10353) -Fix/Feature [FS#669]: disallow (in the GUI) the building of infrastructure you do not have available vehicles for. This means that the airport building button is disabled till you can actually build aircraft. The game itself will not disallow you to build the infrastructure and this "new" behaviour can be overriden with a patch setting.
rubidium
parents: 7560
diff changeset
   738
	"always_build_infrastructure",
21
67cde01e8359 (svn r22) Add: Competitors menu under patches
truelight
parents: 20
diff changeset
   739
};
67cde01e8359 (svn r22) Add: Competitors menu under patches
truelight
parents: 20
diff changeset
   740
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   741
static const char *_patches_construction[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   742
	"build_on_slopes",
8078
bdf94bf88568 (svn r11107) -Feature: some tool so one can still build tunnels under rails (and other structures) when the owner of the structure built it on foundations and if you have enough "empty" space ofcourse. One could use the tool for some other construction needs too. Patch by frosch.
rubidium
parents: 7981
diff changeset
   743
	"autoslope",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   744
	"extra_dynamite",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   745
	"longbridges",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   746
	"signal_side",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   747
	"always_small_airport",
8487
bab0d066128b (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 8450
diff changeset
   748
	"enable_signal_gui",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   749
	"drag_signals_density",
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   750
	"oil_refinery_limit",
5939
77530457a36b (svn r8151) -Feature: Automatically build semaphores before a configurable date, which can be set by each network player seperately.
maedhros
parents: 5919
diff changeset
   751
	"semaphore_build_before",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   752
};
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   753
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   754
static const char *_patches_stations[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   755
	"join_stations",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   756
	"full_load_any",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   757
	"improved_load",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   758
	"selectgoods",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   759
	"new_nonstop",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   760
	"nonuniform_stations",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   761
	"station_spread",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   762
	"serviceathelipad",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   763
	"modified_catchment",
5211
651c9272ad22 (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5163
diff changeset
   764
	"gradual_loading",
6338
0fb4f452873c (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 6144
diff changeset
   765
	"road_stop_on_town_road",
7170
bd34b6d0e4f1 (svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros
parents: 7139
diff changeset
   766
	"adjacent_stations",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   767
};
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   768
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   769
static const char *_patches_economy[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   770
	"inflation",
7673
3ab9344bd532 (svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents: 7582
diff changeset
   771
	"raw_industry_construction",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   772
	"multiple_industry_per_town",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   773
	"same_industry_close",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   774
	"bribe",
8153
32f871f7e7f7 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents: 8137
diff changeset
   775
	"exclusive_rights",
32f871f7e7f7 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents: 8137
diff changeset
   776
	"give_money",
4285
72b3f7d6c891 (svn r5915) -Cleanup: some variables were named *_date while they were only holding years; rename these variables to match this.
rubidium
parents: 4261
diff changeset
   777
	"colored_news_year",
72b3f7d6c891 (svn r5915) -Cleanup: some variables were named *_date while they were only holding years; rename these variables to match this.
rubidium
parents: 4261
diff changeset
   778
	"ending_year",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   779
	"smooth_economy",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   780
	"allow_shares",
8137
67a9579abd74 (svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium
parents: 8078
diff changeset
   781
	"town_layout",
67a9579abd74 (svn r11172) -Codechange: rewrite of town road building and addition of the possibility to clean up unconnected road bits during the local road reconstructions. Based on a patch by skidd13.
rubidium
parents: 8078
diff changeset
   782
	"mod_road_rebuild",
6950
c572b218bf2f (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6916
diff changeset
   783
	"town_growth_rate",
c572b218bf2f (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6916
diff changeset
   784
	"larger_towns",
6982
c414fad6c440 (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6979
diff changeset
   785
	"initial_city_size",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   786
};
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   787
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   788
static const char *_patches_ai[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   789
	"ainew_active",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   790
	"ai_in_multiplayer",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   791
	"ai_disable_veh_train",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   792
	"ai_disable_veh_roadveh",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   793
	"ai_disable_veh_aircraft",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   794
	"ai_disable_veh_ship",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   795
};
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   796
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   797
static const char *_patches_vehicles[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   798
	"realistic_acceleration",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   799
	"forbid_90_deg",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   800
	"mammoth_trains",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   801
	"gotodepot",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   802
	"roadveh_queue",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   803
	"new_pathfinding_all",
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3888
diff changeset
   804
	"yapf.ship_use_yapf",
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3888
diff changeset
   805
	"yapf.road_use_yapf",
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3888
diff changeset
   806
	"yapf.rail_use_yapf",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   807
	"train_income_warn",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   808
	"order_review_system",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   809
	"never_expire_vehicles",
4870
0ee22ed51ada (svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents: 4834
diff changeset
   810
	"lost_train_warn",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   811
	"autorenew",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   812
	"autorenew_months",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   813
	"autorenew_money",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   814
	"max_trains",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   815
	"max_roadveh",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   816
	"max_aircraft",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   817
	"max_ships",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   818
	"servint_ispercent",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   819
	"servint_trains",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   820
	"servint_roadveh",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   821
	"servint_ships",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   822
	"servint_aircraft",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   823
	"no_servicing_if_no_breakdowns",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   824
	"wagon_speed_limits",
5116
2a33a74925c5 (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5113
diff changeset
   825
	"disable_elrails",
5163
83acad83bbdd (svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents: 5141
diff changeset
   826
	"freight_trains",
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7452
diff changeset
   827
	"timetabling",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   828
};
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   829
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   830
struct PatchEntry {
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   831
	const SettingDesc *setting;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   832
	uint index;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   833
};
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   834
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   835
struct PatchPage {
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   836
	const char **names;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   837
	PatchEntry *entries;
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   838
	byte num;
6574
e1d1a12faaf7 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6573
diff changeset
   839
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   840
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   841
/* PatchPage holds the categories, the number of elements in each category
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   842
 * and (in NULL) a dynamic array of settings based on the string-representations
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   843
 * of the settings. This way there is no worry about indeces, and such */
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   844
static PatchPage _patches_page[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   845
	{_patches_ui,           NULL, lengthof(_patches_ui)},
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   846
	{_patches_construction, NULL, lengthof(_patches_construction)},
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   847
	{_patches_vehicles,     NULL, lengthof(_patches_vehicles)},
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   848
	{_patches_stations,     NULL, lengthof(_patches_stations)},
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   849
	{_patches_economy,      NULL, lengthof(_patches_economy)},
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   850
	{_patches_ai,           NULL, lengthof(_patches_ai)},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   851
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   852
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   853
enum PatchesSelectionWidgets {
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   854
	PATCHSEL_OPTIONSPANEL = 3,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   855
	PATCHSEL_INTERFACE,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   856
	PATCHSEL_CONSTRUCTION,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   857
	PATCHSEL_VEHICLES,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   858
	PATCHSEL_STATIONS,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   859
	PATCHSEL_ECONOMY,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   860
	PATCHSEL_COMPETITORS
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   861
};
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   862
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   863
/** The main patches window. Shows a number of categories on top and
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   864
 * a selection of patches in that category.
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   865
 * Uses WP(w, def_d) macro - data_1, data_2, data_3 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   866
static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   867
{
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   868
	static Patches *patches_ptr;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   869
1741
9087c5207f18 (svn r2245) - CodeChange: simplify the clamping of values for patch-settings by using clamp()
Darkvater
parents: 1739
diff changeset
   870
	switch (e->event) {
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   871
		case WE_CREATE: {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   872
			static bool first_time = true;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   873
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   874
			patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   875
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   876
			/* Build up the dynamic settings-array only once per OpenTTD session */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   877
			if (first_time) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   878
				PatchPage *page;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   879
				for (page = &_patches_page[0]; page != endof(_patches_page); page++) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   880
					uint i;
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   881
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   882
					page->entries = MallocT<PatchEntry>(page->num);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   883
					for (i = 0; i != page->num; i++) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   884
						uint index;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   885
						const SettingDesc *sd = GetPatchFromName(page->names[i], &index);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   886
						assert(sd != NULL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   887
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   888
						page->entries[i].setting = sd;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   889
						page->entries[i].index = index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   890
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   891
				}
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   892
				first_time = false;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   893
			}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   894
			w->LowerWidget(4);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   895
		} break;
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   896
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   897
		case WE_PAINT: {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   898
			int x, y;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   899
			const PatchPage *page = &_patches_page[WP(w, def_d).data_1];
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   900
			uint i;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   901
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   902
			/* Set up selected category */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   903
			DrawWindowWidgets(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   904
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   905
			x = 5;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   906
			y = 47;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   907
			for (i = 0; i != page->num; i++) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   908
				const SettingDesc *sd = page->entries[i].setting;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   909
				const SettingDescBase *sdb = &sd->desc;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   910
				const void *var = GetVariableAddress(patches_ptr, &sd->save);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   911
				bool editable = true;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   912
				bool disabled = false;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   913
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   914
				// We do not allow changes of some items when we are a client in a networkgame
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   915
				if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   916
				if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   917
				if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   918
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   919
				if (sdb->cmd == SDT_BOOLX) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   920
					static const int _bool_ctabs[2][2] = {{9, 4}, {7, 6}};
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   921
					/* Draw checkbox for boolean-value either on/off */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   922
					bool on = (*(bool*)var);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   923
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   924
					DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : FR_NONE);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   925
					SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   926
				} else {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   927
					int32 value;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   928
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   929
					value = (int32)ReadValue(var, sd->save.conv);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   930
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   931
					/* Draw [<][>] boxes for settings of an integer-type */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   932
					DrawArrowButtons(x, y, 3, WP(w, def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   933
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   934
					disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   935
					if (disabled) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   936
						SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   937
					} else {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   938
						if (sdb->flags & SGF_CURRENCY) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   939
							SetDParam(0, STR_CONFIG_PATCHES_CURRENCY);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   940
						} else if (sdb->flags & SGF_MULTISTRING) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   941
							SetDParam(0, sdb->str + value + 1);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   942
						} else {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   943
							SetDParam(0, (sdb->flags & SGF_NOCOMMA) ? STR_CONFIG_PATCHES_INT32 : STR_7024);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   944
						}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   945
						SetDParam(1, value);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   946
					}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   947
				}
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   948
				DrawString(30, y, (sdb->str) + disabled, TC_FROMSTRING);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   949
				y += 11;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   950
			}
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
   951
		} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   952
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   953
		case WE_CLICK:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   954
			switch (e->we.click.widget) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   955
				case PATCHSEL_OPTIONSPANEL: {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   956
					const PatchPage *page = &_patches_page[WP(w, def_d).data_1];
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   957
					const SettingDesc *sd;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   958
					void *var;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   959
					int32 value;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   960
					int x, y;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   961
					byte btn;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   962
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   963
					y = e->we.click.pt.y - 46 - 1;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   964
					if (y < 0) return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   965
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   966
					x = e->we.click.pt.x - 5;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   967
					if (x < 0) return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   968
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   969
					btn = y / 11;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   970
					if (y % 11 > 9) return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   971
					if (btn >= page->num) return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   972
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   973
					sd = page->entries[btn].setting;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   974
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   975
					/* return if action is only active in network, or only settable by server */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   976
					if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   977
					if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   978
					if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   979
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   980
					var = GetVariableAddress(patches_ptr, &sd->save);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   981
					value = (int32)ReadValue(var, sd->save.conv);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   982
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   983
					/* clicked on the icon on the left side. Either scroller or bool on/off */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   984
					if (x < 21) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   985
						const SettingDescBase *sdb = &sd->desc;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   986
						int32 oldvalue = value;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   987
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   988
						switch (sdb->cmd) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   989
						case SDT_BOOLX: value ^= 1; break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   990
						case SDT_NUMX: {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   991
							/* Add a dynamic step-size to the scroller. In a maximum of
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   992
							 * 50-steps you should be able to get from min to max,
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   993
							 * unless specified otherwise in the 'interval' variable
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   994
							 * of the current patch. */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   995
							uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   996
							if (step == 0) step = 1;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   997
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   998
							// don't allow too fast scrolling
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
   999
							if ((w->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1000
								_left_button_clicked = false;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1001
								return;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1002
							}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1003
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1004
							/* Increase or decrease the value and clamp it to extremes */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1005
							if (x >= 10) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1006
								value += step;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1007
								if (value > sdb->max) value = sdb->max;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1008
							} else {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1009
								value -= step;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1010
								if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1011
							}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1012
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1013
							/* Set up scroller timeout for numeric values */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1014
							if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1015
								WP(w, def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1016
								w->flags4 |= 5 << WF_TIMEOUT_SHL;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1017
								_left_button_clicked = false;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1018
							}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1019
						} break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1020
						default: NOT_REACHED();
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1021
						}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1022
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1023
						if (value != oldvalue) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1024
							SetPatchValue(page->entries[btn].index, patches_ptr, value);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1025
							SetWindowDirty(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1026
						}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1027
					} else {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1028
						/* only open editbox for types that its sensible for */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1029
						if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1030
							/* Show the correct currency-translated value */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1031
							if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1032
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1033
							WP(w, def_d).data_3 = btn;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1034
							SetDParam(0, value);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1035
							ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1036
						}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1037
					}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1038
				} break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1039
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1040
				case PATCHSEL_INTERFACE: case PATCHSEL_CONSTRUCTION: case PATCHSEL_VEHICLES:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1041
				case PATCHSEL_STATIONS:  case PATCHSEL_ECONOMY:      case PATCHSEL_COMPETITORS:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1042
					w->RaiseWidget(WP(w, def_d).data_1 + PATCHSEL_INTERFACE);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1043
					WP(w, def_d).data_1 = e->we.click.widget - PATCHSEL_INTERFACE;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1044
					w->LowerWidget(WP(w, def_d).data_1 + PATCHSEL_INTERFACE);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1045
					DeleteWindowById(WC_QUERY_STRING, 0);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1046
					SetWindowDirty(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1047
					break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1048
			}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1049
			break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1050
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1051
		case WE_TIMEOUT:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1052
			WP(w, def_d).data_2 = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1053
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1054
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1055
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1056
		case WE_ON_EDIT_TEXT:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1057
			if (e->we.edittext.str != NULL) {
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1058
				const PatchEntry *pe = &_patches_page[WP(w, def_d).data_1].entries[WP(w,def_d).data_3];
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1059
				const SettingDesc *sd = pe->setting;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1060
				int32 value = atoi(e->we.edittext.str);
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
  1061
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1062
				/* Save the correct currency-translated value */
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1063
				if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1064
8686
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1065
				SetPatchValue(pe->index, patches_ptr, value);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1066
				SetWindowDirty(w);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1067
			}
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1068
			break;
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1069
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1070
		case WE_DESTROY:
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1071
			DeleteWindowById(WC_QUERY_STRING, 0);
b1d73ae17e19 (svn r11753) -Codechange: re-indent the switch case structures, as to be more code style oriented.
belugas
parents: 8685
diff changeset
  1072
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1073
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1074
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1075
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1076
static const Widget _patches_selection_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1077
{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1078
{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_CONFIG_PATCHES_CAPTION,      STR_018C_WINDOW_TITLE_DRAG_THIS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1079
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                             STR_NULL},
7476
7f086e4b2a76 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 7452
diff changeset
  1080
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   380, 0x0,                             STR_NULL},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1081
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1082
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_CONFIG_PATCHES_GUI,          STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1083
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1084
{    WWT_TEXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_CONFIG_PATCHES_VEHICLES,     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1085
{    WWT_TEXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_CONFIG_PATCHES_STATIONS,     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1086
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    28,    39, STR_CONFIG_PATCHES_ECONOMY,      STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1087
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    97,   183,    28,    39, STR_CONFIG_PATCHES_AI,           STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 164
diff changeset
  1088
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1089
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1090
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1091
static const WindowDesc _patches_selection_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7673
diff changeset
  1092
	WDP_CENTER, WDP_CENTER, 370, 381, 370, 381,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5939
diff changeset
  1093
	WC_GAME_OPTIONS, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1094
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1095
	_patches_selection_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1096
	PatchesSelectionWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1097
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1098
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6338
diff changeset
  1099
void ShowPatchesSelection()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1100
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1101
	DeleteWindowById(WC_GAME_OPTIONS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1102
	AllocateWindowDesc(&_patches_selection_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1103
}
478
19987403ee5d (svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents: 430
diff changeset
  1104
19987403ee5d (svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents: 430
diff changeset
  1105
4211
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1106
/**
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1107
 * Draw [<][>] boxes.
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1108
 * @param x the x position to draw
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1109
 * @param y the y position to draw
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1110
 * @param ctab the color of the buttons
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1111
 * @param state 0 = none clicked, 1 = first clicked, 2 = second clicked
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1112
 * @param clickable_left is the left button clickable?
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1113
 * @param clickable_right is the right button clickable?
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1114
 */
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1115
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right)
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1116
{
5919
2b58160d667d (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5860
diff changeset
  1117
	int color = (1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[COLOUR_YELLOW][2];
3107
a6406bbecd3d (svn r3710) - Use the general function DrawArrowButtons() instead of doing it manually. The function has two parameters added, colour and an enabled flag.
Darkvater
parents: 2952
diff changeset
  1118
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
  1119
	DrawFrameRect(x,      y + 1, x +  9, y + 9, ctab, (state == 1) ? FR_LOWERED : FR_NONE);
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
  1120
	DrawFrameRect(x + 10, y + 1, x + 19, y + 9, ctab, (state == 2) ? FR_LOWERED : FR_NONE);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8238
diff changeset
  1121
	DrawStringCentered(x +  5, y + 1, STR_6819, TC_FROMSTRING); // [<]
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8238
diff changeset
  1122
	DrawStringCentered(x + 15, y + 1, STR_681A, TC_FROMSTRING); // [>]
4211
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1123
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1124
	/* Grey out the buttons that aren't clickable */
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1125
	if (!clickable_left)
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1126
		GfxFillRect(x +  1, y + 1, x +  1 + 8, y + 8, color);
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1127
	if (!clickable_right)
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1128
		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color);
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1129
}
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1130
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1131
/** These are not, strickly speaking, widget enums,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1132
 *  since they have been changed as line coordinates.
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1133
 *  So, rather, they are more like order of appearance */
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1134
enum CustomCurrenciesWidgets {
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1135
	CUSTCURR_EXCHANGERATE = 0,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1136
	CUSTCURR_SEPARATOR,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1137
	CUSTCURR_PREFIX,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1138
	CUSTCURR_SUFFIX,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1139
	CUSTCURR_TO_EURO,
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1140
};
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1141
2307
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
  1142
static char _str_separator[2];
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1143
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1144
static void CustCurrencyWndProc(Window *w, WindowEvent *e)
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1145
{
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1146
	switch (e->event) {
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1147
		case WE_PAINT: {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1148
			int x;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1149
			int y = 20;
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
  1150
			int clk = WP(w, def_d).data_1;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1151
			DrawWindowWidgets(w);
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1152
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1153
			/* exchange rate */
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1154
			DrawArrowButtons(10, y, 3, GB(clk, 0, 2), true, true);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1155
			SetDParam(0, 1);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1156
			SetDParam(1, 1);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8238
diff changeset
  1157
			DrawString(35, y + 1, STR_CURRENCY_EXCHANGE_RATE, TC_FROMSTRING);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1158
			y += 12;
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1159
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1160
			/* separator */
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
  1161
			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 2, 2) ? FR_LOWERED : FR_NONE);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8238
diff changeset
  1162
			x = DrawString(35, y + 1, STR_CURRENCY_SEPARATOR, TC_FROMSTRING);
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8238
diff changeset
  1163
			DoDrawString(_str_separator, x + 4, y + 1, TC_ORANGE);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1164
			y += 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1165
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1166
			/* prefix */
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
  1167
			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 4, 2) ? FR_LOWERED : FR_NONE);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8238
diff changeset
  1168
			x = DrawString(35, y + 1, STR_CURRENCY_PREFIX, TC_FROMSTRING);
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8238
diff changeset
  1169
			DoDrawString(_custom_currency.prefix, x + 4, y + 1, TC_ORANGE);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1170
			y += 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1171
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1172
			/* suffix */
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
  1173
			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 6, 2) ? FR_LOWERED : FR_NONE);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8238
diff changeset
  1174
			x = DrawString(35, y + 1, STR_CURRENCY_SUFFIX, TC_FROMSTRING);
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8238
diff changeset
  1175
			DoDrawString(_custom_currency.suffix, x + 4, y + 1, TC_ORANGE);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1176
			y += 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1177
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1178
			/* switch to euro */
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1179
			DrawArrowButtons(10, y, 3, GB(clk, 8, 2), true, true);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1180
			SetDParam(0, _custom_currency.to_euro);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8238
diff changeset
  1181
			DrawString(35, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, TC_FROMSTRING);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1182
			y += 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1183
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1184
			/* Preview */
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1185
			y += 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1186
			SetDParam(0, 10000);
8320
6ffad7a5d242 (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 8238
diff changeset
  1187
			DrawString(35, y + 1, STR_CURRENCY_PREVIEW, TC_FROMSTRING);
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1188
		} break;
812
79c99885ad00 (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 788
diff changeset
  1189
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1190
		case WE_CLICK: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
  1191
			int line = (e->we.click.pt.y - 20) / 12;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1192
			int len = 0;
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
  1193
			int x = e->we.click.pt.x;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1194
			StringID str = 0;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1195
			CharSetFilter afilter = CS_ALPHANUMERAL;
812
79c99885ad00 (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 788
diff changeset
  1196
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1197
			switch (line) {
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1198
				case CUSTCURR_EXCHANGERATE:
8450
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8427
diff changeset
  1199
					if (IsInsideMM(x, 10, 30)) { // clicked buttons
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1200
						if (x < 20) {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1201
							if (_custom_currency.rate > 1) _custom_currency.rate--;
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
  1202
							WP(w, def_d).data_1 = 1 << (line * 2 + 0);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1203
						} else {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1204
							if (_custom_currency.rate < 5000) _custom_currency.rate++;
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
  1205
							WP(w, def_d).data_1 = 1 << (line * 2 + 1);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1206
						}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1207
					} else { // enter text
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1208
						SetDParam(0, _custom_currency.rate);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1209
						str = STR_CONFIG_PATCHES_INT32;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1210
						len = 4;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1211
						afilter = CS_NUMERAL;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1212
					}
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1213
					break;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1214
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1215
				case CUSTCURR_SEPARATOR:
8450
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8427
diff changeset
  1216
					if (IsInsideMM(x, 10, 30)) { // clicked button
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
  1217
						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1218
					}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1219
					str = BindCString(_str_separator);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1220
					len = 1;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1221
					break;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1222
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1223
				case CUSTCURR_PREFIX:
8450
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8427
diff changeset
  1224
					if (IsInsideMM(x, 10, 30)) { // clicked button
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
  1225
						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1226
					}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1227
					str = BindCString(_custom_currency.prefix);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1228
					len = 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1229
					break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1230
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1231
				case CUSTCURR_SUFFIX:
8450
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8427
diff changeset
  1232
					if (IsInsideMM(x, 10, 30)) { // clicked button
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
  1233
						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1234
					}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1235
					str = BindCString(_custom_currency.suffix);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1236
					len = 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1237
					break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1238
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1239
				case CUSTCURR_TO_EURO:
8450
dce58137301f (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 8427
diff changeset
  1240
					if (IsInsideMM(x, 10, 30)) { // clicked buttons
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1241
						if (x < 20) {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1242
							_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ?
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1243
								CF_NOEURO : _custom_currency.to_euro - 1;
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
  1244
							WP(w, def_d).data_1 = 1 << (line * 2 + 0);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1245
						} else {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1246
							_custom_currency.to_euro =
8418
b49fc6be1ab9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 8397
diff changeset
  1247
								Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
  1248
							WP(w, def_d).data_1 = 1 << (line * 2 + 1);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1249
						}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1250
					} else { // enter text
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1251
						SetDParam(0, _custom_currency.to_euro);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1252
						str = STR_CONFIG_PATCHES_INT32;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1253
						len = 4;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1254
						afilter = CS_NUMERAL;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1255
					}
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1256
					break;
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1257
			}
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1258
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1259
			if (len != 0) {
5682
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5237
diff changeset
  1260
				WP(w, def_d).data_2 = line;
eeddbbacd4ac (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5237
diff changeset
  1261
				ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, w, afilter);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1262
			}
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1263
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1264
			w->flags4 |= 5 << WF_TIMEOUT_SHL;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1265
			SetWindowDirty(w);
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1266
		} break;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1267
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1268
		case WE_ON_EDIT_TEXT: {
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1269
			const char *b = e->we.edittext.str;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1270
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1271
			switch (WP(w, def_d).data_2) {
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1272
				case CUSTCURR_EXCHANGERATE:
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1273
					_custom_currency.rate = Clamp(atoi(b), 1, 5000);
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1274
					break;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1275
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1276
				case CUSTCURR_SEPARATOR: /* Thousands seperator */
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1277
					_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0];
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1278
					ttd_strlcpy(_str_separator, b, lengthof(_str_separator));
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1279
					break;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1280
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1281
				case CUSTCURR_PREFIX:
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1282
					ttd_strlcpy(_custom_currency.prefix, b, lengthof(_custom_currency.prefix));
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1283
					break;
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1284
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1285
				case CUSTCURR_SUFFIX:
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1286
					ttd_strlcpy(_custom_currency.suffix, b, lengthof(_custom_currency.suffix));
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1287
					break;
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1288
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1289
				case CUSTCURR_TO_EURO: { /* Year to switch to euro */
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1290
					int val = atoi(b);
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1291
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1292
					_custom_currency.to_euro = (val < 2000 ? CF_NOEURO : min(val, MAX_YEAR));
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1293
					break;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1294
				}
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1295
			}
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1296
			MarkWholeScreenDirty();
8684
ad348701d4e1 (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8678
diff changeset
  1297
		} break;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1298
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1299
		case WE_TIMEOUT:
8578
55218950ce2d (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 8493
diff changeset
  1300
			WP(w, def_d).data_1 = 0;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1301
			SetWindowDirty(w);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1302
			break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1303
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1304
		case WE_DESTROY:
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1305
			DeleteWindowById(WC_QUERY_STRING, 0);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1306
			MarkWholeScreenDirty();
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1307
			break;
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1308
	}
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1309
}
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1310
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1311
static const Widget _cust_currency_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1312
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1313
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   229,     0,    13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1314
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   229,    14,   119, 0x0,                 STR_NULL},
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1315
{   WIDGETS_END},
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1316
};
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1317
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1318
static const WindowDesc _cust_currency_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7673
diff changeset
  1319
	WDP_CENTER, WDP_CENTER, 230, 120, 230, 120,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5939
diff changeset
  1320
	WC_CUSTOM_CURRENCY, WC_NONE,
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1321
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1322
	_cust_currency_widgets,
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1323
	CustCurrencyWndProc,
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1324
};
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1325
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6338
diff changeset
  1326
static void ShowCustCurrency()
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1327
{
2306
3d4efe849dd9 (svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents: 2293
diff changeset
  1328
	_str_separator[0] = _custom_currency.separator;
1759
ea38d6193887 (svn r2263) - Fix: If the seperator string is empty for custom currencies, everything after that is cut off. Fix it by replacing nothing with ' '. Thanks for noticing peter1138
Darkvater
parents: 1756
diff changeset
  1329
	_str_separator[1] = '\0';
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1330
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1331
	DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1332
	AllocateWindowDesc(&_cust_currency_desc);
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1333
}