Always enable public roads button in scenario editor

This commit is contained in:
Jonathan G Rennison 2024-09-09 17:25:50 +01:00
parent 0badb27b7c
commit 8e0a1fa8ae
6 changed files with 14 additions and 20 deletions

View File

@ -46,7 +46,7 @@ void GenerateClearTile();
void GenerateIndustries(); void GenerateIndustries();
void GenerateObjects(); void GenerateObjects();
void GenerateTrees(); void GenerateTrees();
void GeneratePublicRoads(); extern void GeneratePublicRoads(PublicRoadsConstruction build_mode);
void StartupEconomy(); void StartupEconomy();
void StartupCompanies(); void StartupCompanies();
@ -157,7 +157,7 @@ static void _GenerateWorld()
GenerateIndustries(); GenerateIndustries();
GenerateObjects(); GenerateObjects();
GenerateTrees(); GenerateTrees();
GeneratePublicRoads(); GeneratePublicRoads(_settings_game.game_creation.build_public_roads);
} }
} }

View File

@ -309,6 +309,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint3
static RoadType _public_road_type; static RoadType _public_road_type;
static const uint _public_road_hash_size = 8U; ///< The number of bits the hash for river finding should have. static const uint _public_road_hash_size = 8U; ///< The number of bits the hash for river finding should have.
static PublicRoadsConstruction _public_road_mode = PRC_NONE;
/** Helper function to check if a slope along a certain direction is going up an inclined slope. */ /** Helper function to check if a slope along a certain direction is going up an inclined slope. */
static bool IsUpwardsSlope(const Slope slope, DiagDirection road_direction) static bool IsUpwardsSlope(const Slope slope, DiagDirection road_direction)
@ -893,7 +894,7 @@ static int32_t PublicRoad_CalculateG(AyStar *, AyStarNode *current, OpenListNode
} }
} }
if (_settings_game.game_creation.build_public_roads == PRC_AVOID_CURVES && if (_public_road_mode == PRC_AVOID_CURVES &&
parent->path.parent != nullptr && parent->path.parent != nullptr &&
DiagdirBetweenTiles(parent->path.parent->node.tile, parent->path.node.tile) != DiagdirBetweenTiles(parent->path.node.tile, current->tile)) { DiagdirBetweenTiles(parent->path.parent->node.tile, parent->path.node.tile) != DiagdirBetweenTiles(parent->path.node.tile, current->tile)) {
cost += 1; cost += 1;
@ -977,9 +978,11 @@ void PostProcessNetworks(AyStar &finder, const std::vector<std::unique_ptr<TownN
/** /**
* Build the public road network connecting towns using AyStar. * Build the public road network connecting towns using AyStar.
*/ */
void GeneratePublicRoads() void GeneratePublicRoads(PublicRoadsConstruction build_mode)
{ {
if (_settings_game.game_creation.build_public_roads == PRC_NONE) return; if (build_mode == PRC_NONE) return;
_public_road_mode = build_mode;
std::vector<TileIndex> towns; std::vector<TileIndex> towns;
towns.clear(); towns.clear();

View File

@ -1775,10 +1775,6 @@ static void ChangeTrackTypeSortMode(int32_t new_value) {
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
static void PublicRoadsSettingChange(int32_t new_value) {
InvalidateWindowClassesData(WC_SCEN_LAND_GEN);
}
static void TrainSpeedAdaptationChanged(int32_t new_value) { static void TrainSpeedAdaptationChanged(int32_t new_value) {
extern void ClearAllSignalSpeedRestrictions(); extern void ClearAllSignalSpeedRestrictions();
ClearAllSignalSpeedRestrictions(); ClearAllSignalSpeedRestrictions();

View File

@ -16,7 +16,6 @@ static void UpdateFreeformEdges(int32_t new_value);
static bool CheckMapEdgeMode(int32_t &new_value); static bool CheckMapEdgeMode(int32_t &new_value);
static void MapEdgeModeChanged(int32_t new_value); static void MapEdgeModeChanged(int32_t new_value);
static void ClimateThresholdModeChanged(int32_t new_value); static void ClimateThresholdModeChanged(int32_t new_value);
static void PublicRoadsSettingChange(int32_t new_value);
static void MarkAllViewportsDirty(int32_t new_value); static void MarkAllViewportsDirty(int32_t new_value);
static bool AllowRoadStopsUnderBridgesSettingGUI(SettingOnGuiCtrlData &data); static bool AllowRoadStopsUnderBridgesSettingGUI(SettingOnGuiCtrlData &data);
@ -500,7 +499,6 @@ max = PRC_END - 1
str = STR_CONFIG_SETTING_BUILD_PUBLIC_ROADS str = STR_CONFIG_SETTING_BUILD_PUBLIC_ROADS
strhelp = STR_CONFIG_SETTING_BUILD_PUBLIC_ROADS_HELPTEXT strhelp = STR_CONFIG_SETTING_BUILD_PUBLIC_ROADS_HELPTEXT
strval = STR_CONFIG_SETTING_BUILD_PUBLIC_ROADS_NONE strval = STR_CONFIG_SETTING_BUILD_PUBLIC_ROADS_NONE
post_cb = PublicRoadsSettingChange
patxname = ""public_roads.game_creation.build_public_roads"" patxname = ""public_roads.game_creation.build_public_roads""
[SDT_VAR] [SDT_VAR]

View File

@ -563,10 +563,8 @@ static constexpr NWidgetPart _nested_scen_edit_land_gen_widgets[] = {
SetFill(1, 0), SetDataTip(STR_TERRAFORM_SE_NEW_WORLD, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetPadding(0, 2, 0, 2), SetFill(1, 0), SetDataTip(STR_TERRAFORM_SE_NEW_WORLD, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetPadding(0, 2, 0, 2),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_ETT_RESET_LANDSCAPE), SetMinimalSize(160, 12), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_ETT_RESET_LANDSCAPE), SetMinimalSize(160, 12),
SetFill(1, 0), SetDataTip(STR_TERRAFORM_RESET_LANDSCAPE, STR_TERRAFORM_RESET_LANDSCAPE_TOOLTIP), SetPadding(1, 2, 0, 2), SetFill(1, 0), SetDataTip(STR_TERRAFORM_RESET_LANDSCAPE, STR_TERRAFORM_RESET_LANDSCAPE_TOOLTIP), SetPadding(1, 2, 0, 2),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_ETT_SHOW_PUBLIC_ROADS), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_ETT_PUBLIC_ROADS), SetMinimalSize(160, 12),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_ETT_PUBLIC_ROADS), SetMinimalSize(160, 12), SetFill(1, 0), SetDataTip(STR_TERRAFORM_PUBLIC_ROADS, STR_TERRAFORM_PUBLIC_ROADS_TOOLTIP), SetPadding(1, 2, 0, 2),
SetFill(1, 0), SetDataTip(STR_TERRAFORM_PUBLIC_ROADS, STR_TERRAFORM_PUBLIC_ROADS_TOOLTIP), SetPadding(1, 2, 0, 2),
EndContainer(),
NWidget(NWID_SPACER), SetMinimalSize(0, 2), NWidget(NWID_SPACER), SetMinimalSize(0, 2),
EndContainer(), EndContainer(),
}; };
@ -713,8 +711,10 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
break; break;
case WID_ETT_PUBLIC_ROADS: { // Build public roads case WID_ETT_PUBLIC_ROADS: { // Build public roads
extern void GeneratePublicRoads(); extern void GeneratePublicRoads(PublicRoadsConstruction build_mode);
GeneratePublicRoads(); PublicRoadsConstruction build_mode = _settings_game.game_creation.build_public_roads;
if (build_mode == PRC_NONE) build_mode = PRC_WITH_CURVES;
GeneratePublicRoads(build_mode);
break; break;
} }
@ -807,8 +807,6 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
{ {
NWidgetStacked *show_desert = this->GetWidget<NWidgetStacked>(WID_ETT_SHOW_PLACE_DESERT); NWidgetStacked *show_desert = this->GetWidget<NWidgetStacked>(WID_ETT_SHOW_PLACE_DESERT);
show_desert->SetDisplayedPlane(_settings_game.game_creation.landscape == LT_TROPIC ? 0 : SZSP_NONE); show_desert->SetDisplayedPlane(_settings_game.game_creation.landscape == LT_TROPIC ? 0 : SZSP_NONE);
NWidgetStacked *show_public_roads = this->GetWidget<NWidgetStacked>(WID_ETT_SHOW_PUBLIC_ROADS);
show_public_roads->SetDisplayedPlane(_settings_game.game_creation.build_public_roads != 0 ? 0 : SZSP_NONE);
} }
static HotkeyList hotkeys; static HotkeyList hotkeys;

View File

@ -30,7 +30,6 @@ enum TerraformToolbarWidgets : WidgetID {
/** Widgets of the #ScenarioEditorLandscapeGenerationWindow class. */ /** Widgets of the #ScenarioEditorLandscapeGenerationWindow class. */
enum EditorTerraformToolbarWidgets : WidgetID { enum EditorTerraformToolbarWidgets : WidgetID {
WID_ETT_SHOW_PLACE_DESERT, ///< Should the place desert button be shown? WID_ETT_SHOW_PLACE_DESERT, ///< Should the place desert button be shown?
WID_ETT_SHOW_PUBLIC_ROADS, ///< Should the public roads button be shown?
WID_ETT_START, ///< Used for iterations. WID_ETT_START, ///< Used for iterations.
WID_ETT_DOTS = WID_ETT_START, ///< Invisible widget for rendering the terraform size on. WID_ETT_DOTS = WID_ETT_START, ///< Invisible widget for rendering the terraform size on.
WID_ETT_BUTTONS_START, ///< Start of pushable buttons. WID_ETT_BUTTONS_START, ///< Start of pushable buttons.