# genworld_gui.cpp File Reference

`#include "stdafx.h"`
`#include "openttd.h"`
`#include "heightmap.h"`
`#include "gui.h"`
`#include "window_gui.h"`
`#include "textbuf_gui.h"`
`#include "gfxinit.h"`
`#include "command_func.h"`
`#include "variables.h"`
`#include "settings_func.h"`
`#include "debug.h"`
`#include "genworld.h"`
`#include "network/network.h"`
`#include "thread.h"`
`#include "newgrf_config.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "date_func.h"`
`#include "sound_func.h"`
`#include "fios.h"`
`#include "string_func.h"`
`#include "gfx_func.h"`
`#include "settings_type.h"`
`#include "widgets/dropdown_type.h"`
`#include "widgets/dropdown_func.h"`
`#include "core/random_func.hpp"`
`#include "table/strings.h"`
`#include "table/sprites.h"`

Go to the source code of this file.

## Data Structures

struct | generate_d
struct | tp_info

## Enumerations

enum | glwp_modes { GLWP_GENERATE, GLWP_HEIGHTMAP, GLWP_SCENARIO, GLWP_END }
| In what 'mode' the GenerateLandscapeWindowProc is.

enum

GenerateLandscapeWindowWidgets {
GLAND_TEMPERATE = 3, GLAND_ARCTIC, GLAND_TROPICAL, GLAND_TOYLAND,
GLAND_MAPSIZE_X_TEXT, GLAND_MAPSIZE_X_PULLDOWN, GLAND_MAPSIZE_Y_TEXT, GLAND_MAPSIZE_Y_PULLDOWN,
GLAND_TOWN_TEXT, GLAND_TOWN_PULLDOWN, GLAND_INDUSTRY_TEXT, GLAND_INDUSTRY_PULLDOWN,
GLAND_RANDOM_TEXT, GLAND_RANDOM_EDITBOX, GLAND_RANDOM_BUTTON, GLAND_GENERATE_BUTTON,
GLAND_START_DATE_TEXT1, GLAND_START_DATE_DOWN, GLAND_START_DATE_TEXT, GLAND_START_DATE_UP,
GLAND_SNOW_LEVEL_TEXT1, GLAND_SNOW_LEVEL_DOWN, GLAND_SNOW_LEVEL_TEXT, GLAND_SNOW_LEVEL_UP,
GLAND_TREE_TEXT, GLAND_TREE_PULLDOWN, GLAND_LANDSCAPE_TEXT, GLAND_LANDSCAPE_PULLDOWN,
GLAND_HEIGHTMAP_ROTATION_TEXT = GLAND_LANDSCAPE_TEXT, GLAND_HEIGHTMAP_ROTATION_PULLDOWN = GLAND_LANDSCAPE_PULLDOWN, GLAND_TERRAIN_TEXT, GLAND_TERRAIN_PULLDOWN,
GLAND_WATER_TEXT, GLAND_WATER_PULLDOWN, GLAND_SMOOTHNESS_TEXT, GLAND_SMOOTHNESS_PULLDOWN
}

enum

CreateScenarioWindowWidgets {
CSCEN_TEMPERATE = 3, CSCEN_ARCTIC, CSCEN_TROPICAL, CSCEN_TOYLAND,
CSCEN_EMPTY_WORLD, CSCEN_RANDOM_WORLD, CSCEN_MAPSIZE_X_TEXT, CSCEN_MAPSIZE_X_PULLDOWN,
CSCEN_MAPSIZE_Y_TEXT, CSCEN_MAPSIZE_Y_PULLDOWN, CSCEN_START_DATE_LABEL, CSCEN_START_DATE_DOWN,
CSCEN_START_DATE_TEXT, CSCEN_START_DATE_UP, CSCEN_FLAT_LAND_HEIGHT_LABEL, CSCEN_FLAT_LAND_HEIGHT_DOWN,
CSCEN_FLAT_LAND_HEIGHT_TEXT, CSCEN_FLAT_LAND_HEIGHT_UP
}

## Functions

