38 extern void MakeNewgameSettingsLive();
97 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_BY, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(1, 1),
151 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_NORTHWEST, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(0, 1),
156 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_NORTHEAST, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(0, 1),
163 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_SOUTHWEST, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(0, 1),
168 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_SOUTHEAST, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(0, 1),
217 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_BY, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(1, 1),
268 MakeNewgameSettingsLive();
276 default: NOT_REACHED();
280 static void LandscapeGenerationCallback(
Window *w,
bool confirmed)
291 item->SetParam(0, 1 << i);
298 static const StringID _elevations[] = {STR_TERRAIN_TYPE_VERY_FLAT, STR_TERRAIN_TYPE_FLAT, STR_TERRAIN_TYPE_HILLY, STR_TERRAIN_TYPE_MOUNTAINOUS, STR_TERRAIN_TYPE_ALPINIST,
INVALID_STRING_ID};
299 static const StringID _sea_lakes[] = {STR_SEA_LEVEL_VERY_LOW, STR_SEA_LEVEL_LOW, STR_SEA_LEVEL_MEDIUM, STR_SEA_LEVEL_HIGH, STR_SEA_LEVEL_CUSTOM,
INVALID_STRING_ID};
300 static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT,
INVALID_STRING_ID};
301 static const StringID _smoothness[] = {STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_SMOOTH, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_SMOOTH, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_ROUGH, STR_CONFIG_SETTING_ROUGHNESS_OF_TERRAIN_VERY_ROUGH,
INVALID_STRING_ID};
302 static const StringID _tree_placer[] = {STR_CONFIG_SETTING_TREE_PLACER_NONE, STR_CONFIG_SETTING_TREE_PLACER_ORIGINAL, STR_CONFIG_SETTING_TREE_PLACER_IMPROVED,
INVALID_STRING_ID};
303 static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE,
INVALID_STRING_ID};
304 static const StringID _landscape[] = {STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL, STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS,
INVALID_STRING_ID};
305 static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM,
INVALID_STRING_ID};
306 static const StringID _num_inds[] = {STR_FUNDING_ONLY, STR_MINIMAL, STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH,
INVALID_STRING_ID};
307 static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, STR_VARIETY_LOW, STR_VARIETY_MEDIUM, STR_VARIETY_HIGH, STR_VARIETY_VERY_HIGH,
INVALID_STRING_ID};
345 if (_game_mode == GM_EDITOR) {
362 SetDParam(0, STR_SEA_LEVEL_CUSTOM_PERCENTAGE);
398 if (!gui_scope)
return;
517 size->width += padding.width;
525 DrawString(r.left, r.right, r.top, this->name, TC_ORANGE);
574 STR_WARNING_HEIGHTMAP_SCALE_CAPTION,
575 STR_WARNING_HEIGHTMAP_SCALE_MESSAGE,
577 LandscapeGenerationCallback);
579 StartGeneratingLandscape(mode);
657 uint32 hidden_mask = 0;
709 for (
const int *widget = raise_widgets; *widget !=
WIDGET_LIST_END; widget++) {
738 this->widget_id = widget;
750 this->widget_id = widget;
764 if (str == NULL)
return;
771 switch (this->widget_id) {
777 default: NOT_REACHED();
781 switch (this->widget_id) {
814 _nested_generate_landscape_widgets,
lengthof(_nested_generate_landscape_widgets)
821 _nested_heightmap_load_widgets,
lengthof(_nested_heightmap_load_widgets)
933 str = STR_BLACK_DATE_LONG;
949 size->width += padding.width;
950 size->height += padding.height;
1021 for (
const int *widget = raise_widgets; *widget !=
WIDGET_LIST_END; widget++) {
1041 int32 value = atoi(str);
1043 switch (this->widget_id) {
1060 static const NWidgetPart _nested_create_scenario_widgets[] = {
1116 _nested_create_scenario_widgets,
lengthof(_nested_create_scenario_widgets)
1126 static const NWidgetPart _nested_generate_progress_widgets[] = {
1144 _nested_generate_progress_widgets,
lengthof(_nested_generate_progress_widgets)
1157 static const StringID _generation_class_table[] = {
1158 STR_GENERATION_WORLD_GENERATION,
1159 STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION,
1160 STR_GENERATION_RIVER_GENERATION,
1161 STR_GENERATION_CLEARING_TILES,
1162 STR_SCENEDIT_TOOLBAR_TOWN_GENERATION,
1163 STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION,
1164 STR_GENERATION_OBJECT_GENERATION,
1165 STR_GENERATION_TREE_GENERATION,
1166 STR_GENERATION_SETTINGUP_GAME,
1167 STR_GENERATION_PREPARING_TILELOOP,
1168 STR_GENERATION_PREPARING_SCRIPT,
1169 STR_GENERATION_PREPARING_GAME
1171 assert_compile(
lengthof(_generation_class_table) == GWP_CLASS_COUNT);
1174 static void AbortGeneratingWorldCallback(
Window *w,
bool confirmed)
1196 STR_GENERATION_ABORT_CAPTION,
1197 STR_GENERATION_ABORT_MESSAGE,
1199 AbortGeneratingWorldCallback
1218 for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
1232 DrawFrameRect(r.left + 1, r.top + 1, (
int)((r.right - r.left - 2) * _gws.percent / 100) + r.left + 1, r.bottom - 1, COLOUR_MAUVE, FR_NONE);
1254 _gws.cls = STR_GENERATION_WORLD_GENERATION;
1270 static void _SetGeneratingWorldProgress(
GenWorldProgress cls, uint progress, uint total)
1272 static const int percent_table[] = {0, 5, 14, 17, 20, 40, 60, 65, 80, 85, 95, 99, 100 };
1273 assert_compile(
lengthof(percent_table) == GWP_CLASS_COUNT + 1);
1274 assert(cls < GWP_CLASS_COUNT);
1282 assert(_gws.cls == _generation_class_table[cls]);
1283 _gws.current += progress;
1284 assert(_gws.current <= _gws.total);
1286 _gws.cls = _generation_class_table[cls];
1287 _gws.current = progress;
1289 _gws.percent = percent_table[cls];
1296 _gws.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_gws.current == 0 ? 0 : _gws.current - 1) / _gws.total;
1299 static uint last_percent = 0;
1302 if (_gws.percent == 0)
return;
1304 if (_gws.percent < last_percent) last_percent = 0;
1306 if (_gws.percent % 5 != 0 && _gws.percent <= last_percent + 5)
return;
1308 if (_gws.percent <= last_percent + 2)
return;
1310 DEBUG(net, 1,
"Map generation percentage complete: %d", _gws.percent);
1311 last_percent = _gws.percent;
1342 if (total == 0)
return;
1344 _SetGeneratingWorldProgress(cls, 0, total);
1357 _SetGeneratingWorldProgress(cls, 1, 0);
Functions related to OTTD's strings.
Generate landscape (newgame); Window numbers:
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
uint16 custom_town_number
manually entered number of towns
uint8 max_heightlevel
maximum allowed heightlevel
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Horizontally center the text.
ResizeInfo resize
Resize information.
void ShowCreateScenario()
Show the window to create a scenario.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
uint32 _realtime_tick
The real time in the game.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
bool GetHeightmapDimensions(DetailedFileType dft, const char *filename, uint *x, uint *y)
Get the dimensions of a heightmap.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
byte landscape
the landscape we're currently in
static const uint CUSTOM_TOWN_MAX_NUMBER
this is the maximum number of towns a user can specify in customisation
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
GenWorldProgress
Current stage of world generation process.
static const uint MAX_TILE_HEIGHT
Maximum allowed tile height.
Load heightmap from scenario editor.
High level window description.
byte land_generator
the landscape generator
void SetMouseCursorBusy(bool busy)
Set or unset the ZZZ cursor.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
WindowFlags flags
Window flags.
static const uint MAX_MAX_HEIGHTLEVEL
Upper bound of maximum allowed heightlevel (in the construction settings)
byte amount_of_rivers
the amount of rivers
void DrawWidgets() const
Paint all widgets of a window.
Functions related to dates.
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Progress report of landscape generation; Window numbers:
Normal amount of vertical space between two paragraphs of text.
Functions related to debugging.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Number of industry density settings.
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY
Value for custom sea level in difficulty settings.
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
byte tree_placer
the tree placer algorithm
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
char title[255]
Internal name of the game.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
bool IsGenerateWorldThreaded()
Tells if the world generation is done in a thread or not.
DifficultySettings difficulty
settings related to the difficulty
bool IsGeneratingWorldAborted()
Is the generation being aborted?
#define lastof(x)
Get the last element of an fixed size array.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Functions related to world/map generation.
void ShowGenerateWorldProgress()
Show the window where a user can follow the process of the map generation.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
uint8 map_x
X size of map.
void AbortGeneratingWorld()
Initializes the abortion process.
static const uint MODAL_PROGRESS_REDRAW_TIMEOUT
Timeout between redraws.
static T max(const T a, const T b)
Returns the maximum of two values.
virtual void EndCritical(bool allow_recursive=false)=0
End of the critical section.
void RaiseWidget(byte widget_index)
Marks a widget as raised.
void DeleteAllNonVitalWindows()
It is possible that a stickied window gets to a position where the 'close' button is outside the gami...
void SetGeneratingWorldProgress(GenWorldProgress cls, uint total)
Set the total of a stage of the world generation.
byte custom_sea_level
manually entered percentage of water in the map
byte se_flat_world_height
land height a flat world gets in SE
void StartNewGameWithoutGUI(uint seed)
Start a normal game without the GUI.
bool _left_button_clicked
Is left mouse button clicked?
static const Year DEF_START_YEAR
The default starting year.
bool _network_dedicated
are we a dedicated server?
T * Append(uint to_add=1)
Append an item and return it.
ThreadMutex * _modal_progress_work_mutex
Rights for the performing work.
Pseudo random number generator.
uint8 map_y
Y size of map.
Base for the GUIs that have an edit box in them.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
bool freeform_edges
allow terraforming the tiles at the map edges
Data structure for an opened window.
byte tgen_smoothness
how rough is the terrain from 0-3
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
static const NWidgetPart _nested_heightmap_load_widgets[]
Widgets of GenerateLandscapeWindow when loading heightmap.
enable the 'Default' button ("\0" is returned)
Functions related to low-level strings.
Functions/types related to saving and loading games.
Functions related to errors.
Load a heightmap and start a new game from it.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Switch to scenario editor.
byte water_borders
bitset of the borders that are water
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
SoundSettings sound
sound effect settings
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Simple vector template class, with automatic delete.
ClientSettings _settings_client
The current settings for this game.
byte snow_line_height
the configured snow line height
Functions related to modal progress.
Definition of base types and functions in a cross-platform compatible way.
void ShowHeightmapLoad()
Start with loading a heightmap.
A number of safeguards to prevent using unsafe methods.
static const uint DEF_MAX_HEIGHTLEVEL
Default maximum allowed heightlevel (in the construction settings)
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
GameSettings _settings_newgame
Game settings for new games (updated from the intro screen).
virtual void OnTimeout()
Called when this window's timeout has been reached.
void LowerWidget(byte widget_index)
Marks a widget as lowered.
void ShowGenerateLandscape()
Start with a normal game.
virtual void OnPaint()
The window must be repainted.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Basic functions/variables used all over the place.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
#define lengthof(x)
Return the length of an fixed size array.
Types related to the drop down widget.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
Functions related to sound.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
ThreadMutex * _modal_progress_paint_mutex
Rights for the painting.
byte number_towns
the amount of towns
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
byte heightmap_rotation
rotation director for the heightmap
byte variety
variety level applied to TGP
Draw border only, no background.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
#define DEBUG(name, level,...)
Output a line of debugging information.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
void SetMouseCursor(CursorID sprite, PaletteID pal)
Assign a single non-animated sprite to the cursor.
Select game window; Window numbers:
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
No window, redirects to WC_MAIN_WINDOW.
byte quantity_sea_lakes
the amount of seas/lakes
void PrepareGenerateWorldProgress()
Initializes the progress counters to the starting point.
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY
value for custom town number in difficulty settings
static const uint MIN_SNOWLINE_HEIGHT
Minimum snowline height.
uint32 generation_seed
noise seed for world generation
static const uint MIN_MAX_HEIGHTLEVEL
Lower bound of maximum allowed heightlevel (in the construction settings)
void IncreaseGeneratingWorldProgress(GenWorldProgress cls)
Increases the current stage of the world generation with one.
void ClearErrorMessages()
Clear all errors from the queue.
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Declarations for savegames operations.
Functions related to creating heightmaps from files.
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void ResetGRFConfig(bool defaults)
Reset the current GRF Config to either blank or newgame settings.
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE
Minimum percentage a user can specify for custom sea level.
char * strecpy(char *dst, const char *src, const char *last)
Copies characters from one buffer to another.
Functions related to the drop down widget.
SwitchMode _switch_mode
The next mainloop command.
bool confirm
Play sound effect on succesful constructions or other actions.
Bottom offset of the dropdown widget string.
char name[MAX_PATH]
Name of the file.
Coordinates of a point in 2D.
byte terrain_type
the mountainousness of the landscape
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
The original landscape generator.
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE
Maximum percentage a user can specify for custom sea level.
ConstructionSettings construction
construction of things in-game
static const Year MIN_YEAR
The absolute minimum & maximum years in OTTD.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
static const uint DEF_SNOWLINE_HEIGHT
Default snowline height.
void HandleGeneratingWorldAbortion()
Really handle the abortion, i.e.
static const uint MAX_MAP_SIZE_BITS
Maximal size of map is equal to 2 ^ MAX_MAP_SIZE_BITS.
int width
width of the window (number of pixels to the right in x direction)
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
GenerateLandscapeWindowMode
Enum for the modes we can generate in.
static const NWidgetPart _nested_generate_landscape_widgets[]
Widgets of GenerateLandscapeWindow when generating world.
Rotate the map clockwise 45 degrees.
virtual void OnTimeout()
Called when this window's timeout has been reached.
static const uint MAX_MAP_SIZE
Maximal map size = 4096.
int32 WindowNumber
Number to differentiate different windows of the same class.
GameCreationSettings game_creation
settings used during the creation of a game (map)
Specification of a rectangle with absolute coordinates of all edges.
DetailedFileType detail_ftype
Concrete file type (PNG, BMP, old save, etc).
WindowNumber window_number
Window number within the window class.
Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
Generate random land within scenario editor.
virtual void BeginCritical(bool allow_recursive=false)=0
Begin the critical section.
Window functions not directly related to making/drawing windows.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
void StartScenarioEditor()
Start with a scenario editor.
void SetNewLandscapeType(byte landscape)
Changes landscape type and sets genworld window dirty.
byte industry_density
The industry density.
String list item with parameters.
uint8 timeout_timer
Timer value of the WF_TIMEOUT for flags.
Dimensions (a width and height) of a rectangle in 2D.
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date...
Year starting_year
starting date
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
New Game –> 'Random game'.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
static bool HasModalProgress()
Check if we are currently in a modal progress state.
Top offset of the dropdown widget string.
static const uint MIN_MAP_SIZE_BITS
Minimal and maximal map width and height.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
AutoDeleteSmallVector< const DropDownListItem *, 4 > DropDownList
A drop down list is a collection of drop down list items.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
static const uint MAX_SNOWLINE_HEIGHT
Maximum allowed snowline height.