Store time display settings both in savegame and client, add setting
This commit is contained in:
@@ -277,7 +277,7 @@ static void OnNewDay()
|
||||
DisasterDailyLoop();
|
||||
IndustryDailyLoop();
|
||||
|
||||
if (!_settings_client.gui.time_in_minutes || _settings_client.gui.date_with_time > 0) {
|
||||
if (!_settings_time.time_in_minutes || _settings_client.gui.date_with_time > 0) {
|
||||
SetWindowWidgetDirty(WC_STATUS_BAR, 0, 0);
|
||||
}
|
||||
EnginesDailyLoop();
|
||||
|
@@ -181,7 +181,7 @@ struct SetMinutesWindow : SetDateWindow
|
||||
/** Constructor. */
|
||||
SetMinutesWindow(WindowDesc *desc, WindowNumber window_number, Window *parent, DateTicksScaled initial_date, Year min_year, Year max_year, SetDateCallback *callback) :
|
||||
SetDateWindow(desc, window_number, parent, initial_date, min_year, max_year, callback),
|
||||
minutes(initial_date / _settings_client.gui.ticks_per_minute)
|
||||
minutes(initial_date / _settings_time.ticks_per_minute)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ struct SetMinutesWindow : SetDateWindow
|
||||
|
||||
case WID_SD_SET_DATE:
|
||||
if (this->callback != nullptr) {
|
||||
this->callback(this, ((DateTicks)minutes - _settings_client.gui.clock_offset) * _settings_client.gui.ticks_per_minute);
|
||||
this->callback(this, ((DateTicks)minutes - _settings_time.clock_offset) * _settings_time.ticks_per_minute);
|
||||
}
|
||||
delete this;
|
||||
break;
|
||||
@@ -362,11 +362,11 @@ void ShowSetDateWindow(Window *parent, int window_number, DateTicksScaled initia
|
||||
{
|
||||
DeleteWindowByClass(WC_SET_DATE);
|
||||
|
||||
if (!_settings_client.gui.time_in_minutes) {
|
||||
if (!_settings_time.time_in_minutes) {
|
||||
new SetDateWindow(&_set_date_desc, window_number, parent, initial_date / (DAY_TICKS * _settings_game.economy.day_length_factor), min_year, max_year, callback);
|
||||
} else {
|
||||
new SetMinutesWindow(&_set_minutes_desc, window_number, parent,
|
||||
initial_date + (_settings_game.economy.day_length_factor * (_settings_client.gui.clock_offset * _settings_client.gui.ticks_per_minute)),
|
||||
initial_date + (_settings_game.economy.day_length_factor * (_settings_time.clock_offset * _settings_time.ticks_per_minute)),
|
||||
min_year, max_year, callback);
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ static const int DAY_TICKS = 74; ///< ticks per day
|
||||
static const int DAYS_IN_YEAR = 365; ///< days per year
|
||||
static const int DAYS_IN_LEAP_YEAR = 366; ///< sometimes, you need one day more...
|
||||
|
||||
#define DATE_UNIT_SIZE (_settings_client.gui.time_in_minutes ? _settings_client.gui.ticks_per_minute : (DAY_TICKS * _settings_game.economy.day_length_factor))
|
||||
#define DATE_UNIT_SIZE (_settings_time.time_in_minutes ? _settings_time.ticks_per_minute : (DAY_TICKS * _settings_game.economy.day_length_factor))
|
||||
|
||||
static const int STATION_RATING_TICKS = 185; ///< cycle duration for updating station rating
|
||||
static const int STATION_ACCEPTANCE_TICKS = 250; ///< cycle duration for updating station acceptance
|
||||
@@ -112,7 +112,7 @@ static const Year MAX_YEAR = 5000000;
|
||||
#define MINUTES_DATE(day, hour, minute) ((day * 1440) + (hour * 60) + minute)
|
||||
|
||||
/** Get the current date in minutes */
|
||||
#define CURRENT_MINUTE (_scaled_date_ticks / _settings_client.gui.ticks_per_minute)
|
||||
#define CURRENT_MINUTE (_scaled_date_ticks / _settings_time.ticks_per_minute)
|
||||
|
||||
/**
|
||||
* Data structure to convert between Date and triplet (year, month, and day).
|
||||
|
@@ -422,7 +422,7 @@ public:
|
||||
|
||||
/* Recompute the minimum date display width if the cached one is no longer valid. */
|
||||
if (cached_date_width == 0 ||
|
||||
_settings_client.gui.time_in_minutes != cached_date_display_method ||
|
||||
_settings_time.time_in_minutes != cached_date_display_method ||
|
||||
_settings_client.gui.departure_show_both != cached_arr_dep_display_method) {
|
||||
this->RecomputeDateWidth();
|
||||
}
|
||||
@@ -539,14 +539,14 @@ void DeparturesWindow<Twaypoint>::RecomputeDateWidth()
|
||||
{
|
||||
cached_date_width = 0;
|
||||
cached_status_width = 0;
|
||||
cached_date_display_method = _settings_client.gui.time_in_minutes;
|
||||
cached_date_display_method = _settings_time.time_in_minutes;
|
||||
cached_arr_dep_display_method = _settings_client.gui.departure_show_both;
|
||||
|
||||
cached_status_width = max((GetStringBoundingBox(STR_DEPARTURES_ON_TIME)).width, cached_status_width);
|
||||
cached_status_width = max((GetStringBoundingBox(STR_DEPARTURES_DELAYED)).width, cached_status_width);
|
||||
cached_status_width = max((GetStringBoundingBox(STR_DEPARTURES_CANCELLED)).width, cached_status_width);
|
||||
|
||||
uint interval = cached_date_display_method ? _settings_client.gui.ticks_per_minute : DAY_TICKS;
|
||||
uint interval = cached_date_display_method ? _settings_time.ticks_per_minute : DAY_TICKS;
|
||||
uint count = cached_date_display_method ? 24*60 : 365;
|
||||
|
||||
for (uint i = 0; i < count; ++i) {
|
||||
|
@@ -1535,6 +1535,8 @@ STR_CONFIG_SETTING_TIMETABLE_IN_TICKS :Show timetable
|
||||
STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT :Show travel times in time tables in game ticks instead of days
|
||||
STR_CONFIG_SETTING_TIMETABLE_LEFTOVER_TICKS :Show leftover ticks in timetable: {STRING2}
|
||||
STR_CONFIG_SETTING_TIMETABLE_LEFTOVER_TICKS_HELPTEXT :When converting from ticks to days/minutes in timetables, also show any leftover ticks
|
||||
STR_CONFIG_SETTING_OVERRIDE_TIME_SETTINGS :Use client time settings instead of savegame time settings: {STRING2}
|
||||
STR_CONFIG_SETTING_OVERRIDE_TIME_SETTINGS_HELPTEXT :Select whether to use local client settings for time display, instead of the time settings in the savegame.
|
||||
STR_CONFIG_SETTING_TIME_IN_MINUTES :Show time in minutes rather than days: {STRING2}
|
||||
STR_CONFIG_SETTING_TIME_IN_MINUTES_HELPTEXT :Select whether to use hours and minutes instead of days
|
||||
STR_CONFIG_SETTING_TICKS_PER_MINUTE :Ticks per minute: {STRING2}
|
||||
@@ -1905,6 +1907,8 @@ STR_CONFIG_SETTING_INTERFACE_VIEWPORTS :{ORANGE}Viewpor
|
||||
STR_CONFIG_SETTING_INTERFACE_CONSTRUCTION :{ORANGE}Construction
|
||||
STR_CONFIG_SETTING_INTERFACE_DEPARTUREBOARDS :{ORANGE}Departure boards
|
||||
STR_CONFIG_SETTING_INTERFACE_WALLCLOCK :{ORANGE}Wall clock
|
||||
STR_CONFIG_SETTING_INTERFACE_TIME_CLIENT :{ORANGE}Client settings
|
||||
STR_CONFIG_SETTING_INTERFACE_TIME_SAVEGAME :{ORANGE}Savegame settings
|
||||
STR_CONFIG_SETTING_INTERFACE_TIMETABLE :{ORANGE}Timetables
|
||||
STR_CONFIG_SETTING_INTERFACE_ADV_SIGNALS :{ORANGE}Signals (advanced)
|
||||
STR_CONFIG_SETTING_ADVISORS :{ORANGE}News / Advisors
|
||||
|
@@ -494,6 +494,7 @@ void MakeNewgameSettingsLive()
|
||||
/* Copy newgame settings to active settings.
|
||||
* Also initialise old settings needed for savegame conversion. */
|
||||
_settings_game = _settings_newgame;
|
||||
_settings_time = _settings_game.game_time = _settings_client.gui;
|
||||
_old_vds = _settings_client.company.vehicle;
|
||||
|
||||
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
|
||||
|
@@ -61,6 +61,7 @@
|
||||
#include "../tunnel_map.h"
|
||||
#include "../bridge_signal_map.h"
|
||||
#include "../water.h"
|
||||
#include "../settings_func.h"
|
||||
|
||||
|
||||
#include "saveload_internal.h"
|
||||
@@ -246,6 +247,8 @@ void ClearAllCachedNames()
|
||||
*/
|
||||
static void InitializeWindowsAndCaches()
|
||||
{
|
||||
SetupTimeSettings();
|
||||
|
||||
/* Initialize windows */
|
||||
ResetWindowSystem();
|
||||
SetupColoursAndInitialWindow();
|
||||
|
@@ -343,16 +343,16 @@ void OrderList::ResetScheduledDispatch()
|
||||
uint16 start_full_date_fract;
|
||||
uint32 duration;
|
||||
|
||||
if (_settings_client.gui.time_in_minutes) {
|
||||
if (_settings_time.time_in_minutes) {
|
||||
/* Set to 00:00 of today, and 1 day */
|
||||
|
||||
DateTicksScaled val;
|
||||
val = MINUTES_DATE(MINUTES_DAY(CURRENT_MINUTE), 0, 0);
|
||||
val -= _settings_client.gui.clock_offset;
|
||||
val *= _settings_client.gui.ticks_per_minute;
|
||||
val -= _settings_time.clock_offset;
|
||||
val *= _settings_time.ticks_per_minute;
|
||||
SchdispatchConvertToFullDateFract(val, &start_date, &start_full_date_fract);
|
||||
|
||||
duration = 24 * 60 * _settings_client.gui.ticks_per_minute;
|
||||
duration = 24 * 60 * _settings_time.ticks_per_minute;
|
||||
} else {
|
||||
/* Set Jan 1st and 365 day */
|
||||
start_date = DAYS_TILL(_cur_year);
|
||||
|
@@ -182,7 +182,7 @@ struct SchdispatchWindow : Window {
|
||||
case WID_SCHDISPATCH_MATRIX: {
|
||||
uint min_height = 0;
|
||||
|
||||
SetDParamMaxValue(0, _settings_client.gui.time_in_minutes ? 0 : MAX_YEAR * DAYS_IN_YEAR);
|
||||
SetDParamMaxValue(0, _settings_time.time_in_minutes ? 0 : MAX_YEAR * DAYS_IN_YEAR);
|
||||
Dimension unumber = GetStringBoundingBox(STR_JUST_DATE_WALLCLOCK_TINY);
|
||||
const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL);
|
||||
this->flag_width = UnScaleGUI(spr->width) + WD_FRAMERECT_RIGHT;
|
||||
@@ -472,7 +472,7 @@ struct SchdispatchWindow : Window {
|
||||
}
|
||||
|
||||
case WID_SCHDISPATCH_ADD: {
|
||||
if (_settings_client.gui.time_in_minutes && _settings_client.gui.timetable_start_text_entry) {
|
||||
if (_settings_time.time_in_minutes && _settings_client.gui.timetable_start_text_entry) {
|
||||
ShowQueryString(STR_EMPTY, STR_SCHDISPATCH_ADD_CAPTION, 31, this, CS_NUMERAL, QSF_NONE);
|
||||
} else {
|
||||
ShowSetDateWindow(this, v->index, _scaled_date_ticks, _cur_year, _cur_year + 15, ScheduleAddCallback);
|
||||
@@ -481,16 +481,16 @@ struct SchdispatchWindow : Window {
|
||||
}
|
||||
|
||||
case WID_SCHDISPATCH_SET_DURATION: {
|
||||
SetDParam(0, RoundDivSU(v->orders.list->GetScheduledDispatchDuration(), _settings_client.gui.ticks_per_minute ? _settings_client.gui.ticks_per_minute : DAY_TICKS));
|
||||
ShowQueryString(STR_JUST_INT, _settings_client.gui.time_in_minutes ? STR_SCHDISPATCH_DURATION_CAPTION_MINUTE : STR_SCHDISPATCH_DURATION_CAPTION_DAY, 31, this, CS_NUMERAL, QSF_NONE);
|
||||
SetDParam(0, RoundDivSU(v->orders.list->GetScheduledDispatchDuration(), _settings_time.ticks_per_minute ? _settings_time.ticks_per_minute : DAY_TICKS));
|
||||
ShowQueryString(STR_JUST_INT, _settings_time.time_in_minutes ? STR_SCHDISPATCH_DURATION_CAPTION_MINUTE : STR_SCHDISPATCH_DURATION_CAPTION_DAY, 31, this, CS_NUMERAL, QSF_NONE);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_SCHDISPATCH_SET_START_DATE: {
|
||||
if (_settings_client.gui.time_in_minutes && _settings_client.gui.timetable_start_text_entry) {
|
||||
if (_settings_time.time_in_minutes && _settings_client.gui.timetable_start_text_entry) {
|
||||
uint64 time = _scaled_date_ticks;
|
||||
time /= _settings_client.gui.ticks_per_minute;
|
||||
time += _settings_client.gui.clock_offset;
|
||||
time /= _settings_time.ticks_per_minute;
|
||||
time += _settings_time.clock_offset;
|
||||
time %= (24 * 60);
|
||||
time = (time % 60) + (((time / 60) % 24) * 100);
|
||||
SetDParam(0, time);
|
||||
@@ -502,8 +502,8 @@ struct SchdispatchWindow : Window {
|
||||
}
|
||||
|
||||
case WID_SCHDISPATCH_SET_DELAY: {
|
||||
SetDParam(0, RoundDivSU(v->orders.list->GetScheduledDispatchDelay(), _settings_client.gui.ticks_per_minute ? _settings_client.gui.ticks_per_minute : DAY_TICKS));
|
||||
ShowQueryString(STR_JUST_INT, _settings_client.gui.time_in_minutes ? STR_SCHDISPATCH_DELAY_CAPTION_MINUTE : STR_SCHDISPATCH_DELAY_CAPTION_DAY, 31, this, CS_NUMERAL, QSF_NONE);
|
||||
SetDParam(0, RoundDivSU(v->orders.list->GetScheduledDispatchDelay(), _settings_time.ticks_per_minute ? _settings_time.ticks_per_minute : DAY_TICKS));
|
||||
ShowQueryString(STR_JUST_INT, _settings_time.time_in_minutes ? STR_SCHDISPATCH_DELAY_CAPTION_MINUTE : STR_SCHDISPATCH_DELAY_CAPTION_DAY, 31, this, CS_NUMERAL, QSF_NONE);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -532,8 +532,8 @@ struct SchdispatchWindow : Window {
|
||||
uint minutes = (val % 100) % 60;
|
||||
uint hours = (val / 100) % 24;
|
||||
DateTicksScaled slot = MINUTES_DATE(MINUTES_DAY(CURRENT_MINUTE), hours, minutes);
|
||||
slot -= _settings_client.gui.clock_offset;
|
||||
slot *= _settings_client.gui.ticks_per_minute;
|
||||
slot -= _settings_time.clock_offset;
|
||||
slot *= _settings_time.ticks_per_minute;
|
||||
ScheduleAddIntl(v->index, slot);
|
||||
}
|
||||
break;
|
||||
@@ -547,8 +547,8 @@ struct SchdispatchWindow : Window {
|
||||
uint minutes = (val % 100) % 60;
|
||||
uint hours = (val / 100) % 24;
|
||||
DateTicksScaled start = MINUTES_DATE(MINUTES_DAY(CURRENT_MINUTE), hours, minutes);
|
||||
start -= _settings_client.gui.clock_offset;
|
||||
start *= _settings_client.gui.ticks_per_minute;
|
||||
start -= _settings_time.clock_offset;
|
||||
start *= _settings_time.ticks_per_minute;
|
||||
SetScheduleStartDateIntl(v->index, start);
|
||||
}
|
||||
break;
|
||||
@@ -558,8 +558,8 @@ struct SchdispatchWindow : Window {
|
||||
int32 val = StrEmpty(str) ? 0 : strtoul(str, nullptr, 10);
|
||||
|
||||
if (val > 0) {
|
||||
if (_settings_client.gui.time_in_minutes) {
|
||||
val *= _settings_client.gui.ticks_per_minute;
|
||||
if (_settings_time.time_in_minutes) {
|
||||
val *= _settings_time.ticks_per_minute;
|
||||
} else {
|
||||
val *= DAY_TICKS;
|
||||
}
|
||||
@@ -574,8 +574,8 @@ struct SchdispatchWindow : Window {
|
||||
int32 val = StrEmpty(str) ? -1 : strtoul(str, &end, 10);
|
||||
|
||||
if (val >= 0 && end && *end == 0) {
|
||||
if (_settings_client.gui.time_in_minutes) {
|
||||
val *= _settings_client.gui.ticks_per_minute;
|
||||
if (_settings_time.time_in_minutes) {
|
||||
val *= _settings_time.ticks_per_minute;
|
||||
} else {
|
||||
val *= DAY_TICKS;
|
||||
}
|
||||
|
@@ -86,6 +86,7 @@
|
||||
ClientSettings _settings_client;
|
||||
GameSettings _settings_game; ///< Game settings of a running game or the scenario editor.
|
||||
GameSettings _settings_newgame; ///< Game settings for new games (updated from the intro screen).
|
||||
TimeSettings _settings_time; ///< The effective settings that are used for time display.
|
||||
VehicleDefaultSettings _old_vds; ///< Used for loading default vehicles settings from old savegames
|
||||
char *_config_file; ///< Configuration file of OpenTTD
|
||||
std::string _config_file_text;
|
||||
@@ -1164,6 +1165,21 @@ static bool InvalidateVehTimetableWindow(int32 p1)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool UpdateTimeSettings(int32 p1)
|
||||
{
|
||||
SetupTimeSettings();
|
||||
InvalidateVehTimetableWindow(p1);
|
||||
MarkWholeScreenDirty();
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ChangeTimeOverrideMode(int32 p1)
|
||||
{
|
||||
InvalidateWindowClassesData(WC_GAME_OPTIONS);
|
||||
UpdateTimeSettings(p1);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool ZoomMinMaxChanged(int32 p1)
|
||||
{
|
||||
extern void ConstrainAllViewportsZoom();
|
||||
@@ -2882,3 +2898,8 @@ static bool IsSignedVarMemType(VarType vt)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetupTimeSettings()
|
||||
{
|
||||
_settings_time = (_game_mode == GM_MENU || _settings_client.gui.override_time_settings) ? _settings_client.gui : _settings_game.game_time;
|
||||
}
|
||||
|
@@ -37,4 +37,6 @@ void SetDefaultCompanySettings(CompanyID cid);
|
||||
|
||||
void SyncCompanySettings();
|
||||
|
||||
void SetupTimeSettings();
|
||||
|
||||
#endif /* SETTINGS_FUNC_H */
|
||||
|
@@ -38,6 +38,7 @@
|
||||
#include "zoom_func.h"
|
||||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
@@ -847,6 +848,7 @@ struct SettingsContainer {
|
||||
struct SettingsPage : BaseSettingEntry, SettingsContainer {
|
||||
StringID title; ///< Title of the sub-page
|
||||
bool folded; ///< Sub-page is folded (not visible except for its title)
|
||||
std::function<bool()> hide_callback; ///< optional callback, returns true if this shouldbe hidden
|
||||
|
||||
SettingsPage(StringID title);
|
||||
|
||||
@@ -1454,6 +1456,7 @@ bool SettingsPage::UpdateFilterState(SettingFilter &filter, bool force_visible)
|
||||
}
|
||||
|
||||
bool visible = SettingsContainer::UpdateFilterState(filter, force_visible);
|
||||
if (this->hide_callback && this->hide_callback()) visible = false;
|
||||
if (visible) {
|
||||
CLRBITS(this->flags, SEF_FILTERED);
|
||||
} else {
|
||||
@@ -1674,11 +1677,27 @@ static SettingsContainer &GetSettingsTree()
|
||||
|
||||
SettingsPage *wallclock = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_WALLCLOCK));
|
||||
{
|
||||
wallclock->Add(new SettingEntry("gui.time_in_minutes"));
|
||||
wallclock->Add(new SettingEntry("gui.timetable_start_text_entry"));
|
||||
wallclock->Add(new SettingEntry("gui.ticks_per_minute"));
|
||||
wallclock->Add(new SettingEntry("gui.override_time_settings"));
|
||||
SettingsPage *game = wallclock->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_TIME_SAVEGAME));
|
||||
{
|
||||
game->hide_callback = []() -> bool {
|
||||
return _game_mode == GM_MENU;
|
||||
};
|
||||
game->Add(new SettingEntry("game_time.time_in_minutes"));
|
||||
game->Add(new SettingEntry("game_time.ticks_per_minute"));
|
||||
game->Add(new SettingEntry("game_time.clock_offset"));
|
||||
}
|
||||
SettingsPage *client = wallclock->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_TIME_CLIENT));
|
||||
{
|
||||
client->hide_callback = []() -> bool {
|
||||
return _game_mode != GM_MENU && !_settings_client.gui.override_time_settings;
|
||||
};
|
||||
client->Add(new SettingEntry("gui.time_in_minutes"));
|
||||
client->Add(new SettingEntry("gui.ticks_per_minute"));
|
||||
client->Add(new SettingEntry("gui.clock_offset"));
|
||||
}
|
||||
|
||||
wallclock->Add(new SettingEntry("gui.date_with_time"));
|
||||
wallclock->Add(new SettingEntry("gui.clock_offset"));
|
||||
}
|
||||
|
||||
SettingsPage *timetable = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_TIMETABLE));
|
||||
@@ -1686,6 +1705,7 @@ static SettingsContainer &GetSettingsTree()
|
||||
timetable->Add(new SettingEntry("gui.timetable_in_ticks"));
|
||||
timetable->Add(new SettingEntry("gui.timetable_leftover_ticks"));
|
||||
timetable->Add(new SettingEntry("gui.timetable_arrival_departure"));
|
||||
timetable->Add(new SettingEntry("gui.timetable_start_text_entry"));
|
||||
}
|
||||
|
||||
SettingsPage *advsig = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_ADV_SIGNALS));
|
||||
|
@@ -79,8 +79,15 @@ enum ViewportScrollMode {
|
||||
VSM_END, ///< Number of scroll mode settings.
|
||||
};
|
||||
|
||||
/** Settings related to time display. This may be loaded from the savegame and/or overriden by the client. */
|
||||
struct TimeSettings {
|
||||
bool time_in_minutes; ///< whether to use the hh:mm conversion when printing dates
|
||||
uint16 ticks_per_minute; ///< how many ticks per minute
|
||||
uint16 clock_offset; ///< clock offset in minutes
|
||||
};
|
||||
|
||||
/** Settings related to the GUI and other stuff that is not saved in the savegame. */
|
||||
struct GUISettings {
|
||||
struct GUISettings : public TimeSettings {
|
||||
bool sg_full_load_any; ///< new full load calculation, any cargo must be full read from pre v93 savegames
|
||||
bool lost_vehicle_warn; ///< if a vehicle can't find its destination, show a warning
|
||||
uint8 order_review_system; ///< perform order reviews on vehicles
|
||||
@@ -153,13 +160,11 @@ struct GUISettings {
|
||||
bool pause_on_newgame; ///< whether to start new games paused or not
|
||||
bool enable_signal_gui; ///< show the signal GUI when the signal button is pressed
|
||||
Year coloured_news_year; ///< when does newspaper become coloured?
|
||||
bool override_time_settings; ///< Whether to override time display settings stored in savegame.
|
||||
bool timetable_in_ticks; ///< whether to show the timetable in ticks rather than days
|
||||
bool timetable_leftover_ticks; ///< whether to show leftover ticks after converting to minutes/days, in the timetable
|
||||
bool time_in_minutes; ///< whether to use the hh:mm conversion when printing dates
|
||||
bool timetable_start_text_entry; ///< whether to enter timetable start times as text (hhmm format)
|
||||
uint16 ticks_per_minute; ///< how many ticks per minute
|
||||
uint8 date_with_time; ///< whether to show the month and year with the time
|
||||
uint16 clock_offset; ///< clock offset in minutes
|
||||
bool quick_goto; ///< Allow quick access to 'goto button' in vehicle orders window
|
||||
bool auto_euro; ///< automatically switch to euro in 2002
|
||||
byte drag_signals_density; ///< many signals density
|
||||
@@ -669,6 +674,7 @@ struct GameSettings {
|
||||
StationSettings station; ///< settings related to station management
|
||||
LocaleSettings locale; ///< settings related to used currency/unit system in the current game
|
||||
DebugSettings debug; ///< debug settings
|
||||
TimeSettings game_time; ///< time display settings.
|
||||
};
|
||||
|
||||
/** All settings that are only important for the local client. */
|
||||
@@ -690,6 +696,9 @@ extern GameSettings _settings_game;
|
||||
/** The settings values that are used for new games and/or modified in config file. */
|
||||
extern GameSettings _settings_newgame;
|
||||
|
||||
/** The effective settings that are used for time display. */
|
||||
extern TimeSettings _settings_time;
|
||||
|
||||
/** Old vehicle settings, which were game settings before, and are company settings now. (Needed for savegame conversion) */
|
||||
extern VehicleDefaultSettings _old_vds;
|
||||
|
||||
|
@@ -224,7 +224,7 @@ struct StatusBarWindow : Window {
|
||||
{
|
||||
if (_pause_mode != PM_UNPAUSED) return;
|
||||
|
||||
if (_settings_client.gui.time_in_minutes && this->last_minute != CURRENT_MINUTE) {
|
||||
if (_settings_time.time_in_minutes && this->last_minute != CURRENT_MINUTE) {
|
||||
this->last_minute = CURRENT_MINUTE;
|
||||
this->SetWidgetDirty(WID_S_LEFT);
|
||||
}
|
||||
|
@@ -415,7 +415,7 @@ static char *FormatBytes(char *buff, int64 number, const char *last)
|
||||
|
||||
static char *FormatWallClockString(char *buff, DateTicksScaled ticks, const char *last, bool show_date, uint case_index)
|
||||
{
|
||||
Minutes minutes = ticks / _settings_client.gui.ticks_per_minute + _settings_client.gui.clock_offset;
|
||||
Minutes minutes = ticks / _settings_time.ticks_per_minute + _settings_time.clock_offset;
|
||||
char hour[3], minute[3];
|
||||
seprintf(hour, lastof(hour), "%02i", (int) MINUTES_HOUR(minutes) );
|
||||
seprintf(minute, lastof(minute), "%02i", (int) MINUTES_MINUTE(minutes));
|
||||
@@ -1424,7 +1424,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
||||
break;
|
||||
|
||||
case SCC_DATE_WALLCLOCK_LONG: { // {DATE_WALLCLOCK_LONG}
|
||||
if (_settings_client.gui.time_in_minutes) {
|
||||
if (_settings_time.time_in_minutes) {
|
||||
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_LONG), last, _settings_client.gui.date_with_time, next_substr_case_index);
|
||||
} else {
|
||||
buff = FormatYmdString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_LONG) / (DAY_TICKS * _settings_game.economy.day_length_factor), last, next_substr_case_index);
|
||||
@@ -1433,7 +1433,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
||||
}
|
||||
|
||||
case SCC_DATE_WALLCLOCK_SHORT: { // {DATE_WALLCLOCK_SHORT}
|
||||
if (_settings_client.gui.time_in_minutes) {
|
||||
if (_settings_time.time_in_minutes) {
|
||||
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_SHORT), last, _settings_client.gui.date_with_time, next_substr_case_index);
|
||||
} else {
|
||||
buff = FormatYmdString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_SHORT) / (DAY_TICKS * _settings_game.economy.day_length_factor), last, next_substr_case_index);
|
||||
@@ -1442,7 +1442,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
||||
}
|
||||
|
||||
case SCC_DATE_WALLCLOCK_TINY: { // {DATE_WALLCLOCK_TINY}
|
||||
if (_settings_client.gui.time_in_minutes) {
|
||||
if (_settings_time.time_in_minutes) {
|
||||
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_TINY), last, false, next_substr_case_index);
|
||||
} else {
|
||||
buff = FormatTinyOrISODate(buff, args->GetInt64(SCC_DATE_WALLCLOCK_TINY) / (DAY_TICKS * _settings_game.economy.day_length_factor), STR_FORMAT_DATE_TINY, last);
|
||||
@@ -1451,7 +1451,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
||||
}
|
||||
|
||||
case SCC_DATE_WALLCLOCK_ISO: { // {DATE_WALLCLOCK_ISO}
|
||||
if (_settings_client.gui.time_in_minutes) {
|
||||
if (_settings_time.time_in_minutes) {
|
||||
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_ISO), last, false, next_substr_case_index);
|
||||
} else {
|
||||
buff = FormatTinyOrISODate(buff, args->GetInt64(SCC_DATE_WALLCLOCK_ISO) / (DAY_TICKS * _settings_game.economy.day_length_factor), STR_FORMAT_DATE_ISO, last);
|
||||
|
@@ -34,6 +34,8 @@ static bool CheckFreeformEdges(int32 p1);
|
||||
static bool ChangeDynamicEngines(int32 p1);
|
||||
static bool StationCatchmentChanged(int32 p1);
|
||||
static bool InvalidateVehTimetableWindow(int32 p1);
|
||||
static bool UpdateTimeSettings(int32 p1);
|
||||
static bool ChangeTimeOverrideMode(int32 p1);
|
||||
static bool InvalidateCompanyLiveryWindow(int32 p1);
|
||||
static bool InvalidateNewGRFChangeWindows(int32 p1);
|
||||
static bool InvalidateIndustryViewWindow(int32 p1);
|
||||
@@ -4200,20 +4202,21 @@ strhelp = STR_CONFIG_SETTING_TIMETABLE_LEFTOVER_TICKS_HELPTEXT
|
||||
proc = InvalidateVehTimetableWindow
|
||||
cat = SC_EXPERT
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.override_time_settings
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
def = false
|
||||
str = STR_CONFIG_SETTING_OVERRIDE_TIME_SETTINGS
|
||||
strhelp = STR_CONFIG_SETTING_OVERRIDE_TIME_SETTINGS_HELPTEXT
|
||||
proc = ChangeTimeOverrideMode
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.time_in_minutes
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
def = false
|
||||
str = STR_CONFIG_SETTING_TIME_IN_MINUTES
|
||||
strhelp = STR_CONFIG_SETTING_TIME_IN_MINUTES_HELPTEXT
|
||||
proc = InvalidateVehTimetableWindow
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.timetable_start_text_entry
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
def = false
|
||||
str = STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY
|
||||
strhelp = STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY_HELPTEXT
|
||||
proc = UpdateTimeSettings
|
||||
|
||||
[SDTC_VAR]
|
||||
var = gui.ticks_per_minute
|
||||
@@ -4223,9 +4226,60 @@ strval = STR_JUST_INT
|
||||
def = 74
|
||||
min = 1
|
||||
max = 8192
|
||||
interval = 10
|
||||
str = STR_CONFIG_SETTING_TICKS_PER_MINUTE
|
||||
strhelp = STR_CONFIG_SETTING_TICKS_PER_MINUTE_HELPTEXT
|
||||
proc = RedrawScreen
|
||||
proc = UpdateTimeSettings
|
||||
|
||||
[SDTC_VAR]
|
||||
var = gui.clock_offset
|
||||
type = SLE_UINT16
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
strval = STR_JUST_INT
|
||||
def = 0
|
||||
min = 0
|
||||
max = 1439
|
||||
interval = 60
|
||||
str = STR_CONFIG_SETTING_CLOCK_OFFSET
|
||||
strhelp = STR_CONFIG_SETTING_CLOCK_OFFSET_HELPTEXT
|
||||
proc = UpdateTimeSettings
|
||||
|
||||
[SDT_BOOL]
|
||||
base = GameSettings
|
||||
var = game_time.time_in_minutes
|
||||
def = false
|
||||
str = STR_CONFIG_SETTING_TIME_IN_MINUTES
|
||||
strhelp = STR_CONFIG_SETTING_TIME_IN_MINUTES_HELPTEXT
|
||||
proc = UpdateTimeSettings
|
||||
patxname = ""game_time.time_in_minutes""
|
||||
|
||||
[SDT_VAR]
|
||||
base = GameSettings
|
||||
var = game_time.ticks_per_minute
|
||||
type = SLE_UINT16
|
||||
strval = STR_JUST_INT
|
||||
def = 74
|
||||
min = 1
|
||||
max = 8192
|
||||
interval = 10
|
||||
str = STR_CONFIG_SETTING_TICKS_PER_MINUTE
|
||||
strhelp = STR_CONFIG_SETTING_TICKS_PER_MINUTE_HELPTEXT
|
||||
proc = UpdateTimeSettings
|
||||
patxname = ""game_time.ticks_per_minute""
|
||||
|
||||
[SDT_VAR]
|
||||
base = GameSettings
|
||||
var = game_time.clock_offset
|
||||
type = SLE_UINT16
|
||||
strval = STR_JUST_INT
|
||||
def = 0
|
||||
min = 0
|
||||
max = 1439
|
||||
interval = 60
|
||||
str = STR_CONFIG_SETTING_CLOCK_OFFSET
|
||||
strhelp = STR_CONFIG_SETTING_CLOCK_OFFSET_HELPTEXT
|
||||
proc = UpdateTimeSettings
|
||||
patxname = ""game_time.clock_offset""
|
||||
|
||||
;; gui.ticks_per_minute
|
||||
[SDT_NULL]
|
||||
@@ -4245,18 +4299,12 @@ strval = STR_CONFIG_SETTING_DATE_WITH_TIME_NONE
|
||||
strhelp = STR_CONFIG_SETTING_DATE_WITH_TIME_HELPTEXT
|
||||
proc = RedrawScreen
|
||||
|
||||
[SDTC_VAR]
|
||||
var = gui.clock_offset
|
||||
type = SLE_UINT16
|
||||
[SDTC_BOOL]
|
||||
var = gui.timetable_start_text_entry
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
strval = STR_JUST_INT
|
||||
def = 0
|
||||
min = 0
|
||||
max = 1439
|
||||
interval = 60
|
||||
str = STR_CONFIG_SETTING_CLOCK_OFFSET
|
||||
strhelp = STR_CONFIG_SETTING_CLOCK_OFFSET_HELPTEXT
|
||||
proc = RedrawScreen
|
||||
def = false
|
||||
str = STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY
|
||||
strhelp = STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY_HELPTEXT
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.timetable_arrival_departure
|
||||
|
@@ -50,7 +50,7 @@ void SetTimetableParams(int first_param, Ticks ticks)
|
||||
SetDParam(first_param, STR_TIMETABLE_TICKS);
|
||||
SetDParam(first_param + 1, ticks);
|
||||
} else {
|
||||
StringID str = _settings_client.gui.time_in_minutes ? STR_TIMETABLE_MINUTES : STR_TIMETABLE_DAYS;
|
||||
StringID str = _settings_time.time_in_minutes ? STR_TIMETABLE_MINUTES : STR_TIMETABLE_DAYS;
|
||||
size_t ratio = DATE_UNIT_SIZE;
|
||||
size_t units = ticks / ratio;
|
||||
size_t leftover = ticks % ratio;
|
||||
@@ -238,7 +238,7 @@ struct TimetableWindow : Window {
|
||||
case WID_VT_ARRIVAL_DEPARTURE_PANEL:
|
||||
SetDParamMaxValue(0, MAX_YEAR * DAYS_IN_YEAR, 0, FS_SMALL);
|
||||
this->deparr_time_width = GetStringBoundingBox(STR_JUST_DATE_TINY).width;
|
||||
SetDParamMaxValue(0, _settings_client.gui.time_in_minutes ? 0 : MAX_YEAR * DAYS_IN_YEAR);
|
||||
SetDParamMaxValue(0, _settings_time.time_in_minutes ? 0 : MAX_YEAR * DAYS_IN_YEAR);
|
||||
this->deparr_time_width = GetStringBoundingBox(STR_JUST_DATE_WALLCLOCK_TINY).width + 4;
|
||||
this->deparr_abbr_width = max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_ABBREVIATION).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_ABBREVIATION).width);
|
||||
size->width = WD_FRAMERECT_LEFT + this->deparr_abbr_width + 10 + this->deparr_time_width + WD_FRAMERECT_RIGHT;
|
||||
@@ -743,12 +743,12 @@ struct TimetableWindow : Window {
|
||||
}
|
||||
|
||||
case WID_VT_START_DATE: // Change the date that the timetable starts.
|
||||
if (_settings_client.gui.time_in_minutes && _settings_client.gui.timetable_start_text_entry) {
|
||||
if (_settings_time.time_in_minutes && _settings_client.gui.timetable_start_text_entry) {
|
||||
this->set_start_date_all = v->orders.list->IsCompleteTimetable() && _ctrl_pressed;
|
||||
StringID str = STR_JUST_INT;
|
||||
uint64 time = _scaled_date_ticks;
|
||||
time /= _settings_client.gui.ticks_per_minute;
|
||||
time += _settings_client.gui.clock_offset;
|
||||
time /= _settings_time.ticks_per_minute;
|
||||
time += _settings_time.clock_offset;
|
||||
time %= (24 * 60);
|
||||
time = (time % 60) + (((time / 60) % 24) * 100);
|
||||
SetDParam(0, time);
|
||||
@@ -948,10 +948,10 @@ struct TimetableWindow : Window {
|
||||
uint minutes = (val % 100) % 60;
|
||||
uint hours = (val / 100) % 24;
|
||||
DateTicksScaled time = MINUTES_DATE(MINUTES_DAY(CURRENT_MINUTE), hours, minutes);
|
||||
time -= _settings_client.gui.clock_offset;
|
||||
time -= _settings_time.clock_offset;
|
||||
|
||||
if (time < (CURRENT_MINUTE - 60)) time += 60 * 24;
|
||||
time *= _settings_client.gui.ticks_per_minute;
|
||||
time *= _settings_time.ticks_per_minute;
|
||||
ChangeTimetableStartIntl(v->index | (this->set_start_date_all ? 1 << 20 : 0), time);
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user