|
@@ -1145,13 +1145,13 @@ void ToggleDirtyBlocks()
|
|
|
/**
|
|
|
* Set the starting year for a scenario.
|
|
|
* @param year New starting year.
|
|
|
*/
|
|
|
void SetStartingYear(TimerGameCalendar::Year year)
|
|
|
{
|
|
|
_settings_game.game_creation.starting_year = Clamp(year, MIN_YEAR, MAX_YEAR);
|
|
|
_settings_game.game_creation.starting_year = Clamp(year, CalendarTime::MIN_YEAR, CalendarTime::MAX_YEAR);
|
|
|
TimerGameCalendar::Date new_date = TimerGameCalendar::ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1);
|
|
|
/* If you open a savegame as scenario there may already be link graphs.*/
|
|
|
LinkGraphSchedule::instance.ShiftDates(new_date - TimerGameCalendar::date);
|
|
|
TimerGameCalendar::SetDate(new_date, 0);
|
|
|
}
|
|
|
|
|
@@ -2354,14 +2354,14 @@ struct ScenarioEditorToolbarWindow : Win
|
|
|
{
|
|
|
Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
|
|
|
}
|
|
|
|
|
|
void OnPaint() override
|
|
|
{
|
|
|
this->SetWidgetDisabledState(WID_TE_DATE_BACKWARD, _settings_game.game_creation.starting_year <= MIN_YEAR);
|
|
|
this->SetWidgetDisabledState(WID_TE_DATE_FORWARD, _settings_game.game_creation.starting_year >= MAX_YEAR);
|
|
|
this->SetWidgetDisabledState(WID_TE_DATE_BACKWARD, _settings_game.game_creation.starting_year <= CalendarTime::MIN_YEAR);
|
|
|
this->SetWidgetDisabledState(WID_TE_DATE_FORWARD, _settings_game.game_creation.starting_year >= CalendarTime::MAX_YEAR);
|
|
|
this->SetWidgetDisabledState(WID_TE_ROADS, (GetRoadTypes(true) & ~_roadtypes_type) == ROADTYPES_NONE);
|
|
|
this->SetWidgetDisabledState(WID_TE_TRAMS, (GetRoadTypes(true) & _roadtypes_type) == ROADTYPES_NONE);
|
|
|
|
|
|
this->DrawWidgets();
|
|
|
}
|
|
|
|
|
@@ -2395,13 +2395,13 @@ struct ScenarioEditorToolbarWindow : Win
|
|
|
switch (widget) {
|
|
|
case WID_TE_SPACER:
|
|
|
size->width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + padding.width;
|
|
|
break;
|
|
|
|
|
|
case WID_TE_DATE:
|
|
|
SetDParam(0, TimerGameCalendar::ConvertYMDToDate(MAX_YEAR, 0, 1));
|
|
|
SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 0, 1));
|
|
|
*size = GetStringBoundingBox(STR_JUST_DATE_LONG);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void OnClick(Point pt, int widget, int click_count) override
|
|
@@ -2509,13 +2509,13 @@ struct ScenarioEditorToolbarWindow : Win
|
|
|
|
|
|
TimerGameCalendar::Year value;
|
|
|
if (!StrEmpty(str)) {
|
|
|
value = atoi(str);
|
|
|
} else {
|
|
|
/* An empty string means revert to the default */
|
|
|
value = static_cast<int32_t>(DEF_START_YEAR);
|
|
|
value = static_cast<int32_t>(CalendarTime::DEF_START_YEAR);
|
|
|
}
|
|
|
SetStartingYear(value);
|
|
|
|
|
|
this->SetDirty();
|
|
|
}
|
|
|
|