43 extern void MakeNewgameSettingsLive();
170 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_NORTHWEST, STR_NULL),
SetPadding(0,
WidgetDimensions::unscaled.hsep_normal, 0, 0),
SetFill(1, 1),
SetAlignment(
SA_RIGHT |
SA_VERT_CENTER),
173 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_NORTHEAST, STR_NULL),
SetPadding(0, 0, 0,
WidgetDimensions::unscaled.hsep_normal),
SetFill(1, 1),
176 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_SOUTHWEST, STR_NULL),
SetPadding(0,
WidgetDimensions::unscaled.hsep_normal, 0, 0),
SetFill(1, 1),
SetAlignment(
SA_RIGHT |
SA_VERT_CENTER),
179 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_SOUTHEAST, STR_NULL),
SetPadding(0, 0, 0,
WidgetDimensions::unscaled.hsep_normal),
SetFill(1, 1),
319 MakeNewgameSettingsLive();
327 default: NOT_REACHED();
331 static void LandscapeGenerationCallback(
Window *w,
bool confirmed)
342 list.push_back(MakeDropDownListStringItem(STR_JUST_INT, i));
353 const auto &grf_names = GetGRFTownNameList();
354 for (uint i = 0; i < grf_names.size(); i++) {
359 size_t newgrf_size = list.size();
361 if (newgrf_size > 0) {
362 list.push_back(MakeDropDownListDividerItem());
368 list.push_back(MakeDropDownListStringItem(STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + i, i));
376 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, STR_TERRAIN_TYPE_CUSTOM};
377 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};
378 static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT};
379 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};
380 static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE};
381 static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM};
382 static const StringID _num_inds[] = {STR_FUNDING_ONLY, STR_MINIMAL, STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM};
383 static const StringID _variety[] = {STR_VARIETY_NONE, STR_VARIETY_VERY_LOW, STR_VARIETY_LOW, STR_VARIETY_MEDIUM, STR_VARIETY_HIGH, STR_VARIETY_VERY_HIGH};
385 static_assert(std::size(_num_inds) ==
ID_END);
419 void SetStringParameters(
WidgetID widget)
const override
430 if (_game_mode == GM_EDITOR) {
443 STR_MAPGEN_TOWN_NAME_ORIGINAL_ENGLISH + gen :
450 if (_game_mode == GM_EDITOR) {
462 SetDParam(0, STR_TERRAIN_TYPE_CUSTOM_VALUE);
471 SetDParam(0, STR_SEA_LEVEL_CUSTOM_PERCENTAGE);
506 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
508 if (!gui_scope)
return;
540 int climate_plane = 0;
542 case LT_TEMPERATE: climate_plane = 2;
break;
543 case LT_ARCTIC: climate_plane = 0;
break;
544 case LT_TROPIC: climate_plane = 1;
break;
545 case LT_TOYLAND: climate_plane = 2;
break;
577 std::span<const StringID> strs;
664 d.width += padding.width;
665 d.height += padding.height;
716 STR_WARNING_HEIGHTMAP_SCALE_CAPTION,
717 STR_WARNING_HEIGHTMAP_SCALE_MESSAGE,
719 LandscapeGenerationCallback);
721 StartGeneratingLandscape(mode);
809 uint32_t hidden_mask = 0;
879 void OnDropdownSelect(
WidgetID widget,
int index)
override
892 this->widget_id = widget;
908 this->widget_id = widget;
917 this->widget_id = widget;
927 this->widget_id = widget;
938 void OnQueryTextFinished(std::optional<std::string> str)
override
941 if (!str.has_value())
return;
945 value = atoi(str->c_str());
948 switch (this->widget_id) {
957 default: NOT_REACHED();
961 switch (this->widget_id) {
1084 void SetStringParameters(
WidgetID widget)
const override
1132 str = STR_JUST_DATE_LONG;
1148 d.width += padding.width;
1149 d.height += padding.height;
1153 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1223 void OnDropdownSelect(
WidgetID widget,
int index)
override
1232 void OnQueryTextFinished(std::optional<std::string> str)
override
1234 if (!str.has_value() || str->empty())
return;
1236 int32_t value = atoi(str->c_str());
1238 switch (this->widget_id) {
1254 static constexpr
NWidgetPart _nested_create_scenario_widgets[] = {
1317 _nested_create_scenario_widgets
1327 static constexpr
NWidgetPart _nested_generate_progress_widgets[] = {
1343 _nested_generate_progress_widgets
1351 std::chrono::steady_clock::time_point next_update;
1356 static const StringID _generation_class_table[] = {
1357 STR_GENERATION_WORLD_GENERATION,
1358 STR_GENERATION_LANDSCAPE_GENERATION,
1359 STR_GENERATION_RIVER_GENERATION,
1360 STR_GENERATION_CLEARING_TILES,
1361 STR_GENERATION_TOWN_GENERATION,
1362 STR_GENERATION_INDUSTRY_GENERATION,
1363 STR_GENERATION_OBJECT_GENERATION,
1364 STR_GENERATION_TREE_GENERATION,
1365 STR_GENERATION_SETTINGUP_GAME,
1366 STR_GENERATION_PREPARING_TILELOOP,
1367 STR_GENERATION_PREPARING_SCRIPT,
1368 STR_GENERATION_PREPARING_GAME
1370 static_assert(
lengthof(_generation_class_table) == GWP_CLASS_COUNT);
1373 static void AbortGeneratingWorldCallback(
Window *,
bool confirmed)
1389 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1395 STR_GENERATION_ABORT_CAPTION,
1396 STR_GENERATION_ABORT_MESSAGE,
1398 AbortGeneratingWorldCallback
1417 for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
1425 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1455 _gws.cls = STR_GENERATION_WORLD_GENERATION;
1459 _gws.next_update = std::chrono::steady_clock::now();
1471 static void _SetGeneratingWorldProgress(
GenWorldProgress cls, uint progress, uint total)
1473 static const int percent_table[] = {0, 5, 14, 17, 20, 40, 60, 65, 80, 85, 95, 99, 100 };
1474 static_assert(
lengthof(percent_table) == GWP_CLASS_COUNT + 1);
1475 assert(cls < GWP_CLASS_COUNT);
1489 assert(_gws.cls == _generation_class_table[cls]);
1490 _gws.current += progress;
1491 assert(_gws.current <= _gws.total);
1493 _gws.cls = _generation_class_table[cls];
1494 _gws.current = progress;
1496 _gws.percent = percent_table[cls];
1500 _gws.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_gws.current == 0 ? 0 : _gws.current - 1) / _gws.total;
1503 static uint last_percent = 0;
1506 if (_gws.percent == 0)
return;
1508 if (_gws.percent < last_percent) last_percent = 0;
1510 if (_gws.percent % 5 != 0 && _gws.percent <= last_percent + 5)
return;
1512 if (_gws.percent <= last_percent + 2)
return;
1514 Debug(net, 3,
"Map generation percentage complete: {}", _gws.percent);
1515 last_percent = _gws.percent;
1535 if (total == 0)
return;
1537 _SetGeneratingWorldProgress(cls, 0, total);
1550 _SetGeneratingWorldProgress(cls, 1, 0);