diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 77a3676dab..53f5ecec55 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -16,6 +16,8 @@ #include #include "../core/Exception.hpp" +#include "../interface/window.h" +#include "../localisation/language.h" #include "../network/network.h" #include "IniReader.h" @@ -26,21 +28,161 @@ extern "C" namespace Config { - static auto Enum_MeasurementFormat = ConfigEnum( + static auto Enum_MeasurementFormat = ConfigEnum( + { + ConfigEnumEntry("IMPERIAL", MEASUREMENT_FORMAT_IMPERIAL), + ConfigEnumEntry("METRIC", MEASUREMENT_FORMAT_METRIC), + ConfigEnumEntry("SI", MEASUREMENT_FORMAT_SI), + }); + + static auto Enum_Currency = ConfigEnum( + { + ConfigEnumEntry("IMPERIAL", MEASUREMENT_FORMAT_IMPERIAL), + ConfigEnumEntry("METRIC", MEASUREMENT_FORMAT_METRIC), + ConfigEnumEntry("SI", MEASUREMENT_FORMAT_SI), + ConfigEnumEntry("GBP", CURRENCY_POUNDS), + ConfigEnumEntry("USD", CURRENCY_DOLLARS), + ConfigEnumEntry("FRF", CURRENCY_FRANC), + ConfigEnumEntry("DEM", CURRENCY_DEUTSCHMARK), + ConfigEnumEntry("JPY", CURRENCY_YEN), + ConfigEnumEntry("ESP", CURRENCY_PESETA), + ConfigEnumEntry("ITL", CURRENCY_LIRA), + ConfigEnumEntry("NLG", CURRENCY_GUILDERS), + ConfigEnumEntry("SEK", CURRENCY_KRONA), + ConfigEnumEntry("EUR", CURRENCY_EUROS), + ConfigEnumEntry("KRW", CURRENCY_WON), + ConfigEnumEntry("RUB", CURRENCY_ROUBLE), + ConfigEnumEntry("CZK", CURRENCY_CZECH_KORUNA), + ConfigEnumEntry("HKD", CURRENCY_HKD), + ConfigEnumEntry("TWD", CURRENCY_TWD), + ConfigEnumEntry("CNY", CURRENCY_YUAN), + }); + + static auto Enum_CurrencySymbolAffix = ConfigEnum( + { + ConfigEnumEntry("PREFIX", CURRENCY_PREFIX), + ConfigEnumEntry("SUFFIX", CURRENCY_SUFFIX), + }); + + static auto Enum_CurrencySymbolAffix = ConfigEnum( + { + ConfigEnumEntry("PREFIX", CURRENCY_PREFIX), + ConfigEnumEntry("SUFFIX", CURRENCY_SUFFIX), + }); + + static auto Enum_DateFormat = ConfigEnum( + { + ConfigEnumEntry("DD/MM/YY", DATE_FORMAT_DMY), + ConfigEnumEntry("MM/DD/YY", DATE_FORMAT_MDY), + ConfigEnumEntry("YY/MM/DD", DATE_FORMAT_YMD), + ConfigEnumEntry("YY/DD/MM", DATE_FORMAT_YDM), + }); + + static auto Enum_DrawingEngine = ConfigEnum( + { + ConfigEnumEntry("SOFTWARE", DRAWING_ENGINE_SOFTWARE), + ConfigEnumEntry("SOFTWARE_HWD", DRAWING_ENGINE_SOFTWARE_WITH_HARDWARE_DISPLAY), + ConfigEnumEntry("OPENGL", DRAWING_ENGINE_OPENGL), + }); + + static auto Enum_Temperature = ConfigEnum( + { + ConfigEnumEntry("CELSIUS", TEMPERATURE_FORMAT_C), + ConfigEnumEntry("FAHRENHEIT", TEMPERATURE_FORMAT_F), + }); + + static auto Enum_LanguageEnum = ConfigEnum( { - ConfigEnumEntry("IMPERIAL", MEASUREMENT_FORMAT_IMPERIAL), - ConfigEnumEntry("METRIC", MEASUREMENT_FORMAT_METRIC), - ConfigEnumEntry("SI", MEASUREMENT_FORMAT_SI), }); static void ReadGeneral(IIniReader * reader) { if (reader->ReadSection("general")) { - gConfigGeneral.always_show_gridlines = reader->GetBoolean("always_show_gridlines", false); - gConfigGeneral.window_width = reader->GetSint32("window_width", -1); - gConfigGeneral.window_height = reader->GetSint32("window_height", -1); - gConfigGeneral.measurement_format = reader->GetEnum("measurement_format", MEASUREMENT_FORMAT_METRIC, Enum_MeasurementFormat); + auto model = &gConfigGeneral; + model->always_show_gridlines = reader->GetBoolean("always_show_gridlines", false); + model->autosave_frequency = reader->GetSint32("autosave", AUTOSAVE_EVERY_5MINUTES); + model->confirmation_prompt = reader->GetBoolean("confirmation_prompt", false); + model->construction_marker_colour = reader->GetBoolean("construction_marker_colour", false); + model->currency_format = reader->GetEnum("currency_format", CURRENCY_POUNDS, Enum_Currency); + model->custom_currency_rate = reader->GetSint32("custom_currency_rate", 10); + model->custom_currency_affix = reader->GetEnum("custom_currency_affix", CURRENCY_SUFFIX, Enum_CurrencySymbolAffix); + model->custom_currency_symbol = reader->GetCString("custom_currency_symbol", "Ctm"); + model->edge_scrolling = reader->GetBoolean("edge_scrolling", true); + model->fullscreen_mode = reader->GetSint32("fullscreen_mode", 0); + model->fullscreen_height = reader->GetSint32("fullscreen_height", -1); + model->fullscreen_width = reader->GetSint32("fullscreen_width", -1); + model->rct1_path = reader->GetCString("rct1_path", nullptr); + model->rct2_path = reader->GetCString("game_path", nullptr); + model->landscape_smoothing = reader->GetBoolean("landscape_smoothing", true); + model->language = reader->GetEnum("language", LANGUAGE_ENGLISH_UK, Enum_LanguageEnum); + model->measurement_format = reader->GetEnum("measurement_format", MEASUREMENT_FORMAT_METRIC, Enum_MeasurementFormat); + model->play_intro = reader->GetBoolean("play_intro", false); + model->save_plugin_data = reader->GetBoolean("save_plugin_data", true); + model->debugging_tools = reader->GetBoolean("debugging_tools", false); + model->show_height_as_units = reader->GetBoolean("show_height_as_units", false); + model->temperature_format = reader->GetEnum("temperature_format", TEMPERATURE_FORMAT_C, Enum_Temperature); + model->window_height = reader->GetSint32("window_height", -1); + model->window_snap_proximity = reader->GetSint32("window_snap_proximity", 5); + model->window_width = reader->GetSint32("window_width", -1); + model->drawing_engine = reader->GetEnum("drawing_engine", DRAWING_ENGINE_SOFTWARE, Enum_DrawingEngine); + model->uncap_fps = reader->GetBoolean("uncap_fps", false); + + // Default config setting is false until ghost trains are implemented #4540 + model->test_unfinished_tracks = reader->GetBoolean("test_unfinished_tracks", false); + + model->no_test_crashes = reader->GetBoolean("no_test_crashes", false); + model->date_format = reader->GetEnum("date_format", DATE_FORMAT_DMY, Enum_DateFormat); + model->auto_staff_placement = reader->GetBoolean("auto_staff", true); + model->handymen_mow_default = reader->GetBoolean("handymen_mow_default", false); + model->default_inspection_interval = reader->GetSint32("default_inspection_interval", 2); + model->last_run_version = reader->GetCString("last_run_version", nullptr); + model->invert_viewport_drag = reader->GetBoolean("invert_viewport_drag", false); + model->load_save_sort = reader->GetSint32("load_save_sort", SORT_NAME_ASCENDING); + model->minimize_fullscreen_focus_loss = reader->GetBoolean("minimize_fullscreen_focus_loss", true); + + //Default config setting is false until the games canvas can be seperated from the effect + model->day_night_cycle = reader->GetBoolean("day_night_cycle", false); + + model->enable_light_fx = reader->GetBoolean("enable_light_fx", false); + model->upper_case_banners = reader->GetBoolean("upper_case_banners", false); + model->disable_lightning_effect = reader->GetBoolean("disable_lightning_effect", false); + model->allow_loading_with_incorrect_checksum = reader->GetBoolean("allow_loading_with_incorrect_checksum", true); + model->steam_overlay_pause = reader->GetBoolean("steam_overlay_pause", true); + model->window_scale = reader->GetFloat("window_scale", 1.0f); + model->scale_quality = reader->GetSint32("scale_quality", 1); + model->use_nn_at_integer_scales = reader->GetBoolean("use_nn_at_integer_scales", true); + model->show_fps = reader->GetBoolean("show_fps", false); + model->trap_cursor = reader->GetBoolean("trap_cursor", false); + model->auto_open_shops = reader->GetBoolean("auto_open_shops", false); + model->scenario_select_mode = reader->GetSint32("scenario_select_mode", SCENARIO_SELECT_MODE_ORIGIN); + model->scenario_unlocking_enabled = reader->GetBoolean("scenario_unlocking_enabled", true); + model->scenario_hide_mega_park = reader->GetBoolean("scenario_hide_mega_park", true); + model->last_save_game_directory = reader->GetCString("last_game_directory", nullptr); + model->last_save_landscape_directory = reader->GetCString("last_landscape_directory", nullptr); + model->last_save_scenario_directory = reader->GetCString("last_scenario_directory", nullptr); + model->last_save_track_directory = reader->GetCString("last_track_directory", nullptr); + model->window_limit = reader->GetBoolean("window_limit", WINDOW_LIMIT_MAX); + model->zoom_to_cursor = reader->GetBoolean("zoom_to_cursor", true); + model->render_weather_effects = reader->GetBoolean("render_weather_effects", true); + model->render_weather_gloom = reader->GetBoolean("render_weather_gloom", true); + } + } + + static void ReadInterface(IIniReader * reader) + { + if (reader->ReadSection("interface")) + { + auto model = &gConfigInterface; + model->toolbar_show_finances = reader->GetBoolean("toolbar_show_finances", true); + model->toolbar_show_research = reader->GetBoolean("toolbar_show_research", true); + model->toolbar_show_cheats = reader->GetBoolean("toolbar_show_cheats", false); + model->toolbar_show_news = reader->GetBoolean("toolbar_show_news", false); + model->select_by_track_type = reader->GetBoolean("select_by_track_type", false); + model->console_small_font = reader->GetBoolean("console_small_font", false); + model->current_theme_preset = reader->GetCString("current_theme", "*RCT2"); + model->current_title_sequence_preset = reader->GetCString("current_title_sequence", "*OPENRCT2"); + model->object_selection_filter_flags = reader->GetSint32("object_selection_filter_flags", 0x7EF); } } @@ -122,16 +264,38 @@ namespace Config } } + static void ReadFont(IIniReader * reader) + { + if (reader->ReadSection("font")) + { + auto model = &gConfigFonts; + model->file_name = reader->GetCString("file_name", nullptr); + model->font_name = reader->GetCString("font_name", nullptr); + model->x_offset = reader->GetSint32("x_offset", false); + model->y_offset = reader->GetSint32("y_offset", true); + model->size_tiny = reader->GetSint32("size_tiny", true); + model->size_small = reader->GetSint32("size_small", false); + model->size_medium = reader->GetSint32("size_medium", false); + model->size_big = reader->GetSint32("size_big", false); + model->height_tiny = reader->GetSint32("height_tiny", false); + model->height_small = reader->GetSint32("height_small", false); + model->height_medium = reader->GetSint32("height_medium", false); + model->height_big = reader->GetSint32("height_big", false); + } + } + static bool ReadFile(const std::string &path) { try { auto reader = std::unique_ptr(CreateIniReader(path)); ReadGeneral(reader.get()); + ReadInterface(reader.get()); ReadSound(reader.get()); ReadNetwork(reader.get()); ReadNotifications(reader.get()); ReadTwitch(reader.get()); + ReadFont(reader.get()); return true; } catch (const Exception &) diff --git a/src/openrct2/config/IniReader.cpp b/src/openrct2/config/IniReader.cpp index a04a1b7fd5..dc6b1cec1d 100644 --- a/src/openrct2/config/IniReader.cpp +++ b/src/openrct2/config/IniReader.cpp @@ -116,6 +116,18 @@ public: return std::stoi(value); } + float GetFloat(const std::string &name, float defaultValue) const override + { + auto it = _values.find(name); + if (it == _values.end()) + { + return defaultValue; + } + + std::string value = it->second; + return std::stof(value); + } + std::string GetString(const std::string &name, const std::string &defaultValue) const override { auto it = _values.find(name); diff --git a/src/openrct2/config/IniReader.h b/src/openrct2/config/IniReader.h index 85dfc1b31d..5dcd2e7fca 100644 --- a/src/openrct2/config/IniReader.h +++ b/src/openrct2/config/IniReader.h @@ -26,6 +26,7 @@ interface IIniReader virtual bool GetBoolean(const std::string &name, bool defaultValue) const abstract; virtual sint32 GetSint32(const std::string &name, sint32 defaultValue) const abstract; + virtual float GetFloat(const std::string &name, float defaultValue) const abstract; virtual std::string GetString(const std::string &name, const std::string &defaultValue) const abstract; virtual bool TryGetString(const std::string &name, std::string * outValue) const abstract;