2017-02-15 20:52:50 +00:00
|
|
|
|
/*****************************************************************************
|
2024-12-31 20:30:04 +01:00
|
|
|
|
* Copyright (c) 2014-2025 OpenRCT2 developers
|
2017-02-15 20:52:50 +00:00
|
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2017-02-15 20:52:50 +00:00
|
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2017-02-15 20:52:50 +00:00
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
#include "Config.h"
|
|
|
|
|
|
|
2017-04-01 13:38:52 +01:00
|
|
|
|
#include "../Context.h"
|
2024-05-10 21:14:05 +02:00
|
|
|
|
#include "../Date.h"
|
2024-07-09 16:23:31 +02:00
|
|
|
|
#include "../Diagnostic.h"
|
2018-06-22 22:58:08 +02:00
|
|
|
|
#include "../OpenRCT2.h"
|
2020-10-21 10:53:22 -07:00
|
|
|
|
#include "../PlatformEnvironment.h"
|
2017-02-16 23:22:26 +00:00
|
|
|
|
#include "../core/Console.hpp"
|
2024-12-15 17:39:52 +01:00
|
|
|
|
#include "../core/EnumUtils.hpp"
|
2017-06-27 13:23:16 +01:00
|
|
|
|
#include "../core/File.h"
|
2020-11-07 13:42:04 +01:00
|
|
|
|
#include "../core/FileStream.h"
|
2017-02-18 15:16:08 +00:00
|
|
|
|
#include "../core/Path.hpp"
|
|
|
|
|
|
#include "../core/String.hpp"
|
2017-02-18 10:54:13 +00:00
|
|
|
|
#include "../drawing/IDrawingEngine.h"
|
2018-01-06 00:05:16 +00:00
|
|
|
|
#include "../interface/Window.h"
|
2018-06-22 22:58:08 +02:00
|
|
|
|
#include "../localisation/Currency.h"
|
2024-07-13 13:48:49 +02:00
|
|
|
|
#include "../localisation/Formatting.h"
|
2018-06-22 22:58:08 +02:00
|
|
|
|
#include "../localisation/Language.h"
|
2020-10-09 12:13:14 -07:00
|
|
|
|
#include "../localisation/StringIds.h"
|
2025-02-24 04:43:06 -05:00
|
|
|
|
#include "../network/Network.h"
|
2018-06-22 22:58:08 +02:00
|
|
|
|
#include "../paint/VirtualFloor.h"
|
2022-02-18 21:57:00 +01:00
|
|
|
|
#include "../platform/Platform.h"
|
2024-05-10 12:05:52 +02:00
|
|
|
|
#include "../rct1/Csg.h"
|
2018-06-22 22:58:08 +02:00
|
|
|
|
#include "../scenario/Scenario.h"
|
2017-04-01 13:38:52 +01:00
|
|
|
|
#include "../ui/UiContext.h"
|
2018-03-13 13:14:02 +01:00
|
|
|
|
#include "ConfigEnum.hpp"
|
2017-02-22 17:46:10 +00:00
|
|
|
|
#include "IniReader.hpp"
|
|
|
|
|
|
#include "IniWriter.hpp"
|
2017-02-15 20:52:50 +00:00
|
|
|
|
|
2017-04-01 13:38:52 +01:00
|
|
|
|
using namespace OpenRCT2;
|
|
|
|
|
|
using namespace OpenRCT2::Ui;
|
|
|
|
|
|
|
2023-05-19 10:17:38 +02:00
|
|
|
|
#ifdef __APPLE__
|
2024-08-04 20:46:32 +01:00
|
|
|
|
static constexpr bool kWindowButtonsOnTheLeftDefault = true;
|
2023-05-19 10:17:38 +02:00
|
|
|
|
#else
|
2024-08-04 20:46:32 +01:00
|
|
|
|
static constexpr bool kWindowButtonsOnTheLeftDefault = false;
|
2023-05-19 10:17:38 +02:00
|
|
|
|
#endif
|
2024-04-20 17:02:39 +02:00
|
|
|
|
#ifdef __ANDROID__
|
|
|
|
|
|
static constexpr bool kEnlargedUiDefault = true;
|
|
|
|
|
|
#else
|
|
|
|
|
|
static constexpr bool kEnlargedUiDefault = false;
|
|
|
|
|
|
#endif
|
2023-05-19 10:17:38 +02:00
|
|
|
|
|
2024-05-10 12:10:21 +02:00
|
|
|
|
namespace OpenRCT2::Config
|
2017-02-15 20:52:50 +00:00
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
static Config _config{};
|
|
|
|
|
|
|
|
|
|
|
|
Config& Get()
|
|
|
|
|
|
{
|
|
|
|
|
|
return _config;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
#pragma region Enums
|
2017-02-16 00:03:02 +00:00
|
|
|
|
|
2020-08-13 21:51:28 +01:00
|
|
|
|
static const auto Enum_MeasurementFormat = ConfigEnum<MeasurementFormat>({
|
|
|
|
|
|
ConfigEnumEntry<MeasurementFormat>("IMPERIAL", MeasurementFormat::Imperial),
|
|
|
|
|
|
ConfigEnumEntry<MeasurementFormat>("METRIC", MeasurementFormat::Metric),
|
|
|
|
|
|
ConfigEnumEntry<MeasurementFormat>("SI", MeasurementFormat::SI),
|
2017-02-15 23:37:28 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
2020-10-24 22:33:06 -06:00
|
|
|
|
static const auto Enum_Currency = ConfigEnum<CurrencyType>({
|
2025-10-07 20:24:14 +02:00
|
|
|
|
ConfigEnumEntry<CurrencyType>("GBP", CurrencyType::pounds),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("USD", CurrencyType::dollars),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("FRF", CurrencyType::franc),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("DEM", CurrencyType::deutscheMark),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("JPY", CurrencyType::yen),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("ESP", CurrencyType::peseta),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("ITL", CurrencyType::lira),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("NLG", CurrencyType::guilders),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("SEK", CurrencyType::krona),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("EUR", CurrencyType::euros),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("KRW", CurrencyType::won),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("RUB", CurrencyType::rouble),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("CZK", CurrencyType::czechKoruna),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("HKD", CurrencyType::hongKongDollar),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("TWD", CurrencyType::newTaiwanDollar),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("CNY", CurrencyType::yuan),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("HUF", CurrencyType::forint),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyType>("CUSTOM", CurrencyType::custom),
|
2017-02-15 23:37:28 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
2020-08-04 21:33:06 +01:00
|
|
|
|
static const auto Enum_CurrencySymbolAffix = ConfigEnum<CurrencyAffix>({
|
2025-10-07 20:25:06 +02:00
|
|
|
|
ConfigEnumEntry<CurrencyAffix>("PREFIX", CurrencyAffix::prefix),
|
|
|
|
|
|
ConfigEnumEntry<CurrencyAffix>("SUFFIX", CurrencyAffix::suffix),
|
2017-02-15 23:37:28 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static const auto Enum_DateFormat = ConfigEnum<int32_t>({
|
2018-06-20 17:28:51 +02:00
|
|
|
|
ConfigEnumEntry<int32_t>("DD/MM/YY", DATE_FORMAT_DAY_MONTH_YEAR),
|
|
|
|
|
|
ConfigEnumEntry<int32_t>("MM/DD/YY", DATE_FORMAT_MONTH_DAY_YEAR),
|
|
|
|
|
|
ConfigEnumEntry<int32_t>("YY/MM/DD", DATE_FORMAT_YEAR_MONTH_DAY),
|
|
|
|
|
|
ConfigEnumEntry<int32_t>("YY/DD/MM", DATE_FORMAT_YEAR_DAY_MONTH),
|
2017-02-15 23:37:28 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
2020-10-02 22:41:30 -03:00
|
|
|
|
static const auto Enum_DrawingEngine = ConfigEnum<DrawingEngine>({
|
2025-05-03 11:07:06 +02:00
|
|
|
|
ConfigEnumEntry<DrawingEngine>("SOFTWARE_HWD", DrawingEngine::SoftwareWithHardwareDisplay),
|
2020-10-02 22:41:30 -03:00
|
|
|
|
ConfigEnumEntry<DrawingEngine>("OPENGL", DrawingEngine::OpenGL),
|
2017-02-15 23:37:28 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
2020-08-08 23:26:46 -07:00
|
|
|
|
static const auto Enum_Temperature = ConfigEnum<TemperatureUnit>({
|
|
|
|
|
|
ConfigEnumEntry<TemperatureUnit>("CELSIUS", TemperatureUnit::Celsius),
|
|
|
|
|
|
ConfigEnumEntry<TemperatureUnit>("FAHRENHEIT", TemperatureUnit::Fahrenheit),
|
2017-02-15 23:37:28 +00:00
|
|
|
|
});
|
2018-01-11 14:50:31 +01:00
|
|
|
|
|
2025-01-04 16:24:00 +01:00
|
|
|
|
static const auto Enum_FileBrowserSort = ConfigEnum<FileBrowserSort>({
|
|
|
|
|
|
ConfigEnumEntry<FileBrowserSort>("NAME_ASCENDING", FileBrowserSort::NameAscending),
|
|
|
|
|
|
ConfigEnumEntry<FileBrowserSort>("NAME_DESCENDING", FileBrowserSort::NameDescending),
|
2025-07-18 14:41:52 +02:00
|
|
|
|
ConfigEnumEntry<FileBrowserSort>("SIZE_ASCENDING", FileBrowserSort::SizeAscending),
|
|
|
|
|
|
ConfigEnumEntry<FileBrowserSort>("SIZE_DESCENDING", FileBrowserSort::SizeDescending),
|
2025-01-04 16:24:00 +01:00
|
|
|
|
ConfigEnumEntry<FileBrowserSort>("DATE_ASCENDING", FileBrowserSort::DateAscending),
|
|
|
|
|
|
ConfigEnumEntry<FileBrowserSort>("DATE_DESCENDING", FileBrowserSort::DateDescending),
|
2020-12-22 21:18:11 -03:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-07-18 15:53:29 +02:00
|
|
|
|
static const auto Enum_ParkPreviewPref = ConfigEnum<ParkPreviewPref>({
|
|
|
|
|
|
ConfigEnumEntry<ParkPreviewPref>("DISABLED", ParkPreviewPref::disabled),
|
|
|
|
|
|
ConfigEnumEntry<ParkPreviewPref>("SCREENSHOT", ParkPreviewPref::screenshot),
|
|
|
|
|
|
ConfigEnumEntry<ParkPreviewPref>("MINIMAP", ParkPreviewPref::miniMap),
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2020-08-28 02:06:39 +02:00
|
|
|
|
static const auto Enum_VirtualFloorStyle = ConfigEnum<VirtualFloorStyles>({
|
|
|
|
|
|
ConfigEnumEntry<VirtualFloorStyles>("OFF", VirtualFloorStyles::Off),
|
|
|
|
|
|
ConfigEnumEntry<VirtualFloorStyles>("CLEAR", VirtualFloorStyles::Clear),
|
|
|
|
|
|
ConfigEnumEntry<VirtualFloorStyles>("GLASSY", VirtualFloorStyles::Glassy),
|
2018-05-30 13:09:50 +02:00
|
|
|
|
});
|
|
|
|
|
|
|
2017-02-16 00:03:02 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Config enum wrapping LanguagesDescriptors.
|
|
|
|
|
|
*/
|
2018-06-20 17:28:51 +02:00
|
|
|
|
static class LanguageConfigEnum final : public IConfigEnum<int32_t>
|
2017-02-15 20:52:50 +00:00
|
|
|
|
{
|
2017-02-16 00:03:02 +00:00
|
|
|
|
public:
|
2018-06-20 17:28:51 +02:00
|
|
|
|
std::string GetName(int32_t value) const override
|
2017-02-16 00:03:02 +00:00
|
|
|
|
{
|
|
|
|
|
|
return LanguagesDescriptors[value].locale;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
int32_t GetValue(const std::string& key, int32_t defaultValue) const override
|
2017-02-16 00:03:02 +00:00
|
|
|
|
{
|
2018-06-20 17:28:51 +02:00
|
|
|
|
int32_t i = 0;
|
2018-06-22 22:58:08 +02:00
|
|
|
|
for (const auto& langDesc : LanguagesDescriptors)
|
2017-02-16 00:03:02 +00:00
|
|
|
|
{
|
2024-12-11 22:28:31 +01:00
|
|
|
|
if (String::equals(key.c_str(), langDesc.locale))
|
2017-02-16 00:03:02 +00:00
|
|
|
|
{
|
|
|
|
|
|
return i;
|
|
|
|
|
|
}
|
|
|
|
|
|
i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
return defaultValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
} Enum_LanguageEnum;
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
#pragma endregion
|
2017-02-15 20:52:50 +00:00
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void ReadGeneral(IIniReader* reader)
|
2017-02-15 20:52:50 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (reader->ReadSection("general"))
|
|
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.general;
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->alwaysShowGridlines = reader->GetBoolean("always_show_gridlines", false);
|
|
|
|
|
|
model->autosaveFrequency = reader->GetInt32("autosave", AUTOSAVE_EVERY_5MINUTES);
|
|
|
|
|
|
model->autosaveAmount = reader->GetInt32("autosave_amount", kDefaultNumAutosavesToKeep);
|
|
|
|
|
|
model->confirmationPrompt = reader->GetBoolean("confirmation_prompt", false);
|
|
|
|
|
|
model->currencyFormat = reader->GetEnum<CurrencyType>(
|
2022-01-08 12:24:57 +01:00
|
|
|
|
"currency_format", Platform::GetLocaleCurrency(), Enum_Currency);
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->customCurrencyRate = reader->GetInt32("custom_currency_rate", 10);
|
|
|
|
|
|
model->customCurrencyAffix = reader->GetEnum<CurrencyAffix>(
|
2025-10-07 20:25:06 +02:00
|
|
|
|
"custom_currency_affix", CurrencyAffix::suffix, Enum_CurrencySymbolAffix);
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->customCurrencySymbol = reader->GetString("custom_currency_symbol", "Ctm");
|
|
|
|
|
|
model->edgeScrolling = reader->GetBoolean("edge_scrolling", true);
|
|
|
|
|
|
model->edgeScrollingSpeed = reader->GetInt32("edge_scrolling_speed", 12);
|
|
|
|
|
|
model->fullscreenMode = reader->GetInt32("fullscreen_mode", 0);
|
|
|
|
|
|
model->fullscreenHeight = reader->GetInt32("fullscreen_height", -1);
|
|
|
|
|
|
model->fullscreenWidth = reader->GetInt32("fullscreen_width", -1);
|
|
|
|
|
|
model->rct1Path = reader->GetString("rct1_path", "");
|
|
|
|
|
|
model->rct2Path = reader->GetString("game_path", "");
|
|
|
|
|
|
model->landscapeSmoothing = reader->GetBoolean("landscape_smoothing", true);
|
|
|
|
|
|
model->language = reader->GetEnum<int32_t>("language", Platform::GetLocaleLanguage(), Enum_LanguageEnum);
|
|
|
|
|
|
model->measurementFormat = reader->GetEnum<MeasurementFormat>(
|
2022-01-10 12:38:26 +01:00
|
|
|
|
"measurement_format", Platform::GetLocaleMeasurementFormat(), Enum_MeasurementFormat);
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->playIntro = reader->GetBoolean("play_intro", false);
|
|
|
|
|
|
model->savePluginData = reader->GetBoolean("save_plugin_data", true);
|
|
|
|
|
|
model->debuggingTools = reader->GetBoolean("debugging_tools", false);
|
|
|
|
|
|
model->showHeightAsUnits = reader->GetBoolean("show_height_as_units", false);
|
|
|
|
|
|
model->temperatureFormat = reader->GetEnum<TemperatureUnit>(
|
2022-01-10 12:49:53 +01:00
|
|
|
|
"temperature_format", Platform::GetLocaleTemperatureFormat(), Enum_Temperature);
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->windowHeight = reader->GetInt32("window_height", -1);
|
|
|
|
|
|
model->windowSnapProximity = reader->GetInt32("window_snap_proximity", 5);
|
|
|
|
|
|
model->windowWidth = reader->GetInt32("window_width", -1);
|
|
|
|
|
|
model->defaultDisplay = reader->GetInt32("default_display", 0);
|
|
|
|
|
|
model->drawingEngine = reader->GetEnum<DrawingEngine>(
|
2024-07-27 19:53:11 +02:00
|
|
|
|
"drawing_engine", DrawingEngine::SoftwareWithHardwareDisplay, Enum_DrawingEngine);
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->uncapFPS = reader->GetBoolean("uncap_fps", false);
|
|
|
|
|
|
model->useVSync = reader->GetBoolean("use_vsync", true);
|
|
|
|
|
|
model->virtualFloorStyle = reader->GetEnum<VirtualFloorStyles>(
|
2020-08-28 02:06:39 +02:00
|
|
|
|
"virtual_floor_style", VirtualFloorStyles::Glassy, Enum_VirtualFloorStyle);
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->dateFormat = reader->GetEnum<int32_t>("date_format", Platform::GetLocaleDateFormat(), Enum_DateFormat);
|
|
|
|
|
|
model->autoStaffPlacement = reader->GetBoolean("auto_staff", true);
|
|
|
|
|
|
model->handymenMowByDefault = reader->GetBoolean("handymen_mow_default", false);
|
|
|
|
|
|
model->defaultInspectionInterval = reader->GetInt32("default_inspection_interval", 2);
|
|
|
|
|
|
model->lastRunVersion = reader->GetString("last_run_version", "");
|
|
|
|
|
|
model->invertViewportDrag = reader->GetBoolean("invert_viewport_drag", false);
|
|
|
|
|
|
model->loadSaveSort = reader->GetEnum<FileBrowserSort>(
|
2025-01-04 18:17:38 +01:00
|
|
|
|
"load_save_sort", FileBrowserSort::NameAscending, Enum_FileBrowserSort);
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->minimizeFullscreenFocusLoss = reader->GetBoolean("minimize_fullscreen_focus_loss", true);
|
|
|
|
|
|
model->disableScreensaver = reader->GetBoolean("disable_screensaver", true);
|
2017-02-15 23:37:28 +00:00
|
|
|
|
|
2017-05-15 02:28:43 -05:00
|
|
|
|
// Default config setting is false until the games canvas can be separated from the effect
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->dayNightCycle = reader->GetBoolean("day_night_cycle", false);
|
|
|
|
|
|
const bool supportsLightFx = model->drawingEngine == DrawingEngine::SoftwareWithHardwareDisplay;
|
|
|
|
|
|
model->enableLightFx = supportsLightFx && reader->GetBoolean("enable_light_fx", false);
|
|
|
|
|
|
model->enableLightFxForVehicles = supportsLightFx && reader->GetBoolean("enable_light_fx_for_vehicles", false);
|
|
|
|
|
|
model->upperCaseBanners = reader->GetBoolean("upper_case_banners", false);
|
|
|
|
|
|
model->disableLightningEffect = reader->GetBoolean("disable_lightning_effect", false);
|
|
|
|
|
|
model->windowScale = reader->GetFloat("window_scale", Platform::GetDefaultScale());
|
|
|
|
|
|
model->inferDisplayDPI = reader->GetBoolean("infer_display_dpi", true);
|
|
|
|
|
|
model->showFPS = reader->GetBoolean("show_fps", false);
|
2023-07-04 23:10:36 +03:00
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
|
// Always have multi-threading disabled in debug builds, this makes things slower.
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->multiThreading = false;
|
2023-07-04 23:10:36 +03:00
|
|
|
|
#else
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->multiThreading = reader->GetBoolean("multithreading", true);
|
2023-07-04 23:10:36 +03:00
|
|
|
|
#endif // _DEBUG
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->trapCursor = reader->GetBoolean("trap_cursor", false);
|
|
|
|
|
|
model->autoOpenShops = reader->GetBoolean("auto_open_shops", false);
|
2025-07-03 22:48:59 +02:00
|
|
|
|
|
|
|
|
|
|
// Gamepad settings
|
|
|
|
|
|
model->gamepadDeadzone = reader->GetInt32("gamepad_deadzone", 3600);
|
|
|
|
|
|
model->gamepadSensitivity = reader->GetFloat("gamepad_sensitivity", 1.5f);
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->scenarioUnlockingEnabled = reader->GetBoolean("scenario_unlocking_enabled", true);
|
|
|
|
|
|
model->scenarioHideMegaPark = reader->GetBoolean("scenario_hide_mega_park", true);
|
|
|
|
|
|
model->lastSaveGameDirectory = reader->GetString("last_game_directory", "");
|
|
|
|
|
|
model->lastSaveLandscapeDirectory = reader->GetString("last_landscape_directory", "");
|
|
|
|
|
|
model->lastSaveScenarioDirectory = reader->GetString("last_scenario_directory", "");
|
|
|
|
|
|
model->lastSaveTrackDirectory = reader->GetString("last_track_directory", "");
|
|
|
|
|
|
model->useNativeBrowseDialog = reader->GetBoolean("use_native_browse_dialog", false);
|
|
|
|
|
|
model->windowLimit = reader->GetInt32("window_limit", kWindowLimitMax);
|
|
|
|
|
|
model->zoomToCursor = reader->GetBoolean("zoom_to_cursor", true);
|
|
|
|
|
|
model->renderWeatherEffects = reader->GetBoolean("render_weather_effects", true);
|
|
|
|
|
|
model->renderWeatherGloom = reader->GetBoolean("render_weather_gloom", true);
|
|
|
|
|
|
model->showGuestPurchases = reader->GetBoolean("show_guest_purchases", false);
|
|
|
|
|
|
model->showRealNamesOfGuests = reader->GetBoolean("show_real_names_of_guests", true);
|
|
|
|
|
|
model->showRealNamesOfStaff = reader->GetBoolean("show_real_names_of_staff", false);
|
|
|
|
|
|
model->allowEarlyCompletion = reader->GetBoolean("allow_early_completion", false);
|
|
|
|
|
|
model->assetPackOrder = reader->GetString("asset_pack_order", "");
|
|
|
|
|
|
model->enabledAssetPacks = reader->GetString("enabled_asset_packs", "");
|
|
|
|
|
|
model->transparentScreenshot = reader->GetBoolean("transparent_screenshot", true);
|
|
|
|
|
|
model->transparentWater = reader->GetBoolean("transparent_water", true);
|
2022-03-06 17:33:02 +00:00
|
|
|
|
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->invisibleRides = reader->GetBoolean("invisible_rides", false);
|
|
|
|
|
|
model->invisibleVehicles = reader->GetBoolean("invisible_vehicles", false);
|
|
|
|
|
|
model->invisibleTrees = reader->GetBoolean("invisible_trees", false);
|
|
|
|
|
|
model->invisibleScenery = reader->GetBoolean("invisible_scenery", false);
|
|
|
|
|
|
model->invisiblePaths = reader->GetBoolean("invisible_paths", false);
|
|
|
|
|
|
model->invisibleSupports = reader->GetBoolean("invisible_supports", true);
|
2022-03-06 17:33:02 +00:00
|
|
|
|
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->lastVersionCheckTime = reader->GetInt64("last_version_check_time", 0);
|
2025-01-04 16:18:27 +01:00
|
|
|
|
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->fileBrowserWidth = reader->GetInt32("file_browser_width", 0);
|
|
|
|
|
|
model->fileBrowserHeight = reader->GetInt32("file_browser_height", 0);
|
|
|
|
|
|
model->fileBrowserShowSizeColumn = reader->GetBoolean("file_browser_show_size_column", true);
|
|
|
|
|
|
model->fileBrowserShowDateColumn = reader->GetBoolean("file_browser_show_date_column", true);
|
|
|
|
|
|
model->fileBrowserPreviewType = reader->GetEnum<ParkPreviewPref>(
|
2025-07-18 15:53:29 +02:00
|
|
|
|
"file_browser_preview_type", ParkPreviewPref::screenshot, Enum_ParkPreviewPref);
|
2017-02-15 23:37:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void WriteGeneral(IIniWriter* writer)
|
2017-02-16 19:12:30 +00:00
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.general;
|
2017-02-16 23:22:26 +00:00
|
|
|
|
writer->WriteSection("general");
|
2025-10-07 20:14:37 +02:00
|
|
|
|
writer->WriteBoolean("always_show_gridlines", model->alwaysShowGridlines);
|
|
|
|
|
|
writer->WriteInt32("autosave", model->autosaveFrequency);
|
|
|
|
|
|
writer->WriteInt32("autosave_amount", model->autosaveAmount);
|
|
|
|
|
|
writer->WriteBoolean("confirmation_prompt", model->confirmationPrompt);
|
|
|
|
|
|
writer->WriteEnum<CurrencyType>("currency_format", model->currencyFormat, Enum_Currency);
|
|
|
|
|
|
writer->WriteInt32("custom_currency_rate", model->customCurrencyRate);
|
|
|
|
|
|
writer->WriteEnum<CurrencyAffix>("custom_currency_affix", model->customCurrencyAffix, Enum_CurrencySymbolAffix);
|
|
|
|
|
|
writer->WriteString("custom_currency_symbol", model->customCurrencySymbol);
|
|
|
|
|
|
writer->WriteBoolean("edge_scrolling", model->edgeScrolling);
|
|
|
|
|
|
writer->WriteInt32("edge_scrolling_speed", model->edgeScrollingSpeed);
|
|
|
|
|
|
writer->WriteInt32("fullscreen_mode", model->fullscreenMode);
|
|
|
|
|
|
writer->WriteInt32("fullscreen_height", model->fullscreenHeight);
|
|
|
|
|
|
writer->WriteInt32("fullscreen_width", model->fullscreenWidth);
|
|
|
|
|
|
writer->WriteString("rct1_path", model->rct1Path);
|
|
|
|
|
|
writer->WriteString("game_path", model->rct2Path);
|
|
|
|
|
|
writer->WriteBoolean("landscape_smoothing", model->landscapeSmoothing);
|
|
|
|
|
|
writer->WriteEnum<int32_t>("language", model->language, Enum_LanguageEnum);
|
|
|
|
|
|
writer->WriteEnum<MeasurementFormat>("measurement_format", model->measurementFormat, Enum_MeasurementFormat);
|
|
|
|
|
|
writer->WriteBoolean("play_intro", model->playIntro);
|
|
|
|
|
|
writer->WriteBoolean("save_plugin_data", model->savePluginData);
|
|
|
|
|
|
writer->WriteBoolean("debugging_tools", model->debuggingTools);
|
|
|
|
|
|
writer->WriteBoolean("show_height_as_units", model->showHeightAsUnits);
|
|
|
|
|
|
writer->WriteEnum<TemperatureUnit>("temperature_format", model->temperatureFormat, Enum_Temperature);
|
|
|
|
|
|
writer->WriteInt32("window_height", model->windowHeight);
|
|
|
|
|
|
writer->WriteInt32("window_snap_proximity", model->windowSnapProximity);
|
|
|
|
|
|
writer->WriteInt32("window_width", model->windowWidth);
|
|
|
|
|
|
writer->WriteInt32("default_display", model->defaultDisplay);
|
|
|
|
|
|
writer->WriteEnum<DrawingEngine>("drawing_engine", model->drawingEngine, Enum_DrawingEngine);
|
|
|
|
|
|
writer->WriteBoolean("uncap_fps", model->uncapFPS);
|
|
|
|
|
|
writer->WriteBoolean("use_vsync", model->useVSync);
|
|
|
|
|
|
writer->WriteEnum<int32_t>("date_format", model->dateFormat, Enum_DateFormat);
|
|
|
|
|
|
writer->WriteBoolean("auto_staff", model->autoStaffPlacement);
|
|
|
|
|
|
writer->WriteBoolean("handymen_mow_default", model->handymenMowByDefault);
|
|
|
|
|
|
writer->WriteInt32("default_inspection_interval", model->defaultInspectionInterval);
|
|
|
|
|
|
writer->WriteString("last_run_version", model->lastRunVersion);
|
|
|
|
|
|
writer->WriteBoolean("invert_viewport_drag", model->invertViewportDrag);
|
|
|
|
|
|
writer->WriteEnum<FileBrowserSort>("load_save_sort", model->loadSaveSort, Enum_FileBrowserSort);
|
|
|
|
|
|
writer->WriteBoolean("minimize_fullscreen_focus_loss", model->minimizeFullscreenFocusLoss);
|
|
|
|
|
|
writer->WriteBoolean("disable_screensaver", model->disableScreensaver);
|
|
|
|
|
|
writer->WriteBoolean("day_night_cycle", model->dayNightCycle);
|
|
|
|
|
|
writer->WriteBoolean("enable_light_fx", model->enableLightFx);
|
|
|
|
|
|
writer->WriteBoolean("enable_light_fx_for_vehicles", model->enableLightFxForVehicles);
|
|
|
|
|
|
writer->WriteBoolean("upper_case_banners", model->upperCaseBanners);
|
|
|
|
|
|
writer->WriteBoolean("disable_lightning_effect", model->disableLightningEffect);
|
|
|
|
|
|
writer->WriteFloat("window_scale", model->windowScale);
|
|
|
|
|
|
writer->WriteBoolean("infer_display_dpi", model->inferDisplayDPI);
|
|
|
|
|
|
writer->WriteBoolean("show_fps", model->showFPS);
|
|
|
|
|
|
writer->WriteBoolean("multithreading", model->multiThreading);
|
|
|
|
|
|
writer->WriteBoolean("trap_cursor", model->trapCursor);
|
|
|
|
|
|
writer->WriteBoolean("auto_open_shops", model->autoOpenShops);
|
2025-07-03 22:48:59 +02:00
|
|
|
|
|
|
|
|
|
|
// Gamepad settings
|
|
|
|
|
|
writer->WriteInt32("gamepad_deadzone", model->gamepadDeadzone);
|
|
|
|
|
|
writer->WriteFloat("gamepad_sensitivity", model->gamepadSensitivity);
|
2025-10-07 20:14:37 +02:00
|
|
|
|
writer->WriteBoolean("scenario_unlocking_enabled", model->scenarioUnlockingEnabled);
|
|
|
|
|
|
writer->WriteBoolean("scenario_hide_mega_park", model->scenarioHideMegaPark);
|
|
|
|
|
|
writer->WriteString("last_game_directory", model->lastSaveGameDirectory);
|
|
|
|
|
|
writer->WriteString("last_landscape_directory", model->lastSaveLandscapeDirectory);
|
|
|
|
|
|
writer->WriteString("last_scenario_directory", model->lastSaveScenarioDirectory);
|
|
|
|
|
|
writer->WriteString("last_track_directory", model->lastSaveTrackDirectory);
|
|
|
|
|
|
writer->WriteBoolean("use_native_browse_dialog", model->useNativeBrowseDialog);
|
|
|
|
|
|
writer->WriteInt32("window_limit", model->windowLimit);
|
|
|
|
|
|
writer->WriteBoolean("zoom_to_cursor", model->zoomToCursor);
|
|
|
|
|
|
writer->WriteBoolean("render_weather_effects", model->renderWeatherEffects);
|
|
|
|
|
|
writer->WriteBoolean("render_weather_gloom", model->renderWeatherGloom);
|
|
|
|
|
|
writer->WriteBoolean("show_guest_purchases", model->showGuestPurchases);
|
|
|
|
|
|
writer->WriteBoolean("show_real_names_of_guests", model->showRealNamesOfGuests);
|
|
|
|
|
|
writer->WriteBoolean("show_real_names_of_staff", model->showRealNamesOfStaff);
|
|
|
|
|
|
writer->WriteBoolean("allow_early_completion", model->allowEarlyCompletion);
|
|
|
|
|
|
writer->WriteString("asset_pack_order", model->assetPackOrder);
|
|
|
|
|
|
writer->WriteString("enabled_asset_packs", model->enabledAssetPacks);
|
|
|
|
|
|
writer->WriteEnum<VirtualFloorStyles>("virtual_floor_style", model->virtualFloorStyle, Enum_VirtualFloorStyle);
|
|
|
|
|
|
writer->WriteBoolean("transparent_screenshot", model->transparentScreenshot);
|
|
|
|
|
|
writer->WriteBoolean("transparent_water", model->transparentWater);
|
|
|
|
|
|
writer->WriteBoolean("invisible_rides", model->invisibleRides);
|
|
|
|
|
|
writer->WriteBoolean("invisible_vehicles", model->invisibleVehicles);
|
|
|
|
|
|
writer->WriteBoolean("invisible_trees", model->invisibleTrees);
|
|
|
|
|
|
writer->WriteBoolean("invisible_scenery", model->invisibleScenery);
|
|
|
|
|
|
writer->WriteBoolean("invisible_paths", model->invisiblePaths);
|
|
|
|
|
|
writer->WriteBoolean("invisible_supports", model->invisibleSupports);
|
|
|
|
|
|
writer->WriteInt64("last_version_check_time", model->lastVersionCheckTime);
|
|
|
|
|
|
writer->WriteInt32("file_browser_width", model->fileBrowserWidth);
|
|
|
|
|
|
writer->WriteInt32("file_browser_height", model->fileBrowserHeight);
|
|
|
|
|
|
writer->WriteBoolean("file_browser_show_size_column", model->fileBrowserShowSizeColumn);
|
|
|
|
|
|
writer->WriteBoolean("file_browser_show_date_column", model->fileBrowserShowDateColumn);
|
|
|
|
|
|
writer->WriteEnum<ParkPreviewPref>("file_browser_preview_type", model->fileBrowserPreviewType, Enum_ParkPreviewPref);
|
2017-02-16 19:12:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void ReadInterface(IIniReader* reader)
|
2017-02-15 23:37:28 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (reader->ReadSection("interface"))
|
|
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.interface;
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->toolbarButtonsCentred = reader->GetBoolean("toolbar_buttons_centred", false);
|
|
|
|
|
|
model->toolbarShowFinances = reader->GetBoolean("toolbar_show_finances", true);
|
|
|
|
|
|
model->toolbarShowResearch = reader->GetBoolean("toolbar_show_research", true);
|
|
|
|
|
|
model->toolbarShowCheats = reader->GetBoolean("toolbar_show_cheats", false);
|
|
|
|
|
|
model->toolbarShowNews = reader->GetBoolean("toolbar_show_news", false);
|
|
|
|
|
|
model->toolbarShowMute = reader->GetBoolean("toolbar_show_mute", false);
|
|
|
|
|
|
model->toolbarShowChat = reader->GetBoolean("toolbar_show_chat", false);
|
|
|
|
|
|
model->toolbarShowZoom = reader->GetBoolean("toolbar_show_zoom", true);
|
|
|
|
|
|
model->toolbarShowRotateAnticlockwise = reader->GetBoolean("toolbar_show_rotate_anti_clockwise", false);
|
|
|
|
|
|
model->consoleSmallFont = reader->GetBoolean("console_small_font", false);
|
|
|
|
|
|
model->currentThemePreset = reader->GetString("current_theme", "*RCT2");
|
|
|
|
|
|
model->currentTitleSequencePreset = reader->GetString("current_title_sequence", "*OPENRCT2");
|
|
|
|
|
|
model->randomTitleSequence = reader->GetBoolean("random_title_sequence", false);
|
|
|
|
|
|
model->objectSelectionFilterFlags = reader->GetInt32("object_selection_filter_flags", 0x3FFF);
|
2025-05-21 18:07:19 +02:00
|
|
|
|
model->scenarioSelectLastTab = reader->GetInt32("scenarioselect_last_tab", 0);
|
2025-05-30 21:42:53 +02:00
|
|
|
|
model->scenarioPreviewScreenshots = reader->GetBoolean("scenario_preview_screenshots", true);
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->listRideVehiclesSeparately = reader->GetBoolean("list_ride_vehicles_separately", false);
|
|
|
|
|
|
model->windowButtonsOnTheLeft = reader->GetBoolean("window_buttons_on_the_left", kWindowButtonsOnTheLeftDefault);
|
|
|
|
|
|
model->enlargedUi = reader->GetBoolean("enlarged_ui", kEnlargedUiDefault);
|
|
|
|
|
|
model->touchEnhancements = reader->GetBoolean("touch_enhancements", kEnlargedUiDefault);
|
2017-02-15 20:52:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void WriteInterface(IIniWriter* writer)
|
2017-02-16 19:12:30 +00:00
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.interface;
|
2017-02-16 23:22:26 +00:00
|
|
|
|
writer->WriteSection("interface");
|
2025-10-07 20:14:37 +02:00
|
|
|
|
writer->WriteBoolean("toolbar_buttons_centred", model->toolbarButtonsCentred);
|
|
|
|
|
|
writer->WriteBoolean("toolbar_show_finances", model->toolbarShowFinances);
|
|
|
|
|
|
writer->WriteBoolean("toolbar_show_research", model->toolbarShowResearch);
|
|
|
|
|
|
writer->WriteBoolean("toolbar_show_cheats", model->toolbarShowCheats);
|
|
|
|
|
|
writer->WriteBoolean("toolbar_show_news", model->toolbarShowNews);
|
|
|
|
|
|
writer->WriteBoolean("toolbar_show_mute", model->toolbarShowMute);
|
|
|
|
|
|
writer->WriteBoolean("toolbar_show_chat", model->toolbarShowChat);
|
|
|
|
|
|
writer->WriteBoolean("toolbar_show_zoom", model->toolbarShowZoom);
|
|
|
|
|
|
writer->WriteBoolean("toolbar_show_rotate_anti_clockwise", model->toolbarShowRotateAnticlockwise);
|
|
|
|
|
|
writer->WriteBoolean("console_small_font", model->consoleSmallFont);
|
|
|
|
|
|
writer->WriteString("current_theme", model->currentThemePreset);
|
|
|
|
|
|
writer->WriteString("current_title_sequence", model->currentTitleSequencePreset);
|
|
|
|
|
|
writer->WriteBoolean("random_title_sequence", model->randomTitleSequence);
|
|
|
|
|
|
writer->WriteInt32("object_selection_filter_flags", model->objectSelectionFilterFlags);
|
2025-05-21 18:07:19 +02:00
|
|
|
|
writer->WriteInt32("scenarioselect_last_tab", model->scenarioSelectLastTab);
|
|
|
|
|
|
writer->WriteBoolean("scenario_preview_screenshots", model->scenarioPreviewScreenshots);
|
2025-10-07 20:14:37 +02:00
|
|
|
|
writer->WriteBoolean("list_ride_vehicles_separately", model->listRideVehiclesSeparately);
|
|
|
|
|
|
writer->WriteBoolean("window_buttons_on_the_left", model->windowButtonsOnTheLeft);
|
|
|
|
|
|
writer->WriteBoolean("enlarged_ui", model->enlargedUi);
|
|
|
|
|
|
writer->WriteBoolean("touch_enhancements", model->touchEnhancements);
|
2017-02-16 19:12:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void ReadSound(IIniReader* reader)
|
2017-02-15 20:52:50 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (reader->ReadSection("sound"))
|
|
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.sound;
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->device = reader->GetString("audio_device", "");
|
|
|
|
|
|
model->masterSoundEnabled = reader->GetBoolean("master_sound", true);
|
|
|
|
|
|
model->masterVolume = reader->GetInt32("master_volume", 100);
|
|
|
|
|
|
model->titleMusic = static_cast<TitleMusicKind>(
|
2023-05-15 00:10:45 +02:00
|
|
|
|
reader->GetInt32("title_theme", EnumValue(TitleMusicKind::OpenRCT2)));
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->soundEnabled = reader->GetBoolean("sound", true);
|
|
|
|
|
|
model->soundVolume = reader->GetInt32("sound_volume", 100);
|
|
|
|
|
|
model->rideMusicEnabled = reader->GetBoolean("ride_music", true);
|
|
|
|
|
|
model->rideMusicVolume = reader->GetInt32("ride_music_volume", 100);
|
|
|
|
|
|
model->audioFocus = reader->GetBoolean("audio_focus", false);
|
2017-02-15 20:52:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void WriteSound(IIniWriter* writer)
|
2017-02-16 19:12:30 +00:00
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.sound;
|
2017-02-16 23:22:26 +00:00
|
|
|
|
writer->WriteSection("sound");
|
2025-10-07 20:14:37 +02:00
|
|
|
|
writer->WriteString("audio_device", model->device);
|
|
|
|
|
|
writer->WriteBoolean("master_sound", model->masterSoundEnabled);
|
|
|
|
|
|
writer->WriteInt32("master_volume", model->masterVolume);
|
|
|
|
|
|
writer->WriteInt32("title_theme", EnumValue(model->titleMusic));
|
|
|
|
|
|
writer->WriteBoolean("sound", model->soundEnabled);
|
|
|
|
|
|
writer->WriteInt32("sound_volume", model->soundVolume);
|
|
|
|
|
|
writer->WriteBoolean("ride_music", model->rideMusicEnabled);
|
|
|
|
|
|
writer->WriteInt32("ride_music_volume", model->rideMusicVolume);
|
|
|
|
|
|
writer->WriteBoolean("audio_focus", model->audioFocus);
|
2017-02-16 19:12:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void ReadNetwork(IIniReader* reader)
|
2017-02-15 22:51:39 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (reader->ReadSection("network"))
|
|
|
|
|
|
{
|
2017-06-26 18:59:01 +01:00
|
|
|
|
// If the `player_name` setting is missing or equal to the empty string
|
|
|
|
|
|
// use the logged-in user's username instead
|
2017-07-22 09:48:34 +01:00
|
|
|
|
auto playerName = reader->GetString("player_name", "");
|
|
|
|
|
|
if (playerName.empty())
|
2017-06-26 18:59:01 +01:00
|
|
|
|
{
|
2022-01-05 14:42:46 +01:00
|
|
|
|
playerName = Platform::GetUsername();
|
2017-07-22 09:48:34 +01:00
|
|
|
|
if (playerName.empty())
|
2017-06-26 18:59:01 +01:00
|
|
|
|
{
|
2017-07-22 09:48:34 +01:00
|
|
|
|
playerName = "Player";
|
2017-06-26 18:59:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-07-04 09:19:39 +02:00
|
|
|
|
// Trim any whitespace before or after the player's name,
|
|
|
|
|
|
// to avoid people pretending to be someone else
|
2024-12-11 22:28:31 +01:00
|
|
|
|
playerName = String::trim(playerName);
|
2017-07-04 09:19:39 +02:00
|
|
|
|
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.network;
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->playerName = std::move(playerName);
|
|
|
|
|
|
model->defaultPort = reader->GetInt32("default_port", ::Network::kDefaultPort);
|
|
|
|
|
|
model->listenAddress = reader->GetString("listen_address", "");
|
|
|
|
|
|
model->defaultPassword = reader->GetString("default_password", "");
|
|
|
|
|
|
model->stayConnected = reader->GetBoolean("stay_connected", true);
|
|
|
|
|
|
model->advertise = reader->GetBoolean("advertise", true);
|
|
|
|
|
|
model->advertiseAddress = reader->GetString("advertise_address", "");
|
|
|
|
|
|
model->maxplayers = reader->GetInt32("maxplayers", 16);
|
|
|
|
|
|
model->serverName = reader->GetString("server_name", "Server");
|
|
|
|
|
|
model->serverDescription = reader->GetString("server_description", "");
|
|
|
|
|
|
model->serverGreeting = reader->GetString("server_greeting", "");
|
|
|
|
|
|
model->masterServerUrl = reader->GetString("master_server_url", "");
|
|
|
|
|
|
model->providerName = reader->GetString("provider_name", "");
|
|
|
|
|
|
model->providerEmail = reader->GetString("provider_email", "");
|
|
|
|
|
|
model->providerWebsite = reader->GetString("provider_website", "");
|
|
|
|
|
|
model->knownKeysOnly = reader->GetBoolean("known_keys_only", false);
|
|
|
|
|
|
model->logChat = reader->GetBoolean("log_chat", false);
|
|
|
|
|
|
model->logServerActions = reader->GetBoolean("log_server_actions", false);
|
|
|
|
|
|
model->pauseServerIfNoClients = reader->GetBoolean("pause_server_if_no_clients", false);
|
|
|
|
|
|
model->desyncDebugging = reader->GetBoolean("desync_debugging", false);
|
2017-02-15 22:51:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void WriteNetwork(IIniWriter* writer)
|
2017-02-16 19:12:30 +00:00
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.network;
|
2017-02-16 23:22:26 +00:00
|
|
|
|
writer->WriteSection("network");
|
2025-10-07 20:14:37 +02:00
|
|
|
|
writer->WriteString("player_name", model->playerName);
|
|
|
|
|
|
writer->WriteInt32("default_port", model->defaultPort);
|
|
|
|
|
|
writer->WriteString("listen_address", model->listenAddress);
|
|
|
|
|
|
writer->WriteString("default_password", model->defaultPassword);
|
|
|
|
|
|
writer->WriteBoolean("stay_connected", model->stayConnected);
|
|
|
|
|
|
writer->WriteBoolean("advertise", model->advertise);
|
|
|
|
|
|
writer->WriteString("advertise_address", model->advertiseAddress);
|
|
|
|
|
|
writer->WriteInt32("maxplayers", model->maxplayers);
|
|
|
|
|
|
writer->WriteString("server_name", model->serverName);
|
|
|
|
|
|
writer->WriteString("server_description", model->serverDescription);
|
|
|
|
|
|
writer->WriteString("server_greeting", model->serverGreeting);
|
|
|
|
|
|
writer->WriteString("master_server_url", model->masterServerUrl);
|
|
|
|
|
|
writer->WriteString("provider_name", model->providerName);
|
|
|
|
|
|
writer->WriteString("provider_email", model->providerEmail);
|
|
|
|
|
|
writer->WriteString("provider_website", model->providerWebsite);
|
|
|
|
|
|
writer->WriteBoolean("known_keys_only", model->knownKeysOnly);
|
|
|
|
|
|
writer->WriteBoolean("log_chat", model->logChat);
|
|
|
|
|
|
writer->WriteBoolean("log_server_actions", model->logServerActions);
|
|
|
|
|
|
writer->WriteBoolean("pause_server_if_no_clients", model->pauseServerIfNoClients);
|
|
|
|
|
|
writer->WriteBoolean("desync_debugging", model->desyncDebugging);
|
2017-02-16 19:12:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void ReadNotifications(IIniReader* reader)
|
2017-02-15 22:51:39 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (reader->ReadSection("notifications"))
|
|
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.notifications;
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->parkAward = reader->GetBoolean("park_award", true);
|
|
|
|
|
|
model->parkMarketingCampaignFinished = reader->GetBoolean("park_marketing_campaign_finished", true);
|
|
|
|
|
|
model->parkWarnings = reader->GetBoolean("park_warnings", true);
|
|
|
|
|
|
model->parkRatingWarnings = reader->GetBoolean("park_rating_warnings", true);
|
|
|
|
|
|
model->rideBrokenDown = reader->GetBoolean("ride_broken_down", true);
|
|
|
|
|
|
model->rideCrashed = reader->GetBoolean("ride_crashed", true);
|
|
|
|
|
|
model->rideCasualties = reader->GetBoolean("ride_casualties", true);
|
|
|
|
|
|
model->rideWarnings = reader->GetBoolean("ride_warnings", true);
|
|
|
|
|
|
model->rideResearched = reader->GetBoolean("ride_researched", true);
|
|
|
|
|
|
model->rideStalledVehicles = reader->GetBoolean("ride_stalled_vehicles", true);
|
|
|
|
|
|
model->guestWarnings = reader->GetBoolean("guest_warnings", true);
|
|
|
|
|
|
model->guestLeftPark = reader->GetBoolean("guest_left_park", true);
|
|
|
|
|
|
model->guestQueuingForRide = reader->GetBoolean("guest_queuing_for_ride", true);
|
|
|
|
|
|
model->guestOnRide = reader->GetBoolean("guest_on_ride", true);
|
|
|
|
|
|
model->guestLeftRide = reader->GetBoolean("guest_left_ride", true);
|
|
|
|
|
|
model->guestBoughtItem = reader->GetBoolean("guest_bought_item", true);
|
|
|
|
|
|
model->guestUsedFacility = reader->GetBoolean("guest_used_facility", true);
|
|
|
|
|
|
model->guestDied = reader->GetBoolean("guest_died", true);
|
2017-02-15 22:51:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void WriteNotifications(IIniWriter* writer)
|
2017-02-16 19:12:30 +00:00
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.notifications;
|
2017-02-16 23:22:26 +00:00
|
|
|
|
writer->WriteSection("notifications");
|
2025-10-07 20:14:37 +02:00
|
|
|
|
writer->WriteBoolean("park_award", model->parkAward);
|
|
|
|
|
|
writer->WriteBoolean("park_marketing_campaign_finished", model->parkMarketingCampaignFinished);
|
|
|
|
|
|
writer->WriteBoolean("park_warnings", model->parkWarnings);
|
|
|
|
|
|
writer->WriteBoolean("park_rating_warnings", model->parkRatingWarnings);
|
|
|
|
|
|
writer->WriteBoolean("ride_broken_down", model->rideBrokenDown);
|
|
|
|
|
|
writer->WriteBoolean("ride_crashed", model->rideCrashed);
|
|
|
|
|
|
writer->WriteBoolean("ride_casualties", model->rideCasualties);
|
|
|
|
|
|
writer->WriteBoolean("ride_warnings", model->rideWarnings);
|
|
|
|
|
|
writer->WriteBoolean("ride_researched", model->rideResearched);
|
|
|
|
|
|
writer->WriteBoolean("ride_stalled_vehicles", model->rideStalledVehicles);
|
|
|
|
|
|
writer->WriteBoolean("guest_warnings", model->guestWarnings);
|
|
|
|
|
|
writer->WriteBoolean("guest_left_park", model->guestLeftPark);
|
|
|
|
|
|
writer->WriteBoolean("guest_queuing_for_ride", model->guestQueuingForRide);
|
|
|
|
|
|
writer->WriteBoolean("guest_on_ride", model->guestOnRide);
|
|
|
|
|
|
writer->WriteBoolean("guest_left_ride", model->guestLeftRide);
|
|
|
|
|
|
writer->WriteBoolean("guest_bought_item", model->guestBoughtItem);
|
|
|
|
|
|
writer->WriteBoolean("guest_used_facility", model->guestUsedFacility);
|
|
|
|
|
|
writer->WriteBoolean("guest_died", model->guestDied);
|
2017-02-16 19:12:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void ReadFont(IIniReader* reader)
|
2017-02-15 23:37:28 +00:00
|
|
|
|
{
|
|
|
|
|
|
if (reader->ReadSection("font"))
|
|
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.fonts;
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->fileName = reader->GetString("file_name", "");
|
|
|
|
|
|
model->fontName = reader->GetString("font_name", "");
|
|
|
|
|
|
model->offsetX = reader->GetInt32("x_offset", false);
|
|
|
|
|
|
model->offsetY = reader->GetInt32("y_offset", true);
|
|
|
|
|
|
model->sizeTiny = reader->GetInt32("size_tiny", true);
|
|
|
|
|
|
model->sizeSmall = reader->GetInt32("size_small", false);
|
|
|
|
|
|
model->sizeMedium = reader->GetInt32("size_medium", false);
|
|
|
|
|
|
model->sizeBig = reader->GetInt32("size_big", false);
|
|
|
|
|
|
model->heightTiny = reader->GetInt32("height_tiny", false);
|
|
|
|
|
|
model->heightSmall = reader->GetInt32("height_small", false);
|
|
|
|
|
|
model->heightMedium = reader->GetInt32("height_medium", false);
|
|
|
|
|
|
model->heightBig = reader->GetInt32("height_big", false);
|
|
|
|
|
|
model->enableHinting = reader->GetBoolean("enable_hinting", true);
|
|
|
|
|
|
model->hintingThreshold = reader->GetInt32("hinting_threshold", false);
|
2017-02-15 23:37:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-22 22:58:08 +02:00
|
|
|
|
static void WriteFont(IIniWriter* writer)
|
2017-02-16 19:12:30 +00:00
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.fonts;
|
2017-02-16 23:22:26 +00:00
|
|
|
|
writer->WriteSection("font");
|
2025-10-07 20:14:37 +02:00
|
|
|
|
writer->WriteString("file_name", model->fileName);
|
|
|
|
|
|
writer->WriteString("font_name", model->fontName);
|
|
|
|
|
|
writer->WriteInt32("x_offset", model->offsetX);
|
|
|
|
|
|
writer->WriteInt32("y_offset", model->offsetY);
|
|
|
|
|
|
writer->WriteInt32("size_tiny", model->sizeTiny);
|
|
|
|
|
|
writer->WriteInt32("size_small", model->sizeSmall);
|
|
|
|
|
|
writer->WriteInt32("size_medium", model->sizeMedium);
|
|
|
|
|
|
writer->WriteInt32("size_big", model->sizeBig);
|
|
|
|
|
|
writer->WriteInt32("height_tiny", model->heightTiny);
|
|
|
|
|
|
writer->WriteInt32("height_small", model->heightSmall);
|
|
|
|
|
|
writer->WriteInt32("height_medium", model->heightMedium);
|
|
|
|
|
|
writer->WriteInt32("height_big", model->heightBig);
|
|
|
|
|
|
writer->WriteBoolean("enable_hinting", model->enableHinting);
|
|
|
|
|
|
writer->WriteInt32("hinting_threshold", model->hintingThreshold);
|
2017-02-16 19:12:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-02-10 18:44:42 +00:00
|
|
|
|
static void ReadPlugin(IIniReader* reader)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (reader->ReadSection("plugin"))
|
|
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.plugin;
|
2025-10-07 20:14:37 +02:00
|
|
|
|
model->enableHotReloading = reader->GetBoolean("enable_hot_reloading", false);
|
|
|
|
|
|
model->allowedHosts = reader->GetString("allowed_hosts", "");
|
2020-02-10 18:44:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void WritePlugin(IIniWriter* writer)
|
|
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto model = &_config.plugin;
|
2020-02-10 18:44:42 +00:00
|
|
|
|
writer->WriteSection("plugin");
|
2025-10-07 20:14:37 +02:00
|
|
|
|
writer->WriteBoolean("enable_hot_reloading", model->enableHotReloading);
|
|
|
|
|
|
writer->WriteString("allowed_hosts", model->allowedHosts);
|
2020-02-10 18:44:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-10 12:10:21 +02:00
|
|
|
|
bool SetDefaults()
|
2017-02-18 15:16:08 +00:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2021-08-20 23:38:15 +02:00
|
|
|
|
auto reader = CreateDefaultIniReader();
|
2017-02-18 15:16:08 +00:00
|
|
|
|
ReadGeneral(reader.get());
|
|
|
|
|
|
ReadInterface(reader.get());
|
|
|
|
|
|
ReadSound(reader.get());
|
|
|
|
|
|
ReadNetwork(reader.get());
|
|
|
|
|
|
ReadNotifications(reader.get());
|
|
|
|
|
|
ReadFont(reader.get());
|
2020-02-10 18:44:42 +00:00
|
|
|
|
ReadPlugin(reader.get());
|
2017-02-18 15:16:08 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2018-06-22 22:58:08 +02:00
|
|
|
|
catch (const std::exception&)
|
2017-02-18 15:16:08 +00:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-29 03:57:31 +01:00
|
|
|
|
static bool ReadFile(u8string_view path)
|
2017-02-15 20:52:50 +00:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2025-03-25 18:23:36 +01:00
|
|
|
|
auto fs = FileStream(path, FileMode::open);
|
2021-08-20 23:38:15 +02:00
|
|
|
|
auto reader = CreateIniReader(&fs);
|
2017-02-15 20:52:50 +00:00
|
|
|
|
ReadGeneral(reader.get());
|
2017-02-15 23:37:28 +00:00
|
|
|
|
ReadInterface(reader.get());
|
2017-02-15 20:52:50 +00:00
|
|
|
|
ReadSound(reader.get());
|
2017-02-15 22:51:39 +00:00
|
|
|
|
ReadNetwork(reader.get());
|
|
|
|
|
|
ReadNotifications(reader.get());
|
2017-02-15 23:37:28 +00:00
|
|
|
|
ReadFont(reader.get());
|
2020-02-10 18:44:42 +00:00
|
|
|
|
ReadPlugin(reader.get());
|
2017-02-15 20:52:50 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2018-06-22 22:58:08 +02:00
|
|
|
|
catch (const std::exception&)
|
2017-02-15 20:52:50 +00:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-02-16 19:12:30 +00:00
|
|
|
|
|
2022-01-29 03:57:31 +01:00
|
|
|
|
static bool WriteFile(u8string_view path)
|
2017-02-16 19:12:30 +00:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2018-02-10 21:37:06 +00:00
|
|
|
|
auto directory = Path::GetDirectory(path);
|
|
|
|
|
|
Path::CreateDirectory(directory);
|
|
|
|
|
|
|
2025-03-25 18:23:36 +01:00
|
|
|
|
auto fs = FileStream(path, FileMode::write);
|
2021-08-20 23:38:15 +02:00
|
|
|
|
auto writer = CreateIniWriter(&fs);
|
2017-02-16 19:12:30 +00:00
|
|
|
|
WriteGeneral(writer.get());
|
|
|
|
|
|
WriteInterface(writer.get());
|
|
|
|
|
|
WriteSound(writer.get());
|
|
|
|
|
|
WriteNetwork(writer.get());
|
|
|
|
|
|
WriteNotifications(writer.get());
|
|
|
|
|
|
WriteFont(writer.get());
|
2020-02-10 18:44:42 +00:00
|
|
|
|
WritePlugin(writer.get());
|
2017-02-16 19:12:30 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2018-06-22 22:58:08 +02:00
|
|
|
|
catch (const std::exception& ex)
|
2017-02-16 19:12:30 +00:00
|
|
|
|
{
|
2022-01-29 03:57:31 +01:00
|
|
|
|
Console::WriteLine("Error saving to '%s'", u8string(path).c_str());
|
2018-01-02 19:23:22 +00:00
|
|
|
|
Console::WriteLine(ex.what());
|
2017-02-16 19:12:30 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-02-18 15:16:08 +00:00
|
|
|
|
|
2018-08-13 15:50:45 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* Attempts to find the RCT1 installation directory.
|
|
|
|
|
|
* @returns Path to RCT1, if found. Empty string otherwise.
|
|
|
|
|
|
*/
|
2022-01-29 03:57:31 +01:00
|
|
|
|
static u8string FindRCT1Path()
|
2018-08-13 15:50:45 +02:00
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
|
LOG_VERBOSE("config_find_rct1_path(...)");
|
2018-08-13 15:50:45 +02:00
|
|
|
|
|
2024-09-29 12:06:05 +01:00
|
|
|
|
static std::vector<u8string_view> searchLocations = Platform::GetSearchablePathsRCT1();
|
2018-08-13 15:50:45 +02:00
|
|
|
|
|
2022-01-29 03:57:31 +01:00
|
|
|
|
for (const auto& location : searchLocations)
|
2018-08-13 15:50:45 +02:00
|
|
|
|
{
|
2020-04-25 15:36:44 +02:00
|
|
|
|
if (RCT1DataPresentAtLocation(location))
|
2018-08-13 15:50:45 +02:00
|
|
|
|
{
|
2022-01-29 03:57:31 +01:00
|
|
|
|
return u8string(location);
|
2018-08-13 15:50:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-10 13:28:23 +01:00
|
|
|
|
auto steamPath = Platform::GetSteamPath();
|
|
|
|
|
|
if (!steamPath.empty())
|
2018-08-13 15:50:45 +02:00
|
|
|
|
{
|
2022-02-18 21:57:00 +01:00
|
|
|
|
std::string location = Path::Combine(steamPath, Platform::GetRCT1SteamDir());
|
2022-01-29 03:57:31 +01:00
|
|
|
|
if (RCT1DataPresentAtLocation(location))
|
2018-08-13 15:50:45 +02:00
|
|
|
|
{
|
|
|
|
|
|
return location;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-09-30 23:37:50 +02:00
|
|
|
|
auto exePath = Path::GetDirectory(Platform::GetCurrentExecutablePath());
|
2022-01-29 03:57:31 +01:00
|
|
|
|
if (RCT1DataPresentAtLocation(exePath))
|
2018-08-13 15:50:45 +02:00
|
|
|
|
{
|
2020-09-30 23:37:50 +02:00
|
|
|
|
return exePath;
|
2018-08-13 15:50:45 +02:00
|
|
|
|
}
|
2022-01-29 03:57:31 +01:00
|
|
|
|
return {};
|
2018-08-13 15:50:45 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-18 15:16:08 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* Attempts to find the RCT2 installation directory.
|
|
|
|
|
|
* This should be created from some other resource when OpenRCT2 grows.
|
2018-06-06 22:36:04 +02:00
|
|
|
|
* @returns Path to RCT2, if found. Empty string otherwise.
|
2017-02-18 15:16:08 +00:00
|
|
|
|
*/
|
2022-01-29 03:57:31 +01:00
|
|
|
|
static u8string FindRCT2Path()
|
2017-02-18 15:16:08 +00:00
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
|
LOG_VERBOSE("config_find_rct2_path(...)");
|
2017-02-18 15:16:08 +00:00
|
|
|
|
|
2024-09-29 12:06:05 +01:00
|
|
|
|
static std::vector<u8string_view> searchLocations = Platform::GetSearchablePathsRCT2();
|
2017-02-18 15:16:08 +00:00
|
|
|
|
|
2022-01-29 03:57:31 +01:00
|
|
|
|
for (const auto& location : searchLocations)
|
2017-02-18 15:16:08 +00:00
|
|
|
|
{
|
2022-01-05 14:17:19 +01:00
|
|
|
|
if (Platform::OriginalGameDataExists(location))
|
2017-02-18 15:16:08 +00:00
|
|
|
|
{
|
2022-01-29 03:57:31 +01:00
|
|
|
|
return u8string(location);
|
2017-02-18 15:16:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-10-24 12:36:40 -04:00
|
|
|
|
|
2022-01-10 13:28:23 +01:00
|
|
|
|
auto steamPath = Platform::GetSteamPath();
|
|
|
|
|
|
if (!steamPath.empty())
|
2017-10-24 12:36:40 -04:00
|
|
|
|
{
|
2022-02-18 21:57:00 +01:00
|
|
|
|
std::string location = Path::Combine(steamPath, Platform::GetRCT2SteamDir());
|
2022-01-05 14:17:19 +01:00
|
|
|
|
if (Platform::OriginalGameDataExists(location))
|
2017-10-24 12:36:40 -04:00
|
|
|
|
{
|
|
|
|
|
|
return location;
|
|
|
|
|
|
}
|
2025-05-18 21:32:48 +02:00
|
|
|
|
|
|
|
|
|
|
std::string location2 = Path::Combine(steamPath, Platform::GetRCTClassicSteamDir());
|
|
|
|
|
|
if (Platform::OriginalGameDataExists(location2))
|
|
|
|
|
|
{
|
|
|
|
|
|
return location2;
|
|
|
|
|
|
}
|
2017-10-24 12:36:40 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-26 12:06:31 +01:00
|
|
|
|
auto discordPath = Platform::GetFolderPath(SpecialFolder::rct2Discord);
|
2022-01-05 14:17:19 +01:00
|
|
|
|
if (!discordPath.empty() && Platform::OriginalGameDataExists(discordPath))
|
2018-10-25 10:57:19 +01:00
|
|
|
|
{
|
|
|
|
|
|
return discordPath;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-09-30 23:37:50 +02:00
|
|
|
|
auto exePath = Path::GetDirectory(Platform::GetCurrentExecutablePath());
|
2022-01-05 14:17:19 +01:00
|
|
|
|
if (Platform::OriginalGameDataExists(exePath))
|
2017-02-18 15:16:08 +00:00
|
|
|
|
{
|
2020-09-30 23:37:50 +02:00
|
|
|
|
return exePath;
|
2017-02-18 15:16:08 +00:00
|
|
|
|
}
|
2022-01-29 03:57:31 +01:00
|
|
|
|
return {};
|
2017-02-18 15:16:08 +00:00
|
|
|
|
}
|
2020-10-21 10:53:22 -07:00
|
|
|
|
|
2024-10-30 12:47:38 +01:00
|
|
|
|
static u8string SelectGogInstaller()
|
2021-01-03 18:40:02 +01:00
|
|
|
|
{
|
2022-01-28 23:50:24 +01:00
|
|
|
|
FileDialogDesc desc{};
|
|
|
|
|
|
desc.Type = FileDialogType::Open;
|
2023-01-17 00:12:35 +01:00
|
|
|
|
desc.Title = LanguageGetString(STR_SELECT_GOG_INSTALLER);
|
|
|
|
|
|
desc.Filters.emplace_back(LanguageGetString(STR_GOG_INSTALLER), "*.exe");
|
|
|
|
|
|
desc.Filters.emplace_back(LanguageGetString(STR_ALL_FILES), "*");
|
2021-01-03 18:40:02 +01:00
|
|
|
|
|
2025-03-26 12:06:31 +01:00
|
|
|
|
const auto userHomePath = Platform::GetFolderPath(SpecialFolder::userHome);
|
2022-04-25 16:32:04 +03:00
|
|
|
|
desc.InitialDirectory = userHomePath;
|
2021-01-03 18:40:02 +01:00
|
|
|
|
|
2024-10-30 12:47:38 +01:00
|
|
|
|
return ContextOpenCommonFileDialog(desc);
|
2021-01-03 18:40:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-12 23:38:23 +02:00
|
|
|
|
static bool ExtractGogInstaller(const u8string& installerPath, const u8string& targetPath)
|
2020-10-21 10:53:22 -07:00
|
|
|
|
{
|
|
|
|
|
|
std::string path;
|
|
|
|
|
|
std::string output;
|
|
|
|
|
|
|
|
|
|
|
|
if (!Platform::FindApp("innoextract", &path))
|
|
|
|
|
|
{
|
2023-01-17 13:24:51 +01:00
|
|
|
|
LOG_ERROR("Please install innoextract to extract files from GOG.");
|
2020-10-21 10:53:22 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2025-10-29 08:50:49 +01:00
|
|
|
|
const char* args[] = { path.c_str(), installerPath.c_str(), "--exclude-temp", "--silent",
|
|
|
|
|
|
"--output-dir", targetPath.c_str(), nullptr };
|
|
|
|
|
|
int32_t exit_status = Platform::Execute(args, &output);
|
2023-01-17 13:24:51 +01:00
|
|
|
|
LOG_INFO("Exit status %d", exit_status);
|
2020-10-21 10:53:22 -07:00
|
|
|
|
return exit_status == 0;
|
|
|
|
|
|
}
|
2017-02-15 20:52:50 +00:00
|
|
|
|
|
2024-05-10 12:10:21 +02:00
|
|
|
|
bool OpenFromPath(u8string_view path)
|
2017-02-18 15:16:08 +00:00
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
if (!File::Exists(path))
|
2017-06-27 13:23:16 +01:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-10 12:10:21 +02:00
|
|
|
|
auto result = ReadFile(path);
|
|
|
|
|
|
if (result)
|
2020-11-08 14:30:56 +01:00
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
CurrencyLoadCustomCurrencyConfig();
|
2020-11-08 14:30:56 +01:00
|
|
|
|
}
|
2024-05-10 12:10:21 +02:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2020-11-08 14:30:56 +01:00
|
|
|
|
|
2024-05-10 12:10:21 +02:00
|
|
|
|
u8string GetDefaultPath()
|
|
|
|
|
|
{
|
2025-05-15 22:46:06 +03:00
|
|
|
|
auto& env = GetContext()->GetPlatformEnvironment();
|
|
|
|
|
|
return Path::Combine(env.GetDirectoryPath(DirBase::user), u8"config.ini");
|
2024-05-10 12:10:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool SaveToPath(u8string_view path)
|
|
|
|
|
|
{
|
|
|
|
|
|
return WriteFile(path);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Save()
|
|
|
|
|
|
{
|
|
|
|
|
|
auto path = GetDefaultPath();
|
|
|
|
|
|
return SaveToPath(path);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool FindOrBrowseInstallDirectory()
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string path = FindRCT2Path();
|
|
|
|
|
|
if (!path.empty())
|
2017-11-28 21:54:25 +00:00
|
|
|
|
{
|
2025-10-07 20:14:37 +02:00
|
|
|
|
Get().general.rct2Path = path;
|
2024-05-10 12:10:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (gOpenRCT2Headless)
|
2017-02-18 15:16:08 +00:00
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2017-06-03 22:13:20 +01:00
|
|
|
|
|
2025-05-15 22:46:06 +03:00
|
|
|
|
auto& uiContext = GetContext()->GetUiContext();
|
|
|
|
|
|
if (!uiContext.HasFilePicker())
|
2024-05-10 12:10:21 +02:00
|
|
|
|
{
|
2025-05-15 22:46:06 +03:00
|
|
|
|
uiContext.ShowMessageBox(LanguageGetString(STR_NEEDS_RCT2_FILES_MANUAL));
|
2024-05-10 12:10:21 +02:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2020-10-21 10:53:22 -07:00
|
|
|
|
|
2024-05-10 12:10:21 +02:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
const char* g1DatPath = PATH_SEPARATOR "Data" PATH_SEPARATOR "g1.dat";
|
|
|
|
|
|
while (true)
|
2020-10-21 10:53:22 -07:00
|
|
|
|
{
|
2025-05-15 22:46:06 +03:00
|
|
|
|
uiContext.ShowMessageBox(LanguageGetString(STR_NEEDS_RCT2_FILES));
|
2024-05-10 12:10:21 +02:00
|
|
|
|
std::string gog = LanguageGetString(STR_OWN_ON_GOG);
|
|
|
|
|
|
std::string hdd = LanguageGetString(STR_INSTALLED_ON_HDD);
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> options;
|
|
|
|
|
|
std::string chosenOption;
|
|
|
|
|
|
|
2025-05-15 22:46:06 +03:00
|
|
|
|
if (uiContext.HasMenuSupport())
|
2020-10-21 10:53:22 -07:00
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
options.push_back(hdd);
|
|
|
|
|
|
options.push_back(gog);
|
2025-05-15 22:46:06 +03:00
|
|
|
|
int optionIndex = uiContext.ShowMenuDialog(
|
2024-05-10 12:10:21 +02:00
|
|
|
|
options, LanguageGetString(STR_OPENRCT2_SETUP), LanguageGetString(STR_WHICH_APPLIES_BEST));
|
|
|
|
|
|
if (optionIndex < 0 || static_cast<uint32_t>(optionIndex) >= options.size())
|
|
|
|
|
|
{
|
|
|
|
|
|
// graceful fallback if app errors or user exits out of window
|
|
|
|
|
|
chosenOption = hdd;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
chosenOption = options[optionIndex];
|
|
|
|
|
|
}
|
2020-10-21 10:53:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2024-05-10 12:10:21 +02:00
|
|
|
|
chosenOption = hdd;
|
2020-10-21 10:53:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-30 21:30:56 +02:00
|
|
|
|
std::vector<std::string> possibleInstallPaths{};
|
2024-05-10 12:10:21 +02:00
|
|
|
|
if (chosenOption == hdd)
|
2020-10-21 10:53:22 -07:00
|
|
|
|
{
|
2025-05-15 22:46:06 +03:00
|
|
|
|
possibleInstallPaths.emplace_back(uiContext.ShowDirectoryDialog(LanguageGetString(STR_PICK_RCT2_DIR)));
|
2024-05-10 12:10:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
else if (chosenOption == gog)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Check if innoextract is installed. If not, prompt the user to install it.
|
|
|
|
|
|
std::string dummy;
|
|
|
|
|
|
if (!Platform::FindApp("innoextract", &dummy))
|
2021-01-03 18:40:02 +01:00
|
|
|
|
{
|
2025-05-15 22:46:06 +03:00
|
|
|
|
uiContext.ShowMessageBox(LanguageGetString(STR_INSTALL_INNOEXTRACT));
|
2021-01-03 18:40:02 +01:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-10 12:10:21 +02:00
|
|
|
|
const std::string dest = Path::Combine(
|
2025-05-15 22:46:06 +03:00
|
|
|
|
GetContext()->GetPlatformEnvironment().GetDirectoryPath(DirBase::config), "rct2");
|
2021-01-03 18:40:02 +01:00
|
|
|
|
|
2024-05-10 12:10:21 +02:00
|
|
|
|
while (true)
|
|
|
|
|
|
{
|
2025-05-15 22:46:06 +03:00
|
|
|
|
uiContext.ShowMessageBox(LanguageGetString(STR_PLEASE_SELECT_GOG_INSTALLER));
|
2024-10-30 12:47:38 +01:00
|
|
|
|
auto gogPath = SelectGogInstaller();
|
|
|
|
|
|
if (gogPath.empty())
|
2024-05-10 12:10:21 +02:00
|
|
|
|
{
|
|
|
|
|
|
// The user clicked "Cancel", so stop trying.
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2021-01-03 18:40:02 +01:00
|
|
|
|
|
2025-05-15 22:46:06 +03:00
|
|
|
|
uiContext.ShowMessageBox(LanguageGetString(STR_THIS_WILL_TAKE_A_FEW_MINUTES));
|
2024-05-10 12:10:21 +02:00
|
|
|
|
|
|
|
|
|
|
if (ExtractGogInstaller(gogPath, dest))
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
2025-05-15 22:46:06 +03:00
|
|
|
|
uiContext.ShowMessageBox(LanguageGetString(STR_NOT_THE_GOG_INSTALLER));
|
2024-05-10 12:10:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-30 21:30:56 +02:00
|
|
|
|
// New installer extracts to ‘dest’, old installer installs in ‘dest/app’.
|
|
|
|
|
|
possibleInstallPaths.emplace_back(dest);
|
|
|
|
|
|
possibleInstallPaths.emplace_back(Path::Combine(dest, u8"app"));
|
2024-05-10 12:10:21 +02:00
|
|
|
|
}
|
2025-03-30 21:30:56 +02:00
|
|
|
|
if (possibleInstallPaths.empty())
|
2024-05-10 12:10:21 +02:00
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-30 21:30:56 +02:00
|
|
|
|
for (const auto& possiblePath : possibleInstallPaths)
|
2024-05-10 12:10:21 +02:00
|
|
|
|
{
|
2025-03-30 21:30:56 +02:00
|
|
|
|
if (Platform::OriginalGameDataExists(possiblePath))
|
|
|
|
|
|
{
|
2025-10-07 20:14:37 +02:00
|
|
|
|
Get().general.rct2Path = possiblePath;
|
2025-03-30 21:30:56 +02:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2020-10-21 10:53:22 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-15 22:46:06 +03:00
|
|
|
|
uiContext.ShowMessageBox(FormatStringIDLegacy(STR_COULD_NOT_FIND_AT_PATH, &g1DatPath));
|
2020-10-21 10:53:22 -07:00
|
|
|
|
}
|
2024-05-10 12:10:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
catch (const std::exception& ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console::Error::WriteLine(ex.what());
|
|
|
|
|
|
return false;
|
2017-02-18 15:16:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-05-10 12:10:21 +02:00
|
|
|
|
// While we're at it, also check if the player has RCT1
|
|
|
|
|
|
std::string rct1Path = FindRCT1Path();
|
|
|
|
|
|
if (!rct1Path.empty())
|
2018-02-01 18:49:14 +01:00
|
|
|
|
{
|
2025-11-07 20:08:10 +01:00
|
|
|
|
Get().general.rct1Path = std::move(rct1Path);
|
2018-02-01 18:49:14 +01:00
|
|
|
|
}
|
2018-08-13 15:50:45 +02:00
|
|
|
|
|
2024-05-10 12:10:21 +02:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
} // namespace OpenRCT2::Config
|