29 TimerGameEconomy::YearMonthDay
date;
75 default: NOT_REACHED();
78 for (uint i = 0; i < 31; i++) {
81 selected = this->date.day;
85 for (uint i = 0; i < 12; i++) {
86 list.push_back(MakeDropDownListStringItem(
STR_MONTH_JAN + i, i));
88 selected = this->date.month;
94 list.push_back(MakeDropDownListStringItem(
STR_JUST_INT, i.base()));
96 selected = this->date.year.base();
110 for (uint i = 0; i < 31; i++) {
116 for (uint i = 0; i < 12; i++) {
127 d.width += padding.width;
128 d.height += padding.height;
161 this->date.day = index;
165 this->date.month = index;
169 this->date.year = index;
216void ShowSetDateWindow(
Window *parent,
int window_number, TimerGameEconomy::Date initial_date, TimerGameEconomy::Year min_year, TimerGameEconomy::Year max_year,
SetDateCallback *callback,
void *callback_data)
Storage class for Economy time constants.
static Date date
Current date in days (day counter).
static YearMonthDay ConvertDateToYMD(Date date)
Converts a Date to a Year, Month & Day.
static Date ConvertYMDToDate(Year year, Month month, Day day)
Converts a tuple of Year, Month and Day to a Date.
static constexpr NWidgetPart _nested_set_date_widgets[]
Widgets for the date setting window.
static WindowDesc _set_date_desc(WDP_CENTER, nullptr, 0, 0, WC_SET_DATE, WC_NONE, 0, _nested_set_date_widgets)
Description of the date setting window.
void ShowSetDateWindow(Window *parent, int window_number, TimerGameEconomy::Date initial_date, TimerGameEconomy::Year min_year, TimerGameEconomy::Year max_year, SetDateCallback *callback, void *callback_data)
Create the new 'set date' window.
Functions related to the graphical selection of a date.
void SetDateCallback(const Window *w, TimerGameEconomy::Date date, void *data)
Callback for when a date has been chosen.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
Functions related to the drop down widget.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
A number of safeguards to prevent using unsafe methods.
Definition of base types and functions in a cross-platform compatible way.
void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Functions related to OTTD's strings.
Dimensions (a width and height) of a rectangle in 2D.
Coordinates of a point in 2D.
Window to select a date graphically by using dropdowns.
SetDateWindow(WindowDesc &desc, WindowNumber window_number, Window *parent, TimerGameEconomy::Date initial_date, TimerGameEconomy::Year min_year, TimerGameEconomy::Year max_year, SetDateCallback *callback, void *callback_data)
Create the new 'set date' window.
Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
Compute the initial position of the window.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void OnDropdownSelect(WidgetID widget, int index) override
A dropdown option associated to this window has been selected.
TimerGameEconomy::Year min_year
The minimum year in the year dropdown.
SetDateCallback * callback
Callback to call when a date has been selected.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
void * callback_data
Callback data pointer.
void ShowDateDropDown(WidgetID widget)
Helper function to construct the dropdown.
TimerGameEconomy::Year max_year
The maximum year (inclusive) in the year dropdown.
TimerGameEconomy::YearMonthDay date
The currently selected date.
Templated helper to make a type-safe 'typedef' representing a single POD value.
High level window description.
Data structure for an opened window.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Window * parent
Parent window.
ResizeInfo resize
Resize information.
int left
x position of left edge of the window
int top
y position of top edge of the window
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
int height
Height of the window (number of pixels down in y direction)
int width
width of the window (number of pixels to the right in x direction)
WindowNumber window_number
Window number within the window class.
Definition of the game-economy-timer.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ WDP_CENTER
Center the window.
int32_t WindowNumber
Number to differentiate different windows of the same class.
@ WC_SET_DATE
Set date; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.