src/settings_gui.cpp
author belugas
Fri, 04 Jan 2008 03:04:19 +0000
changeset 8189 3ec02608168d
parent 8188 f326251c9d7f
child 8190 81dd3c9929c8
permissions -rw-r--r--
(svn r11752) -Fix(r11745): Silence a MSVC warning (glx)
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6378
diff changeset
     3
/** @file settings_gui.cpp */
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6378
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1806
diff changeset
     6
#include "openttd.h"
2291
c142846954ee (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"
1317
3c90086ff34f (svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents: 1309
diff changeset
     8
#include "string.h"
1363
775a7ee52369 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1323
diff changeset
     9
#include "table/sprites.h"
507
04b5403aaf6b (svn r815) Include strings.h only in the files which need it.
tron
parents: 502
diff changeset
    10
#include "table/strings.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    12
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    13
#include "textbuf_gui.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    14
#include "command_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
#include "engine.h"
430
2e9a2e9fcf11 (svn r631) Merge r440, r444, r485, r630 to trunk:
tron
parents: 350
diff changeset
    16
#include "screenshot.h"
478
3a161108a15d (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
    17
#include "newgrf.h"
5469
7edfc643abbc (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: 5431
diff changeset
    18
#include "network/network.h"
835
f6a341f541d7 (svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents: 833
diff changeset
    19
#include "town.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2140
diff changeset
    20
#include "variables.h"
3118
adc86793eee1 (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
    21
#include "settings.h"
6956
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    22
#include "newgrf_townname.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8107
diff changeset
    23
#include "strings_func.h"
8131
160939e24ed3 (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: 8130
diff changeset
    24
#include "functions.h"
160939e24ed3 (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: 8130
diff changeset
    25
#include "window_func.h"
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8140
diff changeset
    26
#include "vehicle_base.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
static uint32 _difficulty_click_a;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
static uint32 _difficulty_click_b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
static byte _difficulty_timeout;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
3342
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    32
static const StringID _units_dropdown[] = {
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    33
	STR_UNITS_IMPERIAL,
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    34
	STR_UNITS_METRIC,
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    35
	STR_UNITS_SI,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
	INVALID_STRING_ID
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
static const StringID _driveside_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
	STR_02E9_DRIVE_ON_LEFT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
	STR_02EA_DRIVE_ON_RIGHT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	INVALID_STRING_ID
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
static const StringID _autosave_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
	STR_02F7_OFF,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
	STR_AUTOSAVE_1_MONTH,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
	STR_02F8_EVERY_3_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
	STR_02F9_EVERY_6_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
	STR_02FA_EVERY_12_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
	INVALID_STRING_ID,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
static const StringID _designnames_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
	STR_02BE_DEFAULT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
	STR_02BF_CUSTOM,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
	INVALID_STRING_ID
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
static StringID *BuildDynamicDropdown(StringID base, int num)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
	static StringID buf[32 + 1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
	StringID *p = buf;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
	while (--num>=0) *p++ = base++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
	*p = INVALID_STRING_ID;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
	return buf;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
6956
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    69
int _nb_orig_names = SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1;
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    70
static StringID *_town_names = NULL;
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    71
static StringID *_grf_names = NULL;
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    72
static int _nb_grf_names = 0;
6797
cc313f6757ef (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 6730
diff changeset
    73
cc313f6757ef (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 6730
diff changeset
    74
void SortTownGeneratorNames()
cc313f6757ef (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 6730
diff changeset
    75
{
6956
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    76
	int n = 0;
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    77
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    78
	/* Get Newgrf generators' names */
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    79
	free(_grf_names);
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    80
	_grf_names = GetGRFTownNameList();
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    81
	_nb_grf_names = 0;
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    82
	for (StringID *s = _grf_names; *s != INVALID_STRING_ID; s++) _nb_grf_names++;
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    83
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    84
	/* Prepare the list */
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    85
	free(_town_names);
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    86
	_town_names = MallocT<StringID>(_nb_orig_names + _nb_grf_names + 1);
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    87
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    88
	/* Put the original strings */
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    89
	for (int i = 0; i < _nb_orig_names; i++) _town_names[n++] = STR_TOWNNAME_ORIGINAL_ENGLISH + i;
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    90
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    91
	/* Put the grf strings */
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    92
	for (int i = 0; i < _nb_grf_names; i++) _town_names[n++] = _grf_names[i];
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    93
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    94
	/* Put the terminator */
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    95
	_town_names[n] = INVALID_STRING_ID;
6797
cc313f6757ef (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 6730
diff changeset
    96
cc313f6757ef (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 6730
diff changeset
    97
	/* Sort the strings */
6956
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    98
	qsort(&_town_names[0], _nb_orig_names + _nb_grf_names, sizeof(StringID), &StringIDSorter);
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
    99
}
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   100
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   101
static inline StringID TownName(int town_name)
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   102
{
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   103
	if (town_name < _nb_orig_names) return STR_TOWNNAME_ORIGINAL_ENGLISH + town_name;
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   104
	town_name -= _nb_orig_names;
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   105
	if (town_name < _nb_grf_names) return _grf_names[town_name];
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   106
	return STR_UNDEFINED;
6797
cc313f6757ef (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 6730
diff changeset
   107
}
cc313f6757ef (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 6730
diff changeset
   108
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6012
diff changeset
   109
static int GetCurRes()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
	int i;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   112
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   113
	for (i = 0; i != _num_resolutions; i++) {
306
9ba288cacf0a (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 298
diff changeset
   114
		if (_resolutions[i][0] == _screen.width &&
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   115
				_resolutions[i][1] == _screen.height) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
			break;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   117
		}
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   118
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	return i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6012
diff changeset
   122
static inline bool RoadVehiclesAreBuilt()
871
0143ae5b4112 (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
   123
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   124
	const Vehicle* v;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   125
915
d845fe7cf6f2 (svn r1402) Trim trailing whitespace
tron
parents: 893
diff changeset
   126
	FOR_ALL_VEHICLES(v) {
6259
471b91a4b1d8 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6255
diff changeset
   127
		if (v->type == VEH_ROAD) return true;
871
0143ae5b4112 (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
   128
	}
0143ae5b4112 (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
   129
	return false;
0143ae5b4112 (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
   130
}
0143ae5b4112 (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
   131
2817
cdf488223c23 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
   132
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   133
enum GameOptionsWidgets {
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   134
	GAMEOPT_CURRENCY_TXT    =  4,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   135
	GAMEOPT_CURRENCY_BTN,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   136
	GAMEOPT_DISTANCE_TXT    =  7,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   137
	GAMEOPT_DISTANCE_BTN,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   138
	GAMEOPT_ROADSIDE_TXT    = 10,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   139
	GAMEOPT_ROADSIDE_BTN,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   140
	GAMEOPT_TOWNNAME_TXT    = 13,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   141
	GAMEOPT_TOWNNAME_BTN,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   142
	GAMEOPT_AUTOSAVE_TXT    = 16,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   143
	GAMEOPT_AUTOSAVE_BTN,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   144
	GAMEOPT_VEHICLENAME_TXT = 19,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   145
	GAMEOPT_VEHICLENAME_BTN,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   146
	GAMEOPT_VEHICLENAME_SAVE,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   147
	GAMEOPT_LANG_TXT        = 23,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   148
	GAMEOPT_LANG_BTN,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   149
	GAMEOPT_RESOLUTION_TXT  = 26,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   150
	GAMEOPT_RESOLUTION_BTN,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   151
	GAMEOPT_FULLSCREEN,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   152
	GAMEOPT_SCREENSHOT_TXT  = 30,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   153
	GAMEOPT_SCREENSHOT_BTN,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   154
};
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   155
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6012
diff changeset
   156
static void ShowCustCurrency();
2817
cdf488223c23 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
   157
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
static void GameOptionsWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
{
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   160
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
	case WE_PAINT: {
871
0143ae5b4112 (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
   162
		int i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
		StringID str = STR_02BE_DEFAULT;
4709
a81ab800c25b (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   164
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7991
diff changeset
   165
		w->SetWidgetDisabledState(21, !(_vehicle_design_names & 1));
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7991
diff changeset
   166
		if (!w->IsWidgetDisabled(21)) str = STR_02BF_CUSTOM;
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   167
		SetDParam(0, str);
4377
f04bcf6f9a04 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4344
diff changeset
   168
		SetDParam(1, _currency_specs[_opt_ptr->currency].name);
3342
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
   169
		SetDParam(2, STR_UNITS_IMPERIAL + _opt_ptr->units);
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   170
		SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_ptr->road_side);
6956
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   171
		SetDParam(4, TownName(_opt_ptr->town_name));
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   172
		SetDParam(5, _autosave_dropdown[_opt_ptr->autosave]);
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   173
		SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
		i = GetCurRes();
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   175
		SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   176
		SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format);
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   177
		w->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen);
298
0123c0489940 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   178
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   179
		DrawWindowWidgets(w);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
   180
		DrawString(20, 175, STR_OPTIONS_FULLSCREEN, TC_FROMSTRING); // fullscreen
6492
286a52449b54 (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6486
diff changeset
   181
	} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   184
		switch (e->we.click.widget) {
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   185
		case GAMEOPT_CURRENCY_TXT: case GAMEOPT_CURRENCY_BTN: /* Setup currencies dropdown */
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   186
			ShowDropDownMenu(w, BuildCurrencyDropdown(), _opt_ptr->currency, GAMEOPT_CURRENCY_BTN, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   187
			break;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   189
		case GAMEOPT_DISTANCE_TXT: case GAMEOPT_DISTANCE_BTN: /* Setup distance unit dropdown */
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   190
			ShowDropDownMenu(w, _units_dropdown, _opt_ptr->units, GAMEOPT_DISTANCE_BTN, 0, 0);
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   191
			break;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   192
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   193
		case GAMEOPT_ROADSIDE_TXT: case GAMEOPT_ROADSIDE_BTN: { /* Setup road-side dropdown */
871
0143ae5b4112 (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
   194
			int i = 0;
0143ae5b4112 (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
   195
0143ae5b4112 (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
   196
			/* You can only change the drive side if you are in the menu or ingame with
0143ae5b4112 (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
   197
			 * no vehicles present. In a networking game only the server can change it */
0143ae5b4112 (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
   198
			if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server))
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   199
				i = (-1) ^ (1 << _opt_ptr->road_side); // disable the other value
871
0143ae5b4112 (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
   200
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   201
			ShowDropDownMenu(w, _driveside_dropdown, _opt_ptr->road_side, GAMEOPT_ROADSIDE_BTN, i, 0);
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   202
		} break;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   203
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   204
		case GAMEOPT_TOWNNAME_TXT: case GAMEOPT_TOWNNAME_BTN: { /* Setup townname dropdown */
6798
a640d9b85407 (svn r10037) -Fix (r10035, r10036): silence some 'may be used uninitialized' warnings
glx
parents: 6797
diff changeset
   205
			uint sel = 0;
6956
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   206
			for (uint i = 0; _town_names[i] != INVALID_STRING_ID; i++) {
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   207
				if (_town_names[i] == TownName(_opt_ptr->town_name)) {
6797
cc313f6757ef (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 6730
diff changeset
   208
					sel = i;
cc313f6757ef (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 6730
diff changeset
   209
					break;
cc313f6757ef (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 6730
diff changeset
   210
				}
cc313f6757ef (svn r10036) -Add: sort the strings in town names dropdown
glx
parents: 6730
diff changeset
   211
			}
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   212
			ShowDropDownMenu(w, _town_names, sel, GAMEOPT_TOWNNAME_BTN, (_game_mode == GM_MENU) ? 0 : (-1) ^ (1 << sel), 0);
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   213
		} break;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   214
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   215
		case GAMEOPT_AUTOSAVE_TXT: case GAMEOPT_AUTOSAVE_BTN: /* Setup autosave dropdown */
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   216
			ShowDropDownMenu(w, _autosave_dropdown, _opt_ptr->autosave, GAMEOPT_AUTOSAVE_BTN, 0, 0);
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   217
			break;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   218
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   219
		case GAMEOPT_VEHICLENAME_TXT: case GAMEOPT_VEHICLENAME_BTN: /* Setup customized vehicle-names dropdown */
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   220
			ShowDropDownMenu(w, _designnames_dropdown, (_vehicle_design_names & 1) ? 1 : 0, GAMEOPT_VEHICLENAME_BTN, (_vehicle_design_names & 2) ? 0 : 2, 0);
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   221
			break;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   222
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   223
		case GAMEOPT_VEHICLENAME_SAVE: /* Save customized vehicle-names to disk */
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   224
			break;  // not implemented
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   225
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   226
		case GAMEOPT_LANG_TXT: case GAMEOPT_LANG_BTN: /* Setup interface language dropdown */
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   227
			ShowDropDownMenu(w, _dynlang.dropdown, _dynlang.curr, GAMEOPT_LANG_BTN, 0, 0);
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   228
			break;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   229
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   230
		case GAMEOPT_RESOLUTION_TXT: case GAMEOPT_RESOLUTION_BTN: /* Setup resolution dropdown */
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   231
			ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), GAMEOPT_RESOLUTION_BTN, 0, 0);
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   232
			break;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   233
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   234
		case GAMEOPT_FULLSCREEN: /* Click fullscreen on/off */
8171
3fb9d1f8ac3b (svn r11734) -Change: Allow ToggleFullScreen to return the result of the operation' attempt. Previously, only visual clues were available.
belugas
parents: 8144
diff changeset
   235
			/* try to toggle full-screen on/off */
3fb9d1f8ac3b (svn r11734) -Change: Allow ToggleFullScreen to return the result of the operation' attempt. Previously, only visual clues were available.
belugas
parents: 8144
diff changeset
   236
			if (!ToggleFullScreen(!_fullscreen)) {
3fb9d1f8ac3b (svn r11734) -Change: Allow ToggleFullScreen to return the result of the operation' attempt. Previously, only visual clues were available.
belugas
parents: 8144
diff changeset
   237
				ShowErrorMessage(INVALID_STRING_ID, STR_FULLSCREEN_FAILED, 0, 0);
3fb9d1f8ac3b (svn r11734) -Change: Allow ToggleFullScreen to return the result of the operation' attempt. Previously, only visual clues were available.
belugas
parents: 8144
diff changeset
   238
			}
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   239
			w->SetWidgetLoweredState(GAMEOPT_FULLSCREEN, _fullscreen);
298
0123c0489940 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   240
			SetWindowDirty(w);
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   241
			break;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   242
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   243
		case GAMEOPT_SCREENSHOT_TXT: case GAMEOPT_SCREENSHOT_BTN: /* Setup screenshot format dropdown */
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   244
			ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, GAMEOPT_SCREENSHOT_BTN, 0, 0);
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   245
			break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   246
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   247
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   248
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   249
	case WE_DROPDOWN_SELECT:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   250
		switch (e->we.dropdown.button) {
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   251
		case GAMEOPT_VEHICLENAME_BTN: /* Vehicle design names */
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   252
			if (e->we.dropdown.index == 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   253
				DeleteCustomEngineNames();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
				MarkWholeScreenDirty();
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   255
			} else if (!(_vehicle_design_names & 1)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   256
				LoadCustomEngineNames();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   257
				MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   258
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   259
			break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   260
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   261
		case GAMEOPT_CURRENCY_BTN: /* Currency */
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   262
			if (e->we.dropdown.index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   263
			_opt_ptr->currency = e->we.dropdown.index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
			MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
			break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   266
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   267
		case GAMEOPT_DISTANCE_BTN: /* Measuring units */
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   268
			_opt_ptr->units = e->we.dropdown.index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
			MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   270
			break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   271
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   272
		case GAMEOPT_ROADSIDE_BTN: /* Road side */
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   273
			if (_opt_ptr->road_side != e->we.dropdown.index) { // only change if setting changed
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   274
				DoCommandP(0, e->we.dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
1113
da5c5c571541 (svn r1614) Fix: Signals were not updated correctly when the vehicle drive side was changed
dominik
parents: 1095
diff changeset
   275
				MarkWholeScreenDirty();
da5c5c571541 (svn r1614) Fix: Signals were not updated correctly when the vehicle drive side was changed
dominik
parents: 1095
diff changeset
   276
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
			break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   278
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   279
		case GAMEOPT_TOWNNAME_BTN: /* Town names */
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   280
			if (_game_mode == GM_MENU) {
6956
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   281
				for (uint i = 0; _town_names[i] != INVALID_STRING_ID; i++) {
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   282
					if (_town_names[e->we.dropdown.index] == TownName(i)) {
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   283
						_opt_ptr->town_name = i;
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   284
						break;
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   285
					}
3579bfc5157b (svn r10211) -Feature: [NewGRF] Add support for action 0F
glx
parents: 6950
diff changeset
   286
				}
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   287
				InvalidateWindow(WC_GAME_OPTIONS, 0);
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   288
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
			break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   290
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   291
		case GAMEOPT_AUTOSAVE_BTN: /* Autosave options */
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   292
			_opt.autosave = _opt_newgame.autosave = e->we.dropdown.index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
			break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   295
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   296
		case GAMEOPT_LANG_BTN: /* Change interface language */
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   297
			ReadLanguagePack(e->we.dropdown.index);
8085
5b58f6315fb8 (svn r11646) -Codechange: check whether (some) characters are missing in the current 'font' for the 'currently' chosen language and give a warning when that does happen.
rubidium
parents: 8082
diff changeset
   298
			CheckForMissingGlyphsInLoadedLanguagePack();
6545
c2813603c9d8 (svn r9741) -Fix [FS#672]: station signs were not resized when the language changed, causing overflows in the coloured sign background.
rubidium
parents: 6543
diff changeset
   299
			UpdateAllStationVirtCoord();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
			MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
			break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   302
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   303
		case GAMEOPT_RESOLUTION_BTN: /* Change resolution */
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   304
			if (e->we.dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->we.dropdown.index][0],_resolutions[e->we.dropdown.index][1]))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
				SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
			break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   307
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   308
		case GAMEOPT_SCREENSHOT_BTN: /* Change screenshot format */
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   309
			SetScreenshotFormat(e->we.dropdown.index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   310
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   313
		break;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   314
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   315
	case WE_DESTROY:
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   316
		DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   317
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   318
	}
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   319
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   320
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   321
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   322
/** Change the side of the road vehicles drive on (server only).
3491
35d747bb5e82 (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
   323
 * @param tile unused
6483
ae78fc3c6b20 (svn r9664) -Documentation: Doxygen corrections,errors and omissions
belugas
parents: 6472
diff changeset
   324
 * @param flags operation to perform
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   325
 * @param p1 the side of the road; 0 = left side and 1 = right side
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   326
 * @param p2 unused
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   327
 */
6943
1914f26aee04 (svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents: 6798
diff changeset
   328
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
   329
{
1803
8fd9dca6d2c6 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents: 1796
diff changeset
   330
	/* Check boundaries and you can only change this if NO vehicles have been built yet,
8fd9dca6d2c6 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents: 1796
diff changeset
   331
	 * except in the intro-menu where of course it's always possible to do so. */
8fd9dca6d2c6 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents: 1796
diff changeset
   332
	if (p1 > 1 || (_game_mode != GM_MENU && RoadVehiclesAreBuilt())) return CMD_ERROR;
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   333
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   334
	if (flags & DC_EXEC) {
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   335
		_opt_ptr->road_side = p1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   336
		InvalidateWindow(WC_GAME_OPTIONS,0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   337
	}
6950
14ecb0acdfb4 (svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents: 6943
diff changeset
   338
	return CommandCost();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   339
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   340
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   341
static const Widget _game_options_widgets[] = {
4344
7e123fec5b0b (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
   342
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
7e123fec5b0b (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
   343
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   369,     0,    13, STR_00B1_GAME_OPTIONS,             STR_018C_WINDOW_TITLE_DRAG_THIS},
7e123fec5b0b (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
   344
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   369,    14,   238, 0x0,                               STR_NULL},
7e123fec5b0b (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
   345
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,    20,    55, STR_02E0_CURRENCY_UNITS,           STR_NULL},
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   346
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,    34,    45, STR_02E1,                          STR_02E2_CURRENCY_UNITS_SELECTION},
4344
7e123fec5b0b (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
   347
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,    35,    44, STR_0225,                          STR_02E2_CURRENCY_UNITS_SELECTION},
7e123fec5b0b (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
   348
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,    20,    55, STR_MEASURING_UNITS,               STR_NULL},
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   349
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,    34,    45, STR_02E4,                          STR_MEASURING_UNITS_SELECTION},
4344
7e123fec5b0b (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
   350
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   338,   348,    35,    44, STR_0225,                          STR_MEASURING_UNITS_SELECTION},
7e123fec5b0b (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
   351
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,    62,    97, STR_02E6_ROAD_VEHICLES,            STR_NULL},
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   352
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,    76,    87, STR_02E7,                          STR_02E8_SELECT_SIDE_OF_ROAD_FOR},
4344
7e123fec5b0b (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
   353
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,    77,    86, STR_0225,                          STR_02E8_SELECT_SIDE_OF_ROAD_FOR},
7e123fec5b0b (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
   354
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,    62,    97, STR_02EB_TOWN_NAMES,               STR_NULL},
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   355
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,    76,    87, STR_02EC,                          STR_02ED_SELECT_STYLE_OF_TOWN_NAMES},
4344
7e123fec5b0b (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
   356
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   338,   348,    77,    86, STR_0225,                          STR_02ED_SELECT_STYLE_OF_TOWN_NAMES},
7e123fec5b0b (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
   357
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,   104,   139, STR_02F4_AUTOSAVE,                 STR_NULL},
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   358
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,   118,   129, STR_02F5,                          STR_02F6_SELECT_INTERVAL_BETWEEN},
4344
7e123fec5b0b (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_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
   360
4344
7e123fec5b0b (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_FRAME,   RESIZE_NONE,    14,    10,   359,   194,   228, STR_02BC_VEHICLE_DESIGN_NAMES,     STR_NULL},
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   362
{      WWT_INSET,   RESIZE_NONE,    14,    20,   119,   207,   218, STR_02BD,                          STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
4344
7e123fec5b0b (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
   363
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   108,   118,   208,   217, STR_0225,                          STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
7e123fec5b0b (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,   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
   365
4344
7e123fec5b0b (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
   366
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,   104,   139, STR_OPTIONS_LANG,                  STR_NULL},
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   367
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,   118,   129, STR_OPTIONS_LANG_CBO,              STR_OPTIONS_LANG_TIP},
4344
7e123fec5b0b (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_TEXTBTN,   RESIZE_NONE,    14,   338,   348,   119,   128, STR_0225,                          STR_OPTIONS_LANG_TIP},
298
0123c0489940 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   369
4344
7e123fec5b0b (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_FRAME,   RESIZE_NONE,    14,    10,   179,   146,   190, STR_OPTIONS_RES,                   STR_NULL},
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   371
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,   160,   171, STR_OPTIONS_RES_CBO,               STR_OPTIONS_RES_TIP},
4344
7e123fec5b0b (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
   372
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,   161,   170, STR_0225,                          STR_OPTIONS_RES_TIP},
7e123fec5b0b (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,   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
   374
4344
7e123fec5b0b (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
   375
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,   146,   190, STR_OPTIONS_SCREENSHOT_FORMAT,     STR_NULL},
4939
bef7c24a6027 (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   376
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,   160,   171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO, STR_OPTIONS_SCREENSHOT_FORMAT_TIP},
4344
7e123fec5b0b (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
   377
{    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
   378
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 164
diff changeset
   379
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   382
static const WindowDesc _game_options_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7177
diff changeset
   383
	WDP_CENTER, WDP_CENTER, 370, 239, 370, 239,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5688
diff changeset
   384
	WC_GAME_OPTIONS, WC_NONE,
2064
e6a2b42d0b15 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   385
	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
   386
	_game_options_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
	GameOptionsWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   388
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   389
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   390
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6012
diff changeset
   391
void ShowGameOptions()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   392
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   393
	DeleteWindowById(WC_GAME_OPTIONS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   394
	AllocateWindowDesc(&_game_options_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   397
struct GameSettingData {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
	int16 min;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
	int16 max;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   400
	int16 step;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
	StringID str;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   402
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
static const GameSettingData _game_setting_info[] = {
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   405
	{  0,   7,  1, STR_NULL},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   406
	{  0,   3,  1, STR_6830_IMMEDIATE},
6560
24106d85dcf5 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 6545
diff changeset
   407
	{  0,   3,  1, STR_NUM_VERY_LOW},
24106d85dcf5 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 6545
diff changeset
   408
	{  0,   4,  1, STR_26816_NONE},
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   409
	{100, 500, 50, STR_NULL},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   410
	{  2,   4,  1, STR_NULL},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   411
	{  0,   2,  1, STR_6820_LOW},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   412
	{  0,   4,  1, STR_681B_VERY_SLOW},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   413
	{  0,   2,  1, STR_6820_LOW},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   414
	{  0,   2,  1, STR_6823_NONE},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   415
	{  0,   3,  1, STR_6826_X1_5},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   416
	{  0,   2,  1, STR_6820_LOW},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   417
	{  0,   3,  1, STR_682A_VERY_FLAT},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   418
	{  0,   3,  1, STR_VERY_LOW},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   419
	{  0,   1,  1, STR_682E_STEADY},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   420
	{  0,   1,  1, STR_6834_AT_END_OF_LINE_AND_AT_STATIONS},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   421
	{  0,   1,  1, STR_6836_OFF},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   422
	{  0,   2,  1, STR_6839_PERMISSIVE},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
1385
91d75432f81e (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
   425
/*
4549
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   426
 * A: competitors
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   427
 * B: start time in months / 3
6560
24106d85dcf5 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 6545
diff changeset
   428
 * C: town count (2 = high, 0 = very low)
24106d85dcf5 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 6545
diff changeset
   429
 * D: industry count (4 = high, 0 = none)
4549
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   430
 * E: inital loan / 1000 (in GBP)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   431
 * F: interest rate
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   432
 * G: running costs (0 = low, 2 = high)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   433
 * H: construction speed of competitors (0 = very slow, 4 = very fast)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   434
 * I: intelligence (0-2)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   435
 * J: breakdowns (0 = off, 2 = normal)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   436
 * K: subsidy multiplier (0 = 1.5, 3 = 4.0)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   437
 * L: construction cost (0-2)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   438
 * M: terrain type (0 = very flat, 3 = mountainous)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   439
 * N: amount of water (0 = very low, 3 = high)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   440
 * O: economy (0 = steady, 1 = fluctuating)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   441
 * P: Train reversing (0 = end of line + stations, 1 = end of line)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   442
 * Q: disasters
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   443
 * R: area restructuring (0 = permissive, 2 = hostile)
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   444
 */
7742
ddea89a86f80 (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: 7657
diff changeset
   445
static const GDType _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /*
1385
91d75432f81e (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
   446
	 A, B, C, D,   E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/
6560
24106d85dcf5 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 6545
diff changeset
   447
	{2, 2, 1, 4, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, ///< easy
24106d85dcf5 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 6545
diff changeset
   448
	{4, 1, 1, 3, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, ///< medium
24106d85dcf5 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 6545
diff changeset
   449
	{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
   450
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
void SetDifficultyLevel(int mode, GameOptions *gm_opt)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   455
	assert(mode <= 3);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   456
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
	gm_opt->diff_level = mode;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
	if (mode != 3) { // not custom
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   459
		for (i = 0; i != GAME_DIFFICULTY_NUM; i++)
7742
ddea89a86f80 (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: 7657
diff changeset
   460
			((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
   461
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
6378
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   464
/**
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   465
 * Checks the difficulty levels read from the configuration and
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   466
 * forces them to be correct when invalid.
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   467
 */
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   468
void CheckDifficultyLevels()
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   469
{
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   470
	if (_opt_newgame.diff_level != 3) {
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   471
		SetDifficultyLevel(_opt_newgame.diff_level, &_opt_newgame);
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   472
	} else {
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   473
		for (uint i = 0; i < GAME_DIFFICULTY_NUM; i++) {
7742
ddea89a86f80 (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: 7657
diff changeset
   474
			GDType *diff = ((GDType*)&_opt_newgame.diff) + i;
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7901
diff changeset
   475
			*diff = Clamp(*diff, _game_setting_info[i].min, _game_setting_info[i].max);
6378
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   476
			*diff -= *diff % _game_setting_info[i].step;
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   477
		}
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   478
	}
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   479
}
817e6cb0b95b (svn r9455) -Fix: the values for diff_custom, diff_level and snow_line in the .cfg were not properly checked.
rubidium
parents: 6296
diff changeset
   480
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6012
diff changeset
   481
extern void StartupEconomy();
46
c9bdf1d58df6 (svn r47) -Fix StartupEconomy warning in settings_gui.c
darkvater
parents: 42
diff changeset
   482
983
4765bf636f6b (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
   483
enum {
4765bf636f6b (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
   484
	GAMEDIFF_WND_TOP_OFFSET = 45,
4765bf636f6b (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
   485
	GAMEDIFF_WND_ROWSIZE    = 9
4765bf636f6b (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
   486
};
4765bf636f6b (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
   487
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6378
diff changeset
   488
/* Temporary holding place of values in the difficulty window until 'Save' is clicked */
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   489
static GameOptions _opt_mod_temp;
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   490
// 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   491
#define DIFF_INGAME_DISABLED_BUTTONS 0x383E
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   492
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   493
/* Names of the game difficulty settings window */
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   494
enum GameDifficultyWidgets {
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   495
	GDW_CLOSEBOX = 0,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   496
	GDW_CAPTION,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   497
	GDW_UPPER_BG,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   498
	GDW_LVL_EASY,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   499
	GDW_LVL_MEDIUM,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   500
	GDW_LVL_HARD,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   501
	GDW_LVL_CUSTOM,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   502
	GDW_HIGHSCORE,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   503
	GDW_SETTING_BG,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   504
	GDW_LOWER_BG,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   505
	GDW_ACCEPT,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   506
	GDW_CANCEL,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   507
};
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   508
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   509
static void GameDifficultyWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
{
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   511
	switch (e->event) {
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   512
	case WE_CREATE:
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   513
		/* Hide the closebox to make sure that the user aborts or confirms his changes */
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   514
		w->HideWidget(GDW_CLOSEBOX);
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   515
		w->widget[GDW_CAPTION].left = 0;
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   516
		/* Setup disabled buttons when creating window
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   517
		 * disable all other difficulty buttons during gameplay except for 'custom' */
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   518
		w->SetWidgetsDisabledState(_game_mode == GM_NORMAL,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   519
			GDW_LVL_EASY,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   520
			GDW_LVL_MEDIUM,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   521
			GDW_LVL_HARD,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   522
			GDW_LVL_CUSTOM,
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   523
			WIDGET_LIST_END);
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   524
		w->SetWidgetDisabledState(GDW_HIGHSCORE, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   525
		w->SetWidgetDisabledState(GDW_ACCEPT, _networking && !_network_server); // Save-button in multiplayer (and if client)
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   526
		w->LowerWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   527
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   528
		break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   529
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   530
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   531
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   532
8182
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   533
		/* XXX - Disabled buttons in normal gameplay or during muliplayer as non server.
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   534
		 *       Bitshifted for each button to see if that bit is set. If it is set, the
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   535
		 *       button is disabled */
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   536
		uint32 disabled = 0;
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   537
		if (_networking && !_network_server) {
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   538
			disabled = MAX_UVALUE(uint32); // Disable all
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   539
		} else if (_game_mode == GM_NORMAL) {
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   540
			disabled = DIFF_INGAME_DISABLED_BUTTONS;
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   541
		}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   543
		int value;
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   544
		int y = GAMEDIFF_WND_TOP_OFFSET;
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   545
		for (uint i = 0; i != GAME_DIFFICULTY_NUM; i++) {
8182
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   546
			const GameSettingData *gsd = &_game_setting_info[i];
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   547
			value = ((GDType*)&_opt_mod_temp.diff)[i];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
8189
3ec02608168d (svn r11752) -Fix(r11745): Silence a MSVC warning (glx)
belugas
parents: 8188
diff changeset
   549
			DrawArrowButtons(5, y, 3,
3ec02608168d (svn r11752) -Fix(r11745): Silence a MSVC warning (glx)
belugas
parents: 8188
diff changeset
   550
					!!HasBit(_difficulty_click_a, i) | !!HasBit(_difficulty_click_b, i) << 1,
8182
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   551
					!(HasBit(disabled, i) || gsd->min == value),
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   552
					!(HasBit(disabled, i) || gsd->max == value));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   553
8182
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   554
			value += _game_setting_info[i].str;
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   555
			if (i == 4) value *= 1000; // XXX - handle currency option
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   556
			SetDParam(0, value);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
   557
			DrawString(30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
983
4765bf636f6b (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
   559
			y += GAMEDIFF_WND_ROWSIZE + 2; // space items apart a bit
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   560
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   562
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   563
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   564
		switch (e->we.click.widget) {
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   565
		case GDW_SETTING_BG: { /* Difficulty settings widget, decode click */
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   566
			/* Don't allow clients to make any changes */
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   567
			if  (_networking && !_network_server) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   568
8182
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   569
			const int x = e->we.click.pt.x - 5;
7954
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
   570
			if (!IsInsideMM(x, 0, 21)) // Button area
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   571
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   572
8182
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   573
			const int y = e->we.click.pt.y - GAMEDIFF_WND_TOP_OFFSET;
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   574
			if (y < 0) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   575
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6378
diff changeset
   576
			/* Get button from Y coord. */
8182
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   577
			const uint btn = y / (GAMEDIFF_WND_ROWSIZE + 2);
983
4765bf636f6b (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
   578
			if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   579
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   580
6420
456c275f3313 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents: 6378
diff changeset
   581
			/* Clicked disabled button? */
8182
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   582
			if (_game_mode == GM_NORMAL && HasBit(DIFF_INGAME_DISABLED_BUTTONS, btn))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   583
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   584
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   585
			_difficulty_timeout = 5;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   586
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   587
			int16 val = ((GDType*)&_opt_mod_temp.diff)[btn];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   588
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   589
			const GameSettingData *info = &_game_setting_info[btn]; // get information about the difficulty setting
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   590
			if (x >= 10) {
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   591
				/* Increase button clicked */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   592
				val = min(val + info->step, info->max);
7931
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7928
diff changeset
   593
				SetBit(_difficulty_click_b, btn);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   594
			} else {
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   595
				/* Decrease button clicked */
5601
d58f82901b2f (svn r8055) -Codechange: Replace the different max, dmax, maxu whatever macros by a simple template function max(), that requires two arguments of the same type. While I'm at it change a variable called "max" to "maxval" in a function that calls max().
celestar
parents: 5587
diff changeset
   596
				val -= info->step;
d58f82901b2f (svn r8055) -Codechange: Replace the different max, dmax, maxu whatever macros by a simple template function max(), that requires two arguments of the same type. While I'm at it change a variable called "max" to "maxval" in a function that calls max().
celestar
parents: 5587
diff changeset
   597
				val = max(val,  info->min);
7931
b0a46cd92225 (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents: 7928
diff changeset
   598
				SetBit(_difficulty_click_a, btn);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   599
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   600
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   601
			/* save value in temporary variable */
7742
ddea89a86f80 (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: 7657
diff changeset
   602
			((GDType*)&_opt_mod_temp.diff)[btn] = val;
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   603
			w->RaiseWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   604
			SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom
8182
e5edf1b01be8 (svn r11745) -Codechange: Unify the spinner widget drawing of the difficulty settings window and make its disabled state min max aware.
skidd13
parents: 8171
diff changeset
   605
			w->LowerWidget(GDW_LVL_CUSTOM);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   606
			SetWindowDirty(w);
6492
286a52449b54 (svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents: 6486
diff changeset
   607
		} break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   608
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   609
		case GDW_LVL_EASY:
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   610
		case GDW_LVL_MEDIUM:
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   611
		case GDW_LVL_HARD:
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   612
		case GDW_LVL_CUSTOM:
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   613
			/* temporarily change difficulty level */
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   614
			w->RaiseWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   615
			SetDifficultyLevel(e->we.click.widget - GDW_LVL_EASY, &_opt_mod_temp);
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   616
			w->LowerWidget(GDW_LVL_EASY + _opt_mod_temp.diff_level);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   617
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   618
			break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   619
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   620
		case GDW_HIGHSCORE: // Highscore Table
983
4765bf636f6b (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
   621
			ShowHighscoreTable(_opt_mod_temp.diff_level, -1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   622
			break;
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   623
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   624
		case GDW_ACCEPT: { // Save button - save changes
7742
ddea89a86f80 (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: 7657
diff changeset
   625
			GDType btn, val;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   626
			for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) {
7742
ddea89a86f80 (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: 7657
diff changeset
   627
				val = ((GDType*)&_opt_mod_temp.diff)[btn];
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   628
				/* if setting has changed, change it */
7742
ddea89a86f80 (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: 7657
diff changeset
   629
				if (val != ((GDType*)&_opt_ptr->diff)[btn])
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   630
					DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   631
			}
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   632
			DoCommandP(0, UINT_MAX, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   633
			DeleteWindow(w);
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   634
			/* If we are in the editor, we should reload the economy.
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   635
			 * This way when you load a game, the max loan and interest rate
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   636
			 * are loaded correctly. */
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   637
			if (_game_mode == GM_EDITOR) StartupEconomy();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   638
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   639
		}
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   640
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   641
		case GDW_CANCEL: // Cancel button - close window, abandon changes
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   642
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   643
			break;
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   644
	} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   645
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   646
	case WE_MOUSELOOP: /* Handle the visual 'clicking' of the buttons */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   647
		if (_difficulty_timeout != 0 && !--_difficulty_timeout) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   648
			_difficulty_click_a = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   649
			_difficulty_click_b = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   650
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   651
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   652
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   653
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   654
}
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   655
#undef DIFF_INGAME_DISABLED_BUTTONS
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   656
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   657
/* Widget definition for the game difficulty settings window */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
static const Widget _game_difficulty_widgets[] = {
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   659
{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},           // GDW_CLOSEBOX
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   660
{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_6800_DIFFICULTY_LEVEL,    STR_018C_WINDOW_TITLE_DRAG_THIS}, // GDW_CAPTION
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   661
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                          STR_NULL},                        // GDW_UPPER_BG
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   662
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_6801_EASY,                STR_NULL},                        // GDW_LVL_EASY
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   663
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_6802_MEDIUM,              STR_NULL},                        // GDW_LVL_MEDIUM
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   664
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_6803_HARD,                STR_NULL},                        // GDW_LVL_HARD
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   665
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_6804_CUSTOM,              STR_NULL},                        // GDW_LVL_CUSTOM
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   666
{    WWT_TEXTBTN,   RESIZE_NONE,     6,    10,   357,    28,    39, STR_6838_SHOW_HI_SCORE_CHART, STR_NULL},                        // GDW_HIGHSCORE
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   667
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   262, 0x0,                          STR_NULL},                        // GDW_SETTING_BG
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   668
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,   263,   278, 0x0,                          STR_NULL},                        // GDW_LOWER_BG
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   669
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   105,   185,   265,   276, STR_OPTIONS_SAVE_CHANGES,     STR_NULL},                        // GDW_ACCEPT
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   670
{ 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
   671
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   672
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   673
8136
53c188f8aa27 (svn r11698) -Change: Make the abort/accept process of the difficulty window a bit less confusing
skidd13
parents: 8131
diff changeset
   674
/* Window definition for the game difficulty settings window */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   675
static const WindowDesc _game_difficulty_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7177
diff changeset
   676
	WDP_CENTER, WDP_CENTER, 370, 279, 370, 279,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5688
diff changeset
   677
	WC_GAME_OPTIONS, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   678
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   679
	_game_difficulty_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   680
	GameDifficultyWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   681
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6012
diff changeset
   683
void ShowGameDifficulty()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   684
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   685
	DeleteWindowById(WC_GAME_OPTIONS, 0);
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   686
	/* Copy current settings (ingame or in intro) to temporary holding place
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   687
	 * change that when setting stuff, copy back on clicking 'OK' */
5024
5e98bf731469 (svn r7065) Use simple assignment instead of memcpy()
tron
parents: 4939
diff changeset
   688
	_opt_mod_temp = *_opt_ptr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   689
	AllocateWindowDesc(&_game_difficulty_desc);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   690
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   691
3247
ede7a53941b2 (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
   692
static const char *_patches_ui[] = {
ede7a53941b2 (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
   693
	"vehicle_speed",
ede7a53941b2 (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
   694
	"status_long_date",
ede7a53941b2 (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
   695
	"show_finances",
ede7a53941b2 (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
   696
	"autoscroll",
ede7a53941b2 (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
   697
	"reverse_scroll",
6730
9311a208f8f7 (svn r9962) -Feature: Add smooth viewport scrolling. This must be enabled with patch setting 'smooth_scroll'
peter1138
parents: 6674
diff changeset
   698
	"smooth_scroll",
3247
ede7a53941b2 (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
   699
	"errmsg_duration",
ede7a53941b2 (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
   700
	"toolbar_pos",
4834
3c6e8a547174 (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4727
diff changeset
   701
	"measure_tooltip",
3247
ede7a53941b2 (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
   702
	"window_snap_radius",
ede7a53941b2 (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
   703
	"invisible_trees",
ede7a53941b2 (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
   704
	"population_in_label",
ede7a53941b2 (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
   705
	"link_terraform_toolbar",
4616
3c22e5eb5ffe (svn r6474) - Add a patch option to control display of liveries, allowing none, your
peter1138
parents: 4552
diff changeset
   706
	"liveries",
5107
f3cddd9ce5f4 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
   707
	"prefer_teamchat",
6289
9f468eccc674 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6259
diff changeset
   708
	/* While the horizontal scrollwheel scrolling is written as general code, only
9f468eccc674 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6259
diff changeset
   709
	 *  the cocoa (OSX) driver generates input for it.
6296
a6bed59002c6 (svn r9126) -Feature: "Function of scrollwheel" can now be set to off as well
bjarni
parents: 6293
diff changeset
   710
	 *  Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
6289
9f468eccc674 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6259
diff changeset
   711
	"scrollwheel_scrolling",
9f468eccc674 (svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
bjarni
parents: 6259
diff changeset
   712
	"scrollwheel_multiplier",
7485
d8799216928a (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7341
diff changeset
   713
#ifdef __APPLE__
d8799216928a (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7341
diff changeset
   714
	/* We might need to emulate a right mouse button on mac */
d8799216928a (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7341
diff changeset
   715
	"right_mouse_btn_emulation",
d8799216928a (svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
bjarni
parents: 7341
diff changeset
   716
#endif
6543
57dfb0d16b10 (svn r9734) -Feature: Add an option to automatically pause when starting a new game.
maedhros
parents: 6492
diff changeset
   717
	"pause_on_newgame",
6643
f81bee57bc09 (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: 6571
diff changeset
   718
	"advanced_vehicle_list",
6998
39e783d3816c (svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents: 6980
diff changeset
   719
	"loading_indicators",
6980
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6956
diff changeset
   720
	"timetable_in_ticks",
7064
81d35e1f3e37 (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: 6998
diff changeset
   721
	"default_rail_type",
7086
de7e83fb1602 (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: 7064
diff changeset
   722
	"always_build_infrastructure",
21
67cde01e8359 (svn r22) Add: Competitors menu under patches
truelight
parents: 20
diff changeset
   723
};
67cde01e8359 (svn r22) Add: Competitors menu under patches
truelight
parents: 20
diff changeset
   724
3247
ede7a53941b2 (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
   725
static const char *_patches_construction[] = {
ede7a53941b2 (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
   726
	"build_on_slopes",
7582
80c8517b08d1 (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: 7485
diff changeset
   727
	"autoslope",
3247
ede7a53941b2 (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
   728
	"extra_dynamite",
ede7a53941b2 (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
   729
	"longbridges",
ede7a53941b2 (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
   730
	"signal_side",
ede7a53941b2 (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
   731
	"always_small_airport",
7991
d6a95a5593ba (svn r11547) -Add: signal selection GUI for the ones that really like to use that over CTRL. Patch by BigBB.
rubidium
parents: 7954
diff changeset
   732
	"enable_signal_gui",
3247
ede7a53941b2 (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
   733
	"drag_signals_density",
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   734
	"oil_refinery_limit",
5688
c4ba40106d5d (svn r8151) -Feature: Automatically build semaphores before a configurable date, which can be set by each network player seperately.
maedhros
parents: 5668
diff changeset
   735
	"semaphore_build_before",
3247
ede7a53941b2 (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
   736
};
ede7a53941b2 (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
   737
ede7a53941b2 (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
   738
static const char *_patches_stations[] = {
ede7a53941b2 (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
   739
	"join_stations",
ede7a53941b2 (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
   740
	"full_load_any",
ede7a53941b2 (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
	"improved_load",
ede7a53941b2 (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
	"selectgoods",
ede7a53941b2 (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
   743
	"new_nonstop",
ede7a53941b2 (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
	"nonuniform_stations",
ede7a53941b2 (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
	"station_spread",
ede7a53941b2 (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
	"serviceathelipad",
ede7a53941b2 (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
	"modified_catchment",
5211
fb4dc0ca975d (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5163
diff changeset
   748
	"gradual_loading",
6012
065d7234a7a9 (svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents: 5893
diff changeset
   749
	"road_stop_on_town_road",
6674
5d77615aeaf2 (svn r9905) -Feature: Allow building new stations adjacent to existing stations by holding down control. Based on a patch by Wolf01.
maedhros
parents: 6643
diff changeset
   750
	"adjacent_stations",
3247
ede7a53941b2 (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
   751
};
ede7a53941b2 (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
ede7a53941b2 (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
static const char *_patches_economy[] = {
ede7a53941b2 (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
	"inflation",
7177
f9796d5be926 (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: 7086
diff changeset
   755
	"raw_industry_construction",
3247
ede7a53941b2 (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
	"multiple_industry_per_town",
ede7a53941b2 (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
	"same_industry_close",
ede7a53941b2 (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
	"bribe",
7657
2b55af55cc51 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents: 7641
diff changeset
   759
	"exclusive_rights",
2b55af55cc51 (svn r11188) -Codechange: rewrite of the town action related code (remove some of the magic).
rubidium
parents: 7641
diff changeset
   760
	"give_money",
4285
19cb745c694e (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
   761
	"colored_news_year",
19cb745c694e (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
   762
	"ending_year",
3247
ede7a53941b2 (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
	"smooth_economy",
ede7a53941b2 (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
   764
	"allow_shares",
7641
3a75903fd892 (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: 7582
diff changeset
   765
	"town_layout",
3a75903fd892 (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: 7582
diff changeset
   766
	"mod_road_rebuild",
6454
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6420
diff changeset
   767
	"town_growth_rate",
ad53226c2027 (svn r9613) -Feature: Make it possible to have some control over the town growth. The
maedhros
parents: 6420
diff changeset
   768
	"larger_towns",
6486
7d2ae0a167fb (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can
maedhros
parents: 6483
diff changeset
   769
	"initial_city_size",
3247
ede7a53941b2 (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
};
ede7a53941b2 (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
   771
ede7a53941b2 (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
static const char *_patches_ai[] = {
ede7a53941b2 (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
	"ainew_active",
ede7a53941b2 (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
	"ai_in_multiplayer",
ede7a53941b2 (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
   775
	"ai_disable_veh_train",
ede7a53941b2 (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
   776
	"ai_disable_veh_roadveh",
ede7a53941b2 (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
   777
	"ai_disable_veh_aircraft",
ede7a53941b2 (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
   778
	"ai_disable_veh_ship",
ede7a53941b2 (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
};
ede7a53941b2 (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
ede7a53941b2 (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
   781
static const char *_patches_vehicles[] = {
ede7a53941b2 (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
   782
	"realistic_acceleration",
ede7a53941b2 (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
   783
	"forbid_90_deg",
ede7a53941b2 (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
   784
	"mammoth_trains",
ede7a53941b2 (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
   785
	"gotodepot",
ede7a53941b2 (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
	"roadveh_queue",
ede7a53941b2 (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
	"new_pathfinding_all",
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3888
diff changeset
   788
	"yapf.ship_use_yapf",
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3888
diff changeset
   789
	"yapf.road_use_yapf",
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3888
diff changeset
   790
	"yapf.rail_use_yapf",
3247
ede7a53941b2 (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
	"train_income_warn",
ede7a53941b2 (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
	"order_review_system",
ede7a53941b2 (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
	"never_expire_vehicles",
4870
2d8c7ffbbac9 (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
   794
	"lost_train_warn",
3247
ede7a53941b2 (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
	"autorenew",
ede7a53941b2 (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
	"autorenew_months",
ede7a53941b2 (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
	"autorenew_money",
ede7a53941b2 (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
	"max_trains",
ede7a53941b2 (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
	"max_roadveh",
ede7a53941b2 (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
	"max_aircraft",
ede7a53941b2 (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
	"max_ships",
ede7a53941b2 (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
	"servint_ispercent",
ede7a53941b2 (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
	"servint_trains",
ede7a53941b2 (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
   804
	"servint_roadveh",
ede7a53941b2 (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
   805
	"servint_ships",
ede7a53941b2 (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
   806
	"servint_aircraft",
ede7a53941b2 (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
	"no_servicing_if_no_breakdowns",
ede7a53941b2 (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
	"wagon_speed_limits",
5116
3c0c3da214ca (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5113
diff changeset
   809
	"disable_elrails",
5163
459b243f8413 (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
   810
	"freight_trains",
6980
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6956
diff changeset
   811
	"timetabling",
3247
ede7a53941b2 (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
};
ede7a53941b2 (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
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   814
struct PatchEntry {
3247
ede7a53941b2 (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
	const SettingDesc *setting;
ede7a53941b2 (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
	uint index;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   817
};
3247
ede7a53941b2 (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
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   819
struct PatchPage {
3247
ede7a53941b2 (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
	const char **names;
ede7a53941b2 (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
	PatchEntry *entries;
3118
adc86793eee1 (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
   822
	byte num;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   823
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   824
3247
ede7a53941b2 (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
   825
/* PatchPage holds the categories, the number of elements in each category
ede7a53941b2 (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
   826
 * and (in NULL) a dynamic array of settings based on the string-representations
ede7a53941b2 (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
   827
 * of the settings. This way there is no worry about indeces, and such */
ede7a53941b2 (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
static PatchPage _patches_page[] = {
ede7a53941b2 (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
	{_patches_ui,           NULL, lengthof(_patches_ui)},
ede7a53941b2 (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
   830
	{_patches_construction, NULL, lengthof(_patches_construction)},
ede7a53941b2 (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
	{_patches_vehicles,     NULL, lengthof(_patches_vehicles)},
ede7a53941b2 (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
	{_patches_stations,     NULL, lengthof(_patches_stations)},
ede7a53941b2 (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
   833
	{_patches_economy,      NULL, lengthof(_patches_economy)},
ede7a53941b2 (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
	{_patches_ai,           NULL, lengthof(_patches_ai)},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   835
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   836
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   837
enum PatchesSelectionWidgets {
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   838
	PATCHSEL_OPTIONSPANEL = 3,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   839
	PATCHSEL_INTERFACE,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   840
	PATCHSEL_CONSTRUCTION,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   841
	PATCHSEL_VEHICLES,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   842
	PATCHSEL_STATIONS,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   843
	PATCHSEL_ECONOMY,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   844
	PATCHSEL_COMPETITORS
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   845
};
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   846
3118
adc86793eee1 (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
   847
/** The main patches window. Shows a number of categories on top and
adc86793eee1 (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
   848
 * a selection of patches in that category.
adc86793eee1 (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
   849
 * 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
   850
static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   851
{
3118
adc86793eee1 (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
   852
	static Patches *patches_ptr;
adc86793eee1 (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
   853
1741
628182f1bbd2 (svn r2245) - CodeChange: simplify the clamping of values for patch-settings by using clamp()
Darkvater
parents: 1739
diff changeset
   854
	switch (e->event) {
3206
00fef2d4d301 (svn r3874) - Codechange: move the extern decleration of _patches_newgame inside the WE_CREATE event because it is only used there.
Darkvater
parents: 3131
diff changeset
   855
	case WE_CREATE: {
3247
ede7a53941b2 (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
   856
		static bool first_time = true;
ede7a53941b2 (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
   857
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
   858
		patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
3247
ede7a53941b2 (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
   859
ede7a53941b2 (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
   860
		/* Build up the dynamic settings-array only once per OpenTTD session */
ede7a53941b2 (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
   861
		if (first_time) {
ede7a53941b2 (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
   862
			PatchPage *page;
ede7a53941b2 (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
   863
			for (page = &_patches_page[0]; page != endof(_patches_page); page++) {
ede7a53941b2 (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
   864
				uint i;
ede7a53941b2 (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
   865
5609
dc6a58930ba4 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents: 5601
diff changeset
   866
				page->entries = MallocT<PatchEntry>(page->num);
3247
ede7a53941b2 (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
   867
				for (i = 0; i != page->num; i++) {
ede7a53941b2 (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
   868
					uint index;
ede7a53941b2 (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
   869
					const SettingDesc *sd = GetPatchFromName(page->names[i], &index);
ede7a53941b2 (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
   870
					assert(sd != NULL);
ede7a53941b2 (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
   871
ede7a53941b2 (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
   872
					page->entries[i].setting = sd;
ede7a53941b2 (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
   873
					page->entries[i].index = index;
ede7a53941b2 (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
   874
				}
ede7a53941b2 (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
   875
			}
ede7a53941b2 (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
   876
			first_time = false;
ede7a53941b2 (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
   877
		}
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7991
diff changeset
   878
		w->LowerWidget(4);
3206
00fef2d4d301 (svn r3874) - Codechange: move the extern decleration of _patches_newgame inside the WE_CREATE event because it is only used there.
Darkvater
parents: 3131
diff changeset
   879
	} break;
3118
adc86793eee1 (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
   880
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   881
	case WE_PAINT: {
3118
adc86793eee1 (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
   882
		int x, y;
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
   883
		const PatchPage *page = &_patches_page[WP(w, def_d).data_1];
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   884
		uint i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   885
3118
adc86793eee1 (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
   886
		/* Set up selected category */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   887
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   888
3118
adc86793eee1 (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
   889
		x = 5;
adc86793eee1 (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
   890
		y = 47;
3247
ede7a53941b2 (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
   891
		for (i = 0; i != page->num; i++) {
ede7a53941b2 (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
   892
			const SettingDesc *sd = page->entries[i].setting;
3118
adc86793eee1 (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
   893
			const SettingDescBase *sdb = &sd->desc;
5141
63e24cb6f071 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
   894
			const void *var = GetVariableAddress(patches_ptr, &sd->save);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   895
			bool editable = true;
3118
adc86793eee1 (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
			bool disabled = false;
998
c90459c24842 (svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents: 983
diff changeset
   897
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   898
			// We do not allow changes of some items when we are a client in a networkgame
3118
adc86793eee1 (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
   899
			if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false;
adc86793eee1 (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
   900
			if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false;
7901
6e8ab6c5473d (svn r11452) -Change: do not allow configuration changes, that NewGRFs can directly use to change their behaviour, during network games as this can cause desyncs.
rubidium
parents: 7824
diff changeset
   901
			if ((sdb->flags & SGF_NO_NETWORK) && _networking) editable = false;
3118
adc86793eee1 (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
   902
adc86793eee1 (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
   903
			if (sdb->cmd == SDT_BOOLX) {
3124
cf624337b649 (svn r3732) - Fix two warnings. Stupid MSVC didn't even complain :s (Thank Tron and peter1138)
Darkvater
parents: 3121
diff changeset
   904
				static const int _bool_ctabs[2][2] = {{9, 4}, {7, 6}};
3118
adc86793eee1 (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
   905
				/* Draw checkbox for boolean-value either on/off */
adc86793eee1 (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
   906
				bool on = (*(bool*)var);
adc86793eee1 (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
   907
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   908
				DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : FR_NONE);
3118
adc86793eee1 (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
   909
				SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   910
			} else {
3118
adc86793eee1 (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
   911
				int32 value;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   912
4211
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   913
				value = (int32)ReadValue(var, sd->save.conv);
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   914
3118
adc86793eee1 (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
   915
				/* Draw [<][>] boxes for settings of an integer-type */
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
   916
				DrawArrowButtons(x, y, 3, WP(w, def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
3118
adc86793eee1 (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
   917
adc86793eee1 (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
   918
				disabled = (value == 0) && (sdb->flags & SGF_0ISDISABLED);
11
836bc4b37b5b (svn r12) Change: removed patch no_train_service. Instead you can set the default service interval for any vehicle type to 'disabled'.
dominik
parents: 0
diff changeset
   919
				if (disabled) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   920
					SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   921
				} else {
3118
adc86793eee1 (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
   922
					if (sdb->flags & SGF_CURRENCY) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   923
						SetDParam(0, STR_CONFIG_PATCHES_CURRENCY);
3118
adc86793eee1 (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
   924
					} else if (sdb->flags & SGF_MULTISTRING) {
adc86793eee1 (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
   925
						SetDParam(0, sdb->str + value + 1);
adc86793eee1 (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
   926
					} else {
adc86793eee1 (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
   927
						SetDParam(0, (sdb->flags & SGF_NOCOMMA) ? STR_CONFIG_PATCHES_INT32 : STR_7024);
53
1e32a44e2e52 (svn r54) -Add: PF_MULTISTRING in Patch menu to select between things instead of numbers (Celestar)
truelight
parents: 48
diff changeset
   928
					}
3118
adc86793eee1 (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
   929
					SetDParam(1, value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   930
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   931
			}
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
   932
			DrawString(30, y, (sdb->str) + disabled, TC_FROMSTRING);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   933
			y += 11;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   934
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   935
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   936
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   937
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   938
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   939
		switch (e->we.click.widget) {
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
   940
		case PATCHSEL_OPTIONSPANEL: {
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
   941
			const PatchPage *page = &_patches_page[WP(w, def_d).data_1];
3118
adc86793eee1 (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
   942
			const SettingDesc *sd;
adc86793eee1 (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
   943
			void *var;
adc86793eee1 (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
   944
			int32 value;
adc86793eee1 (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
   945
			int x, y;
adc86793eee1 (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
   946
			byte btn;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   947
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   948
			y = e->we.click.pt.y - 46 - 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   949
			if (y < 0) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   950
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   951
			x = e->we.click.pt.x - 5;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   952
			if (x < 0) return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   953
3118
adc86793eee1 (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
   954
			btn = y / 11;
adc86793eee1 (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
   955
			if (y % 11 > 9) return;
adc86793eee1 (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
   956
			if (btn >= page->num) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   957
3247
ede7a53941b2 (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
   958
			sd = page->entries[btn].setting;
3118
adc86793eee1 (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
   959
adc86793eee1 (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
   960
			/* return if action is only active in network, or only settable by server */
7901
6e8ab6c5473d (svn r11452) -Change: do not allow configuration changes, that NewGRFs can directly use to change their behaviour, during network games as this can cause desyncs.
rubidium
parents: 7824
diff changeset
   961
			if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return;
3118
adc86793eee1 (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
   962
			if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return;
7901
6e8ab6c5473d (svn r11452) -Change: do not allow configuration changes, that NewGRFs can directly use to change their behaviour, during network games as this can cause desyncs.
rubidium
parents: 7824
diff changeset
   963
			if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return;
3118
adc86793eee1 (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
   964
5141
63e24cb6f071 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
   965
			var = GetVariableAddress(patches_ptr, &sd->save);
3118
adc86793eee1 (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
   966
			value = (int32)ReadValue(var, sd->save.conv);
adc86793eee1 (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
   967
adc86793eee1 (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
   968
			/* clicked on the icon on the left side. Either scroller or bool on/off */
adc86793eee1 (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
   969
			if (x < 21) {
adc86793eee1 (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
   970
				const SettingDescBase *sdb = &sd->desc;
adc86793eee1 (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
   971
				int32 oldvalue = value;
adc86793eee1 (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
   972
adc86793eee1 (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
   973
				switch (sdb->cmd) {
adc86793eee1 (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
   974
				case SDT_BOOLX: value ^= 1; break;
adc86793eee1 (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
   975
				case SDT_NUMX: {
adc86793eee1 (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
   976
					/* Add a dynamic step-size to the scroller. In a maximum of
4431
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4377
diff changeset
   977
					 * 50-steps you should be able to get from min to max,
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4377
diff changeset
   978
					 * unless specified otherwise in the 'interval' variable
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4377
diff changeset
   979
					 * of the current patch. */
7ecf73508c31 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4377
diff changeset
   980
					uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
3118
adc86793eee1 (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
   981
					if (step == 0) step = 1;
adc86793eee1 (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
   982
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   983
					// don't allow too fast scrolling
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   984
					if ((w->flags4 & WF_TIMEOUT_MASK) > 2 << WF_TIMEOUT_SHL) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   985
						_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   986
						return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   987
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   988
3118
adc86793eee1 (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
   989
					/* Increase or decrease the value and clamp it to extremes */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   990
					if (x >= 10) {
3118
adc86793eee1 (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
   991
						value += step;
adc86793eee1 (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
   992
						if (value > sdb->max) value = sdb->max;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   993
					} else {
3118
adc86793eee1 (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
   994
						value -= step;
adc86793eee1 (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
   995
						if (value < sdb->min) value = (sdb->flags & SGF_0ISDISABLED) ? 0 : sdb->min;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   996
					}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   997
6255
149372cc2dcf (svn r9064) -Fix [FS#663]: don't keep on scrolling for non-numeric values in settings, but require reclick
truelight
parents: 6248
diff changeset
   998
					/* Set up scroller timeout for numeric values */
149372cc2dcf (svn r9064) -Fix [FS#663]: don't keep on scrolling for non-numeric values in settings, but require reclick
truelight
parents: 6248
diff changeset
   999
					if (value != oldvalue && !(sd->desc.flags & SGF_MULTISTRING)) {
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1000
						WP(w, def_d).data_2 = btn * 2 + 1 + ((x >= 10) ? 1 : 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1001
						w->flags4 |= 5 << WF_TIMEOUT_SHL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1002
						_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1003
					}
3118
adc86793eee1 (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
  1004
				} break;
adc86793eee1 (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
  1005
				default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1006
				}
3118
adc86793eee1 (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
  1007
adc86793eee1 (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
  1008
				if (value != oldvalue) {
3247
ede7a53941b2 (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
  1009
					SetPatchValue(page->entries[btn].index, patches_ptr, value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1010
					SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1011
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1012
			} else {
3118
adc86793eee1 (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
  1013
				/* only open editbox for types that its sensible for */
adc86793eee1 (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
  1014
				if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
adc86793eee1 (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
  1015
					/* Show the correct currency-translated value */
adc86793eee1 (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
  1016
					if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate;
adc86793eee1 (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
  1017
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1018
					WP(w, def_d).data_3 = btn;
3118
adc86793eee1 (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
  1019
					SetDParam(0, value);
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5237
diff changeset
  1020
					ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1021
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1022
			}
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1023
		} break;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
  1024
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1025
		case PATCHSEL_INTERFACE: case PATCHSEL_CONSTRUCTION: case PATCHSEL_VEHICLES:
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1026
		case PATCHSEL_STATIONS:  case PATCHSEL_ECONOMY:      case PATCHSEL_COMPETITORS:
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1027
			w->RaiseWidget(WP(w, def_d).data_1 + PATCHSEL_INTERFACE);
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1028
			WP(w, def_d).data_1 = e->we.click.widget - PATCHSEL_INTERFACE;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1029
			w->LowerWidget(WP(w, def_d).data_1 + PATCHSEL_INTERFACE);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1030
			DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1031
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1032
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1033
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1034
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1035
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1036
	case WE_TIMEOUT:
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1037
		WP(w, def_d).data_2 = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1038
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1039
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1040
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1041
	case WE_ON_EDIT_TEXT: {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
  1042
		if (e->we.edittext.str != NULL) {
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1043
			const PatchEntry *pe = &_patches_page[WP(w, def_d).data_1].entries[WP(w,def_d).data_3];
3247
ede7a53941b2 (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
  1044
			const SettingDesc *sd = pe->setting;
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
  1045
			int32 value = atoi(e->we.edittext.str);
3118
adc86793eee1 (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
  1046
adc86793eee1 (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
  1047
			/* Save the correct currency-translated value */
adc86793eee1 (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
  1048
			if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
adc86793eee1 (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
  1049
3247
ede7a53941b2 (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
  1050
			SetPatchValue(pe->index, patches_ptr, value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1051
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1052
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1053
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1054
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1055
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1056
	case WE_DESTROY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1057
		DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1058
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1059
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1060
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1061
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1062
static const Widget _patches_selection_widgets[] = {
4344
7e123fec5b0b (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
  1063
{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
7e123fec5b0b (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
  1064
{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_CONFIG_PATCHES_CAPTION,      STR_018C_WINDOW_TITLE_DRAG_THIS},
7e123fec5b0b (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
  1065
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                             STR_NULL},
6980
c7c4f3bf5901 (svn r10236) -Feature: Introduce a form of timetabling for vehicles.
maedhros
parents: 6956
diff changeset
  1066
{      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
  1067
4344
7e123fec5b0b (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
  1068
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_CONFIG_PATCHES_GUI,          STR_NULL},
7e123fec5b0b (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
  1069
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL},
7e123fec5b0b (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
  1070
{    WWT_TEXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_CONFIG_PATCHES_VEHICLES,     STR_NULL},
7e123fec5b0b (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
  1071
{    WWT_TEXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_CONFIG_PATCHES_STATIONS,     STR_NULL},
7e123fec5b0b (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
  1072
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    28,    39, STR_CONFIG_PATCHES_ECONOMY,      STR_NULL},
7e123fec5b0b (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
  1073
{    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
  1074
{   WIDGETS_END},
0
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1077
static const WindowDesc _patches_selection_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7177
diff changeset
  1078
	WDP_CENTER, WDP_CENTER, 370, 381, 370, 381,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5688
diff changeset
  1079
	WC_GAME_OPTIONS, WC_NONE,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1080
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1081
	_patches_selection_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1082
	PatchesSelectionWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1083
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1084
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6012
diff changeset
  1085
void ShowPatchesSelection()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1086
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1087
	DeleteWindowById(WC_GAME_OPTIONS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1088
	AllocateWindowDesc(&_patches_selection_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
  1089
}
478
3a161108a15d (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
  1090
3a161108a15d (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
  1091
4211
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1092
/**
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1093
 * Draw [<][>] boxes.
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1094
 * @param x the x position to draw
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1095
 * @param y the y position to draw
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1096
 * @param ctab the color of the buttons
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1097
 * @param state 0 = none clicked, 1 = first clicked, 2 = second clicked
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1098
 * @param clickable_left is the left button clickable?
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1099
 * @param clickable_right is the right button clickable?
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1100
 */
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1101
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right)
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1102
{
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5609
diff changeset
  1103
	int color = (1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[COLOUR_YELLOW][2];
3107
d743cfa2d832 (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
  1104
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1105
	DrawFrameRect(x,      y + 1, x +  9, y + 9, ctab, (state == 1) ? FR_LOWERED : FR_NONE);
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1106
	DrawFrameRect(x + 10, y + 1, x + 19, y + 9, ctab, (state == 2) ? FR_LOWERED : FR_NONE);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
  1107
	DrawStringCentered(x +  5, y + 1, STR_6819, TC_FROMSTRING); // [<]
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
  1108
	DrawStringCentered(x + 15, y + 1, STR_681A, TC_FROMSTRING); // [>]
4211
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1109
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1110
	/* Grey out the buttons that aren't clickable */
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1111
	if (!clickable_left)
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1112
		GfxFillRect(x +  1, y + 1, x +  1 + 8, y + 8, color);
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1113
	if (!clickable_right)
5ee54ab361c9 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
  1114
		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1115
}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1116
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1117
/** These are not, strickly speaking, widget enums,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1118
 *  since they have been changed as line coordinates.
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1119
 *  So, rather, they are more like order of appearance */
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1120
enum CustomCurrenciesWidgets {
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1121
	CUSTCURR_EXCHANGERATE = 0,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1122
	CUSTCURR_SEPARATOR,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1123
	CUSTCURR_PREFIX,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1124
	CUSTCURR_SUFFIX,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1125
	CUSTCURR_TO_EURO,
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1126
};
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1127
2307
484c654dc875 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
  1128
static char _str_separator[2];
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1129
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1130
static void CustCurrencyWndProc(Window *w, WindowEvent *e)
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1131
{
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1132
	switch (e->event) {
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1133
		case WE_PAINT: {
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1134
			int x;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1135
			int y = 20;
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1136
			int clk = WP(w, def_d).data_1;
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1137
			DrawWindowWidgets(w);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1138
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1139
			/* exchange rate */
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1140
			DrawArrowButtons(10, y, 3, GB(clk, 0, 2), true, true);
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1141
			SetDParam(0, 1);
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1142
			SetDParam(1, 1);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
  1143
			DrawString(35, y + 1, STR_CURRENCY_EXCHANGE_RATE, TC_FROMSTRING);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1144
			y += 12;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1145
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1146
			/* separator */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1147
			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 2, 2) ? FR_LOWERED : FR_NONE);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
  1148
			x = DrawString(35, y + 1, STR_CURRENCY_SEPARATOR, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
  1149
			DoDrawString(_str_separator, x + 4, y + 1, TC_ORANGE);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1150
			y += 12;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1151
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1152
			/* prefix */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1153
			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 4, 2) ? FR_LOWERED : FR_NONE);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
  1154
			x = DrawString(35, y + 1, STR_CURRENCY_PREFIX, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
  1155
			DoDrawString(_custom_currency.prefix, x + 4, y + 1, TC_ORANGE);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1156
			y += 12;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1157
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1158
			/* suffix */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
  1159
			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 6, 2) ? FR_LOWERED : FR_NONE);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
  1160
			x = DrawString(35, y + 1, STR_CURRENCY_SUFFIX, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
  1161
			DoDrawString(_custom_currency.suffix, x + 4, y + 1, TC_ORANGE);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1162
			y += 12;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1163
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1164
			/* switch to euro */
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1165
			DrawArrowButtons(10, y, 3, GB(clk, 8, 2), true, true);
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1166
			SetDParam(0, _custom_currency.to_euro);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
  1167
			DrawString(35, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, TC_FROMSTRING);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1168
			y += 12;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1169
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1170
			/* Preview */
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1171
			y += 12;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1172
			SetDParam(0, 10000);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7742
diff changeset
  1173
			DrawString(35, y + 1, STR_CURRENCY_PREVIEW, TC_FROMSTRING);
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1174
		} break;
812
65ecc321b3db (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 788
diff changeset
  1175
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1176
		case WE_CLICK: {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
  1177
			int line = (e->we.click.pt.y - 20) / 12;
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1178
			int len = 0;
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
  1179
			int x = e->we.click.pt.x;
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1180
			StringID str = 0;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1181
			CharSetFilter afilter = CS_ALPHANUMERAL;
812
65ecc321b3db (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 788
diff changeset
  1182
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1183
			switch (line) {
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1184
				case CUSTCURR_EXCHANGERATE:
7954
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
  1185
					if (IsInsideMM(x, 10, 30)) { // clicked buttons
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1186
						if (x < 20) {
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1187
							if (_custom_currency.rate > 1) _custom_currency.rate--;
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1188
							WP(w, def_d).data_1 = 1 << (line * 2 + 0);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1189
						} else {
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1190
							if (_custom_currency.rate < 5000) _custom_currency.rate++;
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1191
							WP(w, def_d).data_1 = 1 << (line * 2 + 1);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1192
						}
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1193
					} else { // enter text
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1194
						SetDParam(0, _custom_currency.rate);
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1195
						str = STR_CONFIG_PATCHES_INT32;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1196
						len = 4;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1197
						afilter = CS_NUMERAL;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1198
					}
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1199
					break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1200
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1201
				case CUSTCURR_SEPARATOR:
7954
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
  1202
					if (IsInsideMM(x, 10, 30)) { // clicked button
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1203
						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1204
					}
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1205
					str = BindCString(_str_separator);
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1206
					len = 1;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1207
					break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1208
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1209
				case CUSTCURR_PREFIX:
7954
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
  1210
					if (IsInsideMM(x, 10, 30)) { // clicked button
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1211
						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1212
					}
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1213
					str = BindCString(_custom_currency.prefix);
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1214
					len = 12;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1215
					break;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1216
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1217
				case CUSTCURR_SUFFIX:
7954
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
  1218
					if (IsInsideMM(x, 10, 30)) { // clicked button
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1219
						WP(w, def_d).data_1 = 1 << (line * 2 + 1);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1220
					}
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1221
					str = BindCString(_custom_currency.suffix);
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1222
					len = 12;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1223
					break;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1224
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1225
				case CUSTCURR_TO_EURO:
7954
57b51c69c072 (svn r11510) -Codechange: merge the IS_*INSIDE* functions and rename them fitting to the naming style
skidd13
parents: 7931
diff changeset
  1226
					if (IsInsideMM(x, 10, 30)) { // clicked buttons
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1227
						if (x < 20) {
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1228
							_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ?
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1229
								CF_NOEURO : _custom_currency.to_euro - 1;
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1230
							WP(w, def_d).data_1 = 1 << (line * 2 + 0);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1231
						} else {
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1232
							_custom_currency.to_euro =
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7901
diff changeset
  1233
								Clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1234
							WP(w, def_d).data_1 = 1 << (line * 2 + 1);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1235
						}
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1236
					} else { // enter text
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1237
						SetDParam(0, _custom_currency.to_euro);
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1238
						str = STR_CONFIG_PATCHES_INT32;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1239
						len = 4;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1240
						afilter = CS_NUMERAL;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1241
					}
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1242
					break;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1243
			}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1244
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1245
			if (len != 0) {
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5237
diff changeset
  1246
				WP(w, def_d).data_2 = line;
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5237
diff changeset
  1247
				ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, w, afilter);
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1248
			}
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1249
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1250
			w->flags4 |= 5 << WF_TIMEOUT_SHL;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1251
			SetWindowDirty(w);
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1252
		} break;
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1253
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1254
		case WE_ON_EDIT_TEXT: {
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1255
			const char *b = e->we.edittext.str;
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1256
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1257
			switch (WP(w, def_d).data_2) {
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1258
				case CUSTCURR_EXCHANGERATE:
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1259
					_custom_currency.rate = Clamp(atoi(b), 1, 5000);
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1260
					break;
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1261
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1262
				case CUSTCURR_SEPARATOR: /* Thousands seperator */
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1263
					_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0];
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1264
					ttd_strlcpy(_str_separator, b, lengthof(_str_separator));
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1265
					break;
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1266
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1267
				case CUSTCURR_PREFIX:
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1268
					ttd_strlcpy(_custom_currency.prefix, b, lengthof(_custom_currency.prefix));
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1269
					break;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1270
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1271
				case CUSTCURR_SUFFIX:
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1272
					ttd_strlcpy(_custom_currency.suffix, b, lengthof(_custom_currency.suffix));
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1273
					break;
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1274
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1275
				case CUSTCURR_TO_EURO: { /* Year to switch to euro */
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1276
					int val = atoi(b);
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1277
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1278
					_custom_currency.to_euro = (val < 2000 ? CF_NOEURO : min(val, MAX_YEAR));
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1279
					break;
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1280
				}
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1281
			}
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1282
			MarkWholeScreenDirty();
8188
f326251c9d7f (svn r11751) -Codechange: Enumify some widgets (and others) and while at it, apply some code style
belugas
parents: 8182
diff changeset
  1283
		} break;
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1284
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1285
		case WE_TIMEOUT:
8082
63240e1bd6cc (svn r11643) -Codechange: conform with the coding style for the WP macro uses.
rubidium
parents: 7997
diff changeset
  1286
			WP(w, def_d).data_1 = 0;
4488
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1287
			SetWindowDirty(w);
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1288
			break;
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1289
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1290
		case WE_DESTROY:
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1291
			DeleteWindowById(WC_QUERY_STRING, 0);
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1292
			MarkWholeScreenDirty();
1be86990ea3e (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1293
			break;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1294
	}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1295
}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1296
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1297
static const Widget _cust_currency_widgets[] = {
4344
7e123fec5b0b (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
  1298
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},
7e123fec5b0b (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
  1299
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   229,     0,    13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS},
7e123fec5b0b (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
  1300
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   229,    14,   119, 0x0,                 STR_NULL},
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1301
{   WIDGETS_END},
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1302
};
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1303
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1304
static const WindowDesc _cust_currency_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7177
diff changeset
  1305
	WDP_CENTER, WDP_CENTER, 230, 120, 230, 120,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5688
diff changeset
  1306
	WC_CUSTOM_CURRENCY, WC_NONE,
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1307
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1308
	_cust_currency_widgets,
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1309
	CustCurrencyWndProc,
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1310
};
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1311
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6012
diff changeset
  1312
static void ShowCustCurrency()
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1313
{
2306
adb71c055afb (svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents: 2293
diff changeset
  1314
	_str_separator[0] = _custom_currency.separator;
1759
604a74a1e744 (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
  1315
	_str_separator[1] = '\0';
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1316
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1317
	DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1318
	AllocateWindowDesc(&_cust_currency_desc);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1319
}