src/genworld_gui.cpp
author rubidium
Fri, 25 Apr 2008 15:22:32 +0000
changeset 9055 4dc6a0c0ef47
parent 8749 e32c110d0a77
child 9111 48ce04029fe4
permissions -rw-r--r--
(svn r12897) -Codechange: some coding style in station_cmd.cpp.
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     1
/* $Id$ */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     2
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5901
diff changeset
     3
/** @file genworld_gui.cpp */
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5901
diff changeset
     4
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     5
#include "stdafx.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     6
#include "openttd.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     7
#include "heightmap.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     8
#include "gui.h"
8107
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
     9
#include "window_gui.h"
bb7deea89175 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8106
diff changeset
    10
#include "textbuf_gui.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    11
#include "gfxinit.h"
8116
8da76dcb3287 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8114
diff changeset
    12
#include "command_func.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    13
#include "variables.h"
8208
3d0590aa2124 (svn r11771) -Codechange: split settings.h into better separated headers.
rubidium
parents: 8157
diff changeset
    14
#include "settings_func.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    15
#include "debug.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    16
#include "genworld.h"
5469
7edfc643abbc (svn r7751) -Codechange: move network_* to a new network map. Furthermore move the low level network functions to network/core, so they can be reused by the masterserver and website-serverlist-updater.
rubidium
parents: 5464
diff changeset
    17
#include "network/network.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    18
#include "thread.h"
5228
26dc9acf7d94 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents: 5213
diff changeset
    19
