Skip to content

Commit

Permalink
Fix OpenRCT2#8377: Change number of autosaves that are stored (OpenRC…
Browse files Browse the repository at this point in the history
  • Loading branch information
ltoenning authored and ZehMatt committed Jan 24, 2019
1 parent 479c5c7 commit 7cb863b
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 6 deletions.
2 changes: 2 additions & 0 deletions data/language/en-GB.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
Expand Down
1 change: 1 addition & 0 deletions distribution/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
36 changes: 33 additions & 3 deletions src/openrct2-ui/windows/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 },
};

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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));
Expand Down
5 changes: 2 additions & 3 deletions src/openrct2/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@
#include <iterator>
#include <memory>

#define NUMBER_OF_AUTOSAVES_TO_KEEP 9

uint16_t gCurrentDeltaTime;
uint8_t gGamePaused = 0;
int32_t gGameSpeed = 1;
Expand Down Expand Up @@ -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];
Expand Down
2 changes: 2 additions & 0 deletions src/openrct2/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>("currency_format", platform_get_locale_currency(), Enum_Currency);
model->custom_currency_rate = reader->GetInt32("custom_currency_rate", 10);
Expand Down Expand Up @@ -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<int32_t>("currency_format", model->currency_format, Enum_Currency);
writer->WriteInt32("custom_currency_rate", model->custom_currency_rate);
Expand Down
1 change: 1 addition & 0 deletions src/openrct2/config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/openrct2/localisation/StringIds.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
1 change: 1 addition & 0 deletions src/openrct2/scenario/Scenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down

0 comments on commit 7cb863b

Please sign in to comment.