void | SwitchMode (int new_mode)
static void | SetNewLandscapeType (byte landscape)
void | StartGeneratingLandscape (glwp_modes mode)
static void | LandscapeGenerationCallback (Window *w, bool confirmed)
static DropDownList * | BuildMapsizeDropDown ()
static void | GenerateLandscapeWndProc (Window *w, WindowEvent *e)
static void | _ShowGenerateLandscape (glwp_modes mode)
void | ShowGenerateLandscape ()
void | ShowHeightmapLoad ()
void | StartScenarioEditor ()
void | StartNewGameWithoutGUI (uint seed)
static void | CreateScenarioWndProc (Window *w, WindowEvent *e)
void | ShowCreateScenario ()
static void | AbortGeneratingWorldCallback (Window *w, bool confirmed)
static void | ShowTerrainProgressProc (Window *w, WindowEvent *e)
void | PrepareGenerateWorldProgress ()
| Initializes the progress counters to the starting point.
void | ShowGenerateWorldProgress ()
| Show the window where a user can follow the process of the map generation.
static void | _SetGeneratingWorldProgress (gwp_class cls, uint progress, uint total)
void | SetGeneratingWorldProgress (gwp_class cls, uint total)
| Set the total of a stage of the world generation.
void | IncreaseGeneratingWorldProgress (gwp_class cls)
| Increases the current stage of the world generation with one.

## Variables

static const Widget | _generate_landscape_widgets []
static const Widget | _heightmap_load_widgets []
static const WindowDesc | _generate_landscape_desc
static const WindowDesc | _heightmap_load_desc
static const Widget | _create_scenario_widgets []
static const WindowDesc | _create_scenario_desc
static const Widget | _show_terrain_progress_widgets []
static tp_info | _tp
static const WindowDesc | _show_terrain_progress_desc

## Detailed Description

Definition in file genworld_gui.cpp.

## Function Documentation

void IncreaseGeneratingWorldProgress | ( | gwp_class | cls | ) |

Increases the current stage of the world generation with one.

Parameters:

  | cls | the current class we are in.

Warning: this function isn't clever. Don't go from class 4 to 3. Go upwards, always. Also, progress works if total is zero, total works if progress is zero.

Definition at line 989 of file genworld_gui.cpp.

Referenced by _GenerateWorld(), GenerateTerrainPerlin(), PlaceInitialIndustry(), and PlaceTreesRandomly().

void SetGeneratingWorldProgress | ( | gwp_class | cls,
|  | uint | total |
| ) |  |  |

Set the total of a stage of the world generation.

Parameters:

  | cls | the current class we are in.
  | total | Set the total expected items for this class.

Warning: this function isn't clever. Don't go from class 4 to 3. Go upwards, always. Also, progress works if total is zero, total works if progress is zero.

Definition at line 975 of file genworld_gui.cpp.

Referenced by _GenerateWorld(), GenerateIndustries(), and GenerateTrees().

## Variable Documentation

const WindowDesc _create_scenario_desc`[static]`

Initial value:

     {
      WDP_CENTER, WDP_CENTER, 338, 170, 338, 170,
      WC_GENERATE_LANDSCAPE, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
      _create_scenario_widgets,
      CreateScenarioWndProc,
    }

Definition at line 789 of file genworld_gui.cpp.

const Widget _create_scenario_widgets[]`[static]`

