src/genworld_gui.cpp
author rubidium
Wed, 19 Dec 2007 19:44:29 +0000
changeset 8106 e6790dd9e750
parent 8036 279f4cbf9ec7
child 8107 bb7deea89175
permissions -rw-r--r--
(svn r11667) -Codechange: split window.h into a header that defines some 'global' window related types, on that defined 'global' window functions and one that defines functions and types only used by *_gui.cpps.
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 "functions.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     9
#include "table/strings.h"
4366
b1d77b6c3c25 (svn r6082) -CodeChange : Remove the unneeded table/sprites.h include in newgrf_cargo.h.
belugas
parents: 4364
diff changeset
    10
#include "table/sprites.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    11
#include "gui.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    12
#include "gfx.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    13
#include "strings.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    14
#include "gfxinit.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    15
#include "player.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    16
#include "command.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    17
#include "sound.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    18
#include "variables.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    19
#include "string.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    20
#include "settings.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    21
#include "debug.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    22
#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
    23
#include "network/network.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    24
#include "thread.h"
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    25
#include "date.h"
5228
26dc9acf7d94 (svn r7348) -Feature: Initial support for saving NewGRF settings with savegames. Back up your savegames...
peter1138
parents: 5213
diff changeset
    26
#include "newgrf_config.h"
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    27
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    28
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    29
 * In what 'mode' the GenerateLandscapeWindowProc is.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    30
 */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    31
