(svn r23553) -Fix: avoid naming conflict in widget enums

pull/155/head
truebrain 13 years ago
parent 77ee7a3a3a
commit 74a9412141

@ -314,7 +314,7 @@ protected:
this->last_station = NULL;
/* Set the modified widget dirty */
this->SetWidgetDirty(WID_SL_LIST);
this->SetWidgetDirty(WID_STL_LIST);
}
public:
@ -327,23 +327,23 @@ public:
this->SortStationsList();
this->CreateNestedTree(desc);
this->vscroll = this->GetScrollbar(WID_SL_SCROLLBAR);
this->vscroll = this->GetScrollbar(WID_STL_SCROLLBAR);
this->FinishInitNested(desc, window_number);
this->owner = (Owner)this->window_number;
CargoID cid;
FOR_EACH_SET_CARGO_ID(cid, this->cargo_filter) {
if (CargoSpec::Get(cid)->IsValid()) this->LowerWidget(WID_SL_CARGOSTART + cid);
if (CargoSpec::Get(cid)->IsValid()) this->LowerWidget(WID_STL_CARGOSTART + cid);
}
if (this->cargo_filter == this->cargo_filter_max) this->cargo_filter = _cargo_mask;
for (uint i = 0; i < 5; i++) {
if (HasBit(this->facilities, i)) this->LowerWidget(i + WID_SL_TRAIN);
if (HasBit(this->facilities, i)) this->LowerWidget(i + WID_STL_TRAIN);
}
this->SetWidgetLoweredState(WID_SL_NOCARGOWAITING, this->include_empty);
this->SetWidgetLoweredState(WID_STL_NOCARGOWAITING, this->include_empty);
this->GetWidget<NWidgetCore>(WID_SL_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
this->GetWidget<NWidgetCore>(WID_STL_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
}
~CompanyStationsWindow()
@ -354,7 +354,7 @@ public:
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
switch (widget) {
case WID_SL_SORTBY: {
case WID_STL_SORTBY: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + WD_SORTBUTTON_ARROW_WIDTH * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height;
@ -362,7 +362,7 @@ public:
break;
}
case WID_SL_SORTDROPBTN: {
case WID_STL_SORTDROPBTN: {
Dimension d = {0, 0};
for (int i = 0; this->sorter_names[i] != INVALID_STRING_ID; i++) {
d = maxdim(d, GetStringBoundingBox(this->sorter_names[i]));
@ -373,23 +373,23 @@ public:
break;
}
case WID_SL_LIST:
case WID_STL_LIST:
resize->height = FONT_HEIGHT_NORMAL;
size->height = WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM;
break;
case WID_SL_TRAIN:
case WID_SL_TRUCK:
case WID_SL_BUS:
case WID_SL_AIRPLANE:
case WID_SL_SHIP:
case WID_STL_TRAIN:
case WID_STL_TRUCK:
case WID_STL_BUS:
case WID_STL_AIRPLANE:
case WID_STL_SHIP:
size->height = max<uint>(FONT_HEIGHT_SMALL, 10) + padding.height;
break;
case WID_SL_CARGOALL:
case WID_SL_FACILALL:
case WID_SL_NOCARGOWAITING: {
Dimension d = GetStringBoundingBox(widget == WID_SL_NOCARGOWAITING ? STR_ABBREV_NONE : STR_ABBREV_ALL);
case WID_STL_CARGOALL:
case WID_STL_FACILALL:
case WID_STL_NOCARGOWAITING: {
Dimension d = GetStringBoundingBox(widget == WID_STL_NOCARGOWAITING ? STR_ABBREV_NONE : STR_ABBREV_ALL);
d.width += padding.width + 2;
d.height += padding.height;
*size = maxdim(*size, d);
@ -397,8 +397,8 @@ public:
}
default:
if (widget >= WID_SL_CARGOSTART) {
const CargoSpec *cs = CargoSpec::Get(widget - WID_SL_CARGOSTART);
if (widget >= WID_STL_CARGOSTART) {
const CargoSpec *cs = CargoSpec::Get(widget - WID_STL_CARGOSTART);
if (cs->IsValid()) {
Dimension d = GetStringBoundingBox(cs->abbrev);
d.width += padding.width + 2;
@ -421,12 +421,12 @@ public:
virtual void DrawWidget(const Rect &r, int widget) const
{
switch (widget) {
case WID_SL_SORTBY:
case WID_STL_SORTBY:
/* draw arrow pointing up/down for ascending/descending sorting */
this->DrawSortButtonState(WID_SL_SORTBY, this->stations.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
this->DrawSortButtonState(WID_STL_SORTBY, this->stations.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
break;
case WID_SL_LIST: {
case WID_STL_LIST: {
bool rtl = _current_text_dir == TD_RTL;
int max = min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.Length());
int y = r.top + WD_FRAMERECT_TOP;
@ -471,27 +471,27 @@ public:
break;
}
case WID_SL_NOCARGOWAITING: {
case WID_STL_NOCARGOWAITING: {
int cg_ofst = this->IsWidgetLowered(widget) ? 2 : 1;
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + cg_ofst, STR_ABBREV_NONE, TC_BLACK, SA_HOR_CENTER);
break;
}
case WID_SL_CARGOALL: {
case WID_STL_CARGOALL: {
int cg_ofst = this->IsWidgetLowered(widget) ? 2 : 1;
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_HOR_CENTER);
break;
}
case WID_SL_FACILALL: {
case WID_STL_FACILALL: {
int cg_ofst = this->IsWidgetLowered(widget) ? 2 : 1;
DrawString(r.left + cg_ofst, r.right + cg_ofst, r.top + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
break;
}
default:
if (widget >= WID_SL_CARGOSTART) {
const CargoSpec *cs = CargoSpec::Get(widget - WID_SL_CARGOSTART);
if (widget >= WID_STL_CARGOSTART) {
const CargoSpec *cs = CargoSpec::Get(widget - WID_STL_CARGOSTART);
if (cs->IsValid()) {
int cg_ofst = HasBit(this->cargo_filter, cs->Index()) ? 2 : 1;
GfxFillRect(r.left + cg_ofst, r.top + cg_ofst, r.right - 2 + cg_ofst, r.bottom - 2 + cg_ofst, cs->rating_colour);
@ -504,7 +504,7 @@ public:
virtual void SetStringParameters(int widget) const
{
if (widget == WID_SL_CAPTION) {
if (widget == WID_STL_CAPTION) {
SetDParam(0, this->window_number);
SetDParam(1, this->vscroll->GetCount());
}
@ -513,8 +513,8 @@ public:
virtual void OnClick(Point pt, int widget, int click_count)
{
switch (widget) {
case WID_SL_LIST: {
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SL_LIST, 0, FONT_HEIGHT_NORMAL);
case WID_STL_LIST: {
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_STL_LIST, 0, FONT_HEIGHT_NORMAL);
if (id_v >= this->stations.Length()) return; // click out of list bound
const Station *st = this->stations[id_v];
@ -529,28 +529,28 @@ public:
break;
}
case WID_SL_TRAIN:
case WID_SL_TRUCK:
case WID_SL_BUS:
case WID_SL_AIRPLANE:
case WID_SL_SHIP:
case WID_STL_TRAIN:
case WID_STL_TRUCK:
case WID_STL_BUS:
case WID_STL_AIRPLANE:
case WID_STL_SHIP:
if (_ctrl_pressed) {
ToggleBit(this->facilities, widget - WID_SL_TRAIN);
ToggleBit(this->facilities, widget - WID_STL_TRAIN);
this->ToggleWidgetLoweredState(widget);
} else {
uint i;
FOR_EACH_SET_BIT(i, this->facilities) {
this->RaiseWidget(i + WID_SL_TRAIN);
this->RaiseWidget(i + WID_STL_TRAIN);
}
this->facilities = 1 << (widget - WID_SL_TRAIN);
this->facilities = 1 << (widget - WID_STL_TRAIN);
this->LowerWidget(widget);
}
this->stations.ForceRebuild();
this->SetDirty();
break;
case WID_SL_FACILALL:
for (uint i = WID_SL_TRAIN; i <= WID_SL_SHIP; i++) {
case WID_STL_FACILALL:
for (uint i = WID_STL_TRAIN; i <= WID_STL_SHIP; i++) {
this->LowerWidget(i);
}
@ -559,12 +559,12 @@ public:
this->SetDirty();
break;
case WID_SL_CARGOALL: {
case WID_STL_CARGOALL: {
for (uint i = 0; i < NUM_CARGO; i++) {
const CargoSpec *cs = CargoSpec::Get(i);
if (cs->IsValid()) this->LowerWidget(WID_SL_CARGOSTART + i);
if (cs->IsValid()) this->LowerWidget(WID_STL_CARGOSTART + i);
}
this->LowerWidget(WID_SL_NOCARGOWAITING);
this->LowerWidget(WID_STL_NOCARGOWAITING);
this->cargo_filter = _cargo_mask;
this->include_empty = true;
@ -573,40 +573,40 @@ public:
break;
}
case WID_SL_SORTBY: // flip sorting method asc/desc
case WID_STL_SORTBY: // flip sorting method asc/desc
this->stations.ToggleSortOrder();
this->SetTimeout();
this->LowerWidget(WID_SL_SORTBY);
this->LowerWidget(WID_STL_SORTBY);
this->SetDirty();
break;
case WID_SL_SORTDROPBTN: // select sorting criteria dropdown menu
ShowDropDownMenu(this, this->sorter_names, this->stations.SortType(), WID_SL_SORTDROPBTN, 0, 0);
case WID_STL_SORTDROPBTN: // select sorting criteria dropdown menu
ShowDropDownMenu(this, this->sorter_names, this->stations.SortType(), WID_STL_SORTDROPBTN, 0, 0);
break;
case WID_SL_NOCARGOWAITING:
case WID_STL_NOCARGOWAITING:
if (_ctrl_pressed) {
this->include_empty = !this->include_empty;
this->ToggleWidgetLoweredState(WID_SL_NOCARGOWAITING);
this->ToggleWidgetLoweredState(WID_STL_NOCARGOWAITING);
} else {
for (uint i = 0; i < NUM_CARGO; i++) {
const CargoSpec *cs = CargoSpec::Get(i);
if (cs->IsValid()) this->RaiseWidget(WID_SL_CARGOSTART + i);
if (cs->IsValid()) this->RaiseWidget(WID_STL_CARGOSTART + i);
}
this->cargo_filter = 0;
this->include_empty = true;
this->LowerWidget(WID_SL_NOCARGOWAITING);
this->LowerWidget(WID_STL_NOCARGOWAITING);
}
this->stations.ForceRebuild();
this->SetDirty();
break;
default:
if (widget >= WID_SL_CARGOSTART) { // change cargo_filter
if (widget >= WID_STL_CARGOSTART) { // change cargo_filter
/* Determine the selected cargo type */
const CargoSpec *cs = CargoSpec::Get(widget - WID_SL_CARGOSTART);
const CargoSpec *cs = CargoSpec::Get(widget - WID_STL_CARGOSTART);
if (!cs->IsValid()) break;
if (_ctrl_pressed) {
@ -615,9 +615,9 @@ public:
} else {
for (uint i = 0; i < NUM_CARGO; i++) {
const CargoSpec *cs = CargoSpec::Get(i);
if (cs->IsValid()) this->RaiseWidget(WID_SL_CARGOSTART + i);
if (cs->IsValid()) this->RaiseWidget(WID_STL_CARGOSTART + i);
}
this->RaiseWidget(WID_SL_NOCARGOWAITING);
this->RaiseWidget(WID_STL_NOCARGOWAITING);
this->cargo_filter = 0;
this->include_empty = false;
@ -638,7 +638,7 @@ public:
this->stations.SetSortType(index);
/* Display the current sort variant */
this->GetWidget<NWidgetCore>(WID_SL_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
this->GetWidget<NWidgetCore>(WID_STL_SORTDROPBTN)->widget_data = this->sorter_names[this->stations.SortType()];
this->SetDirty();
}
@ -655,13 +655,13 @@ public:
virtual void OnTimeout()
{
this->RaiseWidget(WID_SL_SORTBY);
this->RaiseWidget(WID_STL_SORTBY);
this->SetDirty();
}
virtual void OnResize()
{
this->vscroll->SetCapacityFromWidget(this, WID_SL_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
this->vscroll->SetCapacityFromWidget(this, WID_STL_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
}
/**
@ -707,7 +707,7 @@ const StringID CompanyStationsWindow::sorter_names[] = {
};
/**
* Make a horizontal row of cargo buttons, starting at widget #WID_SL_CARGOSTART.
* Make a horizontal row of cargo buttons, starting at widget #WID_STL_CARGOSTART.
* @param biggest_index Pointer to store biggest used widget number of the buttons.
* @return Horizontal row.
*/
@ -718,53 +718,53 @@ static NWidgetBase *CargoWidgets(int *biggest_index)
for (uint i = 0; i < NUM_CARGO; i++) {
const CargoSpec *cs = CargoSpec::Get(i);
if (cs->IsValid()) {
NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_SL_CARGOSTART + i);
NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, WID_STL_CARGOSTART + i);
panel->SetMinimalSize(14, 11);
panel->SetResize(0, 0);
panel->SetFill(0, 1);
panel->SetDataTip(0, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE);
container->Add(panel);
} else {
NWidgetLeaf *nwi = new NWidgetLeaf(WWT_EMPTY, COLOUR_GREY, WID_SL_CARGOSTART + i, 0x0, STR_NULL);
NWidgetLeaf *nwi = new NWidgetLeaf(WWT_EMPTY, COLOUR_GREY, WID_STL_CARGOSTART + i, 0x0, STR_NULL);
nwi->SetMinimalSize(0, 11);
nwi->SetResize(0, 0);
nwi->SetFill(0, 1);
container->Add(nwi);
}
}
*biggest_index = WID_SL_CARGOSTART + NUM_CARGO;
*biggest_index = WID_STL_CARGOSTART + NUM_CARGO;
return container;
}
static const NWidgetPart _nested_company_stations_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_SL_CAPTION), SetDataTip(STR_STATION_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_STL_CAPTION), SetDataTip(STR_STATION_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_GREY),
NWidget(WWT_STICKYBOX, COLOUR_GREY),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_TRAIN), SetMinimalSize(14, 11), SetDataTip(STR_TRAIN, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_TRUCK), SetMinimalSize(14, 11), SetDataTip(STR_LORRY, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_BUS), SetMinimalSize(14, 11), SetDataTip(STR_BUS, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_SHIP), SetMinimalSize(14, 11), SetDataTip(STR_SHIP, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_AIRPLANE), SetMinimalSize(14, 11), SetDataTip(STR_PLANE, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_SL_FACILALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_FACILITIES), SetFill(0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_TRAIN), SetMinimalSize(14, 11), SetDataTip(STR_TRAIN, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_TRUCK), SetMinimalSize(14, 11), SetDataTip(STR_LORRY, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_BUS), SetMinimalSize(14, 11), SetDataTip(STR_BUS, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_SHIP), SetMinimalSize(14, 11), SetDataTip(STR_SHIP, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_AIRPLANE), SetMinimalSize(14, 11), SetDataTip(STR_PLANE, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE), SetFill(0, 1),
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_STL_FACILALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_FACILITIES), SetFill(0, 1),
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(5, 11), SetFill(0, 1), EndContainer(),
NWidgetFunction(CargoWidgets),
NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_NOCARGOWAITING), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_NO_WAITING_CARGO), SetFill(0, 1), EndContainer(),
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_SL_CARGOALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_TYPES), SetFill(0, 1),
NWidget(WWT_PANEL, COLOUR_GREY, WID_STL_NOCARGOWAITING), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_NO_WAITING_CARGO), SetFill(0, 1), EndContainer(),
NWidget(WWT_PUSHBTN, COLOUR_GREY, WID_STL_CARGOALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_TYPES), SetFill(0, 1),
NWidget(WWT_PANEL, COLOUR_GREY), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(1, 1), EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SL_SORTBY), SetMinimalSize(81, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_SL_SORTDROPBTN), SetMinimalSize(163, 12), SetDataTip(STR_SORT_BY_NAME, STR_TOOLTIP_SORT_CRITERIA), // widget_data gets overwritten.
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_STL_SORTBY), SetMinimalSize(81, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_STL_SORTDROPBTN), SetMinimalSize(163, 12), SetDataTip(STR_SORT_BY_NAME, STR_TOOLTIP_SORT_CRITERIA), // widget_data gets overwritten.
NWidget(WWT_PANEL, COLOUR_GREY), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(1, 1), EndContainer(),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PANEL, COLOUR_GREY, WID_SL_LIST), SetMinimalSize(346, 125), SetResize(1, 10), SetDataTip(0x0, STR_STATION_LIST_TOOLTIP), SetScrollbar(WID_SL_SCROLLBAR), EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_STL_LIST), SetMinimalSize(346, 125), SetResize(1, 10), SetDataTip(0x0, STR_STATION_LIST_TOOLTIP), SetScrollbar(WID_STL_SCROLLBAR), EndContainer(),
NWidget(NWID_VERTICAL),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_SL_SCROLLBAR),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_STL_SCROLLBAR),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(),
EndContainer(),

@ -170,7 +170,7 @@ struct TimetableWindow : Window {
show_expected(true)
{
this->CreateNestedTree(desc);
this->vscroll = this->GetScrollbar(WID_TV_SCROLLBAR);
this->vscroll = this->GetScrollbar(WID_VT_SCROLLBAR);
this->UpdateSelectionStates();
this->FinishInitNested(desc, window_number);
@ -198,19 +198,19 @@ struct TimetableWindow : Window {
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
switch (widget) {
case WID_TV_ARRIVAL_DEPARTURE_PANEL:
case WID_VT_ARRIVAL_DEPARTURE_PANEL:
SetDParam(0, MAX_YEAR * DAYS_IN_YEAR);
this->deparr_time_width = GetStringBoundingBox(STR_JUST_DATE_TINY).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;
/* FALL THROUGH */
case WID_TV_ARRIVAL_DEPARTURE_SELECTION:
case WID_TV_TIMETABLE_PANEL:
case WID_VT_ARRIVAL_DEPARTURE_SELECTION:
case WID_VT_TIMETABLE_PANEL:
resize->height = FONT_HEIGHT_NORMAL;
size->height = WD_FRAMERECT_TOP + 8 * resize->height + WD_FRAMERECT_BOTTOM;
break;
case WID_TV_SUMMARY_PANEL:
case WID_VT_SUMMARY_PANEL:
size->height = WD_FRAMERECT_TOP + 2 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
break;
}
@ -218,7 +218,7 @@ struct TimetableWindow : Window {
int GetOrderFromTimetableWndPt(int y, const Vehicle *v)
{
int sel = (y - this->GetWidget<NWidgetBase>(WID_TV_TIMETABLE_PANEL)->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
int sel = (y - this->GetWidget<NWidgetBase>(WID_VT_TIMETABLE_PANEL)->pos_y - WD_FRAMERECT_TOP) / FONT_HEIGHT_NORMAL;
if ((uint)sel >= this->vscroll->GetCapacity()) return INVALID_ORDER;
@ -320,23 +320,23 @@ struct TimetableWindow : Window {
}
}
this->SetWidgetDisabledState(WID_TV_CHANGE_TIME, disable);
this->SetWidgetDisabledState(WID_TV_CLEAR_TIME, disable);
this->SetWidgetDisabledState(WID_TV_SHARED_ORDER_LIST, !v->IsOrderListShared());
this->SetWidgetDisabledState(WID_VT_CHANGE_TIME, disable);
this->SetWidgetDisabledState(WID_VT_CLEAR_TIME, disable);
this->SetWidgetDisabledState(WID_VT_SHARED_ORDER_LIST, !v->IsOrderListShared());
this->EnableWidget(WID_TV_START_DATE);
this->EnableWidget(WID_TV_RESET_LATENESS);
this->EnableWidget(WID_TV_AUTOFILL);
this->EnableWidget(WID_VT_START_DATE);
this->EnableWidget(WID_VT_RESET_LATENESS);
this->EnableWidget(WID_VT_AUTOFILL);
} else {
this->DisableWidget(WID_TV_START_DATE);
this->DisableWidget(WID_TV_CHANGE_TIME);
this->DisableWidget(WID_TV_CLEAR_TIME);
this->DisableWidget(WID_TV_RESET_LATENESS);
this->DisableWidget(WID_TV_AUTOFILL);
this->DisableWidget(WID_TV_SHARED_ORDER_LIST);
this->DisableWidget(WID_VT_START_DATE);
this->DisableWidget(WID_VT_CHANGE_TIME);
this->DisableWidget(WID_VT_CLEAR_TIME);
this->DisableWidget(WID_VT_RESET_LATENESS);
this->DisableWidget(WID_VT_AUTOFILL);
this->DisableWidget(WID_VT_SHARED_ORDER_LIST);
}
this->SetWidgetLoweredState(WID_TV_AUTOFILL, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE));
this->SetWidgetLoweredState(WID_VT_AUTOFILL, HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE));
this->DrawWidgets();
}
@ -344,8 +344,8 @@ struct TimetableWindow : Window {
virtual void SetStringParameters(int widget) const
{
switch (widget) {
case WID_TV_CAPTION: SetDParam(0, this->vehicle->index); break;
case WID_TV_EXPECTED: SetDParam(0, this->show_expected ? STR_TIMETABLE_EXPECTED : STR_TIMETABLE_SCHEDULED); break;
case WID_VT_CAPTION: SetDParam(0, this->vehicle->index); break;
case WID_VT_EXPECTED: SetDParam(0, this->show_expected ? STR_TIMETABLE_EXPECTED : STR_TIMETABLE_SCHEDULED); break;
}
}
@ -355,7 +355,7 @@ struct TimetableWindow : Window {
int selected = this->sel_index;
switch (widget) {
case WID_TV_TIMETABLE_PANEL: {
case WID_VT_TIMETABLE_PANEL: {
int y = r.top + WD_FRAMERECT_TOP;
int i = this->vscroll->GetPosition();
VehicleOrderID order_id = (i + 1) / 2;
@ -408,7 +408,7 @@ struct TimetableWindow : Window {
break;
}
case WID_TV_ARRIVAL_DEPARTURE_PANEL: {
case WID_VT_ARRIVAL_DEPARTURE_PANEL: {
/* Arrival and departure times are handled in an all-or-nothing approach,
* i.e. are only shown if we can calculate all times.
* Excluding order lists with only one order makes some things easier.
@ -459,7 +459,7 @@ struct TimetableWindow : Window {
break;
}
case WID_TV_SUMMARY_PANEL: {
case WID_VT_SUMMARY_PANEL: {
int y = r.top + WD_FRAMERECT_TOP;
Ticks total_time = v->orders.list != NULL ? v->orders.list->GetTimetableDurationIncomplete() : 0;
@ -505,11 +505,11 @@ struct TimetableWindow : Window {
const Vehicle *v = this->vehicle;
switch (widget) {
case WID_TV_ORDER_VIEW: // Order view button
case WID_VT_ORDER_VIEW: // Order view button
ShowOrdersWindow(v);
break;
case WID_TV_TIMETABLE_PANEL: { // Main panel.
case WID_VT_TIMETABLE_PANEL: { // Main panel.
int selected = GetOrderFromTimetableWndPt(pt.y, v);
this->DeleteChildWindows();
@ -517,11 +517,11 @@ struct TimetableWindow : Window {
break;
}
case WID_TV_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, _date, _cur_year, _cur_year + 15, ChangeTimetableStartCallback);
break;
case WID_TV_CHANGE_TIME: { // "Wait For" button.
case WID_VT_CHANGE_TIME: { // "Wait For" button.
int selected = this->sel_index;
VehicleOrderID real = (selected + 1) / 2;
@ -544,17 +544,17 @@ struct TimetableWindow : Window {
break;
}
case WID_TV_CLEAR_TIME: { // Clear waiting time button.
case WID_VT_CLEAR_TIME: { // Clear waiting time button.
uint32 p1 = PackTimetableArgs(v, this->sel_index);
DoCommandP(0, p1, 0, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
break;
}
case WID_TV_RESET_LATENESS: // Reset the vehicle's late counter.
case WID_VT_RESET_LATENESS: // Reset the vehicle's late counter.
DoCommandP(0, v->index, 0, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE));
break;
case WID_TV_AUTOFILL: { // Autofill the timetable.
case WID_VT_AUTOFILL: { // Autofill the timetable.
uint32 p2 = 0;
if (!HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(p2, 0);
if (_ctrl_pressed) SetBit(p2, 1);
@ -562,11 +562,11 @@ struct TimetableWindow : Window {
break;
}
case WID_TV_EXPECTED:
case WID_VT_EXPECTED:
this->show_expected = !this->show_expected;
break;
case WID_TV_SHARED_ORDER_LIST:
case WID_VT_SHARED_ORDER_LIST:
ShowVehicleListWindow(v);
break;
}
@ -593,7 +593,7 @@ struct TimetableWindow : Window {
virtual void OnResize()
{
/* Update the scroll bar */
this->vscroll->SetCapacityFromWidget(this, WID_TV_TIMETABLE_PANEL, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
this->vscroll->SetCapacityFromWidget(this, WID_VT_TIMETABLE_PANEL, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
}
/**
@ -601,47 +601,47 @@ struct TimetableWindow : Window {
*/
void UpdateSelectionStates()
{
this->GetWidget<NWidgetStacked>(WID_TV_ARRIVAL_DEPARTURE_SELECTION)->SetDisplayedPlane(_settings_client.gui.timetable_arrival_departure ? 0 : SZSP_NONE);
this->GetWidget<NWidgetStacked>(WID_TV_EXPECTED_SELECTION)->SetDisplayedPlane(_settings_client.gui.timetable_arrival_departure ? 0 : 1);
this->GetWidget<NWidgetStacked>(WID_VT_ARRIVAL_DEPARTURE_SELECTION)->SetDisplayedPlane(_settings_client.gui.timetable_arrival_departure ? 0 : SZSP_NONE);
this->GetWidget<NWidgetStacked>(WID_VT_EXPECTED_SELECTION)->SetDisplayedPlane(_settings_client.gui.timetable_arrival_departure ? 0 : 1);
}
};
static const NWidgetPart _nested_timetable_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_TV_CAPTION), SetDataTip(STR_TIMETABLE_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TV_ORDER_VIEW), SetMinimalSize(61, 14), SetDataTip( STR_TIMETABLE_ORDER_VIEW, STR_TIMETABLE_ORDER_VIEW_TOOLTIP),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_VT_CAPTION), SetDataTip(STR_TIMETABLE_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VT_ORDER_VIEW), SetMinimalSize(61, 14), SetDataTip( STR_TIMETABLE_ORDER_VIEW, STR_TIMETABLE_ORDER_VIEW_TOOLTIP),
NWidget(WWT_SHADEBOX, COLOUR_GREY),
NWidget(WWT_STICKYBOX, COLOUR_GREY),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PANEL, COLOUR_GREY, WID_TV_TIMETABLE_PANEL), SetMinimalSize(388, 82), SetResize(1, 10), SetDataTip(STR_NULL, STR_TIMETABLE_TOOLTIP), SetScrollbar(WID_TV_SCROLLBAR), EndContainer(),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_TV_ARRIVAL_DEPARTURE_SELECTION),
NWidget(WWT_PANEL, COLOUR_GREY, WID_TV_ARRIVAL_DEPARTURE_PANEL), SetMinimalSize(110, 0), SetFill(0, 1), SetDataTip(STR_NULL, STR_TIMETABLE_TOOLTIP), SetScrollbar(WID_TV_SCROLLBAR), EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_VT_TIMETABLE_PANEL), SetMinimalSize(388, 82), SetResize(1, 10), SetDataTip(STR_NULL, STR_TIMETABLE_TOOLTIP), SetScrollbar(WID_VT_SCROLLBAR), EndContainer(),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_VT_ARRIVAL_DEPARTURE_SELECTION),
NWidget(WWT_PANEL, COLOUR_GREY, WID_VT_ARRIVAL_DEPARTURE_PANEL), SetMinimalSize(110, 0), SetFill(0, 1), SetDataTip(STR_NULL, STR_TIMETABLE_TOOLTIP), SetScrollbar(WID_VT_SCROLLBAR), EndContainer(),
EndContainer(),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_TV_SCROLLBAR),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_VT_SCROLLBAR),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_TV_SUMMARY_PANEL), SetMinimalSize(400, 22), SetResize(1, 0), EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_VT_SUMMARY_PANEL), SetMinimalSize(400, 22), SetResize(1, 0), EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
NWidget(NWID_VERTICAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TV_CHANGE_TIME), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_CHANGE_TIME, STR_TIMETABLE_WAIT_TIME_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TV_CLEAR_TIME), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_CLEAR_TIME, STR_TIMETABLE_CLEAR_TIME_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VT_CHANGE_TIME), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_CHANGE_TIME, STR_TIMETABLE_WAIT_TIME_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VT_CLEAR_TIME), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_CLEAR_TIME, STR_TIMETABLE_CLEAR_TIME_TOOLTIP),
EndContainer(),
NWidget(NWID_VERTICAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TV_START_DATE), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_STARTING_DATE, STR_TIMETABLE_STARTING_DATE_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TV_RESET_LATENESS), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_RESET_LATENESS, STR_TIMETABLE_RESET_LATENESS_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VT_START_DATE), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_STARTING_DATE, STR_TIMETABLE_STARTING_DATE_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VT_RESET_LATENESS), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_RESET_LATENESS, STR_TIMETABLE_RESET_LATENESS_TOOLTIP),
EndContainer(),
NWidget(NWID_VERTICAL, NC_EQUALSIZE),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TV_AUTOFILL), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_AUTOFILL, STR_TIMETABLE_AUTOFILL_TOOLTIP),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_TV_EXPECTED_SELECTION),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TV_EXPECTED), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_BLACK_STRING, STR_TIMETABLE_EXPECTED_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VT_AUTOFILL), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_TIMETABLE_AUTOFILL, STR_TIMETABLE_AUTOFILL_TOOLTIP),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_VT_EXPECTED_SELECTION),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VT_EXPECTED), SetResize(1, 0), SetFill(1, 1), SetDataTip(STR_BLACK_STRING, STR_TIMETABLE_EXPECTED_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_GREY), SetResize(1, 0), SetFill(1, 1), EndContainer(),
EndContainer(),
EndContainer(),
EndContainer(),
NWidget(NWID_VERTICAL, NC_EQUALSIZE),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_TV_SHARED_ORDER_LIST), SetFill(0, 1), SetDataTip(SPR_SHARED_ORDERS_ICON, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_VT_SHARED_ORDER_LIST), SetFill(0, 1), SetDataTip(SPR_SHARED_ORDERS_ICON, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP),
NWidget(WWT_RESIZEBOX, COLOUR_GREY), SetFill(0, 1),
EndContainer(),
EndContainer(),

