* Callback after the player changes the minutes per year. * @param new_value The intended new value of the setting, used for clamping. */
| 635 | * @param new_value The intended new value of the setting, used for clamping. |
| 636 | */ |
| 637 | static void ChangeMinutesPerYear(int32_t new_value) |
| 638 | { |
| 639 | /* We don't allow setting Minutes Per Year below default, unless it's to 0 for frozen calendar time. */ |
| 640 | if (new_value < CalendarTime::DEF_MINUTES_PER_YEAR) { |
| 641 | int clamped; |
| 642 | |
| 643 | /* If the new value is 1, we're probably at 0 and trying to increase the value, so we should jump up to default. */ |
| 644 | if (new_value == 1) { |
| 645 | clamped = CalendarTime::DEF_MINUTES_PER_YEAR; |
| 646 | } else { |
| 647 | clamped = CalendarTime::FROZEN_MINUTES_PER_YEAR; |
| 648 | } |
| 649 | |
| 650 | /* Override the setting with the clamped value. */ |
| 651 | if (_game_mode == GM_MENU) { |
| 652 | _settings_newgame.economy.minutes_per_calendar_year = clamped; |
| 653 | } else { |
| 654 | _settings_game.economy.minutes_per_calendar_year = clamped; |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | /* If the setting value is not the default, force the game to use wallclock timekeeping units. |
| 659 | * This can only happen in the menu, since the pre_cb ensures this setting can only be changed there, or if we're already using wallclock units. |
| 660 | */ |
| 661 | if (_game_mode == GM_MENU && (_settings_newgame.economy.minutes_per_calendar_year != CalendarTime::DEF_MINUTES_PER_YEAR)) { |
| 662 | if (_settings_newgame.economy.timekeeping_units != TKU_WALLCLOCK) { |
| 663 | _settings_newgame.economy.timekeeping_units = TKU_WALLCLOCK; |
| 664 | ChangeTimekeepingUnits(TKU_WALLCLOCK); |
| 665 | } |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | /* Get the valid range of the "minutes per calendar year" setting. */ |
| 670 | static std::tuple<int32_t, uint32_t> GetMinutesPerYearRange(const IntSettingDesc &) |
nothing calls this directly
no test coverage detected