Import departure boards patch
This commit is contained in:

committed by
Jonathan G Rennison

parent
4dbabbd9e2
commit
79138de1b9
@@ -510,6 +510,10 @@
|
|||||||
RelativePath=".\..\src\dedicated.cpp"
|
RelativePath=".\..\src\dedicated.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\departures.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\depot.cpp"
|
RelativePath=".\..\src\depot.cpp"
|
||||||
>
|
>
|
||||||
@@ -1002,6 +1006,18 @@
|
|||||||
RelativePath=".\..\src\video\dedicated_v.h"
|
RelativePath=".\..\src\video\dedicated_v.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\departures_func.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\departures_gui.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\departures_type.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\depot_base.h"
|
RelativePath=".\..\src\depot_base.h"
|
||||||
>
|
>
|
||||||
@@ -2074,6 +2090,10 @@
|
|||||||
RelativePath=".\..\src\date_gui.cpp"
|
RelativePath=".\..\src\date_gui.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\departures_gui.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\depot_gui.cpp"
|
RelativePath=".\..\src\depot_gui.cpp"
|
||||||
>
|
>
|
||||||
|
@@ -507,6 +507,10 @@
|
|||||||
RelativePath=".\..\src\dedicated.cpp"
|
RelativePath=".\..\src\dedicated.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\departures.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\depot.cpp"
|
RelativePath=".\..\src\depot.cpp"
|
||||||
>
|
>
|
||||||
@@ -999,6 +1003,18 @@
|
|||||||
RelativePath=".\..\src\video\dedicated_v.h"
|
RelativePath=".\..\src\video\dedicated_v.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\departures_func.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\departures_gui.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\departures_type.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\depot_base.h"
|
RelativePath=".\..\src\depot_base.h"
|
||||||
>
|
>
|
||||||
@@ -2071,6 +2087,10 @@
|
|||||||
RelativePath=".\..\src\date_gui.cpp"
|
RelativePath=".\..\src\date_gui.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\..\src\departures_gui.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\..\src\depot_gui.cpp"
|
RelativePath=".\..\src\depot_gui.cpp"
|
||||||
>
|
>
|
||||||
|
@@ -18,6 +18,7 @@ currency.cpp
|
|||||||
date.cpp
|
date.cpp
|
||||||
debug.cpp
|
debug.cpp
|
||||||
dedicated.cpp
|
dedicated.cpp
|
||||||
|
departures.cpp
|
||||||
depot.cpp
|
depot.cpp
|
||||||
disaster_vehicle.cpp
|
disaster_vehicle.cpp
|
||||||
driver.cpp
|
driver.cpp
|
||||||
@@ -171,6 +172,9 @@ date_gui.h
|
|||||||
date_type.h
|
date_type.h
|
||||||
debug.h
|
debug.h
|
||||||
video/dedicated_v.h
|
video/dedicated_v.h
|
||||||
|
departures_func.h
|
||||||
|
departures_gui.h
|
||||||
|
departures_type.h
|
||||||
depot_base.h
|
depot_base.h
|
||||||
depot_func.h
|
depot_func.h
|
||||||
depot_map.h
|
depot_map.h
|
||||||
@@ -456,6 +460,7 @@ cheat_gui.cpp
|
|||||||
company_gui.cpp
|
company_gui.cpp
|
||||||
console_gui.cpp
|
console_gui.cpp
|
||||||
date_gui.cpp
|
date_gui.cpp
|
||||||
|
departures_gui.cpp
|
||||||
depot_gui.cpp
|
depot_gui.cpp
|
||||||
dock_gui.cpp
|
dock_gui.cpp
|
||||||
engine_gui.cpp
|
engine_gui.cpp
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "order_type.h"
|
#include "order_type.h"
|
||||||
#include "date_type.h"
|
#include "date_type.h"
|
||||||
|
#include "timetable.h"
|
||||||
|
|
||||||
/** Various front vehicle properties that are preserved when autoreplacing, using order-backup or switching front engines within a consist. */
|
/** Various front vehicle properties that are preserved when autoreplacing, using order-backup or switching front engines within a consist. */
|
||||||
struct BaseConsist {
|
struct BaseConsist {
|
||||||
@@ -22,7 +23,11 @@ struct BaseConsist {
|
|||||||
/* Used for timetabling. */
|
/* Used for timetabling. */
|
||||||
uint32 current_order_time; ///< How many ticks have passed since this order started.
|
uint32 current_order_time; ///< How many ticks have passed since this order started.
|
||||||
int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is.
|
int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is.
|
||||||
|
#if WALLCLOCK_NETWORK_COMPATIBLE
|
||||||
Date timetable_start; ///< When the vehicle is supposed to start the timetable.
|
Date timetable_start; ///< When the vehicle is supposed to start the timetable.
|
||||||
|
#else
|
||||||
|
DateTicks timetable_start; ///< When the vehicle is supposed to start the timetable.
|
||||||
|
#endif
|
||||||
|
|
||||||
uint16 service_interval; ///< The interval for (automatic) servicing; either in days or %.
|
uint16 service_interval; ///< The interval for (automatic) servicing; either in days or %.
|
||||||
|
|
||||||
|
@@ -24,6 +24,8 @@ void SetDate(Date date, DateFract fract);
|
|||||||
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
|
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
|
||||||
Date ConvertYMDToDate(Year year, Month month, Day day);
|
Date ConvertYMDToDate(Year year, Month month, Day day);
|
||||||
|
|
||||||
|
#define YMD_TO_DATE(ymd) (ConvertYMDToDate(ymd.year, ymd.month, ymd.day))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the given year is a leap year or not.
|
* Checks whether the given year is a leap year or not.
|
||||||
* @param yr The year to check.
|
* @param yr The year to check.
|
||||||
|
158
src/date_gui.cpp
158
src/date_gui.cpp
@@ -16,6 +16,7 @@
|
|||||||
#include "window_gui.h"
|
#include "window_gui.h"
|
||||||
#include "date_gui.h"
|
#include "date_gui.h"
|
||||||
#include "core/geometry_func.hpp"
|
#include "core/geometry_func.hpp"
|
||||||
|
#include "settings_type.h"
|
||||||
|
|
||||||
#include "widgets/dropdown_type.h"
|
#include "widgets/dropdown_type.h"
|
||||||
#include "widgets/date_widget.h"
|
#include "widgets/date_widget.h"
|
||||||
@@ -65,7 +66,7 @@ struct SetDateWindow : Window {
|
|||||||
* Helper function to construct the dropdown.
|
* Helper function to construct the dropdown.
|
||||||
* @param widget the dropdown widget to create the dropdown for
|
* @param widget the dropdown widget to create the dropdown for
|
||||||
*/
|
*/
|
||||||
void ShowDateDropDown(int widget)
|
virtual void ShowDateDropDown(int widget)
|
||||||
{
|
{
|
||||||
int selected;
|
int selected;
|
||||||
DropDownList *list = new DropDownList();
|
DropDownList *list = new DropDownList();
|
||||||
@@ -146,9 +147,8 @@ struct SetDateWindow : Window {
|
|||||||
case WID_SD_YEAR:
|
case WID_SD_YEAR:
|
||||||
ShowDateDropDown(widget);
|
ShowDateDropDown(widget);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_SD_SET_DATE:
|
case WID_SD_SET_DATE:
|
||||||
if (this->callback != NULL) this->callback(this, ConvertYMDToDate(this->date.year, this->date.month, this->date.day));
|
if (this->callback != NULL) this->callback(this, ConvertYMDToDate(this->date.year, this->date.month, this->date.day) * DAY_TICKS);
|
||||||
delete this;
|
delete this;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -173,6 +173,122 @@ struct SetDateWindow : Window {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SetMinutesWindow : SetDateWindow
|
||||||
|
{
|
||||||
|
Minutes minutes;
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
SetMinutesWindow(WindowDesc *desc, WindowNumber window_number, Window *parent, DateTicks initial_date, Year min_year, Year max_year, SetDateCallback *callback) :
|
||||||
|
SetDateWindow(desc, window_number, parent, initial_date, min_year, max_year, callback),
|
||||||
|
minutes(initial_date / _settings_client.gui.ticks_per_minute)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to construct the dropdown.
|
||||||
|
* @param widget the dropdown widget to create the dropdown for
|
||||||
|
*/
|
||||||
|
virtual void ShowDateDropDown(int widget)
|
||||||
|
{
|
||||||
|
int selected;
|
||||||
|
DropDownList *list = new DropDownList();
|
||||||
|
|
||||||
|
switch (widget) {
|
||||||
|
default: NOT_REACHED();
|
||||||
|
|
||||||
|
case WID_SD_DAY:
|
||||||
|
for (uint i = 0; i < 60; i++) {
|
||||||
|
DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
|
||||||
|
item->SetParam(0, i);
|
||||||
|
*list->Append() = item;
|
||||||
|
}
|
||||||
|
selected = MINUTES_MINUTE(minutes);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WID_SD_MONTH:
|
||||||
|
for (uint i = 0; i < 24; i++) {
|
||||||
|
DropDownListParamStringItem *item = new DropDownListParamStringItem(STR_JUST_INT, i, false);
|
||||||
|
item->SetParam(0, i);
|
||||||
|
*list->Append() = item;
|
||||||
|
}
|
||||||
|
selected = MINUTES_HOUR(minutes);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShowDropDownList(this, list, selected, widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||||
|
{
|
||||||
|
Dimension d = {0, 0};
|
||||||
|
switch (widget) {
|
||||||
|
default: return;
|
||||||
|
|
||||||
|
case WID_SD_DAY:
|
||||||
|
for (uint i = 0; i < 60; i++) {
|
||||||
|
SetDParam(0, i);
|
||||||
|
d = maxdim(d, GetStringBoundingBox(STR_JUST_INT));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WID_SD_MONTH:
|
||||||
|
for (uint i = 0; i < 24; i++) {
|
||||||
|
SetDParam(0, i);
|
||||||
|
d = maxdim(d, GetStringBoundingBox(STR_JUST_INT));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
d.width += padding.width;
|
||||||
|
d.height += padding.height;
|
||||||
|
*size = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void SetStringParameters(int widget) const
|
||||||
|
{
|
||||||
|
switch (widget) {
|
||||||
|
case WID_SD_DAY: SetDParam(0, MINUTES_MINUTE(minutes)); break;
|
||||||
|
case WID_SD_MONTH: SetDParam(0, MINUTES_HOUR(minutes)); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnClick(Point pt, int widget, int click_count)
|
||||||
|
{
|
||||||
|
switch (widget) {
|
||||||
|
case WID_SD_DAY:
|
||||||
|
case WID_SD_MONTH:
|
||||||
|
case WID_SD_YEAR:
|
||||||
|
ShowDateDropDown(widget);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WID_SD_SET_DATE:
|
||||||
|
if (this->callback != NULL) this->callback(this->parent, ((DateTicks)minutes - _settings_client.gui.clock_offset) * _settings_client.gui.ticks_per_minute);
|
||||||
|
delete this;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnDropdownSelect(int widget, int index)
|
||||||
|
{
|
||||||
|
Minutes current = 0;
|
||||||
|
switch (widget) {
|
||||||
|
case WID_SD_DAY:
|
||||||
|
current = MINUTES_DATE(MINUTES_DAY(CURRENT_MINUTE), MINUTES_HOUR(minutes), index);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WID_SD_MONTH:
|
||||||
|
current = MINUTES_DATE(MINUTES_DAY(CURRENT_MINUTE), index, MINUTES_MINUTE(minutes));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current < (CURRENT_MINUTE - 60)) current += 60 * 24;
|
||||||
|
minutes = current;
|
||||||
|
|
||||||
|
this->SetDirty();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** Widgets for the date setting window. */
|
/** Widgets for the date setting window. */
|
||||||
static const NWidgetPart _nested_set_date_widgets[] = {
|
static const NWidgetPart _nested_set_date_widgets[] = {
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
@@ -195,6 +311,26 @@ static const NWidgetPart _nested_set_date_widgets[] = {
|
|||||||
EndContainer()
|
EndContainer()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const NWidgetPart _nested_set_minutes_widgets[] = {
|
||||||
|
NWidget(NWID_HORIZONTAL),
|
||||||
|
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
|
||||||
|
NWidget(WWT_CAPTION, COLOUR_BROWN), SetDataTip(STR_DATE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||||
|
EndContainer(),
|
||||||
|
NWidget(WWT_PANEL, COLOUR_BROWN),
|
||||||
|
NWidget(NWID_VERTICAL), SetPIP(6, 6, 6),
|
||||||
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(6, 6, 6),
|
||||||
|
NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_SD_MONTH), SetFill(1, 0), SetDataTip(STR_JUST_INT, STR_DATE_MINUTES_MONTH_TOOLTIP),
|
||||||
|
NWidget(WWT_DROPDOWN, COLOUR_ORANGE, WID_SD_DAY), SetFill(1, 0), SetDataTip(STR_JUST_INT, STR_DATE_MINUTES_DAY_TOOLTIP),
|
||||||
|
EndContainer(),
|
||||||
|
NWidget(NWID_HORIZONTAL),
|
||||||
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
||||||
|
NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_SD_SET_DATE), SetMinimalSize(100, 12), SetDataTip(STR_DATE_SET_DATE, STR_DATE_SET_DATE_TOOLTIP),
|
||||||
|
NWidget(NWID_SPACER), SetFill(1, 0),
|
||||||
|
EndContainer(),
|
||||||
|
EndContainer(),
|
||||||
|
EndContainer()
|
||||||
|
};
|
||||||
|
|
||||||
/** Description of the date setting window. */
|
/** Description of the date setting window. */
|
||||||
static WindowDesc _set_date_desc(
|
static WindowDesc _set_date_desc(
|
||||||
WDP_CENTER, NULL, 0, 0,
|
WDP_CENTER, NULL, 0, 0,
|
||||||
@@ -203,6 +339,13 @@ static WindowDesc _set_date_desc(
|
|||||||
_nested_set_date_widgets, lengthof(_nested_set_date_widgets)
|
_nested_set_date_widgets, lengthof(_nested_set_date_widgets)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
static WindowDesc _set_minutes_desc(
|
||||||
|
WDP_CENTER, NULL, 0, 0,
|
||||||
|
WC_SET_DATE, WC_NONE,
|
||||||
|
0,
|
||||||
|
_nested_set_minutes_widgets, lengthof(_nested_set_minutes_widgets)
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the new 'set date' window
|
* Create the new 'set date' window
|
||||||
* @param window_number number for the window
|
* @param window_number number for the window
|
||||||
@@ -212,8 +355,13 @@ static WindowDesc _set_date_desc(
|
|||||||
* @param max_year the maximum year (inclusive) 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 the callback to call once a date has been selected
|
||||||
*/
|
*/
|
||||||
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, DateTicks initial_date, Year min_year, Year max_year, SetDateCallback *callback)
|
||||||
{
|
{
|
||||||
DeleteWindowByClass(WC_SET_DATE);
|
DeleteWindowByClass(WC_SET_DATE);
|
||||||
new SetDateWindow(&_set_date_desc, window_number, parent, initial_date, min_year, max_year, callback);
|
|
||||||
|
if (!_settings_client.gui.time_in_minutes) {
|
||||||
|
new SetDateWindow(&_set_date_desc, window_number, parent, initial_date / DAY_TICKS, min_year, max_year, callback);
|
||||||
|
} else {
|
||||||
|
new SetMinutesWindow(&_set_minutes_desc, window_number, parent, initial_date + (_settings_client.gui.clock_offset * _settings_client.gui.ticks_per_minute), min_year, max_year, callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,8 +20,8 @@
|
|||||||
* @param w the window that sends the callback
|
* @param w the window that sends the callback
|
||||||
* @param date the date that has been chosen
|
* @param date the date that has been chosen
|
||||||
*/
|
*/
|
||||||
typedef void SetDateCallback(const Window *w, Date date);
|
typedef void SetDateCallback(const Window *w, DateTicks date);
|
||||||
|
|
||||||
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, DateTicks initial_date, Year min_year, Year max_year, SetDateCallback *callback);
|
||||||
|
|
||||||
#endif /* DATE_GUI_H */
|
#endif /* DATE_GUI_H */
|
||||||
|
@@ -12,10 +12,11 @@
|
|||||||
#ifndef DATE_TYPE_H
|
#ifndef DATE_TYPE_H
|
||||||
#define DATE_TYPE_H
|
#define DATE_TYPE_H
|
||||||
|
|
||||||
|
|
||||||
typedef int32 Date; ///< The type to store our dates in
|
typedef int32 Date; ///< The type to store our dates in
|
||||||
typedef uint16 DateFract; ///< The fraction of a date we're in, i.e. the number of ticks since the last date changeover
|
typedef uint16 DateFract; ///< The fraction of a date we're in, i.e. the number of ticks since the last date changeover
|
||||||
typedef int32 Ticks; ///< The type to store ticks in
|
typedef int32 Ticks; ///< The type to store ticks in
|
||||||
|
typedef int32 DateTicks; ///< The type to store dates in when tick-precision is required
|
||||||
|
typedef int32 Minutes; ///< The type to store minutes in
|
||||||
|
|
||||||
typedef int32 Year; ///< Type for the year, note: 0 based, i.e. starts at the year 0.
|
typedef int32 Year; ///< Type for the year, note: 0 based, i.e. starts at the year 0.
|
||||||
typedef uint8 Month; ///< Type for the month, note: 0 based, i.e. 0 = January, 11 = December.
|
typedef uint8 Month; ///< Type for the month, note: 0 based, i.e. 0 = January, 11 = December.
|
||||||
@@ -31,6 +32,8 @@ static const int DAY_TICKS = 74; ///< ticks per day
|
|||||||
static const int DAYS_IN_YEAR = 365; ///< days per year
|
static const int DAYS_IN_YEAR = 365; ///< days per year
|
||||||
static const int DAYS_IN_LEAP_YEAR = 366; ///< sometimes, you need one day more...
|
static const int DAYS_IN_LEAP_YEAR = 366; ///< sometimes, you need one day more...
|
||||||
|
|
||||||
|
#define DATE_UNIT_SIZE (_settings_client.gui.time_in_minutes ? _settings_client.gui.ticks_per_minute : DAY_TICKS)
|
||||||
|
|
||||||
static const int STATION_RATING_TICKS = 185; ///< cycle duration for updating station rating
|
static const int STATION_RATING_TICKS = 185; ///< cycle duration for updating station rating
|
||||||
static const int STATION_ACCEPTANCE_TICKS = 250; ///< cycle duration for updating station acceptance
|
static const int STATION_ACCEPTANCE_TICKS = 250; ///< cycle duration for updating station acceptance
|
||||||
static const int STATION_LINKGRAPH_TICKS = 504; ///< cycle duration for cleaning dead links
|
static const int STATION_LINKGRAPH_TICKS = 504; ///< cycle duration for cleaning dead links
|
||||||
@@ -39,7 +42,6 @@ static const int INDUSTRY_PRODUCE_TICKS = 256; ///< cycle duration for industr
|
|||||||
static const int TOWN_GROWTH_TICKS = 70; ///< cycle duration for towns trying to grow. (this originates from the size of the town array in TTD
|
static const int TOWN_GROWTH_TICKS = 70; ///< cycle duration for towns trying to grow. (this originates from the size of the town array in TTD
|
||||||
static const int INDUSTRY_CUT_TREE_TICKS = INDUSTRY_PRODUCE_TICKS * 2; ///< cycle duration for lumber mill's extra action
|
static const int INDUSTRY_CUT_TREE_TICKS = INDUSTRY_PRODUCE_TICKS * 2; ///< cycle duration for lumber mill's extra action
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are
|
* ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR and DAYS_TILL_ORIGINAL_BASE_YEAR are
|
||||||
* primarily used for loading newgrf and savegame data and returning some
|
* primarily used for loading newgrf and savegame data and returning some
|
||||||
@@ -96,6 +98,21 @@ static const Year MAX_YEAR = 5000000;
|
|||||||
/** The number of days till the last day */
|
/** The number of days till the last day */
|
||||||
#define MAX_DAY (DAYS_TILL(MAX_YEAR + 1) - 1)
|
#define MAX_DAY (DAYS_TILL(MAX_YEAR + 1) - 1)
|
||||||
|
|
||||||
|
/** The day when converting to minutes */
|
||||||
|
#define MINUTES_DAY(minutes) (minutes / 1440)
|
||||||
|
|
||||||
|
/** The hour when converting to minutes */
|
||||||
|
#define MINUTES_HOUR(minutes) ((minutes / 60) % 24)
|
||||||
|
|
||||||
|
/** The day when converting to minutes */
|
||||||
|
#define MINUTES_MINUTE(minutes) (minutes % 60)
|
||||||
|
|
||||||
|
/** Convert minutes to a date */
|
||||||
|
#define MINUTES_DATE(day, hour, minute) ((day * 1440) + (hour * 60) + minute)
|
||||||
|
|
||||||
|
/** Get the current date in minutes */
|
||||||
|
#define CURRENT_MINUTE ((((DateTicks)_date * DAY_TICKS) + _date_fract) / _settings_client.gui.ticks_per_minute)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data structure to convert between Date and triplet (year, month, and day).
|
* Data structure to convert between Date and triplet (year, month, and day).
|
||||||
* @see ConvertDateToYMD(), ConvertYMDToDate()
|
* @see ConvertDateToYMD(), ConvertYMDToDate()
|
||||||
|
644
src/departures.cpp
Normal file
644
src/departures.cpp
Normal file
@@ -0,0 +1,644 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of OpenTTD.
|
||||||
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||||
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file departures.cpp Scheduled departures from a station. */
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "gui.h"
|
||||||
|
#include "textbuf_gui.h"
|
||||||
|
#include "strings_func.h"
|
||||||
|
#include "window_func.h"
|
||||||
|
#include "vehicle_func.h"
|
||||||
|
#include "string_func.h"
|
||||||
|
#include "window_gui.h"
|
||||||
|
#include "timetable.h"
|
||||||
|
#include "vehiclelist.h"
|
||||||
|
#include "company_base.h"
|
||||||
|
#include "date_func.h"
|
||||||
|
#include "departures_gui.h"
|
||||||
|
#include "station_base.h"
|
||||||
|
#include "vehicle_gui_base.h"
|
||||||
|
#include "vehicle_base.h"
|
||||||
|
#include "vehicle_gui.h"
|
||||||
|
#include "order_base.h"
|
||||||
|
#include "settings_type.h"
|
||||||
|
#include "core/smallvec_type.hpp"
|
||||||
|
#include "date_type.h"
|
||||||
|
#include "company_type.h"
|
||||||
|
#include "cargo_type.h"
|
||||||
|
#include "departures_func.h"
|
||||||
|
#include "departures_type.h"
|
||||||
|
|
||||||
|
/** A scheduled order. */
|
||||||
|
typedef struct OrderDate
|
||||||
|
{
|
||||||
|
const Order *order; ///< The order
|
||||||
|
const Vehicle *v; ///< The vehicle carrying out the order
|
||||||
|
DateTicks expected_date;///< The date on which the order is expected to complete
|
||||||
|
Ticks lateness; ///< How late this order is expected to finish
|
||||||
|
DepartureStatus status; ///< Whether the vehicle has arrived to carry out the order yet
|
||||||
|
} OrderDate;
|
||||||
|
|
||||||
|
static bool IsDeparture(const Order *order, StationID station) {
|
||||||
|
return (order->GetType() == OT_GOTO_STATION &&
|
||||||
|
(StationID)order->GetDestination() == station &&
|
||||||
|
(order->GetLoadType() != OLFB_NO_LOAD ||
|
||||||
|
_settings_client.gui.departure_show_all_stops) &&
|
||||||
|
order->GetWaitTime() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsVia(const Order *order, StationID station) {
|
||||||
|
return ((order->GetType() == OT_GOTO_STATION ||
|
||||||
|
order->GetType() == OT_GOTO_WAYPOINT) &&
|
||||||
|
(StationID)order->GetDestination() == station &&
|
||||||
|
(order->GetNonStopType() == ONSF_NO_STOP_AT_ANY_STATION ||
|
||||||
|
order->GetNonStopType() == ONSF_NO_STOP_AT_DESTINATION_STATION));
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsArrival(const Order *order, StationID station) {
|
||||||
|
return (order->GetType() == OT_GOTO_STATION &&
|
||||||
|
(StationID)order->GetDestination() == station &&
|
||||||
|
(order->GetUnloadType() != OUFB_NO_UNLOAD ||
|
||||||
|
_settings_client.gui.departure_show_all_stops) &&
|
||||||
|
order->GetWaitTime() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compute an up-to-date list of departures for a station.
|
||||||
|
* @param station the station to compute the departures of
|
||||||
|
* @param show_vehicle_types the types of vehicles to include in the departure list
|
||||||
|
* @param type the type of departures to get (departures or arrivals)
|
||||||
|
* @param show_vehicles_via whether to include vehicles that have this station in their orders but do not stop at it
|
||||||
|
* @return a list of departures, which is empty if an error occurred
|
||||||
|
*/
|
||||||
|
DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[5], DepartureType type, bool show_vehicles_via)
|
||||||
|
{
|
||||||
|
/* This function is the meat of the departure boards functionality. */
|
||||||
|
/* As an overview, it works by repeatedly considering the best possible next departure to show. */
|
||||||
|
/* By best possible we mean the one expected to arrive at the station first. */
|
||||||
|
/* However, we do not consider departures whose scheduled time is too far in the future, even if they are expected before some delayed ones. */
|
||||||
|
/* This code can probably be made more efficient. I haven't done so in order to keep both its (relative) simplicity and my (relative) sanity. */
|
||||||
|
/* Having written that, it's not exactly slow at the moment. */
|
||||||
|
|
||||||
|
/* The list of departures which will be returned as a result. */
|
||||||
|
SmallVector<Departure*, 32> *result = new SmallVector<Departure*, 32>();
|
||||||
|
|
||||||
|
/* A list of the next scheduled orders to be considered for inclusion in the departure list. */
|
||||||
|
SmallVector<OrderDate*, 32> next_orders;
|
||||||
|
|
||||||
|
/* The maximum possible date for departures to be scheduled to occur. */
|
||||||
|
DateTicks max_date = _settings_client.gui.max_departure_time * DAY_TICKS;
|
||||||
|
|
||||||
|
/* The scheduled order in next_orders with the earliest expected_date field. */
|
||||||
|
OrderDate *least_order = NULL;
|
||||||
|
|
||||||
|
/* Get all the vehicles stopping at this station. */
|
||||||
|
/* We do this to get the order which is the first time they will stop at this station. */
|
||||||
|
/* This order is stored along with some more information. */
|
||||||
|
/* We keep a pointer to the `least' order (the one with the soonest expected completion time). */
|
||||||
|
for (uint i = 0; i < 4; ++i) {
|
||||||
|
VehicleList vehicles;
|
||||||
|
|
||||||
|
if (!show_vehicle_types[i]) {
|
||||||
|
/* Don't show vehicles whose type we're not interested in. */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* MAX_COMPANIES is probably the wrong thing to put here, but it works. GenerateVehicleSortList doesn't check the company when the type of list is VL_STATION_LIST (r20801). */
|
||||||
|
if (!GenerateVehicleSortList(&vehicles, VehicleListIdentifier(VL_STATION_LIST, (VehicleType)(VEH_TRAIN + i), MAX_COMPANIES, station).Pack())) {
|
||||||
|
/* Something went wrong: panic! */
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the first order for each vehicle for the station we're interested in that doesn't have No Loading set. */
|
||||||
|
/* We find the least order while we're at it. */
|
||||||
|
for (const Vehicle **v = vehicles.Begin(); v != vehicles.End(); v++) {
|
||||||
|
if (_settings_client.gui.departure_only_passengers) {
|
||||||
|
bool carries_passengers = false;
|
||||||
|
|
||||||
|
const Vehicle *u = *v;
|
||||||
|
while (u != NULL) {
|
||||||
|
if (u->cargo_type == CT_PASSENGERS && u->cargo_cap > 0) {
|
||||||
|
carries_passengers = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
u = u->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (carries_passengers == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const Order *order = (*v)->GetOrder((*v)->cur_implicit_order_index % (*v)->GetNumOrders());
|
||||||
|
DateTicks start_date = (DateTicks)_date_fract - (*v)->current_order_time;
|
||||||
|
DepartureStatus status = D_TRAVELLING;
|
||||||
|
|
||||||
|
/* If the vehicle is stopped in a depot, ignore it. */
|
||||||
|
if ((*v)->IsStoppedInDepot()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the vehicle is heading for a depot to stop there, then its departures are cancelled. */
|
||||||
|
if ((*v)->current_order.IsType(OT_GOTO_DEPOT) && (*v)->current_order.GetDepotActionType() & ODATFB_HALT) {
|
||||||
|
status = D_CANCELLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((*v)->current_order.IsType(OT_LOADING)) {
|
||||||
|
/* Account for the vehicle having reached the current order and being in the loading phase. */
|
||||||
|
status = D_ARRIVED;
|
||||||
|
start_date -= order->GetTravelTime() + (((*v)->lateness_counter < 0) ? (*v)->lateness_counter : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Loop through the vehicle's orders until we've found a suitable order or we've determined that no such order exists. */
|
||||||
|
/* We only need to consider each order at most once. */
|
||||||
|
for (int i = (*v)->GetNumOrders(); i > 0; --i) {
|
||||||
|
start_date += order->GetTravelTime() + order->GetWaitTime();
|
||||||
|
|
||||||
|
/* If the scheduled departure date is too far in the future, stop. */
|
||||||
|
if (start_date - (*v)->lateness_counter > max_date) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the order is a conditional branch, handle it. */
|
||||||
|
if (order->IsType(OT_CONDITIONAL)) {
|
||||||
|
switch(_settings_client.gui.departure_conditionals) {
|
||||||
|
case 0: {
|
||||||
|
/* Give up */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
/* Take the branch */
|
||||||
|
if (status != D_CANCELLED) {
|
||||||
|
status = D_TRAVELLING;
|
||||||
|
}
|
||||||
|
order = (*v)->GetOrder(order->GetConditionSkipToOrder());
|
||||||
|
if (order == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
start_date -= order->GetTravelTime();
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
/* Do not take the branch */
|
||||||
|
if (status != D_CANCELLED) {
|
||||||
|
status = D_TRAVELLING;
|
||||||
|
}
|
||||||
|
order = (order->next == NULL) ? (*v)->GetFirstOrder() : order->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skip it if it's an automatic order. */
|
||||||
|
if (order->IsType(OT_IMPLICIT)) {
|
||||||
|
order = (order->next == NULL) ? (*v)->GetFirstOrder() : order->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If an order doesn't have a travel time set, then stop. */
|
||||||
|
if (order->GetTravelTime() == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the vehicle will be stopping at and loading from this station, and its wait time is not zero, then it is a departure. */
|
||||||
|
/* If the vehicle will be stopping at and unloading at this station, and its wait time is not zero, then it is an arrival. */
|
||||||
|
if ((type == D_DEPARTURE && IsDeparture(order, station)) ||
|
||||||
|
(type == D_DEPARTURE && show_vehicles_via && IsVia(order, station)) ||
|
||||||
|
(type == D_ARRIVAL && IsArrival(order, station))) {
|
||||||
|
/* If the departure was scheduled to have already begun and has been cancelled, do not show it. */
|
||||||
|
if (start_date < 0 && status == D_CANCELLED) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderDate *od = new OrderDate();
|
||||||
|
od->order = order;
|
||||||
|
od->v = *v;
|
||||||
|
/* We store the expected date for now, so that vehicles will be shown in order of expected time. */
|
||||||
|
od->expected_date = start_date;
|
||||||
|
od->lateness = (*v)->lateness_counter > 0 ? (*v)->lateness_counter : 0;
|
||||||
|
od->status = status;
|
||||||
|
|
||||||
|
/* If we are early, use the scheduled date as the expected date. We also take lateness to be zero. */
|
||||||
|
if ((*v)->lateness_counter < 0 && !(*v)->current_order.IsType(OT_LOADING)) {
|
||||||
|
od->expected_date -= (*v)->lateness_counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update least_order if this is the current least order. */
|
||||||
|
if (least_order == NULL) {
|
||||||
|
least_order = od;
|
||||||
|
} else if (least_order->expected_date - least_order->lateness - (type == D_ARRIVAL ? least_order->order->GetWaitTime() : 0) > od->expected_date - od->lateness - (type == D_ARRIVAL ? od->order->GetWaitTime() : 0)) {
|
||||||
|
least_order = od;
|
||||||
|
}
|
||||||
|
|
||||||
|
*(next_orders.Append(1)) = od;
|
||||||
|
|
||||||
|
/* We're done with this vehicle. */
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
/* Go to the next order in the list. */
|
||||||
|
if (status != D_CANCELLED) {
|
||||||
|
status = D_TRAVELLING;
|
||||||
|
}
|
||||||
|
order = (order->next == NULL) ? (*v)->GetFirstOrder() : order->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No suitable orders found? Then stop. */
|
||||||
|
if (next_orders.Length() == 0) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We now find as many departures as we can. It's a little involved so I'll try to explain each major step. */
|
||||||
|
/* The countdown from 10000 is a safeguard just in case something nasty happens. 10000 seemed large enough. */
|
||||||
|
for(int i = 10000; i > 0; --i) {
|
||||||
|
/* I should probably try to convince you that this loop always terminates regardless of the safeguard. */
|
||||||
|
/* 1. next_orders contains at least one element. */
|
||||||
|
/* 2. The loop terminates if result->Length() exceeds a fixed (for this loop) value, or if the least order's scheduled date is later than max_date. */
|
||||||
|
/* (We ignore the case that the least order's scheduled date has overflown, as it is a relative rather than absolute date.) */
|
||||||
|
/* 3. Every time we loop round, either result->Length() will have increased -OR- we will have increased the expected_date of one of the elements of next_orders. */
|
||||||
|
/* 4. Therefore the loop must eventually terminate. */
|
||||||
|
|
||||||
|
/* least_order is the best candidate for the next departure. */
|
||||||
|
|
||||||
|
/* First, we check if we can stop looking for departures yet. */
|
||||||
|
if (result->Length() >= _settings_client.gui.max_departures ||
|
||||||
|
least_order->expected_date - least_order->lateness > max_date) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We already know the least order and that it's a suitable departure, so make it into a departure. */
|
||||||
|
Departure *d = new Departure();
|
||||||
|
d->scheduled_date = (DateTicks)_date * DAY_TICKS + least_order->expected_date - least_order->lateness;
|
||||||
|
d->lateness = least_order->lateness;
|
||||||
|
d->status = least_order->status;
|
||||||
|
d->vehicle = least_order->v;
|
||||||
|
d->type = type;
|
||||||
|
d->order = least_order->order;
|
||||||
|
|
||||||
|
/* We'll be going through the order list later, so we need a separate variable for it. */
|
||||||
|
const Order *order = least_order->order;
|
||||||
|
|
||||||
|
if (type == D_DEPARTURE) {
|
||||||
|
/* Computing departures: */
|
||||||
|
/* We want to find out where it will terminate, making a list of the stations it calls at along the way. */
|
||||||
|
/* We only count stations where unloading happens as being called at - i.e. pickup-only stations are ignored. */
|
||||||
|
/* Where the vehicle terminates is defined as the last unique station called at by the vehicle from the current order. */
|
||||||
|
|
||||||
|
/* If the vehicle loops round to the current order without a terminus being found, then it terminates upon reaching its current order again. */
|
||||||
|
|
||||||
|
/* We also determine which station this departure is going via, if any. */
|
||||||
|
/* A departure goes via a station if it is the first station for which the vehicle has an order to go via or non-stop via. */
|
||||||
|
/* Multiple departures on the same journey may go via different stations. That a departure can go via at most one station is intentional. */
|
||||||
|
|
||||||
|
/* We keep track of potential via stations along the way. If we call at a station immediately after going via it, then it is the via station. */
|
||||||
|
StationID candidate_via = INVALID_STATION;
|
||||||
|
|
||||||
|
/* Go through the order list, looping if necessary, to find a terminus. */
|
||||||
|
/* Get the next order, which may be the vehicle's first order. */
|
||||||
|
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||||
|
/* We only need to consider each order at most once. */
|
||||||
|
bool found_terminus = false;
|
||||||
|
CallAt c = CallAt((StationID)order->GetDestination(), d->scheduled_date);
|
||||||
|
for (int i = least_order->v->GetNumOrders(); i > 0; --i) {
|
||||||
|
/* If we reach the order at which the departure occurs again, then use the departure station as the terminus. */
|
||||||
|
if (order == least_order->order) {
|
||||||
|
/* If we're not calling anywhere, then skip this departure. */
|
||||||
|
found_terminus = (d->calling_at.Length() > 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the order is a conditional branch, handle it. */
|
||||||
|
if (order->IsType(OT_CONDITIONAL)) {
|
||||||
|
switch(_settings_client.gui.departure_conditionals) {
|
||||||
|
case 0: {
|
||||||
|
/* Give up */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
/* Take the branch */
|
||||||
|
order = least_order->v->GetOrder(order->GetConditionSkipToOrder());
|
||||||
|
if (order == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
/* Do not take the branch */
|
||||||
|
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we reach the original station again, then use it as the terminus. */
|
||||||
|
if (order->GetType() == OT_GOTO_STATION &&
|
||||||
|
(StationID)order->GetDestination() == station &&
|
||||||
|
(order->GetUnloadType() != OUFB_NO_UNLOAD ||
|
||||||
|
_settings_client.gui.departure_show_all_stops) &&
|
||||||
|
order->GetNonStopType() != ONSF_NO_STOP_AT_ANY_STATION &&
|
||||||
|
order->GetNonStopType() != ONSF_NO_STOP_AT_DESTINATION_STATION) {
|
||||||
|
/* If we're not calling anywhere, then skip this departure. */
|
||||||
|
found_terminus = (d->calling_at.Length() > 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if we're going via this station. */
|
||||||
|
if ((order->GetNonStopType() == ONSF_NO_STOP_AT_ANY_STATION ||
|
||||||
|
order->GetNonStopType() == ONSF_NO_STOP_AT_DESTINATION_STATION) &&
|
||||||
|
order->GetType() == OT_GOTO_STATION &&
|
||||||
|
d->via == INVALID_STATION) {
|
||||||
|
candidate_via = (StationID)order->GetDestination();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c.scheduled_date != 0 && order->GetTravelTime() != 0) {
|
||||||
|
c.scheduled_date += order->GetTravelTime();
|
||||||
|
} else {
|
||||||
|
c.scheduled_date = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
c.station = (StationID)order->GetDestination();
|
||||||
|
|
||||||
|
/* We're not interested in this order any further if we're not calling at it. */
|
||||||
|
if ((order->GetUnloadType() == OUFB_NO_UNLOAD &&
|
||||||
|
!_settings_client.gui.departure_show_all_stops) ||
|
||||||
|
(order->GetType() != OT_GOTO_STATION &&
|
||||||
|
order->GetType() != OT_IMPLICIT) ||
|
||||||
|
order->GetNonStopType() == ONSF_NO_STOP_AT_ANY_STATION ||
|
||||||
|
order->GetNonStopType() == ONSF_NO_STOP_AT_DESTINATION_STATION) {
|
||||||
|
c.scheduled_date += order->GetWaitTime();
|
||||||
|
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If this order's station is already in the calling, then the previous called at station is the terminus. */
|
||||||
|
if (d->calling_at.Contains(c)) {
|
||||||
|
found_terminus = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If appropriate, add the station to the calling at list and make it the candidate terminus. */
|
||||||
|
if ((order->GetType() == OT_GOTO_STATION ||
|
||||||
|
order->GetType() == OT_IMPLICIT) &&
|
||||||
|
order->GetNonStopType() != ONSF_NO_STOP_AT_ANY_STATION &&
|
||||||
|
order->GetNonStopType() != ONSF_NO_STOP_AT_DESTINATION_STATION) {
|
||||||
|
if (d->via == INVALID_STATION && candidate_via == (StationID)order->GetDestination()) {
|
||||||
|
d->via = (StationID)order->GetDestination();
|
||||||
|
}
|
||||||
|
d->terminus = c;
|
||||||
|
*(d->calling_at.Append(1)) = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we unload all at this station, then it is the terminus. */
|
||||||
|
if (order->GetType() == OT_GOTO_STATION &&
|
||||||
|
order->GetUnloadType() == OUFB_UNLOAD) {
|
||||||
|
if (d->calling_at.Length() > 0) {
|
||||||
|
found_terminus = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
c.scheduled_date += order->GetWaitTime();
|
||||||
|
|
||||||
|
/* Get the next order, which may be the vehicle's first order. */
|
||||||
|
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found_terminus) {
|
||||||
|
/* Add the departure to the result list. */
|
||||||
|
bool duplicate = false;
|
||||||
|
|
||||||
|
if (_settings_client.gui.departure_merge_identical) {
|
||||||
|
for (uint i = 0; i < result->Length(); ++i) {
|
||||||
|
if (*d == **(result->Get(i))) {
|
||||||
|
duplicate = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!duplicate) {
|
||||||
|
*(result->Append(1)) = d;
|
||||||
|
|
||||||
|
if (_settings_client.gui.departure_smart_terminus && type == D_DEPARTURE) {
|
||||||
|
for (uint i = 0; i < result->Length()-1; ++i) {
|
||||||
|
Departure *d_first = *(result->Get(i));
|
||||||
|
uint k = d_first->calling_at.Length()-2;
|
||||||
|
for (uint j = d->calling_at.Length(); j > 0; --j) {
|
||||||
|
CallAt c = CallAt(*(d->calling_at.Get(j-1)));
|
||||||
|
|
||||||
|
if (d_first->terminus >= c && d_first->calling_at.Length() >= 2) {
|
||||||
|
d_first->terminus = CallAt(*(d_first->calling_at.Get(k)));
|
||||||
|
|
||||||
|
if (k == 0) break;
|
||||||
|
|
||||||
|
k--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the vehicle is expected to be late, we want to know what time it will arrive rather than depart. */
|
||||||
|
/* This is done because it looked silly to me to have a vehicle not be expected for another few days, yet it be at the same time pulling into the station. */
|
||||||
|
if (d->status != D_ARRIVED &&
|
||||||
|
d->lateness > 0) {
|
||||||
|
d->lateness -= least_order->order->GetWaitTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Computing arrivals: */
|
||||||
|
/* First we need to find the origin of the order. This is somewhat like finding a terminus, but a little more involved since order lists are singly linked. */
|
||||||
|
/* The next stage is simpler. We just need to add all the stations called at on the way to the current station. */
|
||||||
|
/* Again, we define a station as being called at if the vehicle loads from it. */
|
||||||
|
|
||||||
|
/* However, the very first thing we do is use the arrival time as the scheduled time instead of the departure time. */
|
||||||
|
d->scheduled_date -= order->GetWaitTime();
|
||||||
|
|
||||||
|
const Order *candidate_origin = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||||
|
bool found_origin = false;
|
||||||
|
|
||||||
|
while (candidate_origin != least_order->order) {
|
||||||
|
if ((candidate_origin->GetLoadType() != OLFB_NO_LOAD ||
|
||||||
|
_settings_client.gui.departure_show_all_stops) &&
|
||||||
|
(candidate_origin->GetType() == OT_GOTO_STATION ||
|
||||||
|
candidate_origin->GetType() == OT_IMPLICIT) &&
|
||||||
|
candidate_origin->GetDestination() != station) {
|
||||||
|
const Order *o = (candidate_origin->next == NULL) ? least_order->v->GetFirstOrder() : candidate_origin->next;
|
||||||
|
bool found_collision = false;
|
||||||
|
|
||||||
|
/* Check if the candidate origin's destination appears again before the original order or the station does. */
|
||||||
|
while (o != least_order->order) {
|
||||||
|
if (o->GetUnloadType() == OUFB_UNLOAD) {
|
||||||
|
found_collision = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((o->GetType() == OT_GOTO_STATION ||
|
||||||
|
o->GetType() == OT_IMPLICIT) &&
|
||||||
|
(o->GetDestination() == candidate_origin->GetDestination() ||
|
||||||
|
o->GetDestination() == station)) {
|
||||||
|
found_collision = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
o = (o->next == NULL) ? least_order->v->GetFirstOrder() : o->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If it doesn't, then we have found the origin. */
|
||||||
|
if (!found_collision) {
|
||||||
|
found_origin = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
candidate_origin = (candidate_origin->next == NULL) ? least_order->v->GetFirstOrder() : candidate_origin->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
order = (candidate_origin->next == NULL) ? least_order->v->GetFirstOrder() : candidate_origin->next;
|
||||||
|
|
||||||
|
while (order != least_order->order) {
|
||||||
|
if (order->GetType() == OT_GOTO_STATION &&
|
||||||
|
(order->GetLoadType() != OLFB_NO_LOAD ||
|
||||||
|
_settings_client.gui.departure_show_all_stops)) {
|
||||||
|
*(d->calling_at.Append(1)) = CallAt((StationID)order->GetDestination());
|
||||||
|
}
|
||||||
|
|
||||||
|
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->terminus = CallAt((StationID)candidate_origin->GetDestination());
|
||||||
|
|
||||||
|
if (found_origin) {
|
||||||
|
bool duplicate = false;
|
||||||
|
|
||||||
|
if (_settings_client.gui.departure_merge_identical) {
|
||||||
|
for (uint i = 0; i < result->Length(); ++i) {
|
||||||
|
if (*d == **(result->Get(i))) {
|
||||||
|
duplicate = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!duplicate) {
|
||||||
|
*(result->Append(1)) = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Save on pointer dereferences in the coming loop. */
|
||||||
|
order = least_order->order;
|
||||||
|
|
||||||
|
/* Now we find the next suitable order for being a departure for this vehicle. */
|
||||||
|
/* We do this in a similar way to finding the first suitable order for the vehicle. */
|
||||||
|
|
||||||
|
/* Go to the next order so we don't add the current order again. */
|
||||||
|
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||||
|
least_order->expected_date += order->GetTravelTime() + order->GetWaitTime();
|
||||||
|
|
||||||
|
/* Go through the order list to find the next candidate departure. */
|
||||||
|
/* We only need to consider each order at most once. */
|
||||||
|
bool found_next_order = false;
|
||||||
|
for (int i = least_order->v->GetNumOrders(); i > 0; --i) {
|
||||||
|
/* If the order is a conditional branch, handle it. */
|
||||||
|
if (order->IsType(OT_CONDITIONAL)) {
|
||||||
|
switch(_settings_client.gui.departure_conditionals) {
|
||||||
|
case 0: {
|
||||||
|
/* Give up */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
/* Take the branch */
|
||||||
|
order = least_order->v->GetOrder(order->GetConditionSkipToOrder());
|
||||||
|
if (order == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
least_order->expected_date += order->GetWaitTime();
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
/* Do not take the branch */
|
||||||
|
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||||
|
least_order->expected_date += order->GetTravelTime() + order->GetWaitTime();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skip it if it's an automatic order. */
|
||||||
|
if (order->IsType(OT_IMPLICIT)) {
|
||||||
|
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If an order doesn't have a travel time set, then stop. */
|
||||||
|
if (order->GetTravelTime() == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the departure is scheduled to be too late, then stop. */
|
||||||
|
if (least_order->expected_date - least_order->lateness > max_date) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the order loads from this station (or unloads if we're computing arrivals) and has a wait time set, then it is suitable for being a departure. */
|
||||||
|
if ((type == D_DEPARTURE && IsDeparture(order, station)) ||
|
||||||
|
(type == D_DEPARTURE && show_vehicles_via && IsVia(order, station)) ||
|
||||||
|
(type == D_ARRIVAL && IsArrival(order, station))) {
|
||||||
|
least_order->order = order;
|
||||||
|
found_next_order = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
order = (order->next == NULL) ? least_order->v->GetFirstOrder() : order->next;
|
||||||
|
least_order->expected_date += order->GetTravelTime() + order->GetWaitTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If we didn't find a suitable order for being a departure, then we can ignore this vehicle from now on. */
|
||||||
|
if (!found_next_order) {
|
||||||
|
/* Make sure we don't try to get departures out of this order. */
|
||||||
|
/* This is cheaper than deleting it from next_orders. */
|
||||||
|
/* If we ever get to a state where _date * DAY_TICKS is close to INT_MAX, then we'll have other problems anyway as departures' scheduled dates will wrap around. */
|
||||||
|
least_order->expected_date = INT32_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The vehicle can't possibly have arrived at its next candidate departure yet. */
|
||||||
|
if (least_order->status == D_ARRIVED) {
|
||||||
|
least_order->status = D_TRAVELLING;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the new least order. */
|
||||||
|
for (uint i = 0; i < next_orders.Length(); ++i) {
|
||||||
|
OrderDate *od = *(next_orders.Get(i));
|
||||||
|
|
||||||
|
DateTicks lod = least_order->expected_date - least_order->lateness;
|
||||||
|
DateTicks odd = od->expected_date - od->lateness;
|
||||||
|
|
||||||
|
if (type == D_ARRIVAL) {
|
||||||
|
lod -= least_order->order->GetWaitTime();
|
||||||
|
odd -= od->order->GetWaitTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lod > odd && od->expected_date - od->lateness < max_date) {
|
||||||
|
least_order = od;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Done. Phew! */
|
||||||
|
return result;
|
||||||
|
}
|
21
src/departures_func.h
Normal file
21
src/departures_func.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/* $Id: departures_func.h $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of OpenTTD.
|
||||||
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||||
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file departures_func.h Functions related to departures. */
|
||||||
|
|
||||||
|
#ifndef DEPARTURES_FUNC_H
|
||||||
|
#define DEPARTURES_FUNC_H
|
||||||
|
|
||||||
|
#include "station_base.h"
|
||||||
|
#include "core/smallvec_type.hpp"
|
||||||
|
#include "departures_type.h"
|
||||||
|
|
||||||
|
DepartureList* MakeDepartureList(StationID station, bool show_vehicle_types[4], DepartureType type = D_DEPARTURE, bool show_vehicles_via = false);
|
||||||
|
|
||||||
|
#endif /* DEPARTURES_FUNC_H */
|
856
src/departures_gui.cpp
Normal file
856
src/departures_gui.cpp
Normal file
@@ -0,0 +1,856 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of OpenTTD.
|
||||||
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||||
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file departures_gui.cpp Scheduled departures from a station. */
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "gui.h"
|
||||||
|
#include "textbuf_gui.h"
|
||||||
|
#include "strings_func.h"
|
||||||
|
#include "window_func.h"
|
||||||
|
#include "vehicle_func.h"
|
||||||
|
#include "string_func.h"
|
||||||
|
#include "window_gui.h"
|
||||||
|
#include "timetable.h"
|
||||||
|
#include "vehiclelist.h"
|
||||||
|
#include "company_base.h"
|
||||||
|
#include "date_func.h"
|
||||||
|
#include "departures_gui.h"
|
||||||
|
#include "station_base.h"
|
||||||
|
#include "vehicle_gui_base.h"
|
||||||
|
#include "vehicle_base.h"
|
||||||
|
#include "vehicle_gui.h"
|
||||||
|
#include "order_base.h"
|
||||||
|
#include "settings_type.h"
|
||||||
|
#include "core/smallvec_type.hpp"
|
||||||
|
#include "date_type.h"
|
||||||
|
#include "company_type.h"
|
||||||
|
#include "departures_func.h"
|
||||||
|
#include "cargotype.h"
|
||||||
|
|
||||||
|
#include "table/sprites.h"
|
||||||
|
#include "table/strings.h"
|
||||||
|
|
||||||
|
static const NWidgetPart _nested_departures_list[] = {
|
||||||
|
NWidget(NWID_HORIZONTAL),
|
||||||
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||||
|
NWidget(WWT_CAPTION, COLOUR_GREY, WID_DB_CAPTION), SetDataTip(STR_DEPARTURES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||||
|
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
||||||
|
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
||||||
|
EndContainer(),
|
||||||
|
|
||||||
|
NWidget(NWID_HORIZONTAL),
|
||||||
|
NWidget(WWT_MATRIX, COLOUR_GREY, WID_DB_LIST), SetMinimalSize(0, 0), SetFill(1, 0), SetResize(1, 1),
|
||||||
|
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_DB_SCROLLBAR),
|
||||||
|
EndContainer(),
|
||||||
|
|
||||||
|
NWidget(NWID_HORIZONTAL),
|
||||||
|
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetResize(1, 0), SetFill(1, 1), EndContainer(),
|
||||||
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_DB_SHOW_ARRS), SetMinimalSize(6, 12), SetFill(0, 1), SetDataTip(STR_DEPARTURES_ARRIVALS, STR_DEPARTURES_ARRIVALS_TOOLTIP),
|
||||||
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_DB_SHOW_DEPS), SetMinimalSize(6, 12), SetFill(0, 1), SetDataTip(STR_DEPARTURES_DEPARTURES, STR_DEPARTURES_DEPARTURES_TOOLTIP),
|
||||||
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_DB_SHOW_VIA), SetMinimalSize(11, 12), SetFill(0, 1), SetDataTip(STR_DEPARTURES_VIA_BUTTON, STR_DEPARTURES_VIA_TOOLTIP),
|
||||||
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_DB_SHOW_TRAINS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_TRAIN, STR_STATION_VIEW_SCHEDULED_TRAINS_TOOLTIP),
|
||||||
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_DB_SHOW_ROADVEHS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_LORRY, STR_STATION_VIEW_SCHEDULED_ROAD_VEHICLES_TOOLTIP),
|
||||||
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_DB_SHOW_SHIPS), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_SHIP, STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP),
|
||||||
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_DB_SHOW_PLANES), SetMinimalSize(14, 12), SetFill(0, 1), SetDataTip(STR_PLANE, STR_STATION_VIEW_SCHEDULED_AIRCRAFT_TOOLTIP),
|
||||||
|
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||||
|
EndContainer(),
|
||||||
|
};
|
||||||
|
|
||||||
|
static WindowDesc _departures_desc(
|
||||||
|
WDP_AUTO, NULL, 260, 246,
|
||||||
|
WC_DEPARTURES_BOARD, WC_NONE,
|
||||||
|
0,
|
||||||
|
_nested_departures_list, lengthof(_nested_departures_list)
|
||||||
|
);
|
||||||
|
|
||||||
|
static uint cached_date_width = 0; ///< The cached maximum width required to display a date.
|
||||||
|
static uint cached_status_width = 0; ///< The cached maximum width required to show the status field.
|
||||||
|
static uint cached_date_arrow_width = 0; ///< The cached width of the red/green arrows that may be displayed alongside times.
|
||||||
|
static bool cached_date_display_method; ///< Whether the above cached values refers to original (d,m,y) dates or the 24h clock.
|
||||||
|
static bool cached_arr_dep_display_method; ///< Whether to show departures and arrivals on a single line.
|
||||||
|
|
||||||
|
template<bool Twaypoint = false>
|
||||||
|
struct DeparturesWindow : public Window {
|
||||||
|
protected:
|
||||||
|
StationID station; ///< The station whose departures we're showing.
|
||||||
|
DepartureList *departures; ///< The current list of departures from this station.
|
||||||
|
DepartureList *arrivals; ///< The current list of arrivals from this station.
|
||||||
|
uint entry_height; ///< The height of an entry in the departures list.
|
||||||
|
uint tick_count; ///< The number of ticks that have elapsed since the window was created. Used for scrolling text.
|
||||||
|
int calc_tick_countdown; ///< The number of ticks to wait until recomputing the departure list. Signed in case it goes below zero.
|
||||||
|
bool show_types[4]; ///< The vehicle types to show in the departure list.
|
||||||
|
bool departure_types[3]; ///< The types of departure to show in the departure list.
|
||||||
|
uint min_width; ///< The minimum width of this window.
|
||||||
|
Scrollbar *vscroll;
|
||||||
|
|
||||||
|
virtual uint GetMinWidth() const;
|
||||||
|
static void RecomputeDateWidth();
|
||||||
|
virtual void DrawDeparturesListItems(const Rect &r) const;
|
||||||
|
void DeleteDeparturesList(DepartureList* list);
|
||||||
|
public:
|
||||||
|
|
||||||
|
DeparturesWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc),
|
||||||
|
station(window_number),
|
||||||
|
departures(new DepartureList()),
|
||||||
|
arrivals(new DepartureList()),
|
||||||
|
entry_height(1 + FONT_HEIGHT_NORMAL + 1 + (_settings_client.gui.departure_larger_font ? FONT_HEIGHT_NORMAL : FONT_HEIGHT_SMALL) + 1 + 1),
|
||||||
|
tick_count(0),
|
||||||
|
calc_tick_countdown(0),
|
||||||
|
min_width(400)
|
||||||
|
{
|
||||||
|
this->CreateNestedTree();
|
||||||
|
this->vscroll = this->GetScrollbar(WID_DB_SCROLLBAR);
|
||||||
|
this->FinishInitNested(window_number);
|
||||||
|
|
||||||
|
/* By default, only show departures. */
|
||||||
|
departure_types[0] = true;
|
||||||
|
departure_types[1] = false;
|
||||||
|
departure_types[2] = false;
|
||||||
|
this->LowerWidget(WID_DB_SHOW_DEPS);
|
||||||
|
this->RaiseWidget(WID_DB_SHOW_ARRS);
|
||||||
|
this->RaiseWidget(WID_DB_SHOW_VIA);
|
||||||
|
|
||||||
|
for (uint i = 0; i < 4; ++i) {
|
||||||
|
show_types[i] = true;
|
||||||
|
this->LowerWidget(WID_DB_SHOW_TRAINS + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Twaypoint) {
|
||||||
|
this->GetWidget<NWidgetCore>(WID_DB_CAPTION)->SetDataTip(STR_DEPARTURES_CAPTION_WAYPOINT, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
|
||||||
|
|
||||||
|
for (uint i = 0; i < 4; ++i) {
|
||||||
|
this->DisableWidget(WID_DB_SHOW_TRAINS + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->DisableWidget(WID_DB_SHOW_ARRS);
|
||||||
|
this->DisableWidget(WID_DB_SHOW_DEPS);
|
||||||
|
this->DisableWidget(WID_DB_SHOW_VIA);
|
||||||
|
|
||||||
|
departure_types[2] = true;
|
||||||
|
|
||||||
|
this->LowerWidget(WID_DB_SHOW_VIA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~DeparturesWindow()
|
||||||
|
{
|
||||||
|
this->DeleteDeparturesList(departures);
|
||||||
|
this->DeleteDeparturesList(this->arrivals);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||||
|
{
|
||||||
|
switch (widget) {
|
||||||
|
case WID_DB_LIST:
|
||||||
|
resize->height = DeparturesWindow::entry_height;
|
||||||
|
size->height = 2 * resize->height;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void SetStringParameters(int widget) const
|
||||||
|
{
|
||||||
|
if (widget == WID_DB_CAPTION) {
|
||||||
|
const Station *st = Station::Get(this->station);
|
||||||
|
SetDParam(0, st->index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnClick(Point pt, int widget, int click_count)
|
||||||
|
{
|
||||||
|
switch (widget) {
|
||||||
|
case WID_DB_SHOW_TRAINS: // Show trains to this station
|
||||||
|
case WID_DB_SHOW_ROADVEHS: // Show road vehicles to this station
|
||||||
|
case WID_DB_SHOW_SHIPS: // Show ships to this station
|
||||||
|
case WID_DB_SHOW_PLANES: // Show aircraft to this station
|
||||||
|
this->show_types[widget - WID_DB_SHOW_TRAINS] = !this->show_types[widget - WID_DB_SHOW_TRAINS];
|
||||||
|
if (this->show_types[widget - WID_DB_SHOW_TRAINS]) {
|
||||||
|
this->LowerWidget(widget);
|
||||||
|
} else {
|
||||||
|
this->RaiseWidget(widget);
|
||||||
|
}
|
||||||
|
/* We need to recompute the departures list. */
|
||||||
|
this->calc_tick_countdown = 0;
|
||||||
|
/* We need to redraw the button that was pressed. */
|
||||||
|
this->SetWidgetDirty(widget);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WID_DB_SHOW_DEPS:
|
||||||
|
case WID_DB_SHOW_ARRS:
|
||||||
|
if (_settings_client.gui.departure_show_both) break;
|
||||||
|
/* FALL THROUGH */
|
||||||
|
|
||||||
|
case WID_DB_SHOW_VIA:
|
||||||
|
|
||||||
|
this->departure_types[widget - WID_DB_SHOW_DEPS] = !this->departure_types[widget - WID_DB_SHOW_DEPS];
|
||||||
|
if (this->departure_types[widget - WID_DB_SHOW_DEPS]) {
|
||||||
|
this->LowerWidget(widget);
|
||||||
|
} else {
|
||||||
|
this->RaiseWidget(widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this->departure_types[0]) {
|
||||||
|
this->RaiseWidget(WID_DB_SHOW_VIA);
|
||||||
|
this->DisableWidget(WID_DB_SHOW_VIA);
|
||||||
|
} else {
|
||||||
|
this->EnableWidget(WID_DB_SHOW_VIA);
|
||||||
|
|
||||||
|
if (this->departure_types[2]) {
|
||||||
|
this->LowerWidget(WID_DB_SHOW_VIA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* We need to recompute the departures list. */
|
||||||
|
this->calc_tick_countdown = 0;
|
||||||
|
/* We need to redraw the button that was pressed. */
|
||||||
|
this->SetWidgetDirty(widget);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WID_DB_LIST: // Matrix to show departures
|
||||||
|
/* We need to find the departure corresponding to where the user clicked. */
|
||||||
|
uint32 id_v = (pt.y - this->GetWidget<NWidgetBase>(WID_DB_LIST)->pos_y) / this->entry_height;
|
||||||
|
|
||||||
|
if (id_v >= this->vscroll->GetCapacity()) return; // click out of bounds
|
||||||
|
|
||||||
|
id_v += this->vscroll->GetPosition();
|
||||||
|
|
||||||
|
if (id_v >= (this->departures->Length() + this->arrivals->Length())) return; // click out of list bound
|
||||||
|
|
||||||
|
uint departure = 0;
|
||||||
|
uint arrival = 0;
|
||||||
|
|
||||||
|
/* Draw each departure. */
|
||||||
|
for (uint i = 0; i <= id_v; ++i) {
|
||||||
|
const Departure *d;
|
||||||
|
|
||||||
|
if (arrival == this->arrivals->Length()) {
|
||||||
|
d = (*(this->departures))[departure++];
|
||||||
|
} else if (departure == this->departures->Length()) {
|
||||||
|
d = (*(this->arrivals))[arrival++];
|
||||||
|
} else {
|
||||||
|
d = (*(this->departures))[departure];
|
||||||
|
const Departure *a = (*(this->arrivals))[arrival];
|
||||||
|
|
||||||
|
if (a->scheduled_date < d->scheduled_date) {
|
||||||
|
d = a;
|
||||||
|
arrival++;
|
||||||
|
} else {
|
||||||
|
departure++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == id_v) {
|
||||||
|
ShowVehicleViewWindow(d->vehicle);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnTick()
|
||||||
|
{
|
||||||
|
if (_pause_mode == PM_UNPAUSED) {
|
||||||
|
this->tick_count += 1;
|
||||||
|
this->calc_tick_countdown -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Recompute the minimum date display width if the cached one is no longer valid. */
|
||||||
|
if (cached_date_width == 0 ||
|
||||||
|
_settings_client.gui.time_in_minutes != cached_date_display_method ||
|
||||||
|
_settings_client.gui.departure_show_both != cached_arr_dep_display_method) {
|
||||||
|
this->RecomputeDateWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We need to redraw the scrolling text in its new position. */
|
||||||
|
this->SetWidgetDirty(WID_DB_LIST);
|
||||||
|
|
||||||
|
/* Recompute the list of departures if we're due to. */
|
||||||
|
if (this->calc_tick_countdown <= 0) {
|
||||||
|
this->calc_tick_countdown = _settings_client.gui.departure_calc_frequency;
|
||||||
|
this->DeleteDeparturesList(this->departures);
|
||||||
|
this->DeleteDeparturesList(this->arrivals);
|
||||||
|
this->departures = (this->departure_types[0] ? MakeDepartureList(this->station, this->show_types, D_DEPARTURE, Twaypoint || this->departure_types[2]) : new DepartureList());
|
||||||
|
this->arrivals = (this->departure_types[1] && !_settings_client.gui.departure_show_both ? MakeDepartureList(this->station, this->show_types, D_ARRIVAL ) : new DepartureList());
|
||||||
|
this->SetWidgetDirty(WID_DB_LIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint new_width = this->GetMinWidth();
|
||||||
|
|
||||||
|
if (new_width != this->min_width) {
|
||||||
|
NWidgetCore *n = this->GetWidget<NWidgetCore>(WID_DB_LIST);
|
||||||
|
n->SetMinimalSize(new_width, 0);
|
||||||
|
this->ReInit();
|
||||||
|
this->min_width = new_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint new_height = 1 + FONT_HEIGHT_NORMAL + 1 + (_settings_client.gui.departure_larger_font ? FONT_HEIGHT_NORMAL : FONT_HEIGHT_SMALL) + 1 + 1;
|
||||||
|
|
||||||
|
if (new_height != this->entry_height) {
|
||||||
|
this->entry_height = new_height;
|
||||||
|
this->SetWidgetDirty(WID_DB_LIST);
|
||||||
|
this->ReInit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnPaint()
|
||||||
|
{
|
||||||
|
if (Twaypoint || _settings_client.gui.departure_show_both) {
|
||||||
|
this->DisableWidget(WID_DB_SHOW_ARRS);
|
||||||
|
this->DisableWidget(WID_DB_SHOW_DEPS);
|
||||||
|
} else {
|
||||||
|
this->EnableWidget(WID_DB_SHOW_ARRS);
|
||||||
|
this->EnableWidget(WID_DB_SHOW_DEPS);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->vscroll->SetCount(min(_settings_client.gui.max_departures, this->departures->Length() + this->arrivals->Length()));
|
||||||
|
this->DrawWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void DrawWidget(const Rect &r, int widget) const
|
||||||
|
{
|
||||||
|
switch (widget) {
|
||||||
|
case WID_DB_LIST:
|
||||||
|
this->DrawDeparturesListItems(r);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void OnResize()
|
||||||
|
{
|
||||||
|
this->vscroll->SetCapacityFromWidget(this, WID_DB_LIST);
|
||||||
|
this->GetWidget<NWidgetCore>(WID_DB_LIST)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows a window of scheduled departures for a station.
|
||||||
|
* @param station the station to show a departures window for
|
||||||
|
*/
|
||||||
|
void ShowStationDepartures(StationID station)
|
||||||
|
{
|
||||||
|
AllocateWindowDescFront<DeparturesWindow<> >(&_departures_desc, station);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows a window of scheduled departures for a station.
|
||||||
|
* @param station the station to show a departures window for
|
||||||
|
*/
|
||||||
|
void ShowWaypointDepartures(StationID waypoint)
|
||||||
|
{
|
||||||
|
AllocateWindowDescFront<DeparturesWindow<true> >(&_departures_desc, waypoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool Twaypoint>
|
||||||
|
void DeparturesWindow<Twaypoint>::RecomputeDateWidth()
|
||||||
|
{
|
||||||
|
cached_date_width = 0;
|
||||||
|
cached_status_width = 0;
|
||||||
|
cached_date_display_method = _settings_client.gui.time_in_minutes;
|
||||||
|
cached_arr_dep_display_method = _settings_client.gui.departure_show_both;
|
||||||
|
|
||||||
|
cached_status_width = max((GetStringBoundingBox(STR_DEPARTURES_ON_TIME)).width, cached_status_width);
|
||||||
|
cached_status_width = max((GetStringBoundingBox(STR_DEPARTURES_DELAYED)).width, cached_status_width);
|
||||||
|
cached_status_width = max((GetStringBoundingBox(STR_DEPARTURES_CANCELLED)).width, cached_status_width);
|
||||||
|
|
||||||
|
uint interval = cached_date_display_method ? _settings_client.gui.ticks_per_minute : DAY_TICKS;
|
||||||
|
uint count = cached_date_display_method ? 24*60 : 365;
|
||||||
|
|
||||||
|
for (uint i = 0; i < count; ++i) {
|
||||||
|
SetDParam(0, INT_MAX - (i*interval));
|
||||||
|
SetDParam(1, INT_MAX - (i*interval));
|
||||||
|
cached_date_width = max(GetStringBoundingBox(cached_arr_dep_display_method ? STR_DEPARTURES_TIME_BOTH : STR_DEPARTURES_TIME_DEP).width, cached_date_width);
|
||||||
|
cached_status_width = max((GetStringBoundingBox(STR_DEPARTURES_EXPECTED)).width, cached_status_width);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDParam(0, 0);
|
||||||
|
cached_date_arrow_width = GetStringBoundingBox(STR_DEPARTURES_TIME_DEP).width - GetStringBoundingBox(STR_DEPARTURES_TIME).width;
|
||||||
|
|
||||||
|
if (!_settings_client.gui.departure_show_both) {
|
||||||
|
cached_date_width -= cached_date_arrow_width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<bool Twaypoint>
|
||||||
|
uint DeparturesWindow<Twaypoint>::GetMinWidth() const
|
||||||
|
{
|
||||||
|
uint result = 0;
|
||||||
|
|
||||||
|
/* Time */
|
||||||
|
result = cached_date_width;
|
||||||
|
|
||||||
|
/* Vehicle type icon */
|
||||||
|
result += _settings_client.gui.departure_show_vehicle_type ? (GetStringBoundingBox(STR_DEPARTURES_TYPE_PLANE)).width : 0;
|
||||||
|
|
||||||
|
/* Status */
|
||||||
|
result += cached_status_width;
|
||||||
|
|
||||||
|
/* Find the maximum company name width. */
|
||||||
|
int toc_width = 0;
|
||||||
|
|
||||||
|
/* Find the maximum company name width. */
|
||||||
|
int group_width = 0;
|
||||||
|
|
||||||
|
/* Find the maximum vehicle name width. */
|
||||||
|
int veh_width = 0;
|
||||||
|
|
||||||
|
if (_settings_client.gui.departure_show_vehicle || _settings_client.gui.departure_show_company || _settings_client.gui.departure_show_group) {
|
||||||
|
for (uint i = 0; i < 4; ++i) {
|
||||||
|
VehicleList vehicles;
|
||||||
|
|
||||||
|
/* MAX_COMPANIES is probably the wrong thing to put here, but it works. GenerateVehicleSortList doesn't check the company when the type of list is VL_STATION_LIST (r20801). */
|
||||||
|
if (!GenerateVehicleSortList(&vehicles, VehicleListIdentifier(VL_STATION_LIST, (VehicleType)(VEH_TRAIN + i), MAX_COMPANIES, station).Pack())) {
|
||||||
|
/* Something went wrong: panic! */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const Vehicle **v = vehicles.Begin(); v != vehicles.End(); v++) {
|
||||||
|
SetDParam(0, (uint64)((*v)->index));
|
||||||
|
int width = (GetStringBoundingBox(STR_DEPARTURES_VEH)).width;
|
||||||
|
if (_settings_client.gui.departure_show_vehicle && width > veh_width) veh_width = width;
|
||||||
|
|
||||||
|
if ((*v)->group_id != INVALID_GROUP && (*v)->group_id != DEFAULT_GROUP) {
|
||||||
|
SetDParam(0, (uint64)((*v)->group_id));
|
||||||
|
width = (GetStringBoundingBox(STR_DEPARTURES_GROUP)).width;
|
||||||
|
if (_settings_client.gui.departure_show_group && width > group_width) group_width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDParam(0, (uint64)((*v)->owner));
|
||||||
|
width = (GetStringBoundingBox(STR_DEPARTURES_TOC)).width;
|
||||||
|
if (_settings_client.gui.departure_show_company && width > toc_width) toc_width = width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result += toc_width + veh_width + group_width;
|
||||||
|
|
||||||
|
return result + 140;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes this window's departure list.
|
||||||
|
*/
|
||||||
|
template<bool Twaypoint>
|
||||||
|
void DeparturesWindow<Twaypoint>::DeleteDeparturesList(DepartureList *list)
|
||||||
|
{
|
||||||
|
/* SmallVector uses free rather than delete on its contents (which doesn't invoke the destructor), so we need to delete each departure manually. */
|
||||||
|
for (uint i = 0; i < list->Length(); ++i) {
|
||||||
|
Departure **d = list->Get(i);
|
||||||
|
delete *d;
|
||||||
|
/* Make sure a double free doesn't happen. */
|
||||||
|
*d = NULL;
|
||||||
|
}
|
||||||
|
list->Reset();
|
||||||
|
delete list;
|
||||||
|
list = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a list of departures.
|
||||||
|
*/
|
||||||
|
template<bool Twaypoint>
|
||||||
|
void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
|
||||||
|
{
|
||||||
|
int left = r.left + WD_MATRIX_LEFT;
|
||||||
|
int right = r.right - WD_MATRIX_RIGHT;
|
||||||
|
|
||||||
|
bool rtl = _current_text_dir == TD_RTL;
|
||||||
|
bool ltr = !rtl;
|
||||||
|
|
||||||
|
int text_offset = WD_FRAMERECT_RIGHT;
|
||||||
|
int text_left = left + (rtl ? 0 : text_offset);
|
||||||
|
int text_right = right - (rtl ? text_offset : 0);
|
||||||
|
|
||||||
|
int y = r.top + 1;
|
||||||
|
uint max_departures = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->departures->Length() + this->arrivals->Length());
|
||||||
|
|
||||||
|
if (max_departures > _settings_client.gui.max_departures) {
|
||||||
|
max_departures = _settings_client.gui.max_departures;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte small_font_size = _settings_client.gui.departure_larger_font ? FONT_HEIGHT_NORMAL : FONT_HEIGHT_SMALL;
|
||||||
|
|
||||||
|
/* Draw the black background. */
|
||||||
|
GfxFillRect(r.left + 1, r.top, r.right - 1, r.bottom, PC_BLACK);
|
||||||
|
|
||||||
|
/* Nothing selected? Then display the information text. */
|
||||||
|
bool none_selected[2] = {true, true};
|
||||||
|
for (uint i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
if (this->show_types[i]) {
|
||||||
|
none_selected[0] = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint i = 0; i < 2; ++i)
|
||||||
|
{
|
||||||
|
if (this->departure_types[i]) {
|
||||||
|
none_selected[1] = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (none_selected[0] || none_selected[1]) {
|
||||||
|
DrawString(text_left, text_right, y + 1, STR_DEPARTURES_NONE_SELECTED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No scheduled departures? Then display the information text. */
|
||||||
|
if (max_departures == 0) {
|
||||||
|
DrawString(text_left, text_right, y + 1, STR_DEPARTURES_EMPTY);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find the maximum possible width of the departure time and "Expt <time>" fields. */
|
||||||
|
int time_width = cached_date_width;
|
||||||
|
|
||||||
|
if (!_settings_client.gui.departure_show_both) {
|
||||||
|
time_width += (departure_types[0] && departure_types[1] ? cached_date_arrow_width : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Vehicle type icon */
|
||||||
|
int type_width = _settings_client.gui.departure_show_vehicle_type ? (GetStringBoundingBox(STR_DEPARTURES_TYPE_PLANE)).width : 0;
|
||||||
|
|
||||||
|
/* Find the maximum width of the status field */
|
||||||
|
int status_width = cached_status_width;
|
||||||
|
|
||||||
|
/* Find the width of the "Calling at:" field. */
|
||||||
|
int calling_at_width = (GetStringBoundingBox(_settings_client.gui.departure_larger_font ? STR_DEPARTURES_CALLING_AT_LARGE : STR_DEPARTURES_CALLING_AT)).width;
|
||||||
|
|
||||||
|
/* Find the maximum company name width. */
|
||||||
|
int toc_width = 0;
|
||||||
|
|
||||||
|
/* Find the maximum group name width. */
|
||||||
|
int group_width = 0;
|
||||||
|
|
||||||
|
/* Find the maximum vehicle name width. */
|
||||||
|
int veh_width = 0;
|
||||||
|
|
||||||
|
if (_settings_client.gui.departure_show_vehicle || _settings_client.gui.departure_show_company || _settings_client.gui.departure_show_group) {
|
||||||
|
for (uint i = 0; i < 4; ++i) {
|
||||||
|
VehicleList vehicles;
|
||||||
|
|
||||||
|
/* MAX_COMPANIES is probably the wrong thing to put here, but it works. GenerateVehicleSortList doesn't check the company when the type of list is VL_STATION_LIST (r20801). */
|
||||||
|
if (!GenerateVehicleSortList(&vehicles, VehicleListIdentifier(VL_STATION_LIST, (VehicleType)(VEH_TRAIN + i), MAX_COMPANIES, station).Pack())) {
|
||||||
|
/* Something went wrong: panic! */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const Vehicle **v = vehicles.Begin(); v != vehicles.End(); v++) {
|
||||||
|
SetDParam(0, (uint64)((*v)->index));
|
||||||
|
int width = (GetStringBoundingBox(STR_DEPARTURES_VEH)).width;
|
||||||
|
if (_settings_client.gui.departure_show_vehicle && width > veh_width) veh_width = width;
|
||||||
|
|
||||||
|
if ((*v)->group_id != INVALID_GROUP && (*v)->group_id != DEFAULT_GROUP) {
|
||||||
|
SetDParam(0, (uint64)((*v)->group_id));
|
||||||
|
width = (GetStringBoundingBox(STR_DEPARTURES_GROUP)).width;
|
||||||
|
if (_settings_client.gui.departure_show_group && width > group_width) group_width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDParam(0, (uint64)((*v)->owner));
|
||||||
|
width = (GetStringBoundingBox(STR_DEPARTURES_TOC)).width;
|
||||||
|
if (_settings_client.gui.departure_show_company && width > toc_width) toc_width = width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint departure = 0;
|
||||||
|
uint arrival = 0;
|
||||||
|
|
||||||
|
/* Draw each departure. */
|
||||||
|
for (uint i = 0; i < max_departures; ++i) {
|
||||||
|
const Departure *d;
|
||||||
|
|
||||||
|
if (arrival == this->arrivals->Length()) {
|
||||||
|
d = (*(this->departures))[departure++];
|
||||||
|
} else if (departure == this->departures->Length()) {
|
||||||
|
d = (*(this->arrivals))[arrival++];
|
||||||
|
} else {
|
||||||
|
d = (*(this->departures))[departure];
|
||||||
|
const Departure *a = (*(this->arrivals))[arrival];
|
||||||
|
|
||||||
|
if (a->scheduled_date < d->scheduled_date) {
|
||||||
|
d = a;
|
||||||
|
arrival++;
|
||||||
|
} else {
|
||||||
|
departure++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < this->vscroll->GetPosition()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If for some reason the departure is too far in the future or is at a negative time, skip it. */
|
||||||
|
if ((d->scheduled_date / DAY_TICKS) > (_date + _settings_client.gui.max_departure_time) ||
|
||||||
|
d->scheduled_date < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d->terminus == INVALID_STATION) continue;
|
||||||
|
|
||||||
|
StringID time_str = (departure_types[0] && departure_types[1]) ? (d->type == D_DEPARTURE ? STR_DEPARTURES_TIME_DEP : STR_DEPARTURES_TIME_ARR) : STR_DEPARTURES_TIME;
|
||||||
|
|
||||||
|
if (_settings_client.gui.departure_show_both) time_str = STR_DEPARTURES_TIME_BOTH;
|
||||||
|
|
||||||
|
/* Time */
|
||||||
|
SetDParam(0, d->scheduled_date);
|
||||||
|
SetDParam(1, d->scheduled_date - d->order->GetWaitTime());
|
||||||
|
ltr ? DrawString( text_left, text_left + time_width, y + 1, time_str)
|
||||||
|
: DrawString(text_right - time_width, text_right, y + 1, time_str);
|
||||||
|
|
||||||
|
/* Vehicle type icon, with thanks to sph */
|
||||||
|
if (_settings_client.gui.departure_show_vehicle_type) {
|
||||||
|
StringID type = STR_DEPARTURES_TYPE_TRAIN;
|
||||||
|
int offset = (_settings_client.gui.departure_show_vehicle_color ? 1 : 0);
|
||||||
|
|
||||||
|
switch (d->vehicle->type) {
|
||||||
|
case VEH_TRAIN:
|
||||||
|
type = STR_DEPARTURES_TYPE_TRAIN;
|
||||||
|
break;
|
||||||
|
case VEH_ROAD:
|
||||||
|
type = IsCargoInClass(d->vehicle->cargo_type, CC_PASSENGERS) ? STR_DEPARTURES_TYPE_BUS : STR_DEPARTURES_TYPE_LORRY;
|
||||||
|
break;
|
||||||
|
case VEH_SHIP:
|
||||||
|
type = STR_DEPARTURES_TYPE_SHIP;
|
||||||
|
break;
|
||||||
|
case VEH_AIRCRAFT:
|
||||||
|
type = STR_DEPARTURES_TYPE_PLANE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
type += offset;
|
||||||
|
|
||||||
|
DrawString(text_left + time_width + 3, text_left + time_width + type_width + 3, y, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The icons to show with the destination and via stations. */
|
||||||
|
StringID icon = STR_DEPARTURES_STATION_NONE;
|
||||||
|
StringID icon_via = STR_DEPARTURES_STATION_NONE;
|
||||||
|
|
||||||
|
if (_settings_client.gui.departure_destination_type) {
|
||||||
|
Station *t = Station::Get(d->terminus.station);
|
||||||
|
|
||||||
|
if (t->facilities & FACIL_DOCK &&
|
||||||
|
t->facilities & FACIL_AIRPORT &&
|
||||||
|
d->vehicle->type != VEH_SHIP &&
|
||||||
|
d->vehicle->type != VEH_AIRCRAFT) {
|
||||||
|
icon = STR_DEPARTURES_STATION_PORTAIRPORT;
|
||||||
|
} else if (t->facilities & FACIL_DOCK &&
|
||||||
|
d->vehicle->type != VEH_SHIP) {
|
||||||
|
icon = STR_DEPARTURES_STATION_PORT;
|
||||||
|
} else if (t->facilities & FACIL_AIRPORT &&
|
||||||
|
d->vehicle->type != VEH_AIRCRAFT) {
|
||||||
|
icon = STR_DEPARTURES_STATION_AIRPORT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_settings_client.gui.departure_destination_type && d->via != INVALID_STATION) {
|
||||||
|
Station *t = Station::Get(d->via);
|
||||||
|
|
||||||
|
if (t->facilities & FACIL_DOCK &&
|
||||||
|
t->facilities & FACIL_AIRPORT &&
|
||||||
|
d->vehicle->type != VEH_SHIP &&
|
||||||
|
d->vehicle->type != VEH_AIRCRAFT) {
|
||||||
|
icon_via = STR_DEPARTURES_STATION_PORTAIRPORT;
|
||||||
|
} else if (t->facilities & FACIL_DOCK &&
|
||||||
|
d->vehicle->type != VEH_SHIP) {
|
||||||
|
icon_via = STR_DEPARTURES_STATION_PORT;
|
||||||
|
} else if (t->facilities & FACIL_AIRPORT &&
|
||||||
|
d->vehicle->type != VEH_AIRCRAFT) {
|
||||||
|
icon_via = STR_DEPARTURES_STATION_AIRPORT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Destination */
|
||||||
|
if (d->via == INVALID_STATION) {
|
||||||
|
/* Only show the terminus. */
|
||||||
|
SetDParam(0, d->terminus.station);
|
||||||
|
SetDParam(1, icon);
|
||||||
|
ltr ? DrawString( text_left + time_width + type_width + 6, text_right - status_width - (toc_width + veh_width + group_width + 2) - 2, y + 1, STR_DEPARTURES_TERMINUS)
|
||||||
|
: DrawString(text_left + status_width + (toc_width + veh_width + group_width + 2) + 2, text_right - time_width - type_width - 6, y + 1, STR_DEPARTURES_TERMINUS);
|
||||||
|
} else {
|
||||||
|
/* Show the terminus and the via station. */
|
||||||
|
SetDParam(0, d->terminus.station);
|
||||||
|
SetDParam(1, icon);
|
||||||
|
SetDParam(2, d->via);
|
||||||
|
SetDParam(3, icon_via);
|
||||||
|
int text_width = (GetStringBoundingBox(STR_DEPARTURES_TERMINUS_VIA_STATION)).width;
|
||||||
|
|
||||||
|
if (text_width < text_right - status_width - (toc_width + veh_width + group_width + 2) - 2 - (text_left + time_width + type_width + 6)) {
|
||||||
|
/* They will both fit, so show them both. */
|
||||||
|
SetDParam(0, d->terminus.station);
|
||||||
|
SetDParam(1, icon);
|
||||||
|
SetDParam(2, d->via);
|
||||||
|
SetDParam(3, icon_via);
|
||||||
|
ltr ? DrawString( text_left + time_width + type_width + 6, text_right - status_width - (toc_width + veh_width + group_width + 2) - 2, y + 1, STR_DEPARTURES_TERMINUS_VIA_STATION)
|
||||||
|
: DrawString(text_left + status_width + (toc_width + veh_width + group_width + 2) + 2, text_right - time_width - type_width - 6, y + 1, STR_DEPARTURES_TERMINUS_VIA_STATION);
|
||||||
|
} else {
|
||||||
|
/* They won't both fit, so switch between showing the terminus and the via station approximately every 4 seconds. */
|
||||||
|
if (this->tick_count & (1 << 7)) {
|
||||||
|
SetDParam(0, d->via);
|
||||||
|
SetDParam(1, icon_via);
|
||||||
|
ltr ? DrawString( text_left + time_width + type_width + 6, text_right - status_width - (toc_width + veh_width + group_width + 2) - 2, y + 1, STR_DEPARTURES_VIA)
|
||||||
|
: DrawString(text_left + status_width + (toc_width + veh_width + group_width + 2) + 2, text_right - time_width - type_width - 6, y + 1, STR_DEPARTURES_VIA);
|
||||||
|
} else {
|
||||||
|
SetDParam(0, d->terminus.station);
|
||||||
|
SetDParam(1, icon);
|
||||||
|
ltr ? DrawString( text_left + time_width + type_width + 6, text_right - status_width - (toc_width + veh_width + group_width + 2) - 2, y + 1, STR_DEPARTURES_TERMINUS_VIA)
|
||||||
|
: DrawString(text_left + status_width + (toc_width + veh_width + group_width + 2) + 2, text_right - time_width - type_width - 6, y + 1, STR_DEPARTURES_TERMINUS_VIA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status */
|
||||||
|
{
|
||||||
|
int status_left = ltr ? text_right - status_width - 2 - (toc_width + veh_width + group_width + 2) : text_left + (toc_width + veh_width + group_width + 2) + 2;
|
||||||
|
int status_right = ltr ? text_right - (toc_width + veh_width + group_width + 2) + 2 : text_left + status_width + 2 + (toc_width + veh_width + group_width + 2);
|
||||||
|
|
||||||
|
if (d->status == D_ARRIVED) {
|
||||||
|
/* The vehicle has arrived. */
|
||||||
|
DrawString(status_left, status_right, y + 1, STR_DEPARTURES_ARRIVED);
|
||||||
|
} else if(d->status == D_CANCELLED) {
|
||||||
|
/* The vehicle has been cancelled. */
|
||||||
|
DrawString(status_left, status_right, y + 1, STR_DEPARTURES_CANCELLED);
|
||||||
|
} else{
|
||||||
|
if (d->lateness <= DAY_TICKS && d->scheduled_date > ((_date * DAY_TICKS) + _date_fract)) {
|
||||||
|
/* We have no evidence that the vehicle is late, so assume it is on time. */
|
||||||
|
DrawString(status_left, status_right, y + 1, STR_DEPARTURES_ON_TIME);
|
||||||
|
} else {
|
||||||
|
if ((d->scheduled_date + d->lateness) < ((_date * DAY_TICKS) + _date_fract)) {
|
||||||
|
/* The vehicle was expected to have arrived by now, even if we knew it was going to be late. */
|
||||||
|
/* We assume that the train stays at least a day at a station so it won't accidentally be marked as delayed for a fraction of a day. */
|
||||||
|
DrawString(status_left, status_right, y + 1, STR_DEPARTURES_DELAYED);
|
||||||
|
} else {
|
||||||
|
/* The vehicle is expected to be late and is not yet due to arrive. */
|
||||||
|
SetDParam(0, d->scheduled_date + d->lateness);
|
||||||
|
DrawString(status_left, status_right, y + 1, STR_DEPARTURES_EXPECTED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Vehicle name */
|
||||||
|
|
||||||
|
if (_settings_client.gui.departure_show_vehicle) {
|
||||||
|
SetDParam(0, (uint64)(d->vehicle->index));
|
||||||
|
ltr ? DrawString(text_right - (toc_width + veh_width + group_width + 2), text_right - toc_width - group_width - 2, y + 1, STR_DEPARTURES_VEH)
|
||||||
|
: DrawString( text_left + toc_width + group_width + 2, text_left + (toc_width + veh_width + group_width + 2), y + 1, STR_DEPARTURES_VEH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Group name */
|
||||||
|
|
||||||
|
if (_settings_client.gui.departure_show_group && d->vehicle->group_id != INVALID_GROUP && d->vehicle->group_id != DEFAULT_GROUP) {
|
||||||
|
SetDParam(0, (uint64)(d->vehicle->group_id));
|
||||||
|
ltr ? DrawString(text_right - (toc_width + group_width + 2), text_right - toc_width - 2, y + 1, STR_DEPARTURES_GROUP)
|
||||||
|
: DrawString( text_left + toc_width + 2, text_left + (toc_width + group_width + 2), y + 1, STR_DEPARTURES_GROUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Operating company */
|
||||||
|
if (_settings_client.gui.departure_show_company) {
|
||||||
|
SetDParam(0, (uint64)(d->vehicle->owner));
|
||||||
|
ltr ? DrawString(text_right - toc_width, text_right, y + 1, STR_DEPARTURES_TOC, TC_FROMSTRING, SA_RIGHT)
|
||||||
|
: DrawString( text_left, text_left + toc_width, y + 1, STR_DEPARTURES_TOC, TC_FROMSTRING, SA_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bottom_y = y + this->entry_height - small_font_size - (_settings_client.gui.departure_larger_font ? 1 : 3);
|
||||||
|
|
||||||
|
/* Calling at */
|
||||||
|
ltr ? DrawString( text_left, text_left + calling_at_width, bottom_y, _settings_client.gui.departure_larger_font ? STR_DEPARTURES_CALLING_AT_LARGE : STR_DEPARTURES_CALLING_AT)
|
||||||
|
: DrawString(text_right - calling_at_width, text_right, bottom_y, _settings_client.gui.departure_larger_font ? STR_DEPARTURES_CALLING_AT_LARGE : STR_DEPARTURES_CALLING_AT);
|
||||||
|
|
||||||
|
/* List of stations */
|
||||||
|
/* RTL languages can be handled in the language file, e.g. by having the following: */
|
||||||
|
/* STR_DEPARTURES_CALLING_AT_STATION :{STATION}, {RAW_STRING} */
|
||||||
|
/* STR_DEPARTURES_CALLING_AT_LAST_STATION :{STATION} & {RAW_STRING}*/
|
||||||
|
char buffer[512], scratch[512];
|
||||||
|
|
||||||
|
if (d->calling_at.Length() != 0) {
|
||||||
|
SetDParam(0, (uint64)(*d->calling_at.Get(0)).station);
|
||||||
|
GetString(scratch, STR_DEPARTURES_CALLING_AT_FIRST_STATION, lastof(scratch));
|
||||||
|
|
||||||
|
StationID continuesTo = INVALID_STATION;
|
||||||
|
|
||||||
|
if (d->calling_at.Get(0)->station == d->terminus.station && d->calling_at.Length() > 1) {
|
||||||
|
continuesTo = d->calling_at.Get(d->calling_at.Length() - 1)->station;
|
||||||
|
} else if (d->calling_at.Length() > 1) {
|
||||||
|
/* There's more than one stop. */
|
||||||
|
|
||||||
|
uint i;
|
||||||
|
/* For all but the last station, write out ", <station>". */
|
||||||
|
for (i = 1; i < d->calling_at.Length() - 1; ++i) {
|
||||||
|
StationID s = d->calling_at.Get(i)->station;
|
||||||
|
if (s == d->terminus.station) {
|
||||||
|
continuesTo = d->calling_at.Get(d->calling_at.Length() - 1)->station;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SetDParam(0, (uint64)scratch);
|
||||||
|
SetDParam(1, (uint64)s);
|
||||||
|
GetString(buffer, STR_DEPARTURES_CALLING_AT_STATION, lastof(buffer));
|
||||||
|
strncpy(scratch, buffer, sizeof(scratch));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finally, finish off with " and <station>". */
|
||||||
|
SetDParam(0, (uint64)scratch);
|
||||||
|
SetDParam(1, (uint64)d->calling_at.Get(i)->station);
|
||||||
|
GetString(buffer, STR_DEPARTURES_CALLING_AT_LAST_STATION, lastof(buffer));
|
||||||
|
strncpy(scratch, buffer, sizeof(scratch));
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDParam(0, (uint64)scratch);
|
||||||
|
StringID string;
|
||||||
|
if (continuesTo == INVALID_STATION) {
|
||||||
|
string = _settings_client.gui.departure_larger_font ? STR_DEPARTURES_CALLING_AT_LIST_LARGE : STR_DEPARTURES_CALLING_AT_LIST;
|
||||||
|
} else {
|
||||||
|
SetDParam(1, continuesTo);
|
||||||
|
string = _settings_client.gui.departure_larger_font ? STR_DEPARTURES_CALLING_AT_LIST_SMART_TERMINUS_LARGE : STR_DEPARTURES_CALLING_AT_LIST_SMART_TERMINUS;
|
||||||
|
}
|
||||||
|
GetString(buffer, string, lastof(buffer));
|
||||||
|
} else {
|
||||||
|
buffer[0] = 0;
|
||||||
|
//SetDParam(0, d->terminus);
|
||||||
|
//GetString(scratch, STR_DEPARTURES_CALLING_AT_FIRST_STATION, lastof(scratch));
|
||||||
|
}
|
||||||
|
|
||||||
|
int list_width = (GetStringBoundingBox(buffer, _settings_client.gui.departure_larger_font ? FS_NORMAL : FS_SMALL)).width;
|
||||||
|
|
||||||
|
/* Draw the whole list if it will fit. Otherwise scroll it. */
|
||||||
|
if (list_width < text_right - (text_left + calling_at_width + 2)) {
|
||||||
|
ltr ? DrawString(text_left + calling_at_width + 2, text_right, bottom_y, buffer)
|
||||||
|
: DrawString( text_left, text_right - calling_at_width - 2, bottom_y, buffer);
|
||||||
|
} else {
|
||||||
|
DrawPixelInfo tmp_dpi;
|
||||||
|
if (ltr
|
||||||
|
? !FillDrawPixelInfo(&tmp_dpi, text_left + calling_at_width + 2, bottom_y, text_right - (text_left + calling_at_width + 2), small_font_size + 3)
|
||||||
|
: !FillDrawPixelInfo(&tmp_dpi, text_left , bottom_y, text_right - (text_left + calling_at_width + 2), small_font_size + 3)) {
|
||||||
|
y += this->entry_height;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DrawPixelInfo *old_dpi = _cur_dpi;
|
||||||
|
_cur_dpi = &tmp_dpi;
|
||||||
|
|
||||||
|
/* The scrolling text starts out of view at the right of the screen and finishes when it is out of view at the left of the screen. */
|
||||||
|
int pos = ltr
|
||||||
|
? text_right - (this->tick_count % (list_width + text_right - text_left))
|
||||||
|
: text_left + (this->tick_count % (list_width + text_right - text_left));
|
||||||
|
|
||||||
|
ltr ? DrawString( pos, INT16_MAX, 0, buffer, TC_FROMSTRING, SA_LEFT | SA_FORCE)
|
||||||
|
: DrawString(-INT16_MAX, pos, 0, buffer, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
|
||||||
|
|
||||||
|
_cur_dpi = old_dpi;
|
||||||
|
}
|
||||||
|
|
||||||
|
y += this->entry_height;
|
||||||
|
}
|
||||||
|
}
|
22
src/departures_gui.h
Normal file
22
src/departures_gui.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/* $Id: departures_gui.h $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of OpenTTD.
|
||||||
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||||
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file departures_gui.h */
|
||||||
|
|
||||||
|
#ifndef DEPARTURES_GUI_H
|
||||||
|
#define DEPARTURES_GUI_H
|
||||||
|
|
||||||
|
#include "departures_type.h"
|
||||||
|
#include "station_base.h"
|
||||||
|
#include "widgets/departures_widget.h"
|
||||||
|
|
||||||
|
void ShowStationDepartures(StationID station);
|
||||||
|
void ShowWaypointDepartures(StationID waypoint);
|
||||||
|
|
||||||
|
#endif /* DEPARTURES_GUI_H */
|
101
src/departures_type.h
Normal file
101
src/departures_type.h
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
/* $Id: departures_type.h $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of OpenTTD.
|
||||||
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||||
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file departures_type.h Types related to departures. */
|
||||||
|
|
||||||
|
#ifndef DEPARTURES_TYPE_H
|
||||||
|
#define DEPARTURES_TYPE_H
|
||||||
|
|
||||||
|
#include "station_base.h"
|
||||||
|
#include "order_base.h"
|
||||||
|
#include "vehicle_base.h"
|
||||||
|
|
||||||
|
/** Whether or not a vehicle has arrived for a departure. */
|
||||||
|
typedef enum {
|
||||||
|
D_TRAVELLING = 0,
|
||||||
|
D_ARRIVED = 1,
|
||||||
|
D_CANCELLED = 2,
|
||||||
|
} DepartureStatus;
|
||||||
|
|
||||||
|
/** The type of departures. */
|
||||||
|
typedef enum {
|
||||||
|
D_DEPARTURE = 0,
|
||||||
|
D_ARRIVAL = 1,
|
||||||
|
} DepartureType;
|
||||||
|
|
||||||
|
typedef struct CallAt {
|
||||||
|
StationID station;
|
||||||
|
DateTicks scheduled_date;
|
||||||
|
|
||||||
|
CallAt(const StationID& s) : station(s), scheduled_date(0) { }
|
||||||
|
CallAt(const StationID& s, const DateTicks& t) : station(s), scheduled_date(t) { }
|
||||||
|
CallAt(const CallAt& c) : station(c.station), scheduled_date(c.scheduled_date) { }
|
||||||
|
|
||||||
|
inline bool operator==(const CallAt& c) const {
|
||||||
|
return this->station == c.station;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator!=(const CallAt& c) const {
|
||||||
|
return this->station != c.station;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator>=(const CallAt& c) const {
|
||||||
|
return this->station == c.station &&
|
||||||
|
this->scheduled_date != 0 &&
|
||||||
|
c.scheduled_date != 0 &&
|
||||||
|
this->scheduled_date >= c.scheduled_date;
|
||||||
|
}
|
||||||
|
|
||||||
|
CallAt& operator=(const CallAt& c) {
|
||||||
|
this->station = c.station;
|
||||||
|
this->scheduled_date = c.scheduled_date;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator==(StationID s) const {
|
||||||
|
return this->station == s;
|
||||||
|
}
|
||||||
|
} CallAt;
|
||||||
|
|
||||||
|
/** A scheduled departure. */
|
||||||
|
typedef struct Departure {
|
||||||
|
DateTicks scheduled_date; ///< The date this departure is scheduled to finish on (i.e. when the vehicle leaves the station)
|
||||||
|
DateTicks lateness; ///< How delayed the departure is expected to be
|
||||||
|
CallAt terminus; ///< The station at which the vehicle will terminate following this departure
|
||||||
|
StationID via; ///< The station the departure should list as going via
|
||||||
|
SmallVector<CallAt, 32> calling_at; ///< The stations both called at and unloaded at by the vehicle after this departure before it terminates
|
||||||
|
DepartureStatus status; ///< Whether the vehicle has arrived yet for this departure
|
||||||
|
DepartureType type; ///< The type of the departure (departure or arrival)
|
||||||
|
const Vehicle *vehicle; ///< The vehicle performing this departure
|
||||||
|
const Order *order; ///< The order corresponding to this departure
|
||||||
|
Departure() : terminus(INVALID_STATION), via(INVALID_STATION), calling_at(), vehicle(NULL) { }
|
||||||
|
~Departure()
|
||||||
|
{
|
||||||
|
calling_at.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator==(const Departure& d) const {
|
||||||
|
if (this->calling_at.Length() != d.calling_at.Length()) return false;
|
||||||
|
|
||||||
|
for (uint i = 0; i < this->calling_at.Length(); ++i) {
|
||||||
|
if (*(this->calling_at.Get(i)) != *(d.calling_at.Get(i))) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
(this->scheduled_date / DATE_UNIT_SIZE) == (d.scheduled_date / DATE_UNIT_SIZE) &&
|
||||||
|
this->vehicle->type == d.vehicle->type &&
|
||||||
|
this->via == d.via &&
|
||||||
|
this->type == d.type
|
||||||
|
;
|
||||||
|
}
|
||||||
|
} Departure;
|
||||||
|
|
||||||
|
typedef SmallVector<Departure*, 32> DepartureList;
|
||||||
|
|
||||||
|
#endif /* DEPARTURES_TYPE_H */
|
@@ -1400,6 +1400,20 @@ STR_CONFIG_SETTING_LOADING_INDICATORS :Use loading ind
|
|||||||
STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT :Select whether loading indicators are displayed above loading or unloading vehicles
|
STR_CONFIG_SETTING_LOADING_INDICATORS_HELPTEXT :Select whether loading indicators are displayed above loading or unloading vehicles
|
||||||
STR_CONFIG_SETTING_TIMETABLE_IN_TICKS :Show timetable in ticks rather than days: {STRING2}
|
STR_CONFIG_SETTING_TIMETABLE_IN_TICKS :Show timetable in ticks rather than days: {STRING2}
|
||||||
STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT :Show travel times in time tables in game ticks instead of days
|
STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT :Show travel times in time tables in game ticks instead of days
|
||||||
|
STR_CONFIG_SETTING_TIME_IN_MINUTES :Show time in minutes rather than days: {STRING2}
|
||||||
|
STR_CONFIG_SETTING_TIME_IN_MINUTES_HELPTEXT :Select whether to use hours and minutes instead of days
|
||||||
|
STR_CONFIG_SETTING_TICKS_PER_MINUTE :Ticks per minute: {STRING2}
|
||||||
|
STR_CONFIG_SETTING_TICKS_PER_MINUTE_HELPTEXT :The number of game ticks per minute
|
||||||
|
STR_CONFIG_SETTING_DATE_WITH_TIME :Show date with time in status bar: {STRING2}
|
||||||
|
STR_CONFIG_SETTING_DATE_WITH_TIME_HELPTEXT :Show the real game date in the status bar as well as the time
|
||||||
|
STR_CONFIG_SETTING_CLOCK_OFFSET :Clock offset in minutes: {STRING2}
|
||||||
|
STR_CONFIG_SETTING_CLOCK_OFFSET_HELPTEXT :The number of minutes the game clock is offset by
|
||||||
|
STR_CONFIG_SETTING_DATE_WITH_TIME_NONE :None
|
||||||
|
STR_CONFIG_SETTING_DATE_WITH_TIME_Y :Year
|
||||||
|
STR_CONFIG_SETTING_DATE_WITH_TIME_YM :Month and year
|
||||||
|
STR_CONFIG_SETTING_DATE_WITH_TIME_YMD :Full date
|
||||||
|
STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY :Enter timetable start times as text (requires time to be in minutes): {STRING2}
|
||||||
|
STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY_HELPTEXT :Select whether timetable start times may be entered as text if time is being shown in minutes
|
||||||
STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Show arrival and departure in timetables: {STRING2}
|
STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Show arrival and departure in timetables: {STRING2}
|
||||||
STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Display anticipated arrival and departure times in timetables
|
STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Display anticipated arrival and departure times in timetables
|
||||||
STR_CONFIG_SETTING_QUICKGOTO :Quick creation of vehicle orders: {STRING2}
|
STR_CONFIG_SETTING_QUICKGOTO :Quick creation of vehicle orders: {STRING2}
|
||||||
@@ -1675,6 +1689,8 @@ STR_CONFIG_SETTING_INTERFACE :{ORANGE}Interfa
|
|||||||
STR_CONFIG_SETTING_INTERFACE_GENERAL :{ORANGE}General
|
STR_CONFIG_SETTING_INTERFACE_GENERAL :{ORANGE}General
|
||||||
STR_CONFIG_SETTING_INTERFACE_VIEWPORTS :{ORANGE}Viewports
|
STR_CONFIG_SETTING_INTERFACE_VIEWPORTS :{ORANGE}Viewports
|
||||||
STR_CONFIG_SETTING_INTERFACE_CONSTRUCTION :{ORANGE}Construction
|
STR_CONFIG_SETTING_INTERFACE_CONSTRUCTION :{ORANGE}Construction
|
||||||
|
STR_CONFIG_SETTING_INTERFACE_DEPARTUREBOARDS :{ORANGE}Departure boards
|
||||||
|
STR_CONFIG_SETTING_INTERFACE_WALLCLOCK :{ORANGE}Wall clock
|
||||||
STR_CONFIG_SETTING_ADVISORS :{ORANGE}News / Advisors
|
STR_CONFIG_SETTING_ADVISORS :{ORANGE}News / Advisors
|
||||||
STR_CONFIG_SETTING_COMPANY :{ORANGE}Company
|
STR_CONFIG_SETTING_COMPANY :{ORANGE}Company
|
||||||
STR_CONFIG_SETTING_ACCOUNTING :{ORANGE}Accounting
|
STR_CONFIG_SETTING_ACCOUNTING :{ORANGE}Accounting
|
||||||
@@ -3148,6 +3164,9 @@ STR_STATION_VIEW_GROUP_V_D_S :Via-Destination
|
|||||||
STR_STATION_VIEW_GROUP_D_S_V :Destination-Source-Via
|
STR_STATION_VIEW_GROUP_D_S_V :Destination-Source-Via
|
||||||
STR_STATION_VIEW_GROUP_D_V_S :Destination-Via-Source
|
STR_STATION_VIEW_GROUP_D_V_S :Destination-Via-Source
|
||||||
|
|
||||||
|
STR_STATION_VIEW_DEPARTURES_BUTTON :{BLACK}Departures
|
||||||
|
STR_STATION_VIEW_DEPARTURES_TOOLTIP :{BLACK}Show list of scheduled departures
|
||||||
|
|
||||||
############ range for rating starts
|
############ range for rating starts
|
||||||
STR_CARGO_RATING_APPALLING :Appalling
|
STR_CARGO_RATING_APPALLING :Appalling
|
||||||
STR_CARGO_RATING_VERY_POOR :Very Poor
|
STR_CARGO_RATING_VERY_POOR :Very Poor
|
||||||
@@ -3168,10 +3187,102 @@ STR_STATION_VIEW_SCHEDULED_AIRCRAFT_TOOLTIP :{BLACK}Show all
|
|||||||
STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP :{BLACK}Show all ships which have this station on their schedule
|
STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP :{BLACK}Show all ships which have this station on their schedule
|
||||||
|
|
||||||
STR_STATION_VIEW_RENAME_STATION_CAPTION :Rename station/loading area
|
STR_STATION_VIEW_RENAME_STATION_CAPTION :Rename station/loading area
|
||||||
|
|
||||||
STR_STATION_VIEW_CLOSE_AIRPORT :{BLACK}Close airport
|
STR_STATION_VIEW_CLOSE_AIRPORT :{BLACK}Close airport
|
||||||
STR_STATION_VIEW_CLOSE_AIRPORT_TOOLTIP :{BLACK}Prevent aircraft from landing on this airport
|
STR_STATION_VIEW_CLOSE_AIRPORT_TOOLTIP :{BLACK}Prevent aircraft from landing on this airport
|
||||||
|
|
||||||
|
# Departures window
|
||||||
|
STR_DEPARTURES_CAPTION :{WHITE}{STATION} Live Travel Information
|
||||||
|
STR_DEPARTURES_CAPTION_WAYPOINT :{WHITE}{WAYPOINT} Live Travel Information
|
||||||
|
STR_DEPARTURES_DEPARTURES :{BLACK}{TINY_FONT}D
|
||||||
|
STR_DEPARTURES_ARRIVALS :{BLACK}{TINY_FONT}A
|
||||||
|
STR_DEPARTURES_VIA_BUTTON :{BLACK}{TINY_FONT}via
|
||||||
|
STR_DEPARTURES_DEPARTURES_TOOLTIP :{BLACK}Show timetabled departures
|
||||||
|
STR_DEPARTURES_ARRIVALS_TOOLTIP :{BLACK}Show timetabled arrivals
|
||||||
|
STR_DEPARTURES_VIA_TOOLTIP :{BLACK}Show timetabled vehicles that do not stop here
|
||||||
|
STR_DEPARTURES_EMPTY :{ORANGE}No vehicles are currently timetabled for this station.
|
||||||
|
STR_DEPARTURES_NONE_SELECTED :{ORANGE}No timetable information has been requested.
|
||||||
|
STR_DEPARTURES_TIME :{ORANGE}{DATE_WALLCLOCK_TINY}
|
||||||
|
STR_DEPARTURES_TIME_DEP :{ORANGE}{DATE_WALLCLOCK_TINY} {GREEN}{UP_ARROW}
|
||||||
|
STR_DEPARTURES_TIME_ARR :{ORANGE}{DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW}
|
||||||
|
STR_DEPARTURES_TIME_BOTH :{ORANGE}{1:DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW} {ORANGE}{0:DATE_WALLCLOCK_TINY} {GREEN}{UP_ARROW}
|
||||||
|
STR_DEPARTURES_TERMINUS :{ORANGE}{STATION}{STRING}
|
||||||
|
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING} via {STATION}{STRING}
|
||||||
|
STR_DEPARTURES_TERMINUS_VIA :{ORANGE}{STATION}{STRING} via
|
||||||
|
STR_DEPARTURES_VIA :{ORANGE}via {STATION}{STRING}
|
||||||
|
STR_DEPARTURES_TOC :{ORANGE}{COMPANY}
|
||||||
|
STR_DEPARTURES_GROUP :{ORANGE}{GROUP}
|
||||||
|
STR_DEPARTURES_VEH :{ORANGE}{VEHICLE}
|
||||||
|
STR_DEPARTURES_CALLING_AT :{TINY_FONT}{ORANGE}Calling at:
|
||||||
|
STR_DEPARTURES_CALLING_AT_LARGE :{ORANGE}Calling at:
|
||||||
|
STR_DEPARTURES_CALLING_AT_FIRST_STATION :{STATION}
|
||||||
|
STR_DEPARTURES_CALLING_AT_STATION :{RAW_STRING}, {STATION}
|
||||||
|
STR_DEPARTURES_CALLING_AT_LAST_STATION :{RAW_STRING} and {STATION}
|
||||||
|
STR_DEPARTURES_CALLING_AT_LIST :{TINY_FONT}{ORANGE}{RAW_STRING}.
|
||||||
|
STR_DEPARTURES_CALLING_AT_LIST_LARGE :{ORANGE}{RAW_STRING}.
|
||||||
|
STR_DEPARTURES_CALLING_AT_LIST_SMART_TERMINUS :{TINY_FONT}{ORANGE}{RAW_STRING}. This service continues to {STATION}.
|
||||||
|
STR_DEPARTURES_CALLING_AT_LIST_SMART_TERMINUS_LARGE :{ORANGE}{RAW_STRING}. This service continues to {STATION}.
|
||||||
|
|
||||||
|
STR_DEPARTURES_TYPE_TRAIN :{ORANGE}{TRAIN}
|
||||||
|
STR_DEPARTURES_TYPE_TRAIN_SILVER :{SILVER}{TRAIN}
|
||||||
|
STR_DEPARTURES_TYPE_BUS :{ORANGE}{BUS}
|
||||||
|
STR_DEPARTURES_TYPE_BUS_SILVER :{SILVER}{BUS}
|
||||||
|
STR_DEPARTURES_TYPE_LORRY :{ORANGE}{LORRY}
|
||||||
|
STR_DEPARTURES_TYPE_LORRY_SILVER :{SILVER}{LORRY}
|
||||||
|
STR_DEPARTURES_TYPE_PLANE :{ORANGE}{PLANE}
|
||||||
|
STR_DEPARTURES_TYPE_PLANE_SILVER :{SILVER}{PLANE}
|
||||||
|
STR_DEPARTURES_TYPE_SHIP :{ORANGE}{SHIP}
|
||||||
|
STR_DEPARTURES_TYPE_SHIP_SILVER :{SILVER}{SHIP}
|
||||||
|
|
||||||
|
STR_DEPARTURES_STATION_NONE :
|
||||||
|
STR_DEPARTURES_STATION_PORT :{ORANGE} {SHIP}
|
||||||
|
STR_DEPARTURES_STATION_AIRPORT :{ORANGE} {PLANE}
|
||||||
|
STR_DEPARTURES_STATION_PORTAIRPORT :{ORANGE} {SHIP} {PLANE}
|
||||||
|
|
||||||
|
############ possible statuses start
|
||||||
|
STR_DEPARTURES_ON_TIME :{GREEN}On time
|
||||||
|
STR_DEPARTURES_ARRIVED :{GREEN}Arrived
|
||||||
|
STR_DEPARTURES_DELAYED :{YELLOW}Delayed
|
||||||
|
STR_DEPARTURES_EXPECTED :{YELLOW}Expt {DATE_WALLCLOCK_TINY}
|
||||||
|
STR_DEPARTURES_CANCELLED :{RED}Cancelled
|
||||||
|
|
||||||
|
############ config settings
|
||||||
|
STR_CONFIG_SETTING_DEPARTUREBOARDS :{ORANGE}Departure boards
|
||||||
|
STR_CONFIG_MAX_DEPARTURES :Show at most {STRING2} departures at each station
|
||||||
|
STR_CONFIG_MAX_DEPARTURES_HELPTEXT :The maximum number of departures to show on a departure board
|
||||||
|
STR_CONFIG_MAX_DEPARTURE_TIME :Show departures at most {STRING2} days in advance
|
||||||
|
STR_CONFIG_MAX_DEPARTURE_TIME_HELPTEXT :How far in advance to show departures, in days
|
||||||
|
STR_CONFIG_DEPARTURE_CALC_FREQUENCY :Calculate departures every {STRING2} ticks
|
||||||
|
STR_CONFIG_DEPARTURE_CALC_FREQUENCY_HELPTEXT :How frequently to refresh a list of departures, in ticks
|
||||||
|
STR_CONFIG_DEPARTURE_VEHICLE_NAME :Show vehicle name with departures: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_VEHICLE_NAME_HELPTEXT :Whether to show vehicle names next to their departures
|
||||||
|
STR_CONFIG_DEPARTURE_GROUP_NAME :Show group name with departures: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_GROUP_NAME_HELPTEXT :Whether to show names of groups that a vehicle belongs to next to its departures
|
||||||
|
STR_CONFIG_DEPARTURE_COMPANY_NAME :Show company name with departures: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_COMPANY_NAME_HELPTEXT :Whether to show a company's name next to its vehicles' departures
|
||||||
|
STR_CONFIG_DEPARTURE_VEHICLE_TYPE :Show vehicle type icon with departures: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_VEHICLE_TYPE_HELPTEXT :Whether to show a vehicle's type as an icon next to its departures
|
||||||
|
STR_CONFIG_DEPARTURE_VEHICLE_COLOR :Show vehicle type icon in silver: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_VEHICLE_COLOR_HELPTEXT :Whether to show vehicle type icons in silver
|
||||||
|
STR_CONFIG_DEPARTURE_LARGER_FONT :Use larger font for stations called at on departure boards: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_LARGER_FONT_HELPTEXT :Whether to use a larger font for lists of stations called at
|
||||||
|
STR_CONFIG_DEPARTURE_DESTINATION_TYPE :Show icons for destinations that are docks or airports: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_DESTINATION_TYPE_HELPTEXT :Whether to show icons next to destinations that are docks or airports
|
||||||
|
STR_CONFIG_DEPARTURE_SHOW_BOTH :Show arrival and departure times on the same line: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_SHOW_BOTH_HELPTEXT :Whether to show both arrival and departure times next to departures
|
||||||
|
STR_CONFIG_DEPARTURE_ONLY_PASSENGERS :Only show departures for vehicles that can carry passengers: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_ONLY_PASSENGERS_HELPTEXT :Whether to only show departures of vehicles that can carry passengers
|
||||||
|
STR_CONFIG_DEPARTURE_SMART_TERMINUS :Don't show termini that can be reached sooner on a later vehicle: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_SMART_TERMINUS_HELPTEXT :Whether to show termini that can be reached sooner on another vehicle that departs later
|
||||||
|
STR_CONFIG_DEPARTURE_CONDITIONALS :Handle conditional order jumps by: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_CONDITIONALS_HELPTEXT :How conditional orders should be dealt with when calculating departures
|
||||||
|
STR_CONFIG_DEPARTURE_CONDITIONALS_1 :giving up
|
||||||
|
STR_CONFIG_DEPARTURE_CONDITIONALS_2 :assuming they will be taken
|
||||||
|
STR_CONFIG_DEPARTURE_CONDITIONALS_3 :assuming they will not be taken
|
||||||
|
STR_CONFIG_DEPARTURE_SHOW_ALL_STOPS :Show all stations called at regardless of loading/unloading: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_SHOW_ALL_STOPS_HELPTEXT :Whether stations that a vehicle only loads from will be shown in the calling at list
|
||||||
|
STR_CONFIG_DEPARTURE_MERGE_IDENTICAL :Merge identical departures: {STRING2}
|
||||||
|
STR_CONFIG_DEPARTURE_MERGE_IDENTICAL_HELPTEXT :Whether identical departures should be merged into a single departure
|
||||||
|
|
||||||
# Waypoint/buoy view window
|
# Waypoint/buoy view window
|
||||||
STR_WAYPOINT_VIEW_CAPTION :{WHITE}{WAYPOINT}
|
STR_WAYPOINT_VIEW_CAPTION :{WHITE}{WAYPOINT}
|
||||||
STR_WAYPOINT_VIEW_CENTER_TOOLTIP :{BLACK}Centre main view on waypoint location. Ctrl+Click opens a new viewport on waypoint location
|
STR_WAYPOINT_VIEW_CENTER_TOOLTIP :{BLACK}Centre main view on waypoint location. Ctrl+Click opens a new viewport on waypoint location
|
||||||
@@ -3909,6 +4020,7 @@ STR_TIMETABLE_STAY_FOR :and stay for {S
|
|||||||
STR_TIMETABLE_AND_TRAVEL_FOR :and travel for {STRING1}
|
STR_TIMETABLE_AND_TRAVEL_FOR :and travel for {STRING1}
|
||||||
STR_TIMETABLE_DAYS :{COMMA}{NBSP}day{P "" s}
|
STR_TIMETABLE_DAYS :{COMMA}{NBSP}day{P "" s}
|
||||||
STR_TIMETABLE_TICKS :{COMMA}{NBSP}tick{P "" s}
|
STR_TIMETABLE_TICKS :{COMMA}{NBSP}tick{P "" s}
|
||||||
|
STR_TIMETABLE_MINUTES :{COMMA}{NBSP}minute{P "" s}
|
||||||
|
|
||||||
STR_TIMETABLE_TOTAL_TIME :{BLACK}This timetable will take {STRING1} to complete
|
STR_TIMETABLE_TOTAL_TIME :{BLACK}This timetable will take {STRING1} to complete
|
||||||
STR_TIMETABLE_TOTAL_TIME_INCOMPLETE :{BLACK}This timetable will take at least {STRING1} to complete (not all timetabled)
|
STR_TIMETABLE_TOTAL_TIME_INCOMPLETE :{BLACK}This timetable will take at least {STRING1} to complete (not all timetabled)
|
||||||
@@ -3955,6 +4067,8 @@ STR_DATE_SET_DATE_TOOLTIP :{BLACK}Use the
|
|||||||
STR_DATE_DAY_TOOLTIP :{BLACK}Select day
|
STR_DATE_DAY_TOOLTIP :{BLACK}Select day
|
||||||
STR_DATE_MONTH_TOOLTIP :{BLACK}Select month
|
STR_DATE_MONTH_TOOLTIP :{BLACK}Select month
|
||||||
STR_DATE_YEAR_TOOLTIP :{BLACK}Select year
|
STR_DATE_YEAR_TOOLTIP :{BLACK}Select year
|
||||||
|
STR_DATE_MINUTES_DAY_TOOLTIP :{BLACK}Select minute
|
||||||
|
STR_DATE_MINUTES_MONTH_TOOLTIP :{BLACK}Select hour
|
||||||
|
|
||||||
|
|
||||||
# AI debug window
|
# AI debug window
|
||||||
@@ -4858,6 +4972,11 @@ STR_FORMAT_DATE_SHORT :{STRING} {NUM}
|
|||||||
STR_FORMAT_DATE_LONG :{STRING} {STRING} {NUM}
|
STR_FORMAT_DATE_LONG :{STRING} {STRING} {NUM}
|
||||||
STR_FORMAT_DATE_ISO :{2:NUM}-{1:RAW_STRING}-{0:RAW_STRING}
|
STR_FORMAT_DATE_ISO :{2:NUM}-{1:RAW_STRING}-{0:RAW_STRING}
|
||||||
|
|
||||||
|
STR_FORMAT_DATE_MINUTES :{0:RAW_STRING}:{1:RAW_STRING}
|
||||||
|
STR_FORMAT_DATE_MINUTES_WITH_Y :{0:RAW_STRING}:{1:RAW_STRING} / {2:NUM}
|
||||||
|
STR_FORMAT_DATE_MINUTES_WITH_YM :{0:RAW_STRING}:{1:RAW_STRING} / {2:DATE_SHORT}
|
||||||
|
STR_FORMAT_DATE_MINUTES_WITH_YMD :{0:RAW_STRING}:{1:RAW_STRING} / {2:DATE_LONG}
|
||||||
|
|
||||||
STR_FORMAT_BUOY_NAME :{TOWN} Buoy
|
STR_FORMAT_BUOY_NAME :{TOWN} Buoy
|
||||||
STR_FORMAT_BUOY_NAME_SERIAL :{TOWN} Buoy #{COMMA}
|
STR_FORMAT_BUOY_NAME_SERIAL :{TOWN} Buoy #{COMMA}
|
||||||
STR_FORMAT_COMPANY_NUM :(Company {COMMA})
|
STR_FORMAT_COMPANY_NUM :(Company {COMMA})
|
||||||
@@ -4922,6 +5041,10 @@ STR_JUST_DATE_TINY :{DATE_TINY}
|
|||||||
STR_JUST_DATE_SHORT :{DATE_SHORT}
|
STR_JUST_DATE_SHORT :{DATE_SHORT}
|
||||||
STR_JUST_DATE_LONG :{DATE_LONG}
|
STR_JUST_DATE_LONG :{DATE_LONG}
|
||||||
STR_JUST_DATE_ISO :{DATE_ISO}
|
STR_JUST_DATE_ISO :{DATE_ISO}
|
||||||
|
STR_JUST_DATE_WALLCLOCK_TINY :{DATE_WALLCLOCK_TINY}
|
||||||
|
STR_JUST_DATE_WALLCLOCK_SHORT :{DATE_WALLCLOCK_SHORT}
|
||||||
|
STR_JUST_DATE_WALLCLOCK_LONG :{DATE_WALLCLOCK_LONG}
|
||||||
|
STR_JUST_DATE_WALLCLOCK_ISO :{DATE_WALLCLOCK_ISO}
|
||||||
STR_JUST_STRING :{STRING}
|
STR_JUST_STRING :{STRING}
|
||||||
STR_JUST_STRING_STRING :{STRING}{STRING}
|
STR_JUST_STRING_STRING :{STRING}{STRING}
|
||||||
STR_JUST_RAW_STRING :{RAW_STRING}
|
STR_JUST_RAW_STRING :{RAW_STRING}
|
||||||
@@ -4938,6 +5061,8 @@ STR_TINY_BLACK_DECIMAL :{TINY_FONT}{BLA
|
|||||||
STR_COMPANY_MONEY :{WHITE}{CURRENCY_LONG}
|
STR_COMPANY_MONEY :{WHITE}{CURRENCY_LONG}
|
||||||
STR_BLACK_DATE_LONG :{BLACK}{DATE_LONG}
|
STR_BLACK_DATE_LONG :{BLACK}{DATE_LONG}
|
||||||
STR_WHITE_DATE_LONG :{WHITE}{DATE_LONG}
|
STR_WHITE_DATE_LONG :{WHITE}{DATE_LONG}
|
||||||
|
STR_WHITE_DATE_WALLCLOCK_LONG :{WHITE}{DATE_WALLCLOCK_LONG}
|
||||||
|
STR_WHITE_DATE_WALLCLOCK_SHORT :{WHITE}{DATE_WALLCLOCK_SHORT}
|
||||||
STR_SHORT_DATE :{WHITE}{DATE_TINY}
|
STR_SHORT_DATE :{WHITE}{DATE_TINY}
|
||||||
STR_DATE_LONG_SMALL :{TINY_FONT}{BLACK}{DATE_LONG}
|
STR_DATE_LONG_SMALL :{TINY_FONT}{BLACK}{DATE_LONG}
|
||||||
STR_TINY_GROUP :{TINY_FONT}{GROUP}
|
STR_TINY_GROUP :{TINY_FONT}{GROUP}
|
||||||
|
@@ -1536,6 +1536,35 @@ static SettingsContainer &GetSettingsTree()
|
|||||||
construction->Add(new SettingEntry("gui.disable_unsuitable_building"));
|
construction->Add(new SettingEntry("gui.disable_unsuitable_building"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsPage *departureboards = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_DEPARTUREBOARDS));
|
||||||
|
{
|
||||||
|
departureboards->Add(new SettingEntry("gui.max_departures"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.max_departure_time"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_calc_frequency"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_show_vehicle"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_show_group"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_show_company"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_show_vehicle_type"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_show_vehicle_color"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_larger_font"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_destination_type"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_show_both"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_only_passengers"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_smart_terminus"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_conditionals"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_show_all_stops"));
|
||||||
|
departureboards->Add(new SettingEntry("gui.departure_merge_identical"));
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsPage *wallclock = interface->Add(new SettingsPage(STR_CONFIG_SETTING_INTERFACE_WALLCLOCK));
|
||||||
|
{
|
||||||
|
wallclock->Add(new SettingEntry("gui.time_in_minutes"));
|
||||||
|
wallclock->Add(new SettingEntry("gui.timetable_start_text_entry"));
|
||||||
|
wallclock->Add(new SettingEntry("gui.ticks_per_minute"));
|
||||||
|
wallclock->Add(new SettingEntry("gui.date_with_time"));
|
||||||
|
wallclock->Add(new SettingEntry("gui.clock_offset"));
|
||||||
|
}
|
||||||
|
|
||||||
interface->Add(new SettingEntry("gui.autosave"));
|
interface->Add(new SettingEntry("gui.autosave"));
|
||||||
interface->Add(new SettingEntry("gui.toolbar_pos"));
|
interface->Add(new SettingEntry("gui.toolbar_pos"));
|
||||||
interface->Add(new SettingEntry("gui.statusbar_pos"));
|
interface->Add(new SettingEntry("gui.statusbar_pos"));
|
||||||
|
@@ -112,11 +112,32 @@ struct GUISettings {
|
|||||||
uint8 scrollwheel_scrolling; ///< scrolling using the scroll wheel?
|
uint8 scrollwheel_scrolling; ///< scrolling using the scroll wheel?
|
||||||
uint8 scrollwheel_multiplier; ///< how much 'wheel' per incoming event from the OS?
|
uint8 scrollwheel_multiplier; ///< how much 'wheel' per incoming event from the OS?
|
||||||
bool timetable_arrival_departure; ///< show arrivals and departures in vehicle timetables
|
bool timetable_arrival_departure; ///< show arrivals and departures in vehicle timetables
|
||||||
|
uint8 max_departures; ///< maximum number of departures to show per station
|
||||||
|
uint16 max_departure_time; ///< maximum time in advance to show departures
|
||||||
|
uint16 departure_calc_frequency; ///< how often to calculate departures (in ticks)
|
||||||
|
bool departure_show_vehicle; ///< whether to show vehicle names with departures
|
||||||
|
bool departure_show_group; ///< whether to show group names with departures
|
||||||
|
bool departure_show_company; ///< whether to show company names with departures
|
||||||
|
bool departure_show_vehicle_type; ///< whether to show vehicle type icons with departures
|
||||||
|
bool departure_show_vehicle_color; ///< whether to show vehicle type icons in silver instead of orange
|
||||||
|
bool departure_larger_font; ///< whether to show the calling at list in a larger font
|
||||||
|
bool departure_destination_type; ///< whether to show destination types for ports and airports
|
||||||
|
bool departure_show_both; ///< whether to show departure and arrival times on the same line
|
||||||
|
bool departure_only_passengers; ///< whether to only show passenger services
|
||||||
|
bool departure_smart_terminus; ///< whether to only show passenger services
|
||||||
|
uint8 departure_conditionals; ///< how to handle conditional orders
|
||||||
|
bool departure_show_all_stops; ///< whether to show stops regardless of loading/unloading done at them
|
||||||
|
bool departure_merge_identical; ///< whether to merge identical departures
|
||||||
bool left_mouse_btn_scrolling; ///< left mouse button scroll
|
bool left_mouse_btn_scrolling; ///< left mouse button scroll
|
||||||
bool pause_on_newgame; ///< whether to start new games paused or not
|
bool pause_on_newgame; ///< whether to start new games paused or not
|
||||||
bool enable_signal_gui; ///< show the signal GUI when the signal button is pressed
|
bool enable_signal_gui; ///< show the signal GUI when the signal button is pressed
|
||||||
Year coloured_news_year; ///< when does newspaper become coloured?
|
Year coloured_news_year; ///< when does newspaper become coloured?
|
||||||
bool timetable_in_ticks; ///< whether to show the timetable in ticks rather than days
|
bool timetable_in_ticks; ///< whether to show the timetable in ticks rather than days
|
||||||
|
bool time_in_minutes; ///< whether to use the hh:mm conversion when printing dates
|
||||||
|
bool timetable_start_text_entry; ///< whether to enter timetable start times as text (hhmm format)
|
||||||
|
uint8 ticks_per_minute; ///< how many ticks per minute
|
||||||
|
uint8 date_with_time; ///< whether to show the month and year with the time
|
||||||
|
uint16 clock_offset; ///< clock offset in minutes
|
||||||
bool quick_goto; ///< Allow quick access to 'goto button' in vehicle orders window
|
bool quick_goto; ///< Allow quick access to 'goto button' in vehicle orders window
|
||||||
bool auto_euro; ///< automatically switch to euro in 2002
|
bool auto_euro; ///< automatically switch to euro in 2002
|
||||||
byte drag_signals_density; ///< many signals density
|
byte drag_signals_density; ///< many signals density
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "town.h"
|
#include "town.h"
|
||||||
#include "linkgraph/linkgraph.h"
|
#include "linkgraph/linkgraph.h"
|
||||||
#include "zoom_func.h"
|
#include "zoom_func.h"
|
||||||
|
#include "departures_gui.h"
|
||||||
|
|
||||||
#include "widgets/station_widget.h"
|
#include "widgets/station_widget.h"
|
||||||
|
|
||||||
@@ -783,6 +784,8 @@ static const NWidgetPart _nested_station_view_widgets[] = {
|
|||||||
SetDataTip(STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP),
|
SetDataTip(STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SV_RENAME), SetMinimalSize(45, 12), SetResize(1, 0), SetFill(1, 1),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SV_RENAME), SetMinimalSize(45, 12), SetResize(1, 0), SetFill(1, 1),
|
||||||
SetDataTip(STR_BUTTON_RENAME, STR_STATION_VIEW_RENAME_TOOLTIP),
|
SetDataTip(STR_BUTTON_RENAME, STR_STATION_VIEW_RENAME_TOOLTIP),
|
||||||
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SV_DEPARTURES), SetMinimalSize(80, 12), SetResize(1, 0), SetFill(1, 1),
|
||||||
|
SetDataTip(STR_STATION_VIEW_DEPARTURES_BUTTON, STR_STATION_VIEW_DEPARTURES_TOOLTIP),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SV_CLOSE_AIRPORT), SetMinimalSize(45, 12), SetResize(1, 0), SetFill(1, 1),
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SV_CLOSE_AIRPORT), SetMinimalSize(45, 12), SetResize(1, 0), SetFill(1, 1),
|
||||||
SetDataTip(STR_STATION_VIEW_CLOSE_AIRPORT, STR_STATION_VIEW_CLOSE_AIRPORT_TOOLTIP),
|
SetDataTip(STR_STATION_VIEW_CLOSE_AIRPORT, STR_STATION_VIEW_CLOSE_AIRPORT_TOOLTIP),
|
||||||
@@ -1949,6 +1952,11 @@ struct StationViewWindow : public Window {
|
|||||||
this->LowerWidget(WID_SV_SORT_ORDER);
|
this->LowerWidget(WID_SV_SORT_ORDER);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WID_SV_DEPARTURES: {
|
||||||
|
ShowStationDepartures((StationID)this->window_number);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -139,8 +139,8 @@ struct StatusBarWindow : Window {
|
|||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_S_LEFT:
|
case WID_S_LEFT:
|
||||||
/* Draw the date */
|
/* Draw the date */
|
||||||
SetDParam(0, _date);
|
SetDParam(0, ((DateTicks)_date * DAY_TICKS) + _date_fract);
|
||||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, STR_WHITE_DATE_LONG, TC_FROMSTRING, SA_HOR_CENTER);
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, STR_WHITE_DATE_WALLCLOCK_LONG, TC_FROMSTRING, SA_HOR_CENTER);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_S_RIGHT: {
|
case WID_S_RIGHT: {
|
||||||
@@ -221,6 +221,10 @@ struct StatusBarWindow : Window {
|
|||||||
{
|
{
|
||||||
if (_pause_mode != PM_UNPAUSED) return;
|
if (_pause_mode != PM_UNPAUSED) return;
|
||||||
|
|
||||||
|
if (_settings_client.gui.time_in_minutes) {
|
||||||
|
this->SetWidgetDirty(WID_S_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
if (this->ticker_scroll < TICKER_STOP) { // Scrolling text
|
if (this->ticker_scroll < TICKER_STOP) { // Scrolling text
|
||||||
this->ticker_scroll += COUNTER_STEP;
|
this->ticker_scroll += COUNTER_STEP;
|
||||||
this->SetWidgetDirty(WID_S_MIDDLE);
|
this->SetWidgetDirty(WID_S_MIDDLE);
|
||||||
@@ -237,7 +241,7 @@ struct StatusBarWindow : Window {
|
|||||||
|
|
||||||
static const NWidgetPart _nested_main_status_widgets[] = {
|
static const NWidgetPart _nested_main_status_widgets[] = {
|
||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_S_LEFT), SetMinimalSize(140, 12), EndContainer(),
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_S_LEFT), SetMinimalSize(160, 12), EndContainer(),
|
||||||
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_S_MIDDLE), SetMinimalSize(40, 12), SetDataTip(0x0, STR_STATUSBAR_TOOLTIP_SHOW_LAST_NEWS), SetResize(1, 0),
|
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_S_MIDDLE), SetMinimalSize(40, 12), SetDataTip(0x0, STR_STATUSBAR_TOOLTIP_SHOW_LAST_NEWS), SetResize(1, 0),
|
||||||
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_S_RIGHT), SetMinimalSize(140, 12),
|
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_S_RIGHT), SetMinimalSize(140, 12),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
@@ -404,6 +404,29 @@ static char *FormatBytes(char *buff, int64 number, const char *last)
|
|||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *FormatWallClockString(char *buff, DateTicks ticks, const char *last, bool show_date, uint case_index)
|
||||||
|
{
|
||||||
|
Minutes minutes = ticks / _settings_client.gui.ticks_per_minute + _settings_client.gui.clock_offset;
|
||||||
|
char hour[3], minute[3];
|
||||||
|
seprintf(hour, lastof(hour), "%02i", MINUTES_HOUR(minutes) );
|
||||||
|
seprintf(minute, lastof(minute), "%02i", MINUTES_MINUTE(minutes));
|
||||||
|
if (show_date) {
|
||||||
|
int64 args[3] = { (int64)hour, (int64)minute, (int64)ticks / DAY_TICKS };
|
||||||
|
if (_settings_client.gui.date_with_time == 1) {
|
||||||
|
YearMonthDay ymd;
|
||||||
|
ConvertDateToYMD(args[2], &ymd);
|
||||||
|
args[2] = ymd.year;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringParameters tmp_params(args);
|
||||||
|
return FormatString(buff, GetStringPtr(STR_FORMAT_DATE_MINUTES + _settings_client.gui.date_with_time), &tmp_params, last, case_index);
|
||||||
|
} else {
|
||||||
|
int64 args[2] = { (int64)hour, (int64)minute };
|
||||||
|
StringParameters tmp_params(args);
|
||||||
|
return FormatString(buff, GetStringPtr(STR_FORMAT_DATE_MINUTES), &tmp_params, last, case_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static char *FormatYmdString(char *buff, Date date, const char *last, uint case_index)
|
static char *FormatYmdString(char *buff, Date date, const char *last, uint case_index)
|
||||||
{
|
{
|
||||||
YearMonthDay ymd;
|
YearMonthDay ymd;
|
||||||
@@ -1201,6 +1224,42 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
|||||||
next_substr_case_index = 0;
|
next_substr_case_index = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SCC_DATE_WALLCLOCK_LONG: { // {DATE_WALLCLOCK_LONG}
|
||||||
|
if (_settings_client.gui.time_in_minutes) {
|
||||||
|
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_LONG), last, _settings_client.gui.date_with_time, next_substr_case_index);
|
||||||
|
} else {
|
||||||
|
buff = FormatYmdString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_LONG) / DAY_TICKS, last, next_substr_case_index);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SCC_DATE_WALLCLOCK_SHORT: { // {DATE_WALLCLOCK_SHORT}
|
||||||
|
if (_settings_client.gui.time_in_minutes) {
|
||||||
|
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_SHORT), last, _settings_client.gui.date_with_time, next_substr_case_index);
|
||||||
|
} else {
|
||||||
|
buff = FormatYmdString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_SHORT) / DAY_TICKS, last, next_substr_case_index);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SCC_DATE_WALLCLOCK_TINY: { // {DATE_WALLCLOCK_TINY}
|
||||||
|
if (_settings_client.gui.time_in_minutes) {
|
||||||
|
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_TINY), last, false, next_substr_case_index);
|
||||||
|
} else {
|
||||||
|
buff = FormatTinyOrISODate(buff, args->GetInt64(SCC_DATE_WALLCLOCK_TINY) / DAY_TICKS, STR_FORMAT_DATE_TINY, last);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SCC_DATE_WALLCLOCK_ISO: { // {DATE_WALLCLOCK_ISO}
|
||||||
|
if (_settings_client.gui.time_in_minutes) {
|
||||||
|
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_ISO), last, false, next_substr_case_index);
|
||||||
|
} else {
|
||||||
|
buff = FormatTinyOrISODate(buff, args->GetInt64(SCC_DATE_WALLCLOCK_ISO) / DAY_TICKS, STR_FORMAT_DATE_ISO, last);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case SCC_DATE_ISO: // {DATE_ISO}
|
case SCC_DATE_ISO: // {DATE_ISO}
|
||||||
buff = FormatTinyOrISODate(buff, args->GetInt32(), STR_FORMAT_DATE_ISO, last);
|
buff = FormatTinyOrISODate(buff, args->GetInt32(), STR_FORMAT_DATE_ISO, last);
|
||||||
break;
|
break;
|
||||||
|
@@ -66,6 +66,10 @@ enum StringControlCode {
|
|||||||
SCC_DATE_SHORT,
|
SCC_DATE_SHORT,
|
||||||
SCC_DATE_LONG,
|
SCC_DATE_LONG,
|
||||||
SCC_DATE_ISO,
|
SCC_DATE_ISO,
|
||||||
|
SCC_DATE_WALLCLOCK_TINY,
|
||||||
|
SCC_DATE_WALLCLOCK_SHORT,
|
||||||
|
SCC_DATE_WALLCLOCK_LONG,
|
||||||
|
SCC_DATE_WALLCLOCK_ISO,
|
||||||
|
|
||||||
/* Must be consecutive */
|
/* Must be consecutive */
|
||||||
SCC_STRING1,
|
SCC_STRING1,
|
||||||
|
@@ -2814,6 +2814,59 @@ strhelp = STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT
|
|||||||
proc = InvalidateVehTimetableWindow
|
proc = InvalidateVehTimetableWindow
|
||||||
cat = SC_EXPERT
|
cat = SC_EXPERT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.time_in_minutes
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_SETTING_TIME_IN_MINUTES
|
||||||
|
strhelp = STR_CONFIG_SETTING_TIME_IN_MINUTES_HELPTEXT
|
||||||
|
proc = InvalidateVehTimetableWindow
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.timetable_start_text_entry
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY
|
||||||
|
strhelp = STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_VAR]
|
||||||
|
var = gui.ticks_per_minute
|
||||||
|
type = SLE_UINT8
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
strval = STR_JUST_INT
|
||||||
|
def = 74
|
||||||
|
min = 1
|
||||||
|
max = 255
|
||||||
|
str = STR_CONFIG_SETTING_TICKS_PER_MINUTE
|
||||||
|
strhelp = STR_CONFIG_SETTING_TICKS_PER_MINUTE_HELPTEXT
|
||||||
|
proc = RedrawScreen
|
||||||
|
|
||||||
|
[SDTC_VAR]
|
||||||
|
var = gui.date_with_time
|
||||||
|
type = SLE_UINT8
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
guiflags = SGF_MULTISTRING
|
||||||
|
def = 0
|
||||||
|
min = 0
|
||||||
|
max = 3
|
||||||
|
str = STR_CONFIG_SETTING_DATE_WITH_TIME
|
||||||
|
strval = STR_CONFIG_SETTING_DATE_WITH_TIME_NONE
|
||||||
|
strhelp = STR_CONFIG_SETTING_DATE_WITH_TIME_HELPTEXT
|
||||||
|
proc = RedrawScreen
|
||||||
|
|
||||||
|
[SDTC_VAR]
|
||||||
|
var = gui.clock_offset
|
||||||
|
type = SLE_UINT16
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
strval = STR_JUST_INT
|
||||||
|
def = 0
|
||||||
|
min = 0
|
||||||
|
max = 1439
|
||||||
|
interval = 60
|
||||||
|
str = STR_CONFIG_SETTING_CLOCK_OFFSET
|
||||||
|
strhelp = STR_CONFIG_SETTING_CLOCK_OFFSET_HELPTEXT
|
||||||
|
proc = RedrawScreen
|
||||||
|
|
||||||
[SDTC_BOOL]
|
[SDTC_BOOL]
|
||||||
var = gui.timetable_arrival_departure
|
var = gui.timetable_arrival_departure
|
||||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
@@ -2822,6 +2875,139 @@ str = STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE
|
|||||||
strhelp = STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT
|
strhelp = STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT
|
||||||
proc = InvalidateVehTimetableWindow
|
proc = InvalidateVehTimetableWindow
|
||||||
|
|
||||||
|
[SDTC_VAR]
|
||||||
|
var = gui.max_departures
|
||||||
|
type = SLE_UINT8
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
strval = STR_JUST_INT
|
||||||
|
def = 10
|
||||||
|
min = 1
|
||||||
|
max = 30
|
||||||
|
interval = 1
|
||||||
|
str = STR_CONFIG_MAX_DEPARTURES
|
||||||
|
strhelp = STR_CONFIG_MAX_DEPARTURES_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_VAR]
|
||||||
|
var = gui.max_departure_time
|
||||||
|
type = SLE_UINT16
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
strval = STR_JUST_INT
|
||||||
|
def = 120
|
||||||
|
min = 30
|
||||||
|
max = 240
|
||||||
|
interval = 1
|
||||||
|
str = STR_CONFIG_MAX_DEPARTURE_TIME
|
||||||
|
strhelp = STR_CONFIG_MAX_DEPARTURE_TIME_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_VAR]
|
||||||
|
var = gui.departure_calc_frequency
|
||||||
|
type = SLE_UINT16
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
strval = STR_JUST_INT
|
||||||
|
def = 10
|
||||||
|
min = 1
|
||||||
|
max = 120
|
||||||
|
interval = 1
|
||||||
|
str = STR_CONFIG_DEPARTURE_CALC_FREQUENCY
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_CALC_FREQUENCY_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_show_vehicle
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_VEHICLE_NAME
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_VEHICLE_NAME_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_show_group
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_GROUP_NAME
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_GROUP_NAME_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_show_company
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_COMPANY_NAME
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_COMPANY_NAME_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_show_vehicle_type
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_VEHICLE_TYPE
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_VEHICLE_TYPE_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_show_vehicle_color
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_VEHICLE_COLOR
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_VEHICLE_COLOR_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_larger_font
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_LARGER_FONT
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_LARGER_FONT_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_destination_type
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_DESTINATION_TYPE
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_DESTINATION_TYPE_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_show_both
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_SHOW_BOTH
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_SHOW_BOTH_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_only_passengers
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_ONLY_PASSENGERS
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_ONLY_PASSENGERS_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_smart_terminus
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_SMART_TERMINUS
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_SMART_TERMINUS_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_show_all_stops
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_SHOW_ALL_STOPS
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_SHOW_ALL_STOPS_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_BOOL]
|
||||||
|
var = gui.departure_merge_identical
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
def = false
|
||||||
|
str = STR_CONFIG_DEPARTURE_MERGE_IDENTICAL
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_MERGE_IDENTICAL_HELPTEXT
|
||||||
|
|
||||||
|
[SDTC_VAR]
|
||||||
|
var = gui.departure_conditionals
|
||||||
|
type = SLE_UINT8
|
||||||
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
guiflags = SGF_MULTISTRING
|
||||||
|
def = 0
|
||||||
|
min = 0
|
||||||
|
max = 2
|
||||||
|
str = STR_CONFIG_DEPARTURE_CONDITIONALS
|
||||||
|
strval = STR_CONFIG_DEPARTURE_CONDITIONALS_1
|
||||||
|
strhelp = STR_CONFIG_DEPARTURE_CONDITIONALS_HELPTEXT
|
||||||
|
proc = RedrawScreen
|
||||||
|
|
||||||
[SDTC_BOOL]
|
[SDTC_BOOL]
|
||||||
var = gui.quick_goto
|
var = gui.quick_goto
|
||||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||||
|
@@ -90,6 +90,10 @@ static const CmdStruct _cmd_structs[] = {
|
|||||||
{"DATE_SHORT", EmitSingleChar, SCC_DATE_SHORT, 1, C_CASE},
|
{"DATE_SHORT", EmitSingleChar, SCC_DATE_SHORT, 1, C_CASE},
|
||||||
{"DATE_LONG", EmitSingleChar, SCC_DATE_LONG, 1, C_CASE},
|
{"DATE_LONG", EmitSingleChar, SCC_DATE_LONG, 1, C_CASE},
|
||||||
{"DATE_ISO", EmitSingleChar, SCC_DATE_ISO, 1, C_NONE},
|
{"DATE_ISO", EmitSingleChar, SCC_DATE_ISO, 1, C_NONE},
|
||||||
|
{"DATE_WALLCLOCK_TINY", EmitSingleChar, SCC_DATE_WALLCLOCK_TINY, 1, C_NONE},
|
||||||
|
{"DATE_WALLCLOCK_SHORT", EmitSingleChar, SCC_DATE_WALLCLOCK_SHORT, 1, C_NONE},
|
||||||
|
{"DATE_WALLCLOCK_LONG", EmitSingleChar, SCC_DATE_WALLCLOCK_LONG, 1, C_NONE},
|
||||||
|
{"DATE_WALLCLOCK_ISO", EmitSingleChar, SCC_DATE_WALLCLOCK_ISO, 1, C_NONE},
|
||||||
|
|
||||||
{"STRING", EmitSingleChar, SCC_STRING, 1, C_CASE | C_GENDER},
|
{"STRING", EmitSingleChar, SCC_STRING, 1, C_CASE | C_GENDER},
|
||||||
{"RAW_STRING", EmitSingleChar, SCC_RAW_STRING_POINTER, 1, C_NONE | C_GENDER},
|
{"RAW_STRING", EmitSingleChar, SCC_RAW_STRING_POINTER, 1, C_NONE | C_GENDER},
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
#include "date_type.h"
|
#include "date_type.h"
|
||||||
#include "vehicle_type.h"
|
#include "vehicle_type.h"
|
||||||
|
|
||||||
|
#define WALLCLOCK_NETWORK_COMPATIBLE 0 ///< Whether wallclock should preserve network compatibility. If so, then timetable start dates cannot be set exactly using minutes.
|
||||||
|
|
||||||
void ShowTimetableWindow(const Vehicle *v);
|
void ShowTimetableWindow(const Vehicle *v);
|
||||||
void UpdateVehicleTimetable(Vehicle *v, bool travelling);
|
void UpdateVehicleTimetable(Vehicle *v, bool travelling);
|
||||||
void SetTimetableParams(int param1, int param2, Ticks ticks);
|
void SetTimetableParams(int param1, int param2, Ticks ticks);
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include "vehicle_base.h"
|
#include "vehicle_base.h"
|
||||||
#include "cmd_helper.h"
|
#include "cmd_helper.h"
|
||||||
#include "core/sort_func.hpp"
|
#include "core/sort_func.hpp"
|
||||||
|
#include "settings_type.h"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
@@ -257,12 +258,17 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
|||||||
CommandCost ret = CheckOwnership(v->owner);
|
CommandCost ret = CheckOwnership(v->owner);
|
||||||
if (ret.Failed()) return ret;
|
if (ret.Failed()) return ret;
|
||||||
|
|
||||||
|
DateTicks start_date = (Date)p2 / DAY_TICKS;
|
||||||
|
|
||||||
|
#if WALLCLOCK_NETWORK_COMPATIBLE
|
||||||
/* Don't let a timetable start more than 15 years into the future or 1 year in the past. */
|
/* Don't let a timetable start more than 15 years into the future or 1 year in the past. */
|
||||||
Date start_date = (Date)p2;
|
|
||||||
if (start_date < 0 || start_date > MAX_DAY) return CMD_ERROR;
|
if (start_date < 0 || start_date > MAX_DAY) return CMD_ERROR;
|
||||||
if (start_date - _date > 15 * DAYS_IN_LEAP_YEAR) return CMD_ERROR;
|
if (start_date - _date > 15 * DAYS_IN_LEAP_YEAR) return CMD_ERROR;
|
||||||
if (_date - start_date > DAYS_IN_LEAP_YEAR) return CMD_ERROR;
|
if (_date - start_date > DAYS_IN_LEAP_YEAR) return CMD_ERROR;
|
||||||
if (timetable_all && !v->orders.list->IsCompleteTimetable()) return CMD_ERROR;
|
if (timetable_all && !v->orders.list->IsCompleteTimetable()) return CMD_ERROR;
|
||||||
|
#else
|
||||||
|
start_date = ((DateTicks)_date * DAY_TICKS) + _date_fract + (DateTicks)(int32)p2;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
SmallVector<Vehicle *, 8> vehs;
|
SmallVector<Vehicle *, 8> vehs;
|
||||||
@@ -384,7 +390,11 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
|
|||||||
just_started = !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
|
just_started = !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
|
||||||
|
|
||||||
if (v->timetable_start != 0) {
|
if (v->timetable_start != 0) {
|
||||||
|
#if WALLCLOCK_NETWORK_COMPATIBLE
|
||||||
v->lateness_counter = (_date - v->timetable_start) * DAY_TICKS + _date_fract;
|
v->lateness_counter = (_date - v->timetable_start) * DAY_TICKS + _date_fract;
|
||||||
|
#else
|
||||||
|
v->lateness_counter = (_date * DAY_TICKS) + _date_fract - v->timetable_start;
|
||||||
|
#endif
|
||||||
v->timetable_start = 0;
|
v->timetable_start = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,7 +425,7 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
|
|||||||
* the timetable entry like is done for road vehicles/ships.
|
* the timetable entry like is done for road vehicles/ships.
|
||||||
* Thus always make sure at least one tick is used between the
|
* Thus always make sure at least one tick is used between the
|
||||||
* processing of different orders when filling the timetable. */
|
* processing of different orders when filling the timetable. */
|
||||||
uint time_to_set = CeilDiv(max(time_taken, 1U), DAY_TICKS) * DAY_TICKS;
|
uint time_to_set = CeilDiv(max(time_taken, 1U), DATE_UNIT_SIZE) * DATE_UNIT_SIZE;
|
||||||
|
|
||||||
if (travelling && (autofilling || !v->current_order.IsTravelTimetabled())) {
|
if (travelling && (autofilling || !v->current_order.IsTravelTimetabled())) {
|
||||||
ChangeTimetable(v, v->cur_real_order_index, time_to_set, MTF_TRAVEL_TIME, autofilling);
|
ChangeTimetable(v, v->cur_real_order_index, time_to_set, MTF_TRAVEL_TIME, autofilling);
|
||||||
|
@@ -47,11 +47,14 @@ struct TimetableArrivalDeparture {
|
|||||||
void SetTimetableParams(int param1, int param2, Ticks ticks)
|
void SetTimetableParams(int param1, int param2, Ticks ticks)
|
||||||
{
|
{
|
||||||
if (_settings_client.gui.timetable_in_ticks) {
|
if (_settings_client.gui.timetable_in_ticks) {
|
||||||
SetDParam(param1, STR_TIMETABLE_TICKS);
|
|
||||||
SetDParam(param2, ticks);
|
SetDParam(param2, ticks);
|
||||||
|
SetDParam(param1, STR_TIMETABLE_TICKS);
|
||||||
|
} else if (_settings_client.gui.time_in_minutes) {
|
||||||
|
SetDParam(param2, ticks / DATE_UNIT_SIZE);
|
||||||
|
SetDParam(param1, STR_TIMETABLE_MINUTES);
|
||||||
} else {
|
} else {
|
||||||
|
SetDParam(param2, ticks / DATE_UNIT_SIZE);
|
||||||
SetDParam(param1, STR_TIMETABLE_DAYS);
|
SetDParam(param1, STR_TIMETABLE_DAYS);
|
||||||
SetDParam(param2, ticks / DAY_TICKS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,9 +145,13 @@ static void FillTimetableArrivalDepartureTable(const Vehicle *v, VehicleOrderID
|
|||||||
* @param window the window related to the setting of the date
|
* @param window the window related to the setting of the date
|
||||||
* @param date the actually chosen date
|
* @param date the actually chosen date
|
||||||
*/
|
*/
|
||||||
static void ChangeTimetableStartCallback(const Window *w, Date date)
|
static void ChangeTimetableStartCallback(const Window *w, DateTicks date)
|
||||||
{
|
{
|
||||||
DoCommandP(0, w->window_number, date, CMD_SET_TIMETABLE_START | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
#if WALLCLOCK_NETWORK_COMPATIBLE
|
||||||
|
DoCommandP(0, w->window_number, (Date)(date / DAY_TICKS), CMD_SET_TIMETABLE_START | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
||||||
|
#else
|
||||||
|
DoCommandP(0, w->window_number, (Ticks)(date - (((DateTicks)_date * DAY_TICKS) + _date_fract)), CMD_SET_TIMETABLE_START | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -154,6 +161,7 @@ struct TimetableWindow : Window {
|
|||||||
bool show_expected; ///< Whether we show expected arrival or scheduled
|
bool show_expected; ///< Whether we show expected arrival or scheduled
|
||||||
uint deparr_time_width; ///< The width of the departure/arrival time
|
uint deparr_time_width; ///< The width of the departure/arrival time
|
||||||
uint deparr_abbr_width; ///< The width of the departure/arrival abbreviation
|
uint deparr_abbr_width; ///< The width of the departure/arrival abbreviation
|
||||||
|
int clicked_widget; ///< The widget that was clicked (used to determine what to do in OnQueryTextFinished)
|
||||||
Scrollbar *vscroll;
|
Scrollbar *vscroll;
|
||||||
bool query_is_speed_query; ///< The currently open query window is a speed query and not a time query.
|
bool query_is_speed_query; ///< The currently open query window is a speed query and not a time query.
|
||||||
|
|
||||||
@@ -195,6 +203,8 @@ struct TimetableWindow : Window {
|
|||||||
case WID_VT_ARRIVAL_DEPARTURE_PANEL:
|
case WID_VT_ARRIVAL_DEPARTURE_PANEL:
|
||||||
SetDParamMaxValue(0, MAX_YEAR * DAYS_IN_YEAR, 0, FS_SMALL);
|
SetDParamMaxValue(0, MAX_YEAR * DAYS_IN_YEAR, 0, FS_SMALL);
|
||||||
this->deparr_time_width = GetStringBoundingBox(STR_JUST_DATE_TINY).width;
|
this->deparr_time_width = GetStringBoundingBox(STR_JUST_DATE_TINY).width;
|
||||||
|
SetDParamMaxValue(0, _settings_client.gui.time_in_minutes ? 0 : MAX_YEAR * DAYS_IN_YEAR);
|
||||||
|
this->deparr_time_width = GetStringBoundingBox(STR_JUST_DATE_WALLCLOCK_TINY).width + 4;
|
||||||
this->deparr_abbr_width = max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_ABBREVIATION).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_ABBREVIATION).width);
|
this->deparr_abbr_width = max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_ABBREVIATION).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_ABBREVIATION).width);
|
||||||
size->width = WD_FRAMERECT_LEFT + this->deparr_abbr_width + 10 + this->deparr_time_width + WD_FRAMERECT_RIGHT;
|
size->width = WD_FRAMERECT_LEFT + this->deparr_abbr_width + 10 + this->deparr_time_width + WD_FRAMERECT_RIGHT;
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
@@ -433,7 +443,7 @@ struct TimetableWindow : Window {
|
|||||||
|
|
||||||
int y = r.top + WD_FRAMERECT_TOP;
|
int y = r.top + WD_FRAMERECT_TOP;
|
||||||
|
|
||||||
bool show_late = this->show_expected && v->lateness_counter > DAY_TICKS;
|
bool show_late = this->show_expected && v->lateness_counter > DATE_UNIT_SIZE;
|
||||||
Ticks offset = show_late ? 0 : -v->lateness_counter;
|
Ticks offset = show_late ? 0 : -v->lateness_counter;
|
||||||
|
|
||||||
bool rtl = _current_text_dir == TD_RTL;
|
bool rtl = _current_text_dir == TD_RTL;
|
||||||
@@ -450,19 +460,19 @@ struct TimetableWindow : Window {
|
|||||||
if (arr_dep[i / 2].arrival != INVALID_TICKS) {
|
if (arr_dep[i / 2].arrival != INVALID_TICKS) {
|
||||||
DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_ARRIVAL_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
|
DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_ARRIVAL_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
|
||||||
if (this->show_expected && i / 2 == earlyID) {
|
if (this->show_expected && i / 2 == earlyID) {
|
||||||
SetDParam(0, _date + arr_dep[i / 2].arrival / DAY_TICKS);
|
SetDParam(0, ((DateTicks)_date * DAY_TICKS) + arr_dep[i / 2].arrival);
|
||||||
DrawString(time_left, time_right, y, STR_JUST_DATE_TINY, TC_GREEN);
|
DrawString(time_left, time_right, y, STR_JUST_DATE_WALLCLOCK_TINY, TC_GREEN);
|
||||||
} else {
|
} else {
|
||||||
SetDParam(0, _date + (arr_dep[i / 2].arrival + offset) / DAY_TICKS);
|
SetDParam(0, ((DateTicks)_date * DAY_TICKS) + (arr_dep[i / 2].arrival + offset));
|
||||||
DrawString(time_left, time_right, y, STR_JUST_DATE_TINY,
|
DrawString(time_left, time_right, y, STR_JUST_DATE_WALLCLOCK_TINY,
|
||||||
show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
|
show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (arr_dep[i / 2].departure != INVALID_TICKS) {
|
if (arr_dep[i / 2].departure != INVALID_TICKS) {
|
||||||
DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_DEPARTURE_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
|
DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_DEPARTURE_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
|
||||||
SetDParam(0, _date + (arr_dep[i/2].departure + offset) / DAY_TICKS);
|
SetDParam(0, ((DateTicks)_date * DAY_TICKS) + (arr_dep[i/2].departure + offset));
|
||||||
DrawString(time_left, time_right, y, STR_JUST_DATE_TINY,
|
DrawString(time_left, time_right, y, STR_JUST_DATE_WALLCLOCK_TINY,
|
||||||
show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
|
show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -484,14 +494,18 @@ struct TimetableWindow : Window {
|
|||||||
if (v->timetable_start != 0) {
|
if (v->timetable_start != 0) {
|
||||||
/* We are running towards the first station so we can start the
|
/* We are running towards the first station so we can start the
|
||||||
* timetable at the given time. */
|
* timetable at the given time. */
|
||||||
SetDParam(0, STR_JUST_DATE_TINY);
|
SetDParam(0, STR_JUST_DATE_WALLCLOCK_TINY);
|
||||||
|
#if WALLCLOCK_NETWORK_COMPATIBLE
|
||||||
|
SetDParam(1, v->timetable_start * DAY_TICKS);
|
||||||
|
#else
|
||||||
SetDParam(1, v->timetable_start);
|
SetDParam(1, v->timetable_start);
|
||||||
|
#endif
|
||||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_TIMETABLE_STATUS_START_AT);
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_TIMETABLE_STATUS_START_AT);
|
||||||
} else if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) {
|
} else if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) {
|
||||||
/* We aren't running on a timetable yet, so how can we be "on time"
|
/* We aren't running on a timetable yet, so how can we be "on time"
|
||||||
* when we aren't even "on service"/"on duty"? */
|
* when we aren't even "on service"/"on duty"? */
|
||||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_TIMETABLE_STATUS_NOT_STARTED);
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_TIMETABLE_STATUS_NOT_STARTED);
|
||||||
} else if (v->lateness_counter == 0 || (!_settings_client.gui.timetable_in_ticks && v->lateness_counter / DAY_TICKS == 0)) {
|
} else if (v->lateness_counter == 0 || (!_settings_client.gui.timetable_in_ticks && v->lateness_counter / DATE_UNIT_SIZE == 0)) {
|
||||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_TIMETABLE_STATUS_ON_TIME);
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_TIMETABLE_STATUS_ON_TIME);
|
||||||
} else {
|
} else {
|
||||||
SetTimetableParams(0, 1, abs(v->lateness_counter));
|
SetTimetableParams(0, 1, abs(v->lateness_counter));
|
||||||
@@ -516,6 +530,8 @@ struct TimetableWindow : Window {
|
|||||||
{
|
{
|
||||||
const Vehicle *v = this->vehicle;
|
const Vehicle *v = this->vehicle;
|
||||||
|
|
||||||
|
this->clicked_widget = widget;
|
||||||
|
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_VT_ORDER_VIEW: // Order view button
|
case WID_VT_ORDER_VIEW: // Order view button
|
||||||
ShowOrdersWindow(v);
|
ShowOrdersWindow(v);
|
||||||
@@ -530,7 +546,18 @@ struct TimetableWindow : Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WID_VT_START_DATE: // Change the date that the timetable starts.
|
case WID_VT_START_DATE: // Change the date that the timetable starts.
|
||||||
ShowSetDateWindow(this, v->index | (v->orders.list->IsCompleteTimetable() && _ctrl_pressed ? 1U << 20 : 0), _date, _cur_year, _cur_year + 15, ChangeTimetableStartCallback);
|
if (_settings_client.gui.time_in_minutes && _settings_client.gui.timetable_start_text_entry) {
|
||||||
|
StringID str = STR_JUST_INT;
|
||||||
|
uint64 time = ((DateTicks)_date * DAY_TICKS) + _date_fract;
|
||||||
|
time /= _settings_client.gui.ticks_per_minute;
|
||||||
|
time += _settings_client.gui.clock_offset;
|
||||||
|
time %= 24*60;
|
||||||
|
time = (time % 60) + (((time / 60) % 24) * 100);
|
||||||
|
SetDParam(0, time);
|
||||||
|
ShowQueryString(str, STR_TIMETABLE_STARTING_DATE, 31, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
|
||||||
|
} else {
|
||||||
|
ShowSetDateWindow(this, v->index | (v->orders.list->IsCompleteTimetable() && _ctrl_pressed ? 1U << 20 : 0), _date, _cur_year, _cur_year + 15, ChangeTimetableStartCallback);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WID_VT_CHANGE_TIME: { // "Wait For" button.
|
case WID_VT_CHANGE_TIME: { // "Wait For" button.
|
||||||
@@ -544,7 +571,7 @@ struct TimetableWindow : Window {
|
|||||||
|
|
||||||
if (order != NULL) {
|
if (order != NULL) {
|
||||||
uint time = (selected % 2 == 1) ? order->GetTravelTime() : order->GetWaitTime();
|
uint time = (selected % 2 == 1) ? order->GetTravelTime() : order->GetWaitTime();
|
||||||
if (!_settings_client.gui.timetable_in_ticks) time /= DAY_TICKS;
|
if (!_settings_client.gui.timetable_in_ticks) time /= DATE_UNIT_SIZE;
|
||||||
|
|
||||||
if (time != 0) {
|
if (time != 0) {
|
||||||
SetDParam(0, time);
|
SetDParam(0, time);
|
||||||
@@ -619,18 +646,41 @@ struct TimetableWindow : Window {
|
|||||||
|
|
||||||
const Vehicle *v = this->vehicle;
|
const Vehicle *v = this->vehicle;
|
||||||
|
|
||||||
uint32 p1 = PackTimetableArgs(v, this->sel_index, this->query_is_speed_query);
|
switch (this->clicked_widget) {
|
||||||
|
default: NOT_REACHED();
|
||||||
|
|
||||||
uint64 val = StrEmpty(str) ? 0 : strtoul(str, NULL, 10);
|
case WID_VT_CHANGE_SPEED:
|
||||||
if (this->query_is_speed_query) {
|
case WID_VT_CHANGE_TIME: {
|
||||||
val = ConvertDisplaySpeedToKmhishSpeed(val);
|
uint32 p1 = PackTimetableArgs(v, this->sel_index, this->query_is_speed_query);
|
||||||
} else {
|
|
||||||
if (!_settings_client.gui.timetable_in_ticks) val *= DAY_TICKS;
|
uint64 val = StrEmpty(str) ? 0 : strtoul(str, NULL, 10);
|
||||||
|
if (this->query_is_speed_query) {
|
||||||
|
val = ConvertDisplaySpeedToKmhishSpeed(val);
|
||||||
|
} else {
|
||||||
|
if (!_settings_client.gui.timetable_in_ticks) val *= DATE_UNIT_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32 p2 = minu(val, UINT16_MAX);
|
||||||
|
|
||||||
|
DoCommandP(0, p1, p2, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WID_VT_START_DATE: {
|
||||||
|
int32 val = StrEmpty(str) ? 0 : strtoul(str, NULL, 10);
|
||||||
|
if (val > 0) {
|
||||||
|
uint minutes = (val % 100) % 60;
|
||||||
|
uint hours = (val / 100) % 24;
|
||||||
|
val = MINUTES_DATE(MINUTES_DAY(CURRENT_MINUTE), hours, minutes);
|
||||||
|
val -= _settings_client.gui.clock_offset;
|
||||||
|
|
||||||
|
if (val < (CURRENT_MINUTE - 60)) val += 60 * 24;
|
||||||
|
val *= DATE_UNIT_SIZE;
|
||||||
|
ChangeTimetableStartCallback(this, val);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 p2 = minu(val, UINT16_MAX);
|
|
||||||
|
|
||||||
DoCommandP(0, p1, p2, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnResize()
|
virtual void OnResize()
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "order_func.h"
|
#include "order_func.h"
|
||||||
#include "transport_type.h"
|
#include "transport_type.h"
|
||||||
#include "group_type.h"
|
#include "group_type.h"
|
||||||
|
#include "timetable.h"
|
||||||
#include "base_consist.h"
|
#include "base_consist.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
#include "window_func.h"
|
#include "window_func.h"
|
||||||
#include "waypoint_base.h"
|
#include "waypoint_base.h"
|
||||||
|
#include "departures_gui.h"
|
||||||
|
|
||||||
#include "widgets/waypoint_widget.h"
|
#include "widgets/waypoint_widget.h"
|
||||||
|
|
||||||
@@ -105,6 +106,10 @@ public:
|
|||||||
case WID_W_SHOW_VEHICLES: // show list of vehicles having this waypoint in their orders
|
case WID_W_SHOW_VEHICLES: // show list of vehicles having this waypoint in their orders
|
||||||
ShowVehicleListWindow(this->wp->owner, this->vt, this->wp->index);
|
ShowVehicleListWindow(this->wp->owner, this->vt, this->wp->index);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WID_W_DEPARTURES: // show departure times of vehicles
|
||||||
|
ShowWaypointDepartures((StationID)this->wp->index);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,6 +166,7 @@ static const NWidgetPart _nested_waypoint_view_widgets[] = {
|
|||||||
NWidget(NWID_HORIZONTAL),
|
NWidget(NWID_HORIZONTAL),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_CENTER_VIEW), SetMinimalSize(100, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_BUOY_VIEW_CENTER_TOOLTIP),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_CENTER_VIEW), SetMinimalSize(100, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_LOCATION, STR_BUOY_VIEW_CENTER_TOOLTIP),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_RENAME), SetMinimalSize(100, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_RENAME, STR_BUOY_VIEW_CHANGE_BUOY_NAME),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_RENAME), SetMinimalSize(100, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_BUTTON_RENAME, STR_BUOY_VIEW_CHANGE_BUOY_NAME),
|
||||||
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_DEPARTURES), SetMinimalSize(100, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_STATION_VIEW_DEPARTURES_BUTTON, STR_STATION_VIEW_DEPARTURES_TOOLTIP),
|
||||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_SHOW_VEHICLES), SetMinimalSize(15, 12), SetDataTip(STR_SHIP, STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP),
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_SHOW_VEHICLES), SetMinimalSize(15, 12), SetDataTip(STR_SHIP, STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP),
|
||||||
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
||||||
EndContainer(),
|
EndContainer(),
|
||||||
|
29
src/widgets/departures_widget.h
Normal file
29
src/widgets/departures_widget.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of OpenTTD.
|
||||||
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||||
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @file waypoint_widget.h Types related to the waypoint widgets. */
|
||||||
|
|
||||||
|
#ifndef WIDGETS_DEPARTURES_WIDGET_H
|
||||||
|
#define WIDGETS_DEPARTURES_WIDGET_H
|
||||||
|
|
||||||
|
/** Widgets of the WC_DEPARTURES_BOARD. */
|
||||||
|
enum DeparturesWindowWidgets {
|
||||||
|
WID_DB_CAPTION, ///< Window caption
|
||||||
|
WID_DB_LIST, ///< List of departures
|
||||||
|
WID_DB_SCROLLBAR, ///< List scrollbar
|
||||||
|
WID_DB_SHOW_DEPS, ///< Toggle departures button
|
||||||
|
WID_DB_SHOW_ARRS, ///< Toggle arrivals button
|
||||||
|
WID_DB_SHOW_VIA, ///< Toggle via button
|
||||||
|
WID_DB_SHOW_TRAINS, ///< Toggle trains button
|
||||||
|
WID_DB_SHOW_ROADVEHS, ///< Toggle road vehicles button
|
||||||
|
WID_DB_SHOW_SHIPS, ///< Toggle ships button
|
||||||
|
WID_DB_SHOW_PLANES, ///< Toggle planes button
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* WIDGETS_DEPARTURES_WIDGET_H */
|
@@ -30,6 +30,7 @@ enum StationViewWidgets {
|
|||||||
WID_SV_ROADVEHS, ///< List of scheduled road vehs button.
|
WID_SV_ROADVEHS, ///< List of scheduled road vehs button.
|
||||||
WID_SV_SHIPS, ///< List of scheduled ships button.
|
WID_SV_SHIPS, ///< List of scheduled ships button.
|
||||||
WID_SV_PLANES, ///< List of scheduled planes button.
|
WID_SV_PLANES, ///< List of scheduled planes button.
|
||||||
|
WID_SV_DEPARTURES, ///< Departures button.
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Widgets of the #CompanyStationsWindow class. */
|
/** Widgets of the #CompanyStationsWindow class. */
|
||||||
|
@@ -19,6 +19,7 @@ enum WaypointWidgets {
|
|||||||
WID_W_CENTER_VIEW, ///< Center the main view on this waypoint.
|
WID_W_CENTER_VIEW, ///< Center the main view on this waypoint.
|
||||||
WID_W_RENAME, ///< Rename this waypoint.
|
WID_W_RENAME, ///< Rename this waypoint.
|
||||||
WID_W_SHOW_VEHICLES, ///< Show the vehicles visiting this waypoint.
|
WID_W_SHOW_VEHICLES, ///< Show the vehicles visiting this waypoint.
|
||||||
|
WID_W_DEPARTURES, ///< Departures button.
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* WIDGETS_WAYPOINT_WIDGET_H */
|
#endif /* WIDGETS_WAYPOINT_WIDGET_H */
|
||||||
|
@@ -681,6 +681,11 @@ enum WindowClass {
|
|||||||
*/
|
*/
|
||||||
WC_SAVE_PRESET,
|
WC_SAVE_PRESET,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Departure boards
|
||||||
|
*/
|
||||||
|
WC_DEPARTURES_BOARD,
|
||||||
|
|
||||||
WC_INVALID = 0xFFFF, ///< Invalid window.
|
WC_INVALID = 0xFFFF, ///< Invalid window.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user