#include "newgrf_config.h"
8114
dd6d21dc99c1 (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8108
diff changeset
    20
#include "strings_func.h"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8121
diff changeset
    21
#include "window_func.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8131
diff changeset
    22
#include "date_func.h"
8157
1505def01945 (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium
parents: 8151
diff changeset
    23
#include "sound_func.h"
8151
4cefeef74c28 (svn r11713) -Codechange: Move some declarations and definitions in a more logical disposition
belugas
parents: 8140
diff changeset
    24
#include "fios.h"
8214
971f861d5543 (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8208
diff changeset
    25
#include "string_func.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8214
diff changeset
    26
#include "gfx_func.h"
8270
e7c342f6b14c (svn r11834) -Codechange: only include settings_type.h if needed.
rubidium
parents: 8264
diff changeset
    27
#include "settings_type.h"
8327
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
    28
#include "widgets/dropdown_type.h"
8284
ebdc5ba08874 (svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138
parents: 8270
diff changeset
    29
#include "widgets/dropdown_func.h"
8433
33899f3d6b5c (svn r12003) -Codechange: don't declare InteractiveRandom[Range] in multiple places.
rubidium
parents: 8424
diff changeset
    30
#include "core/random_func.hpp"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    31
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    32
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    33
#include "table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8254
diff changeset
    34
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    35
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    36
 * In what 'mode' the GenerateLandscapeWindowProc is.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    37
 */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    38
enum glwp_modes {
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    39
	GLWP_GENERATE,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    40
	GLWP_HEIGHTMAP,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    41
	GLWP_SCENARIO,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    42
	GLWP_END
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    43
};
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    44
7103
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
    45
struct generate_d {
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
    46
	uint widget_id;
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
    47
	uint x;
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
    48
	uint y;
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
    49
	char name[64];
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
    50
};
8749
e32c110d0a77 (svn r12445) -Fix: Add missing compile asserts for window data structs
peter1138
parents: 8737
diff changeset
    51
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(generate_d));
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    52
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    53
extern void SwitchMode(int new_mode);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    54
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    55
static inline void SetNewLandscapeType(byte landscape)
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    56
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    57
	_opt_newgame.landscape = landscape;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    58
	InvalidateWindowClasses(WC_SELECT_GAME);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    59
	InvalidateWindowClasses(WC_GENERATE_LANDSCAPE);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    60
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    61
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    62
enum GenerateLandscapeWindowWidgets {
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    63
	GLAND_TEMPERATE = 3,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    64
	GLAND_ARCTIC,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    65
	GLAND_TROPICAL,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    66
	GLAND_TOYLAND,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    67
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    68
	GLAND_MAPSIZE_X_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    69
	GLAND_MAPSIZE_X_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    70
	GLAND_MAPSIZE_Y_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    71
	GLAND_MAPSIZE_Y_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    72
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    73
	GLAND_TOWN_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    74
	GLAND_TOWN_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    75
	GLAND_INDUSTRY_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    76
	GLAND_INDUSTRY_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    77
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
    78
	GLAND_RANDOM_TEXT,
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    79
	GLAND_RANDOM_EDITBOX,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    80
	GLAND_RANDOM_BUTTON,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    81
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    82
	GLAND_GENERATE_BUTTON,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    83
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
    84
	GLAND_START_DATE_TEXT1,
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    85
	GLAND_START_DATE_DOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    86
	GLAND_START_DATE_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    87
	GLAND_START_DATE_UP,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    88
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
    89
	GLAND_SNOW_LEVEL_TEXT1,
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    90
	GLAND_SNOW_LEVEL_DOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    91
	GLAND_SNOW_LEVEL_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    92
	GLAND_SNOW_LEVEL_UP,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    93
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    94
	GLAND_TREE_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    95
	GLAND_TREE_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    96
	GLAND_LANDSCAPE_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    97
	GLAND_LANDSCAPE_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    98
	GLAND_HEIGHTMAP_ROTATION_TEXT = GLAND_LANDSCAPE_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    99
	GLAND_HEIGHTMAP_ROTATION_PULLDOWN = GLAND_LANDSCAPE_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   100
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   101
	GLAND_TERRAIN_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   102
	GLAND_TERRAIN_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   103
	GLAND_WATER_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   104
	GLAND_WATER_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   105
	GLAND_SMOOTHNESS_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   106
	GLAND_SMOOTHNESS_PULLDOWN
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   107
};
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   108
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   109
static const Widget _generate_landscape_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   110
{  WWT_CLOSEBOX,  RESIZE_NONE, 13,   0,  10,   0,  13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   111
{    WWT_CAPTION, RESIZE_NONE, 13,  11, 337,   0,  13, STR_WORLD_GENERATION_CAPTION, STR_NULL},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   112
{      WWT_PANEL, RESIZE_NONE, 13,   0, 337,  14, 267, 0x0,                          STR_NULL},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   113
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   114
{   WWT_IMGBTN_2, RESIZE_NONE, 12,  10,  86,  24,  78, SPR_SELECT_TEMPERATE,         STR_030E_SELECT_TEMPERATE_LANDSCAPE},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   115
{   WWT_IMGBTN_2, RESIZE_NONE, 12,  90, 166,  24,  78, SPR_SELECT_SUB_ARCTIC,        STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   116
{   WWT_IMGBTN_2, RESIZE_NONE, 12, 170, 246,  24,  78, SPR_SELECT_SUB_TROPICAL,      STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   117
{   WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326,  24,  78, SPR_SELECT_TOYLAND,           STR_0311_SELECT_TOYLAND_LANDSCAPE},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   118
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   119
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110,  91, 101, STR_MAPSIZE,                  STR_NULL},
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   120
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 161,  90, 101, STR_NUM_1,                    STR_NULL}, // Mapsize X
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   121
{       WWT_TEXT, RESIZE_NONE,  0, 168, 176,  91, 101, STR_BY,                       STR_NULL},
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   122
{   WWT_DROPDOWN, RESIZE_NONE, 12, 180, 227,  90, 101, STR_NUM_2,                    STR_NULL}, // Mapsize Y
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   123
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   124
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 113, 123, STR_NUMBER_OF_TOWNS,          STR_NULL},
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   125
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 175, 112, 123, 0x0,                          STR_NULL}, // Number of towns
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   126
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   127
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 131, 141, STR_NUMBER_OF_INDUSTRIES,     STR_NULL},
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   128
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 175, 130, 141, 0x0,                          STR_NULL}, // Number of industries
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   129
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   130
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 153, 163, STR_RANDOM_SEED,              STR_NULL},
8737
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8433
diff changeset
   131
{    WWT_EDITBOX, RESIZE_NONE, 15, 114, 207, 152, 163, STR_RANDOM_SEED_OSKTITLE,     STR_RANDOM_SEED_HELP}, // Edit box for seed
4364
2a82f78e42af (svn r6079) -Change: size and alignment of random seed input box and randomise button
glx
parents: 4344
diff changeset
   132
{    WWT_TEXTBTN, RESIZE_NONE, 12, 216, 326, 152, 163, STR_RANDOM,                   STR_RANDOM_HELP},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   133
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   134
{    WWT_TEXTBTN, RESIZE_NONE,  6, 243, 326, 228, 257, STR_GENERATE,                 STR_NULL}, // Generate button
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   135
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   136
{       WWT_TEXT, RESIZE_NONE,  0, 182, 212, 113, 123, STR_DATE,                     STR_NULL},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   137
{     WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 112, 123, SPR_ARROW_DOWN,               STR_029E_MOVE_THE_STARTING_DATE},
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   138
{    WWT_TEXTBTN, RESIZE_NONE, 12, 228, 314, 112, 123, STR_GENERATE_DATE,            STR_NULL},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   139
{     WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 112, 123, SPR_ARROW_UP,                 STR_029F_MOVE_THE_STARTING_DATE},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   140
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   141
{       WWT_TEXT, RESIZE_NONE,  0, 182, 278, 131, 141, STR_SNOW_LINE_HEIGHT,         STR_NULL},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   142
{     WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 130, 141, SPR_ARROW_DOWN,               STR_SNOW_LINE_DOWN},
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   143
{    WWT_TEXTBTN, RESIZE_NONE, 12, 294, 314, 130, 141, STR_NUM_3,                    STR_NULL},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   144
{     WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 130, 141, SPR_ARROW_UP,                 STR_SNOW_LINE_UP},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   145
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   146
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 193, 203, STR_TREE_PLACER,              STR_NULL},
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   147
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 192, 203, 0x0,                          STR_NULL}, // Tree placer
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   148
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   149
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 175, 185, STR_LAND_GENERATOR,           STR_NULL},
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   150
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 174, 185, 0x0,                          STR_NULL}, // Landscape generator
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   151
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   152
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 211, 221, STR_TERRAIN_TYPE,             STR_NULL},
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   153
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 210, 221, 0x0,                          STR_NULL}, // Terrain type
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   154
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   155
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 229, 239, STR_QUANTITY_OF_SEA_LAKES,    STR_NULL},
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   156
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 228, 239, 0x0,                          STR_NULL}, // Water quantity
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   157
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   158
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 245, 257, STR_SMOOTHNESS,               STR_NULL},
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   159
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 246, 257, 0x0,                          STR_NULL}, // Map smoothness
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   160
{   WIDGETS_END},
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   161
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   162
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   163
static const Widget _heightmap_load_widgets[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   164
{   WWT_CLOSEBOX, RESIZE_NONE, 13,   0,  10,   0,  13, STR_00C5,                     STR_018B_CLOSE_WINDOW},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   165
{    WWT_CAPTION, RESIZE_NONE, 13,  11, 337,   0,  13, STR_WORLD_GENERATION_CAPTION, STR_NULL},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   166
{      WWT_PANEL, RESIZE_NONE, 13,   0, 337,  14, 235, 0x0,                          STR_NULL},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   167
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   168
{   WWT_IMGBTN_2, RESIZE_NONE, 12,  10,  86,  24,  78, SPR_SELECT_TEMPERATE,        STR_030E_SELECT_TEMPERATE_LANDSCAPE},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   169
{   WWT_IMGBTN_2, RESIZE_NONE, 12,  90, 166,  24,  78, SPR_SELECT_SUB_ARCTIC,       STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   170
{   WWT_IMGBTN_2, RESIZE_NONE, 12, 170, 246,  24,  78, SPR_SELECT_SUB_TROPICAL,     STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   171
{   WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326,  24,  78, SPR_SELECT_TOYLAND,          STR_0311_SELECT_TOYLAND_LANDSCAPE},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   172
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   173
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 113, 123, STR_MAPSIZE,                  STR_NULL},
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   174
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 161, 112, 123, STR_NUM_1,                    STR_NULL}, // Mapsize X
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   175
{       WWT_TEXT, RESIZE_NONE,  0, 168, 176, 113, 123, STR_BY,                       STR_NULL},
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   176
{   WWT_DROPDOWN, RESIZE_NONE, 12, 180, 227, 112, 123, STR_NUM_2,                    STR_NULL}, // Mapsize Y
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   177
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   178
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 135, 145, STR_NUMBER_OF_TOWNS,          STR_NULL},
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   179
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 175, 134, 145, 0x0,                          STR_NULL}, // Number of towns
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   180
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   181
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 153, 163, STR_NUMBER_OF_INDUSTRIES,     STR_NULL},
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   182
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 175, 152, 163, 0x0,                          STR_NULL}, // Number of industries
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   183
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   184
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 175, 185, STR_RANDOM_SEED,              STR_NULL},
8737
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8433
diff changeset
   185
{    WWT_EDITBOX, RESIZE_NONE, 15, 114, 207, 174, 185, STR_RANDOM_SEED_OSKTITLE,     STR_RANDOM_SEED_HELP}, // Edit box for seed
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   186
{    WWT_TEXTBTN, RESIZE_NONE, 12, 216, 326, 174, 185, STR_RANDOM,                   STR_RANDOM_HELP},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   187
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   188
{    WWT_TEXTBTN, RESIZE_NONE,  6, 243, 326, 196, 225, STR_GENERATE,                 STR_NULL}, // Generate button
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   189
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   190
{       WWT_TEXT, RESIZE_NONE,  0, 182, 212, 135, 145, STR_DATE,                     STR_NULL},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   191
{     WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 134, 145, SPR_ARROW_DOWN,               STR_029E_MOVE_THE_STARTING_DATE},
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   192
{    WWT_TEXTBTN, RESIZE_NONE, 12, 228, 314, 134, 145, STR_GENERATE_DATE,            STR_NULL},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   193
{     WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 134, 145, SPR_ARROW_UP,                 STR_029F_MOVE_THE_STARTING_DATE},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   194
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   195
{       WWT_TEXT, RESIZE_NONE,  0, 182, 278, 153, 163, STR_SNOW_LINE_HEIGHT,         STR_NULL},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   196
{     WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 152, 163, SPR_ARROW_DOWN,               STR_SNOW_LINE_DOWN},
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   197
{    WWT_TEXTBTN, RESIZE_NONE, 12, 294, 314, 152, 163, STR_NUM_3,                    STR_NULL},
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   198
{     WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 152, 163, SPR_ARROW_UP,                 STR_SNOW_LINE_UP},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   199
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   200
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 197, 207, STR_TREE_PLACER,              STR_NULL},
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   201
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 196, 207, STR_0225,                     STR_NULL}, // Tree placer
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   202
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   203
{       WWT_TEXT, RESIZE_NONE,  0,  12, 110, 215, 225, STR_HEIGHTMAP_ROTATION,       STR_NULL},
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   204
{   WWT_DROPDOWN, RESIZE_NONE, 12, 114, 231, 214, 225, STR_0225,                     STR_NULL}, // Heightmap rotation
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   205
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   206
{   WIDGETS_END},
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   207
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   208
5899
6f5ece1805fe (svn r8522) -Regression (r8512): The flat/random window moved the to scenario editor did not use the right settings for generating land
Darkvater
parents: 5894
diff changeset
   209