Initial value:

     {
    {   WWT_CLOSEBOX, RESIZE_NONE, 13,   0,  10,   0,  13, STR_00C5,                STR_018B_CLOSE_WINDOW},
    {    WWT_CAPTION, RESIZE_NONE, 13,  11, 337,   0,  13, STR_SE_CAPTION,          STR_NULL},
    {      WWT_PANEL, RESIZE_NONE, 13,   0, 337,  14, 169, 0x0,                     STR_NULL},

    {   WWT_IMGBTN_2, RESIZE_NONE, 12,  10,  86,  24,  78, SPR_SELECT_TEMPERATE,    STR_030E_SELECT_TEMPERATE_LANDSCAPE},
    {   WWT_IMGBTN_2, RESIZE_NONE, 12,  90, 166,  24,  78, SPR_SELECT_SUB_ARCTIC,   STR_030F_SELECT_SUB_ARCTIC_LANDSCAPE},
    {   WWT_IMGBTN_2, RESIZE_NONE, 12, 170, 246,  24,  78, SPR_SELECT_SUB_TROPICAL, STR_0310_SELECT_SUB_TROPICAL_LANDSCAPE},
    {   WWT_IMGBTN_2, RESIZE_NONE, 12, 250, 326,  24,  78, SPR_SELECT_TOYLAND,      STR_0311_SELECT_TOYLAND_LANDSCAPE},

    {    WWT_TEXTBTN, RESIZE_NONE,  6,  12, 115,  95, 124, STR_SE_FLAT_WORLD,       STR_SE_FLAT_WORLD_TIP},
    {    WWT_TEXTBTN, RESIZE_NONE,  6,  12, 115, 131, 160, STR_SE_RANDOM_LAND,      STR_022A_GENERATE_RANDOM_LAND},

    {       WWT_TEXT, RESIZE_NONE, 12, 182, 212,  96, 106, STR_MAPSIZE,             STR_NULL},
    {   WWT_DROPDOWN, RESIZE_NONE, 12, 216, 263,  95, 106, STR_NUM_1,               STR_NULL},
    {       WWT_TEXT, RESIZE_NONE, 12, 268, 276,  96, 106, STR_BY,                  STR_NULL},
    {   WWT_DROPDOWN, RESIZE_NONE, 12, 279, 326,  95, 106, STR_NUM_2,               STR_NULL},

    {       WWT_TEXT, RESIZE_NONE,  0, 182, 212, 114, 124, STR_DATE,                STR_NULL},
    {     WWT_IMGBTN, RESIZE_NONE, 12, 216, 227, 113, 124, SPR_ARROW_DOWN,          STR_029E_MOVE_THE_STARTING_DATE},
    {    WWT_TEXTBTN, RESIZE_NONE, 12, 228, 314, 113, 124, STR_GENERATE_DATE,       STR_NULL},
    {     WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 113, 124, SPR_ARROW_UP,            STR_029F_MOVE_THE_STARTING_DATE},

    {       WWT_TEXT, RESIZE_NONE,  0, 182, 278, 132, 142, STR_FLAT_WORLD_HEIGHT,   STR_NULL},
    {     WWT_IMGBTN, RESIZE_NONE, 12, 282, 293, 131, 142, SPR_ARROW_DOWN,          STR_FLAT_WORLD_HEIGHT_DOWN},
    {    WWT_TEXTBTN, RESIZE_NONE, 12, 294, 314, 131, 142, STR_NUM_3,               STR_NULL},
    {     WWT_IMGBTN, RESIZE_NONE, 12, 315, 326, 131, 142, SPR_ARROW_UP,            STR_FLAT_WORLD_HEIGHT_UP},
    {   WIDGETS_END},
    }

Definition at line 759 of file genworld_gui.cpp.

const WindowDesc _generate_landscape_desc`[static]`

Initial value:

     {
      WDP_CENTER, WDP_CENTER, 338, 268, 338, 268,
      WC_GENERATE_LANDSCAPE, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
      _generate_landscape_widgets,
      GenerateLandscapeWndProc,
    }

Definition at line 544 of file genworld_gui.cpp.

const WindowDesc _heightmap_load_desc`[static]`

Initial value:

     {
      WDP_CENTER, WDP_CENTER, 338, 236, 338, 236,
      WC_GENERATE_LANDSCAPE, WC_NONE,
      WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_STD_BTN | WDF_UNCLICK_BUTTONS,
      _heightmap_load_widgets,
      GenerateLandscapeWndProc,
    }

Definition at line 552 of file genworld_gui.cpp.

const WindowDesc _show_terrain_progress_desc`[static]`

Initial value:

     {
      WDP_CENTER, WDP_CENTER, 181, 97, 181, 97,
      WC_GENERATE_PROGRESS_WINDOW, WC_NONE,
      WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
      _show_terrain_progress_widgets,
      ShowTerrainProgressProc
    }

Definition at line 869 of file genworld_gui.cpp.

const Widget _show_terrain_progress_widgets[]`[static]`

Initial value:

     {
    {    WWT_CAPTION,   RESIZE_NONE,    14,     0,   180,     0,    13, STR_GENERATION_WORLD,   STR_018C_WINDOW_TITLE_DRAG_THIS},
    {      WWT_PANEL,   RESIZE_NONE,    14,     0,   180,    14,    96, 0x0,                    STR_NULL},
    {    WWT_TEXTBTN,   RESIZE_NONE,    15,    20,   161,    74,    85, STR_GENERATION_ABORT,   STR_NULL},
    {   WIDGETS_END},
    }

Definition at line 804 of file genworld_gui.cpp.