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