Merge branch 'master' into jgrpp
# Conflicts: # src/openttd.cpp # src/settings_gui.cpp # src/settings_type.h # src/table/settings/gameopt_settings.ini # src/table/settings/gui_settings.ini
This commit is contained in:
12
src/date.cpp
12
src/date.cpp
@@ -297,12 +297,6 @@ static void OnNewYear()
|
||||
*/
|
||||
static void OnNewMonth()
|
||||
{
|
||||
if (_settings_client.gui.autosave != 0 && _settings_client.gui.autosave < 5 && (_cur_date_ymd.month % _autosave_months[_settings_client.gui.autosave]) == 0) {
|
||||
_do_autosave = true;
|
||||
_check_special_modes = true;
|
||||
SetWindowDirty(WC_STATUS_BAR, 0);
|
||||
}
|
||||
|
||||
SetWindowClassesDirty(WC_CHEATS);
|
||||
CompaniesMonthlyLoop();
|
||||
EnginesMonthlyLoop();
|
||||
@@ -319,12 +313,6 @@ static void OnNewMonth()
|
||||
*/
|
||||
static void OnNewDay()
|
||||
{
|
||||
if (_settings_client.gui.autosave == 5 && (_date % _settings_client.gui.autosave_custom_days) == 0) {
|
||||
_do_autosave = true;
|
||||
_check_special_modes = true;
|
||||
SetWindowDirty(WC_STATUS_BAR, 0);
|
||||
}
|
||||
|
||||
if (_network_server) NetworkServerDailyLoop();
|
||||
|
||||
DisasterDailyLoop();
|
||||
|
@@ -74,6 +74,9 @@ STR_ABOUT_MENU_SHOW_PICKER_TOOL :Picker tool
|
||||
##after STR_ABOUT_MENU_SHOW_FRAMERATE
|
||||
STR_ABOUT_MENU_SHOW_TOGGLE_MODIFIER_KEYS :Modifier key window
|
||||
|
||||
##before STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_MINUTES_CUSTOM :Every {COMMA}{NBSP}minute{P 0 "" s}
|
||||
|
||||
##after STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_1_MONTH :Every month
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_3_MONTHS :Every 3 months
|
||||
@@ -140,7 +143,6 @@ STR_NEWS_TRAIN_OVERSHOT_STATION :{WHITE}{VEHICLE
|
||||
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_DAYS_CUSTOM :Every {COMMA}{NBSP}days
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_DAYS_CUSTOM_SINGULAR :Every day
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_MINUTES_CUSTOM :Every {COMMA} real-time minutes
|
||||
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DAYS_QUERY_CAPT :{WHITE}Autosave interval in days
|
||||
STR_GAME_OPTIONS_AUTOSAVE_MINUTES_QUERY_CAPT :{WHITE}Autosave interval in real-time minutes
|
||||
|
@@ -2097,8 +2097,8 @@ void StateGameLoop()
|
||||
_scaled_date_ticks++; // This must update in lock-step with _tick_skip_counter, such that it always matches what SetScaledTickVariables would return.
|
||||
}
|
||||
|
||||
if (_settings_client.gui.autosave == 6 && !(_game_mode == GM_MENU || _game_mode == GM_BOOTSTRAP) &&
|
||||
(_scaled_date_ticks % (_settings_client.gui.autosave_custom_minutes * (_settings_game.economy.tick_rate == TRM_MODERN ? (60000 / 27) : (60000 / 30)))) == 0) {
|
||||
if (!(_game_mode == GM_MENU || _game_mode == GM_BOOTSTRAP) &&
|
||||
(_scaled_date_ticks % (_settings_client.gui.autosave_interval * (_settings_game.economy.tick_rate == TRM_MODERN ? (60000 / 27) : (60000 / 30)))) == 0) {
|
||||
_do_autosave = true;
|
||||
_check_special_modes = true;
|
||||
SetWindowDirty(WC_STATUS_BAR, 0);
|
||||
|
@@ -195,6 +195,8 @@ enum IniFileVersion : uint32 {
|
||||
IFV_LINKGRAPH_SECONDS, ///< 3 PR#10610 Store linkgraph update intervals in seconds instead of days.
|
||||
IFV_NETWORK_PRIVATE_SETTINGS, ///< 4 PR#10762 Move no_http_content_downloads / use_relay_service to private settings.
|
||||
|
||||
IFV_AUTOSAVE_RENAME, ///< 5 PR#11143 Renamed values of autosave to be in minutes.
|
||||
|
||||
IFV_MAX_VERSION, ///< Highest possible ini-file version.
|
||||
};
|
||||
|
||||
@@ -2454,6 +2456,34 @@ void LoadFromConfig(bool startup)
|
||||
_settings_client.network.server_game_type = old_value.value_or(false) ? SERVER_GAME_TYPE_PUBLIC : SERVER_GAME_TYPE_LOCAL;
|
||||
}
|
||||
|
||||
if (generic_version < IFV_AUTOSAVE_RENAME && IsConversionNeeded(generic_ini, "gui", "autosave", "autosave_interval", &old_item)) {
|
||||
static std::vector<std::string> _old_autosave_interval{"off", "monthly", "quarterly", "half year", "yearly", "custom_days", "custom_realtime_minutes"};
|
||||
auto old_value = OneOfManySettingDesc::ParseSingleValue(old_item->value->c_str(), old_item->value->size(), _old_autosave_interval);
|
||||
|
||||
switch (old_value) {
|
||||
case 0: _settings_client.gui.autosave_interval = 0; break;
|
||||
case 1: _settings_client.gui.autosave_interval = 10; break;
|
||||
case 2: _settings_client.gui.autosave_interval = 30; break;
|
||||
case 3: _settings_client.gui.autosave_interval = 60; break;
|
||||
case 4: _settings_client.gui.autosave_interval = 120; break;
|
||||
case 5: {
|
||||
IniItem *old_autosave_custom_days;
|
||||
if (IsConversionNeeded(generic_ini, "gui", "autosave_custom_days", "autosave_interval", &old_autosave_custom_days)) {
|
||||
_settings_client.gui.autosave_interval = (std::strtoul(old_autosave_custom_days->value->c_str(), nullptr, 10) + 2) / 3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
IniItem *old_autosave_custom_minutes;
|
||||
if (IsConversionNeeded(generic_ini, "gui", "autosave_custom_minutes", "autosave_interval", &old_autosave_custom_minutes)) {
|
||||
_settings_client.gui.autosave_interval = std::strtoul(old_autosave_custom_minutes->value->c_str(), nullptr, 10);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
_grfconfig_newgame = GRFLoadConfig(generic_ini, "newgrf", false);
|
||||
_grfconfig_static = GRFLoadConfig(generic_ini, "newgrf-static", true);
|
||||
AILoadConfig(generic_ini, "ai_players");
|
||||
|
@@ -62,15 +62,23 @@ extern void FlushDeparturesWindowTextCaches();
|
||||
|
||||
static const StringID _autosave_dropdown[] = {
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF,
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_1_MONTH,
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_3_MONTHS,
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_6_MONTHS,
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_12_MONTHS,
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_DAYS_CUSTOM_LABEL,
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_10_MINUTES,
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_30_MINUTES,
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_60_MINUTES,
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_120_MINUTES,
|
||||
STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_MINUTES_CUSTOM_LABEL,
|
||||
INVALID_STRING_ID,
|
||||
};
|
||||
|
||||
/** Available settings for autosave intervals. */
|
||||
static const uint32 _autosave_dropdown_to_minutes[] = {
|
||||
0, ///< never
|
||||
10,
|
||||
30,
|
||||
60,
|
||||
120,
|
||||
};
|
||||
|
||||
static Dimension _circle_size; ///< Dimension of the circle +/- icon. This is here as not all users are within the class of the settings window.
|
||||
|
||||
static const void *ResolveObject(const GameSettings *settings_ptr, const IntSettingDesc *sd);
|
||||
@@ -176,7 +184,6 @@ struct GameOptionsWindow : Window {
|
||||
|
||||
enum class QueryTextItem {
|
||||
None,
|
||||
AutosaveCustomDays,
|
||||
AutosaveCustomRealTimeMinutes,
|
||||
};
|
||||
QueryTextItem current_query_text_item = QueryTextItem::None;
|
||||
@@ -240,7 +247,16 @@ struct GameOptionsWindow : Window {
|
||||
}
|
||||
|
||||
case WID_GO_AUTOSAVE_DROPDOWN: { // Setup autosave dropdown
|
||||
*selected_index = _settings_client.gui.autosave;
|
||||
*selected_index = 5;
|
||||
int index = 0;
|
||||
for (auto &minutes : _autosave_dropdown_to_minutes) {
|
||||
if (_settings_client.gui.autosave_interval == minutes) {
|
||||
*selected_index = index;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
const StringID *items = _autosave_dropdown;
|
||||
for (uint i = 0; *items != INVALID_STRING_ID; items++, i++) {
|
||||
list.emplace_back(new DropDownListStringItem(*items, i, false));
|
||||
@@ -322,14 +338,15 @@ struct GameOptionsWindow : Window {
|
||||
break;
|
||||
}
|
||||
case WID_GO_AUTOSAVE_DROPDOWN: {
|
||||
if (_settings_client.gui.autosave == 5) {
|
||||
SetDParam(0, _settings_client.gui.autosave_custom_days == 1 ? STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_DAYS_CUSTOM_SINGULAR : STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_DAYS_CUSTOM);
|
||||
SetDParam(1, _settings_client.gui.autosave_custom_days);
|
||||
} else if (_settings_client.gui.autosave == 6) {
|
||||
SetDParam(0, STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_MINUTES_CUSTOM);
|
||||
SetDParam(1, _settings_client.gui.autosave_custom_minutes);
|
||||
} else {
|
||||
SetDParam(0, _autosave_dropdown[_settings_client.gui.autosave]);
|
||||
SetDParam(1, _settings_client.gui.autosave_interval);
|
||||
int index = 0;
|
||||
for (auto &minutes : _autosave_dropdown_to_minutes) {
|
||||
if (_settings_client.gui.autosave_interval == minutes) {
|
||||
SetDParam(0, _autosave_dropdown[index]);
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -697,15 +714,11 @@ struct GameOptionsWindow : Window {
|
||||
|
||||
case WID_GO_AUTOSAVE_DROPDOWN: // Autosave options
|
||||
if (index == 5) {
|
||||
this->current_query_text_item = QueryTextItem::AutosaveCustomDays;
|
||||
SetDParam(0, _settings_client.gui.autosave_custom_days);
|
||||
ShowQueryString(STR_JUST_INT, STR_GAME_OPTIONS_AUTOSAVE_DAYS_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
|
||||
} else if (index == 6) {
|
||||
this->current_query_text_item = QueryTextItem::AutosaveCustomRealTimeMinutes;
|
||||
SetDParam(0, _settings_client.gui.autosave_custom_minutes);
|
||||
SetDParam(0, _settings_client.gui.autosave_interval);
|
||||
ShowQueryString(STR_JUST_INT, STR_GAME_OPTIONS_AUTOSAVE_MINUTES_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
|
||||
} else {
|
||||
_settings_client.gui.autosave = index;
|
||||
_settings_client.gui.autosave_interval = _autosave_dropdown_to_minutes[index];
|
||||
this->SetDirty();
|
||||
}
|
||||
break;
|
||||
@@ -766,15 +779,8 @@ struct GameOptionsWindow : Window {
|
||||
case QueryTextItem::None:
|
||||
break;
|
||||
|
||||
case QueryTextItem::AutosaveCustomDays:
|
||||
_settings_client.gui.autosave = 5;
|
||||
_settings_client.gui.autosave_custom_days = Clamp(value, 1, 4000);
|
||||
this->SetDirty();
|
||||
break;
|
||||
|
||||
case QueryTextItem::AutosaveCustomRealTimeMinutes:
|
||||
_settings_client.gui.autosave = 6;
|
||||
_settings_client.gui.autosave_custom_minutes = Clamp(value, 1, 8000);
|
||||
_settings_client.gui.autosave_interval = Clamp(value, 1, 8000);
|
||||
this->SetDirty();
|
||||
break;
|
||||
}
|
||||
@@ -841,7 +847,7 @@ static const NWidgetPart _nested_game_options_widgets[] = {
|
||||
EndContainer(),
|
||||
|
||||
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_AUTOSAVE_FRAME, STR_NULL),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_AUTOSAVE_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_STRING, STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_TOOLTIP), SetFill(1, 0),
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GO_AUTOSAVE_DROPDOWN), SetMinimalSize(100, 12), SetDataTip(STR_JUST_STRING2, STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_TOOLTIP), SetFill(1, 0),
|
||||
EndContainer(),
|
||||
|
||||
NWidget(WWT_FRAME, COLOUR_GREY), SetDataTip(STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME, STR_NULL),
|
||||
@@ -1992,9 +1998,7 @@ static SettingsContainer &GetSettingsTree()
|
||||
|
||||
SettingsPage *save = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_SAVE));
|
||||
{
|
||||
save->Add(new SettingEntry("gui.autosave"));
|
||||
save->Add(new ConditionallyHiddenSettingEntry("gui.autosave_custom_days", []() -> bool { return _settings_client.gui.autosave != 5; }));
|
||||
save->Add(new ConditionallyHiddenSettingEntry("gui.autosave_custom_minutes", []() -> bool { return _settings_client.gui.autosave != 6; }));
|
||||
save->Add(new SettingEntry("gui.autosave_interval"));
|
||||
save->Add(new SettingEntry("gui.autosave_on_network_disconnect"));
|
||||
save->Add(new SettingEntry("gui.savegame_overwrite_confirm"));
|
||||
}
|
||||
|
@@ -169,9 +169,7 @@ struct GUISettings : public TimeSettings {
|
||||
ZoomLevel zoom_min; ///< minimum zoom out level
|
||||
ZoomLevel zoom_max; ///< maximum zoom out level
|
||||
ZoomLevel sprite_zoom_min; ///< maximum zoom level at which higher-resolution alternative sprites will be used (if available) instead of scaling a lower resolution sprite
|
||||
byte autosave; ///< how often should we do autosaves?
|
||||
uint16 autosave_custom_days; ///< custom autosave interval in days
|
||||
uint16 autosave_custom_minutes; ///< custom autosave interval in real-time minutes
|
||||
uint32 autosave_interval; ///< how often should we do autosaves?
|
||||
bool threaded_saves; ///< should we do threaded saves?
|
||||
bool keep_all_autosave; ///< name the autosave in a different way
|
||||
bool autosave_on_exit; ///< save an autosave when you quit the game, but do not ask "Do you really want to quit?"
|
||||
|
@@ -27,7 +27,6 @@ static_assert(_locale_currencies.size() == CURRENCY_END);
|
||||
static constexpr std::initializer_list<const char*> _locale_units{"imperial", "metric", "si", "gameunits"};
|
||||
static constexpr std::initializer_list<const char*> _town_names{"english", "french", "german", "american", "latin", "silly", "swedish", "dutch", "finnish", "polish", "slovak", "norwegian", "hungarian", "austrian", "romanian", "czech", "swiss", "danish", "turkish", "italian", "catalan"};
|
||||
static constexpr std::initializer_list<const char*> _climates{"temperate", "arctic", "tropic", "toyland"};
|
||||
static constexpr std::initializer_list<const char*> _autosave_interval{"off", "monthly", "quarterly", "half year", "yearly", "custom_days", "custom_realtime_minutes"};
|
||||
static constexpr std::initializer_list<const char*> _roadsides{"left", "right"};
|
||||
static constexpr std::initializer_list<const char*> _savegame_date{"long", "short", "iso"};
|
||||
static constexpr std::initializer_list<const char*> _savegame_overwrite_confirm{"no", "different", "not same", "yes"};
|
||||
@@ -175,15 +174,6 @@ to = SLV_165
|
||||
length = 1
|
||||
to = SLV_23
|
||||
|
||||
[SDTC_OMANY]
|
||||
var = gui.autosave
|
||||
type = SLE_UINT8
|
||||
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
|
||||
def = 1
|
||||
max = 6
|
||||
full = _autosave_interval
|
||||
cat = SC_BASIC
|
||||
|
||||
[SDT_OMANY]
|
||||
var = vehicle.road_side
|
||||
type = SLE_UINT8
|
||||
|
@@ -4511,45 +4511,20 @@ patxname = ""safer_crossings.vehicle.safer_crossings""
|
||||
;***************************************************************************
|
||||
; Unsaved setting variables.
|
||||
|
||||
[SDTC_OMANY]
|
||||
var = gui.autosave
|
||||
type = SLE_UINT8
|
||||
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_DROPDOWN
|
||||
def = 1
|
||||
max = 6
|
||||
full = _autosave_interval
|
||||
[SDTC_VAR]
|
||||
var = gui.autosave_interval
|
||||
type = SLE_UINT32
|
||||
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_GUI_0_IS_SPECIAL
|
||||
def = 10
|
||||
min = 0
|
||||
max = 1440
|
||||
interval = 5
|
||||
str = STR_CONFIG_SETTING_AUTOSAVE
|
||||
strhelp = STR_CONFIG_SETTING_AUTOSAVE_HELPTEXT
|
||||
strval = STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_OFF
|
||||
strval = STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_EVERY_MINUTES_CUSTOM
|
||||
post_cb = AutosaveModeChanged
|
||||
cat = SC_BASIC
|
||||
|
||||
[SDTC_VAR]
|
||||
var = gui.autosave_custom_days
|
||||
type = SLE_UINT16
|
||||
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
|
||||
def = 14
|
||||
min = 1
|
||||
max = 4000
|
||||
interval = 7
|
||||
str = STR_CONFIG_SETTING_AUTOSAVE_CUSTOM_DAYS
|
||||
strhelp = STR_CONFIG_SETTING_AUTOSAVE_CUSTOM_DAYS_HELPTEXT
|
||||
strval = STR_TIMETABLE_DAYS
|
||||
cat = SC_BASIC
|
||||
|
||||
[SDTC_VAR]
|
||||
var = gui.autosave_custom_minutes
|
||||
type = SLE_UINT16
|
||||
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
|
||||
def = 30
|
||||
min = 3
|
||||
max = 8000
|
||||
interval = 10
|
||||
str = STR_CONFIG_SETTING_AUTOSAVE_CUSTOM_MINUTES
|
||||
strhelp = STR_CONFIG_SETTING_AUTOSAVE_CUSTOM_MINUTES_HELPTEXT
|
||||
strval = STR_TIMETABLE_MINUTES
|
||||
cat = SC_BASIC
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.threaded_saves
|
||||
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC
|
||||
|
Reference in New Issue
Block a user