From c72d362840a4081cfcc27ab0807e42b5b6b4193f Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 21 Sep 2014 12:25:04 +0000 Subject: (svn r26885) -Feature-ish: user interface for limiting the maximum height of a map --- src/genworld_gui.cpp | 88 ++++++++++++++++++++++++++-------- src/lang/english.txt | 9 ++++ src/script/api/game/game_window.hpp.sq | 3 ++ src/script/api/script_window.hpp | 4 ++ src/settings_gui.cpp | 1 + src/table/settings.ini | 2 + src/terraform_cmd.cpp | 4 +- src/widgets/genworld_widget.h | 4 ++ 8 files changed, 92 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 55235fb35..649ad55ff 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -84,9 +84,9 @@ static const NWidgetPart _nested_generate_landscape_widgets[] = { NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_LAND_GENERATOR, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TERRAIN_TYPE, STR_NULL), SetFill(1, 1), + NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_VARIETY, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_SEA_LAKES, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TREE_PLACER, STR_NULL), SetFill(1, 1), - NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_VARIETY, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BORDER_TYPE, STR_NULL), SetFill(1, 1), EndContainer(), /* Widgets at the right of the labels. */ @@ -100,34 +100,41 @@ static const NWidgetPart _nested_generate_landscape_widgets[] = { NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_LANDSCAPE_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TERRAIN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), + NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_VARIETY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_WATER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TREE_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), - NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_VARIETY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_BORDERS_RANDOM), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), EndContainer(), EndContainer(), NWidget(NWID_VERTICAL), SetPIP(0, 4, 0), NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0), NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, 4, 0), - NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1), + NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAX_HEIGHTLEVEL, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_LINE_HEIGHT, STR_NULL), SetFill(1, 1), + NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SMOOTHNESS, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_NULL), SetFill(1, 1), EndContainer(), NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, 4, 0), - /* Starting date. */ + /* Max. heightlevel. */ NWidget(NWID_HORIZONTAL), - NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD), SetFill(0, 1), - NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL), SetFill(1, 0), - NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_UP), SetDataTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD), SetFill(0, 1), + NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_MAX_HEIGHTLEVEL_DOWN), SetFill(0, 1), + NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0), + NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_MAX_HEIGHTLEVEL_UP), SetFill(0, 1), EndContainer(), /* Snow line. */ NWidget(NWID_HORIZONTAL), NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_LINE_DOWN), SetFill(0, 1), - NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0), + NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0), NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_LINE_UP), SetFill(0, 1), EndContainer(), + /* Starting date. */ + NWidget(NWID_HORIZONTAL), + NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD), SetFill(0, 1), + NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL), SetFill(1, 0), + NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_UP), SetDataTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD), SetFill(0, 1), + EndContainer(), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_SMOOTHNESS_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), @@ -194,11 +201,11 @@ static const NWidgetPart _nested_heightmap_load_widgets[] = { NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, 4, 0), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_NAME, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAPSIZE, STR_NULL), SetFill(1, 1), + NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_ROTATION, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_TOWNS, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_NUMBER_OF_INDUSTRIES, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_QUANTITY_OF_RIVERS, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_TREE_PLACER, STR_NULL), SetFill(1, 1), - NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_ROTATION, STR_NULL), SetFill(1, 1), EndContainer(), /* Widgets at the right of the labels. */ NWidget(NWID_VERTICAL), SetPIP(0, 4, 0), @@ -211,31 +218,37 @@ static const NWidgetPart _nested_heightmap_load_widgets[] = { NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_BY, STR_NULL), SetPadding(1, 0, 0, 0), SetFill(1, 1), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_MAPSIZE_Y_PULLDOWN), SetDataTip(STR_JUST_INT, STR_NULL), SetFill(1, 0), EndContainer(), + NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TOWN_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_INDUSTRY_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_RIVER_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_TREE_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), - NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN), SetDataTip(STR_JUST_STRING, STR_NULL), SetFill(1, 0), EndContainer(), NWidget(NWID_VERTICAL), SetPIP(0, 4, 0), NWidget(NWID_HORIZONTAL), SetPIP(0, 3, 0), NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, 4, 0), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE_LABEL, STR_NULL), SetFill(1, 1), - NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1), NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_SNOW_LINE_HEIGHT, STR_NULL), SetFill(1, 1), + NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_MAX_HEIGHTLEVEL, STR_NULL), SetFill(1, 1), + NWidget(WWT_TEXT, COLOUR_ORANGE), SetDataTip(STR_MAPGEN_DATE, STR_NULL), SetFill(1, 1), EndContainer(), NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, 4, 0), NWidget(WWT_TEXT, COLOUR_ORANGE, WID_GL_HEIGHTMAP_SIZE_TEXT), SetDataTip(STR_MAPGEN_HEIGHTMAP_SIZE, STR_NULL), SetFill(1, 0), + NWidget(NWID_HORIZONTAL), + NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_LINE_DOWN), SetFill(0, 1), + NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0), + NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_LINE_UP), SetFill(0, 1), + EndContainer(), + NWidget(NWID_HORIZONTAL), + NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_MAX_HEIGHTLEVEL_DOWN), SetFill(0, 1), + NWidget(WWT_TEXTBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0), + NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_MAX_HEIGHTLEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_MAX_HEIGHTLEVEL_UP), SetFill(0, 1), + EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_BACKWARD), SetFill(0, 1), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_START_DATE_TEXT), SetDataTip(STR_BLACK_DATE_LONG, STR_NULL), SetFill(1, 0), NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_START_DATE_UP), SetDataTip(SPR_ARROW_UP, STR_SCENEDIT_TOOLBAR_TOOLTIP_MOVE_THE_STARTING_DATE_FORWARD), SetFill(0, 1), EndContainer(), - NWidget(NWID_HORIZONTAL), - NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_DOWN), SetDataTip(SPR_ARROW_DOWN, STR_MAPGEN_SNOW_LINE_DOWN), SetFill(0, 1), - NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_TEXT), SetDataTip(STR_BLACK_INT, STR_NULL), SetFill(1, 0), - NWidget(WWT_IMGBTN, COLOUR_ORANGE, WID_GL_SNOW_LEVEL_UP), SetDataTip(SPR_ARROW_UP, STR_MAPGEN_SNOW_LINE_UP), SetFill(0, 1), - EndContainer(), EndContainer(), EndContainer(), NWidget(NWID_SPACER), SetFill(1, 1), @@ -324,10 +337,11 @@ struct GenerateLandscapeWindow : public Window { virtual void SetStringParameters(int widget) const { switch (widget) { - case WID_GL_START_DATE_TEXT: SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); break; - case WID_GL_MAPSIZE_X_PULLDOWN: SetDParam(0, 1 << _settings_newgame.game_creation.map_x); break; - case WID_GL_MAPSIZE_Y_PULLDOWN: SetDParam(0, 1 << _settings_newgame.game_creation.map_y); break; - case WID_GL_SNOW_LEVEL_TEXT: SetDParam(0, _settings_newgame.game_creation.snow_line_height); break; + case WID_GL_START_DATE_TEXT: SetDParam(0, ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1)); break; + case WID_GL_MAPSIZE_X_PULLDOWN: SetDParam(0, 1 << _settings_newgame.game_creation.map_x); break; + case WID_GL_MAPSIZE_Y_PULLDOWN: SetDParam(0, 1 << _settings_newgame.game_creation.map_y); break; + case WID_GL_MAX_HEIGHTLEVEL_TEXT: SetDParam(0, _settings_newgame.construction.max_heightlevel); break; + case WID_GL_SNOW_LEVEL_TEXT: SetDParam(0, _settings_newgame.game_creation.snow_line_height); break; case WID_GL_TOWN_PULLDOWN: if (_game_mode == GM_EDITOR) { @@ -413,6 +427,8 @@ struct GenerateLandscapeWindow : public Window { this->SetWidgetDisabledState(WID_GL_SNOW_LEVEL_TEXT, _settings_newgame.game_creation.landscape != LT_ARCTIC); /* Update availability of decreasing / increasing start date and snow level */ + this->SetWidgetDisabledState(WID_GL_MAX_HEIGHTLEVEL_DOWN, _settings_newgame.construction.max_heightlevel <= MIN_MAX_HEIGHTLEVEL); + this->SetWidgetDisabledState(WID_GL_MAX_HEIGHTLEVEL_UP, _settings_newgame.construction.max_heightlevel >= MAX_MAX_HEIGHTLEVEL); this->SetWidgetDisabledState(WID_GL_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR); this->SetWidgetDisabledState(WID_GL_START_DATE_UP, _settings_newgame.game_creation.starting_year >= MAX_YEAR); this->SetWidgetDisabledState(WID_GL_SNOW_LEVEL_DOWN, _settings_newgame.game_creation.snow_line_height <= MIN_SNOWLINE_HEIGHT || _settings_newgame.game_creation.landscape != LT_ARCTIC); @@ -430,6 +446,11 @@ struct GenerateLandscapeWindow : public Window { { const StringID *strs = NULL; switch (widget) { + case WID_GL_MAX_HEIGHTLEVEL_TEXT: + SetDParam(0, MAX_TILE_HEIGHT); + *size = GetStringBoundingBox(STR_JUST_INT); + break; + case WID_GL_START_DATE_TEXT: SetDParam(0, ConvertYMDToDate(MAX_YEAR, 0, 1)); *size = maxdim(*size, GetStringBoundingBox(STR_BLACK_DATE_LONG)); @@ -562,6 +583,25 @@ struct GenerateLandscapeWindow : public Window { break; } + case WID_GL_MAX_HEIGHTLEVEL_DOWN: + case WID_GL_MAX_HEIGHTLEVEL_UP: // Height level buttons + /* Don't allow too fast scrolling */ + if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) { + this->HandleButtonClick(widget); + + _settings_newgame.construction.max_heightlevel = Clamp(_settings_newgame.construction.max_heightlevel + widget - WID_GL_MAX_HEIGHTLEVEL_TEXT, MIN_MAX_HEIGHTLEVEL, MAX_MAX_HEIGHTLEVEL); + this->InvalidateData(); + } + _left_button_clicked = false; + break; + + case WID_GL_MAX_HEIGHTLEVEL_TEXT: // Height level text + this->widget_id = WID_GL_MAX_HEIGHTLEVEL_TEXT; + SetDParam(0, _settings_newgame.construction.max_heightlevel); + ShowQueryString(STR_JUST_INT, STR_MAPGEN_MAX_HEIGHTLEVEL_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT); + break; + + case WID_GL_START_DATE_DOWN: case WID_GL_START_DATE_UP: // Year buttons /* Don't allow too fast scrolling */ @@ -666,7 +706,7 @@ struct GenerateLandscapeWindow : public Window { virtual void OnTimeout() { - static const int raise_widgets[] = {WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_LEVEL_UP, WID_GL_SNOW_LEVEL_DOWN, WIDGET_LIST_END}; + static const int raise_widgets[] = {WID_GL_MAX_HEIGHTLEVEL_DOWN, WID_GL_MAX_HEIGHTLEVEL_UP, WID_GL_START_DATE_DOWN, WID_GL_START_DATE_UP, WID_GL_SNOW_LEVEL_UP, WID_GL_SNOW_LEVEL_DOWN, WIDGET_LIST_END}; for (const int *widget = raise_widgets; *widget != WIDGET_LIST_END; widget++) { if (this->IsWidgetLowered(*widget)) { this->RaiseWidget(*widget); @@ -735,6 +775,7 @@ struct GenerateLandscapeWindow : public Window { } else { /* An empty string means revert to the default */ switch (this->widget_id) { + case WID_GL_MAX_HEIGHTLEVEL_TEXT: value = DEF_MAX_HEIGHTLEVEL; break; case WID_GL_START_DATE_TEXT: value = DEF_START_YEAR; break; case WID_GL_SNOW_LEVEL_TEXT: value = DEF_SNOWLINE_HEIGHT; break; case WID_GL_TOWN_PULLDOWN: value = 1; break; @@ -744,6 +785,11 @@ struct GenerateLandscapeWindow : public Window { } switch (this->widget_id) { + case WID_GL_MAX_HEIGHTLEVEL_TEXT: + this->SetWidgetDirty(WID_GL_MAX_HEIGHTLEVEL_TEXT); + _settings_newgame.construction.max_heightlevel = Clamp(value, MIN_MAX_HEIGHTLEVEL, MAX_MAX_HEIGHTLEVEL); + break; + case WID_GL_START_DATE_TEXT: this->SetWidgetDirty(WID_GL_START_DATE_TEXT); _settings_newgame.game_creation.starting_year = Clamp(value, MIN_YEAR, MAX_YEAR); diff --git a/src/lang/english.txt b/src/lang/english.txt index e095edfe1..a1b57d1c3 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1158,6 +1158,9 @@ STR_CONFIG_SETTING_DISASTERS_HELPTEXT :Toggle disaster STR_CONFIG_SETTING_CITY_APPROVAL :Town council's attitude towards area restructuring: {STRING2} STR_CONFIG_SETTING_CITY_APPROVAL_HELPTEXT :Choose how much noise and environmental damage by companies affect their town rating and further construction actions in their area +STR_CONFIG_SETTING_MAX_HEIGHTLEVEL :Maximum map height: {STRING2} +STR_CONFIG_SETTING_MAX_HEIGHTLEVEL_HELPTEXT :Set the maximum allowed height for mountains on the map +STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN :{WHITE}You can't set the maximum map height to this value. At least one mountain on the map is higher STR_CONFIG_SETTING_AUTOSLOPE :Allow landscaping under buildings, tracks, etc.: {STRING2} STR_CONFIG_SETTING_AUTOSLOPE_HELPTEXT :Allow landscaping under buildings and tracks without removing them STR_CONFIG_SETTING_CATCHMENT :Allow more realistically sized catchment areas: {STRING2} @@ -1788,6 +1791,8 @@ STR_CHEAT_CHANGE_COMPANY :{LTBLUE}Playing STR_CHEAT_EXTRA_DYNAMITE :{LTBLUE}Magic bulldozer (remove industries, unmovable objects): {ORANGE}{STRING1} STR_CHEAT_CROSSINGTUNNELS :{LTBLUE}Tunnels may cross each other: {ORANGE}{STRING1} STR_CHEAT_NO_JETCRASH :{LTBLUE}Jetplanes will not crash (frequently) on small airports: {ORANGE}{STRING} +STR_CHEAT_EDIT_MAX_HL :{LTBLUE}Edit the maximum map height: {ORANGE}{NUM} +STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT :{WHITE}Edit the maximum height of mountains on the map STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE :Temperate landscape STR_CHEAT_SWITCH_CLIMATE_SUB_ARCTIC_LANDSCAPE :Sub-arctic landscape STR_CHEAT_SWITCH_CLIMATE_SUB_TROPICAL_LANDSCAPE :Sub-tropical landscape @@ -2713,6 +2718,9 @@ STR_MAPGEN_BY :{BLACK}* STR_MAPGEN_NUMBER_OF_TOWNS :{BLACK}No. of towns: STR_MAPGEN_DATE :{BLACK}Date: STR_MAPGEN_NUMBER_OF_INDUSTRIES :{BLACK}No. of industries: +STR_MAPGEN_MAX_HEIGHTLEVEL :{BLACK}Maximum map height: +STR_MAPGEN_MAX_HEIGHTLEVEL_UP :{BLACK}Increase the maximum height of mountains on the map by one +STR_MAPGEN_MAX_HEIGHTLEVEL_DOWN :{BLACK}Decrease the maximum height of mountains on the map by one STR_MAPGEN_SNOW_LINE_HEIGHT :{BLACK}Snow line height: STR_MAPGEN_SNOW_LINE_UP :{BLACK}Move the snow line height one up STR_MAPGEN_SNOW_LINE_DOWN :{BLACK}Move the snow line height one down @@ -2742,6 +2750,7 @@ STR_MAPGEN_HEIGHTMAP_NAME :{BLACK}Heightma STR_MAPGEN_HEIGHTMAP_SIZE_LABEL :{BLACK}Size: STR_MAPGEN_HEIGHTMAP_SIZE :{ORANGE}{NUM} x {NUM} +STR_MAPGEN_MAX_HEIGHTLEVEL_QUERY_CAPT :{WHITE}Change maximum map height STR_MAPGEN_SNOW_LINE_QUERY_CAPT :{WHITE}Change snow line height STR_MAPGEN_START_DATE_QUERY_CAPT :{WHITE}Change starting year diff --git a/src/script/api/game/game_window.hpp.sq b/src/script/api/game/game_window.hpp.sq index 084dd77e2..80b43c08b 100644 --- a/src/script/api/game/game_window.hpp.sq +++ b/src/script/api/game/game_window.hpp.sq @@ -461,6 +461,9 @@ void SQGSWindow_Register(Squirrel *engine) SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_TOWN_PULLDOWN, "WID_GL_TOWN_PULLDOWN"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_INDUSTRY_PULLDOWN, "WID_GL_INDUSTRY_PULLDOWN"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_GENERATE_BUTTON, "WID_GL_GENERATE_BUTTON"); + SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_MAX_HEIGHTLEVEL_DOWN, "WID_GL_MAX_HEIGHTLEVEL_DOWN"); + SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_MAX_HEIGHTLEVEL_TEXT, "WID_GL_MAX_HEIGHTLEVEL_TEXT"); + SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_MAX_HEIGHTLEVEL_UP, "WID_GL_MAX_HEIGHTLEVEL_UP"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_START_DATE_DOWN, "WID_GL_START_DATE_DOWN"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_START_DATE_TEXT, "WID_GL_START_DATE_TEXT"); SQGSWindow.DefSQConst(engine, ScriptWindow::WID_GL_START_DATE_UP, "WID_GL_START_DATE_UP"); diff --git a/src/script/api/script_window.hpp b/src/script/api/script_window.hpp index 099d90fb2..f9d659108 100644 --- a/src/script/api/script_window.hpp +++ b/src/script/api/script_window.hpp @@ -1293,6 +1293,10 @@ public: WID_GL_GENERATE_BUTTON = ::WID_GL_GENERATE_BUTTON, ///< 'Generate' button. + WID_GL_MAX_HEIGHTLEVEL_DOWN = ::WID_GL_MAX_HEIGHTLEVEL_DOWN, ///< Decrease max. heightlevel + WID_GL_MAX_HEIGHTLEVEL_TEXT = ::WID_GL_MAX_HEIGHTLEVEL_TEXT, ///< Max. heightlevel + WID_GL_MAX_HEIGHTLEVEL_UP = ::WID_GL_MAX_HEIGHTLEVEL_UP, ///< Increase max. heightlevel + WID_GL_START_DATE_DOWN = ::WID_GL_START_DATE_DOWN, ///< Decrease start year. WID_GL_START_DATE_TEXT = ::WID_GL_START_DATE_TEXT, ///< Start year. WID_GL_START_DATE_UP = ::WID_GL_START_DATE_UP, ///< Increase start year. diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index bd8eb91ca..799edf73d 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1499,6 +1499,7 @@ static SettingsContainer &GetSettingsTree() SettingsPage *construction = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_CONSTRUCTION)); { construction->Add(new SettingEntry("gui.link_terraform_toolbar")); + construction->Add(new SettingEntry("construction.max_heightlevel")); construction->Add(new SettingEntry("gui.enable_signal_gui")); construction->Add(new SettingEntry("gui.persistent_buildingtools")); construction->Add(new SettingEntry("gui.quick_goto")); diff --git a/src/table/settings.ini b/src/table/settings.ini index a2d6841fd..ad59eb30a 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -387,6 +387,8 @@ def = DEF_MAX_HEIGHTLEVEL min = MIN_MAX_HEIGHTLEVEL max = MAX_MAX_HEIGHTLEVEL interval = 1 +str = STR_CONFIG_SETTING_MAX_HEIGHTLEVEL +strhelp = STR_CONFIG_SETTING_MAX_HEIGHTLEVEL_HELPTEXT strval = STR_JUST_INT cat = SC_BASIC diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index 82554d43e..2d36a101e 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -106,7 +106,7 @@ static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int /* Check range of destination height */ if (height < 0) return_cmd_error(STR_ERROR_ALREADY_AT_SEA_LEVEL); - if (height > (int)MAX_TILE_HEIGHT) return_cmd_error(STR_ERROR_TOO_HIGH); + if (height > _settings_game.construction.max_heightlevel) return_cmd_error(STR_ERROR_TOO_HIGH); /* * Check if the terraforming has any effect. @@ -360,7 +360,7 @@ CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 } /* Check range of destination height */ - if (h > MAX_TILE_HEIGHT) return_cmd_error((oldh == 0) ? STR_ERROR_ALREADY_AT_SEA_LEVEL : STR_ERROR_TOO_HIGH); + if (h > _settings_game.construction.max_heightlevel) return_cmd_error((oldh == 0) ? STR_ERROR_ALREADY_AT_SEA_LEVEL : STR_ERROR_TOO_HIGH); Money money = GetAvailableMoneyForCommand(); CommandCost cost(EXPENSES_CONSTRUCTION); diff --git a/src/widgets/genworld_widget.h b/src/widgets/genworld_widget.h index 2048851ff..877efbb92 100644 --- a/src/widgets/genworld_widget.h +++ b/src/widgets/genworld_widget.h @@ -27,6 +27,10 @@ enum GenerateLandscapeWidgets { WID_GL_GENERATE_BUTTON, ///< 'Generate' button. + WID_GL_MAX_HEIGHTLEVEL_DOWN, ///< Decrease max. heightlevel + WID_GL_MAX_HEIGHTLEVEL_TEXT, ///< Max. heightlevel + WID_GL_MAX_HEIGHTLEVEL_UP, ///< Increase max. heightlevel + WID_GL_START_DATE_DOWN, ///< Decrease start year. WID_GL_START_DATE_TEXT, ///< Start year. WID_GL_START_DATE_UP, ///< Increase start year. -- cgit v1.2.3-70-g09d2