summaryrefslogtreecommitdiff
path: root/src/date_gui.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-11-04 00:10:13 +0100
committerMichael Lutz <michi@icosahedron.de>2021-12-16 22:28:32 +0100
commit2637c06f88ed6f9dea55449883f42a62c30f19d8 (patch)
treed54f06200b16c0c51b40cce65242e3099c8b4b7c /src/date_gui.cpp
parent211c630cbe4185a2adf8b8cd8f52ca58f8bf17ed (diff)
downloadopenttd-2637c06f88ed6f9dea55449883f42a62c30f19d8.tar.xz
Codechange: Un-bitstuff timetable commands.
Diffstat (limited to 'src/date_gui.cpp')
-rw-r--r--src/date_gui.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/date_gui.cpp b/src/date_gui.cpp
index 932728720..66c9a378a 100644
--- a/src/date_gui.cpp
+++ b/src/date_gui.cpp
@@ -24,6 +24,7 @@
/** Window to select a date graphically by using dropdowns */
struct SetDateWindow : Window {
SetDateCallback *callback; ///< Callback to call when a date has been selected
+ void *callback_data; ///< Callback data pointer.
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
@@ -38,9 +39,10 @@ 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, SetDateCallback *callback) :
+ SetDateWindow(WindowDesc *desc, WindowNumber window_number, Window *parent, Date initial_date, Year min_year, Year max_year, SetDateCallback *callback, void *callback_data) :
Window(desc),
callback(callback),
+ callback_data(callback_data),
min_year(std::max(MIN_YEAR, min_year)),
max_year(std::min(MAX_YEAR, max_year))
{
@@ -146,7 +148,7 @@ struct SetDateWindow : Window {
break;
case WID_SD_SET_DATE:
- if (this->callback != nullptr) this->callback(this, ConvertYMDToDate(this->date.year, this->date.month, this->date.day));
+ if (this->callback != nullptr) this->callback(this, ConvertYMDToDate(this->date.year, this->date.month, this->date.day), this->callback_data);
this->Close();
break;
}
@@ -209,9 +211,10 @@ static WindowDesc _set_date_desc(
* @param min_year the minimum year to show in the year dropdown
* @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
+ * @param callback_data extra callback data
*/
-void ShowSetDateWindow(Window *parent, int window_number, Date initial_date, Year min_year, Year max_year, SetDateCallback *callback)
+void ShowSetDateWindow(Window *parent, int window_number, Date initial_date, Year min_year, Year max_year, SetDateCallback *callback, void *callback_data)
{
CloseWindowByClass(WC_SET_DATE);
- new SetDateWindow(&_set_date_desc, window_number, parent, initial_date, min_year, max_year, callback);
+ new SetDateWindow(&_set_date_desc, window_number, parent, initial_date, min_year, max_year, callback, callback_data);
}