@ -29,25 +29,25 @@ enum StationViewWidgets {
/** Widgets of the WC_STATION_LIST. */
enum StationListWidgets {
WID_SL_CAPTION, ///< Caption of the window.
WID_SL_LIST, ///< The main panel, list of stations.
WID_SL_SCROLLBAR, ///< Scrollbar next to the main panel.
WID_STL_CAPTION, ///< Caption of the window.
WID_STL_LIST, ///< The main panel, list of stations.
WID_STL_SCROLLBAR, ///< Scrollbar next to the main panel.
/* Vehicletypes need to be in order of StationFacility due to bit magic */
WID_SL_TRAIN, ///< 'TRAIN' button - list only facilities where is a railroad station.
WID_SL_TRUCK, ///< 'TRUCK' button - list only facilities where is a truck stop.
WID_SL_BUS, ///< 'BUS' button - list only facilities where is a bus stop.
WID_SL_AIRPLANE, ///< 'AIRPLANE' button - list only facilities where is an airport.
WID_SL_SHIP, ///< 'SHIP' button - list only facilities where is a dock.
WID_SL_FACILALL, ///< 'ALL' button - list all facilities.
WID_STL_TRAIN, ///< 'TRAIN' button - list only facilities where is a railroad station.
WID_STL_TRUCK, ///< 'TRUCK' button - list only facilities where is a truck stop.
WID_STL_BUS, ///< 'BUS' button - list only facilities where is a bus stop.
WID_STL_AIRPLANE, ///< 'AIRPLANE' button - list only facilities where is an airport.
WID_STL_SHIP, ///< 'SHIP' button - list only facilities where is a dock.
WID_STL_FACILALL, ///< 'ALL' button - list all facilities.
WID_SL_NOCARGOWAITING, ///< 'NO' button - list stations where no cargo is waiting.
WID_SL_CARGOALL, ///< 'ALL' button - list all stations.
WID_STL_NOCARGOWAITING, ///< 'NO' button - list stations where no cargo is waiting.
WID_STL_CARGOALL, ///< 'ALL' button - list all stations.
WID_SL_SORTBY, ///< 'Sort by' button - reverse sort direction.
WID_SL_SORTDROPBTN, ///< Dropdown button.
WID_STL_SORTBY, ///< 'Sort by' button - reverse sort direction.
WID_STL_SORTDROPBTN, ///< Dropdown button.
WID_SL_CARGOSTART, ///< Widget numbers used for list of cargo types (not present in _company_stations_widgets).
WID_STL_CARGOSTART, ///< Widget numbers used for list of cargo types (not present in _company_stations_widgets).
};
/** Widgets of the WC_SELECT_STATION. */

@ -13,22 +13,22 @@
#define WIDGETS_TIMETABLE_WIDGET_H
/** Widgets of the WC_VEHICLE_TIMETABLE. */
enum TimetableViewWidgets {
WID_TV_CAPTION, ///< Caption of the window.
WID_TV_ORDER_VIEW, ///< Order view.
WID_TV_TIMETABLE_PANEL, ///< Timetable panel.
WID_TV_ARRIVAL_DEPARTURE_PANEL, ///< Panel with the expected/scheduled arrivals.
WID_TV_SCROLLBAR, ///< Scrollbar for the panel.
WID_TV_SUMMARY_PANEL, ///< Summary panel.
WID_TV_START_DATE, ///< Start date button.
WID_TV_CHANGE_TIME, ///< Change time button.
WID_TV_CLEAR_TIME, ///< Clear time button.
WID_TV_RESET_LATENESS, ///< Reset lateness button.
WID_TV_AUTOFILL, ///< Autofill button.
WID_TV_EXPECTED, ///< Toggle between expected and scheduled arrivals.
WID_TV_SHARED_ORDER_LIST, ///< Show the shared order list.
WID_TV_ARRIVAL_DEPARTURE_SELECTION, ///< Disable/hide the arrival departure panel.
WID_TV_EXPECTED_SELECTION, ///< Disable/hide the expected selection button.
enum VehicleTimetableWidgets {
WID_VT_CAPTION, ///< Caption of the window.
WID_VT_ORDER_VIEW, ///< Order view.
WID_VT_TIMETABLE_PANEL, ///< Timetable panel.
WID_VT_ARRIVAL_DEPARTURE_PANEL, ///< Panel with the expected/scheduled arrivals.
WID_VT_SCROLLBAR, ///< Scrollbar for the panel.
WID_VT_SUMMARY_PANEL, ///< Summary panel.
WID_VT_START_DATE, ///< Start date button.
WID_VT_CHANGE_TIME, ///< Change time button.
WID_VT_CLEAR_TIME, ///< Clear time button.
WID_VT_RESET_LATENESS, ///< Reset lateness button.
WID_VT_AUTOFILL, ///< Autofill button.
WID_VT_EXPECTED, ///< Toggle between expected and scheduled arrivals.
WID_VT_SHARED_ORDER_LIST, ///< Show the shared order list.
WID_VT_ARRIVAL_DEPARTURE_SELECTION, ///< Disable/hide the arrival departure panel.
WID_VT_EXPECTED_SELECTION, ///< Disable/hide the expected selection button.
};
#endif /* WIDGETS_TIMETABLE_WIDGET_H */

Loading…
Cancel
Save