diff --git a/src/openrct2-ui/interface/Objective.cpp b/src/openrct2-ui/interface/Objective.cpp new file mode 100644 index 0000000000..0e48b81c95 --- /dev/null +++ b/src/openrct2-ui/interface/Objective.cpp @@ -0,0 +1,53 @@ +/***************************************************************************** + * Copyright (c) 2014-2024 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#include "Objective.h" + +#include +#include +#include +#include +#include +#include + +void formatObjective(Formatter& ft, Objective objective) +{ + if (objective.Type == OBJECTIVE_BUILD_THE_BEST) + { + StringId rideTypeString = STR_NONE; + auto rideTypeId = objective.RideId; + if (rideTypeId != RIDE_TYPE_NULL && rideTypeId < RIDE_TYPE_COUNT) + { + rideTypeString = GetRideTypeDescriptor(rideTypeId).Naming.Name; + } + ft.Add(rideTypeString); + } + else if (objective.Type == OBJECTIVE_GUESTS_BY) + { + ft.Add(objective.NumGuests); + ft.Add(DateGetTotalMonths(MONTH_OCTOBER, objective.Year)); + } + else if (objective.Type == OBJECTIVE_GUESTS_AND_RATING) + { + ft.Add(objective.NumGuests); + } + else if (objective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH) + { + ft.Add(objective.MinimumLength); + } + else + { + ft.Add(objective.NumGuests); + ft.Add(DateGetTotalMonths(MONTH_OCTOBER, objective.Year)); + if (objective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS) + ft.Add(objective.MinimumExcitement); + else + ft.Add(objective.Currency); + } +} diff --git a/src/openrct2-ui/interface/Objective.h b/src/openrct2-ui/interface/Objective.h new file mode 100644 index 0000000000..d7cf2da51f --- /dev/null +++ b/src/openrct2-ui/interface/Objective.h @@ -0,0 +1,17 @@ +/***************************************************************************** + * Copyright (c) 2014-2024 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include + +class Formatter; +struct Objective; + +void formatObjective(Formatter& ft, Objective objective); diff --git a/src/openrct2-ui/libopenrct2ui.vcxproj b/src/openrct2-ui/libopenrct2ui.vcxproj index 0ab8e83b43..986e72712f 100644 --- a/src/openrct2-ui/libopenrct2ui.vcxproj +++ b/src/openrct2-ui/libopenrct2ui.vcxproj @@ -69,6 +69,7 @@ + @@ -129,6 +130,7 @@ + @@ -248,4 +250,4 @@ - \ No newline at end of file + diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index 17d79524db..99e23e55e0 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -1092,38 +1093,7 @@ static constexpr WindowParkAward _parkAwards[] = { // Objective ft = Formatter(); - if (gameState.ScenarioObjective.Type == OBJECTIVE_BUILD_THE_BEST) - { - StringId rideTypeString = STR_NONE; - auto rideTypeId = gameState.ScenarioObjective.RideId; - if (rideTypeId != RIDE_TYPE_NULL && rideTypeId < RIDE_TYPE_COUNT) - { - rideTypeString = GetRideTypeDescriptor(rideTypeId).Naming.Name; - } - ft.Add(rideTypeString); - } - else if (gameState.ScenarioObjective.Type == OBJECTIVE_GUESTS_BY) - { - ft.Add(gameState.ScenarioObjective.NumGuests); - ft.Add(DateGetTotalMonths(MONTH_OCTOBER, gameState.ScenarioObjective.Year)); - } - else if (gameState.ScenarioObjective.Type == OBJECTIVE_GUESTS_AND_RATING) - { - ft.Add(gameState.ScenarioObjective.NumGuests); - } - else if (gameState.ScenarioObjective.Type == OBJECTIVE_10_ROLLERCOASTERS_LENGTH) - { - ft.Add(gameState.ScenarioObjective.MinimumLength); - } - else - { - ft.Add(0); // Unused value by other objective messages - ft.Add(DateGetTotalMonths(MONTH_OCTOBER, gameState.ScenarioObjective.Year)); - if (gameState.ScenarioObjective.Type == OBJECTIVE_FINISH_5_ROLLERCOASTERS) - ft.Add(gameState.ScenarioObjective.MinimumExcitement); - else - ft.Add(gameState.ScenarioObjective.Currency); - } + formatObjective(ft, gameState.ScenarioObjective); screenCoords.y += DrawTextWrapped(dpi, screenCoords, 221, ObjectiveNames[gameState.ScenarioObjective.Type], ft); screenCoords.y += 5; diff --git a/src/openrct2-ui/windows/ScenarioSelect.cpp b/src/openrct2-ui/windows/ScenarioSelect.cpp index 8996b3faf2..d40760ae41 100644 --- a/src/openrct2-ui/windows/ScenarioSelect.cpp +++ b/src/openrct2-ui/windows/ScenarioSelect.cpp @@ -9,6 +9,7 @@ #include "../interface/Theme.h" +#include #include #include #include @@ -244,27 +245,14 @@ static Widget _scenarioSelectWidgets[] = { screenPos.y += DrawTextWrapped(dpi, screenPos, 170, STR_BLACK_STRING, ft) + 5; // Scenario objective + Objective objective = { .Type = scenario->ObjectiveType, + .Year = scenario->ObjectiveArg1, + .NumGuests = static_cast(scenario->ObjectiveArg3), + .Currency = scenario->ObjectiveArg2 }; + ft = Formatter(); ft.Add(ObjectiveNames[scenario->ObjectiveType]); - if (scenario->ObjectiveType == OBJECTIVE_BUILD_THE_BEST) - { - StringId rideTypeString = STR_NONE; - auto rideTypeId = scenario->ObjectiveArg3; - if (rideTypeId != RIDE_TYPE_NULL && rideTypeId < RIDE_TYPE_COUNT) - { - rideTypeString = GetRideTypeDescriptor(rideTypeId).Naming.Name; - } - ft.Add(rideTypeString); - } - else - { - ft.Add(scenario->ObjectiveArg3); - ft.Add(DateGetTotalMonths(MONTH_OCTOBER, scenario->ObjectiveArg1)); - if (scenario->ObjectiveType == OBJECTIVE_FINISH_5_ROLLERCOASTERS) - ft.Add(scenario->ObjectiveArg2); - else - ft.Add(scenario->ObjectiveArg2); - } + formatObjective(ft, objective); screenPos.y += DrawTextWrapped(dpi, screenPos, 170, STR_OBJECTIVE, ft) + 5; // Scenario score