mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 09:32:29 +01:00
Create strong enum for ScenarioSelectMode
This commit is contained in:
@@ -1800,7 +1800,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{ windowPos.x + widget->left, windowPos.y + widget->top }, widget->height() + 1, colours[1], 0,
|
||||
Dropdown::Flag::StayOpen, numItems, widget->width() - 3);
|
||||
|
||||
Dropdown::SetChecked(Config::Get().general.ScenarioSelectMode, true);
|
||||
Dropdown::SetChecked(EnumValue(Config::Get().general.scenarioSelectMode), true);
|
||||
break;
|
||||
}
|
||||
case WIDX_DEFAULT_INSPECTION_INTERVAL_DROPDOWN:
|
||||
@@ -1847,9 +1847,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
break;
|
||||
case WIDX_SCENARIO_GROUPING_DROPDOWN:
|
||||
if (dropdownIndex != Config::Get().general.ScenarioSelectMode)
|
||||
if (dropdownIndex != EnumValue(Config::Get().general.scenarioSelectMode))
|
||||
{
|
||||
Config::Get().general.ScenarioSelectMode = dropdownIndex;
|
||||
Config::Get().general.scenarioSelectMode = static_cast<ScenarioSelectMode>(dropdownIndex);
|
||||
Config::Get().interface.ScenarioselectLastTab = 0;
|
||||
Config::Save();
|
||||
Invalidate();
|
||||
@@ -1898,14 +1898,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
SetCheckboxValue(WIDX_AUTO_OPEN_SHOPS, Config::Get().general.AutoOpenShops);
|
||||
SetCheckboxValue(WIDX_ALLOW_EARLY_COMPLETION, Config::Get().general.AllowEarlyCompletion);
|
||||
|
||||
if (Config::Get().general.ScenarioSelectMode == SCENARIO_SELECT_MODE_DIFFICULTY)
|
||||
if (Config::Get().general.scenarioSelectMode == ScenarioSelectMode::difficulty)
|
||||
widgets[WIDX_SCENARIO_GROUPING].text = STR_OPTIONS_SCENARIO_DIFFICULTY;
|
||||
else
|
||||
widgets[WIDX_SCENARIO_GROUPING].text = STR_OPTIONS_SCENARIO_ORIGIN;
|
||||
|
||||
SetCheckboxValue(WIDX_SCENARIO_UNLOCKING, Config::Get().general.ScenarioUnlockingEnabled);
|
||||
|
||||
if (Config::Get().general.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN)
|
||||
if (Config::Get().general.scenarioSelectMode == ScenarioSelectMode::origin)
|
||||
{
|
||||
disabled_widgets &= ~(1uLL << WIDX_SCENARIO_UNLOCKING);
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
continue;
|
||||
|
||||
auto ft = Formatter();
|
||||
if (Config::Get().general.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN)
|
||||
if (Config::Get().general.scenarioSelectMode == ScenarioSelectMode::origin)
|
||||
{
|
||||
ft.Add<StringId>(kScenarioOriginStringIds[i]);
|
||||
}
|
||||
@@ -553,7 +553,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
// Category heading
|
||||
StringId headingStringId = kStringIdNone;
|
||||
if (Config::Get().general.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN)
|
||||
if (Config::Get().general.scenarioSelectMode == ScenarioSelectMode::origin)
|
||||
{
|
||||
if (selected_tab != EnumValue(ScenarioSource::Real) && currentHeading.category != scenario->Category)
|
||||
{
|
||||
@@ -659,7 +659,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
bool IsScenarioVisible(const ScenarioIndexEntry& scenario) const
|
||||
{
|
||||
if (Config::Get().general.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN)
|
||||
if (Config::Get().general.scenarioSelectMode == ScenarioSelectMode::origin)
|
||||
{
|
||||
if (static_cast<uint8_t>(scenario.SourceGame) != selected_tab)
|
||||
{
|
||||
@@ -683,7 +683,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
bool IsLockingEnabled() const
|
||||
{
|
||||
if (Config::Get().general.ScenarioSelectMode != SCENARIO_SELECT_MODE_ORIGIN)
|
||||
if (Config::Get().general.scenarioSelectMode != ScenarioSelectMode::origin)
|
||||
return false;
|
||||
if (!Config::Get().general.ScenarioUnlockingEnabled)
|
||||
return false;
|
||||
@@ -700,7 +700,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
for (size_t i = 0; i < numScenarios; i++)
|
||||
{
|
||||
const ScenarioIndexEntry* scenario = ScenarioRepositoryGetByIndex(i);
|
||||
if (Config::Get().general.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN)
|
||||
if (Config::Get().general.scenarioSelectMode == ScenarioSelectMode::origin)
|
||||
{
|
||||
showPages |= 1 << static_cast<uint8_t>(scenario->SourceGame);
|
||||
}
|
||||
|
||||
@@ -124,6 +124,11 @@ namespace OpenRCT2::Config
|
||||
ConfigEnumEntry<VirtualFloorStyles>("GLASSY", VirtualFloorStyles::Glassy),
|
||||
});
|
||||
|
||||
static const auto Enum_ScenarioSelectMode = ConfigEnum<ScenarioSelectMode>({
|
||||
ConfigEnumEntry<ScenarioSelectMode>("ORIGIN", ScenarioSelectMode::origin),
|
||||
ConfigEnumEntry<ScenarioSelectMode>("DIFFICULTY", ScenarioSelectMode::difficulty),
|
||||
});
|
||||
|
||||
/**
|
||||
* Config enum wrapping LanguagesDescriptors.
|
||||
*/
|
||||
@@ -224,7 +229,8 @@ namespace OpenRCT2::Config
|
||||
#endif // _DEBUG
|
||||
model->TrapCursor = reader->GetBoolean("trap_cursor", false);
|
||||
model->AutoOpenShops = reader->GetBoolean("auto_open_shops", false);
|
||||
model->ScenarioSelectMode = reader->GetInt32("scenario_select_mode", SCENARIO_SELECT_MODE_ORIGIN);
|
||||
model->scenarioSelectMode = reader->GetEnum(
|
||||
"scenario_select_mode", ScenarioSelectMode::origin, Enum_ScenarioSelectMode);
|
||||
model->ScenarioUnlockingEnabled = reader->GetBoolean("scenario_unlocking_enabled", true);
|
||||
model->ScenarioHideMegaPark = reader->GetBoolean("scenario_hide_mega_park", true);
|
||||
model->LastSaveGameDirectory = reader->GetString("last_game_directory", "");
|
||||
@@ -317,7 +323,7 @@ namespace OpenRCT2::Config
|
||||
writer->WriteBoolean("multithreading", model->MultiThreading);
|
||||
writer->WriteBoolean("trap_cursor", model->TrapCursor);
|
||||
writer->WriteBoolean("auto_open_shops", model->AutoOpenShops);
|
||||
writer->WriteInt32("scenario_select_mode", model->ScenarioSelectMode);
|
||||
writer->WriteEnum<ScenarioSelectMode>("scenario_select_mode", model->scenarioSelectMode, Enum_ScenarioSelectMode);
|
||||
writer->WriteBoolean("scenario_unlocking_enabled", model->ScenarioUnlockingEnabled);
|
||||
writer->WriteBoolean("scenario_hide_mega_park", model->ScenarioHideMegaPark);
|
||||
writer->WriteString("last_game_directory", model->LastSaveGameDirectory);
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#undef interface
|
||||
#endif
|
||||
|
||||
enum class ScenarioSelectMode : uint8_t;
|
||||
|
||||
namespace OpenRCT2::Config
|
||||
{
|
||||
struct General
|
||||
@@ -97,7 +99,7 @@ namespace OpenRCT2::Config
|
||||
bool AutoOpenShops;
|
||||
int32_t DefaultInspectionInterval;
|
||||
int32_t WindowLimit;
|
||||
int32_t ScenarioSelectMode;
|
||||
ScenarioSelectMode scenarioSelectMode;
|
||||
bool ScenarioUnlockingEnabled;
|
||||
bool ScenarioHideMegaPark;
|
||||
bool SteamOverlayPause;
|
||||
|
||||
@@ -127,10 +127,10 @@ private:
|
||||
ObjectiveStatus CheckMonthlyFoodIncome() const;
|
||||
};
|
||||
|
||||
enum
|
||||
enum class ScenarioSelectMode : uint8_t
|
||||
{
|
||||
SCENARIO_SELECT_MODE_DIFFICULTY,
|
||||
SCENARIO_SELECT_MODE_ORIGIN,
|
||||
difficulty,
|
||||
origin,
|
||||
};
|
||||
|
||||
enum
|
||||
|
||||
@@ -508,7 +508,7 @@ private:
|
||||
|
||||
void Sort()
|
||||
{
|
||||
if (Config::Get().general.ScenarioSelectMode == SCENARIO_SELECT_MODE_ORIGIN)
|
||||
if (Config::Get().general.scenarioSelectMode == ScenarioSelectMode::origin)
|
||||
{
|
||||
std::sort(
|
||||
_scenarios.begin(), _scenarios.end(), [](const ScenarioIndexEntry& a, const ScenarioIndexEntry& b) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user