enum glwp_modes {
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    32
	GLWP_GENERATE,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    33
	GLWP_HEIGHTMAP,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    34
	GLWP_SCENARIO,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    35
	GLWP_END
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
    36
};
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    37
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
    38
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
    39
	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
    40
	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
    41
	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
    42
	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
    43
};
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    44
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    45
extern void SwitchMode(int new_mode);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    46
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    47
static inline void SetNewLandscapeType(byte landscape)
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    48
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    49
	_opt_newgame.landscape = landscape;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    50
	InvalidateWindowClasses(WC_SELECT_GAME);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    51
	InvalidateWindowClasses(WC_GENERATE_LANDSCAPE);
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
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    54
enum GenerateLandscapeWindowWidgets {
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    55
	GLAND_TEMPERATE = 3,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    56
	GLAND_ARCTIC,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    57
	GLAND_TROPICAL,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    58
	GLAND_TOYLAND,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    59
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    60
	GLAND_MAPSIZE_X_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    61
	GLAND_MAPSIZE_X_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    62
	GLAND_MAPSIZE_Y_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    63
	GLAND_MAPSIZE_Y_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    64
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    65
	GLAND_TOWN_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    66
	GLAND_TOWN_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    67
	GLAND_INDUSTRY_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    68
	GLAND_INDUSTRY_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    69
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    70
	GLAND_RANDOM_EDITBOX,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    71
	GLAND_RANDOM_BUTTON,
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_GENERATE_BUTTON,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    74
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    75
	GLAND_START_DATE_DOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    76
	GLAND_START_DATE_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    77
	GLAND_START_DATE_UP,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    78
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    79
	GLAND_SNOW_LEVEL_DOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    80
	GLAND_SNOW_LEVEL_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    81
	GLAND_SNOW_LEVEL_UP,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    82
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    83
	GLAND_TREE_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    84
	GLAND_TREE_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    85
	GLAND_LANDSCAPE_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    86
	GLAND_LANDSCAPE_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    87
	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
    88
	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
    89
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    90
	GLAND_TERRAIN_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    91
	GLAND_TERRAIN_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    92
	GLAND_WATER_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    93
	GLAND_WATER_PULLDOWN,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    94
	GLAND_SMOOTHNESS_TEXT,
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    95
	GLAND_SMOOTHNESS_PULLDOWN
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    96
};
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
    97
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
    98
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
    99
{  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
   100
{    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
   101
{      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
   102
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   103
{   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
   104
{   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
   105
{   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
   106
{   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
   107
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   108
{      WWT_PANEL, RESIZE_NONE, 12, 114, 149,  90, 101, 0x0,                          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
   109
{    WWT_TEXTBTN, RESIZE_NONE, 12, 150, 161,  90, 101, STR_0225,                     STR_NULL}, // Mapsize X
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   110
{      WWT_PANEL, RESIZE_NONE, 12, 180, 215,  90, 101, 0x0,                          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
   111
{    WWT_TEXTBTN, RESIZE_NONE, 12, 216, 227,  90, 101, STR_0225,                     STR_NULL}, // Mapsize Y
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   112
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   113
{      WWT_PANEL, RESIZE_NONE, 12, 114, 163, 112, 123, 0x0,                          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
   114
{    WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 112, 123, STR_0225,                     STR_NULL}, // Number of towns
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   115
{      WWT_PANEL, RESIZE_NONE, 12, 114, 163, 130, 141, 0x0,                          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
   116
{    WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 130, 141, STR_0225,                     STR_NULL}, // Number of industries
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
   117
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   118
{      WWT_PANEL, RESIZE_NONE, 15, 114, 207, 152, 163, 0x0,                          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
   119
{    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
   120
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
   121
{    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
   122
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
   123
{     WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 112, 123, SPR_ARROW_DOWN,               STR_029E_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
   124
{      WWT_PANEL, RESIZE_NONE, 12, 228, 314, 112, 123, 0x0,                          STR_NULL},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   125
{     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
   126
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
   127
{     WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 130, 141, SPR_ARROW_DOWN,               STR_SNOW_LINE_DOWN},
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
   128
{      WWT_PANEL, RESIZE_NONE, 12, 294, 314, 130, 141, 0x0,                          STR_NULL},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   129
{     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
   130
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   131
{      WWT_PANEL, RESIZE_NONE, 12, 114, 219, 192, 203, 0x0,                          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
   132
{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 192, 203, STR_0225,                     STR_NULL}, // Tree placer
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   133
{      WWT_PANEL, RESIZE_NONE, 12, 114, 219, 174, 185, 0x0,                          STR_NULL},
4750
b125e18e9e29 (svn r6663) -Codechange: Remove the 32 widgets limit on landscape generator.
belugas
parents: 4729
diff changeset
   134
{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 174, 185, STR_0225,                     STR_NULL}, // Landscape generator
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   135
{      WWT_PANEL, RESIZE_NONE, 12, 114, 219, 210, 221, 0x0,                          STR_NULL},
4750
b125e18e9e29 (svn r6663) -Codechange: Remove the 32 widgets limit on landscape generator.
belugas
parents: 4729
diff changeset
   136
{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 210, 221, STR_0225,                     STR_NULL}, // Terrain type
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   137
{      WWT_PANEL, RESIZE_NONE, 12, 113, 219, 228, 239, 0x0,                          STR_NULL},
4750
b125e18e9e29 (svn r6663) -Codechange: Remove the 32 widgets limit on landscape generator.
belugas
parents: 4729
diff changeset
   138
{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 228, 239, STR_0225,                     STR_NULL}, // Water quantity
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   139
{      WWT_PANEL, RESIZE_NONE, 12, 113, 219, 246, 257, 0x0,                          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
   140
{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 246, 257, STR_0225,                     STR_NULL}, // Map smoothness
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   141
{   WIDGETS_END},
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   142
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   143
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
   144
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
   145
{   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
   146
{    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
   147
{      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
   148
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   149
{   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
   150
{   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
   151
{   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
   152
{   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
   153
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   154
{      WWT_PANEL, RESIZE_NONE, 12, 114, 149, 112, 123, 0x0,                          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
   155
{    WWT_TEXTBTN, RESIZE_NONE, 12, 150, 161, 112, 123, STR_0225,                     STR_NULL}, // Mapsize X
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   156
{      WWT_PANEL, RESIZE_NONE, 12, 180, 215, 112, 123, 0x0,                          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
   157
{    WWT_TEXTBTN, RESIZE_NONE, 12, 216, 227, 112, 123, STR_0225,                     STR_NULL}, // Mapsize Y
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   158
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   159
{      WWT_PANEL, RESIZE_NONE, 12, 114, 163, 134, 145, 0x0,                          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
   160
{    WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 134, 145, STR_0225,                     STR_NULL}, // Number of towns
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   161
{      WWT_PANEL, RESIZE_NONE, 12, 114, 163, 152, 163, 0x0,                          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
   162
{    WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 152, 163, STR_0225,                     STR_NULL}, // Number of industries
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   163
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   164
{      WWT_PANEL, RESIZE_NONE, 15, 114, 194, 174, 185, 0x0,                          STR_RANDOM_SEED_HELP}, // Edit box for seed
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
   165
{    WWT_TEXTBTN, RESIZE_NONE, 12, 203, 285, 174, 185, STR_RANDOM,                   STR_RANDOM_HELP},
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   166
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
   167
{    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
   168
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
   169
{     WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 134, 145, SPR_ARROW_DOWN,               STR_029E_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
   170
{      WWT_PANEL, RESIZE_NONE, 12, 228, 314, 134, 145, 0x0,                          STR_NULL},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   171
{     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
   172
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
   173
{     WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 152, 163, SPR_ARROW_DOWN,               STR_SNOW_LINE_DOWN},
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
   174
{      WWT_PANEL, RESIZE_NONE, 12, 294, 314, 152, 163, 0x0,                          STR_NULL},
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   175
{     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
   176
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   177
{      WWT_PANEL, RESIZE_NONE, 12, 114, 219, 196, 207, 0x0,                          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
   178
{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 196, 207, STR_0225,                     STR_NULL}, // Tree placer
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
   179
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   180
{      WWT_PANEL, RESIZE_NONE, 12, 114, 219, 214, 225, 0x0,                          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
   181
{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 214, 225, STR_0225,                     STR_NULL}, // Heightmap rotation
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   182
{   WIDGETS_END},
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   183
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   184
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
   185
void StartGeneratingLandscape(glwp_modes mode)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   186
{
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
   187
	DeleteAllNonVitalWindows();
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   188
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
   189
	/* 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
   190
	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
   191
	_opt = _opt_newgame;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   192
	_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
   193
	ResetGRFConfig(true);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   194
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   195
	SndPlayFx(SND_15_BEEP);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   196
	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
   197
		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
   198
		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
   199
		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
   200
		default: NOT_REACHED();
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   201
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   202
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   203
6571
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   204
static void LandscapeGenerationCallback(Window *w, bool confirmed)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   205
{
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   206
	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
   207
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   208
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
   209
static void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   210
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   211
	static const StringID mapsizes[]    = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   212
	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
   213
	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
   214
	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
   215
	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
   216
	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
   217
	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
   218
	static const StringID num_towns[]   = {STR_NUM_VERY_LOW, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
24106d85dcf5 (svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents: 6481
diff changeset
   219
	static const StringID num_inds[]    = {STR_26816_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
   220
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
   221
	/* 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
   222
	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
   223
	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
   224
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   225
	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
   226
	uint y;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   227
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   228
	switch (e->event) {
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
   229
	case WE_CREATE:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   230
		w->LowerWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
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
   231
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
   232
		snprintf(_genseed_buffer, sizeof(_genseed_buffer), "%u", _patches_newgame.generation_seed);
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
   233
		InitializeTextBuffer(&_genseed_query.text, _genseed_buffer, lengthof(_genseed_buffer), 120);
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
   234
		_genseed_query.caption = STR_NULL;
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
   235
		_genseed_query.afilter = CS_NUMERAL;
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
   236
		break;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   237
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   238
	case WE_PAINT:
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   239
		/* You can't select smoothness if not terragenesis */
5213
f5234ffd2cc4 (svn r7328) -Fix: memory corruption. The 'Load Heightmap' window does not have TerraGenesis configuration buttons and it does have only 29 widgets, not at least 33. Thanks to Tefad for finding this bug.
rubidium
parents: 5052
diff changeset
   240
		if (mode == GLWP_GENERATE) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   241
			w->SetWidgetDisabledState(GLAND_SMOOTHNESS_TEXT,     _patches_newgame.land_generator == 0);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   242
			w->SetWidgetDisabledState(GLAND_SMOOTHNESS_PULLDOWN, _patches_newgame.land_generator == 0);
5213
f5234ffd2cc4 (svn r7328) -Fix: memory corruption. The 'Load Heightmap' window does not have TerraGenesis configuration buttons and it does have only 29 widgets, not at least 33. Thanks to Tefad for finding this bug.
rubidium
parents: 5052
diff changeset
   243
		}
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   244
		/* Disable snowline if not hilly */
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   245
		w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_TEXT, _opt_newgame.landscape != LT_ARCTIC);
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   246
		/* Disable town, industry and trees in SE */
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   247
		w->SetWidgetDisabledState(GLAND_TOWN_TEXT,         _game_mode == GM_EDITOR);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   248
		w->SetWidgetDisabledState(GLAND_TOWN_PULLDOWN,     _game_mode == GM_EDITOR);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   249
		w->SetWidgetDisabledState(GLAND_INDUSTRY_TEXT,     _game_mode == GM_EDITOR);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   250
		w->SetWidgetDisabledState(GLAND_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   251
		w->SetWidgetDisabledState(GLAND_TREE_TEXT,         _game_mode == GM_EDITOR);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   252
		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
   253
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   254
		w->SetWidgetDisabledState(GLAND_START_DATE_DOWN, _patches_newgame.starting_year <= MIN_YEAR);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   255
		w->SetWidgetDisabledState(GLAND_START_DATE_UP,   _patches_newgame.starting_year >= MAX_YEAR);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   256
		w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_DOWN, _patches_newgame.snow_line_height <= 2 || _opt_newgame.landscape != LT_ARCTIC);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   257
		w->SetWidgetDisabledState(GLAND_SNOW_LEVEL_UP,   _patches_newgame.snow_line_height >= MAX_SNOWLINE_HEIGHT || _opt_newgame.landscape != LT_ARCTIC);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   258
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   259
		w->SetWidgetLoweredState(GLAND_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   260
		w->SetWidgetLoweredState(GLAND_ARCTIC,    _opt_newgame.landscape == LT_ARCTIC);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   261
		w->SetWidgetLoweredState(GLAND_TROPICAL,  _opt_newgame.landscape == LT_TROPIC);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   262
		w->SetWidgetLoweredState(GLAND_TOYLAND,   _opt_newgame.landscape == LT_TOYLAND);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   263
		DrawWindowWidgets(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   264
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   265
		y = (mode == GLWP_HEIGHTMAP) ? 22 : 0;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   266
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   267
		DrawString( 12,  91 + y, STR_MAPSIZE, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   268
		DrawString(119,  91 + y, mapsizes[_patches_newgame.map_x - 6], TC_BLACK);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   269
		DrawString(168,  91 + y, STR_BY, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   270
		DrawString(182,  91 + y, mapsizes[_patches_newgame.map_y - 6], TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   271
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   272
		DrawString( 12, 113 + y, STR_NUMBER_OF_TOWNS, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   273
		DrawString( 12, 131 + y, STR_NUMBER_OF_INDUSTRIES, TC_FROMSTRING);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   274
		if (_game_mode == GM_EDITOR) {
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   275
			DrawString(118, 113 + y, STR_6836_OFF, TC_BLACK);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   276
			DrawString(118, 131 + y, STR_6836_OFF, TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   277
		} else {
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   278
			DrawString(118, 113 + y, num_towns[_opt_newgame.diff.number_towns], TC_BLACK);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   279
			DrawString(118, 131 + y, num_inds[_opt_newgame.diff.number_industries], TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   280
		}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   281
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   282
		DrawString( 12, 153 + y, STR_RANDOM_SEED, TC_FROMSTRING);
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   283
		DrawEditBox(w, &_genseed_query, GLAND_RANDOM_EDITBOX);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   284
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   285
		DrawString(182, 113 + y, STR_DATE, TC_FROMSTRING);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   286
		SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   287
		DrawStringCentered(271, 113 + y, STR_GENERATE_DATE, TC_FROMSTRING);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   288
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   289
		DrawString(182, 131 + y, STR_SNOW_LINE_HEIGHT, TC_FROMSTRING);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   290
		SetDParam(0, _patches_newgame.snow_line_height);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   291
		DrawStringCentered(303, 131 + y, STR_SNOW_LINE_HEIGHT_NUM, TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   292
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   293
		if (mode == GLWP_GENERATE) {
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   294
			DrawString( 12, 175, STR_LAND_GENERATOR, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   295
			DrawString(118, 175, landscape[_patches_newgame.land_generator], TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   296
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   297
			DrawString( 12, 193, STR_TREE_PLACER, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   298
			DrawString(118, 193, tree_placer[_patches_newgame.tree_placer], TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   299
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   300
			DrawString( 12, 211, STR_TERRAIN_TYPE, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   301
			DrawString(118, 211, elevations[_opt_newgame.diff.terrain_type], TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   302
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   303
			DrawString( 12, 229, STR_QUANTITY_OF_SEA_LAKES, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   304
			DrawString(118, 229, sea_lakes[_opt_newgame.diff.quantity_sea_lakes], TC_BLACK);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   305
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   306
			DrawString( 12, 247, STR_SMOOTHNESS, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   307
			DrawString(118, 247, smoothness[_patches_newgame.tgen_smoothness], TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   308
		} else {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   309
			char buffer[512];
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   310
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   311
			if (_patches_newgame.heightmap_rotation == HM_CLOCKWISE) {
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
   312
				SetDParam(0, WP(w, generate_d).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
   313
				SetDParam(1, WP(w, generate_d).x);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   314
			} else {
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
   315
				SetDParam(0, WP(w, generate_d).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
   316
				SetDParam(1, WP(w, generate_d).y);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   317
			}
4912
0f51b47cb983 (svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents: 4909
diff changeset
   318
			GetString(buffer, STR_HEIGHTMAP_SIZE, lastof(buffer));
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   319
			DrawStringRightAligned(326, 91, STR_HEIGHTMAP_SIZE, TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   320
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   321
			DrawString( 12,  91, STR_HEIGHTMAP_NAME, TC_BLACK);
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
   322
			SetDParamStr(0, WP(w, generate_d).name);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   323
			DrawStringTruncated(114,  91, STR_ORANGE, TC_BLACK, 326 - 114 - GetStringBoundingBox(buffer).width - 5);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   324
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   325
			DrawString( 12, 197, STR_TREE_PLACER, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   326
			DrawString(118, 197, tree_placer[_patches_newgame.tree_placer], TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   327
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   328
			DrawString( 12, 215, STR_HEIGHTMAP_ROTATION, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   329
			DrawString(118, 215, rotation[_patches_newgame.heightmap_rotation], TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   330
		}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   331
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   332
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   333
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   334
		switch (e->we.click.widget) {
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   335
		case 0: DeleteWindow(w); break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   336
		case GLAND_TEMPERATE: case GLAND_ARCTIC: case GLAND_TROPICAL: case GLAND_TOYLAND:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   337
			w->RaiseWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   338
			SetNewLandscapeType(e->we.click.widget - GLAND_TEMPERATE);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   339
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   340
		case GLAND_MAPSIZE_X_TEXT: case GLAND_MAPSIZE_X_PULLDOWN: // Mapsize X
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   341
			ShowDropDownMenu(w, mapsizes, _patches_newgame.map_x - 6, GLAND_MAPSIZE_X_PULLDOWN, 0, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   342
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   343
		case GLAND_MAPSIZE_Y_TEXT: case GLAND_MAPSIZE_Y_PULLDOWN: // Mapsize Y
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   344
			ShowDropDownMenu(w, mapsizes, _patches_newgame.map_y - 6, GLAND_MAPSIZE_Y_PULLDOWN, 0, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   345
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   346
		case GLAND_TOWN_TEXT: case GLAND_TOWN_PULLDOWN: // Number of towns
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   347
			ShowDropDownMenu(w, num_towns, _opt_newgame.diff.number_towns, GLAND_TOWN_PULLDOWN, 0, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   348
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   349
		case GLAND_INDUSTRY_TEXT: case GLAND_INDUSTRY_PULLDOWN: // Number of industries
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   350
			ShowDropDownMenu(w, num_inds, _opt_newgame.diff.number_industries, GLAND_INDUSTRY_PULLDOWN, 0, 0);
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   351
			break;
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   352
		case GLAND_RANDOM_BUTTON: // Random seed
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   353
			_patches_newgame.generation_seed = InteractiveRandom();
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
   354
			snprintf(_genseed_buffer, lengthof(_genseed_buffer), "%u", _patches_newgame.generation_seed);
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
   355
			UpdateTextBufferSize(&_genseed_query.text);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   356
			SetWindowDirty(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   357
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   358
		case GLAND_GENERATE_BUTTON: // Generate
6571
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   359
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   360
			UpdatePatches();
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   361
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   362
			if (_patches.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
   363
				ShowQuery(
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   364
					STR_TOWN_LAYOUT_WARNING_CAPTION,
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   365
					STR_TOWN_LAYOUT_WARNING_MESSAGE,
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   366
					w,
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   367
					LandscapeGenerationCallback);
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   368
			} else if (mode == GLWP_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
   369
					(WP(w, generate_d).x * 2 < (1U << _patches_newgame.map_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
   370
					WP(w, generate_d).x / 2 > (1U << _patches_newgame.map_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
   371
					WP(w, generate_d).y * 2 < (1U << _patches_newgame.map_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
   372
					WP(w, generate_d).y / 2 > (1U << _patches_newgame.map_y))) {
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   373
				ShowQuery(
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   374
					STR_HEIGHTMAP_SCALE_WARNING_CAPTION,
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   375
					STR_HEIGHTMAP_SCALE_WARNING_MESSAGE,
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   376
					w,
6571
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   377
					LandscapeGenerationCallback);
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   378
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   379
			} else {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   380
				StartGeneratingLandscape(mode);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   381
			}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   382
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   383
		case GLAND_START_DATE_DOWN: case GLAND_START_DATE_UP: // Year buttons
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   384
			/* Don't allow too fast scrolling */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   385
			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8028
diff changeset
   386
				w->HandleButtonClick(e->we.click.widget);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   387
				SetWindowDirty(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   388
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7824
diff changeset
   389
				_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - GLAND_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   390
			}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   391
			_left_button_clicked = false;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   392
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   393
		case GLAND_START_DATE_TEXT: // Year text
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
   394
			WP(w, generate_d).widget_id = GLAND_START_DATE_TEXT;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   395
			SetDParam(0, _patches_newgame.starting_year);
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   396
			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, w, CS_NUMERAL);
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   397
			break;
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   398
		case GLAND_SNOW_LEVEL_DOWN: case GLAND_SNOW_LEVEL_UP: // Snow line buttons
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   399
			/* Don't allow too fast scrolling */
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   400
			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8028
diff changeset
   401
				w->HandleButtonClick(e->we.click.widget);
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   402
				SetWindowDirty(w);
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   403
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7824
diff changeset
   404
				_patches_newgame.snow_line_height = Clamp(_patches_newgame.snow_line_height + e->we.click.widget - GLAND_SNOW_LEVEL_TEXT, 2, MAX_SNOWLINE_HEIGHT);
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   405
			}
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   406
			_left_button_clicked = false;
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   407
			break;
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   408
		case GLAND_SNOW_LEVEL_TEXT: // Snow line text
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
   409
			WP(w, generate_d).widget_id = GLAND_SNOW_LEVEL_TEXT;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   410
			SetDParam(0, _patches_newgame.snow_line_height);
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5418
diff changeset
   411
			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, w, CS_NUMERAL);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   412
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   413
		case GLAND_TREE_TEXT: case GLAND_TREE_PULLDOWN: // Tree placer
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   414
			ShowDropDownMenu(w, tree_placer, _patches_newgame.tree_placer, GLAND_TREE_PULLDOWN, 0, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   415
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   416
		case GLAND_LANDSCAPE_TEXT: case GLAND_LANDSCAPE_PULLDOWN: // Landscape generator OR Heightmap rotation
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5901
diff changeset
   417
		/* case GLAND_HEIGHTMAP_ROTATION_TEXT: case GLAND_HEIGHTMAP_ROTATION_PULLDOWN:*/
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   418
			if (mode == GLWP_HEIGHTMAP) {
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   419
				ShowDropDownMenu(w, rotation, _patches_newgame.heightmap_rotation, GLAND_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   420
			} else {
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   421
				ShowDropDownMenu(w, landscape, _patches_newgame.land_generator, GLAND_LANDSCAPE_PULLDOWN, 0, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   422
			}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   423
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   424
		case GLAND_TERRAIN_TEXT: case GLAND_TERRAIN_PULLDOWN: // Terrain type
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   425
			ShowDropDownMenu(w, elevations, _opt_newgame.diff.terrain_type, GLAND_TERRAIN_PULLDOWN, 0, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   426
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   427
		case GLAND_WATER_TEXT: case GLAND_WATER_PULLDOWN: // Water quantity
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   428
			ShowDropDownMenu(w, sea_lakes, _opt_newgame.diff.quantity_sea_lakes, GLAND_WATER_PULLDOWN, 0, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   429
			break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   430
		case GLAND_SMOOTHNESS_TEXT: case GLAND_SMOOTHNESS_PULLDOWN: // Map smoothness
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   431
			ShowDropDownMenu(w, smoothness, _patches_newgame.tgen_smoothness, GLAND_SMOOTHNESS_PULLDOWN, 0, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   432
			break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   433
		}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   434
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   435
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   436
	case WE_MOUSELOOP:
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   437
		HandleEditBox(w, &_genseed_query, GLAND_RANDOM_EDITBOX);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   438
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   439
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   440
	case WE_KEYPRESS:
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   441
		HandleEditBoxKey(w, &_genseed_query, GLAND_RANDOM_EDITBOX, e);
4453
f50f1d57a230 (svn r6236) -Fix (FS#313): TGP generation seed edit box only accepted seeds up to 2^31-1, instead of up to 2^32-2.
rubidium
parents: 4366
diff changeset
   442
		/* the seed is unsigned, therefore atoi cannot be used.
f50f1d57a230 (svn r6236) -Fix (FS#313): TGP generation seed edit box only accepted seeds up to 2^31-1, instead of up to 2^32-2.
rubidium
parents: 4366
diff changeset
   443
		 * As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value
f50f1d57a230 (svn r6236) -Fix (FS#313): TGP generation seed edit box only accepted seeds up to 2^31-1, instead of up to 2^32-2.
rubidium
parents: 4366
diff changeset
   444
		 * (use random seed) it should not be possible to be
f50f1d57a230 (svn r6236) -Fix (FS#313): TGP generation seed edit box only accepted seeds up to 2^31-1, instead of up to 2^32-2.
rubidium
parents: 4366
diff changeset
   445
		 * entered into the input field; the generate seed
f50f1d57a230 (svn r6236) -Fix (FS#313): TGP generation seed edit box only accepted seeds up to 2^31-1, instead of up to 2^32-2.
rubidium
parents: 4366
diff changeset
   446
		 * button can be used instead. */
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
   447
		_patches_newgame.generation_seed = minu(strtoul(_genseed_buffer, NULL, sizeof(_genseed_buffer) - 1), MAX_UVALUE(uint32) - 1);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   448
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   449
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   450
	case WE_DROPDOWN_SELECT:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   451
		switch (e->we.dropdown.button) {
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   452
			case GLAND_MAPSIZE_X_PULLDOWN:  _patches_newgame.map_x = e->we.dropdown.index + 6; break;
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   453
			case GLAND_MAPSIZE_Y_PULLDOWN:  _patches_newgame.map_y = e->we.dropdown.index + 6; break;
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   454
			case GLAND_TREE_PULLDOWN:       _patches_newgame.tree_placer = e->we.dropdown.index; break;
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   455
			case GLAND_SMOOTHNESS_PULLDOWN: _patches_newgame.tgen_smoothness = e->we.dropdown.index;  break;
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   456
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   457
			case GLAND_TOWN_PULLDOWN:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   458
				_opt_newgame.diff.number_towns = e->we.dropdown.index;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   459
				if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   460
				DoCommandP(0, 2, _opt_newgame.diff.number_towns, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   461
				break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   462
			case GLAND_INDUSTRY_PULLDOWN:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   463
				_opt_newgame.diff.number_industries = e->we.dropdown.index;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   464
				if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   465
				DoCommandP(0, 3, _opt_newgame.diff.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   466
				break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   467
			case GLAND_LANDSCAPE_PULLDOWN:
6179
d19b0137d8e4 (svn r8950) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents: 5901
diff changeset
   468
			/* case GLAND_HEIGHTMAP_PULLDOWN: */
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   469
				if (mode == GLWP_HEIGHTMAP) {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   470
					_patches_newgame.heightmap_rotation = e->we.dropdown.index;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   471
				} else {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   472
					_patches_newgame.land_generator = e->we.dropdown.index;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   473
				}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   474
				break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   475
			case GLAND_TERRAIN_PULLDOWN:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   476
				_opt_newgame.diff.terrain_type = e->we.dropdown.index;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   477
				if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   478
				DoCommandP(0, 12, _opt_newgame.diff.terrain_type, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   479
				break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   480
			case GLAND_WATER_PULLDOWN:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   481
				_opt_newgame.diff.quantity_sea_lakes = e->we.dropdown.index;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   482
				if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   483
				DoCommandP(0, 13, _opt_newgame.diff.quantity_sea_lakes, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   484
				break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   485
		}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   486
		SetWindowDirty(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   487
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   488
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   489
	case WE_ON_EDIT_TEXT: {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   490
		if (e->we.edittext.str != NULL) {
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   491
			int32 value = atoi(e->we.edittext.str);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   492
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
   493
			switch (WP(w, generate_d).widget_id) {
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   494
			case GLAND_START_DATE_TEXT:
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 8019
diff changeset
   495
				w->InvalidateWidget(GLAND_START_DATE_TEXT);
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7824
diff changeset
   496
				_patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   497
				break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   498
			case GLAND_SNOW_LEVEL_TEXT:
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 8019
diff changeset
   499
				w->InvalidateWidget(GLAND_SNOW_LEVEL_TEXT);
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7824
diff changeset
   500
				_patches_newgame.snow_line_height = Clamp(value, 2, MAX_SNOWLINE_HEIGHT);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   501
				break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   502
			}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   503
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   504
			SetWindowDirty(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   505
		}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   506
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   507
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   508
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   509
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   510
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
   511
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
   512
	WDP_CENTER, WDP_CENTER, 338, 268, 338, 268,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5892
diff changeset
   513
	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
   514
	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
   515
	_generate_landscape_widgets,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   516
	GenerateLandscapeWndProc,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   517
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   518
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
   519
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
   520
	WDP_CENTER, WDP_CENTER, 338, 236, 338, 236,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5892
diff changeset
   521
	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
   522
	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
   523
	_heightmap_load_widgets,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   524
	GenerateLandscapeWndProc,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   525
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   526
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   527
static void _ShowGenerateLandscape(glwp_modes mode)
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   528
{
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
   529
	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
   530
	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
   531
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   532
	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   533
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   534
	/* Always give a new seed if not editor */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   535
	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
   536
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   537
	if (mode == GLWP_HEIGHTMAP) {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   538
		/* 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
   539
		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
   540
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   541
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
   542
	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
   543
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
   544
	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
   545
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
   546
	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
   547
		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
   548
		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
   549
		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
   550
	}
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
   551
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
   552
	InvalidateWindow(WC_GENERATE_LANDSCAPE, mode);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   553
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   554
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   555
void ShowGenerateLandscape()
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   556
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   557
	_ShowGenerateLandscape(GLWP_GENERATE);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   558
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   559
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   560
void ShowHeightmapLoad()
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   561
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   562
	_ShowGenerateLandscape(GLWP_HEIGHTMAP);
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
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   565
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
   566
{
6571
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   567
	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
   568
		_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
   569
	}
6a8a1d0835d9 (svn r9779) -Feature: Add the possiblity to choose different road patterns for towns to use.
belugas
parents: 6560
diff changeset
   570
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
   571
	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
   572
}
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
   573
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   574
void StartNewGameWithoutGUI(uint seed)
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   575
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   576
	/* 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
   577
	_patches_newgame.generation_seed = seed;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   578
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   579
	StartGeneratingLandscape(GLWP_GENERATE);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   580
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   581
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   582
enum CreateScenarioWindowWidgets {
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   583
	CSCEN_TEMPERATE = 3,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   584
	CSCEN_ARCTIC,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   585
	CSCEN_TROPICAL,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   586
	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
   587
	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
   588
	CSCEN_RANDOM_WORLD,
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   589
	CSCEN_MAPSIZE_X_TEXT,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   590
	CSCEN_MAPSIZE_X_PULLDOWN,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   591
	CSCEN_MAPSIZE_Y_TEXT,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   592
	CSCEN_MAPSIZE_Y_PULLDOWN,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   593
	CSCEN_START_DATE_DOWN,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   594
	CSCEN_START_DATE_TEXT,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   595
	CSCEN_START_DATE_UP,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   596
	CSCEN_FLAT_LAND_HEIGHT_DOWN,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   597
	CSCEN_FLAT_LAND_HEIGHT_TEXT,
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   598
	CSCEN_FLAT_LAND_HEIGHT_UP
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   599
};
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   600
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
   601
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
   602
static void CreateScenarioWndProc(Window *w, WindowEvent *e)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   603
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   604
	static const StringID mapsizes[] = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   605
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   606
	switch (e->event) {
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   607
	case WE_CREATE: w->LowerWidget(_opt_newgame.landscape + CSCEN_TEMPERATE); break;
4719
fc6e14219f72 (svn r6631) -Codechange: Use accessors for click_state.
belugas
parents: 4709
diff changeset
   608
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   609
	case WE_PAINT:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   610
		w->SetWidgetDisabledState(CSCEN_START_DATE_DOWN,       _patches_newgame.starting_year <= MIN_YEAR);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   611
		w->SetWidgetDisabledState(CSCEN_START_DATE_UP,         _patches_newgame.starting_year >= MAX_YEAR);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   612
		w->SetWidgetDisabledState(CSCEN_FLAT_LAND_HEIGHT_DOWN, _patches_newgame.se_flat_world_height <= 0);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   613
		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
   614
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   615
		w->SetWidgetLoweredState(CSCEN_TEMPERATE, _opt_newgame.landscape == LT_TEMPERATE);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   616
		w->SetWidgetLoweredState(CSCEN_ARCTIC,    _opt_newgame.landscape == LT_ARCTIC);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   617
		w->SetWidgetLoweredState(CSCEN_TROPICAL,  _opt_newgame.landscape == LT_TROPIC);
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   618
		w->SetWidgetLoweredState(CSCEN_TOYLAND,   _opt_newgame.landscape == LT_TOYLAND);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   619
		DrawWindowWidgets(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   620
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   621
		DrawStringRightAligned(211, 97, STR_MAPSIZE, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   622
		DrawString(            221, 97, mapsizes[_patches_newgame.map_x - 6], TC_BLACK);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   623
		DrawStringCentered(    272, 97, STR_BY, TC_FROMSTRING);
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   624
		DrawString(            284, 97, mapsizes[_patches_newgame.map_y - 6], TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   625
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   626
		DrawStringRightAligned(211, 115, STR_DATE, TC_FROMSTRING);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   627
		SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   628
		DrawStringCentered(271, 115, STR_GENERATE_DATE, TC_FROMSTRING);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   629
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   630
		DrawStringRightAligned(278, 133, STR_FLAT_WORLD_HEIGHT, TC_FROMSTRING);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   631
		SetDParam(0, _patches_newgame.se_flat_world_height);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   632
		DrawStringCentered(303, 133, STR_FLAT_WORLD_HEIGHT_NUM, TC_BLACK);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   633
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   634
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   635
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   636
		switch (e->we.click.widget) {
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   637
		case CSCEN_TEMPERATE: case CSCEN_ARCTIC: case CSCEN_TROPICAL: case CSCEN_TOYLAND:
7997
df87ccd00a96 (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents: 7922
diff changeset
   638
			w->RaiseWidget(_opt_newgame.landscape + CSCEN_TEMPERATE);
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   639
			SetNewLandscapeType(e->we.click.widget - CSCEN_TEMPERATE);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   640
			break;
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   641
		case CSCEN_MAPSIZE_X_TEXT: case CSCEN_MAPSIZE_X_PULLDOWN: // Mapsize X
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   642
			ShowDropDownMenu(w, mapsizes, _patches_newgame.map_x - 6, CSCEN_MAPSIZE_X_PULLDOWN, 0, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   643
			break;
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   644
		case CSCEN_MAPSIZE_Y_TEXT: case CSCEN_MAPSIZE_Y_PULLDOWN: // Mapsize Y
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   645
			ShowDropDownMenu(w, mapsizes, _patches_newgame.map_y - 6, CSCEN_MAPSIZE_Y_PULLDOWN, 0, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   646
			break;
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   647
		case CSCEN_EMPTY_WORLD: // Empty world / flat world
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   648
			StartGeneratingLandscape(GLWP_SCENARIO);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   649
			break;
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   650
		case CSCEN_RANDOM_WORLD: // Generate
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   651
			ShowGenerateLandscape();
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   652
			break;
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   653
		case CSCEN_START_DATE_DOWN: case CSCEN_START_DATE_UP: // Year buttons
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   654
			/* Don't allow too fast scrolling */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   655
			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8028
diff changeset
   656
				w->HandleButtonClick(e->we.click.widget);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   657
				SetWindowDirty(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   658
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7824
diff changeset
   659
				_patches_newgame.starting_year = Clamp(_patches_newgame.starting_year + e->we.click.widget - CSCEN_START_DATE_TEXT, MIN_YEAR, MAX_YEAR);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   660
			}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   661
			_left_button_clicked = false;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   662
			break;
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   663
		case CSCEN_START_DATE_TEXT: // Year text
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
   664
			WP(w, generate_d).widget_id = CSCEN_START_DATE_TEXT;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   665
			SetDParam(0, _patches_newgame.starting_year);
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5418
diff changeset
   666
			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, w, CS_NUMERAL);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   667
			break;
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   668
		case CSCEN_FLAT_LAND_HEIGHT_DOWN: case CSCEN_FLAT_LAND_HEIGHT_UP: // Height level buttons
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   669
			/* Don't allow too fast scrolling */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   670
			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
8036
279f4cbf9ec7 (svn r11596) -Codechange: Use the Window member HandleButtonClick and remove its now useless counterpart function
belugas
parents: 8028
diff changeset
   671
				w->HandleButtonClick(e->we.click.widget);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   672
				SetWindowDirty(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   673
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7824
diff changeset
   674
				_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);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   675
			}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   676
			_left_button_clicked = false;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   677
			break;
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   678
		case CSCEN_FLAT_LAND_HEIGHT_TEXT: // Height level text
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
   679
			WP(w, generate_d).widget_id = CSCEN_FLAT_LAND_HEIGHT_TEXT;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   680
			SetDParam(0, _patches_newgame.se_flat_world_height);
5431
6e56b4f13dd7 (svn r7637) -Codechange: Change ShowQueryString to use a window pointer as a parent. If the
Darkvater
parents: 5418
diff changeset
   681
			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_FLAT_WORLD_HEIGHT_QUERY_CAPT, 3, 100, w, CS_NUMERAL);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   682
			break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   683
		}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   684
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   685
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   686
	case WE_DROPDOWN_SELECT:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   687
		switch (e->we.dropdown.button) {
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
   688
			case CSCEN_MAPSIZE_X_PULLDOWN: _patches_newgame.map_x = e->we.dropdown.index + 6; break;
5892
e1d55528ba34 (svn r8509) -Cleanup: Add some enum names to the create scenario window
Darkvater
parents: 5668
diff changeset
   689
			case CSCEN_MAPSIZE_Y_PULLDOWN: _patches_newgame.map_y = e->we.dropdown.index + 6; break;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   690
		}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   691
		SetWindowDirty(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   692
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   693
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   694
	case WE_ON_EDIT_TEXT: {
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   695
		if (e->we.edittext.str != NULL) {
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   696
			int32 value = atoi(e->we.edittext.str);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   697
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
   698
			switch (WP(w, generate_d).widget_id) {
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   699
			case CSCEN_START_DATE_TEXT:
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 8019
diff changeset
   700
				w->InvalidateWidget(CSCEN_START_DATE_TEXT);
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7824
diff changeset
   701
				_patches_newgame.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   702
				break;
5901
ab59510b0c9c (svn r8524) -Cleanup: Ala r8509 add some enum names to the generate landscape window
Darkvater
parents: 5899
diff changeset
   703
			case CSCEN_FLAT_LAND_HEIGHT_TEXT:
8028
e578ea22f371 (svn r11588) -Codechange: use the new member introduced in r11551
glx
parents: 8019
diff changeset
   704
				w->InvalidateWidget(CSCEN_FLAT_LAND_HEIGHT_TEXT);
7922
a7e266f966d9 (svn r11475) -Codechange: rename clamp and clampu to Clamp and ClampU to fit with the coding style
skidd13
parents: 7824
diff changeset
   705
				_patches_newgame.se_flat_world_height = Clamp(value, 0, MAX_TILE_HEIGHT);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   706
				break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   707
			}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   708
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   709
			SetWindowDirty(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   710
		}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   711
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   712
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   713
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   714
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   715
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
   716
static const Widget _create_scenario_widgets[] = {
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   717
{   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
   718
{    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
   719
{      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
   720
4938
0447845fd1b3 (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4937
diff changeset
   721
{   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
   722
{   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
   723
{   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
   724
{   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
   725
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
   726
{    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
   727
{    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
   728
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
   729
{      WWT_PANEL, RESIZE_NONE, 12, 216, 251,  95, 106, 0x0,                     STR_NULL},
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
   730
{    WWT_TEXTBTN, RESIZE_NONE, 12, 252, 263,  95, 106, STR_0225,                STR_NULL}, // Mapsize X
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
   731
{      WWT_PANEL, RESIZE_NONE, 12, 279, 314,  95, 106, 0x0,                     STR_NULL},
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
   732
{    WWT_TEXTBTN, RESIZE_NONE, 12, 315, 326,  95, 106, STR_0225,                STR_NULL}, // Mapsize Y
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   733
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
   734
{     WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 113, 124, SPR_ARROW_DOWN,          STR_029E_MOVE_THE_STARTING_DATE},
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
   735
{      WWT_PANEL, RESIZE_NONE, 12, 228, 314, 113, 124, 0x0,                     STR_NULL},
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
   736
{     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
   737
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
   738
{     WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 131, 142, SPR_ARROW_DOWN,          STR_FLAT_WORLD_HEIGHT_DOWN},
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
   739
{      WWT_PANEL, RESIZE_NONE, 12, 294, 314, 131, 142, 0x0,                     STR_NULL},
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
   740
{     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
   741
{   WIDGETS_END},
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   742
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   743
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
   744
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
   745
	WDP_CENTER, WDP_CENTER, 338, 170, 338, 170,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5892
diff changeset
   746
	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
   747
	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
   748
	_create_scenario_widgets,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   749
	CreateScenarioWndProc,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   750
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   751
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   752
void ShowCreateScenario()
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   753
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   754
	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   755
	AllocateWindowDescFront(&_create_scenario_desc, GLWP_SCENARIO);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   756
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   757
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   758
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   759
static const Widget _show_terrain_progress_widgets[] = {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   760
{    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
   761
{      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
   762
{    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
   763
{   WIDGETS_END},
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   764
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   765
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   766
struct tp_info {
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   767
	uint percent;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   768
	StringID cls;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   769
	uint current;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   770
	uint total;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   771
	int timer;
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6247
diff changeset
   772
};
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   773
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   774
static tp_info _tp;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   775
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   776
static void AbortGeneratingWorldCallback(Window *w, bool confirmed)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   777
{
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   778
	if (confirmed) {
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   779
		AbortGeneratingWorld();
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   780
	} else if (IsGeneratingWorld() && !IsGeneratingWorldAborted()) {
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   781
		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
   782
	}
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   783
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   784
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   785
static void ShowTerrainProgressProc(Window* w, WindowEvent* e)
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   786
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   787
	switch (e->event) {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   788
	case WE_CLICK:
4634
07699ac2bf37 (svn r6499) -Codechange: Finally, got "byte event" outside of the union WindowEvent, which is now a struct
belugas
parents: 4609
diff changeset
   789
		switch (e->we.click.widget) {
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   790
		case 2:
5668
36b39f4a9032 (svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents: 5587
diff changeset
   791
			if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
5418
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   792
			ShowQuery(
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   793
				STR_GENERATION_ABORT_CAPTION,
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   794
				STR_GENERATION_ABORT_MESSAGE,
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   795
				w,
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   796
				AbortGeneratingWorldCallback
793a133c6d2a (svn r7621) -Codechange: Rework ShowQuery into a general modal popup window. It gets passed
Darkvater
parents: 5380
diff changeset
   797
			);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   798
			break;
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
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   801
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   802
	case WE_PAINT:
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   803
		DrawWindowWidgets(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   804
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   805
		/* Draw the % complete with a bar and a text */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   806
		DrawFrameRect(19, 20, (w->width - 18), 37, 14, FR_BORDERONLY);
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   807
		DrawFrameRect(20, 21, (int)((w->width - 40) * _tp.percent / 100) + 20, 36, 10, FR_NONE);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   808
		SetDParam(0, _tp.percent);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   809
		DrawStringCentered(90, 25, STR_PROGRESS, TC_FROMSTRING);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   810
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   811
		/* Tell which class we are generating */
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   812
		DrawStringCentered(90, 46, _tp.cls, TC_FROMSTRING);
4300
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
		/* And say where we are in that class */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   815
		SetDParam(0, _tp.current);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   816
		SetDParam(1, _tp.total);
7824
5a63d41b59ea (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents: 7341
diff changeset
   817
		DrawStringCentered(90, 58, STR_GENERATION_PROGRESS, TC_FROMSTRING);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   818
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   819
		SetWindowDirty(w);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   820
		break;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   821
	}
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
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   824
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
   825
	WDP_CENTER, WDP_CENTER, 181, 97, 181, 97,
5893
7e431a4abebb (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 5892
diff changeset
   826
	WC_GENERATE_PROGRESS_WINDOW, WC_NONE,
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   827
	WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   828
	_show_terrain_progress_widgets,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   829
	ShowTerrainProgressProc
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   830
};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   831
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
 * Initializes the progress counters to the starting point.
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   834
 */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   835
void PrepareGenerateWorldProgress()
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   836
{
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   837
	_tp.cls   = STR_WORLD_GENERATION;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   838
	_tp.current = 0;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   839
	_tp.total   = 0;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   840
	_tp.percent = 0;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   841
	_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
   842
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   843
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   844
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   845
 * 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
   846
 */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6179
diff changeset
   847
void ShowGenerateWorldProgress()
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   848
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   849
	AllocateWindowDescFront(&_show_terrain_progress_desc, 0);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   850
}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   851
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   852
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
   853
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   854
	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
   855
	static const StringID class_table[GWP_CLASS_COUNT]  = {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   856
		STR_WORLD_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   857
		STR_022E_LANDSCAPE_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   858
		STR_CLEARING_TILES,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   859
		STR_022F_TOWN_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   860
		STR_0230_INDUSTRY_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   861
		STR_UNMOVABLE_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   862
		STR_TREE_GENERATION,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   863
		STR_SETTINGUP_GAME,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   864
		STR_PREPARING_TILELOOP,
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   865
		STR_PREPARING_GAME
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   866
	};
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   867
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   868
	assert(cls < GWP_CLASS_COUNT);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   869
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   870
	/* 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
   871
	if (!IsGenerateWorldThreaded() && !_network_dedicated) return;
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
	if (IsGeneratingWorldAborted()) HandleGeneratingWorldAbortion();
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   874
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   875
	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
   876
		assert(_tp.cls == class_table[cls]);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   877
		_tp.current += progress;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   878
	} else {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   879
		_tp.cls   = class_table[cls];
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   880
		_tp.current = progress;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   881
		_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
   882
		_tp.percent = percent_table[cls];
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   883
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   884
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
   885
	/* 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
   886
	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
   887
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   888
	/* 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
   889
	_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
   890
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   891
	if (_network_dedicated) {
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   892
		static uint last_percent = 0;
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
		/* Never display 0% */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   895
		if (_tp.percent == 0) return;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   896
		/* 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
   897
		if (_tp.percent < last_percent) last_percent = 0;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   898
		/* 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
   899
		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
   900
		/* 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
   901
		if (_tp.percent <= last_percent + 2) return;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   902
5380
8ea58542b6e0 (svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents: 5228
diff changeset
   903
		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
   904
		last_percent = _tp.percent;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   905
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   906
		/* 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
   907
		return;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   908
	}
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   909
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   910
	InvalidateWindow(WC_GENERATE_PROGRESS_WINDOW, 0);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   911
	MarkWholeScreenDirty();
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   912
	SetGeneratingWorldPaintStatus(true);
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   913
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   914
	/* 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
   915
	 *  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
   916
	 *  if you implement threading afterwards */
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   917
	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
   918
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
   919
	_tp.timer = _realtime_tick;
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   920
}
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
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   923
 * 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
   924
 * @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
   925
 * @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
   926
 *
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   927
 * 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
   928
 *  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
   929
 */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   930
void SetGeneratingWorldProgress(gwp_class cls, uint total)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   931
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   932
	if (total == 0) return;
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   933
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   934
	_SetGeneratingWorldProgress(cls, 0, total);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   935
}
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
/**
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   938
 * 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
   939
 * @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
   940
 *
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   941
 * 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
   942
 *  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
   943
 */
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   944
void IncreaseGeneratingWorldProgress(gwp_class cls)
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   945
{
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   946
	/* 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
   947
	_SetGeneratingWorldProgress(cls, 1, 0);
4300
c7e43c47a2b9 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   948
}