Allow changing time-keeping mode in-game

pull/661/head
Jonathan G Rennison 4 months ago
parent 471934e685
commit f32eef4f38

@ -1252,17 +1252,17 @@ static void ChangeTimekeepingUnits(int32_t)
InvalidateWindowClassesData(WC_GAME_OPTIONS, 0);
/* It is possible to change these units in Scenario Editor. We must set the economy date appropriately. */
if (_game_mode == GM_EDITOR) {
/* It is possible to change these units in-game. We must set the economy date appropriately. */
if (_game_mode != GM_MENU) {
EconTime::Date new_economy_date;
EconTime::DateFract new_economy_date_fract;
if (EconTime::UsingWallclockUnits()) {
/* If the new mode is wallclock units, set the economy year back to 1. */
new_economy_date = EconTime::DAYS_TILL_ORIGINAL_BASE_YEAR_WALLCLOCK_MODE;
new_economy_date_fract = 0;
/* If the new mode is wallclock units, adjust the economy date to account for different month/year lengths. */
new_economy_date = EconTime::ConvertYMDToDate(EconTime::CurYear(), EconTime::CurMonth(), Clamp<EconTime::Day>(EconTime::CurDay(), 1, EconTime::DAYS_IN_ECONOMY_WALLCLOCK_MONTH));
new_economy_date_fract = EconTime::CurDateFract();
} else {
/* If the new mode is calendar units, sync the economy year with the calendar year. */
/* If the new mode is calendar units, sync the economy date with the calendar date. */
new_economy_date = CalTime::CurDate().base();
new_economy_date_fract = CalTime::CurDateFract();
}

@ -715,7 +715,7 @@ cat = SC_BASIC
[SDT_VAR]
var = economy.timekeeping_units
type = SLE_UINT8
flags = SF_GUI_DROPDOWN | SF_NEWGAME_ONLY | SF_SCENEDIT_TOO
flags = SF_GUI_DROPDOWN
def = TKU_CALENDAR
min = TKU_CALENDAR
max = TKU_WALLCLOCK

Loading…
Cancel
Save