src/settings_gui.cpp
author celestar
Mon, 15 Jan 2007 20:14:06 +0000
branchcustombridgeheads
changeset 5650 aefc131bf5ce
parent 5649 55c8267c933f
child 5852 cb3f71b16e1a
permissions -rw-r--r--
(svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1806
diff changeset
     4
#include "openttd.h"
2291
2b064aa97f91 (svn r2815) Store the currency information in one central place instead of scattering it in several unrelated files
tron
parents: 2231
diff changeset
     5
#include "currency.h"
2163
637ec3c361f5 (svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents: 2159
diff changeset
     6
#include "functions.h"
1317
f382f1b439c7 (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
dab90d4cbf2d (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
01d3de5d8039 (svn r1867) Include tables/sprites.h only in files which need it
tron
parents: 1323
diff changeset
     9
#include "table/sprites.h"
507
8aa8100b0b22 (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
75820dedf4f1 (svn r631) Merge r440, r444, r485, r630 to trunk:
tron
parents: 350
diff changeset
    16
#include "screenshot.h"
478
19987403ee5d (svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents: 430
diff changeset
    17
#include "newgrf.h"
5642
bfa6074e2833 (svn r7789) [cbh] - Sync with r7720:7758 from trunk
celestar
parents: 5623
diff changeset
    18
#include "network/network.h"
835
a22d6bc16a51 (svn r1312) -Add: Patch which is on by default: population in label of the town
truelight
parents: 833
diff changeset
    19
#include "town.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2140
diff changeset
    20
#include "variables.h"
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
    21
#include "settings.h"
3577
9e345c932ba2 (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"
4261
2ec8f5a9747b (svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents: 4211
diff changeset
    23
#include "date.h"
5650
aefc131bf5ce (svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents: 5649
diff changeset
    24
#include "helpers.hpp"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
static uint32 _difficulty_click_a;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
static uint32 _difficulty_click_b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
static byte _difficulty_timeout;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    30
static const StringID _units_dropdown[] = {
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    31
	STR_UNITS_IMPERIAL,
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    32
	STR_UNITS_METRIC,
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
    33
	STR_UNITS_SI,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
	INVALID_STRING_ID
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
static const StringID _driveside_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
	STR_02E9_DRIVE_ON_LEFT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
	STR_02EA_DRIVE_ON_RIGHT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
	INVALID_STRING_ID
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    41
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    42
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
static const StringID _autosave_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    44
	STR_02F7_OFF,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    45
	STR_AUTOSAVE_1_MONTH,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    46
	STR_02F8_EVERY_3_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    47
	STR_02F9_EVERY_6_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    48
	STR_02FA_EVERY_12_MONTHS,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    49
	INVALID_STRING_ID,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    50
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    51
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    52
static const StringID _designnames_dropdown[] = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    53
	STR_02BE_DEFAULT,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    54
	STR_02BF_CUSTOM,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
	INVALID_STRING_ID
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    56
};
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 *BuildDynamicDropdown(StringID base, int num)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    60
	static StringID buf[32 + 1];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
	StringID *p = buf;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    62
	while (--num>=0) *p++ = base++;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
	*p = INVALID_STRING_ID;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
	return buf;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
    67
static int GetCurRes(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
	int i;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    70
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    71
	for (i = 0; i != _num_resolutions; i++) {
306
c44133836566 (svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
darkvater
parents: 298
diff changeset
    72
		if (_resolutions[i][0] == _screen.width &&
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    73
				_resolutions[i][1] == _screen.height) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
			break;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    75
		}
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    76
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
	return i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
    80
static inline bool RoadVehiclesAreBuilt(void)
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
    81
{
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    82
	const Vehicle* v;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
    83
915
013cb2d74800 (svn r1402) Trim trailing whitespace
tron
parents: 893
diff changeset
    84
	FOR_ALL_VEHICLES(v) {
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
    85
		if (v->type == VEH_Road) return true;
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
    86
	}
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
    87
	return false;
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
    88
}
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
    89
2817
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
    90
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
    91
static void ShowCustCurrency(void);
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
    92
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
static void GameOptionsWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
{
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
    95
	switch (e->event) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	case WE_PAINT: {
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
    97
		int i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
		StringID str = STR_02BE_DEFAULT;
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
    99
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   100
		SetWindowWidgetDisabledState(w, 21, !(_vehicle_design_names & 1));
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   101
		if (!IsWindowWidgetDisabled(w, 21)) str = STR_02BF_CUSTOM;
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   102
		SetDParam(0, str);
4377
0fb9077b8173 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4344
diff changeset
   103
		SetDParam(1, _currency_specs[_opt_ptr->currency].name);
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
   104
		SetDParam(2, STR_UNITS_IMPERIAL + _opt_ptr->units);
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   105
		SetDParam(3, STR_02E9_DRIVE_ON_LEFT + _opt_ptr->road_side);
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   106
		SetDParam(4, STR_TOWNNAME_ORIGINAL_ENGLISH + _opt_ptr->town_name);
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   107
		SetDParam(5, _autosave_dropdown[_opt_ptr->autosave]);
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   108
		SetDParam(6, SPECSTR_LANGUAGE_START + _dynlang.curr);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
		i = GetCurRes();
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   110
		SetDParam(7, i == _num_resolutions ? STR_RES_OTHER : SPECSTR_RESOLUTION_START + i);
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   111
		SetDParam(8, SPECSTR_SCREENSHOT_START + _cur_screenshot_format);
4727
ba5bae41b004 (svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents: 4719
diff changeset
   112
		SetWindowWidgetLoweredState(w, 28, _fullscreen);
298
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   113
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
		DrawWindowWidgets(w);
298
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   115
		DrawString(20, 175, STR_OPTIONS_FULLSCREEN, 0); // fullscreen
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
	}	break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   118
	case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   119
		switch (e->we.click.widget) {
1806
75dc9c737892 (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
   120
		case 4: case 5: /* Setup currencies dropdown */
4377
0fb9077b8173 (svn r6108) -NewGRF Feature: Implement currencies replacment via grf file.
belugas
parents: 4344
diff changeset
   121
			ShowDropDownMenu(w, BuildCurrencyDropdown(), _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
   122
			return;
1806
75dc9c737892 (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
   123
		case 7: case 8: /* Setup distance unit dropdown */
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
   124
			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
   125
			return;
1806
75dc9c737892 (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
   126
		case 10: case 11: { /* Setup road-side dropdown */
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   127
			int i = 0;
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   128
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   129
			/* You can only change the drive side if you are in the menu or ingame with
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   130
			 * no vehicles present. In a networking game only the server can change it */
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   131
			if ((_game_mode != GM_MENU && RoadVehiclesAreBuilt()) || (_networking && !_network_server))
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   132
				i = (-1) ^ (1 << _opt_ptr->road_side); // disable the other value
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   133
1806
75dc9c737892 (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, _driveside_dropdown, _opt_ptr->road_side, 11, i, 0);
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   135
		} return;
1806
75dc9c737892 (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
   136
		case 13: case 14: { /* Setup townname dropdown */
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   137
			int i = _opt_ptr->town_name;
1806
75dc9c737892 (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, 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
   139
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
		}
1806
75dc9c737892 (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
		case 16: case 17: /* Setup autosave dropdown */
75dc9c737892 (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
   142
			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
   143
			return;
1806
75dc9c737892 (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
   144
		case 19: case 20: /* Setup customized vehicle-names dropdown */
75dc9c737892 (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
			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
   146
			return;
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   147
		case 21: /* Save customized vehicle-names to disk */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   148
			return;
1806
75dc9c737892 (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
		case 23: case 24: /* Setup interface language dropdown */
75dc9c737892 (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
   150
			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
   151
			return;
1806
75dc9c737892 (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
   152
		case 26: case 27: /* Setup resolution dropdown */
75dc9c737892 (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
   153
			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
   154
			return;
298
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   155
		case 28: /* Click fullscreen on/off */
4727
ba5bae41b004 (svn r6639) -CodeChange : Conversion of SetWidgetLoweredState to SetWindowWidgetLoweredState, in order to follow pre-established standard
belugas
parents: 4719
diff changeset
   156
			SetWindowWidgetLoweredState(w, 28, !_fullscreen);
298
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   157
			ToggleFullScreen(!_fullscreen); // toggle full-screen on/off
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   158
			SetWindowDirty(w);
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   159
			return;
1806
75dc9c737892 (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
   160
		case 30: case 31: /* Setup screenshot format dropdown */
75dc9c737892 (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
   161
			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
   162
			return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   163
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   164
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   166
	case WE_DROPDOWN_SELECT:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   167
		switch (e->we.dropdown.button) {
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   168
		case 20: /* Vehicle design names */
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   169
			if (e->we.dropdown.index == 0) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
				DeleteCustomEngineNames();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   171
				MarkWholeScreenDirty();
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   172
			} else if (!(_vehicle_design_names & 1)) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   173
				LoadCustomEngineNames();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   174
				MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
			break;
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   177
		case 5: /* Currency */
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   178
			if (e->we.dropdown.index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   179
			_opt_ptr->currency = e->we.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;
3342
0de5e6997611 (svn r4126) - Feature: A new multi-lingual multi-measuring-unit system:
peter1138
parents: 3247
diff changeset
   182
		case 8: /* Measuring units */
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   183
			_opt_ptr->units = e->we.dropdown.index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
			MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
			break;
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   186
		case 11: /* Road side */
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   187
			if (_opt_ptr->road_side != e->we.dropdown.index) { // only change if setting changed
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   188
				DoCommandP(0, e->we.dropdown.index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
1113
8c4c1e1ba4c5 (svn r1614) Fix: Signals were not updated correctly when the vehicle drive side was changed
dominik
parents: 1095
diff changeset
   189
				MarkWholeScreenDirty();
8c4c1e1ba4c5 (svn r1614) Fix: Signals were not updated correctly when the vehicle drive side was changed
dominik
parents: 1095
diff changeset
   190
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   191
			break;
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   192
		case 14: /* Town names */
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   193
			if (_game_mode == GM_MENU) {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   194
				_opt_ptr->town_name = e->we.dropdown.index;
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   195
				InvalidateWindow(WC_GAME_OPTIONS, 0);
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   196
			}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   197
			break;
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   198
		case 17: /* Autosave options */
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   199
			_opt.autosave = _opt_newgame.autosave = e->we.dropdown.index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
			break;
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   202
		case 24: /* Change interface language */
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   203
			ReadLanguagePack(e->we.dropdown.index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   204
			MarkWholeScreenDirty();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   205
			break;
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   206
		case 27: /* Change resolution */
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   207
			if (e->we.dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->we.dropdown.index][0],_resolutions[e->we.dropdown.index][1]))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
				SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   209
			break;
871
63d7f79199ec (svn r1352) -Fix: [1093200] Drive side in new games. Setting the driver side is possible during the game until someone buys road vehicles. In networked games only the server can change it.
darkvater
parents: 867
diff changeset
   210
		case 31: /* Change screenshot format */
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   211
			SetScreenshotFormat(e->we.dropdown.index);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   212
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   215
		break;
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   216
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   217
	case WE_DESTROY:
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   218
		DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   219
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
	}
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   221
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   224
/** Change the side of the road vehicles drive on (server only).
3491
4c8427796c64 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3342
diff changeset
   225
 * @param tile unused
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   226
 * @param p1 the side of the road; 0 = left side and 1 = right side
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   227
 * @param p2 unused
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   228
 */
3491
4c8427796c64 (svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents: 3342
diff changeset
   229
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
   230
{
1803
24a94314cfa9 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents: 1796
diff changeset
   231
	/* Check boundaries and you can only change this if NO vehicles have been built yet,
24a94314cfa9 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents: 1796
diff changeset
   232
	 * except in the intro-menu where of course it's always possible to do so. */
24a94314cfa9 (svn r2307) - Fix (regression): it was not possible to change the drive-side in the intro-game.
Darkvater
parents: 1796
diff changeset
   233
	if (p1 > 1 || (_game_mode != GM_MENU && RoadVehiclesAreBuilt())) return CMD_ERROR;
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   234
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
	if (flags & DC_EXEC) {
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   236
		_opt_ptr->road_side = p1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
		InvalidateWindow(WC_GAME_OPTIONS,0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
	return 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   242
static const Widget _game_options_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   243
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,                          STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   244
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   369,     0,    13, STR_00B1_GAME_OPTIONS,             STR_018C_WINDOW_TITLE_DRAG_THIS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   245
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   369,    14,   238, 0x0,                               STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   246
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,    20,    55, STR_02E0_CURRENCY_UNITS,           STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   247
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,    34,    45, STR_02E1,                          STR_02E2_CURRENCY_UNITS_SELECTION},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   248
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,    35,    44, STR_0225,                          STR_02E2_CURRENCY_UNITS_SELECTION},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   249
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,    20,    55, STR_MEASURING_UNITS,               STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   250
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,    34,    45, STR_02E4,                          STR_MEASURING_UNITS_SELECTION},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   251
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   338,   348,    35,    44, STR_0225,                          STR_MEASURING_UNITS_SELECTION},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   252
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,    62,    97, STR_02E6_ROAD_VEHICLES,            STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   253
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,    76,    87, STR_02E7,                          STR_02E8_SELECT_SIDE_OF_ROAD_FOR},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   254
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,    77,    86, STR_0225,                          STR_02E8_SELECT_SIDE_OF_ROAD_FOR},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   255
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,    62,    97, STR_02EB_TOWN_NAMES,               STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   256
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,    76,    87, STR_02EC,                          STR_02ED_SELECT_STYLE_OF_TOWN_NAMES},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   257
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   338,   348,    77,    86, STR_0225,                          STR_02ED_SELECT_STYLE_OF_TOWN_NAMES},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   258
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,   104,   139, STR_02F4_AUTOSAVE,                 STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   259
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,   118,   129, STR_02F5,                          STR_02F6_SELECT_INTERVAL_BETWEEN},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   260
{    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
   261
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   262
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   359,   194,   228, STR_02BC_VEHICLE_DESIGN_NAMES,     STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   263
{      WWT_INSET,   RESIZE_NONE,    14,    20,   119,   207,   218, STR_02BD,                          STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   264
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   108,   118,   208,   217, STR_0225,                          STR_02C1_VEHICLE_DESIGN_NAMES_SELECTION},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   265
{    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
   266
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   267
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,   104,   139, STR_OPTIONS_LANG,                  STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   268
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,   118,   129, STR_OPTIONS_LANG_CBO,              STR_OPTIONS_LANG_TIP},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   269
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   338,   348,   119,   128, STR_0225,                          STR_OPTIONS_LANG_TIP},
298
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   270
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   271
{      WWT_FRAME,   RESIZE_NONE,    14,    10,   179,   146,   190, STR_OPTIONS_RES,                   STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   272
{      WWT_INSET,   RESIZE_NONE,    14,    20,   169,   160,   171, STR_OPTIONS_RES_CBO,               STR_OPTIONS_RES_TIP},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   273
{    WWT_TEXTBTN,   RESIZE_NONE,    14,   158,   168,   161,   170, STR_0225,                          STR_OPTIONS_RES_TIP},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   274
{    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
   275
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   276
{      WWT_FRAME,   RESIZE_NONE,    14,   190,   359,   146,   190, STR_OPTIONS_SCREENSHOT_FORMAT,     STR_NULL},
4939
ede0f6777b3c (svn r6926) -Codechange: Rename WWT_4 to WWT_TEXTBTN_2 and WWT_6 to WWT_INSET (credits to peter1138
Darkvater
parents: 4870
diff changeset
   277
{      WWT_INSET,   RESIZE_NONE,    14,   200,   349,   160,   171, STR_OPTIONS_SCREENSHOT_FORMAT_CBO, STR_OPTIONS_SCREENSHOT_FORMAT_TIP},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   278
{    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
   279
176
84990c4b9212 (svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents: 164
diff changeset
   280
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
static const WindowDesc _game_options_desc = {
298
b3e83b94be19 (svn r304) -Fix: [967096] fullscreen. New button 'Fullscreen' in 'Game Options' menu which lets you set fullscreen ingame.
darkvater
parents: 193
diff changeset
   284
	WDP_CENTER, WDP_CENTER, 370, 239,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   285
	WC_GAME_OPTIONS,0,
2064
c889fcc76398 (svn r2573) Codechange: Removed WDF_RESTORE_DPARAM, it's not needed with the new string system.
ludde
parents: 2055
diff changeset
   286
	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
   287
	_game_options_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
	GameOptionsWndProc
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
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   291
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
   292
void ShowGameOptions(void)
0
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
	DeleteWindowById(WC_GAME_OPTIONS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   295
	AllocateWindowDesc(&_game_options_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
typedef struct {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   299
	int16 min;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
	int16 max;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   301
	int16 step;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
	StringID str;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
} GameSettingData;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
static const GameSettingData _game_setting_info[] = {
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   306
	{  0,   7,  1, STR_NULL},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   307
	{  0,   3,  1, STR_6830_IMMEDIATE},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   308
	{  0,   2,  1, STR_6816_LOW},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   309
	{  0,   3,  1, STR_26816_NONE},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   310
	{100, 500, 50, STR_NULL},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   311
	{  2,   4,  1, STR_NULL},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   312
	{  0,   2,  1, STR_6820_LOW},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   313
	{  0,   4,  1, STR_681B_VERY_SLOW},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   314
	{  0,   2,  1, STR_6820_LOW},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   315
	{  0,   2,  1, STR_6823_NONE},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   316
	{  0,   3,  1, STR_6826_X1_5},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   317
	{  0,   2,  1, STR_6820_LOW},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   318
	{  0,   3,  1, STR_682A_VERY_FLAT},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   319
	{  0,   3,  1, STR_VERY_LOW},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   320
	{  0,   1,  1, STR_682E_STEADY},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   321
	{  0,   1,  1, STR_6834_AT_END_OF_LINE_AND_AT_STATIONS},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   322
	{  0,   1,  1, STR_6836_OFF},
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   323
	{  0,   2,  1, STR_6839_PERMISSIVE},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   324
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   325
536
aef4753985d3 (svn r907) Sprinkle holy ANSI water:
tron
parents: 534
diff changeset
   326
static inline bool GetBitAndShift(uint32 *b)
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
	uint32 x = *b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   329
	*b >>= 1;
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   330
	return HASBIT(x, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   331
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   332
1385
324d3d06a930 (svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents: 1363
diff changeset
   333
/*
4549
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   334
 * A: competitors
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   335
 * B: start time in months / 3
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   336
 * C: town count (2 = high, 0 = low)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   337
 * D: industry count (3 = high, 0 = none)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   338
 * E: inital loan / 1000 (in GBP)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   339
 * F: interest rate
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   340
 * G: running costs (0 = low, 2 = high)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   341
 * H: construction speed of competitors (0 = very slow, 4 = very fast)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   342
 * I: intelligence (0-2)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   343
 * J: breakdowns (0 = off, 2 = normal)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   344
 * K: subsidy multiplier (0 = 1.5, 3 = 4.0)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   345
 * L: construction cost (0-2)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   346
 * M: terrain type (0 = very flat, 3 = mountainous)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   347
 * N: amount of water (0 = very low, 3 = high)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   348
 * O: economy (0 = steady, 1 = fluctuating)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   349
 * P: Train reversing (0 = end of line + stations, 1 = end of line)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   350
 * Q: disasters
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   351
 * R: area restructuring (0 = permissive, 2 = hostile)
60410aa1aa88 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 4488
diff changeset
   352
 */
1385
324d3d06a930 (svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents: 1363
diff changeset
   353
static const int16 _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /*
324d3d06a930 (svn r1889) -Fix: [ 1108637 ] 'Play scenario' now loads game options and difficulty, 'Load game' starts game with user-selected values.
celestar
parents: 1363
diff changeset
   354
	 A, B, C, D,   E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   355
	{2, 2, 1, 3, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, //easy
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   356
	{4, 1, 1, 2, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, //medium
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   357
	{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
   358
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   359
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   360
void SetDifficultyLevel(int mode, GameOptions *gm_opt)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   361
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   362
	int i;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   363
	assert(mode <= 3);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   364
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   365
	gm_opt->diff_level = mode;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   366
	if (mode != 3) { // not custom
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   367
		for (i = 0; i != GAME_DIFFICULTY_NUM; i++)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   368
			((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
   369
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   370
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   371
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
   372
extern void StartupEconomy(void);
46
c9bdf1d58df6 (svn r47) -Fix StartupEconomy warning in settings_gui.c
darkvater
parents: 42
diff changeset
   373
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   374
enum {
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   375
	GAMEDIFF_WND_TOP_OFFSET = 45,
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   376
	GAMEDIFF_WND_ROWSIZE    = 9
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   377
};
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   378
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   379
// Temporary holding place of values in the difficulty window until 'Save' is clicked
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   380
static GameOptions _opt_mod_temp;
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   381
// 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   382
#define DIFF_INGAME_DISABLED_BUTTONS 0x383E
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   383
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   384
static void GameDifficultyWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   385
{
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   386
	switch (e->event) {
4709
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   387
	case WE_CREATE: // Setup disabled buttons when creating window
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   388
		/* disable all other difficulty buttons during gameplay except for 'custom' */
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   389
		SetWindowWidgetDisabledState(w,  3, _game_mode == GM_NORMAL);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   390
		SetWindowWidgetDisabledState(w,  4, _game_mode == GM_NORMAL);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   391
		SetWindowWidgetDisabledState(w,  5, _game_mode == GM_NORMAL);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   392
		SetWindowWidgetDisabledState(w,  6, _game_mode == GM_NORMAL);
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   393
		SetWindowWidgetDisabledState(w,  7, _game_mode == GM_EDITOR || _networking); // highscore chart in multiplayer
eff35edfb653 (svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents: 4634
diff changeset
   394
		SetWindowWidgetDisabledState(w, 10, _networking && !_network_server); // Save-button in multiplayer (and if client)
1794
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   395
44f9deff97ed (svn r2298) - CodeChange: removed CmdAbuses: CmdSetTownNameType(), CmdStartNewGame(), CmdCreateScenario(), CmdSetNewLandscapeType() and CmdGenRandomNewGame().
Darkvater
parents: 1781
diff changeset
   396
		break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   397
	case WE_PAINT: {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   398
		uint32 click_a, click_b, disabled;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   399
		int i;
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   400
		int y, value;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   401
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   402
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   403
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   404
		click_a = _difficulty_click_a;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   405
		click_b = _difficulty_click_b;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   406
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   407
		/* XXX - Disabled buttons in normal gameplay. Bitshifted for each button to see if
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   408
		 * that bit is set. If it is set, the button is disabled */
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   409
		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
   410
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   411
		y = GAMEDIFF_WND_TOP_OFFSET;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   412
		for (i = 0; i != GAME_DIFFICULTY_NUM; i++) {
5650
aefc131bf5ce (svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents: 5649
diff changeset
   413
			DrawFrameRect( 5, y,  5 + 8, y + 8, 3, GetBitAndShift(&click_a) ? FR_LOWERED : FR_NONE);
aefc131bf5ce (svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents: 5649
diff changeset
   414
			DrawFrameRect(15, y, 15 + 8, y + 8, 3, GetBitAndShift(&click_b) ? FR_LOWERED : FR_NONE);
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   415
			if (GetBitAndShift(&disabled) || (_networking && !_network_server)) {
4444
9c9c7f962482 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   416
				int color = PALETTE_MODIFIER_GREYOUT | _colour_gradient[COLOUR_YELLOW][2];
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   417
				GfxFillRect( 6, y + 1,  6 + 8, y + 8, color);
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   418
				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
   419
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   420
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   421
			DrawStringCentered(10, y, STR_6819, 0);
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   422
			DrawStringCentered(20, y, STR_681A, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   423
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   425
			value = _game_setting_info[i].str + ((int*)&_opt_mod_temp.diff)[i];
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   426
			if (i == 4) value *= 1000; // XXX - handle currency option
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   427
			SetDParam(0, value);
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   428
			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
   429
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   430
			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
   431
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   432
	} break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   433
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   434
	case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   435
		switch (e->we.click.widget) {
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   436
		case 8: { /* Difficulty settings widget, decode click */
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   437
			const GameSettingData *info;
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   438
			int x, y;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   439
			uint btn, dis;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   440
			int val;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   441
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   442
			// Don't allow clients to make any changes
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   443
			if  (_networking && !_network_server)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   444
				return;
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   445
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   446
			x = e->we.click.pt.x - 5;
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   447
			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
   448
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   449
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   450
			y = e->we.click.pt.y - GAMEDIFF_WND_TOP_OFFSET;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   451
			if (y < 0)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   452
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   453
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   454
			// Get button from Y coord.
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   455
			btn = y / (GAMEDIFF_WND_ROWSIZE + 2);
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   456
			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
   457
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   458
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   459
			// Clicked disabled button?
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   460
			dis = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   461
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   462
			if (HASBIT(dis, btn))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   463
				return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   464
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   465
			_difficulty_timeout = 5;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   467
			val = ((int*)&_opt_mod_temp.diff)[btn];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   469
			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
   470
			if (x >= 10) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
				// Increase button clicked
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
				val = min(val + info->step, info->max);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   473
				SETBIT(_difficulty_click_b, btn);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   474
			} else {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
				// Decrease button clicked
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
				val = max(val - info->step, info->min);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
				SETBIT(_difficulty_click_a, btn);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
			}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   480
			// save value in temporary variable
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
			((int*)&_opt_mod_temp.diff)[btn] = val;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   482
			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
   483
			SetWindowDirty(w);
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   484
		}	break;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   485
		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
   486
			// temporarily change difficulty level
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   487
			RaiseWindowWidget(w, _opt_mod_temp.diff_level + 3);
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   488
			SetDifficultyLevel(e->we.click.widget - 3, &_opt_mod_temp);
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   489
			LowerWindowWidget(w, _opt_mod_temp.diff_level + 3);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   490
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
			break;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   492
		case 7: /* Highscore Table */
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   493
			ShowHighscoreTable(_opt_mod_temp.diff_level, -1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   494
			break;
983
1be852dcdd4c (svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents: 982
diff changeset
   495
		case 10: { /* Save button - save changes */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   496
			int btn, val;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   497
			for (btn = 0; btn != GAME_DIFFICULTY_NUM; btn++) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   498
				val = ((int*)&_opt_mod_temp.diff)[btn];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   499
				// if setting has changed, change it
1501
0faec0f792b0 (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
   500
				if (val != ((int*)&_opt_ptr->diff)[btn])
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   501
					DoCommandP(0, btn, val, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
			}
5650
aefc131bf5ce (svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents: 5649
diff changeset
   503
			DoCommandP(0, UINT_MAX, _opt_mod_temp.diff_level, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
			DeleteWindow(w);
42
567add3568d6 (svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents: 26
diff changeset
   505
			// 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
   506
			//  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
   507
			//  are loaded correctly.
567add3568d6 (svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents: 26
diff changeset
   508
			if (_game_mode == GM_EDITOR)
567add3568d6 (svn r43) Fix: [ 982666 ] max_loan in editor bug (truelight)
dominik
parents: 26
diff changeset
   509
				StartupEconomy();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   510
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   511
		}
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   512
		case 11: /* Cancel button - close window, abandon changes */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   513
			DeleteWindow(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   514
			break;
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   515
	} break;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   516
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   517
	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
   518
		if (_difficulty_timeout != 0 && !--_difficulty_timeout) {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   519
			_difficulty_click_a = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   520
			_difficulty_click_b = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   521
			SetWindowDirty(w);
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
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   524
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   525
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   526
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   527
#undef DIFF_INGAME_DISABLED_BUTTONS
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   528
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   529
static const Widget _game_difficulty_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   530
{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   531
{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_6800_DIFFICULTY_LEVEL,    STR_018C_WINDOW_TITLE_DRAG_THIS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   532
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    29, 0x0,                          STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   533
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_6801_EASY,                STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   534
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_6802_MEDIUM,              STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   535
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_6803_HARD,                STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   536
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_6804_CUSTOM,              STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   537
{    WWT_TEXTBTN,   RESIZE_NONE,    10,     0,   369,    30,    41, STR_6838_SHOW_HI_SCORE_CHART, STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   538
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   262, 0x0,                          STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   539
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,   263,   278, 0x0,                          STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   540
{ WWT_PUSHTXTBTN,   RESIZE_NONE,     3,   105,   185,   265,   276, STR_OPTIONS_SAVE_CHANGES,     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   541
{ 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
   542
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   543
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   544
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   545
static const WindowDesc _game_difficulty_desc = {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   546
	WDP_CENTER, WDP_CENTER, 370, 279,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   547
	WC_GAME_OPTIONS,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   548
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   549
	_game_difficulty_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   550
	GameDifficultyWndProc
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
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
   553
void ShowGameDifficulty(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   554
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   555
	DeleteWindowById(WC_GAME_OPTIONS, 0);
1500
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   556
	/* Copy current settings (ingame or in intro) to temporary holding place
228f77e88adf (svn r2004) - Fix: [ 1149487 ] Autosave ignoring settings
Darkvater
parents: 1477
diff changeset
   557
	 * change that when setting stuff, copy back on clicking 'OK' */
5024
f13f2f2d43f9 (svn r7065) Use simple assignment instead of memcpy()
tron
parents: 4939
diff changeset
   558
	_opt_mod_temp = *_opt_ptr;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   559
	AllocateWindowDesc(&_game_difficulty_desc);
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   560
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   561
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   562
static const char *_patches_ui[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   563
	"vehicle_speed",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   564
	"status_long_date",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   565
	"show_finances",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   566
	"autoscroll",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   567
	"reverse_scroll",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   568
	"errmsg_duration",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   569
	"toolbar_pos",
4834
ddcf440d0ffd (svn r6758) -Feature: Add a measurement tool that will show dimensions and height
Darkvater
parents: 4727
diff changeset
   570
	"measure_tooltip",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   571
	"window_snap_radius",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   572
	"invisible_trees",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   573
	"population_in_label",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   574
	"link_terraform_toolbar",
4616
baa9d4436b9e (svn r6474) - Add a patch option to control display of liveries, allowing none, your
peter1138
parents: 4552
diff changeset
   575
	"liveries",
5107
8791beb0ae51 (svn r7179) -Codechange (r7173): Actually "prefer" team chat through the patch setting instead of
Darkvater
parents: 5102
diff changeset
   576
	"prefer_teamchat",
21
67cde01e8359 (svn r22) Add: Competitors menu under patches
truelight
parents: 20
diff changeset
   577
};
67cde01e8359 (svn r22) Add: Competitors menu under patches
truelight
parents: 20
diff changeset
   578
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   579
static const char *_patches_construction[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   580
	"build_on_slopes",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   581
	"extra_dynamite",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   582
	"longbridges",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   583
	"signal_side",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   584
	"always_small_airport",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   585
	"drag_signals_density",
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents: 4299
diff changeset
   586
	"oil_refinery_limit",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   587
};
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   588
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   589
static const char *_patches_stations[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   590
	"join_stations",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   591
	"full_load_any",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   592
	"improved_load",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   593
	"selectgoods",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   594
	"new_nonstop",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   595
	"nonuniform_stations",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   596
	"station_spread",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   597
	"serviceathelipad",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   598
	"modified_catchment",
5211
651c9272ad22 (svn r7326) -Feature: Add support for gradual (un)loading of vehicles (Maedhros)
peter1138
parents: 5163
diff changeset
   599
	"gradual_loading",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   600
};
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   601
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   602
static const char *_patches_economy[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   603
	"inflation",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   604
	"build_rawmaterial_ind",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   605
	"multiple_industry_per_town",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   606
	"same_industry_close",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   607
	"bribe",
4285
72b3f7d6c891 (svn r5915) -Cleanup: some variables were named *_date while they were only holding years; rename these variables to match this.
rubidium
parents: 4261
diff changeset
   608
	"colored_news_year",
72b3f7d6c891 (svn r5915) -Cleanup: some variables were named *_date while they were only holding years; rename these variables to match this.
rubidium
parents: 4261
diff changeset
   609
	"ending_year",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   610
	"smooth_economy",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   611
	"allow_shares",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   612
};
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   613
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   614
static const char *_patches_ai[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   615
	"ainew_active",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   616
	"ai_in_multiplayer",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   617
	"ai_disable_veh_train",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   618
	"ai_disable_veh_roadveh",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   619
	"ai_disable_veh_aircraft",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   620
	"ai_disable_veh_ship",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   621
};
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   622
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   623
static const char *_patches_vehicles[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   624
	"realistic_acceleration",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   625
	"forbid_90_deg",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   626
	"mammoth_trains",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   627
	"gotodepot",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   628
	"roadveh_queue",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   629
	"new_pathfinding_all",
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3888
diff changeset
   630
	"yapf.ship_use_yapf",
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3888
diff changeset
   631
	"yapf.road_use_yapf",
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3888
diff changeset
   632
	"yapf.rail_use_yapf",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   633
	"train_income_warn",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   634
	"order_review_system",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   635
	"never_expire_vehicles",
4870
0ee22ed51ada (svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents: 4834
diff changeset
   636
	"lost_train_warn",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   637
	"autorenew",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   638
	"autorenew_months",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   639
	"autorenew_money",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   640
	"max_trains",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   641
	"max_roadveh",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   642
	"max_aircraft",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   643
	"max_ships",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   644
	"servint_ispercent",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   645
	"servint_trains",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   646
	"servint_roadveh",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   647
	"servint_ships",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   648
	"servint_aircraft",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   649
	"no_servicing_if_no_breakdowns",
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   650
	"wagon_speed_limits",
5116
2a33a74925c5 (svn r7195) -Feature: [FS#297, optional elrails] New patches/vehicles option 'disable electrified railways'.
KUDr
parents: 5113
diff changeset
   651
	"disable_elrails",
5163
83acad83bbdd (svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents: 5141
diff changeset
   652
	"freight_trains",
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   653
};
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   654
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   655
typedef struct PatchEntry {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   656
	const SettingDesc *setting;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   657
	uint index;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   658
} PatchEntry;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   659
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   660
typedef struct PatchPage {
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   661
	const char **names;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   662
	PatchEntry *entries;
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   663
	byte num;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   664
} PatchPage;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   665
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   666
/* PatchPage holds the categories, the number of elements in each category
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   667
 * and (in NULL) a dynamic array of settings based on the string-representations
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   668
 * of the settings. This way there is no worry about indeces, and such */
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   669
static PatchPage _patches_page[] = {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   670
	{_patches_ui,           NULL, lengthof(_patches_ui)},
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   671
	{_patches_construction, NULL, lengthof(_patches_construction)},
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   672
	{_patches_vehicles,     NULL, lengthof(_patches_vehicles)},
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   673
	{_patches_stations,     NULL, lengthof(_patches_stations)},
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   674
	{_patches_economy,      NULL, lengthof(_patches_economy)},
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   675
	{_patches_ai,           NULL, lengthof(_patches_ai)},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   676
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   677
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   678
/** The main patches window. Shows a number of categories on top and
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   679
 * a selection of patches in that category.
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   680
 * 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
   681
static void PatchesSelectionWndProc(Window *w, WindowEvent *e)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   682
{
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   683
	static Patches *patches_ptr;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   684
1741
9087c5207f18 (svn r2245) - CodeChange: simplify the clamping of values for patch-settings by using clamp()
Darkvater
parents: 1739
diff changeset
   685
	switch (e->event) {
3206
7635c2101f2e (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
   686
	case WE_CREATE: {
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   687
		static bool first_time = true;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   688
3121
2e50f731567a (svn r3726) - [6/6] Finalize conversion, finally save the patches struct.
Darkvater
parents: 3119
diff changeset
   689
		patches_ptr = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   690
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   691
		/* Build up the dynamic settings-array only once per OpenTTD session */
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   692
		if (first_time) {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   693
			PatchPage *page;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   694
			for (page = &_patches_page[0]; page != endof(_patches_page); page++) {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   695
				uint i;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   696
5650
aefc131bf5ce (svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents: 5649
diff changeset
   697
				MallocT(&page->entries, page->num);
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   698
				for (i = 0; i != page->num; i++) {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   699
					uint index;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   700
					const SettingDesc *sd = GetPatchFromName(page->names[i], &index);
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   701
					assert(sd != NULL);
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   702
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   703
					page->entries[i].setting = sd;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   704
					page->entries[i].index = index;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   705
				}
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   706
			}
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   707
			first_time = false;
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   708
		}
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   709
		LowerWindowWidget(w, 4);
3206
7635c2101f2e (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
   710
	} break;
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   711
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   712
	case WE_PAINT: {
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   713
		int x, y;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   714
		const PatchPage *page = &_patches_page[WP(w,def_d).data_1];
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
   715
		uint i;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   716
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   717
		/* Set up selected category */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   718
		DrawWindowWidgets(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   719
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   720
		x = 5;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   721
		y = 47;
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   722
		for (i = 0; i != page->num; i++) {
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   723
			const SettingDesc *sd = page->entries[i].setting;
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   724
			const SettingDescBase *sdb = &sd->desc;
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
   725
			const void *var = GetVariableAddress(patches_ptr, &sd->save);
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   726
			bool editable = true;
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   727
			bool disabled = false;
998
d9dc257b8949 (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
   728
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   729
			// We do not allow changes of some items when we are a client in a networkgame
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   730
			if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) editable = false;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   731
			if ((sdb->flags & SGF_NETWORK_ONLY) && !_networking) editable = false;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   732
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   733
			if (sdb->cmd == SDT_BOOLX) {
3124
60f74c9c90e3 (svn r3732) - Fix two warnings. Stupid MSVC didn't even complain :s (Thank Tron and peter1138)
Darkvater
parents: 3121
diff changeset
   734
				static const int _bool_ctabs[2][2] = {{9, 4}, {7, 6}};
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   735
				/* Draw checkbox for boolean-value either on/off */
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   736
				bool on = (*(bool*)var);
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   737
5650
aefc131bf5ce (svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents: 5649
diff changeset
   738
				DrawFrameRect(x, y, x + 19, y + 8, _bool_ctabs[!!on][!!editable], on ? FR_LOWERED : FR_NONE);
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   739
				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
   740
			} else {
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   741
				int32 value;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   742
4211
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   743
				value = (int32)ReadValue(var, sd->save.conv);
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   744
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   745
				/* Draw [<][>] boxes for settings of an integer-type */
4211
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   746
				DrawArrowButtons(x, y, 3, WP(w,def_d).data_2 - (i * 2), (editable && value != sdb->min), (editable && value != sdb->max));
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   747
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   748
				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
   749
				if (disabled) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   750
					SetDParam(0, STR_CONFIG_PATCHES_DISABLED);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   751
				} else {
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   752
					if (sdb->flags & SGF_CURRENCY) {
534
17ab2f22ff74 (svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents: 523
diff changeset
   753
						SetDParam(0, STR_CONFIG_PATCHES_CURRENCY);
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   754
					} else if (sdb->flags & SGF_MULTISTRING) {
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   755
						SetDParam(0, sdb->str + value + 1);
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   756
					} else {
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   757
						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
   758
					}
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   759
					SetDParam(1, value);
0
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
			}
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   762
			DrawString(30, y, (sdb->str) + disabled, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   763
			y += 11;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   764
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   765
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   766
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   767
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   768
	case WE_CLICK:
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   769
		switch (e->we.click.widget) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   770
		case 3: {
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   771
			const PatchPage *page = &_patches_page[WP(w,def_d).data_1];
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   772
			const SettingDesc *sd;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   773
			void *var;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   774
			int32 value;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   775
			int x, y;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   776
			byte btn;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   777
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   778
			y = e->we.click.pt.y - 46 - 1;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   779
			if (y < 0) return;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   780
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   781
			x = e->we.click.pt.x - 5;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   782
			if (x < 0) return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   783
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   784
			btn = y / 11;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   785
			if (y % 11 > 9) return;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   786
			if (btn >= page->num) return;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   787
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   788
			sd = page->entries[btn].setting;
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   789
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   790
			/* return if action is only active in network, or only settable by server */
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   791
			if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking) return;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   792
			if (!(sd->save.conv & SLF_NETWORK_NO) && _networking && !_network_server) return;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   793
5141
05a806850445 (svn r7231) -Codechange: rename ini_get_variable to GetVariableAddress for use both in settings.c
Darkvater
parents: 5116
diff changeset
   794
			var = GetVariableAddress(patches_ptr, &sd->save);
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   795
			value = (int32)ReadValue(var, sd->save.conv);
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   796
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   797
			/* clicked on the icon on the left side. Either scroller or bool on/off */
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   798
			if (x < 21) {
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   799
				const SettingDescBase *sdb = &sd->desc;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   800
				int32 oldvalue = value;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   801
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   802
				switch (sdb->cmd) {
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   803
				case SDT_BOOLX: value ^= 1; break;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   804
				case SDT_NUMX: {
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   805
					/* Add a dynamic step-size to the scroller. In a maximum of
4431
7468c1484d20 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4377
diff changeset
   806
					 * 50-steps you should be able to get from min to max,
7468c1484d20 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4377
diff changeset
   807
					 * unless specified otherwise in the 'interval' variable
7468c1484d20 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4377
diff changeset
   808
					 * of the current patch. */
7468c1484d20 (svn r6186) -Fix [FS#309]: add an override system to the dynamically determined size of steps for numeric patch settings in the 'Configure patches' GUI.
rubidium
parents: 4377
diff changeset
   809
					uint32 step = (sdb->interval == 0) ? ((sdb->max - sdb->min) / 50) : sdb->interval;
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   810
					if (step == 0) step = 1;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   811
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   812
					// don't allow too fast scrolling
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   813
					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
   814
						_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   815
						return;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   816
					}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   817
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   818
					/* 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
   819
					if (x >= 10) {
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   820
						value += step;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   821
						if (value > sdb->max) value = sdb->max;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   822
					} else {
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   823
						value -= step;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   824
						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
   825
					}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   826
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   827
					/* Set up scroller timeout */
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   828
					if (value != oldvalue) {
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   829
						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
   830
						w->flags4 |= 5 << WF_TIMEOUT_SHL;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   831
						_left_button_clicked = false;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   832
					}
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   833
				} break;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   834
				default: NOT_REACHED();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   835
				}
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   836
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   837
				if (value != oldvalue) {
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   838
					SetPatchValue(page->entries[btn].index, patches_ptr, value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   839
					SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   840
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   841
			} else {
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   842
				/* only open editbox for types that its sensible for */
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   843
				if (sd->desc.cmd != SDT_BOOLX && !(sd->desc.flags & SGF_MULTISTRING)) {
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   844
					/* Show the correct currency-translated value */
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   845
					if (sd->desc.flags & SGF_CURRENCY) value *= _currency->rate;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   846
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   847
					WP(w,def_d).data_3 = btn;
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   848
					SetDParam(0, value);
5623
ef2a8a524a95 (svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents: 5237
diff changeset
   849
					ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_CONFIG_PATCHES_QUERY_CAPT, 10, 100, w, CS_NUMERAL);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   850
				}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   851
			}
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 179
diff changeset
   852
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   853
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   854
		}
21
67cde01e8359 (svn r22) Add: Competitors menu under patches
truelight
parents: 20
diff changeset
   855
		case 4: case 5: case 6: case 7: case 8: case 9:
4719
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   856
			RaiseWindowWidget(w, WP(w, def_d).data_1 + 4);
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   857
			WP(w, def_d).data_1 = e->we.click.widget - 4;
413b21513ef7 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   858
			LowerWindowWidget(w, WP(w, def_d).data_1 + 4);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   859
			DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   860
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   861
			break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   862
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   863
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   864
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   865
	case WE_TIMEOUT:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   866
		WP(w,def_d).data_2 = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   867
		SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   868
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   869
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   870
	case WE_ON_EDIT_TEXT: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   871
		if (e->we.edittext.str != NULL) {
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   872
			const PatchEntry *pe = &_patches_page[WP(w,def_d).data_1].entries[WP(w,def_d).data_3];
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   873
			const SettingDesc *sd = pe->setting;
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   874
			int32 value = atoi(e->we.edittext.str);
3118
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   875
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   876
			/* Save the correct currency-translated value */
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   877
			if (sd->desc.flags & SGF_CURRENCY) value /= _currency->rate;
99926945ccb1 (svn r3722) - [4/4] Present the game with a unified structure for the configuration-ini, saveload, console and gui representations of the settings. The last part finishes the transition with the merging of the settings_gui table(s).
Darkvater
parents: 3107
diff changeset
   878
3247
4e70e64adbb8 (svn r3930) - [Patches] Change the GUI-patch options from indeces to string representations. Not only makes this the part more humanly readable, but saves us from rewriting the whole index when a patch is added/removed/changed
Darkvater
parents: 3206
diff changeset
   879
			SetPatchValue(pe->index, patches_ptr, value);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   880
			SetWindowDirty(w);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   881
		}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   882
		break;
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
	case WE_DESTROY:
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   886
		DeleteWindowById(WC_QUERY_STRING, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   887
		break;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   888
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   889
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   890
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   891
static const Widget _patches_selection_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   892
{   WWT_CLOSEBOX,   RESIZE_NONE,    10,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   893
{    WWT_CAPTION,   RESIZE_NONE,    10,    11,   369,     0,    13, STR_CONFIG_PATCHES_CAPTION,      STR_018C_WINDOW_TITLE_DRAG_THIS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   894
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    14,    41, 0x0,                             STR_NULL},
5163
83acad83bbdd (svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents: 5141
diff changeset
   895
{      WWT_PANEL,   RESIZE_NONE,    10,     0,   369,    42,   370, 0x0,                             STR_NULL},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   896
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   897
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    16,    27, STR_CONFIG_PATCHES_GUI,          STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   898
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    97,   183,    16,    27, STR_CONFIG_PATCHES_CONSTRUCTION, STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   899
{    WWT_TEXTBTN,   RESIZE_NONE,     3,   184,   270,    16,    27, STR_CONFIG_PATCHES_VEHICLES,     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   900
{    WWT_TEXTBTN,   RESIZE_NONE,     3,   271,   357,    16,    27, STR_CONFIG_PATCHES_STATIONS,     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   901
{    WWT_TEXTBTN,   RESIZE_NONE,     3,    10,    96,    28,    39, STR_CONFIG_PATCHES_ECONOMY,      STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
   902
{    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
   903
{   WIDGETS_END},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   904
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   905
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   906
static const WindowDesc _patches_selection_desc = {
5163
83acad83bbdd (svn r7269) -Feature: Add freight trains patch option. This option is a multiplier for the weight of cargo on freight trains, to simulate longer heavier trains. The default value of 1 behaves as before.
peter1138
parents: 5141
diff changeset
   907
	WDP_CENTER, WDP_CENTER, 370, 371,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   908
	WC_GAME_OPTIONS,0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   909
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   910
	_patches_selection_widgets,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   911
	PatchesSelectionWndProc,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   912
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   913
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1037
diff changeset
   914
void ShowPatchesSelection(void)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   915
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   916
	DeleteWindowById(WC_GAME_OPTIONS, 0);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   917
	AllocateWindowDesc(&_patches_selection_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   918
}
478
19987403ee5d (svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents: 430
diff changeset
   919
19987403ee5d (svn r745) Added newgrf GUI (in options menu)\nThe interface currently only displays the installed grf sets, you can't (de)activate them through the gui yet
dominik
parents: 430
diff changeset
   920
4211
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   921
/**
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   922
 * Draw [<][>] boxes.
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   923
 * @param x the x position to draw
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   924
 * @param y the y position to draw
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   925
 * @param ctab the color of the buttons
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   926
 * @param state 0 = none clicked, 1 = first clicked, 2 = second clicked
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   927
 * @param clickable_left is the left button clickable?
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   928
 * @param clickable_right is the right button clickable?
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   929
 */
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   930
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right)
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   931
{
4444
9c9c7f962482 (svn r6222) Remove struct ColorList, because the names of its attributes are plain confusing
tron
parents: 4437
diff changeset
   932
	int color = PALETTE_MODIFIER_GREYOUT | _colour_gradient[COLOUR_YELLOW][2];
3107
a6406bbecd3d (svn r3710) - Use the general function DrawArrowButtons() instead of doing it manually. The function has two parameters added, colour and an enabled flag.
Darkvater
parents: 2952
diff changeset
   933
5650
aefc131bf5ce (svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents: 5649
diff changeset
   934
	DrawFrameRect(x,      y + 1, x +  9, y + 9, ctab, (state == 1) ? FR_LOWERED : FR_NONE);
aefc131bf5ce (svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents: 5649
diff changeset
   935
	DrawFrameRect(x + 10, y + 1, x + 19, y + 9, ctab, (state == 2) ? FR_LOWERED : FR_NONE);
4211
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   936
	DrawStringCentered(x +  5, y + 1, STR_6819, 0); // [<]
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   937
	DrawStringCentered(x + 15, y + 1, STR_681A, 0); // [>]
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   938
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   939
	/* Grey out the buttons that aren't clickable */
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   940
	if (!clickable_left)
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   941
		GfxFillRect(x +  1, y + 1, x +  1 + 8, y + 8, color);
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   942
	if (!clickable_right)
d8c4c40eba62 (svn r5714) Backport from branches/TGP (r5701 and r5711)
miham
parents: 4196
diff changeset
   943
		GfxFillRect(x + 11, y + 1, x + 11 + 8, y + 8, color);
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   944
}
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   945
2307
63e18261a7e7 (svn r2831) Fix some potential and real buffer overflows
tron
parents: 2306
diff changeset
   946
static char _str_separator[2];
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   947
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   948
static void CustCurrencyWndProc(Window *w, WindowEvent *e)
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   949
{
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   950
	switch (e->event) {
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   951
		case WE_PAINT: {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   952
			int x;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   953
			int y = 20;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   954
			int clk = WP(w,def_d).data_1;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   955
			DrawWindowWidgets(w);
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   956
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   957
			// exchange rate
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   958
			DrawArrowButtons(10, y, 3, GB(clk, 0, 2), true, true);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   959
			SetDParam(0, 1);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   960
			SetDParam(1, 1);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   961
			DrawString(35, y + 1, STR_CURRENCY_EXCHANGE_RATE, 0);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   962
			y += 12;
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   963
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   964
			// separator
5650
aefc131bf5ce (svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents: 5649
diff changeset
   965
			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 2, 2) ? FR_LOWERED : FR_NONE);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   966
			x = DrawString(35, y + 1, STR_CURRENCY_SEPARATOR, 0);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   967
			DoDrawString(_str_separator, x + 4, y + 1, 6);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   968
			y += 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   969
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   970
			// prefix
5650
aefc131bf5ce (svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents: 5649
diff changeset
   971
			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 4, 2) ? FR_LOWERED : FR_NONE);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   972
			x = DrawString(35, y + 1, STR_CURRENCY_PREFIX, 0);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   973
			DoDrawString(_custom_currency.prefix, x + 4, y + 1, 6);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   974
			y += 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   975
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   976
			// suffix
5650
aefc131bf5ce (svn r8149) [cbh] - Sync with -r8038:8038 from trunk (the cpp merge)
celestar
parents: 5649
diff changeset
   977
			DrawFrameRect(10, y + 1, 29, y + 9, 0, GB(clk, 6, 2) ? FR_LOWERED : FR_NONE);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   978
			x = DrawString(35, y + 1, STR_CURRENCY_SUFFIX, 0);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   979
			DoDrawString(_custom_currency.suffix, x + 4, y + 1, 6);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   980
			y += 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   981
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   982
			// switch to euro
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   983
			DrawArrowButtons(10, y, 3, GB(clk, 8, 2), true, true);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   984
			SetDParam(0, _custom_currency.to_euro);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   985
			DrawString(35, y + 1, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER, 0);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   986
			y += 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   987
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   988
			// Preview
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   989
			y += 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   990
			SetDParam(0, 10000);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   991
			DrawString(35, y + 1, STR_CURRENCY_PREVIEW, 0);
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   992
			break;
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
   993
		}
812
79c99885ad00 (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 788
diff changeset
   994
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   995
		case WE_CLICK: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   996
			int line = (e->we.click.pt.y - 20) / 12;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   997
			int len = 0;
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
   998
			int x = e->we.click.pt.x;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
   999
			StringID str = 0;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1000
			CharSetFilter afilter = CS_ALPHANUMERAL;
812
79c99885ad00 (svn r1283) -Add: AutoRenew is now a client-side patch instead of a game-side patch
truelight
parents: 788
diff changeset
  1001
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1002
			switch (line) {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1003
				case 0: // rate
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1004
					if (IS_INT_INSIDE(x, 10, 30)) { // clicked buttons
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1005
						if (x < 20) {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1006
							if (_custom_currency.rate > 1) _custom_currency.rate--;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1007
							WP(w,def_d).data_1 = 1 << (line * 2 + 0);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1008
						} else {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1009
							if (_custom_currency.rate < 5000) _custom_currency.rate++;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1010
							WP(w,def_d).data_1 = 1 << (line * 2 + 1);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1011
						}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1012
					} else { // enter text
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1013
						SetDParam(0, _custom_currency.rate);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1014
						str = STR_CONFIG_PATCHES_INT32;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1015
						len = 4;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1016
						afilter = CS_NUMERAL;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1017
					}
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1018
					break;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1019
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1020
				case 1: // separator
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1021
					if (IS_INT_INSIDE(x, 10, 30)) { // clicked button
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1022
						WP(w,def_d).data_1 = 1 << (line * 2 + 1);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1023
					}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1024
					str = BindCString(_str_separator);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1025
					len = 1;
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1026
					break;
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1027
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1028
				case 2: // prefix
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1029
					if (IS_INT_INSIDE(x, 10, 30)) { // clicked button
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1030
						WP(w,def_d).data_1 = 1 << (line * 2 + 1);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1031
					}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1032
					str = BindCString(_custom_currency.prefix);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1033
					len = 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1034
					break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1035
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1036
				case 3: // suffix
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1037
					if (IS_INT_INSIDE(x, 10, 30)) { // clicked button
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1038
						WP(w,def_d).data_1 = 1 << (line * 2 + 1);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1039
					}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1040
					str = BindCString(_custom_currency.suffix);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1041
					len = 12;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1042
					break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1043
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1044
				case 4: // to euro
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1045
					if (IS_INT_INSIDE(x, 10, 30)) { // clicked buttons
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1046
						if (x < 20) {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1047
							_custom_currency.to_euro = (_custom_currency.to_euro <= 2000) ?
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1048
								CF_NOEURO : _custom_currency.to_euro - 1;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1049
							WP(w,def_d).data_1 = 1 << (line * 2 + 0);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1050
						} else {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1051
							_custom_currency.to_euro =
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1052
								clamp(_custom_currency.to_euro + 1, 2000, MAX_YEAR);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1053
							WP(w,def_d).data_1 = 1 << (line * 2 + 1);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1054
						}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1055
					} else { // enter text
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1056
						SetDParam(0, _custom_currency.to_euro);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1057
						str = STR_CONFIG_PATCHES_INT32;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1058
						len = 4;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1059
						afilter = CS_NUMERAL;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1060
					}
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1061
					break;
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1062
			}
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1063
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1064
			if (len != 0) {
5623
ef2a8a524a95 (svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents: 5237
diff changeset
  1065
				WP(w, def_d).data_2 = line;
ef2a8a524a95 (svn r7721) [cbh] - Sync with 7607:7720 from trunk
celestar
parents: 5237
diff changeset
  1066
				ShowQueryString(str, STR_CURRENCY_CHANGE_PARAMETER, len + 1, 250, w, afilter);
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1067
			}
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1068
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1069
			w->flags4 |= 5 << WF_TIMEOUT_SHL;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1070
			SetWindowDirty(w);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1071
			break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1072
		}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1073
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1074
		case WE_ON_EDIT_TEXT: {
4634
897461a3e9ca (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4616
diff changeset
  1075
				const char *b = e->we.edittext.str;
4488
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1076
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1077
				switch (WP(w,def_d).data_2) {
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1078
					case 0: /* Exchange rate */
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1079
						_custom_currency.rate = clamp(atoi(b), 1, 5000);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1080
						break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1081
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1082
					case 1: /* Thousands seperator */
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1083
						_custom_currency.separator = (b[0] == '\0') ? ' ' : b[0];
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1084
						ttd_strlcpy(_str_separator, b, lengthof(_str_separator));
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1085
						break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1086
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1087
					case 2: /* Currency prefix */
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1088
						ttd_strlcpy(_custom_currency.prefix, b, lengthof(_custom_currency.prefix));
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1089
						break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1090
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1091
					case 3: /* Currency suffix */
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1092
						ttd_strlcpy(_custom_currency.suffix, b, lengthof(_custom_currency.suffix));
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1093
						break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1094
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1095
					case 4: { /* Year to switch to euro */
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1096
						int val = atoi(b);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1097
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1098
						_custom_currency.to_euro =
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1099
							(val < 2000 ? CF_NOEURO : min(val, MAX_YEAR));
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1100
						break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1101
					}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1102
				}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1103
			MarkWholeScreenDirty();
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1104
			break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1105
		}
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1106
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1107
		case WE_TIMEOUT:
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1108
			WP(w,def_d).data_1 = 0;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1109
			SetWindowDirty(w);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1110
			break;
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1111
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1112
		case WE_DESTROY:
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1113
			DeleteWindowById(WC_QUERY_STRING, 0);
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1114
			MarkWholeScreenDirty();
6eb5f6192c3a (svn r6273) Clean up the custom currency window handler a bit
tron
parents: 4444
diff changeset
  1115
			break;
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1116
	}
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1117
}
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1118
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1119
static const Widget _cust_currency_widgets[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1120
{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1121
{    WWT_CAPTION,   RESIZE_NONE,    14,    11,   229,     0,    13, STR_CURRENCY_WINDOW, STR_018C_WINDOW_TITLE_DRAG_THIS},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4300
diff changeset
  1122
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   229,    14,   119, 0x0,                 STR_NULL},
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1123
{   WIDGETS_END},
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1124
};
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1125
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1126
static const WindowDesc _cust_currency_desc = {
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1127
	WDP_CENTER, WDP_CENTER, 230, 120,
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1128
	WC_CUSTOM_CURRENCY, 0,
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1129
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1130
	_cust_currency_widgets,
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1131
	CustCurrencyWndProc,
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1132
};
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1133
2817
58dcead3f545 (svn r3365) Staticise 36 functions
tron
parents: 2776
diff changeset
  1134
static void ShowCustCurrency(void)
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1135
{
2306
3d4efe849dd9 (svn r2830) Move CheckSwitchToEuro() to currency.[ch] and hide the truth about the custom currency behind a #define
tron
parents: 2293
diff changeset
  1136
	_str_separator[0] = _custom_currency.separator;
1759
ea38d6193887 (svn r2263) - Fix: If the seperator string is empty for custom currencies, everything after that is cut off. Fix it by replacing nothing with ' '. Thanks for noticing peter1138
Darkvater
parents: 1756
diff changeset
  1137
	_str_separator[1] = '\0';
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1138
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1139
	DeleteWindowById(WC_CUSTOM_CURRENCY, 0);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2631
diff changeset
  1140
	AllocateWindowDesc(&_cust_currency_desc);
759
6d087784a08a (svn r1215) Feature: You can now make a custom currency by chosing "Custom..."
dominik
parents: 654
diff changeset
  1141
}