static void custom_currency_window_text_input([[maybe_unused]] struct rct_window * w, rct_widgetindex widgetIndex, char * text) { if (text == nullptr) return; sint32 rate; char* end; switch(widgetIndex){ case WIDX_SYMBOL_TEXT: safe_strcpy( CurrencyDescriptors[CURRENCY_CUSTOM].symbol_unicode, text, CURRENCY_SYMBOL_MAX_SIZE ); safe_strcpy( gConfigGeneral.custom_currency_symbol, CurrencyDescriptors[CURRENCY_CUSTOM].symbol_unicode, CURRENCY_SYMBOL_MAX_SIZE ); config_save_default(); window_invalidate_all(); break; case WIDX_RATE: rate = strtol(text, &end, 10); if (*end == '\0') { CurrencyDescriptors[CURRENCY_CUSTOM].rate = rate; gConfigGeneral.custom_currency_rate = CurrencyDescriptors[CURRENCY_CUSTOM].rate; config_save_default(); window_invalidate_all(); } break; } }
IPlatformEnvironment * SetupEnvironment() { utf8 userPath[MAX_PATH]; platform_resolve_openrct_data_path(); platform_resolve_user_data_path(); platform_get_user_directory(userPath, NULL, sizeof(userPath)); if (!platform_ensure_directory_exists(userPath)) { Console::Error::WriteLine("Could not create user directory (do you have write access to your documents folder?)"); return nullptr; } openrct2_set_exe_path(); config_set_defaults(); if (!config_open_default()) { if (!config_find_or_browse_install_directory()) { gConfigGeneral.last_run_version = String::Duplicate(OPENRCT2_VERSION); config_save_default(); utf8 path[MAX_PATH]; config_get_default_path(path, sizeof(path)); Console::Error::WriteLine("An RCT2 install directory must be specified! Please edit \"game_path\" in %s.", path); return nullptr; } config_save_default(); } if (!rct2_init_directories()) { return nullptr; } if (!rct2_startup_checks()) { return nullptr; } utf8 path[260]; std::string basePaths[4]; basePaths[(size_t)DIRBASE::RCT1] = String::ToStd(gConfigGeneral.rct1_path); basePaths[(size_t)DIRBASE::RCT2] = String::ToStd(gConfigGeneral.rct2_path); platform_get_openrct_data_path(path, sizeof(path)); basePaths[(size_t)DIRBASE::OPENRCT2] = std::string(path); platform_get_user_directory(path, nullptr, sizeof(path)); basePaths[(size_t)DIRBASE::USER] = std::string(path); IPlatformEnvironment * env = CreatePlatformEnvironment(basePaths); return env; }
void platform_toggle_windowed_mode() { sint32 targetMode = gConfigGeneral.fullscreen_mode == 0 ? 2 : 0; context_set_fullscreen_mode(targetMode); gConfigGeneral.fullscreen_mode = targetMode; config_save_default(); }
static void window_title_editor_textinput(rct_window * w, rct_widgetindex widgetIndex, char * text) { if (str_is_null_or_empty(text)) return; switch (widgetIndex) { case WIDX_TITLE_EDITOR_NEW_BUTTON: case WIDX_TITLE_EDITOR_DUPLICATE_BUTTON: case WIDX_TITLE_EDITOR_RENAME_BUTTON: if (filename_valid_characters(text)) { if (title_sequence_manager_get_index_for_name(text) == SIZE_MAX) { if (!title_sequence_manager_is_name_reserved(text)) { if (widgetIndex == WIDX_TITLE_EDITOR_NEW_BUTTON) { size_t newIndex = title_sequence_manager_create(text); window_title_editor_load_sequence(newIndex); } else if (widgetIndex == WIDX_TITLE_EDITOR_DUPLICATE_BUTTON) { size_t newIndex = title_sequence_manager_duplicate(_selectedTitleSequence, text); window_title_editor_load_sequence(newIndex); } else { size_t newIndex = title_sequence_manager_rename(_selectedTitleSequence, text); window_title_editor_load_sequence(newIndex); } config_save_default(); window_invalidate(w); } else { context_show_error(STR_ERROR_RESERVED_NAME, STR_NONE); } } else { context_show_error(STR_ERROR_EXISTING_NAME, STR_NONE); } } else { context_show_error(STR_ERROR_INVALID_CHARACTERS, STR_NONE); } break; case WIDX_TITLE_EDITOR_RENAME_SAVE: window_title_editor_rename_park(w->selected_list_item, text); break; } }
static void custom_currency_window_dropdown([[maybe_unused]] rct_window * w, rct_widgetindex widgetIndex, sint32 dropdownIndex) { if(dropdownIndex == -1) return; if(widgetIndex == WIDX_AFFIX_DROPDOWN_BUTTON) { if(dropdownIndex == 0) { CurrencyDescriptors[CURRENCY_CUSTOM].affix_ascii = CURRENCY_PREFIX; CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode = CURRENCY_PREFIX; } else if(dropdownIndex == 1) { CurrencyDescriptors[CURRENCY_CUSTOM].affix_ascii = CURRENCY_SUFFIX; CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode = CURRENCY_SUFFIX; } gConfigGeneral.custom_currency_affix = CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode; config_save_default(); window_invalidate_all(); } }
static void window_news_options_mouseup(rct_window *w, rct_widgetindex widgetIndex) { switch (widgetIndex) { case WIDX_CLOSE: window_close(w); break; case WIDX_TAB_PARK: case WIDX_TAB_RIDE: case WIDX_TAB_GUEST: window_news_options_set_page(w, widgetIndex - WIDX_TAB_PARK); break; default: { sint32 checkBoxIndex = widgetIndex - WIDX_CHECKBOX_0; if (checkBoxIndex >= 0) { sint32 matchIndex = 0; for (size_t i = 0; i < Util::CountOf(NewsItemOptionDefinitions); i++) { const notification_def *ndef = &NewsItemOptionDefinitions[i]; if (ndef->category != w->page) continue; if (matchIndex == checkBoxIndex) { // Toggle value bool *configValue = get_notification_value_ptr(ndef); *configValue = !(*configValue); config_save_default(); widget_invalidate(w, widgetIndex); break; } matchIndex++; } } break; } } }
static int cc_set(const char **argv, int argc) { if (argc > 1) { bool int_valid = true, double_valid = true; int int_val = console_parse_int(argv[1], &int_valid); double double_val = console_parse_double(argv[1], &double_valid); if (strcmp(argv[0], "money") == 0 && double_valid) { RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONEY_ENCRYPTED, money32) = ENCRYPT_MONEY(MONEY((int)double_val, ((int)(double_val * 100)) % 100)); console_execute_silent("get money"); } else if (strcmp(argv[0], "current_loan") == 0 && int_valid) { RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_LOAN, money32) = clamp(MONEY(int_val - (int_val % 1000), 0), MONEY(0, 0), RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, money32)); console_execute_silent("get current_loan"); } else if (strcmp(argv[0], "max_loan") == 0 && int_valid) { RCT2_GLOBAL(RCT2_ADDRESS_MAXIMUM_LOAN, money32) = clamp(MONEY(int_val - (int_val % 1000), 0), MONEY(0, 0), MONEY(5000000, 0)); console_execute_silent("get max_loan"); } else if (strcmp(argv[0], "guest_initial_cash") == 0 && double_valid) { RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_CASH, money16) = clamp(MONEY((int)double_val, ((int)(double_val * 100)) % 100), MONEY(0, 0), MONEY(15000, 0)); console_execute_silent("get guest_initial_cash"); } else if (strcmp(argv[0], "guest_initial_happiness") == 0 && int_valid) { RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HAPPINESS, uint8) = calculate_guest_initial_happiness((uint8)int_val); console_execute_silent("get guest_initial_happiness"); } else if (strcmp(argv[0], "guest_initial_hunger") == 0 && int_valid) { RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_HUNGER, uint8) = (clamp(int_val, 1, 84) * 255 / 100 - 255) * -1; console_execute_silent("get guest_initial_hunger"); } else if (strcmp(argv[0], "guest_initial_thirst") == 0 && int_valid) { RCT2_GLOBAL(RCT2_ADDRESS_GUEST_INITIAL_THIRST, uint8) = (clamp(int_val, 1, 84) * 255 / 100 - 255) * -1; console_execute_silent("get guest_initial_thirst"); } else if (strcmp(argv[0], "guest_prefer_less_intense_rides") == 0 && int_valid) { SET_FLAG(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), PARK_FLAGS_PREF_LESS_INTENSE_RIDES, int_val); console_execute_silent("get guest_prefer_less_intense_rides"); } else if (strcmp(argv[0], "guest_prefer_more_intense_rides") == 0 && int_valid) { SET_FLAG(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), PARK_FLAGS_PREF_MORE_INTENSE_RIDES, int_val); console_execute_silent("get guest_prefer_more_intense_rides"); } else if (strcmp(argv[0], "forbid_marketing_campagns") == 0 && int_valid) { SET_FLAG(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), PARK_FLAGS_FORBID_MARKETING_CAMPAIGN, int_val); console_execute_silent("get forbid_marketing_campagns"); } else if (strcmp(argv[0], "forbid_landscape_changes") == 0 && int_valid) { SET_FLAG(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), PARK_FLAGS_FORBID_LANDSCAPE_CHANGES, int_val); console_execute_silent("get forbid_landscape_changes"); } else if (strcmp(argv[0], "forbid_tree_removal") == 0 && int_valid) { SET_FLAG(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), PARK_FLAGS_FORBID_TREE_REMOVAL, int_val); console_execute_silent("get forbid_tree_removal"); } else if (strcmp(argv[0], "forbid_high_construction") == 0 && int_valid) { SET_FLAG(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), PARK_FLAGS_FORBID_HIGH_CONSTRUCTION, int_val); console_execute_silent("get forbid_high_construction"); } else if (strcmp(argv[0], "pay_for_rides") == 0 && int_valid) { SET_FLAG(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), PARK_FLAGS_PARK_FREE_ENTRY, int_val); console_execute_silent("get pay_for_rides"); } else if (strcmp(argv[0], "no_money") == 0 && int_valid) { SET_FLAG(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), PARK_FLAGS_NO_MONEY, int_val); console_execute_silent("get no_money"); } else if (strcmp(argv[0], "difficult_park_rating") == 0 && int_valid) { SET_FLAG(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), PARK_FLAGS_DIFFICULT_PARK_RATING, int_val); console_execute_silent("get difficult_park_rating"); } else if (strcmp(argv[0], "difficult_guest_generation") == 0 && int_valid) { SET_FLAG(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), PARK_FLAGS_DIFFICULT_GUEST_GENERATION, int_val); console_execute_silent("get difficult_guest_generation"); } else if (strcmp(argv[0], "park_open") == 0 && int_valid) { SET_FLAG(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32), PARK_FLAGS_PARK_OPEN, int_val); console_execute_silent("get park_open"); } else if (strcmp(argv[0], "land_rights_cost") == 0 && double_valid) { RCT2_GLOBAL(RCT2_ADDRESS_LAND_COST, money16) = clamp(MONEY((int)double_val, ((int)(double_val * 100)) % 100), MONEY(0, 0), MONEY(15000, 0)); console_execute_silent("get land_rights_cost"); } else if (strcmp(argv[0], "construction_rights_cost") == 0 && double_valid) { RCT2_GLOBAL(RCT2_ADDRESS_CONSTRUCTION_RIGHTS_COST, money16) = clamp(MONEY((int)double_val, ((int)(double_val * 100)) % 100), MONEY(0, 0), MONEY(15000, 0)); console_execute_silent("get construction_rights_cost"); } else if (strcmp(argv[0], "climate") == 0) { if (int_valid) { RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, sint8) = clamp(int_val, 0, 3); } else { char* climate_names[] = { "cool_and_wet", "warm", "hot_and_dry", "cold" }; for (int i = 0; i < 4; i++) { if (strcmp(argv[1], climate_names[i]) == 0) { RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, sint8) = i; break; } } } console_execute_silent("get climate"); } else if (strcmp(argv[0], "game_speed") == 0 && int_valid) { gGameSpeed = clamp(int_val, 1, 8); console_execute_silent("get game_speed"); } else if (strcmp(argv[0], "console_small_font") == 0 && int_valid) { gConfigInterface.console_small_font = (int_val != 0); config_save_default(); console_execute_silent("get console_small_font"); } else if (strcmp(argv[0], "test_unfinished_tracks") == 0 && int_valid) { gConfigGeneral.test_unfinished_tracks = (int_val != 0); config_save_default(); console_execute_silent("get test_unfinished_tracks"); } else if (strcmp(argv[0], "no_test_crashes") == 0 && int_valid) { gConfigGeneral.no_test_crashes = (int_val != 0); config_save_default(); console_execute_silent("get no_test_crashes"); } else { console_writeline_error("Invalid variable or value."); } gfx_invalidate_screen(); } return 0; }
bool openrct2_initialise() { utf8 userPath[MAX_PATH]; platform_resolve_user_data_path(); platform_get_user_directory(userPath, NULL); if (!platform_ensure_directory_exists(userPath)) { log_fatal("Could not create user directory (do you have write access to your documents folder?)"); return false; } if (!openrct2_setup_rct2_segment()) { log_fatal("Unable to load RCT2 data sector"); return false; } openrct2_set_exe_path(); config_set_defaults(); if (!config_open_default()) { if (!config_find_or_browse_install_directory()) { log_fatal("An RCT2 install directory must be specified!"); return false; } } gOpenRCT2ShowChangelog = true; if (gConfigGeneral.last_run_version != NULL && (strcmp(gConfigGeneral.last_run_version, OPENRCT2_VERSION) == 0)) gOpenRCT2ShowChangelog = false; gConfigGeneral.last_run_version = OPENRCT2_VERSION; config_save_default(); // TODO add configuration option to allow multiple instances // if (!gOpenRCT2Headless && !platform_lock_single_instance()) { // log_fatal("OpenRCT2 is already running."); // return false; // } get_system_info(); if (!gOpenRCT2Headless) { audio_init(); audio_get_devices(); } if (!language_open(gConfigGeneral.language)) { log_fatal("Failed to open language, exiting."); return false; } http_init(); themes_set_default(); themes_load_presets(); title_sequences_set_default(); title_sequences_load_presets(); openrct2_setup_rct2_hooks(); if (!rct2_init()) return false; chat_init(); openrct2_copy_original_user_files_over(); // TODO move to audio initialise function if (str_is_null_or_empty(gConfigSound.device)) { Mixer_Init(NULL); RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = 0; } else { Mixer_Init(gConfigSound.device); for (int i = 0; i < gAudioDeviceCount; i++) { if (strcmp(gAudioDevices[i].name, gConfigSound.device) == 0) { RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = i; } } } return true; }
void drawing_engine_init() { assert(_drawingEngine == nullptr); IDrawingEngine * drawingEngine = nullptr; _drawingEngineType = gConfigGeneral.drawing_engine; switch (_drawingEngineType) { case DRAWING_ENGINE_SOFTWARE: drawingEngine = DrawingEngineFactory::CreateSoftware(); break; case DRAWING_ENGINE_SOFTWARE_WITH_HARDWARE_DISPLAY: drawingEngine = DrawingEngineFactory::CreateSoftwareWithHardwareDisplay(); break; case DRAWING_ENGINE_OPENGL: drawingEngine = DrawingEngineFactory::CreateOpenGL(); break; } if (drawingEngine == nullptr) { if (_drawingEngineType == DRAWING_ENGINE_SOFTWARE) { _drawingEngineType = DRAWING_ENGINE_NONE; log_fatal("Unable to create a drawing engine."); exit(-1); } else { log_error("Unable to create drawing engine. Falling back to software."); // Fallback to software gConfigGeneral.drawing_engine = DRAWING_ENGINE_SOFTWARE; config_save_default(); drawing_engine_init(); } } else { try { drawingEngine->Initialise(gWindow); drawingEngine->SetUncappedFrameRate(gConfigGeneral.uncap_fps == 1); _drawingEngine = drawingEngine; } catch (const Exception &ex) { delete drawingEngine; drawingEngine = nullptr; if (_drawingEngineType == DRAWING_ENGINE_SOFTWARE) { _drawingEngineType = DRAWING_ENGINE_NONE; log_error(ex.GetMessage()); log_fatal("Unable to initialise a drawing engine."); exit(-1); } else { log_error(ex.GetMessage()); log_error("Unable to initialise drawing engine. Falling back to software."); // Fallback to software gConfigGeneral.drawing_engine = DRAWING_ENGINE_SOFTWARE; config_save_default(); drawing_engine_init(); } } } }
static void custom_currency_window_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget *widget) { widget = &w->widgets[widgetIndex - 1]; switch(widgetIndex) { case WIDX_CLOSE: window_close(w); break; case WIDX_RATE_UP: CurrencyDescriptors[CURRENCY_CUSTOM].rate += 1; gConfigGeneral.custom_currency_rate = CurrencyDescriptors[CURRENCY_CUSTOM].rate; config_save_default(); window_invalidate_all(); break; case WIDX_RATE_DOWN: if(CurrencyDescriptors[CURRENCY_CUSTOM].rate > 1) { CurrencyDescriptors[CURRENCY_CUSTOM].rate -= 1; gConfigGeneral.custom_currency_rate = CurrencyDescriptors[CURRENCY_CUSTOM].rate; config_save_default(); window_invalidate_all(); } break; case WIDX_AFFIX_DROPDOWN_BUTTON: gDropdownItemsFormat[0] = STR_DROPDOWN_MENU_LABEL; gDropdownItemsArgs[0] = STR_PREFIX; gDropdownItemsFormat[1] = STR_DROPDOWN_MENU_LABEL; gDropdownItemsArgs[1] = STR_SUFFIX; window_dropdown_show_text_custom_width( w->x + widget->left, w->y + widget->top, widget->bottom - widget->top + 1, w->colours[1], 0, DROPDOWN_FLAG_STAY_OPEN, 2, widget->right - widget->left - 3 ); if(CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode == CURRENCY_PREFIX) { dropdown_set_checked(0, true); } else { dropdown_set_checked(1, true); } break; case WIDX_SYMBOL_TEXT: window_text_input_raw_open( w, WIDX_SYMBOL_TEXT, STR_CUSTOM_CURRENCY_SYMBOL_INPUT_TITLE, STR_CUSTOM_CURRENCY_SYMBOL_INPUT_DESC, CurrencyDescriptors[CURRENCY_CUSTOM].symbol_unicode, CURRENCY_SYMBOL_MAX_SIZE ); break; } }
bool openrct2_initialise() { #ifndef DISABLE_NETWORK gHashCTX = EVP_MD_CTX_create(); Guard::Assert(gHashCTX != nullptr, "EVP_MD_CTX_create failed"); #endif // DISABLE_NETWORK crash_init(); // Sets up the environment OpenRCT2 is running in, e.g. directory paths OpenRCT2::_env = OpenRCT2::SetupEnvironment(); if (OpenRCT2::_env == nullptr) { return false; } if (!rct2_interop_setup_segment()) { log_fatal("Unable to load RCT2 data sector"); return false; } if (gConfigGeneral.last_run_version != nullptr && String::Equals(gConfigGeneral.last_run_version, OPENRCT2_VERSION)) { gOpenRCT2ShowChangelog = false; } else { gOpenRCT2ShowChangelog = true; gConfigGeneral.last_run_version = String::Duplicate(OPENRCT2_VERSION); config_save_default(); } // TODO add configuration option to allow multiple instances // if (!gOpenRCT2Headless && !platform_lock_single_instance()) { // log_fatal("OpenRCT2 is already running."); // return false; // } IObjectRepository * objRepo = CreateObjectRepository(OpenRCT2::_env); ITrackDesignRepository * tdRepo = CreateTrackDesignRepository(OpenRCT2::_env); IScenarioRepository * scenarioRepo = CreateScenarioRepository(OpenRCT2::_env); if (!language_open(gConfigGeneral.language)) { log_error("Failed to open configured language..."); if (!language_open(LANGUAGE_ENGLISH_UK)) { log_fatal("Failed to open fallback language..."); return false; } } // TODO Ideally we want to delay this until we show the title so that we can // still open the game window and draw a progress screen for the creation // of the object cache. objRepo->LoadOrConstruct(); // TODO Like objects, this can take a while if there are a lot of track designs // its also really something really we might want to do in the background // as its not required until the player wants to place a new ride. tdRepo->Scan(); scenarioRepo->Scan(); TitleSequenceManager::Scan(); if (!gOpenRCT2Headless) { audio_init(); audio_populate_devices(); } http_init(); theme_manager_initialise(); rct2_interop_setup_hooks(); if (!rct2_init()) { return false; } chat_init(); rct2_copy_original_user_files_over(); return true; }
static void window_loadsave_mouseup(rct_window *w, int widgetIndex) { int result = 0; char path[MAX_PATH], filter[MAX_PATH]; switch (widgetIndex){ case WIDX_CLOSE: window_close(w); break; case WIDX_UP: { char directory[MAX_PATH]; int includeNewItem = (_type & 1) == LOADSAVETYPE_SAVE; safe_strcpy(directory, _parentDirectory, sizeof(directory)); window_loadsave_populate_list(w, includeNewItem, directory, _extension); window_init_scroll_widgets(w); w->no_list_items = _listItemsCount; break; } case WIDX_NEW: { rct_string_id templateStringId = 3165; char *templateString; templateString = (char *)language_get_string(templateStringId); strcpy(templateString, _defaultName); window_text_input_open(w, WIDX_NEW, STR_NONE, 2710, templateStringId, 0, 64); break; } case WIDX_BROWSE: safe_strcpy(path, _directory, MAX_PATH); if (_type & LOADSAVETYPE_SAVE) { strcat(path, _defaultName); } memset(filter, '\0', MAX_PATH); safe_strcpy(filter, "*", MAX_PATH); strncat(filter, _extension, MAX_PATH - strnlen(filter, MAX_PATH) - 1); file_dialog_desc desc; memset(&desc, 0, sizeof(desc)); desc.initial_directory = _directory; if (_type & LOADSAVETYPE_SAVE) { desc.default_filename = path; } switch (_type) { case (LOADSAVETYPE_LOAD | LOADSAVETYPE_GAME) : desc.type = FD_OPEN; desc.title = language_get_string(STR_FILE_DIALOG_TITLE_LOAD_GAME); desc.filters[0].name = language_get_string(STR_OPENRCT2_SAVED_GAME); desc.filters[0].pattern = "*.sv4;*.sv6"; break; case (LOADSAVETYPE_SAVE | LOADSAVETYPE_GAME) : desc.type = FD_SAVE; desc.title = language_get_string(STR_FILE_DIALOG_TITLE_SAVE_GAME); desc.filters[0].name = language_get_string(STR_OPENRCT2_SAVED_GAME); desc.filters[0].pattern = "*.sv6"; break; case (LOADSAVETYPE_LOAD | LOADSAVETYPE_LANDSCAPE) : desc.type = FD_OPEN; desc.title = language_get_string(STR_FILE_DIALOG_TITLE_LOAD_LANDSCAPE); desc.filters[0].name = language_get_string(STR_OPENRCT2_LANDSCAPE_FILE); desc.filters[0].pattern = "*.sc4;*.sv4;*.sc6;*.sv6"; break; case (LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE) : desc.type = FD_SAVE; desc.title = language_get_string(STR_FILE_DIALOG_TITLE_SAVE_LANDSCAPE); desc.filters[0].name = language_get_string(STR_OPENRCT2_LANDSCAPE_FILE); desc.filters[0].pattern = "*.sc6"; break; case (LOADSAVETYPE_SAVE | LOADSAVETYPE_SCENARIO) : desc.type = FD_SAVE; desc.title = language_get_string(STR_FILE_DIALOG_TITLE_SAVE_SCENARIO); desc.filters[0].name = language_get_string(STR_OPENRCT2_SCENARIO_FILE); desc.filters[0].pattern = "*.sc6"; break; case (LOADSAVETYPE_LOAD | LOADSAVETYPE_TRACK) : desc.type = FD_OPEN; desc.title = language_get_string(STR_FILE_DIALOG_TITLE_INSTALL_NEW_TRACK_DESIGN); desc.filters[0].name = language_get_string(STR_OPENRCT2_TRACK_DESIGN_FILE); desc.filters[0].pattern = "*.td4;*.td6"; break; } result = platform_open_common_file_dialog(path, &desc); if (result) { window_loadsave_select(w, path); } break; case WIDX_SORT_NAME: if (gConfigGeneral.load_save_sort == SORT_NAME_ASCENDING){ gConfigGeneral.load_save_sort = SORT_NAME_DESCENDING; } else { gConfigGeneral.load_save_sort = SORT_NAME_ASCENDING; } config_save_default(); window_loadsave_sort_list(0, _listItemsCount - 1); window_invalidate(w); break; case WIDX_SORT_DATE: if (gConfigGeneral.load_save_sort == SORT_DATE_DESCENDING){ gConfigGeneral.load_save_sort = SORT_DATE_ASCENDING; } else { gConfigGeneral.load_save_sort = SORT_DATE_DESCENDING; } config_save_default(); window_loadsave_sort_list(0, _listItemsCount - 1); window_invalidate(w); break; } }
static exitcode_t HandleCommandSetRCT2(CommandLineArgEnumerator * enumerator) { exitcode_t result = CommandLine::HandleCommandDefault(); if (result != EXITCODE_CONTINUE) { return result; } // Get the path that was passed const utf8 * rawPath; if (!enumerator->TryPopString(&rawPath)) { Console::Error::WriteLine("Expected a path."); return EXITCODE_FAIL; } utf8 path[MAX_PATH]; Path::GetAbsolute(path, sizeof(path), rawPath); // Check if path exists Console::WriteLine("Checking path..."); if (!platform_directory_exists(path)) { Console::Error::WriteLine("The path '%s' does not exist", path); return EXITCODE_FAIL; } // Check if g1.dat exists (naive but good check) Console::WriteLine("Checking g1.dat..."); utf8 pathG1Check[MAX_PATH]; String::Set(pathG1Check, sizeof(pathG1Check), path); Path::Append(pathG1Check, sizeof(pathG1Check), "Data"); Path::Append(pathG1Check, sizeof(pathG1Check), "g1.dat"); if (!platform_file_exists(pathG1Check)) { Console::Error::WriteLine("RCT2 path not valid."); Console::Error::WriteLine("Unable to find %s.", pathG1Check); return EXITCODE_FAIL; } // Check user path that will contain the config utf8 userPath[MAX_PATH]; platform_resolve_user_data_path(); platform_get_user_directory(userPath, NULL, sizeof(userPath)); if (!platform_ensure_directory_exists(userPath)) { Console::Error::WriteLine("Unable to access or create directory '%s'.", userPath); return EXITCODE_FAIL; } // Update RCT2 path in config config_set_defaults(); config_open_default(); String::DiscardDuplicate(&gConfigGeneral.rct2_path, path); if (config_save_default()) { Console::WriteFormat("Updating RCT2 path to '%s'.", path); Console::WriteLine(); Console::WriteLine("Updated config.ini"); return EXITCODE_OK; } else { Console::Error::WriteLine("Unable to update config.ini"); return EXITCODE_FAIL; } }