void StartGeneratingLandscape(glwp_modes mode)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   210
{
5899
6f5ece1805fe (svn r8522) -Regression (r8512): The flat/random window moved the to scenario editor did not use the right settings for generating land
Darkvater
parents: 5894
diff changeset
   211
	DeleteAllNonVitalWindows();
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   212
5899
6f5ece1805fe (svn r8522) -Regression (r8512): The flat/random window moved the to scenario editor did not use the right settings for generating land
Darkvater
parents: 5894
diff changeset
   213
	/* Copy all XXX_newgame to XXX when coming from outside the editor */
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   214
	UpdatePatches();
5899
6f5ece1805fe (svn r8522) -Regression (r8512): The flat/random window moved the to scenario editor did not use the right settings for generating land
Darkvater
parents: 5894
diff changeset
   215
	_opt = _opt_newgame;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   216
	_opt_ptr = &_opt;
5228
26dc9acf7d94 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents: 5213
diff changeset
   217
	ResetGRFConfig(true);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   218
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   219
	SndPlayFx(SND_15_BEEP);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   220
	switch (mode) {
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   221
		case GLWP_GENERATE:  _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND    : SM_NEWGAME;         break;
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   222
		case GLWP_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break;
5899
6f5ece1805fe (svn r8522) -Regression (r8512): The flat/random window moved the to scenario editor did not use the right settings for generating land
Darkvater
parents: 5894
diff changeset
   223
		case GLWP_SCENARIO:  _switch_mode = SM_EDITOR; break;
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   224
		default: NOT_REACHED();
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   225
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   226
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   227
6571
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   228
static void LandscapeGenerationCallback(Window *w, bool confirmed)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   229
{
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   230
	if (confirmed) StartGeneratingLandscape((glwp_modes)w->window_number);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   231
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   232
8327
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   233
static DropDownList *BuildMapsizeDropDown()
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   234
{
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   235
	DropDownList *list = new DropDownList();
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   236
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   237
	for (uint i = 6; i <= 11; i++) {
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   238
		DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   239
		item->SetParam(0, 1 << i);
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   240
		list->push_back(item);
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   241
	}
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   242
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   243
	return list;
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   244
}
201e0042e83e (svn r11893) -Codechange: build map size drop downs dynamically and remove unneeded strings
peter1138
parents: 8284
diff changeset
   245
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   246
static void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   247
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   248
	static const StringID elevations[]  = {STR_682A_VERY_FLAT, STR_682B_FLAT, STR_682C_HILLY, STR_682D_MOUNTAINOUS, INVALID_STRING_ID};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   249
	static const StringID sea_lakes[]   = {STR_VERY_LOW, STR_6820_LOW, STR_6821_MEDIUM, STR_6822_HIGH, INVALID_STRING_ID};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   250
	static const StringID smoothness[]  = {STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_SMOOTH, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_ROUGH, STR_CONFIG_PATCHES_ROUGHNESS_OF_TERRAIN_VERY_ROUGH, INVALID_STRING_ID};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   251
	static const StringID tree_placer[] = {STR_CONFIG_PATCHES_TREE_PLACER_NONE, STR_CONFIG_PATCHES_TREE_PLACER_ORIGINAL, STR_CONFIG_PATCHES_TREE_PLACER_IMPROVED, INVALID_STRING_ID};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   252
	static const StringID rotation[]    = {STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_PATCHES_HEIGHTMAP_ROTATION_CLOCKWISE, INVALID_STRING_ID};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   253
	static const StringID landscape[]   = {STR_CONFIG_PATCHES_LAND_GENERATOR_ORIGINAL, STR_CONFIG_PATCHES_LAND_GENERATOR_TERRA_GENESIS, INVALID_STRING_ID};
6560
24106d85dcf5 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 6481
diff changeset
   254
	static const StringID num_towns[]   = {STR_NUM_VERY_LOW, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
8424
c3477565c975 (svn r11994) -Codechange: Remove numbers from string names where the strings aren't present in TTD, since they don't correspond to either TTD's TextIDs or OpenTTD's StringIDs.
maedhros
parents: 8355
diff changeset
   255
	static const StringID num_inds[]    = {STR_NONE, STR_NUM_VERY_LOW, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   256
5464
a87a7f4b1acd (svn r7733) -Fix (r5946): do not use WP(w, querystr_d) and WP(w, def_d) for the same window.
rubidium
parents: 5431
diff changeset
   257
	/* Data used for the generate seed edit box */
a87a7f4b1acd (svn r7733) -Fix (r5946): do not use WP(w, querystr_d) and WP(w, def_d) for the same window.
rubidium
parents: 5431
diff changeset
   258
	static querystr_d _genseed_query;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   259
	static char _genseed_buffer[11];
5464
a87a7f4b1acd (svn r7733) -Fix (r5946): do not use WP(w, querystr_d) and WP(w, def_d) for the same window.
rubidium
parents: 5431
diff changeset
   260
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   261
	glwp_modes mode = (glwp_modes)w->window_number;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   262
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   263
	switch (e->event) {
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   264
		case WE_CREATE:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   265
			w->LowerWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
8341
b557ca10fdff (svn r11907) -Codechange: clean up of worldgen/heightmap ui: replace many separate DrawString() calls with widgets, use dropdown widgets, and use consistent positioning/sizing.
peter1138
parents: 8327
diff changeset
   266
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   267
			snprintf(_genseed_buffer, sizeof(_genseed_buffer), "%u", _patches_newgame.generation_seed);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   268
			InitializeTextBuffer(&_genseed_query.text, _genseed_buffer, lengthof(_genseed_buffer), 120);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   269
			_genseed_query.caption = STR_NULL;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   270
			_genseed_query.afilter = CS_NUMERAL;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   271
			break;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   272
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   273
		case WE_PAINT:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   274
			/* You can't select smoothness if not terragenesis */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   275
			if (mode == GLWP_GENERATE) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   276
				w->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _patches_newgame.land_generator == 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   277
			}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   278
			/* Disable snowline if not hilly */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   279
			w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _opt_newgame.landscape != LT_ARCTIC);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   280
			/* Disable town, industry and trees in SE */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   281
			w->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN,     _game_mode == GM_EDITOR);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   282
			w->SetWidgetDisabledState(GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   283
			w->SetWidgetDisabledState(GLAND_TREE_PULLDOWN,     _game_mode == GM_EDITOR);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   284
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   285
			w->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   286
			w->SetWidgetDisabledState(GLAND_START_DATE_UP,   _patches_newgame.starting_year >= MAX_YEAR);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   287
			w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _patches_newgame.snow_line_height <= 2 || _opt_newgame.landscape != LT_ARCTIC);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   288
			w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP,   _patches_newgame.snow_line_height >= MAX_SNOWLINE_HEIGHT || _opt_newgame.landscape != LT_ARCTIC);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   289
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   290
			w->SetWidgetLoweredState(GLAND_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   291
			w->SetWidgetLoweredState(GLAND_ARCTIC,    _opt_newgame.landscape == LT_ARCTIC);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   292
			w->SetWidgetLoweredState(GLAND_TROPICAL,  _opt_newgame.landscape == LT_TROPIC);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   293
			w->SetWidgetLoweredState(GLAND_TOYLAND,   _opt_newgame.landscape == LT_TOYLAND);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   294
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   295
			if (_game_mode == GM_EDITOR) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   296
				w->widget[GLAND_TOWN_PULLDOWN].data     = STR_6836_OFF;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   297
				w->widget[GLAND_INDUSTRY_PULLDOWN].data = STR_6836_OFF;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   298
			} else {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   299
				w->widget[GLAND_TOWN_PULLDOWN].data     = num_towns[_opt_newgame.diff.number_towns];
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   300
				w->widget[GLAND_INDUSTRY_PULLDOWN].data = num_inds[_opt_newgame.diff.number_industries];
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   301
			}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   302
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   303
			if (mode == GLWP_GENERATE) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   304
				w->widget[GLAND_LANDSCAPE_PULLDOWN].data  = landscape[_patches_newgame.land_generator];
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   305
				w->widget[GLAND_TREE_PULLDOWN].data       = tree_placer[_patches_newgame.tree_placer];
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   306
				w->widget[GLAND_TERRAIN_PULLDOWN].data    = elevations[_opt_newgame.diff.terrain_type];
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   307
				w->widget[GLAND_WATER_PULLDOWN].data      = sea_lakes[_opt_newgame.diff.quantity_sea_lakes];
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   308
				w->widget[GLAND_SMOOTHNESS_PULLDOWN].data = smoothness[_patches_newgame.tgen_smoothness];
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   309
			} else {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   310
				w->widget[GLAND_TREE_PULLDOWN].data               = tree_placer[_patches_newgame.tree_placer];
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   311
				w->widget[GLAND_HEIGHTMAP_ROTATION_PULLDOWN].data = rotation[_patches_newgame.heightmap_rotation];
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   312
			}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   313
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   314
			/* Set parameters for widget text that requires them. */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   315
			SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); // GLAND_START_DATE_TEXT
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   316
			SetDParam(1, 1 << _patches_newgame.map_x); // GLAND_MAPSIZE_X_PULLDOWN
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   317
			SetDParam(2, 1 << _patches_newgame.map_y); // GLAND_MAPSIZE_Y_PULLDOWN
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   318
			SetDParam(3, _patches_newgame.snow_line_height); // GLAND_SNOW_LEVEL_TEXT
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   319
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   320
			DrawWindowWidgets(w);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   321
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   322
			DrawEditBox(w, &_genseed_query, GLAND_RANDOM_EDITBOX);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   323
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   324
			if (mode != GLWP_GENERATE) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   325
				char buffer[512];
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   326
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   327
				if (_patches_newgame.heightmap_rotation == HM_CLOCKWISE) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   328
					SetDParam(0, WP(w, generate_d).y);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   329
					SetDParam(1, WP(w, generate_d).x);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   330
				} else {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   331
					SetDParam(0, WP(w, generate_d).x);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   332
					SetDParam(1, WP(w, generate_d).y);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   333
				}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   334
				GetString(buffer, STR_HEIGHTMAP_SIZE, lastof(buffer));
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   335
				DrawStringRightAligned(326, 91, STR_HEIGHTMAP_SIZE, TC_BLACK);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   336
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   337
				DrawString( 12,  91, STR_HEIGHTMAP_NAME, TC_BLACK);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   338
				SetDParamStr(0, WP(w, generate_d).name);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   339
				DrawStringTruncated(114,  91, STR_ORANGE, TC_BLACK, 326 - 114 - GetStringBoundingBox(buffer).width - 5);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   340
			}
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   341
			break;
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   342
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   343
		case WE_CLICK:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   344
			switch (e->we.click.widget) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   345
				case 0: DeleteWindow(w); break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   346
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   347
				case GLAND_TEMPERATE:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   348
				case GLAND_ARCTIC:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   349
				case GLAND_TROPICAL:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   350
				case GLAND_TOYLAND:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   351
					w->RaiseWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   352
					SetNewLandscapeType(e->we.click.widget - GLAND_TEMPERATE);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   353
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   354
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   355
				case GLAND_MAPSIZE_X_PULLDOWN: // Mapsize X
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   356
					ShowDropDownList(w, BuildMapsizeDropDown(), _patches_newgame.map_x, GLAND_MAPSIZE_X_PULLDOWN);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   357
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   358
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   359
				case GLAND_MAPSIZE_Y_PULLDOWN: // Mapsize Y
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   360
					ShowDropDownList(w, BuildMapsizeDropDown(), _patches_newgame.map_y, GLAND_MAPSIZE_Y_PULLDOWN);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   361
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   362
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   363
				case GLAND_TOWN_PULLDOWN: // Number of towns
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   364
					ShowDropDownMenu(w, num_towns, _opt_newgame.diff.number_towns, GLAND_TOWN_PULLDOWN, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   365
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   366
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   367
				case GLAND_INDUSTRY_PULLDOWN: // Number of industries
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   368
					ShowDropDownMenu(w, num_inds, _opt_newgame.diff.number_industries, GLAND_INDUSTRY_PULLDOWN, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   369
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   370
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   371
				case GLAND_RANDOM_BUTTON: // Random seed
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   372
					_patches_newgame.generation_seed = InteractiveRandom();
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   373
					snprintf(_genseed_buffer, lengthof(_genseed_buffer), "%u", _patches_newgame.generation_seed);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   374
					UpdateTextBufferSize(&_genseed_query.text);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   375
					SetWindowDirty(w);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   376
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   377
8737
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8433
diff changeset
   378
				case GLAND_RANDOM_EDITBOX: // edit box for random seed
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8433
diff changeset
   379
					ShowOnScreenKeyboard(w, & _genseed_query, GLAND_RANDOM_EDITBOX, 0, 0);
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8433
diff changeset
   380
					break;
4405e2e80db6 (svn r12425) -Feature [FS#1846]: On Screen Keyboard for input fields so someone without a keyboard can enter text too. Patch by Dominik.
rubidium
parents: 8433
diff changeset
   381
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   382
				case GLAND_GENERATE_BUTTON: // Generate
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   383
					UpdatePatches();
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   384
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   385
					if (_patches.town_layout == TL_NO_ROADS) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   386
						ShowQuery(
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   387
							STR_TOWN_LAYOUT_WARNING_CAPTION,
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   388
							STR_TOWN_LAYOUT_WARNING_MESSAGE,
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   389
							w,
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   390
							LandscapeGenerationCallback);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   391
					} else if (mode == GLWP_HEIGHTMAP &&
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   392
							(WP(w, generate_d).x * 2 < (1U << _patches_newgame.map_x) ||
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   393
							WP(w, generate_d).x / 2 > (1U << _patches_newgame.map_x) ||
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   394
							WP(w, generate_d).y * 2 < (1U << _patches_newgame.map_y) ||
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   395
							WP(w, generate_d).y / 2 > (1U << _patches_newgame.map_y))) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   396
						ShowQuery(
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   397
							STR_HEIGHTMAP_SCALE_WARNING_CAPTION,
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   398
							STR_HEIGHTMAP_SCALE_WARNING_MESSAGE,
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   399
							w,
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   400
							LandscapeGenerationCallback);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   401
					} else {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   402
						StartGeneratingLandscape(mode);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   403
					}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   404
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   405
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   406
				case GLAND_START_DATE_DOWN:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   407
				case GLAND_START_DATE_UP: // Year buttons
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   408
					/* Don't allow too fast scrolling */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   409
					if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   410
						w->HandleButtonClick(e->we.click.widget);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   411
						SetWindowDirty(w);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   412
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   413
						_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   414
					}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   415
					_left_button_clicked = false;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   416
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   417
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   418
				case GLAND_START_DATE_TEXT: // Year text
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   419
					WP(w, generate_d).widget_id = GLAND_START_DATE_TEXT;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   420
					SetDParam(0, _patches_newgame.starting_year);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   421
					ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, w, CS_NUMERAL);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   422
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   423
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   424
				case GLAND_SNOW_LEVEL_DOWN:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   425
				case GLAND_SNOW_LEVEL_UP: // Snow line buttons
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   426
					/* Don't allow too fast scrolling */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   427
					if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   428
						w->HandleButtonClick(e->we.click.widget);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   429
						SetWindowDirty(w);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   430
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   431
						_patches_newgame.snow_line_height = Clamp(_patches_newgame.snow_line_height + e->we.click.widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   432
					}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   433
					_left_button_clicked = false;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   434
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   435
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   436
				case GLAND_SNOW_LEVEL_TEXT: // Snow line text
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   437
					WP(w, generate_d).widget_id = GLAND_SNOW_LEVEL_TEXT;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   438
					SetDParam(0, _patches_newgame.snow_line_height);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   439
					ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, w, CS_NUMERAL);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   440
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   441
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   442
				case GLAND_TREE_PULLDOWN: // Tree placer
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   443
					ShowDropDownMenu(w, tree_placer, _patches_newgame.tree_placer, GLAND_TREE_PULLDOWN, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   444
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   445
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   446
				case GLAND_LANDSCAPE_PULLDOWN: // Landscape generator OR Heightmap rotation
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   447
				/* case GLAND_HEIGHTMAP_ROTATION_TEXT: case GLAND_HEIGHTMAP_ROTATION_PULLDOWN:*/
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   448
					if (mode == GLWP_HEIGHTMAP) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   449
						ShowDropDownMenu(w, rotation, _patches_newgame.heightmap_rotation, GLAND_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   450
					} else {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   451
						ShowDropDownMenu(w, landscape, _patches_newgame.land_generator, GLAND_LANDSCAPE_PULLDOWN, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   452
					}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   453
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   454
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   455
				case GLAND_TERRAIN_PULLDOWN: // Terrain type
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   456
					ShowDropDownMenu(w, elevations, _opt_newgame.diff.terrain_type, GLAND_TERRAIN_PULLDOWN, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   457
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   458
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   459
				case GLAND_WATER_PULLDOWN: // Water quantity
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   460
					ShowDropDownMenu(w, sea_lakes, _opt_newgame.diff.quantity_sea_lakes, GLAND_WATER_PULLDOWN, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   461
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   462
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   463
				case GLAND_SMOOTHNESS_PULLDOWN: // Map smoothness
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   464
					ShowDropDownMenu(w, smoothness, _patches_newgame.tgen_smoothness, GLAND_SMOOTHNESS_PULLDOWN, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   465
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   466
			}
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   467
			break;
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   468
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   469
		case WE_MOUSELOOP:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   470
			HandleEditBox(w, &_genseed_query, GLAND_RANDOM_EDITBOX);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   471
			break;
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   472
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   473
		case WE_KEYPRESS:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   474
			HandleEditBoxKey(w, &_genseed_query, GLAND_RANDOM_EDITBOX, e);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   475
			/* the seed is unsigned, therefore atoi cannot be used.
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   476
			 * As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   477
			 * (use random seed) it should not be possible to be
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   478
			 * entered into the input field; the generate seed
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   479
			 * button can be used instead. */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   480
			_patches_newgame.generation_seed = minu(strtoul(_genseed_buffer, NULL, sizeof(_genseed_buffer) - 1), MAX_UVALUE(uint32) - 1);
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   481
			break;
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   482
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   483
		case WE_DROPDOWN_SELECT:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   484
			switch (e->we.dropdown.button) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   485
				case GLAND_MAPSIZE_X_PULLDOWN:  _patches_newgame.map_x = e->we.dropdown.index; break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   486
				case GLAND_MAPSIZE_Y_PULLDOWN:  _patches_newgame.map_y = e->we.dropdown.index; break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   487
				case GLAND_TREE_PULLDOWN:       _patches_newgame.tree_placer = e->we.dropdown.index; break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   488
				case GLAND_SMOOTHNESS_PULLDOWN: _patches_newgame.tgen_smoothness = e->we.dropdown.index;  break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   489
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   490
				case GLAND_TOWN_PULLDOWN:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   491
					_opt_newgame.diff.number_towns = e->we.dropdown.index;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   492
					if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   493
					DoCommandP(0, 2, _opt_newgame.diff.number_towns, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   494
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   495
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   496
				case GLAND_INDUSTRY_PULLDOWN:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   497
					_opt_newgame.diff.number_industries = e->we.dropdown.index;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   498
					if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   499
					DoCommandP(0, 3, _opt_newgame.diff.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   500
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   501
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   502
				case GLAND_LANDSCAPE_PULLDOWN:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   503
				/* case GLAND_HEIGHTMAP_PULLDOWN: */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   504
					if (mode == GLWP_HEIGHTMAP) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   505
						_patches_newgame.heightmap_rotation = e->we.dropdown.index;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   506
					} else {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   507
						_patches_newgame.land_generator = e->we.dropdown.index;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   508
					}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   509
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   510
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   511
				case GLAND_TERRAIN_PULLDOWN:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   512
					_opt_newgame.diff.terrain_type = e->we.dropdown.index;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   513
					if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   514
					DoCommandP(0, 12, _opt_newgame.diff.terrain_type, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   515
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   516
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   517
				case GLAND_WATER_PULLDOWN:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   518
					_opt_newgame.diff.quantity_sea_lakes = e->we.dropdown.index;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   519
					if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   520
					DoCommandP(0, 13, _opt_newgame.diff.quantity_sea_lakes, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   521
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   522
			}
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   523
			SetWindowDirty(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   524
			break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   525
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   526
		case WE_ON_EDIT_TEXT:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   527
			if (e->we.edittext.str != NULL) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   528
				int32 value = atoi(e->we.edittext.str);
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   529
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   530
				switch (WP(w, generate_d).widget_id) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   531
					case GLAND_START_DATE_TEXT:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   532
						w->InvalidateWidget(GLAND_START_DATE_TEXT);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   533
						_patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   534
						break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   535
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   536
					case GLAND_SNOW_LEVEL_TEXT:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   537
						w->InvalidateWidget(GLAND_SNOW_LEVEL_TEXT);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   538
						_patches_newgame.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   539
						break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   540
				}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   541
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   542
				SetWindowDirty(w);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   543
			}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   544
			break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   545
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   546
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   547
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   548
static const WindowDesc _generate_landscape_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7313
diff changeset
   549
	WDP_CENTER, WDP_CENTER, 338, 268, 338, 268,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5892
diff changeset
   550
	WC_GENERATE_LANDSCAPE, WC_NONE,
8019
fc0e94dee165 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents: 8018
diff changeset
   551
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   552
	_generate_landscape_widgets,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   553
	GenerateLandscapeWndProc,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   554
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   555
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   556
static const WindowDesc _heightmap_load_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7313
diff changeset
   557
	WDP_CENTER, WDP_CENTER, 338, 236, 338, 236,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5892
diff changeset
   558
	WC_GENERATE_LANDSCAPE, WC_NONE,
8019
fc0e94dee165 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents: 8018
diff changeset
   559
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   560
	_heightmap_load_widgets,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   561
	GenerateLandscapeWndProc,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   562
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   563
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   564
static void _ShowGenerateLandscape(glwp_modes mode)
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   565
{
7103
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   566
	uint x = 0;
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   567
	uint y = 0;
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   568
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   569
	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   570
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   571
	/* Always give a new seed if not editor */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   572
	if (_game_mode != GM_EDITOR) _patches_newgame.generation_seed = InteractiveRandom();
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   573
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   574
	if (mode == GLWP_HEIGHTMAP) {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   575
		/* If the function returns negative, it means there was a problem loading the heightmap */
7103
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   576
		if (!GetHeightmapDimensions(_file_to_saveload.name, &x, &y)) return;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   577
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   578
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   579
	Window *w = AllocateWindowDescFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   580
7103
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   581
	if (w == NULL) return;
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   582
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   583
	if (mode == GLWP_HEIGHTMAP) {
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   584
		WP(w, generate_d).x = x;
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   585
		WP(w, generate_d).y = y;
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   586
		strecpy(WP(w, generate_d).name, _file_to_saveload.title, lastof(WP(w, generate_d).name));
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   587
	}
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   588
e10badf500c8 (svn r10370) -Fix: Heightmap GUI abused custom name system and used unnecessary globals. All details are now kept within the window's custom data.
peter1138
parents: 7018
diff changeset
   589
	InvalidateWindow(WC_GENERATE_LANDSCAPE, mode);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   590
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   591
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   592
void ShowGenerateLandscape()
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   593
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   594
	_ShowGenerateLandscape(GLWP_GENERATE);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   595
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   596
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   597
void ShowHeightmapLoad()
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   598
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   599
	_ShowGenerateLandscape(GLWP_HEIGHTMAP);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   600
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   601
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   602
void StartScenarioEditor()
5899
6f5ece1805fe (svn r8522) -Regression (r8512): The flat/random window moved the to scenario editor did not use the right settings for generating land
Darkvater
parents: 5894
diff changeset
   603
{
6571
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   604
	if (_patches_newgame.town_layout == TL_NO_ROADS) {
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   605
		_patches_newgame.town_layout = TL_ORIGINAL;
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   606
	}
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   607
5899
6f5ece1805fe (svn r8522) -Regression (r8512): The flat/random window moved the to scenario editor did not use the right settings for generating land
Darkvater
parents: 5894
diff changeset
   608
	StartGeneratingLandscape(GLWP_SCENARIO);
6f5ece1805fe (svn r8522) -Regression (r8512): The flat/random window moved the to scenario editor did not use the right settings for generating land
Darkvater
parents: 5894
diff changeset
   609
}
6f5ece1805fe (svn r8522) -Regression (r8512): The flat/random window moved the to scenario editor did not use the right settings for generating land
Darkvater
parents: 5894
diff changeset
   610
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   611
void StartNewGameWithoutGUI(uint seed)
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   612
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   613
	/* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   614
	_patches_newgame.generation_seed = seed;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   615
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   616
	StartGeneratingLandscape(GLWP_GENERATE);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   617
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   618
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   619
enum CreateScenarioWindowWidgets {
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   620
	CSCEN_TEMPERATE = 3,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   621
	CSCEN_ARCTIC,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   622
	CSCEN_TROPICAL,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   623
	CSCEN_TOYLAND,
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   624
	CSCEN_EMPTY_WORLD,
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   625
	CSCEN_RANDOM_WORLD,
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   626
	CSCEN_MAPSIZE_X_TEXT,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   627
	CSCEN_MAPSIZE_X_PULLDOWN,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   628
	CSCEN_MAPSIZE_Y_TEXT,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   629
	CSCEN_MAPSIZE_Y_PULLDOWN,
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   630
	CSCEN_START_DATE_LABEL,
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   631
	CSCEN_START_DATE_DOWN,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   632
	CSCEN_START_DATE_TEXT,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   633
	CSCEN_START_DATE_UP,
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   634
	CSCEN_FLAT_LAND_HEIGHT_LABEL,
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   635
	CSCEN_FLAT_LAND_HEIGHT_DOWN,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   636
	CSCEN_FLAT_LAND_HEIGHT_TEXT,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   637
	CSCEN_FLAT_LAND_HEIGHT_UP
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   638
};
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   639
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   640
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   641
static void CreateScenarioWndProc(Window *w, WindowEvent *e)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   642
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   643
	switch (e->event) {
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   644
		case WE_CREATE:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   645
			w->LowerWidget(_opt_newgame.landscape + CSCEN_TEMPERATE);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   646
			break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   647
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   648
		case WE_PAINT:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   649
			w->SetWidgetDisabledState(CSCEN_START_DATE_DOWN,       _patches_newgame.starting_year <= MIN_YEAR);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   650
			w->SetWidgetDisabledState(CSCEN_START_DATE_UP,         _patches_newgame.starting_year >= MAX_YEAR);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   651
			w->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_DOWN, _patches_newgame.se_flat_world_height <= 0);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   652
			w->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_UP,   _patches_newgame.se_flat_world_height >= MAX_TILE_HEIGHT);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   653
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   654
			w->SetWidgetLoweredState(CSCEN_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   655
			w->SetWidgetLoweredState(CSCEN_ARCTIC,    _opt_newgame.landscape == LT_ARCTIC);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   656
			w->SetWidgetLoweredState(CSCEN_TROPICAL,  _opt_newgame.landscape == LT_TROPIC);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   657
			w->SetWidgetLoweredState(CSCEN_TOYLAND,   _opt_newgame.landscape == LT_TOYLAND);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   658
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   659
			/* Set parameters for widget text that requires them */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   660
			SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1)); // CSCEN_START_DATE_TEXT
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   661
			SetDParam(1, 1 << _patches_newgame.map_x); // CSCEN_MAPSIZE_X_PULLDOWN
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   662
			SetDParam(2, 1 << _patches_newgame.map_y); // CSCEN_MAPSIZE_Y_PULLDOWN
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   663
			SetDParam(3, _patches_newgame.se_flat_world_height); // CSCEN_FLAT_LAND_HEIGHT_TEXT
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   664
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   665
			DrawWindowWidgets(w);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   666
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   667
			break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   668
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   669
		case WE_CLICK:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   670
			switch (e->we.click.widget) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   671
				case CSCEN_TEMPERATE:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   672
				case CSCEN_ARCTIC:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   673
				case CSCEN_TROPICAL:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   674
				case CSCEN_TOYLAND:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   675
					w->RaiseWidget(_opt_newgame.landscape + CSCEN_TEMPERATE);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   676
					SetNewLandscapeType(e->we.click.widget - CSCEN_TEMPERATE);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   677
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   678
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   679
				case CSCEN_MAPSIZE_X_PULLDOWN: // Mapsize X
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   680
					ShowDropDownList(w, BuildMapsizeDropDown(), _patches_newgame.map_x, CSCEN_MAPSIZE_X_PULLDOWN);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   681
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   682
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   683
				case CSCEN_MAPSIZE_Y_PULLDOWN: // Mapsize Y
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   684
					ShowDropDownList(w, BuildMapsizeDropDown(), _patches_newgame.map_y, CSCEN_MAPSIZE_Y_PULLDOWN);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   685
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   686
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   687
				case CSCEN_EMPTY_WORLD: // Empty world / flat world
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   688
					StartGeneratingLandscape(GLWP_SCENARIO);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   689
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   690
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   691
				case CSCEN_RANDOM_WORLD: // Generate
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   692
					ShowGenerateLandscape();
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   693
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   694
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   695
				case CSCEN_START_DATE_DOWN:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   696
				case CSCEN_START_DATE_UP: // Year buttons
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   697
					/* Don't allow too fast scrolling */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   698
					if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   699
						w->HandleButtonClick(e->we.click.widget);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   700
						SetWindowDirty(w);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   701
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   702
						_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   703
					}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   704
					_left_button_clicked = false;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   705
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   706
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   707
				case CSCEN_START_DATE_TEXT: // Year text
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   708
					WP(w, generate_d).widget_id = CSCEN_START_DATE_TEXT;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   709
					SetDParam(0, _patches_newgame.starting_year);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   710
					ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, w, CS_NUMERAL);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   711
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   712
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   713
				case CSCEN_FLAT_LAND_HEIGHT_DOWN:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   714
				case CSCEN_FLAT_LAND_HEIGHT_UP: // Height level buttons
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   715
					/* Don't allow too fast scrolling */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   716
					if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   717
						w->HandleButtonClick(e->we.click.widget);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   718
						SetWindowDirty(w);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   719
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   720
						_patches_newgame.se_flat_world_height = Clamp(_patches_newgame.se_flat_world_height + e->we.click.widget - CSCEN_FLAT_LAND_HEIGHT_TEXT, 0, MAX_TILE_HEIGHT);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   721
					}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   722
					_left_button_clicked = false;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   723
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   724
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   725
				case CSCEN_FLAT_LAND_HEIGHT_TEXT: // Height level text
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   726
					WP(w, generate_d).widget_id = CSCEN_FLAT_LAND_HEIGHT_TEXT;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   727
					SetDParam(0, _patches_newgame.se_flat_world_height);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   728
					ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_FLAT_WORLD_HEIGHT_QUERY_CAPT, 3, 100, w, CS_NUMERAL);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   729
					break;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   730
			}
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   731
			break;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   732
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   733
		case WE_DROPDOWN_SELECT:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   734
			switch (e->we.dropdown.button) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   735
				case CSCEN_MAPSIZE_X_PULLDOWN: _patches_newgame.map_x = e->we.dropdown.index; break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   736
				case CSCEN_MAPSIZE_Y_PULLDOWN: _patches_newgame.map_y = e->we.dropdown.index; break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   737
			}
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   738
			SetWindowDirty(w);
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   739
			break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   740
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   741
		case WE_ON_EDIT_TEXT:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   742
			if (e->we.edittext.str != NULL) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   743
				int32 value = atoi(e->we.edittext.str);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   744
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   745
				switch (WP(w, generate_d).widget_id) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   746
					case CSCEN_START_DATE_TEXT:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   747
						w->InvalidateWidget(CSCEN_START_DATE_TEXT);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   748
						_patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   749
						break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   750
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   751
					case CSCEN_FLAT_LAND_HEIGHT_TEXT:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   752
						w->InvalidateWidget(CSCEN_FLAT_LAND_HEIGHT_TEXT);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   753
						_patches_newgame.se_flat_world_height = Clamp(value, 0, MAX_TILE_HEIGHT);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   754
						break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   755
				}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   756
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   757
				SetWindowDirty(w);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   758
			}
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   759
			break;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   760
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   761
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   762
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   763
static const Widget _create_scenario_widgets[] = {
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   764
{   WWT_CLOSEBOX, RESIZE_NONE, 13,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW},
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   765
{    WWT_CAPTION, RESIZE_NONE, 13,  11, 337,   0,  13, STR_SE_CAPTION,          STR_NULL},
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   766
{      WWT_PANEL, RESIZE_NONE, 13,   0, 337,  14, 169, 0x0,                     STR_NULL},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   767
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   768
{   WWT_IMGBTN_2, RESIZE_NONE, 12,  10,  86,  24,  78, SPR_SELECT_TEMPERATE,    STR_030E_SELECT_TEMPERATE_LANDSCAPE},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   769
{   WWT_IMGBTN_2, RESIZE_NONE, 12,  90, 166,  24,  78, SPR_SELECT_SUB_ARCTIC,   STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   770
{   WWT_IMGBTN_2, RESIZE_NONE, 12, 170, 246,  24,  78, SPR_SELECT_SUB_TROPICAL, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   771
{   WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326,  24,  78, SPR_SELECT_TOYLAND,      STR_0311_SELECT_TOYLAND_LANDSCAPE},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   772
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   773
{    WWT_TEXTBTN, RESIZE_NONE,  6,  12, 115,  95, 124, STR_SE_FLAT_WORLD,       STR_SE_FLAT_WORLD_TIP},         // Empty (sea-level) map
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   774
{    WWT_TEXTBTN, RESIZE_NONE,  6,  12, 115, 131, 160, STR_SE_RANDOM_LAND,      STR_022A_GENERATE_RANDOM_LAND}, // Generate
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   775
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   776
{       WWT_TEXT, RESIZE_NONE, 12, 182, 212,  96, 106, STR_MAPSIZE,             STR_NULL},
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   777
{   WWT_DROPDOWN, RESIZE_NONE, 12, 216, 263,  95, 106, STR_NUM_1,               STR_NULL}, // Mapsize X
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   778
{       WWT_TEXT, RESIZE_NONE, 12, 268, 276,  96, 106, STR_BY,                  STR_NULL},
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   779
{   WWT_DROPDOWN, RESIZE_NONE, 12, 279, 326,  95, 106, STR_NUM_2,               STR_NULL}, // Mapsize Y
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   780
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   781
{       WWT_TEXT, RESIZE_NONE,  0, 182, 212, 114, 124, STR_DATE,                STR_NULL},
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   782
{     WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 113, 124, SPR_ARROW_DOWN,          STR_029E_MOVE_THE_STARTING_DATE},
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   783
{    WWT_TEXTBTN, RESIZE_NONE, 12, 228, 314, 113, 124, STR_GENERATE_DATE,       STR_NULL},
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   784
{     WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 113, 124, SPR_ARROW_UP,            STR_029F_MOVE_THE_STARTING_DATE},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   785
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   786
{       WWT_TEXT, RESIZE_NONE,  0, 182, 278, 132, 142, STR_FLAT_WORLD_HEIGHT,   STR_NULL},
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   787
{     WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 131, 142, SPR_ARROW_DOWN,          STR_FLAT_WORLD_HEIGHT_DOWN},
8353
056b4f562f88 (svn r11919) -Codechange: Assign numbered parameters to world generator widgets to avoid separate DrawString()s, and do the same for the scenario flat-land window.
peter1138
parents: 8341
diff changeset
   788
{    WWT_TEXTBTN, RESIZE_NONE, 12, 294, 314, 131, 142, STR_NUM_3,               STR_NULL},
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   789
{     WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 131, 142, SPR_ARROW_UP,            STR_FLAT_WORLD_HEIGHT_UP},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   790
{   WIDGETS_END},
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   791
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   792
5894
afbd6aea0d56 (svn r8512) -Codechange: From the intro window enter the scenario editor. From the scenario editor dialog, remove the 'load heightmap' option and put that with the other options like 'load scenario', 'save scenario', etc. Play a little bit with positioning of elements inside the scenario editor dialog so it looks better.
Darkvater
parents: 5893
diff changeset
   793
static const WindowDesc _create_scenario_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7313
diff changeset
   794
	WDP_CENTER, WDP_CENTER, 338, 170, 338, 170,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5892
diff changeset
   795
	WC_GENERATE_LANDSCAPE, WC_NONE,
8019
fc0e94dee165 (svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
belugas
parents: 8018
diff changeset
   796
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   797
	_create_scenario_widgets,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   798
	CreateScenarioWndProc,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   799
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   800
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   801
void ShowCreateScenario()
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   802
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   803
	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   804
	AllocateWindowDescFront(&_create_scenario_desc, GLWP_SCENARIO);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   805
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   806
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   807
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   808
static const Widget _show_terrain_progress_widgets[] = {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   809
{    WWT_CAPTION,   RESIZE_NONE,    14,     0,   180,     0,    13, STR_GENERATION_WORLD,   STR_018C_WINDOW_TITLE_DRAG_THIS},
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   810
{      WWT_PANEL,   RESIZE_NONE,    14,     0,   180,    14,    96, 0x0,                    STR_NULL},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   811
{    WWT_TEXTBTN,   RESIZE_NONE,    15,    20,   161,    74,    85, STR_GENERATION_ABORT,   STR_NULL}, // Abort button
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   812
{   WIDGETS_END},
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   813
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   814
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   815
struct tp_info {
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   816
	uint percent;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   817
	StringID cls;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   818
	uint current;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   819
	uint total;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   820
	int timer;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   821
};
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   822
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   823
static tp_info _tp;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   824
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   825
static void AbortGeneratingWorldCallback(Window *w, bool confirmed)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   826
{
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   827
	if (confirmed) {
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   828
		AbortGeneratingWorld();
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   829
	} else if (IsGeneratingWorld() && !IsGeneratingWorldAborted()) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   830
		SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   831
	}
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   832
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   833
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   834
static void ShowTerrainProgressProc(Window* w, WindowEvent* e)
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   835
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   836
	switch (e->event) {
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   837
		case WE_CLICK:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   838
			switch (e->we.click.widget) {
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   839
				case 2:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   840
					if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   841
					ShowQuery(
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   842
						STR_GENERATION_ABORT_CAPTION,
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   843
						STR_GENERATION_ABORT_MESSAGE,
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   844
						w,
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   845
						AbortGeneratingWorldCallback
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   846
					);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   847
					break;
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   848
			}
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   849
			break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   850
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   851
		case WE_PAINT:
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   852
			DrawWindowWidgets(w);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   853
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   854
			/* Draw the % complete with a bar and a text */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   855
			DrawFrameRect(19, 20, (w->width - 18), 37, 14, FR_BORDERONLY);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   856
			DrawFrameRect(20, 21, (int)((w->width - 40) * _tp.percent / 100) + 20, 36, 10, FR_NONE);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   857
			SetDParam(0, _tp.percent);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   858
			DrawStringCentered(90, 25, STR_PROGRESS, TC_FROMSTRING);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   859
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   860
			/* Tell which class we are generating */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   861
			DrawStringCentered(90, 46, _tp.cls, TC_FROMSTRING);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   862
8355
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   863
			/* And say where we are in that class */
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   864
			SetDParam(0, _tp.current);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   865
			SetDParam(1, _tp.total);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   866
			DrawStringCentered(90, 58, STR_GENERATION_PROGRESS, TC_FROMSTRING);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   867
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   868
			SetWindowDirty(w);
aafc7b4dd7bf (svn r11921) -Cleanup: correct indenting and switch case line spacing.
peter1138
parents: 8353
diff changeset
   869
			break;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   870
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   871
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   872
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   873
static const WindowDesc _show_terrain_progress_desc = {
7341
02515d0d4ced (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7313
diff changeset
   874
	WDP_CENTER, WDP_CENTER, 181, 97, 181, 97,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5892
diff changeset
   875
	WC_GENERATE_PROGRESS_WINDOW, WC_NONE,
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   876
	WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   877
	_show_terrain_progress_widgets,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   878
	ShowTerrainProgressProc
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   879
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   880
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   881
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   882
 * Initializes the progress counters to the starting point.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   883
 */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   884
void PrepareGenerateWorldProgress()
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   885
{
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   886
	_tp.cls   = STR_WORLD_GENERATION;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   887
	_tp.current = 0;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   888
	_tp.total   = 0;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   889
	_tp.percent = 0;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   890
	_tp.timer   = 0; // Forces to paint the progress window immediatelly
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   891
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   892
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   893
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   894
 * Show the window where a user can follow the process of the map generation.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   895
 */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   896
void ShowGenerateWorldProgress()
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   897
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   898
	AllocateWindowDescFront(&_show_terrain_progress_desc, 0);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   899
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   900
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   901
static void _SetGeneratingWorldProgress(gwp_class cls, uint progress, uint total)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   902
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   903
	static const int percent_table[GWP_CLASS_COUNT + 1] = {0, 5, 15, 20, 40, 60, 65, 80, 85, 99, 100 };
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   904
	static const StringID class_table[GWP_CLASS_COUNT]  = {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   905
		STR_WORLD_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   906
		STR_022E_LANDSCAPE_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   907
		STR_CLEARING_TILES,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   908
		STR_022F_TOWN_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   909
		STR_0230_INDUSTRY_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   910
		STR_UNMOVABLE_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   911
		STR_TREE_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   912
		STR_SETTINGUP_GAME,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   913
		STR_PREPARING_TILELOOP,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   914
		STR_PREPARING_GAME
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   915
	};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   916
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   917
	assert(cls < GWP_CLASS_COUNT);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   918
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   919
	/* Do not run this function if we aren't in a thread */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   920
	if (!IsGenerateWorldThreaded() && !_network_dedicated) return;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   921
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   922
	if (IsGeneratingWorldAborted()) HandleGeneratingWorldAbortion();
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   923
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   924
	if (total == 0) {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   925
		assert(_tp.cls == class_table[cls]);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   926
		_tp.current += progress;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   927
	} else {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   928
		_tp.cls   = class_table[cls];
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   929
		_tp.current = progress;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   930
		_tp.total   = total;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   931
		_tp.percent = percent_table[cls];
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   932
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   933
7018
71e174292e42 (svn r10276) -Codechange: made a counter based on milliseconds and independent of the game-state to base double-click and TGP Generation Process on
truelight
parents: 6571
diff changeset
   934
	/* Don't update the screen too often. So update it once in every 200ms */
71e174292e42 (svn r10276) -Codechange: made a counter based on milliseconds and independent of the game-state to base double-click and TGP Generation Process on
truelight
parents: 6571
diff changeset
   935
	if (!_network_dedicated && _tp.timer != 0 && _realtime_tick - _tp.timer < 200) return;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   936
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   937
	/* Percentage is about the number of completed tasks, so 'current - 1' */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   938
	_tp.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_tp.current == 0 ? 0 : _tp.current - 1) / _tp.total;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   939
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   940
	if (_network_dedicated) {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   941
		static uint last_percent = 0;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   942
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   943
		/* Never display 0% */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   944
		if (_tp.percent == 0) return;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   945
		/* Reset if percent is lower then the last recorded */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   946
		if (_tp.percent < last_percent) last_percent = 0;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   947
		/* Display every 5%, but 6% is also very valid.. just not smaller steps then 5% */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   948
		if (_tp.percent % 5 != 0 && _tp.percent <= last_percent + 5) return;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   949
		/* Never show steps smaller then 2%, even if it is a mod 5% */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   950
		if (_tp.percent <= last_percent + 2) return;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   951
5380
8ea58542b6e0 (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5228
diff changeset
   952
		DEBUG(net, 1, "Map generation percentage complete: %d", _tp.percent);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   953
		last_percent = _tp.percent;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   954
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   955
		/* Don't continue as dedicated never has a thread running */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   956
		return;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   957
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   958
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   959
	InvalidateWindow(WC_GENERATE_PROGRESS_WINDOW, 0);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   960
	MarkWholeScreenDirty();
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   961
	SetGeneratingWorldPaintStatus(true);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   962
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   963
	/* We wait here till the paint is done, so we don't read and write
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   964
	 *  on the same tile at the same moment. Nasty hack, but that happens
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   965
	 *  if you implement threading afterwards */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   966
	while (IsGeneratingWorldReadyForPaint()) { CSleep(10); }
7123
25daf2b19a33 (svn r10396) -Fix: When landscape generating, allow for 200ms between screen updates instead of updating every 200ms. Previously slow screen updates would result in very slow map generation (GeekToo)
peter1138
parents: 7103
diff changeset
   967
25daf2b19a33 (svn r10396) -Fix: When landscape generating, allow for 200ms between screen updates instead of updating every 200ms. Previously slow screen updates would result in very slow map generation (GeekToo)
peter1138
parents: 7103
diff changeset
   968
	_tp.timer = _realtime_tick;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   969
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   970
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   971
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   972
 * Set the total of a stage of the world generation.
6481
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6357
diff changeset
   973
 * @param cls the current class we are in.
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   974
 * @param total Set the total expected items for this class.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   975
 *
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   976
 * Warning: this function isn't clever. Don't go from class 4 to 3. Go upwards, always.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   977
 *  Also, progress works if total is zero, total works if progress is zero.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   978
 */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   979
void SetGeneratingWorldProgress(gwp_class cls, uint total)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   980
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   981
	if (total == 0) return;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   982
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   983
	_SetGeneratingWorldProgress(cls, 0, total);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   984
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   985
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   986
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   987
 * Increases the current stage of the world generation with one.
6481
85ad87daf4b0 (svn r9662) -Documentation: Doxygen corrections and @file omissions
belugas
parents: 6357
diff changeset
   988
 * @param cls the current class we are in.
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   989
 *
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   990
 * Warning: this function isn't clever. Don't go from class 4 to 3. Go upwards, always.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   991
 *  Also, progress works if total is zero, total works if progress is zero.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   992
 */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   993
void IncreaseGeneratingWorldProgress(gwp_class cls)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   994
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   995
	/* In fact the param 'class' isn't needed.. but for some security reasons, we want it around */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   996
	_SetGeneratingWorldProgress(cls, 1, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   997
}