settings_gui.c
author Darkvater
Mon, 31 Jul 2006 22:40:55 +0000
changeset 4204 3aa39be759f2
parent 4196 1df4eeea1f81
child 4211 5ee54ab361c9
permissions -rw-r--r--
(svn r5688) - Forward-port the release-changes from the 0.4 branch back to trunk. This ensures an updated changelog, known-bugs, etc.
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
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1806
diff changeset
     4
#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
     5
#include "currency.h"
2163
b17b313113a0 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     6
#include "functions.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
     7
#include "string.h"
1309
4403a69da4f8 (svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents: 1282
diff changeset
     8
#include "strings.h" // XXX GetCurrentCurrencyRate()
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 "window.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
#include "gui.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
#include "gfx.h"
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
#include "command.h"
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"
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
    18
#include "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"
3577
c6532e0bee4c (svn r4463) -Codechange. Include vehicle.h directly instead of implicitly via station.h in a number of source files
celestar
parents: 3491
diff changeset
    22
#include "vehicle.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
static uint32 _difficulty_click_a;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
static uint32 _difficulty_click_b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
static byte _difficulty_timeout;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
3342
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    28
static const StringID _units_dropdown[] = {
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    29
	STR_UNITS_IMPERIAL,
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    30
	STR_UNITS_METRIC,
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    31
	STR_UNITS_SI,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
	INVALID_STRING_ID
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
static const StringID _driveside_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
	STR_02E9_DRIVE_ON_LEFT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
	STR_02EA_DRIVE_ON_RIGHT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
	INVALID_STRING_ID
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
static const StringID _autosave_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
	STR_02F7_OFF,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
	STR_AUTOSAVE_1_MONTH,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
	STR_02F8_EVERY_3_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
	STR_02F9_EVERY_6_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
	STR_02FA_EVERY_12_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
	INVALID_STRING_ID,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
static const StringID _designnames_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
	STR_02BE_DEFAULT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
	STR_02BF_CUSTOM,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
	INVALID_STRING_ID
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
static StringID *BuildDynamicDropdown(StringID base, int num)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    58
	static StringID buf[32 + 1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
	StringID *p = buf;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
	while (--num>=0) *p++ = base++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
	*p = INVALID_STRING_ID;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
	return buf;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
    65
static int GetCurRes(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	int i;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    68
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    69
	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
    70
		if (_resolutions[i][0] == _screen.width &&
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    71
				_resolutions[i][1] == _screen.height) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
			break;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    73
		}
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    74
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
	return i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
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
    78
static inline bool RoadVehiclesAreBuilt(void)
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
    79
{
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    80
	const Vehicle* v;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    81
915
d845fe7cf6f2 (svn r1402) Trim trailing whitespace
tron
parents: 893
diff changeset
    82
	FOR_ALL_VEHICLES(v) {
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
    83
		if (v->type == VEH_Road) return true;
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
    84
	}
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
    85
	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
    86
}
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
    87
2817
cdf488223c23 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
    88
cdf488223c23 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
    89
static void ShowCustCurrency(void);
cdf488223c23 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
    90
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
static void GameOptionsWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
{
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
    93
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	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
    95
		int i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
		StringID str = STR_02BE_DEFAULT;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
		w->disabled_state = (_vehicle_design_names & 1) ? (++str, 0) : (1 << 21);
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
    98
		SetDParam(0, str);
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
    99
		SetDParam(1, _currency_string_list[_opt_ptr->currency]);
3342
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
   100
		SetDParam(2, STR_UNITS_IMPERIAL + _opt_ptr->units);
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   101
		SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_ptr->road_side);
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   102
		SetDParam(4, STR_TOWNNAME_ORIGINAL_ENGLISH + _opt_ptr->town_name);
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   103
		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
   104
		SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
		i = GetCurRes();
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   106
		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
   107
		SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format);
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
   108
		(_fullscreen) ? SETBIT(w->click_state, 28) : CLRBIT(w->click_state, 28); // fullscreen button
0123c0489940 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   109
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
		DrawWindowWidgets(w);
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
   111
		DrawString(20, 175, STR_OPTIONS_FULLSCREEN, 0); // fullscreen
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
	}	break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
	case WE_CLICK:
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   115
		switch (e->click.widget) {
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   116
		case 4: case 5: /* Setup currencies dropdown */
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   117
			ShowDropDownMenu(w, _currency_string_list, _opt_ptr->currency, 5, _game_mode == GM_MENU ? 0 : ~GetMaskOfAllowedCurrencies(), 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
			return;
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   119
		case 7: case 8: /* Setup distance unit dropdown */
3342
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
   120
			ShowDropDownMenu(w, _units_dropdown, _opt_ptr->units, 8, 0, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
			return;
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   122
		case 10: case 11: { /* 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
   123
			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
   124
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
   125
			/* 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
   126
			 * 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
   127
			if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server))
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   128
				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
   129
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   130
			ShowDropDownMenu(w, _driveside_dropdown, _opt_ptr->road_side, 11, i, 0);
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
   131
		} return;
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   132
		case 13: case 14: { /* Setup townname dropdown */
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   133
			int i = _opt_ptr->town_name;
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   134
			ShowDropDownMenu(w, BuildDynamicDropdown(STR_TOWNNAME_ORIGINAL_ENGLISH, SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1), i, 14, (_game_mode == GM_MENU) ? 0 : (-1) ^ (1 << i), 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
		}
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   137
		case 16: case 17: /* Setup autosave dropdown */
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   138
			ShowDropDownMenu(w, _autosave_dropdown, _opt_ptr->autosave, 17, 0, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
			return;
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   140
		case 19: case 20: /* Setup customized vehicle-names dropdown */
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   141
			ShowDropDownMenu(w, _designnames_dropdown, (_vehicle_design_names & 1) ? 1 : 0, 20, (_vehicle_design_names & 2) ? 0 : 2, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
			return;
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
   143
		case 21: /* Save customized vehicle-names to disk */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   144
			return;
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   145
		case 23: case 24: /* Setup interface language dropdown */
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   146
			ShowDropDownMenu(w, _dynlang.dropdown, _dynlang.curr, 24, 0, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
			return;
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   148
		case 26: case 27: /* Setup resolution dropdown */
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   149
			ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_RESOLUTION_START, _num_resolutions), GetCurRes(), 27, 0, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
			return;
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
   151
		case 28: /* Click fullscreen on/off */
0123c0489940 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   152
			(_fullscreen) ? CLRBIT(w->click_state, 28) : SETBIT(w->click_state, 28);
0123c0489940 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   153
			ToggleFullScreen(!_fullscreen); // toggle full-screen on/off
0123c0489940 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   154
			SetWindowDirty(w);
0123c0489940 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   155
			return;
1806
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   156
		case 30: case 31: /* Setup screenshot format dropdown */
5a55d508c23e (svn r2310) - Fix: Game would crash if you full-screened with the 'fullscreen' button than chose a resolution from the dropdown box that was no longer valid. Big thanks to DaleStan for track down the crashing bug.
Darkvater
parents: 1805
diff changeset
   157
			ShowDropDownMenu(w, BuildDynamicDropdown(SPECSTR_SCREENSHOT_START, _num_screenshot_formats), _cur_screenshot_format, 31, 0, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   158
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   162
	case WE_DROPDOWN_SELECT:
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   163
		switch (e->dropdown.button) {
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
   164
		case 20: /* Vehicle design names */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
			if (e->dropdown.index == 0) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
				DeleteCustomEngineNames();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
				MarkWholeScreenDirty();
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   168
			} else if (!(_vehicle_design_names & 1)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
				LoadCustomEngineNames();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
				MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   172
			break;
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
   173
		case 5: /* Currency */
3596
6654541a3958 (svn r4487) - Codechange: replace the custom currency magic number 23 with a define
peter1138
parents: 3577
diff changeset
   174
			if (e->dropdown.index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   175
			_opt_ptr->currency = e->dropdown.index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
			MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
			break;
3342
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
   178
		case 8: /* Measuring units */
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
   179
			_opt_ptr->units = e->dropdown.index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
			MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
			break;
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
   182
		case 11: /* Road side */
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   183
			if (_opt_ptr->road_side != e->dropdown.index) { // only change if setting changed
1803
8fd9dca6d2c6 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents: 1796
diff changeset
   184
				DoCommandP(0, e->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
   185
				MarkWholeScreenDirty();
da5c5c571541 (svn r1614) Fix: Signals were not updated correctly when the vehicle drive side was changed
dominik
parents: 1095
diff changeset
   186
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
			break;
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
   188
		case 14: /* Town names */
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   189
			if (_game_mode == GM_MENU) {
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   190
				_opt_ptr->town_name = e->dropdown.index;
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   191
				InvalidateWindow(WC_GAME_OPTIONS, 0);
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   192
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
			break;
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
		case 17: /* Autosave options */
4196
1df4eeea1f81 (svn r5656) -Fix [SF 1296259]: Autosave override. Changing autosave interval ingame should also change the default interval.
Darkvater
parents: 3900
diff changeset
   195
			_opt.autosave = _opt_newgame.autosave = e->dropdown.index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   196
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
			break;
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
   198
		case 24: /* Change interface language */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
			ReadLanguagePack(e->dropdown.index);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
			MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
			break;
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
   202
		case 27: /* Change resolution */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
			if (e->dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->dropdown.index][0],_resolutions[e->dropdown.index][1]))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
				SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
			break;
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
   206
		case 31: /* Change screenshot format */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
			SetScreenshotFormat(e->dropdown.index);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   210
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
		break;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   212
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   213
	case WE_DESTROY:
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   214
		DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   215
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
	}
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   217
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   220
/** 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
   221
 * @param tile unused
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   222
 * @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
   223
 * @param p2 unused
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   224
 */
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
   225
int32 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
   226
{
1803
8fd9dca6d2c6 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents: 1796
diff changeset
   227
	/* 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
   228
	 * 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
   229
	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
   230
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
	if (flags & DC_EXEC) {
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   232
		_opt_ptr->road_side = p1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   233
		InvalidateWindow(WC_GAME_OPTIONS,0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   236
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
static const Widget _game_options_widgets[] = {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   239
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,								STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   240
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   369,     0,    13, STR_00B1_GAME_OPTIONS,		STR_018C_WINDOW_TITLE_DRAG_THIS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   241
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   369,    14,   238, 0x0,											STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   242
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,    20,    55, STR_02E0_CURRENCY_UNITS,	STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   243
{          WWT_6,   RESIZE_NONE,    14,    20,   169,    34,    45, STR_02E1,								STR_02E2_CURRENCY_UNITS_SELECTION},
2725
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   244
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,    35,    44, STR_0225,								STR_02E2_CURRENCY_UNITS_SELECTION},
3342
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
   245
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,    20,    55, STR_MEASURING_UNITS,		STR_NULL},
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
   246
{          WWT_6,   RESIZE_NONE,    14,   200,   349,    34,    45, STR_02E4,								STR_MEASURING_UNITS_SELECTION},
cb9b5c6dd74c (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
   247
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   338,   348,    35,    44, STR_0225,								STR_MEASURING_UNITS_SELECTION},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   248
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,    62,    97, STR_02E6_ROAD_VEHICLES,	STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   249
{          WWT_6,   RESIZE_NONE,    14,    20,   169,    76,    87, STR_02E7,								STR_02E8_SELECT_SIDE_OF_ROAD_FOR},
2725
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   250
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,    77,    86, STR_0225,								STR_02E8_SELECT_SIDE_OF_ROAD_FOR},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   251
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,    62,    97, STR_02EB_TOWN_NAMES,			STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   252
{          WWT_6,   RESIZE_NONE,    14,   200,   349,    76,    87, STR_02EC,								STR_02ED_SELECT_STYLE_OF_TOWN_NAMES},
2725
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   253
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   338,   348,    77,    86, STR_0225,								STR_02ED_SELECT_STYLE_OF_TOWN_NAMES},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   254
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,   104,   139, STR_02F4_AUTOSAVE,				STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   255
{          WWT_6,   RESIZE_NONE,    14,    20,   169,   118,   129, STR_02F5,								STR_02F6_SELECT_INTERVAL_BETWEEN},
2725
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   256
{    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
   257
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   258
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   359,   194,   228, STR_02BC_VEHICLE_DESIGN_NAMES,				STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   259
{          WWT_6,   RESIZE_NONE,    14,    20,   119,   207,   218, STR_02BD,								STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
2725
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   260
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   108,   118,   208,   217, STR_0225,								STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   261
{    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
   262
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   263
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,   104,   139, STR_OPTIONS_LANG,				STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   264
{          WWT_6,   RESIZE_NONE,    14,   200,   349,   118,   129, STR_OPTIONS_LANG_CBO,		STR_OPTIONS_LANG_TIP},
2725
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   265
{    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
   266
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   267
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,   146,   190, STR_OPTIONS_RES,					STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   268
{          WWT_6,   RESIZE_NONE,    14,    20,   169,   160,   171, STR_OPTIONS_RES_CBO,			STR_OPTIONS_RES_TIP},
2725
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   269
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,   161,   170, STR_0225,								STR_OPTIONS_RES_TIP},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   270
{    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
   271
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   272
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,   146,   190, STR_OPTIONS_SCREENSHOT_FORMAT,				STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   273
{          WWT_6,   RESIZE_NONE,    14,   200,   349,   160,   171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO,		STR_OPTIONS_SCREENSHOT_FORMAT_TIP},
2725
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   274
{    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
   275
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 164
diff changeset
   276
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   278
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   279
static const WindowDesc _game_options_desc = {
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
   280
	WDP_CENTER, WDP_CENTER, 370, 239,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
	WC_GAME_OPTIONS,0,
2064
e6a2b42d0b15 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   282
	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
   283
	_game_options_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   284
	GameOptionsWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   286
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   287
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
   288
void ShowGameOptions(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   290
	DeleteWindowById(WC_GAME_OPTIONS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
	AllocateWindowDesc(&_game_options_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
typedef struct {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
	int16 min;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
	int16 max;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
	int16 step;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
	StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
} GameSettingData;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
static const GameSettingData _game_setting_info[] = {
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   302
	{  0,   7,  1, STR_NULL},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   303
	{  0,   3,  1, STR_6830_IMMEDIATE},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   304
	{  0,   2,  1, STR_6816_LOW},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   305
	{  0,   3,  1, STR_26816_NONE},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   306
	{100, 500, 50, STR_NULL},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   307
	{  2,   4,  1, STR_NULL},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   308
	{  0,   2,  1, STR_6820_LOW},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   309
	{  0,   4,  1, STR_681B_VERY_SLOW},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   310
	{  0,   2,  1, STR_6820_LOW},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   311
	{  0,   2,  1, STR_6823_NONE},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   312
	{  0,   3,  1, STR_6826_X1_5},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   313
	{  0,   2,  1, STR_6820_LOW},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   314
	{  0,   3,  1, STR_682A_VERY_FLAT},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   315
	{  0,   3,  1, STR_VERY_LOW},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   316
	{  0,   1,  1, STR_682E_STEADY},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   317
	{  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
   318
	{  0,   1,  1, STR_6836_OFF},
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   319
	{  0,   2,  1, STR_6839_PERMISSIVE},
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
536
03d80fecb999 (svn r907) Sprinkle holy ANSI water:
tron
parents: 534
diff changeset
   322
static inline bool GetBitAndShift(uint32 *b)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   323
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
	uint32 x = *b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
	*b >>= 1;
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   326
	return HASBIT(x, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   327
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   328
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
   329
/*
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
   330
	A: competitors
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
   331
	B: start time in months / 3
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
   332
	C: town count (2 = high, 0 = low)
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
   333
	D: industry count (3 = high, 0 = none)
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
   334
	E: inital loan / 1000 (in GBP)
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
   335
	F: interest rate
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
   336
	G: running costs (0 = low, 2 = high)
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
   337
	H: construction speed of competitors (0 = very slow, 4 = very fast)
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
   338
	I: intelligence (0-2)
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
   339
	J: breakdowns(0 = off, 2 = normal)
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
   340
	K: subsidy multiplier (0 = 1.5, 3 = 4.0)
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
   341
	L: construction cost (0-2)
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
   342
	M: terrain type (0 = very flat, 3 = mountainous)
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
   343
	N: amount of water (0 = very low, 3 = high)
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
   344
	O: economy (0 = steady, 1 = fluctuating)
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
   345
	P: Train reversing (0 = end of line + stations, 1 = end of line)
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
   346
	Q: disasters
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
   347
	R: area restructuring (0 = permissive, 2 = hostile)
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
   348
*/
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
   349
static const int16 _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /*
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
   350
	 A, B, C, D,   E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/
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
   351
	{2, 2, 1, 3, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0},	//easy
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
   352
	{4, 1, 1, 2, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1},	//medium
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
   353
	{7, 0, 2, 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
   354
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   355
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   356
void SetDifficultyLevel(int mode, GameOptions *gm_opt)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   357
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   358
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
	assert(mode <= 3);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
	gm_opt->diff_level = mode;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
	if (mode != 3) { // not custom
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   363
		for (i = 0; i != GAME_DIFFICULTY_NUM; i++)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
			((int*)&gm_opt->diff)[i] = _default_game_diff[mode][i];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   367
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
   368
extern void StartupEconomy(void);
46
c9bdf1d58df6 (svn r47) -Fix StartupEconomy warning in settings_gui.c
darkvater
parents: 42
diff changeset
   369
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
   370
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
   371
	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
   372
	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
   373
};
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
   374
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   375
// Temporary holding place of values in the difficulty window until 'Save' is clicked
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   376
static GameOptions _opt_mod_temp;
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   377
// 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
   378
#define DIFF_INGAME_DISABLED_BUTTONS 0x383E
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   379
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   380
static void GameDifficultyWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   381
{
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   382
	switch (e->event) {
1794
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   383
		case WE_CREATE: /* Setup disabled buttons when creating window */
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   384
		// disable all other difficulty buttons during gameplay except for 'custom'
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   385
		w->disabled_state = (_game_mode != GM_NORMAL) ? 0 : (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6);
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   386
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   387
		if (_game_mode == GM_EDITOR) SETBIT(w->disabled_state, 7);
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   388
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   389
		if (_networking) {
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   390
			SETBIT(w->disabled_state, 7); // disable highscore chart in multiplayer
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   391
			if (!_network_server)
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   392
				SETBIT(w->disabled_state, 10); // Disable save-button in multiplayer (and if client)
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   393
		}
24b4239f2090 (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   394
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   395
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   396
		uint32 click_a, click_b, disabled;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
		int i;
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   398
		int y, value;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   400
		w->click_state = (1 << 3) << _opt_mod_temp.diff_level; // have current difficulty button clicked
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
		click_a = _difficulty_click_a;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
		click_b = _difficulty_click_b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   406
		/* XXX - Disabled buttons in normal gameplay. Bitshifted for each button to see if
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   407
		 * that bit is set. If it is set, the button is disabled */
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   408
		disabled = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   409
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
   410
		y = GAMEDIFF_WND_TOP_OFFSET;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   411
		for (i = 0; i != GAME_DIFFICULTY_NUM; i++) {
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   412
			DrawFrameRect( 5, y,  5 + 8, y + 8, 3, GetBitAndShift(&click_a) ? (1 << 5) : 0);
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   413
			DrawFrameRect(15, y, 15 + 8, y + 8, 3, GetBitAndShift(&click_b) ? (1 << 5) : 0);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   414
			if (GetBitAndShift(&disabled) || (_networking && !_network_server)) {
2231
0e3123832176 (svn r2751) -Fix: Disabled buttons in the patches and difficulty windows are now rendered properly again
celestar
parents: 2201
diff changeset
   415
				int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2;
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   416
				GfxFillRect( 6, y + 1,  6 + 8, y + 8, color);
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   417
				GfxFillRect(16, y + 1, 16 + 8, y + 8, color);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   418
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   419
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   420
			DrawStringCentered(10, y, STR_6819, 0);
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   421
			DrawStringCentered(20, y, STR_681A, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
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
			value = _game_setting_info[i].str + ((int*)&_opt_mod_temp.diff)[i];
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   425
			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
   426
			SetDParam(0, value);
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   427
			DrawString(30, y, STR_6805_MAXIMUM_NO_COMPETITORS + i, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   428
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
   429
			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
   430
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   431
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
	case WE_CLICK:
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   434
		switch (e->click.widget) {
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   435
		case 8: { /* Difficulty settings widget, decode click */
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   436
			const GameSettingData *info;
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   437
			int x, y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   438
			uint btn, dis;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
			int val;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   440
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   441
			// Don't allow clients to make any changes
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   442
			if  (_networking && !_network_server)
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   443
				return;
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   444
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   445
			x = e->click.pt.x - 5;
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   446
			if (!IS_INT_INSIDE(x, 0, 21)) // Button area
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   447
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   448
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
   449
			y = e->click.pt.y - GAMEDIFF_WND_TOP_OFFSET;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   450
			if (y < 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
			// Get button from Y coord.
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
   454
			btn = y / (GAMEDIFF_WND_ROWSIZE + 2);
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
   455
			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
   456
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   457
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
			// Clicked disabled button?
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   459
			dis = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0;
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
   460
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   461
			if (HASBIT(dis, btn))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
			_difficulty_timeout = 5;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
			val = ((int*)&_opt_mod_temp.diff)[btn];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   468
			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
   469
			if (x >= 10) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
				// Increase button clicked
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
				val = min(val + info->step, info->max);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
				SETBIT(_difficulty_click_b, btn);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
			} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
				// Decrease button clicked
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
				val = max(val - info->step, info->min);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
				SETBIT(_difficulty_click_a, btn);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
			// save value in temporary variable
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
			((int*)&_opt_mod_temp.diff)[btn] = val;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
			SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
			SetWindowDirty(w);
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   483
		}	break;
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
   484
		case 3: case 4: case 5: case 6: /* Easy / Medium / Hard / Custom */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   485
			// temporarily change difficulty level
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
   486
			SetDifficultyLevel(e->click.widget - 3, &_opt_mod_temp);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   487
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
			break;
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
   489
		case 7: /* Highscore Table */
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
   490
			ShowHighscoreTable(_opt_mod_temp.diff_level, -1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
			break;
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
   492
		case 10: { /* Save button - save changes */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   493
			int btn, val;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   494
			for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   495
				val = ((int*)&_opt_mod_temp.diff)[btn];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
				// if setting has changed, change it
1501
0fc808b4e375 (svn r2005) - Fix: fix previous commit. Using 'New Game (scenario)' will use YOUR difficulty settings but ingame options (eg townnames, currency). Also settings are correctly saved when closing the difficulty window now.
Darkvater
parents: 1500
diff changeset
   497
				if (val != ((int*)&_opt_ptr->diff)[btn])
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
					DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   500
			DoCommandP(0, -1, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
			DeleteWindow(w);
42
567add3568d6 (svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents: 26
diff changeset
   502
			// If we are in the editor, we should reload the economy.
567add3568d6 (svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents: 26
diff changeset
   503
			//  This way when you load a game, the max loan and interest rate
567add3568d6 (svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents: 26
diff changeset
   504
			//  are loaded correctly.
567add3568d6 (svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents: 26
diff changeset
   505
			if (_game_mode == GM_EDITOR)
567add3568d6 (svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents: 26
diff changeset
   506
				StartupEconomy();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   508
		}
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   509
		case 11: /* Cancel button - close window, abandon changes */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
			break;
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   512
	} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   514
	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
   515
		if (_difficulty_timeout != 0 && !--_difficulty_timeout) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
			_difficulty_click_a = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   517
			_difficulty_click_b = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   518
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   522
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   523
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   524
#undef DIFF_INGAME_DISABLED_BUTTONS
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   525
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
static const Widget _game_difficulty_widgets[] = {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   527
{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,									STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   528
{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_6800_DIFFICULTY_LEVEL,	STR_018C_WINDOW_TITLE_DRAG_THIS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   529
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    29, 0x0,												STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   530
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_6801_EASY,							STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   531
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_6802_MEDIUM,						STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   532
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_6803_HARD,							STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   533
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_6804_CUSTOM,						STR_NULL},
2725
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   534
{    WWT_TEXTBTN,   RESIZE_NONE,    10,     0,   369,    30,    41, STR_6838_SHOW_HI_SCORE_CHART,STR_NULL},
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
   535
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   262, 0x0,												STR_NULL},
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   536
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,   263,   278, 0x0,												STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   537
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   105,   185,   265,   276, STR_OPTIONS_SAVE_CHANGES,	STR_NULL},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   538
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   186,   266,   265,   276, STR_012E_CANCEL,						STR_NULL},
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 164
diff changeset
   539
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   540
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   541
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   542
static const WindowDesc _game_difficulty_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
	WDP_CENTER, WDP_CENTER, 370, 279,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
	WC_GAME_OPTIONS,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
	_game_difficulty_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
	GameDifficultyWndProc
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
   550
void ShowGameDifficulty(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   551
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   552
	DeleteWindowById(WC_GAME_OPTIONS, 0);
1500
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   553
	/* Copy current settings (ingame or in intro) to temporary holding place
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   554
	 * change that when setting stuff, copy back on clicking 'OK' */
a66721629bc0 (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   555
	memcpy(&_opt_mod_temp, _opt_ptr, sizeof(GameOptions));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   556
	AllocateWindowDesc(&_game_difficulty_desc);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   557
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   558
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
   559
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
   560
	"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
   561
	"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
   562
	"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
   563
	"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
   564
	"reverse_scroll",
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
   565
	"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
   566
	"toolbar_pos",
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
   567
	"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
   568
	"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
   569
	"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
   570
	"map_x",
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
   571
	"map_y",
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
   572
	"link_terraform_toolbar",
21
67cde01e8359 (svn r22) Add: Competitors menu under patches
truelight
parents: 20
diff changeset
   573
};
67cde01e8359 (svn r22) Add: Competitors menu under patches
truelight
parents: 20
diff changeset
   574
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
   575
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
   576
	"build_on_slopes",
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
   577
	"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
   578
	"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
   579
	"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
   580
	"always_small_airport",
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
   581
	"drag_signals_density",
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
   582
};
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
   583
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
   584
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
   585
	"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
   586
	"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
   587
	"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
   588
	"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
   589
	"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
   590
	"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
   591
	"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
   592
	"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
   593
	"modified_catchment",
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
   594
};
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
   595
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
   596
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
   597
	"inflation",
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
   598
	"build_rawmaterial_ind",
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
   599
	"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
   600
	"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
   601
	"bribe",
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
   602
	"snow_line_height",
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
   603
	"colored_news_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
   604
	"starting_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
   605
	"ending_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
   606
	"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
   607
	"allow_shares",
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
   608
};
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
   609
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
   610
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
   611
	"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
   612
	"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
   613
	"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
   614
	"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
   615
	"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
   616
	"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
   617
};
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
   618
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
   619
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
   620
	"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
   621
	"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
   622
	"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
   623
	"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
   624
	"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
   625
	"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
   626
	"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
   627
	"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
   628
	"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
   629
	"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
   630
	"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
   631
	"never_expire_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
   632
	"lost_train_days",
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
   633
	"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
   634
	"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
   635
	"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
   636
	"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
   637
	"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
   638
	"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
   639
	"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
   640
	"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
   641
	"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
   642
	"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
   643
	"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
   644
	"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
   645
	"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
   646
	"wagon_speed_limits",
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
   647
};
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
   648
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
   649
typedef struct PatchEntry {
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
   650
	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
   651
	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
   652
} PatchEntry;
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
   653
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   654
typedef 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
   655
	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
   656
	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
   657
	byte num;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   658
} PatchPage;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   659
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
   660
/* 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
   661
 * 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
   662
 * 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
   663
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
   664
	{_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
   665
	{_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
   666
	{_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
   667
	{_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
   668
	{_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
   669
	{_patches_ai,           NULL, lengthof(_patches_ai)},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   670
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   671
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
   672
/** 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
   673
 * 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
   674
 * 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
   675
static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
{
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
   677
	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
   678
1741
628182f1bbd2 (svn r2245) - CodeChange: simplify the clamping of values for patch-settings by using clamp()
Darkvater
parents: 1739
diff changeset
   679
	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
   680
	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
   681
		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
   682
3121
72fb0554f9f1 (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
   683
		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
   684
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
   685
		/* 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
   686
		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
   687
			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
   688
			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
   689
				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
   690
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
   691
				page->entries = malloc(page->num * sizeof(*page->entries));
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
				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
   693
					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
   694
					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
   695
					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
   696
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
					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
   698
					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
   699
				}
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
			}
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
   701
			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
   702
		}
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
   703
	} 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
   704
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   705
	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
   706
		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
   707
		const PatchPage *page = &_patches_page[WP(w,def_d).data_1];
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   708
		uint i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   709
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
   710
		/* Set up selected 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
   711
		w->click_state = 1 << (WP(w, def_d).data_1 + 4);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   713
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
   714
		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
   715
		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
   716
		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
   717
			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
   718
			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
   719
			const void *var = ini_get_variable(&sd->save, patches_ptr);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   720
			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
   721
			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
   722
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   723
			// 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
   724
			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
   725
			if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) 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
   726
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
   727
			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
   728
				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
   729
				/* 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
   730
				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
   731
3124
cf624337b649 (svn r3732) - Fix two warnings. Stupid MSVC didn't even complain :s (Thank Tron and peter1138)
Darkvater
parents: 3121
diff changeset
   732
				DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : 0);
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
   733
				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
   734
			} 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
   735
				int32 value;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   736
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
   737
				/* Draw [<][>] boxes for settings of an integer-type */
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
   738
				DrawArrowButtons(x, y, 3, WP(w,def_d).data_2 - (i * 2), editable);
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
   739
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
   740
				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
   741
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
   742
				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
   743
				if (disabled) {
534
306bc86eb23e (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   744
					SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   745
				} 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
   746
					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
   747
						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
   748
					} 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
   749
						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
   750
					} 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
   751
						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
   752
					}
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
   753
					SetDParam(1, value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   754
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   755
			}
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
   756
			DrawString(30, y, (sdb->str) + disabled, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   757
			y += 11;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   758
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   759
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   760
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   761
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   762
	case WE_CLICK:
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2916
diff changeset
   763
		switch (e->click.widget) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   764
		case 3: {
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
   765
			const PatchPage *page = &_patches_page[WP(w,def_d).data_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
   766
			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
   767
			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
   768
			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
   769
			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
   770
			byte btn;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   771
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   772
			y = e->click.pt.y - 46 - 1;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   773
			if (y < 0) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   774
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   775
			x = e->click.pt.x - 5;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   776
			if (x < 0) return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   777
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
   778
			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
   779
			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
   780
			if (btn >= page->num) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   781
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
   782
			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
   783
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
   784
			/* return if action is only active in network, or only settable by server */
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
   785
			if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) 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
   786
			if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) 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
   787
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
   788
			var = ini_get_variable(&sd->save, 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
   789
			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
   790
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
   791
			/* 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
   792
			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
   793
				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
   794
				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
   795
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
   796
				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
   797
				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
   798
				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
   799
					/* Add a dynamic step-size to the scroller. In a maximum of
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
   800
					 * 50-steps you should be able to get from min to max */
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
   801
					uint32 step = ((sdb->max - sdb->min) / 50);
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
   802
					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
   803
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   804
					// don't allow too fast scrolling
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   805
					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
   806
						_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   807
						return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   808
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   809
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
   810
					/* 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
   811
					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
   812
						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
   813
						if (value > sdb->max) value = sdb->max;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   814
					} 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
   815
						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
   816
						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
   817
					}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   818
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
   819
					/* Set up scroller timeout */
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
   820
					if (value != oldvalue) {
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
   821
						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
   822
						w->flags4 |= 5 << WF_TIMEOUT_SHL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   823
						_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   824
					}
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
   825
				} 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
   826
				default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   827
				}
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
   828
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
   829
				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
   830
					SetPatchValue(page->entries[btn].index, patches_ptr, value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   831
					SetWindowDirty(w);
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
   832
					if (sdb->proc != NULL) sdb->proc((int32)ReadValue(var, sd->save.conv));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   833
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   834
			} 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
   835
				/* 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
   836
				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
   837
					/* 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
   838
					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
   839
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   840
					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
   841
					SetDParam(0, value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   842
					ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, WC_GAME_OPTIONS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   843
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   844
			}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   845
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   846
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   847
		}
21
67cde01e8359 (svn r22) Add: Competitors menu under patches
truelight
parents: 20
diff changeset
   848
		case 4: case 5: case 6: case 7: case 8: case 9:
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   849
			WP(w,def_d).data_1 = e->click.widget - 4;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   850
			DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   851
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   852
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   853
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   854
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   855
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   856
	case WE_TIMEOUT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   857
		WP(w,def_d).data_2 = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   858
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   859
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   860
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   861
	case WE_ON_EDIT_TEXT: {
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
   862
		if (e->edittext.str != NULL) {
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
   863
			const PatchEntry *pe = &_patches_page[WP(w,def_d).data_1].entries[WP(w,def_d).data_3];
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
			const SettingDesc *sd = pe->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
   865
			void *var = ini_get_variable(&sd->save, 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
   866
			int32 value = atoi(e->edittext.str);
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
   867
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
   868
			/* 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
   869
			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
   870
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
   871
			SetPatchValue(pe->index, patches_ptr, value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   872
			SetWindowDirty(w);
68
4051f3c8efa2 (svn r69) -Feature: align toolbar left/center/right patch (TrueLight)
darkvater
parents: 67
diff changeset
   873
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
   874
			if (sd->desc.proc != NULL) sd->desc.proc((int32)ReadValue(var, sd->save.conv));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   875
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   876
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   877
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   878
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   879
	case WE_DESTROY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   880
		DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   881
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   882
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   883
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   884
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   885
static const Widget _patches_selection_widgets[] = {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   886
{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,												STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   887
{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_CONFIG_PATCHES_CAPTION,			STR_018C_WINDOW_TITLE_DRAG_THIS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
   888
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,															STR_NULL},
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3888
diff changeset
   889
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   360, 0x0,															STR_NULL},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   890
2725
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   891
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_CONFIG_PATCHES_GUI,					STR_NULL},
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   892
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_CONFIG_PATCHES_CONSTRUCTION,	STR_NULL},
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   893
{    WWT_TEXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_CONFIG_PATCHES_VEHICLES,			STR_NULL},
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   894
{    WWT_TEXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_CONFIG_PATCHES_STATIONS,			STR_NULL},
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   895
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    28,    39, STR_CONFIG_PATCHES_ECONOMY,			STR_NULL},
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
   896
{    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
   897
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   898
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   899
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   900
static const WindowDesc _patches_selection_desc = {
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3888
diff changeset
   901
	WDP_CENTER, WDP_CENTER, 370, 361,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   902
	WC_GAME_OPTIONS,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   903
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   904
	_patches_selection_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   905
	PatchesSelectionWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   906
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   907
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
   908
void ShowPatchesSelection(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   909
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   910
	DeleteWindowById(WC_GAME_OPTIONS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   911
	AllocateWindowDesc(&_patches_selection_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   912
}
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
   913
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   914
enum {
502
defb8fd8fc98 (svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents: 486
diff changeset
   915
	NEWGRF_WND_PROC_OFFSET_TOP_WIDGET = 14,
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   916
	NEWGRF_WND_PROC_ROWSIZE = 14
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   917
};
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
   918
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
   919
static void NewgrfWndProc(Window *w, WindowEvent *e)
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
   920
{
1741
628182f1bbd2 (svn r2245) - CodeChange: simplify the clamping of values for patch-settings by using clamp()
Darkvater
parents: 1739
diff changeset
   921
	static GRFFile *_sel_grffile;
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   922
	switch (e->event) {
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
   923
	case WE_PAINT: {
502
defb8fd8fc98 (svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents: 486
diff changeset
   924
		int x, y = NEWGRF_WND_PROC_OFFSET_TOP_WIDGET;
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   925
		uint16 i = 0;
1477
9389baf2bf3c (svn r1981) Typedef some structs and enums
tron
parents: 1385
diff changeset
   926
		GRFFile *c = _first_grffile;
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
   927
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
   928
		DrawWindowWidgets(w);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   929
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   930
		if (_first_grffile == NULL) { // no grf sets installed
502
defb8fd8fc98 (svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents: 486
diff changeset
   931
			DrawStringMultiCenter(140, 210, STR_NEWGRF_NO_FILES_INSTALLED, 250);
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
   932
			break;
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
   933
		}
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
   934
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
   935
		// draw list of all grf files
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   936
		while (c != NULL) {
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   937
			if (i >= w->vscroll.pos) { // draw files according to scrollbar position
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   938
				bool h = (_sel_grffile == c);
502
defb8fd8fc98 (svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents: 486
diff changeset
   939
				// show highlighted item with a different background and highlighted text
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   940
				if (h) GfxFillRect(1, y + 1, 267, y + 12, 156);
502
defb8fd8fc98 (svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents: 486
diff changeset
   941
				// XXX - will be grf name later
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   942
				DoDrawString(c->filename, 25, y + 2, h ? 0xC : 0x10);
2187
a0e206ce9fbf (svn r2702) -Codechange: Cleaned up the sprite code and replaced many magic numbers
celestar
parents: 2186
diff changeset
   943
				DrawSprite(SPRITE_PALETTE(SPR_SQUARE | PALETTE_TO_RED), 5, y + 2);
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   944
				y += NEWGRF_WND_PROC_ROWSIZE;
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
   945
			}
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   946
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   947
			c = c->next;
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   948
			if (++i == w->vscroll.cap + w->vscroll.pos) break; // stop after displaying 12 items
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
   949
		}
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
   950
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
   951
// 		DoDrawString(_sel_grffile->setname, 120, 200, 0x01); // draw grf name
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
   952
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   953
		if (_sel_grffile == NULL) { // no grf file selected yet
502
defb8fd8fc98 (svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents: 486
diff changeset
   954
			DrawStringMultiCenter(140, 210, STR_NEWGRF_TIP, 250);
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
   955
		} else {
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
   956
			// draw filename
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   957
			x = DrawString(5, 199, STR_NEWGRF_FILENAME, 0);
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   958
			DoDrawString(_sel_grffile->filename, x + 2, 199, 0x01);
543
946badd71033 (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   959
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
   960
			// draw grf id
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   961
			x = DrawString(5, 209, STR_NEWGRF_GRF_ID, 0);
3711
431475cbb208 (svn r4654) - Fix [NewGRF]: Properly read in the GRFID. This fixes GRFID checking and activation/deactivation. Do swap the GRFID for displaying purposes.
Darkvater
parents: 3596
diff changeset
   962
			snprintf(_userstring, lengthof(_userstring), "%08X", BSWAP32(_sel_grffile->grfid));
486
e81a0c19c503 (svn r768) In the NewGRF manager, show GRF ids as 8-digit hex numbers (that's how they are supposed to look).
pasky
parents: 484
diff changeset
   963
			DrawString(x + 2, 209, STR_SPEC_USERSTRING, 0x01);
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
   964
		}
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   965
	} break;
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
   966
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
   967
	case WE_CLICK:
2952
58522ed8f0f1 (svn r3511) More whitespace ([FS#46] by Rubidium)
tron
parents: 2916
diff changeset
   968
		switch (e->click.widget) {
982
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 970
diff changeset
   969
		case 3: { // select a grf file
502
defb8fd8fc98 (svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents: 486
diff changeset
   970
			int y = (e->click.pt.y - NEWGRF_WND_PROC_OFFSET_TOP_WIDGET) / NEWGRF_WND_PROC_ROWSIZE;
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
   971
2549
5587f9a38563 (svn r3078) Some more stuff, which piled up:
tron
parents: 2548
diff changeset
   972
			if (y >= w->vscroll.cap) return; // click out of bounds
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
   973
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   974
			y += w->vscroll.pos;
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   975
2766
3a33fe670d29 (svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents: 2749
diff changeset
   976
			if (y >= w->vscroll.count) return;
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
   977
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
   978
			_sel_grffile = _first_grffile;
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   979
			// get selected grf-file
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   980
			while (y-- != 0) _sel_grffile = _sel_grffile->next;
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   981
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
   982
			SetWindowDirty(w);
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   983
		} break;
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
   984
		case 9: /* Cancel button */
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
   985
			DeleteWindowById(WC_GAME_OPTIONS, 0);
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
   986
			break;
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
   987
		} break;
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
   988
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
   989
/* Parameter edit box not used yet
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
   990
	case WE_TIMEOUT:
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
   991
		WP(w,def_d).data_2 = 0;
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
   992
		SetWindowDirty(w);
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
   993
		break;
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
   994
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
   995
	case WE_ON_EDIT_TEXT: {
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
   996
		if (*e->edittext.str) {
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
   997
			SetWindowDirty(w);
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
   998
		}
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
   999
		break;
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
  1000
	}
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
  1001
*/
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
  1002
	case WE_DESTROY:
502
defb8fd8fc98 (svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents: 486
diff changeset
  1003
		_sel_grffile = NULL;
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
  1004
		DeleteWindowById(WC_QUERY_STRING, 0);
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
  1005
		break;
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
  1006
	}
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
  1007
}
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
  1008
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
  1009
static const Widget _newgrf_widgets[] = {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1010
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,										STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1011
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   279,     0,    13, STR_NEWGRF_SETTINGS_CAPTION,	STR_018C_WINDOW_TITLE_DRAG_THIS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1012
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   279,   183,   276, 0x0,													STR_NULL},
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
  1013
982
d3ce4d6a65f8 (svn r1478) -Fix: [1099195] mouse-wheel in train replace window. Scrollbar1 and Scrollbar2 now work independently. You can only scroll on list and scrollbar itself; scrollbar must be next widget of the list.
darkvater
parents: 970
diff changeset
  1014
{     WWT_MATRIX,   RESIZE_NONE,    14,     0,   267,    14,   182, 0xC01,/*small rows*/					STR_NEWGRF_TIP},
893
f4698309dec7 (svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents: 871
diff changeset
  1015
{  WWT_SCROLLBAR,   RESIZE_NONE,    14,   268,   279,    14,   182, 0x0,													STR_0190_SCROLL_BAR_SCROLLS_LIST},
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
  1016
2725
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
  1017
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   147,   158,   244,   255, STR_0188,	STR_NULL},
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
  1018
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   159,   170,   244,   255, STR_0189,	STR_NULL},
775e3e14ca46 (svn r3270) Correct all (mis)uses of WWT_CLOSEBOX / WWT_TEXTBTN to reflect their actual use, and add "Close Window" tooltip where missing.
peter1138
parents: 2696
diff changeset
  1019
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   175,   274,   244,   255, STR_NEWGRF_SET_PARAMETERS,		STR_NULL},
484
2083d2c44373 (svn r766) -Fix: compilation problems on windows
darkvater
parents: 478
diff changeset
  1020
1015
3629f5e8c092 (svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents: 998
diff changeset
  1021
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,     5,   138,   261,   272, STR_NEWGRF_APPLY_CHANGES,		STR_NULL},
3629f5e8c092 (svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents: 998
diff changeset
  1022
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   142,   274,   261,   272, STR_012E_CANCEL,							STR_NULL},
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
  1023
{   WIDGETS_END},
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
  1024
};
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
  1025
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
  1026
static const WindowDesc _newgrf_desc = {
502
defb8fd8fc98 (svn r801) - re-enabled background highlighting in Newgrf GUI
dominik
parents: 486
diff changeset
  1027
	WDP_CENTER, WDP_CENTER, 280, 277,
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
  1028
	WC_GAME_OPTIONS,0,
1015
3629f5e8c092 (svn r1515) -Removed the 'close ALL windows' from the toolbar since shift+del does this.
darkvater
parents: 998
diff changeset
  1029
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
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
  1030
	_newgrf_widgets,
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
  1031
	NewgrfWndProc,
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
  1032
};
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
  1033
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
  1034
void ShowNewgrf(void)
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
  1035
{
2766
3a33fe670d29 (svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents: 2749
diff changeset
  1036
	const GRFFile* c;
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
  1037
	Window *w;
2766
3a33fe670d29 (svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents: 2749
diff changeset
  1038
	uint count;
3a33fe670d29 (svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents: 2749
diff changeset
  1039
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
  1040
	DeleteWindowById(WC_GAME_OPTIONS, 0);
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
  1041
	w = AllocateWindowDesc(&_newgrf_desc);
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
  1042
2766
3a33fe670d29 (svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents: 2749
diff changeset
  1043
	count = 0;
3a33fe670d29 (svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents: 2749
diff changeset
  1044
	for (c = _first_grffile; c != NULL; c = c->next) count++;
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
  1045
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
  1046
	w->vscroll.cap = 12;
2766
3a33fe670d29 (svn r3311) Remove the unnecessary global variable _grffile_count: It's just the scroll count of a list and furthermore only used in one file
tron
parents: 2749
diff changeset
  1047
	w->vscroll.count = count;
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
  1048
	w->vscroll.pos = 0;
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
  1049
	w->disabled_state = (1 << 5) | (1 << 6) | (1 << 7);
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
  1050
}
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
  1051
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
  1052
/** Draw [<][>] boxes
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
  1053
 * state: 0 = none clicked, 1 = first clicked, 2 = second clicked */
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
  1054
void DrawArrowButtons(int x, int y, int ctab, byte state, bool enabled)
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1055
{
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
  1056
	DrawFrameRect(x,    y+1, x + 9, y+9, ctab, (state == 1) ? FR_LOWERED : 0);
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
  1057
	DrawFrameRect(x+10, y+1, x +19, y+9, ctab, (state == 2) ? FR_LOWERED : 0);
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
  1058
	DrawStringCentered(x+ 5, y+1, STR_6819, 0); // [<]
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
  1059
	DrawStringCentered(x+15, y+1, STR_681A, 0); // [>]
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
  1060
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
  1061
	if (!enabled) {
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
  1062
		int color = PALETTE_MODIFIER_GREYOUT | _color_list[3].unk2;
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
  1063
		GfxFillRect(x+ 1, y+1, x+ 1+8, y+8, color);
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
  1064
		GfxFillRect(x+11, y+1, x+11+8, y+8, color);
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
  1065
	}
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1066
}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1067
2307
484c654dc875 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
  1068
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
  1069
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1070
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
  1071
{
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1072
	switch (e->event) {
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1073
	case WE_PAINT: {
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1074
		int x=35, y=20, i=0;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1075
		int clk = WP(w,def_d).data_1;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1076
		DrawWindowWidgets(w);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1077
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1078
		// exchange rate
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
  1079
		DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1080
		SetDParam(0, 1);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1081
		SetDParam(1, 1);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1082
		DrawString(x, y + 1, STR_CURRENCY_EXCHANGE_RATE, 0);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1083
		x = 35;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1084
		y+=12;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1085
		i++;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1086
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1087
		// separator
1938
70baf462aff1 (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
  1088
		DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03) ? FR_LOWERED : 0);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1089
		x = DrawString(x, y + 1, STR_CURRENCY_SEPARATOR, 0);
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
  1090
		DoDrawString(_str_separator, x + 4, y + 1, 6);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1091
		x = 35;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1092
		y+=12;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1093
		i++;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1094
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1095
		// prefix
1938
70baf462aff1 (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
  1096
		DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03) ? FR_LOWERED : 0);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1097
		x = DrawString(x, y + 1, STR_CURRENCY_PREFIX, 0);
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
  1098
		DoDrawString(_custom_currency.prefix, x + 4, y + 1, 6);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1099
		x = 35;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1100
		y+=12;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1101
		i++;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1102
788
951b52443d48 (svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents: 776
diff changeset
  1103
		// suffix
1938
70baf462aff1 (svn r2444) - CodeChange: Add an enum for demagicifying the values of the 'flags' parameter of DrawFrameRect(). (_Abraxa_)
hackykid
parents: 1891
diff changeset
  1104
		DrawFrameRect(10, y+1, 29, y+9, 0, ((clk >> (i*2)) & 0x03) ? FR_LOWERED : 0);
788
951b52443d48 (svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents: 776
diff changeset
  1105
		x = DrawString(x, y + 1, STR_CURRENCY_SUFFIX, 0);
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
  1106
		DoDrawString(_custom_currency.suffix, x + 4, y + 1, 6);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1107
		x = 35;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1108
		y+=12;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1109
		i++;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1110
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1111
		// switch to euro
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
  1112
		DrawArrowButtons(10, y, 3, (clk >> (i*2)) & 0x03, true);
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
  1113
		SetDParam(0, _custom_currency.to_euro);
adb71c055afb (svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents: 2293
diff changeset
  1114
		DrawString(x, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, 0);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1115
		x = 35;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1116
		y+=12;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1117
		i++;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1118
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1119
		// Preview
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1120
		y+=12;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1121
		SetDParam(0, 10000);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1122
		DrawString(x, y + 1, STR_CURRENCY_PREVIEW, 0);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1123
	} break;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1124
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1125
	case WE_CLICK: {
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1126
		bool edittext = false;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1127
		int line = (e->click.pt.y - 20)/12;
776
5b14f0b1e6d3 (svn r1242) -Fix: fix some morhpos warnings (tokai)
darkvater
parents: 759
diff changeset
  1128
		int len = 0;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1129
		int x = e->click.pt.x;
776
5b14f0b1e6d3 (svn r1242) -Fix: fix some morhpos warnings (tokai)
darkvater
parents: 759
diff changeset
  1130
		StringID str = 0;
759
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 ( line ) {
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1133
			case 0: // rate
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1134
				if ( IS_INT_INSIDE(x, 10, 30) ) { // clicked buttons
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1135
					if (x < 20) {
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
  1136
						if (_custom_currency.rate > 1) _custom_currency.rate--;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1137
						WP(w,def_d).data_1 =  (1 << (line * 2 + 0));
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1138
					} else {
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
  1139
						if (_custom_currency.rate < 5000) _custom_currency.rate++;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1140
						WP(w,def_d).data_1 =  (1 << (line * 2 + 1));
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1141
					}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1142
				} else { // enter text
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
  1143
					SetDParam(0, _custom_currency.rate);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1144
					str = STR_CONFIG_PATCHES_INT32;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1145
					len = 4;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1146
					edittext = true;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1147
				}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1148
			break;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1149
			case 1: // separator
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1150
				if ( IS_INT_INSIDE(x, 10, 30) )  // clicked button
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1151
					WP(w,def_d).data_1 =  (1 << (line * 2 + 1));
2055
4926ed1a7562 (svn r2564) Fix: Fixed conceptual issue in network_gui.c. AllocateName is not meant to be used by GUI-code, because it modifies the "game-state".
ludde
parents: 2044
diff changeset
  1152
				str = BindCString(_str_separator);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1153
				len = 1;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1154
				edittext = true;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1155
			break;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1156
			case 2: // prefix
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1157
				if ( IS_INT_INSIDE(x, 10, 30) )  // clicked button
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1158
					WP(w,def_d).data_1 =  (1 << (line * 2 + 1));
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
  1159
				str = BindCString(_custom_currency.prefix);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1160
				len = 12;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1161
				edittext = true;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1162
			break;
788
951b52443d48 (svn r1255) Renamed "postfix" to "suffix", for strings and variable names
dominik
parents: 776
diff changeset
  1163
			case 3: // suffix
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1164
				if ( IS_INT_INSIDE(x, 10, 30) )  // clicked button
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1165
					WP(w,def_d).data_1 =  (1 << (line * 2 + 1));
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
  1166
				str = BindCString(_custom_currency.suffix);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1167
				len = 12;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1168
				edittext = true;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1169
			break;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1170
			case 4: // to euro
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1171
				if ( IS_INT_INSIDE(x, 10, 30) ) { // clicked buttons
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1172
					if (x < 20) {
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
  1173
						_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ?
adb71c055afb (svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents: 2293
diff changeset
  1174
							CF_NOEURO : _custom_currency.to_euro - 1;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1175
						WP(w,def_d).data_1 = (1 << (line * 2 + 0));
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1176
					} else {
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
  1177
						_custom_currency.to_euro =
adb71c055afb (svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents: 2293
diff changeset
  1178
							clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR_END_REAL);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1179
						WP(w,def_d).data_1 = (1 << (line * 2 + 1));
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1180
					}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1181
				} else { // enter text
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
  1182
					SetDParam(0, _custom_currency.to_euro);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1183
					str = STR_CONFIG_PATCHES_INT32;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1184
					len = 4;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1185
					edittext = true;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1186
				}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1187
			break;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1188
		}
812
65ecc321b3db (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 788
diff changeset
  1189
1756
963d4cd8d3d2 (svn r2260) - Fix (regression): custom currency input works again ingame
Darkvater
parents: 1741
diff changeset
  1190
		if (edittext) {
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1191
			WP(w,def_d).data_2 = line;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1192
			ShowQueryString(
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1193
			str,
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1194
			STR_CURRENCY_CHANGE_PARAMETER,
1756
963d4cd8d3d2 (svn r2260) - Fix (regression): custom currency input works again ingame
Darkvater
parents: 1741
diff changeset
  1195
			len + 1, // maximum number of characters OR
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1196
			250, // characters up to this width pixels, whichever is satisfied first
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1197
			w->window_class,
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1198
			w->window_number);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1199
		}
812
65ecc321b3db (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 788
diff changeset
  1200
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1201
		w->flags4 |= 5 << WF_TIMEOUT_SHL;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1202
		SetWindowDirty(w);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1203
	} break;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1204
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1205
	case WE_ON_EDIT_TEXT: {
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1206
			int val;
1323
bac2e38e8b60 (svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents: 1317
diff changeset
  1207
			const char *b = e->edittext.str;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1208
			switch (WP(w,def_d).data_2) {
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
  1209
				case 0: /* Exchange rate */
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1210
					val = atoi(b);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1211
					val = clamp(val, 1, 5000);
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
  1212
					_custom_currency.rate = val;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1213
					break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1214
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
  1215
				case 1: /* Thousands seperator */
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
  1216
					_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0];
2307
484c654dc875 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
  1217
					ttd_strlcpy(_str_separator, b, lengthof(_str_separator));
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1218
					break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1219
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
  1220
				case 2: /* Currency prefix */
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
  1221
					ttd_strlcpy(_custom_currency.prefix, b, lengthof(_custom_currency.prefix));
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1222
					break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1223
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
  1224
				case 3: /* Currency suffix */
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
  1225
					ttd_strlcpy(_custom_currency.suffix, b, lengthof(_custom_currency.suffix));
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1226
					break;
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1227
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
  1228
				case 4: /* Year to switch to euro */
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1229
					val = atoi(b);
970
24abd02b1092 (svn r1465) -Fix: [1099101] starting year patch goes out of range. Clamped year between 1920-2090 as wel as adding defines for it.
darkvater
parents: 959
diff changeset
  1230
					val = clamp(val, 1999, MAX_YEAR_END_REAL);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1231
					if (val == 1999) val = 0;
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
  1232
					_custom_currency.to_euro = val;
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1233
					break;
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1234
			}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1235
		MarkWholeScreenDirty();
812
65ecc321b3db (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 788
diff changeset
  1236
65ecc321b3db (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 788
diff changeset
  1237
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1238
	} break;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1239
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1240
	case WE_TIMEOUT:
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1241
		WP(w,def_d).data_1 = 0;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1242
		SetWindowDirty(w);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1243
		break;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1244
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1245
	case WE_DESTROY:
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1246
		DeleteWindowById(WC_QUERY_STRING, 0);
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1247
		MarkWholeScreenDirty();
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1248
		break;
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1249
	}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1250
}
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1251
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1252
static const Widget _cust_currency_widgets[] = {
867
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1253
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,						STR_018B_CLOSE_WINDOW},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1254
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   229,     0,    13, STR_CURRENCY_WINDOW,	STR_018C_WINDOW_TITLE_DRAG_THIS},
dffd33233237 (svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents: 842
diff changeset
  1255
{      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
  1256
{   WIDGETS_END},
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1257
};
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1258
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1259
static const WindowDesc _cust_currency_desc = {
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1260
	WDP_CENTER, WDP_CENTER, 230, 120,
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1261
	WC_CUSTOM_CURRENCY, 0,
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1262
	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
  1263
	_cust_currency_widgets,
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1264
	CustCurrencyWndProc,
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1265
};
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1266
2817
cdf488223c23 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
  1267
static void ShowCustCurrency(void)
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1268
{
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
  1269
	_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
  1270
	_str_separator[1] = '\0';
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1271
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1272
	DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
2639
eeaefdabfdfd (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1273
	AllocateWindowDesc(&_cust_currency_desc);
759
a445474d7c21 (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1274
}