37 extern void MakeNewgameSettingsLive();
96 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_BY, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(1, 1),
150 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_NORTHWEST, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(0, 1),
155 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_NORTHEAST, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(0, 1),
162 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_SOUTHWEST, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(0, 1),
167 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_SOUTHEAST, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(0, 1),
216 NWidget(
WWT_TEXT, COLOUR_ORANGE),
SetDataTip(STR_MAPGEN_BY, STR_NULL),
SetPadding(1, 0, 0, 0),
SetFill(1, 1),
267 MakeNewgameSettingsLive();
275 default: NOT_REACHED();
279 static void LandscapeGenerationCallback(
Window *w,
bool confirmed)
290 item->SetParam(0, 1 << i);
297 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};
298 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};
299 static const StringID _rivers[] = {STR_RIVERS_NONE, STR_RIVERS_FEW, STR_RIVERS_MODERATE, STR_RIVERS_LOT,
INVALID_STRING_ID};
300 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};
301 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};
302 static const StringID _rotation[] = {STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_COUNTER_CLOCKWISE, STR_CONFIG_SETTING_HEIGHTMAP_ROTATION_CLOCKWISE,
INVALID_STRING_ID};
303 static const StringID _landscape[] = {STR_CONFIG_SETTING_LAND_GENERATOR_ORIGINAL, STR_CONFIG_SETTING_LAND_GENERATOR_TERRA_GENESIS,
INVALID_STRING_ID};
304 static const StringID _num_towns[] = {STR_NUM_VERY_LOW, STR_NUM_LOW, STR_NUM_NORMAL, STR_NUM_HIGH, STR_NUM_CUSTOM,
INVALID_STRING_ID};
305 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};
306 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};
344 if (_game_mode == GM_EDITOR) {
361 SetDParam(0, STR_SEA_LEVEL_CUSTOM_PERCENTAGE);
397 if (!gui_scope)
return;
516 size->width += padding.width;
524 DrawString(r.left, r.right, r.top, this->name, TC_ORANGE);
573 STR_WARNING_HEIGHTMAP_SCALE_CAPTION,
574 STR_WARNING_HEIGHTMAP_SCALE_MESSAGE,
576 LandscapeGenerationCallback);
578 StartGeneratingLandscape(mode);
656 uint32 hidden_mask = 0;
708 for (
const int *widget = raise_widgets; *widget !=
WIDGET_LIST_END; widget++) {
737 this->widget_id = widget;
749 this->widget_id = widget;
763 if (str == NULL)
return;
770 switch (this->widget_id) {
776 default: NOT_REACHED();
780 switch (this->widget_id) {
813 _nested_generate_landscape_widgets,
lengthof(_nested_generate_landscape_widgets)
820 _nested_heightmap_load_widgets,
lengthof(_nested_heightmap_load_widgets)
932 str = STR_BLACK_DATE_LONG;
948 size->width += padding.width;
949 size->height += padding.height;
1020 for (
const int *widget = raise_widgets; *widget !=
WIDGET_LIST_END; widget++) {
1040 int32 value = atoi(str);
1042 switch (this->widget_id) {
1059 static const NWidgetPart _nested_create_scenario_widgets[] = {
1115 _nested_create_scenario_widgets,
lengthof(_nested_create_scenario_widgets)
1125 static const NWidgetPart _nested_generate_progress_widgets[] = {
1143 _nested_generate_progress_widgets,
lengthof(_nested_generate_progress_widgets)
1156 static const StringID _generation_class_table[] = {
1157 STR_GENERATION_WORLD_GENERATION,
1158 STR_SCENEDIT_TOOLBAR_LANDSCAPE_GENERATION,
1159 STR_GENERATION_RIVER_GENERATION,
1160 STR_GENERATION_CLEARING_TILES,
1161 STR_SCENEDIT_TOOLBAR_TOWN_GENERATION,
1162 STR_SCENEDIT_TOOLBAR_INDUSTRY_GENERATION,
1163 STR_GENERATION_OBJECT_GENERATION,
1164 STR_GENERATION_TREE_GENERATION,
1165 STR_GENERATION_SETTINGUP_GAME,
1166 STR_GENERATION_PREPARING_TILELOOP,
1167 STR_GENERATION_PREPARING_SCRIPT,
1168 STR_GENERATION_PREPARING_GAME
1170 assert_compile(
lengthof(_generation_class_table) == GWP_CLASS_COUNT);
1173 static void AbortGeneratingWorldCallback(
Window *w,
bool confirmed)
1195 STR_GENERATION_ABORT_CAPTION,
1196 STR_GENERATION_ABORT_MESSAGE,
1198 AbortGeneratingWorldCallback
1217 for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
1231 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);
1253 _gws.cls = STR_GENERATION_WORLD_GENERATION;
1269 static void _SetGeneratingWorldProgress(
GenWorldProgress cls, uint progress, uint total)
1271 static const int percent_table[] = {0, 5, 14, 17, 20, 40, 60, 65, 80, 85, 95, 99, 100 };
1272 assert_compile(
lengthof(percent_table) == GWP_CLASS_COUNT + 1);
1273 assert(cls < GWP_CLASS_COUNT);
1281 assert(_gws.cls == _generation_class_table[cls]);
1282 _gws.current += progress;
1283 assert(_gws.current <= _gws.total);
1285 _gws.cls = _generation_class_table[cls];
1286 _gws.current = progress;
1288 _gws.percent = percent_table[cls];
1295 _gws.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_gws.current == 0 ? 0 : _gws.current - 1) / _gws.total;
1298 static uint last_percent = 0;
1301 if (_gws.percent == 0)
return;
1303 if (_gws.percent < last_percent) last_percent = 0;
1305 if (_gws.percent % 5 != 0 && _gws.percent <= last_percent + 5)
return;
1307 if (_gws.percent <= last_percent + 2)
return;
1309 DEBUG(net, 1,
"Map generation percentage complete: %d", _gws.percent);
1310 last_percent = _gws.percent;
1341 if (total == 0)
return;
1343 _SetGeneratingWorldProgress(cls, 0, total);
1356 _SetGeneratingWorldProgress(cls, 1, 0);