@@ -24,10 +24,10 @@
|
||||
|
||||
/** Window to select a date graphically by using dropdowns */
|
||||
struct SetDateWindow : Window {
|
||||
SetTickCallback *callback; ///< Callback to call when a date has been selected
|
||||
YearMonthDay date; ///< The currently selected date
|
||||
Year min_year; ///< The minimum year in the year dropdown
|
||||
Year max_year; ///< The maximum year (inclusive) in the year dropdown
|
||||
SetTickCallback *callback; ///< Callback to call when a date has been selected
|
||||
EconTime::YearMonthDay date; ///< The currently selected date
|
||||
EconTime::Year min_year; ///< The minimum year in the year dropdown
|
||||
EconTime::Year max_year; ///< The maximum year (inclusive) in the year dropdown
|
||||
|
||||
/**
|
||||
* Create the new 'set date' window
|
||||
@@ -39,12 +39,12 @@ struct SetDateWindow : Window {
|
||||
* @param max_year the maximum year (inclusive) to show in the year dropdown
|
||||
* @param callback the callback to call once a date has been selected
|
||||
*/
|
||||
SetDateWindow(WindowDesc *desc, WindowNumber window_number, Window *parent, Date initial_date, Year min_year, Year max_year,
|
||||
SetDateWindow(WindowDesc *desc, WindowNumber window_number, Window *parent, EconTime::Date initial_date, EconTime::Year min_year, EconTime::Year max_year,
|
||||
SetTickCallback *callback, StringID button_text, StringID button_tooltip) :
|
||||
Window(desc),
|
||||
callback(callback),
|
||||
min_year(std::max(MIN_YEAR, min_year)),
|
||||
max_year(std::min(MAX_YEAR, max_year))
|
||||
min_year(std::max(EconTime::MIN_YEAR, min_year)),
|
||||
max_year(std::min(EconTime::MAX_YEAR, max_year))
|
||||
{
|
||||
assert(this->min_year <= this->max_year);
|
||||
this->parent = parent;
|
||||
@@ -56,8 +56,8 @@ struct SetDateWindow : Window {
|
||||
}
|
||||
this->FinishInitNested(window_number);
|
||||
|
||||
if (initial_date == 0) initial_date = _date;
|
||||
this->date = ConvertDateToYMD(initial_date);
|
||||
if (initial_date == 0) initial_date = EconTime::CurDate();
|
||||
this->date = EconTime::ConvertDateToYMD(initial_date);
|
||||
this->date.year = Clamp(this->date.year, min_year, max_year);
|
||||
}
|
||||
|
||||
@@ -94,11 +94,11 @@ struct SetDateWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_SD_YEAR:
|
||||
for (Year i = this->min_year; i <= this->max_year; i++) {
|
||||
for (EconTime::Year i = this->min_year; i <= this->max_year; i++) {
|
||||
SetDParam(0, i);
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_JUST_INT, i, false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_JUST_INT, i.base(), false));
|
||||
}
|
||||
selected = this->date.year;
|
||||
selected = this->date.year.base();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ struct SetDateWindow : Window {
|
||||
break;
|
||||
|
||||
case WID_SD_YEAR:
|
||||
SetDParamMaxValue(0, this->max_year);
|
||||
SetDParamMaxValue(0, this->max_year.base());
|
||||
d = maxdim(d, GetStringBoundingBox(STR_JUST_INT));
|
||||
break;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ struct SetDateWindow : Window {
|
||||
break;
|
||||
case WID_SD_SET_DATE:
|
||||
if (this->callback != nullptr) {
|
||||
this->callback(this, DateToStateTicks(ConvertYMDToDate(this->date.year, this->date.month, this->date.day)));
|
||||
this->callback(this, DateToStateTicks(EconTime::ConvertYMDToDate(this->date.year, this->date.month, this->date.day)));
|
||||
}
|
||||
this->Close();
|
||||
break;
|
||||
@@ -184,7 +184,7 @@ struct SetMinutesWindow : SetDateWindow
|
||||
TickMinutes minutes;
|
||||
|
||||
/** Constructor. */
|
||||
SetMinutesWindow(WindowDesc *desc, WindowNumber window_number, Window *parent, StateTicks initial_tick, Year min_year, Year max_year,
|
||||
SetMinutesWindow(WindowDesc *desc, WindowNumber window_number, Window *parent, StateTicks initial_tick, EconTime::Year min_year, EconTime::Year max_year,
|
||||
SetTickCallback *callback, StringID button_text, StringID button_tooltip) :
|
||||
SetDateWindow(desc, window_number, parent, 0, min_year, max_year, callback, button_text, button_tooltip),
|
||||
minutes(_settings_time.ToTickMinutes(initial_tick))
|
||||
@@ -366,7 +366,7 @@ static WindowDesc _set_minutes_desc(__FILE__, __LINE__,
|
||||
* @param max_year the maximum year (inclusive) to show in the year dropdown
|
||||
* @param callback the callback to call once a date has been selected
|
||||
*/
|
||||
void ShowSetDateWindow(Window *parent, int window_number, StateTicks initial_tick, Year min_year, Year max_year,
|
||||
void ShowSetDateWindow(Window *parent, int window_number, StateTicks initial_tick, EconTime::Year min_year, EconTime::Year max_year,
|
||||
SetTickCallback *callback, StringID button_text, StringID button_tooltip)
|
||||
{
|
||||
CloseWindowByClass(WC_SET_DATE);
|
||||
|
Reference in New Issue
Block a user