diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index 93a939e74d..1e8025d933 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -3725,6 +3725,8 @@ STR_6274 :Can't set colour scheme... STR_6275 :{WINDOW_COLOUR_2}Station style: STR_6276 :{RED}{STRINGID} has guests getting stuck, possibly due to invalid ride type or operating mode. STR_6277 :{WINDOW_COLOUR_2}Station index: {BLACK}{COMMA16} +STR_6278 :Autosave amount +STR_6279 :{SMALLFONT}{BLACK}Number of autosaves that should be kept ############# # Scenarios # diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 1ffb085974..efa4d0e68f 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -14,6 +14,7 @@ - Feature: [#8191] Allow building on-ride photos and water S-bends on the Water Coaster. - Feature: [#8259] Add say command to in-game console. - Feature: [#8374] Add replay system. +- Feature: [#8377] Add option to adjust amount of autosaves to keep. - Feature: [#8583] Add boosters to water coaster. - Change: [#7961] Add new object types: station, terrain surface, and terrain edge. - Change: [#8222] The climate setting has been moved from objective options to scenario options. diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index dad13152a0..1d413377b5 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -178,6 +178,9 @@ enum WINDOW_OPTIONS_WIDGET_IDX { WIDX_ALWAYS_NATIVE_LOADSAVE, WIDX_AUTOSAVE, WIDX_AUTOSAVE_DROPDOWN, + WIDX_AUTOSAVE_AMOUNT, + WIDX_AUTOSAVE_AMOUNT_UP, + WIDX_AUTOSAVE_AMOUNT_DOWN, WIDX_PATH_TO_RCT1_TEXT, WIDX_PATH_TO_RCT1_BUTTON, WIDX_PATH_TO_RCT1_CLEAR, @@ -359,9 +362,10 @@ static rct_widget window_options_advanced_widgets[] = { { WWT_CHECKBOX, 1, 10, 299, 129, 140, STR_ALWAYS_NATIVE_LOADSAVE, STR_ALWAYS_NATIVE_LOADSAVE_TIP }, // Use native load/save window { WWT_DROPDOWN, 1, 165, 299, 145, 157, STR_NONE, STR_NONE }, // Autosave dropdown { WWT_BUTTON, 1, 288, 298, 146, 156, STR_DROPDOWN_GLYPH, STR_AUTOSAVE_FREQUENCY_TIP }, // Autosave dropdown button - { WWT_LABEL, 1, 23, 298, 165, 176, STR_PATH_TO_RCT1, STR_PATH_TO_RCT1_TIP }, // RCT 1 path text - { WWT_BUTTON, 1, 24, 289, 180, 193, STR_NONE, STR_STRING_TOOLTIP }, // RCT 1 path button - { WWT_BUTTON, 1, 289, 299, 180, 193, STR_CLOSE_X, STR_PATH_TO_RCT1_CLEAR_TIP }, // RCT 1 path clear button + SPINNER_WIDGETS (1, 165, 299, 165, 176, STR_NONE, STR_AUTOSAVE_AMOUNT_TIP ), // Autosave amount spinner + { WWT_LABEL, 1, 23, 298, 184, 195, STR_PATH_TO_RCT1, STR_PATH_TO_RCT1_TIP }, // RCT 1 path text + { WWT_BUTTON, 1, 24, 289, 199, 212, STR_NONE, STR_STRING_TOOLTIP }, // RCT 1 path button + { WWT_BUTTON, 1, 289, 299, 199, 212, STR_CLOSE_X, STR_PATH_TO_RCT1_CLEAR_TIP }, // RCT 1 path clear button { WIDGETS_END }, }; @@ -598,6 +602,9 @@ static uint64_t window_options_page_enabled_widgets[] = { (1 << WIDX_ALWAYS_NATIVE_LOADSAVE) | (1 << WIDX_AUTOSAVE) | (1 << WIDX_AUTOSAVE_DROPDOWN) | + (1 << WIDX_AUTOSAVE_AMOUNT) | + (1 << WIDX_AUTOSAVE_AMOUNT_UP) | + (1 << WIDX_AUTOSAVE_AMOUNT_DOWN) | (1 << WIDX_PATH_TO_RCT1_TEXT) | (1 << WIDX_PATH_TO_RCT1_BUTTON) | (1 << WIDX_PATH_TO_RCT1_CLEAR), @@ -1318,6 +1325,22 @@ static void window_options_mousedown(rct_window* w, rct_widgetindex widgetIndex, window_options_show_dropdown(w, widget, AUTOSAVE_NEVER + 1); dropdown_set_checked(gConfigGeneral.autosave_frequency, true); break; + case WIDX_AUTOSAVE_AMOUNT_UP: + gConfigGeneral.autosave_amount += 1; + config_save_default(); + widget_invalidate(w, WIDX_AUTOSAVE); + widget_invalidate(w, WIDX_AUTOSAVE_DROPDOWN); + widget_invalidate(w, WIDX_AUTOSAVE_AMOUNT); + break; + case WIDX_AUTOSAVE_AMOUNT_DOWN: + if (gConfigGeneral.autosave_amount > 1) + { + gConfigGeneral.autosave_amount -= 1; + config_save_default(); + widget_invalidate(w, WIDX_AUTOSAVE); + widget_invalidate(w, WIDX_AUTOSAVE_DROPDOWN); + widget_invalidate(w, WIDX_AUTOSAVE_AMOUNT); + } } break; @@ -2062,6 +2085,13 @@ static void window_options_paint(rct_window* w, rct_drawpixelinfo* dpi) dpi, window_options_autosave_names[gConfigGeneral.autosave_frequency], nullptr, w->colours[1], w->x + window_options_advanced_widgets[WIDX_AUTOSAVE].left + 1, w->y + window_options_advanced_widgets[WIDX_AUTOSAVE].top); + gfx_draw_string_left( + dpi, STR_AUTOSAVE_AMOUNT, w, w->colours[1], w->x + 24, + w->y + window_options_advanced_widgets[WIDX_AUTOSAVE_AMOUNT].top + 1); + int32_t autosavesToKeep = (int32_t)(gConfigGeneral.autosave_amount); + gfx_draw_string_left( + dpi, STR_WINDOW_OBJECTIVE_VALUE_GUEST_COUNT, &autosavesToKeep, w->colours[1], + w->x + w->widgets[WIDX_AUTOSAVE_AMOUNT].left + 1, w->y + w->widgets[WIDX_AUTOSAVE_AMOUNT].top + 1); #ifdef __APPLE__ set_format_arg(0, uintptr_t, (uintptr_t)macos_str_decomp_to_precomp(gConfigGeneral.rct1_path)); diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 97574ac59c..04bb2b5924 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -64,8 +64,6 @@ #include #include -#define NUMBER_OF_AUTOSAVES_TO_KEEP 9 - uint16_t gCurrentDeltaTime; uint8_t gGamePaused = 0; int32_t gGameSpeed = 1; @@ -1384,7 +1382,8 @@ void game_autosave() timeName, sizeof(timeName), "autosave_%04u-%02u-%02u_%02u-%02u-%02u%s", currentDate.year, currentDate.month, currentDate.day, currentTime.hour, currentTime.minute, currentTime.second, fileExtension); - limit_autosave_count(NUMBER_OF_AUTOSAVES_TO_KEEP, (gScreenFlags & SCREEN_FLAGS_EDITOR)); + int32_t autosavesToKeep = gConfigGeneral.autosave_amount; + limit_autosave_count(autosavesToKeep - 1, (gScreenFlags & SCREEN_FLAGS_EDITOR)); utf8 path[MAX_PATH]; utf8 backupPath[MAX_PATH]; diff --git a/src/openrct2/config/Config.cpp b/src/openrct2/config/Config.cpp index 1d32b45dc0..b43be14830 100644 --- a/src/openrct2/config/Config.cpp +++ b/src/openrct2/config/Config.cpp @@ -137,6 +137,7 @@ namespace Config auto model = &gConfigGeneral; model->always_show_gridlines = reader->GetBoolean("always_show_gridlines", false); model->autosave_frequency = reader->GetInt32("autosave", AUTOSAVE_EVERY_5MINUTES); + model->autosave_amount = reader->GetInt32("autosave_amount", DEFAULT_NUM_AUTOSAVES_TO_KEEP); model->confirmation_prompt = reader->GetBoolean("confirmation_prompt", false); model->currency_format = reader->GetEnum("currency_format", platform_get_locale_currency(), Enum_Currency); model->custom_currency_rate = reader->GetInt32("custom_currency_rate", 10); @@ -220,6 +221,7 @@ namespace Config writer->WriteSection("general"); writer->WriteBoolean("always_show_gridlines", model->always_show_gridlines); writer->WriteInt32("autosave", model->autosave_frequency); + writer->WriteInt32("autosave_amount", model->autosave_amount); writer->WriteBoolean("confirmation_prompt", model->confirmation_prompt); writer->WriteEnum("currency_format", model->currency_format, Enum_Currency); writer->WriteInt32("custom_currency_rate", model->custom_currency_rate); diff --git a/src/openrct2/config/Config.h b/src/openrct2/config/Config.h index 34bf2d8c6b..c4b0ecc0b3 100644 --- a/src/openrct2/config/Config.h +++ b/src/openrct2/config/Config.h @@ -71,6 +71,7 @@ struct GeneralConfiguration bool no_test_crashes; bool debugging_tools; int32_t autosave_frequency; + int32_t autosave_amount; bool auto_staff_placement; bool handymen_mow_default; bool auto_open_shops; diff --git a/src/openrct2/localisation/StringIds.h b/src/openrct2/localisation/StringIds.h index ff0a418fce..ccc26b2d44 100644 --- a/src/openrct2/localisation/StringIds.h +++ b/src/openrct2/localisation/StringIds.h @@ -3898,6 +3898,9 @@ enum STR_TILE_INSPECTOR_STATION_INDEX = 6277, + STR_AUTOSAVE_AMOUNT = 6278, + STR_AUTOSAVE_AMOUNT_TIP = 6279, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 }; diff --git a/src/openrct2/scenario/Scenario.h b/src/openrct2/scenario/Scenario.h index 42c24ef069..0e5966794e 100644 --- a/src/openrct2/scenario/Scenario.h +++ b/src/openrct2/scenario/Scenario.h @@ -361,6 +361,7 @@ enum }; #define AUTOSAVE_PAUSE 0 +#define DEFAULT_NUM_AUTOSAVES_TO_KEEP 10 extern const rct_string_id ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT];