genworld_gui.c
author bjarni
Fri, 08 Sep 2006 10:47:39 +0000
changeset 4574 497540b4a75f
parent 4453 890c107f6fa6
child 4609 6c337b3fbf4b
permissions -rw-r--r--
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
To do this, the player struct contains an array, that contains the count of each engine type that the player owns
Those arrays are updated each time a vehicle is build or deleted and is calculated on load (it's not saved)
It's possible to access the arrays outside of the autoreplace GUI, so feel free to read from them in other patches as well
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
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     3
#include "stdafx.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     4
#include "openttd.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     5
#include "heightmap.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     6
#include "functions.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     7
#include "table/strings.h"
4366
b40a2ecadf99 (svn r6082) -CodeChange : Remove the unneeded table/sprites.h include in newgrf_cargo.h.
belugas
parents: 4364
diff changeset
     8
#include "table/sprites.h"
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
     9
#include "window.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    10
#include "gui.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    11
#include "gfx.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    12
#include "strings.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    13
#include "gfxinit.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    14
#include "player.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    15
#include "command.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    16
#include "sound.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    17
#include "variables.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    18
#include "string.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    19
#include "settings.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    20
#include "debug.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    21
#include "genworld.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    22
#include "network.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    23
#include "thread.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    24
#include "date.h"
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    25
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    26
enum {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    27
	START_DATE_QUERY,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    28
	SNOW_LINE_QUERY,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    29
	FLAT_WORLD_HEIGHT_QUERY,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    30
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    31
	LEN_RND_SEED = 11,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    32
	SEED_EDIT    = 15,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    33
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    34
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    35
/**
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    36
 * In what 'mode' the GenerateLandscapeWindowProc is.
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    37
 */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    38
typedef enum glwp_modes {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    39
	GLWP_GENERATE,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    40
	GLWP_HEIGHTMAP,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    41
	GLWP_SCENARIO,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    42
	GLWP_END
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    43
} glwp_modes;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    44
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    45
static char _edit_str_buf[LEN_RND_SEED];
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    46
static uint _heightmap_x = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    47
static uint _heightmap_y = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    48
static StringID _heightmap_str = STR_NULL;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    49
static bool _goto_editor = false;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    50
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    51
extern void SwitchMode(int new_mode);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    52
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    53
static inline void SetNewLandscapeType(byte landscape)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    54
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    55
	_opt_newgame.landscape = landscape;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    56
	InvalidateWindowClasses(WC_SELECT_GAME);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    57
	InvalidateWindowClasses(WC_GENERATE_LANDSCAPE);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    58
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    59
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    60
// no longer static to allow calling from outside module
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    61
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
    62
{  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
    63
{    WWT_CAPTION, RESIZE_NONE, 13,  11, 337,   0,  13, STR_WORLD_GENERATION_CAPTION, STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    64
{     WWT_IMGBTN, RESIZE_NONE, 13,   0, 337,  14, 267, STR_NULL,                     STR_NULL},
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    65
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
    66
{    WWT_PANEL_2, RESIZE_NONE, 12,  10,  86,  24,  78, 0x1312,                       STR_030E_SELECT_TEMPERATE_LANDSCAPE},
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
    67
{    WWT_PANEL_2, RESIZE_NONE, 12,  90, 166,  24,  78, 0x1314,                       STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
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
    68
{    WWT_PANEL_2, RESIZE_NONE, 12, 170, 246,  24,  78, 0x1316,                       STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
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
    69
{    WWT_PANEL_2, RESIZE_NONE, 12, 250, 326,  24,  78, 0x1318,                       STR_0311_SELECT_TOYLAND_LANDSCAPE},
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    70
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
    71
{      WWT_PANEL, RESIZE_NONE, 12, 114, 149,  90, 101, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    72
{    WWT_TEXTBTN, RESIZE_NONE, 12, 150, 161,  90, 101, STR_0225,                     STR_NULL}, // Mapsize X
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
    73
{      WWT_PANEL, RESIZE_NONE, 12, 180, 215,  90, 101, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    74
{    WWT_TEXTBTN, RESIZE_NONE, 12, 216, 227,  90, 101, STR_0225,                     STR_NULL}, // Mapsize Y
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
    75
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
    76
{      WWT_PANEL, RESIZE_NONE, 12, 114, 163, 112, 123, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    77
{    WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 112, 123, STR_0225,                     STR_NULL}, // Number of towns
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
    78
{      WWT_PANEL, RESIZE_NONE, 12, 114, 163, 130, 141, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    79
{    WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 130, 141, STR_0225,                     STR_NULL}, // Number of industries
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
    80
4364
0fc1e43842f6 (svn r6079) -Change: size and alignment of random seed input box and randomise button
glx
parents: 4344
diff changeset
    81
{     WWT_IMGBTN, RESIZE_NONE, 15, 114, 207, 152, 163, STR_NULL,                     STR_RANDOM_SEED_HELP}, // Edit box for seed
0fc1e43842f6 (svn r6079) -Change: size and alignment of random seed input box and randomise button
glx
parents: 4344
diff changeset
    82
{    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
    83
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
    84
{    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
    85
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
    86
{     WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 112, 123, SPR_ARROW_DOWN,               STR_029E_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
    87
{      WWT_PANEL, RESIZE_NONE, 12, 228, 314, 112, 123, 0x0,                          STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    88
{     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
    89
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
    90
{     WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 130, 141, SPR_ARROW_DOWN,               STR_SNOW_LINE_DOWN},
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
    91
{      WWT_PANEL, RESIZE_NONE, 12, 294, 314, 130, 141, 0x0,                          STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    92
{     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
    93
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
    94
{      WWT_PANEL, RESIZE_NONE, 12, 114, 219, 192, 203, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    95
{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 192, 203, STR_0225,                     STR_NULL}, // Tree placer
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
    96
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
    97
{      WWT_EMPTY, RESIZE_NONE, 12, 114, 231, 174, 185, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    98
//{      WWT_PANEL, RESIZE_NONE, 12, 114, 219, 174, 185, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
    99
{      WWT_PANEL, RESIZE_NONE, 12, 114, 231, 174, 185, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   100
//{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 174, 185, STR_0225,                     STR_NULL}, // Landscape generator
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
   101
//{      WWT_PANEL, RESIZE_NONE, 12, 114, 219, 210, 221, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   102
{      WWT_PANEL, RESIZE_NONE, 12, 114, 231, 210, 221, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   103
//{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 210, 221, STR_0225,                     STR_NULL}, // Terrain type
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
   104
//{      WWT_PANEL, RESIZE_NONE, 12, 114, 219, 228, 239, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   105
{      WWT_PANEL, RESIZE_NONE, 12, 114, 231, 228, 239, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   106
//{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 228, 239, STR_0225,                     STR_NULL}, // Water quantity
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
   107
{      WWT_PANEL, RESIZE_NONE, 12, 113, 219, 246, 257, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   108
{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 246, 257, STR_0225,                     STR_NULL}, // Map smoothness
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   109
{   WIDGETS_END},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   110
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   111
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   112
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
   113
{   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
   114
{    WWT_CAPTION, RESIZE_NONE, 13,  11, 337,   0,  13, STR_WORLD_GENERATION_CAPTION, STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   115
{     WWT_IMGBTN, RESIZE_NONE, 13,   0, 337,  14, 235, STR_NULL,                     STR_NULL},
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   116
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
   117
{    WWT_PANEL_2, RESIZE_NONE, 12,  10,  86,  24,  78, 0x1312,                       STR_030E_SELECT_TEMPERATE_LANDSCAPE},
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
   118
{    WWT_PANEL_2, RESIZE_NONE, 12,  90, 166,  24,  78, 0x1314,                       STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
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
   119
{    WWT_PANEL_2, RESIZE_NONE, 12, 170, 246,  24,  78, 0x1316,                       STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
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
   120
{    WWT_PANEL_2, RESIZE_NONE, 12, 250, 326,  24,  78, 0x1318,                       STR_0311_SELECT_TOYLAND_LANDSCAPE},
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   121
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
   122
{      WWT_PANEL, RESIZE_NONE, 12, 114, 149, 112, 123, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   123
{    WWT_TEXTBTN, RESIZE_NONE, 12, 150, 161, 112, 123, STR_0225,                     STR_NULL}, // Mapsize X
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
   124
{      WWT_PANEL, RESIZE_NONE, 12, 180, 215, 112, 123, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   125
{    WWT_TEXTBTN, RESIZE_NONE, 12, 216, 227, 112, 123, STR_0225,                     STR_NULL}, // Mapsize Y
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   126
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
{      WWT_PANEL, RESIZE_NONE, 12, 114, 163, 134, 145, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   128
{    WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 134, 145, STR_0225,                     STR_NULL}, // Number of towns
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
   129
{      WWT_PANEL, RESIZE_NONE, 12, 114, 163, 152, 163, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   130
{    WWT_TEXTBTN, RESIZE_NONE, 12, 164, 175, 152, 163, STR_0225,                     STR_NULL}, // Number of industries
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   131
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
   132
{     WWT_IMGBTN, RESIZE_NONE, 15, 114, 194, 174, 185, STR_NULL,                     STR_RANDOM_SEED_HELP}, // Edit box for seed
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
   133
{    WWT_TEXTBTN, RESIZE_NONE, 12, 203, 285, 174, 185, STR_RANDOM,                   STR_RANDOM_HELP},
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   134
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
   135
{    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
   136
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
   137
{     WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 134, 145, SPR_ARROW_DOWN,               STR_029E_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
   138
{      WWT_PANEL, RESIZE_NONE, 12, 228, 314, 134, 145, 0x0,                          STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   139
{     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
   140
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
{     WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 152, 163, SPR_ARROW_DOWN,               STR_SNOW_LINE_DOWN},
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
   142
{      WWT_PANEL, RESIZE_NONE, 12, 294, 314, 152, 163, 0x0,                          STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   143
{     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
   144
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_PANEL, RESIZE_NONE, 12, 114, 219, 196, 207, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   146
{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 196, 207, STR_0225,                     STR_NULL}, // Tree placer
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
   147
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
   148
{      WWT_PANEL, RESIZE_NONE, 12, 114, 219, 214, 225, STR_NULL,                     STR_NULL},
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   149
{    WWT_TEXTBTN, RESIZE_NONE, 12, 220, 231, 214, 225, STR_0225,                     STR_NULL}, // Heightmap rotation
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   150
{   WIDGETS_END},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   151
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   152
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   153
static void StartGeneratingLandscape(glwp_modes mode)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   154
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   155
	/* If we want to go to the editor, and aren't yet, we need to delay
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   156
	 *  it as long as possible, else it gives nasty side-effects (aborting
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   157
	 *  results in ending up in the SE, which you don't want. Therefor we
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   158
	 *  use this switch to do it at the very end.
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   159
	 */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   160
	if (_goto_editor) _game_mode = GM_EDITOR;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   161
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   162
	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   163
	DeleteWindowByClass(WC_INDUSTRY_VIEW);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   164
	DeleteWindowByClass(WC_TOWN_VIEW);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   165
	DeleteWindowByClass(WC_LAND_INFO);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   166
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   167
	/* Copy all XXX_newgame to XXX */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   168
	UpdatePatches();
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   169
	_opt_ptr = &_opt;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   170
	memcpy(_opt_ptr, &_opt_newgame, sizeof(GameOptions));
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   171
	/* Load the right landscape stuff */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   172
	GfxLoadSprites();
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   173
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   174
	SndPlayFx(SND_15_BEEP);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   175
	switch (mode) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   176
	case GLWP_GENERATE:  _switch_mode = (_game_mode == GM_EDITOR) ? SM_GENRANDLAND    : SM_NEWGAME;         break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   177
	case GLWP_HEIGHTMAP: _switch_mode = (_game_mode == GM_EDITOR) ? SM_LOAD_HEIGHTMAP : SM_START_HEIGHTMAP; break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   178
	case GLWP_SCENARIO:  _switch_mode = SM_EDITOR; break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   179
	default: NOT_REACHED(); return;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   180
	}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   181
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   182
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   183
static void HeightmapScaledTooMuchCallback(bool ok_clicked)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   184
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   185
	if (ok_clicked) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   186
		Window *w;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   187
		glwp_modes mode = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   188
		for (mode = 0; mode < GLWP_END; mode++) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   189
			w = FindWindowById(WC_GENERATE_LANDSCAPE, mode);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   190
			if (w != NULL) StartGeneratingLandscape(mode);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   191
		}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   192
	}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   193
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   194
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   195
void GenerateLandscapeWndProc(Window *w, WindowEvent *e)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   196
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   197
	static const StringID mapsizes[]    = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   198
	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
   199
	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
   200
	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
   201
	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
   202
	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
   203
	static const StringID landscape[]   = {STR_CONFIG_PATCHES_LAND_GENERATOR_ORIGINAL, STR_CONFIG_PATCHES_LAND_GENERATOR_TERRA_GENESIS, INVALID_STRING_ID};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   204
	static const StringID num_towns[]   = {STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   205
	static const StringID num_inds[]    = {STR_26816_NONE, STR_6816_LOW, STR_6817_NORMAL, STR_6818_HIGH, INVALID_STRING_ID};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   206
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   207
	uint mode = w->window_number;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   208
	uint y;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   209
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   210
	switch (e->event) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   211
	case WE_PAINT:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   212
		w->disabled_state = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   213
		/* TODO -- Above and below you see some lines commented out with '//' in
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   214
		 *  front of it. This is because currently the widget system can't handle
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   215
		 *  more than 32 widgets per window, and we need 34. Therefor we draw
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   216
		 *  parts of the widgets manually below, reducing the number to 32.
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   217
		 *  Of course someone is already hard working to replace the system with
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   218
		 *  one that can scale past the 32 limit. When this is done you should
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   219
		 *  re-enable the lines and remove the ones that came instead. Better,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   220
		 *  revert revision 5817 (from TGP branch), and you should be just fine.
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   221
		 * If you have any questions about it, bug TrueLight.
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   222
		 */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   223
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   224
		/* You can't select smoothness if not terragenesis */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   225
//		if (_patches_newgame.land_generator == 0) w->disabled_state |= (1 << 32 | 1 << 33);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   226
		if (_patches_newgame.land_generator == 0) w->disabled_state |= (1 << 30 | 1 << 31);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   227
		/* Disable snowline if not hilly */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   228
		if (_opt_newgame.landscape != LT_HILLY)   w->disabled_state |= (1 << 21 | 1 << 22 | 1 << 23);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   229
		/* Disable town and industry in SE */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   230
		if (_game_mode == GM_EDITOR)              w->disabled_state |= (1 << 11 | 1 << 12 | 1 << 13 | 1 << 14 | 1 << 24 | 1 << 25);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   231
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   232
		if (_patches_newgame.starting_year <= MIN_YEAR) SETBIT(w->disabled_state, 18);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   233
		if (_patches_newgame.starting_year >= MAX_YEAR) SETBIT(w->disabled_state, 20);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   234
		if (_patches_newgame.snow_line_height <= 2 )    SETBIT(w->disabled_state, 21);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   235
		if (_patches_newgame.snow_line_height >= 13)    SETBIT(w->disabled_state, 23);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   236
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   237
		w->click_state = (w->click_state & ~(0xF << 3)) | (1 << (_opt_newgame.landscape + 3));
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   238
		DrawWindowWidgets(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   239
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   240
		y = (mode == GLWP_HEIGHTMAP) ? 22 : 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   241
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   242
		DrawString( 12,  91 + y, STR_MAPSIZE, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   243
		DrawString(119,  91 + y, mapsizes[_patches_newgame.map_x - 6], 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   244
		DrawString(168,  91 + y, STR_BY, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   245
		DrawString(182,  91 + y, mapsizes[_patches_newgame.map_y - 6], 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   246
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   247
		DrawString( 12, 113 + y, STR_NUMBER_OF_TOWNS, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   248
		DrawString( 12, 131 + y, STR_NUMBER_OF_INDUSTRIES, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   249
		if (_game_mode == GM_EDITOR) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   250
			DrawString(118, 113 + y, STR_6836_OFF, 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   251
			DrawString(118, 131 + y, STR_6836_OFF, 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   252
		} else {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   253
			DrawString(118, 113 + y, num_towns[_opt_newgame.diff.number_towns], 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   254
			DrawString(118, 131 + y, num_inds[_opt_newgame.diff.number_industries], 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   255
		}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   256
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   257
		DrawString( 12, 153 + y, STR_RANDOM_SEED, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   258
		DrawEditBox(w, &WP(w, querystr_d), SEED_EDIT);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   259
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   260
		DrawString(182, 113 + y, STR_DATE, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   261
		SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   262
		DrawStringCentered(271, 113 + y, STR_GENERATE_DATE, 0);
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
		DrawString(182, 131 + y, STR_SNOW_LINE_HEIGHT, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   265
		SetDParam(0, _patches_newgame.snow_line_height);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   266
		DrawStringCentered(303, 131 + y, STR_SNOW_LINE_HEIGHT_NUM, 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   267
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   268
		if (mode == GLWP_GENERATE) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   269
			/* TODO -- Remove next 2 lines if 32 widget limit is removed */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   270
			DrawFrameRect(114, 174, 219, 185, 12, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   271
			DrawString(222, 175, STR_0225, 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   272
			DrawString( 12, 175, STR_LAND_GENERATOR, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   273
			DrawString(118, 175, landscape[_patches_newgame.land_generator], 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   274
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   275
			DrawString( 12, 193, STR_TREE_PLACER, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   276
			DrawString(118, 193, tree_placer[_patches_newgame.tree_placer], 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   277
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   278
			/* TODO -- Remove next 2 lines if 32 widget limit is removed */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   279
			DrawFrameRect(114, 210, 219, 221, 12, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   280
			DrawString(222, 211, STR_0225, 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   281
			DrawString( 12, 211, STR_TERRAIN_TYPE, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   282
			DrawString(118, 211, elevations[_opt_newgame.diff.terrain_type], 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   283
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   284
			/* TODO -- Remove next 2 lines if 32 widget limit is removed */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   285
			DrawFrameRect(114, 228, 219, 239, 12, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   286
			DrawString(222, 229, STR_0225, 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   287
			DrawString( 12, 229, STR_QUANTITY_OF_SEA_LAKES, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   288
			DrawString(118, 229, sea_lakes[_opt_newgame.diff.quantity_sea_lakes], 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   289
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   290
			DrawString( 12, 247, STR_SMOOTHNESS, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   291
			DrawString(118, 247, smoothness[_patches_newgame.tgen_smoothness], 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   292
		} else {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   293
			char buffer[512];
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   294
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   295
			if (_patches_newgame.heightmap_rotation == HM_CLOCKWISE) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   296
				SetDParam(0, _heightmap_y);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   297
				SetDParam(1, _heightmap_x);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   298
			} else {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   299
				SetDParam(0, _heightmap_x);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   300
				SetDParam(1, _heightmap_y);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   301
			}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   302
			GetString(buffer, STR_HEIGHTMAP_SIZE);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   303
			DrawStringRightAligned(326, 91, STR_HEIGHTMAP_SIZE, 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   304
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   305
			DrawString( 12,  91, STR_HEIGHTMAP_NAME, 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   306
			SetDParam(0, _heightmap_str);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   307
			DrawStringTruncated(114,  91, STR_ORANGE, 0x10, 326 - 114 - GetStringWidth(buffer) - 5);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   308
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   309
			/* TODO -- Remove next 2 lines if 32 widget limit is removed */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   310
			DrawFrameRect(114, 196, 219, 207, 12, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   311
			DrawString(222, 197, STR_0225, 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   312
			DrawString( 12, 197, STR_TREE_PLACER, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   313
			DrawString(118, 197, tree_placer[_patches_newgame.tree_placer], 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   314
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   315
			DrawString( 12, 215, STR_HEIGHTMAP_ROTATION, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   316
			DrawString(118, 215, rotation[_patches_newgame.heightmap_rotation], 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   317
		}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   318
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   319
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   320
	case WE_CLICK:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   321
		switch (e->click.widget) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   322
		case 0: DeleteWindow(w); break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   323
		case 3: case 4: case 5: case 6:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   324
			SetNewLandscapeType(e->click.widget - 3);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   325
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   326
		case 7: case 8: // Mapsize X
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   327
			ShowDropDownMenu(w, mapsizes, _patches_newgame.map_x - 6, 8, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   328
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   329
		case 9: case 10: // Mapsize Y
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   330
			ShowDropDownMenu(w, mapsizes, _patches_newgame.map_y - 6, 10, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   331
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   332
		case 11: case 12: // Number of towns
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   333
			ShowDropDownMenu(w, num_towns, _opt_newgame.diff.number_towns, 12, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   334
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   335
		case 13: case 14: // Number of industries
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   336
			ShowDropDownMenu(w, num_inds, _opt_newgame.diff.number_industries, 14, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   337
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   338
		case 16: // Random seed
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   339
			_patches_newgame.generation_seed = InteractiveRandom();
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   340
			ttd_strlcpy(_edit_str_buf, str_fmt("%u", _patches_newgame.generation_seed), lengthof(_edit_str_buf));
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   341
			UpdateTextBufferSize(&((querystr_d *)&WP(w, querystr_d))->text);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   342
			SetWindowDirty(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   343
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   344
		case 17: // Generate
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   345
			if (mode == GLWP_HEIGHTMAP && (
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   346
					_heightmap_x * 2 < (1U << _patches_newgame.map_x) || _heightmap_x / 2 > (1U << _patches_newgame.map_x) ||
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   347
					_heightmap_y * 2 < (1U << _patches_newgame.map_y) || _heightmap_y / 2 > (1U << _patches_newgame.map_y))) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   348
				ShowQuery(STR_HEIGHTMAP_SCALE_WARNING_CAPTION, STR_HEIGHTMAP_SCALE_WARNING_MESSAGE, HeightmapScaledTooMuchCallback, WC_GENERATE_LANDSCAPE, mode);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   349
			} else {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   350
				StartGeneratingLandscape(mode);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   351
			}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   352
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   353
		case 18: case 20: // Year buttons
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   354
			/* Don't allow too fast scrolling */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   355
			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   356
				HandleButtonClick(w, e->click.widget);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   357
				SetWindowDirty(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   358
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   359
				_patches_newgame.starting_year = clamp(_patches_newgame.starting_year + e->click.widget - 19, MIN_YEAR, MAX_YEAR);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   360
			}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   361
			_left_button_clicked = false;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   362
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   363
		case 19: // Year text
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   364
			WP(w, def_d).data_3 = START_DATE_QUERY;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   365
			SetDParam(0, _patches_newgame.starting_year);
4326
c2ae4dbc1074 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4309
diff changeset
   366
			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, WC_GENERATE_LANDSCAPE, mode, CS_NUMERAL);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   367
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   368
		case 21: case 23: // Snow line buttons
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   369
			/* Don't allow too fast scrolling */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   370
			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   371
				HandleButtonClick(w, e->click.widget);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   372
				SetWindowDirty(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   373
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   374
				_patches_newgame.snow_line_height = clamp(_patches_newgame.snow_line_height + e->click.widget - 22, 2, 13);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   375
			}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   376
			_left_button_clicked = false;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   377
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   378
		case 22: // Snow line text
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   379
			WP(w, def_d).data_3 = SNOW_LINE_QUERY;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   380
			SetDParam(0, _patches_newgame.snow_line_height);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   381
			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_SNOW_LINE_QUERY_CAPT, 3, 100, WC_GENERATE_LANDSCAPE, mode, CS_NUMERAL);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   382
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   383
		case 24: case 25: // Tree placer
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   384
			ShowDropDownMenu(w, tree_placer, _patches_newgame.tree_placer, 25, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   385
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   386
//		case 26: case 27: // Landscape generator OR Heightmap rotation
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   387
		case 27:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   388
			if (mode == GLWP_HEIGHTMAP) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   389
				ShowDropDownMenu(w, rotation, _patches_newgame.heightmap_rotation, 27, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   390
			} else {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   391
				ShowDropDownMenu(w, landscape, _patches_newgame.land_generator, 27, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   392
			}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   393
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   394
//		case 28: case 29: // Terrain type
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   395
		case 28:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   396
//			ShowDropDownMenu(w, elevations, _opt_newgame.diff.terrain_type, 29, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   397
			ShowDropDownMenu(w, elevations, _opt_newgame.diff.terrain_type, 28, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   398
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   399
//		case 30: case 31: // Water quantity
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   400
		case 29:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   401
//			ShowDropDownMenu(w, sea_lakes, _opt_newgame.diff.quantity_sea_lakes, 31, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   402
			ShowDropDownMenu(w, sea_lakes, _opt_newgame.diff.quantity_sea_lakes, 29, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   403
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   404
//		case 32: case 33: // Map smoothness
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   405
		case 30: case 31:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   406
//			ShowDropDownMenu(w, smoothness, _patches_newgame.tgen_smoothness, 33, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   407
			ShowDropDownMenu(w, smoothness, _patches_newgame.tgen_smoothness, 31, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   408
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   409
		}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   410
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   411
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   412
	case WE_MESSAGE:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   413
		ttd_strlcpy(_edit_str_buf, str_fmt("%u", _patches_newgame.generation_seed), lengthof(_edit_str_buf));
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   414
		DrawEditBox(w, &WP(w, querystr_d), SEED_EDIT);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   415
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   416
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   417
	case WE_MOUSELOOP:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   418
		HandleEditBox(w, &WP(w, querystr_d), SEED_EDIT);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   419
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   420
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   421
	case WE_KEYPRESS:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   422
		HandleEditBoxKey(w, &WP(w, querystr_d), SEED_EDIT, e, CS_NUMERAL);
4453
890c107f6fa6 (svn r6236) -Fix (FS#313): TGP generation seed edit box only accepted seeds up to 2^31-1, instead of up to 2^32-2.
rubidium
parents: 4366
diff changeset
   423
		/* the seed is unsigned, therefore atoi cannot be used.
890c107f6fa6 (svn r6236) -Fix (FS#313): TGP generation seed edit box only accepted seeds up to 2^31-1, instead of up to 2^32-2.
rubidium
parents: 4366
diff changeset
   424
		 * As 2^32 - 1 (MAX_UVALUE(uint32)) is a 'magic' value
890c107f6fa6 (svn r6236) -Fix (FS#313): TGP generation seed edit box only accepted seeds up to 2^31-1, instead of up to 2^32-2.
rubidium
parents: 4366
diff changeset
   425
		 * (use random seed) it should not be possible to be
890c107f6fa6 (svn r6236) -Fix (FS#313): TGP generation seed edit box only accepted seeds up to 2^31-1, instead of up to 2^32-2.
rubidium
parents: 4366
diff changeset
   426
		 * entered into the input field; the generate seed
890c107f6fa6 (svn r6236) -Fix (FS#313): TGP generation seed edit box only accepted seeds up to 2^31-1, instead of up to 2^32-2.
rubidium
parents: 4366
diff changeset
   427
		 * button can be used instead. */
890c107f6fa6 (svn r6236) -Fix (FS#313): TGP generation seed edit box only accepted seeds up to 2^31-1, instead of up to 2^32-2.
rubidium
parents: 4366
diff changeset
   428
		_patches_newgame.generation_seed = minu(strtoul(_edit_str_buf, NULL, 10), MAX_UVALUE(uint32) - 1);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   429
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   430
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   431
	case WE_DROPDOWN_SELECT:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   432
		switch (e->dropdown.button) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   433
			case 8:  _patches_newgame.map_x = e->dropdown.index + 6; break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   434
			case 10: _patches_newgame.map_y = e->dropdown.index + 6; break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   435
			case 12:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   436
				_opt_newgame.diff.number_towns = e->dropdown.index;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   437
				if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   438
				DoCommandP(0, 2, _opt_newgame.diff.number_towns, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   439
				break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   440
			case 14:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   441
				_opt_newgame.diff.number_industries = e->dropdown.index;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   442
				if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   443
				DoCommandP(0, 3, _opt_newgame.diff.number_industries, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   444
				break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   445
			case 25:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   446
				_patches_newgame.tree_placer = e->dropdown.index;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   447
				break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   448
			case 27:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   449
				if (mode == GLWP_HEIGHTMAP) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   450
					_patches_newgame.heightmap_rotation = e->dropdown.index;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   451
				} else {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   452
					_patches_newgame.land_generator = e->dropdown.index;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   453
				}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   454
				break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   455
//			case 29:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   456
			case 28:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   457
				_opt_newgame.diff.terrain_type = e->dropdown.index;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   458
				if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   459
				DoCommandP(0, 12, _opt_newgame.diff.terrain_type, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   460
				break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   461
//			case 31:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   462
			case 29:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   463
				_opt_newgame.diff.quantity_sea_lakes = e->dropdown.index;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   464
				if (_opt_newgame.diff_level != 3) ShowErrorMessage(INVALID_STRING_ID, STR_DIFFICULTY_TO_CUSTOM, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   465
				DoCommandP(0, 13, _opt_newgame.diff.quantity_sea_lakes, NULL, CMD_CHANGE_DIFFICULTY_LEVEL);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   466
				break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   467
//			case 33:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   468
			case 31:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   469
				_patches_newgame.tgen_smoothness = e->dropdown.index;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   470
				break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   471
		}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   472
		SetWindowDirty(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   473
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   474
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   475
	case WE_ON_EDIT_TEXT: {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   476
		if (e->edittext.str != NULL) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   477
			int32 value = atoi(e->edittext.str);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   478
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   479
			switch (WP(w, def_d).data_3) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   480
			case START_DATE_QUERY:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   481
				InvalidateWidget(w, 19);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   482
				_patches_newgame.starting_year = clamp(value, MIN_YEAR, MAX_YEAR);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   483
				break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   484
			case SNOW_LINE_QUERY:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   485
				InvalidateWidget(w, 22);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   486
				_patches_newgame.snow_line_height = clamp(value, 2, 13);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   487
				break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   488
			}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   489
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   490
			SetWindowDirty(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   491
		}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   492
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   493
	}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   494
	}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   495
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   496
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   497
const WindowDesc _generate_landscape_desc = {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   498
	WDP_CENTER, WDP_CENTER, 338, 268,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   499
	WC_GENERATE_LANDSCAPE, 0,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   500
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   501
	_generate_landscape_widgets,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   502
	GenerateLandscapeWndProc,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   503
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   504
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   505
const WindowDesc _heightmap_load_desc = {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   506
	WDP_CENTER, WDP_CENTER, 338, 236,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   507
	WC_GENERATE_LANDSCAPE, 0,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   508
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   509
	_heightmap_load_widgets,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   510
	GenerateLandscapeWndProc,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   511
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   512
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   513
static void _ShowGenerateLandscape(glwp_modes mode)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   514
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   515
	Window *w;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   516
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   517
	/* Don't kill WC_GENERATE_LANDSCAPE:GLWP_SCENARIO, because it resets
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   518
	 *  _goto_editor, which we maybe need later on. */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   519
	DeleteWindowById(WC_GENERATE_LANDSCAPE, GLWP_GENERATE);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   520
	DeleteWindowById(WC_GENERATE_LANDSCAPE, GLWP_HEIGHTMAP);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   521
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   522
	/* Always give a new seed if not editor */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   523
	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
   524
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   525
	if (mode == GLWP_HEIGHTMAP) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   526
		if (_heightmap_str != STR_NULL) DeleteName(_heightmap_str);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   527
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   528
		_heightmap_x = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   529
		_heightmap_y = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   530
		_heightmap_str = AllocateName(_file_to_saveload.title, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   531
		/* If the function returns negative, it means there was a problem loading the heightmap */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   532
		if (!GetHeightmapDimensions(_file_to_saveload.name, &_heightmap_x, &_heightmap_y))
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   533
			return;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   534
	}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   535
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   536
	w = AllocateWindowDescFront((mode == GLWP_HEIGHTMAP) ? &_heightmap_load_desc : &_generate_landscape_desc, mode);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   537
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   538
	if (w != NULL) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   539
		querystr_d *querystr = &WP(w, querystr_d);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   540
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   541
		ttd_strlcpy(_edit_str_buf, str_fmt("%u", _patches_newgame.generation_seed), lengthof(_edit_str_buf));
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   542
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   543
		querystr->text.caret = true;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   544
		querystr->text.maxlength = lengthof(_edit_str_buf);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   545
		querystr->text.maxwidth = 120;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   546
		querystr->text.buf = _edit_str_buf;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   547
		querystr->caption = STR_NULL;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   548
		UpdateTextBufferSize(&querystr->text);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   549
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   550
		InvalidateWindow(WC_GENERATE_LANDSCAPE, mode);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   551
	}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   552
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   553
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   554
void ShowGenerateLandscape(void)
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
	_ShowGenerateLandscape(GLWP_GENERATE);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   557
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   558
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   559
void ShowHeightmapLoad(void)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   560
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   561
	_ShowGenerateLandscape(GLWP_HEIGHTMAP);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   562
}
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
void StartNewGameWithoutGUI(uint seed)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   565
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   566
	/* 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
   567
	_patches_newgame.generation_seed = seed;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   568
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   569
	StartGeneratingLandscape(GLWP_GENERATE);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   570
}
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
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   573
void CreateScenarioWndProc(Window *w, WindowEvent *e)
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
	static const StringID mapsizes[] = {STR_64, STR_128, STR_256, STR_512, STR_1024, STR_2048, INVALID_STRING_ID};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   576
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   577
	switch (e->event) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   578
	case WE_PAINT:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   579
		w->disabled_state = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   580
		if (_patches_newgame.starting_year <= MIN_YEAR)  SETBIT(w->disabled_state, 14);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   581
		if (_patches_newgame.starting_year >= MAX_YEAR)  SETBIT(w->disabled_state, 16);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   582
		if (_patches_newgame.se_flat_world_height <= 0)  SETBIT(w->disabled_state, 17);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   583
		if (_patches_newgame.se_flat_world_height >= 15) SETBIT(w->disabled_state, 19);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   584
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   585
		w->click_state = (w->click_state & ~(0xF << 3)) | (1 << (_opt_newgame.landscape + 3));
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   586
		DrawWindowWidgets(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   587
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   588
		DrawString( 12,  96, STR_MAPSIZE, 0);
4309
d79f75b27c86 (svn r5959) -Change: size selection dropdowns placement in 'Scenario type' window
glx
parents: 4306
diff changeset
   589
		DrawString(167,  96, mapsizes[_patches_newgame.map_x - 6], 0x10);
d79f75b27c86 (svn r5959) -Change: size selection dropdowns placement in 'Scenario type' window
glx
parents: 4306
diff changeset
   590
		DrawString(216,  96, STR_BY, 0);
d79f75b27c86 (svn r5959) -Change: size selection dropdowns placement in 'Scenario type' window
glx
parents: 4306
diff changeset
   591
		DrawString(230,  96, mapsizes[_patches_newgame.map_y - 6], 0x10);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   592
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   593
		DrawString(162, 118, STR_DATE, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   594
		SetDParam(0, ConvertYMDToDate(_patches_newgame.starting_year, 0, 1));
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   595
		DrawStringCentered(271, 118, STR_GENERATE_DATE, 0);
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
		DrawString(162, 136, STR_FLAT_WORLD_HEIGHT, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   598
		SetDParam(0, _patches_newgame.se_flat_world_height);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   599
		DrawStringCentered(303, 136, STR_FLAT_WORLD_HEIGHT_NUM, 0x10);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   600
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   601
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   602
	case WE_CLICK:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   603
		switch (e->click.widget) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   604
		case 0: DeleteWindow(w); break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   605
		case 3: case 4: case 5: case 6:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   606
			SetNewLandscapeType(e->click.widget - 3);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   607
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   608
		case 7: case 8: // Mapsize X
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   609
			ShowDropDownMenu(w, mapsizes, _patches_newgame.map_x - 6, 8, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   610
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   611
		case 9: case 10: // Mapsize Y
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   612
			ShowDropDownMenu(w, mapsizes, _patches_newgame.map_y - 6, 10, 0, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   613
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   614
		case 11: // Empty world / flat world
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   615
			StartGeneratingLandscape(GLWP_SCENARIO);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   616
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   617
		case 12: // Generate
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   618
			_goto_editor = true;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   619
			ShowGenerateLandscape();
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   620
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   621
		case 13: // Heightmap
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   622
			_goto_editor = true;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   623
			ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   624
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   625
		case 14: case 16: // Year buttons
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   626
			/* Don't allow too fast scrolling */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   627
			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   628
				HandleButtonClick(w, e->click.widget);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   629
				SetWindowDirty(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   630
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   631
				_patches_newgame.starting_year = clamp(_patches_newgame.starting_year + e->click.widget - 15, MIN_YEAR, MAX_YEAR);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   632
			}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   633
			_left_button_clicked = false;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   634
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   635
		case 15: // Year text
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   636
			WP(w, def_d).data_3 = START_DATE_QUERY;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   637
			SetDParam(0, _patches_newgame.starting_year);
4326
c2ae4dbc1074 (svn r5999) -Feature: change the original date format to a 32 bits format based at the year 0.
rubidium
parents: 4309
diff changeset
   638
			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_START_DATE_QUERY_CAPT, 8, 100, WC_GENERATE_LANDSCAPE, GLWP_SCENARIO, CS_NUMERAL);
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   639
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   640
		case 17: case 19: // Height level buttons
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   641
			/* Don't allow too fast scrolling */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   642
			if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   643
				HandleButtonClick(w, e->click.widget);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   644
				SetWindowDirty(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   645
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   646
				_patches_newgame.se_flat_world_height = clamp(_patches_newgame.se_flat_world_height + e->click.widget - 18, 0, 15);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   647
			}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   648
			_left_button_clicked = false;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   649
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   650
		case 18: // Height level text
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   651
			WP(w, def_d).data_3 = FLAT_WORLD_HEIGHT_QUERY;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   652
			SetDParam(0, _patches_newgame.se_flat_world_height);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   653
			ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_FLAT_WORLD_HEIGHT_QUERY_CAPT, 3, 100, WC_GENERATE_LANDSCAPE, GLWP_SCENARIO, CS_NUMERAL);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   654
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   655
		}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   656
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   657
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   658
	case WE_DROPDOWN_SELECT:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   659
		switch (e->dropdown.button) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   660
			case 8:  _patches_newgame.map_x = e->dropdown.index + 6; break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   661
			case 10: _patches_newgame.map_y = e->dropdown.index + 6; break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   662
		}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   663
		SetWindowDirty(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   664
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   665
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   666
	case WE_DESTROY:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   667
		_goto_editor = false;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   668
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   669
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   670
	case WE_ON_EDIT_TEXT: {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   671
		if (e->edittext.str != NULL) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   672
			int32 value = atoi(e->edittext.str);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   673
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   674
			switch (WP(w, def_d).data_3) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   675
			case START_DATE_QUERY:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   676
				InvalidateWidget(w, 15);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   677
				_patches_newgame.starting_year = clamp(value, MIN_YEAR, MAX_YEAR);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   678
				break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   679
			case FLAT_WORLD_HEIGHT_QUERY:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   680
				InvalidateWidget(w, 18);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   681
				_patches_newgame.se_flat_world_height = clamp(value, 0, 15);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   682
				break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   683
			}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   684
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   685
			SetWindowDirty(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   686
		}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   687
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   688
	}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   689
	}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   690
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   691
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   692
const Widget _create_scenario_widgets[] = {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   693
{   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
   694
{    WWT_CAPTION, RESIZE_NONE, 13,  11, 337,   0,  13, STR_SE_CAPTION,          STR_NULL},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   695
{     WWT_IMGBTN, RESIZE_NONE, 13,   0, 337,  14, 179, STR_NULL,                STR_NULL},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   696
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   697
{    WWT_PANEL_2, RESIZE_NONE, 12,  10,  86,  24,  78, 0x1312,                  STR_030E_SELECT_TEMPERATE_LANDSCAPE},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   698
{    WWT_PANEL_2, RESIZE_NONE, 12,  90, 166,  24,  78, 0x1314,                  STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   699
{    WWT_PANEL_2, RESIZE_NONE, 12, 170, 246,  24,  78, 0x1316,                  STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   700
{    WWT_PANEL_2, RESIZE_NONE, 12, 250, 326,  24,  78, 0x1318,                  STR_0311_SELECT_TOYLAND_LANDSCAPE},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   701
4309
d79f75b27c86 (svn r5959) -Change: size selection dropdowns placement in 'Scenario type' window
glx
parents: 4306
diff changeset
   702
{      WWT_PANEL, RESIZE_NONE, 12, 162, 197,  95, 106, STR_NULL,                STR_NULL},
d79f75b27c86 (svn r5959) -Change: size selection dropdowns placement in 'Scenario type' window
glx
parents: 4306
diff changeset
   703
{    WWT_TEXTBTN, RESIZE_NONE, 12, 198, 209,  95, 106, STR_0225,                STR_NULL}, // Mapsize X
d79f75b27c86 (svn r5959) -Change: size selection dropdowns placement in 'Scenario type' window
glx
parents: 4306
diff changeset
   704
{      WWT_PANEL, RESIZE_NONE, 12, 228, 263,  95, 106, STR_NULL,                STR_NULL},
d79f75b27c86 (svn r5959) -Change: size selection dropdowns placement in 'Scenario type' window
glx
parents: 4306
diff changeset
   705
{    WWT_TEXTBTN, RESIZE_NONE, 12, 264, 275,  95, 106, STR_0225,                STR_NULL}, // Mapsize Y
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   706
4306
a58132bd0432 (svn r5953) -Fix: tooltip for FlatLand had wrong color (tnx glx)
truelight
parents: 4300
diff changeset
   707
{    WWT_TEXTBTN, RESIZE_NONE,  6,  12, 145, 117, 128, STR_SE_FLAT_WORLD,       STR_SE_FLAT_WORLD_TIP},                      // Empty (sea-level) map
4300
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   708
{    WWT_TEXTBTN, RESIZE_NONE,  6,  12, 145, 135, 146, STR_SE_RANDOM_LAND,      STR_022A_GENERATE_RANDOM_LAND}, // Generate
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   709
{    WWT_TEXTBTN, RESIZE_NONE,  6,  12, 145, 153, 164, STR_LOAD_GAME_HEIGHTMAP, STR_LOAD_SCEN_HEIGHTMAP},       // Heightmap
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   710
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   711
{     WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 117, 128, SPR_ARROW_DOWN,          STR_029E_MOVE_THE_STARTING_DATE},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   712
{      WWT_PANEL, RESIZE_NONE, 12, 228, 314, 117, 128, 0x0,                     STR_NULL},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   713
{     WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 117, 128, SPR_ARROW_UP,            STR_029F_MOVE_THE_STARTING_DATE},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   714
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   715
{     WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 135, 146, SPR_ARROW_DOWN,          STR_FLAT_WORLD_HEIGHT_DOWN},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   716
{      WWT_PANEL, RESIZE_NONE, 12, 294, 314, 135, 146, 0x0,                     STR_NULL},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   717
{     WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 135, 146, SPR_ARROW_UP,            STR_FLAT_WORLD_HEIGHT_UP},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   718
{   WIDGETS_END},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   719
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   720
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   721
const WindowDesc _create_scenario_desc = {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   722
	WDP_CENTER, WDP_CENTER, 338, 180,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   723
	WC_GENERATE_LANDSCAPE, 0,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   724
	WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   725
	_create_scenario_widgets,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   726
	CreateScenarioWndProc,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   727
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   728
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   729
void ShowCreateScenario(void)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   730
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   731
	DeleteWindowByClass(WC_GENERATE_LANDSCAPE);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   732
	AllocateWindowDescFront(&_create_scenario_desc, GLWP_SCENARIO);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   733
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   734
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   735
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   736
static const Widget _show_terrain_progress_widgets[] = {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   737
{    WWT_CAPTION,   RESIZE_NONE,    14,     0,   180,     0,    13, STR_GENERATION_WORLD,   STR_018C_WINDOW_TITLE_DRAG_THIS},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   738
{     WWT_IMGBTN,   RESIZE_NONE,    14,     0,   180,    14,    96, 0x0,                    STR_NULL},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   739
{    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
   740
{   WIDGETS_END},
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   741
};
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   742
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   743
typedef struct tp_info {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   744
	uint percent;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   745
	StringID class;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   746
	uint current;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   747
	uint total;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   748
	int timer;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   749
} tp_info;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   750
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   751
static tp_info _tp;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   752
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   753
static void AbortGeneratingWorldCallback(bool ok_clicked)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   754
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   755
	if (ok_clicked) AbortGeneratingWorld();
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   756
	else if (IsGeneratingWorld() && !IsGeneratingWorldAborted()) SetMouseCursor(SPR_CURSOR_ZZZ);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   757
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   758
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   759
static void ShowTerrainProgressProc(Window* w, WindowEvent* e)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   760
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   761
	switch (e->event) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   762
	case WE_CLICK:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   763
		switch (e->click.widget) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   764
		case 2:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   765
			if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   766
			ShowQuery(STR_GENERATION_ABORT_CAPTION, STR_GENERATION_ABORT_MESSAGE, AbortGeneratingWorldCallback, WC_GENERATE_PROGRESS_WINDOW, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   767
			break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   768
		}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   769
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   770
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   771
	case WE_PAINT:
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   772
		DrawWindowWidgets(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   773
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   774
		/* Draw the % complete with a bar and a text */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   775
		DrawFrameRect(19, 20, (w->width - 18), 37, 14, FR_BORDERONLY);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   776
		DrawFrameRect(20, 21, (int)((w->width - 40) * _tp.percent / 100) + 20, 36, 10, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   777
		SetDParam(0, _tp.percent);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   778
		DrawStringCentered(90, 25, STR_PROGRESS, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   779
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   780
		/* Tell which class we are generating */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   781
		DrawStringCentered(90, 46, _tp.class, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   782
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   783
		/* And say where we are in that class */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   784
		SetDParam(0, _tp.current);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   785
		SetDParam(1, _tp.total);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   786
		DrawStringCentered(90, 58, STR_GENERATION_PROGRESS, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   787
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   788
		SetWindowDirty(w);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   789
		break;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   790
	}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   791
}
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
static const WindowDesc _show_terrain_progress_desc = {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   794
	WDP_CENTER, WDP_CENTER, 181, 97,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   795
	WC_GENERATE_PROGRESS_WINDOW, 0,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   796
	WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   797
	_show_terrain_progress_widgets,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   798
	ShowTerrainProgressProc
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   799
};
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
/**
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   802
 * Initializes the progress counters to the starting point.
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
void PrepareGenerateWorldProgress(void)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   805
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   806
	_tp.class   = STR_WORLD_GENERATION;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   807
	_tp.current = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   808
	_tp.total   = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   809
	_tp.percent = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   810
	_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
   811
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   812
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   813
/**
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   814
 * 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
   815
 */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   816
void ShowGenerateWorldProgress(void)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   817
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   818
	AllocateWindowDescFront(&_show_terrain_progress_desc, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   819
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   820
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   821
static void _SetGeneratingWorldProgress(gwp_class class, uint progress, uint total)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   822
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   823
	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
   824
	static const StringID class_table[GWP_CLASS_COUNT]  = {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   825
		STR_WORLD_GENERATION,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   826
		STR_022E_LANDSCAPE_GENERATION,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   827
		STR_CLEARING_TILES,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   828
		STR_022F_TOWN_GENERATION,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   829
		STR_0230_INDUSTRY_GENERATION,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   830
		STR_UNMOVABLE_GENERATION,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   831
		STR_TREE_GENERATION,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   832
		STR_SETTINGUP_GAME,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   833
		STR_PREPARING_TILELOOP,
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   834
		STR_PREPARING_GAME
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   835
	};
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
	assert(class < GWP_CLASS_COUNT);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   838
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   839
	/* 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
   840
	if (!IsGenerateWorldThreaded() && !_network_dedicated) return;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   841
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   842
	if (IsGeneratingWorldAborted()) HandleGeneratingWorldAbortion();
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   843
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   844
	if (total == 0) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   845
		assert(_tp.class == class_table[class]);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   846
		_tp.current += progress;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   847
	} else {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   848
		_tp.class   = class_table[class];
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   849
		_tp.current = progress;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   850
		_tp.total   = total;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   851
		_tp.percent = percent_table[class];
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   852
	}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   853
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   854
	/* Don't update the screen too often. So update it once in the
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   855
	 * _patches.progress_update_interval. However, the _tick_counter
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   856
	 * increases with 8 every 30ms, so compensate for that. */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   857
	if (!_network_dedicated && _tp.timer != 0 && _timer_counter - _tp.timer < (_patches.progress_update_interval * 8 / 30)) return;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   858
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   859
	/* Percentage is about the number of completed tasks, so 'current - 1' */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   860
	_tp.percent = percent_table[class] + (percent_table[class + 1] - percent_table[class]) * (_tp.current == 0 ? 0 : _tp.current - 1) / _tp.total;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   861
	_tp.timer = _timer_counter;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   862
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   863
	if (_network_dedicated) {
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   864
		static uint last_percent = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   865
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   866
		/* Never display 0% */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   867
		if (_tp.percent == 0) return;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   868
		/* 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
   869
		if (_tp.percent < last_percent) last_percent = 0;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   870
		/* 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
   871
		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
   872
		/* 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
   873
		if (_tp.percent <= last_percent + 2) return;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   874
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   875
		DEBUG(net, 1)("Percent complete: %d", _tp.percent);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   876
		last_percent = _tp.percent;
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   877
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   878
		/* 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
   879
		return;
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
	InvalidateWindow(WC_GENERATE_PROGRESS_WINDOW, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   883
	MarkWholeScreenDirty();
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   884
	SetGeneratingWorldPaintStatus(true);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   885
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   886
	/* 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
   887
	 *  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
   888
	 *  if you implement threading afterwards */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   889
	while (IsGeneratingWorldReadyForPaint()) { CSleep(10); }
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   890
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   891
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
 * Set the total of a stage of the world generation.
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   894
 * @param class the current class we are in.
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   895
 * @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
   896
 *
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   897
 * 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
   898
 *  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
   899
 */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   900
void SetGeneratingWorldProgress(gwp_class class, uint total)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   901
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   902
	if (total == 0) return;
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
	_SetGeneratingWorldProgress(class, 0, total);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   905
}
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   906
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   907
/**
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   908
 * Increases the current stage of the world generation with one.
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   909
 * @param class the current class we are in.
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   910
 *
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   911
 * 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
   912
 *  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
   913
 */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   914
void IncreaseGeneratingWorldProgress(gwp_class class)
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   915
{
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   916
	/* In fact the param 'class' isn't needed.. but for some security reasons, we want it around */
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   917
	_SetGeneratingWorldProgress(class, 1, 0);
687a17c9c557 (svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
diff changeset
   918
}