Merge commit '73bed054b87399484e39f6972d30f91a404daba8'
This commit is contained in:
@@ -177,13 +177,14 @@ static const StringID _order_conditional_condition[] = {
|
||||
INVALID_STRING_ID,
|
||||
};
|
||||
|
||||
extern uint ConvertSpeedToDisplaySpeed(uint speed);
|
||||
extern uint ConvertDisplaySpeedToSpeed(uint speed);
|
||||
extern uint ConvertSpeedToDisplaySpeed(uint speed, VehicleType type);
|
||||
extern uint ConvertDisplaySpeedToSpeed(uint speed, VehicleType type);
|
||||
|
||||
static const StringID _order_depot_action_dropdown[] = {
|
||||
STR_ORDER_DROP_GO_ALWAYS_DEPOT,
|
||||
STR_ORDER_DROP_SERVICE_DEPOT,
|
||||
STR_ORDER_DROP_HALT_DEPOT,
|
||||
STR_ORDER_DROP_UNBUNCH,
|
||||
INVALID_STRING_ID
|
||||
};
|
||||
|
||||
@@ -193,6 +194,8 @@ static int DepotActionStringIndex(const Order *order)
|
||||
return DA_STOP;
|
||||
} else if (order->GetDepotOrderType() & ODTFB_SERVICE) {
|
||||
return DA_SERVICE;
|
||||
} else if (order->GetDepotActionType() & ODATFB_UNBUNCH) {
|
||||
return DA_UNBUNCH;
|
||||
} else {
|
||||
return DA_ALWAYS_GO;
|
||||
}
|
||||
@@ -223,10 +226,12 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||
SpriteID sprite = rtl ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT;
|
||||
Dimension sprite_size = GetSpriteSize(sprite);
|
||||
if (v->cur_real_order_index == order_index) {
|
||||
DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
|
||||
DrawSprite(sprite, PAL_NONE, rtl ? right - 2 * sprite_size.width : left + sprite_size.width, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
|
||||
/* Draw two arrows before the next real order. */
|
||||
DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)GetCharacterHeight(FS_NORMAL) - (int)sprite_size.height) / 2);
|
||||
DrawSprite(sprite, PAL_NONE, rtl ? right - 2 * sprite_size.width : left + sprite_size.width, y + ((int)GetCharacterHeight(FS_NORMAL) - (int)sprite_size.height) / 2);
|
||||
} else if (v->cur_implicit_order_index == order_index) {
|
||||
DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
|
||||
/* Draw one arrow before the next implicit order; the next real order will still get two arrows. */
|
||||
DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)GetCharacterHeight(FS_NORMAL) - (int)sprite_size.height) / 2);
|
||||
}
|
||||
|
||||
TextColour colour = TC_BLACK;
|
||||
@@ -241,11 +246,12 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||
|
||||
SetDParam(5, STR_EMPTY);
|
||||
SetDParam(8, STR_EMPTY);
|
||||
SetDParam(9, STR_EMPTY);
|
||||
|
||||
/* Check range for aircraft. */
|
||||
if (v->type == VEH_AIRCRAFT && Aircraft::From(v)->GetRange() > 0 && order->IsGotoOrder()) {
|
||||
const Order *next = order->next != nullptr ? order->next : v->GetFirstOrder();
|
||||
if (GetOrderDistance(order, next, v) > Aircraft::From(v)->acache.cached_max_range_sqr) SetDParam(8, STR_ORDER_OUT_OF_RANGE);
|
||||
if (GetOrderDistance(order, next, v) > Aircraft::From(v)->acache.cached_max_range_sqr) SetDParam(9, STR_ORDER_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
switch (order->GetType()) {
|
||||
@@ -271,6 +277,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||
SetDParam(2, order->GetDestination());
|
||||
|
||||
if (timetable) {
|
||||
/* Show only wait time in the timetable window. */
|
||||
SetDParam(3, STR_EMPTY);
|
||||
|
||||
if (order->GetWaitTime() > 0) {
|
||||
@@ -278,12 +285,18 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||
SetTimetableParams(6, 7, order->GetWaitTime());
|
||||
}
|
||||
} else {
|
||||
/* Show non-stop, refit and stop location only in the order window. */
|
||||
SetDParam(3, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ? STR_EMPTY : _station_load_types[order->IsRefit()][unload][load]);
|
||||
if (order->IsRefit()) {
|
||||
SetDParam(4, order->IsAutoRefit() ? STR_ORDER_AUTO_REFIT_ANY : CargoSpec::Get(order->GetRefitCargo())->name);
|
||||
}
|
||||
if (v->type == VEH_TRAIN && (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) == 0) {
|
||||
SetDParam(5, order->GetStopLocation() + STR_ORDER_STOP_LOCATION_NEAR_END);
|
||||
/* Only show the stopping location if other than the default chosen by the player. */
|
||||
if (order->GetStopLocation() != (OrderStopLocation)(_settings_client.gui.stop_location)) {
|
||||
SetDParam(5, order->GetStopLocation() + STR_ORDER_STOP_LOCATION_NEAR_END);
|
||||
} else {
|
||||
SetDParam(5, STR_EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -291,6 +304,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||
|
||||
case OT_GOTO_DEPOT:
|
||||
if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
|
||||
/* Going to the nearest depot. */
|
||||
SetDParam(0, STR_ORDER_GO_TO_NEAREST_DEPOT_FORMAT);
|
||||
if (v->type == VEH_AIRCRAFT) {
|
||||
SetDParam(2, STR_ORDER_NEAREST_HANGAR);
|
||||
@@ -300,6 +314,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||
SetDParam(3, STR_ORDER_TRAIN_DEPOT + v->type);
|
||||
}
|
||||
} else {
|
||||
/* Going to a specific depot. */
|
||||
SetDParam(0, STR_ORDER_GO_TO_DEPOT_FORMAT);
|
||||
SetDParam(2, v->type);
|
||||
SetDParam(3, order->GetDestination());
|
||||
@@ -311,14 +326,22 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||
SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO : STR_ORDER_GO_TO);
|
||||
}
|
||||
|
||||
/* Do not show stopping in the depot in the timetable window. */
|
||||
if (!timetable && (order->GetDepotActionType() & ODATFB_HALT)) {
|
||||
SetDParam(5, STR_ORDER_STOP_ORDER);
|
||||
}
|
||||
|
||||
/* Do not show refitting in the depot in the timetable window. */
|
||||
if (!timetable && order->IsRefit()) {
|
||||
SetDParam(5, (order->GetDepotActionType() & ODATFB_HALT) ? STR_ORDER_REFIT_STOP_ORDER : STR_ORDER_REFIT_ORDER);
|
||||
SetDParam(6, CargoSpec::Get(order->GetRefitCargo())->name);
|
||||
}
|
||||
|
||||
/* Do not show unbunching in the depot in the timetable window. */
|
||||
if (!timetable && (order->GetDepotActionType() & ODATFB_UNBUNCH)) {
|
||||
SetDParam(8, STR_ORDER_WAIT_TO_UNBUNCH);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case OT_GOTO_WAYPOINT:
|
||||
@@ -337,7 +360,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||
SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
|
||||
|
||||
uint value = order->GetConditionValue();
|
||||
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
||||
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value, v->type);
|
||||
SetDParam(4, value);
|
||||
}
|
||||
|
||||
@@ -375,8 +398,17 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
||||
ODTFB_PART_OF_ORDERS,
|
||||
(_settings_client.gui.new_nonstop && v->IsGroundVehicle()) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
|
||||
|
||||
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
||||
|
||||
if (_ctrl_pressed) {
|
||||
/* Don't allow a new unbunching order if we already have one. */
|
||||
if (v->HasUnbunchingOrder()) {
|
||||
ShowErrorMessage(STR_ERROR_CAN_T_INSERT_NEW_ORDER, STR_ERROR_UNBUNCHING_ONLY_ONE_ALLOWED, WL_ERROR);
|
||||
/* Return an empty order to bail out. */
|
||||
order.Free();
|
||||
return order;
|
||||
} else {
|
||||
order.SetDepotActionType(ODATFB_UNBUNCH);
|
||||
}
|
||||
}
|
||||
return order;
|
||||
}
|
||||
|
||||
@@ -552,14 +584,11 @@ private:
|
||||
*/
|
||||
VehicleOrderID GetOrderFromPt(int y)
|
||||
{
|
||||
NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_O_ORDER_LIST);
|
||||
uint sel = (y - nwid->pos_y - WidgetDimensions::scaled.framerect.top) / nwid->resize_y; // Selected line in the WID_O_ORDER_LIST panel.
|
||||
|
||||
if (sel >= this->vscroll->GetCapacity()) return INVALID_VEH_ORDER_ID;
|
||||
|
||||
sel += this->vscroll->GetPosition();
|
||||
|
||||
return (sel <= vehicle->GetNumOrders()) ? sel : INVALID_VEH_ORDER_ID;
|
||||
int sel = this->vscroll->GetScrolledRowFromWidget(y, this, WID_O_ORDER_LIST, WidgetDimensions::scaled.framerect.top);
|
||||
if (sel == INT_MAX) return INVALID_VEH_ORDER_ID;
|
||||
/* One past the orders is the 'End of Orders' line. */
|
||||
assert(IsInsideBS(sel, 0, vehicle->GetNumOrders() + 1));
|
||||
return sel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -742,10 +771,10 @@ private:
|
||||
{
|
||||
if (_ctrl_pressed) {
|
||||
/* Cancel refitting */
|
||||
Command<CMD_ORDER_REFIT>::Post(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CT_NO_REFIT);
|
||||
Command<CMD_ORDER_REFIT>::Post(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CARGO_NO_REFIT);
|
||||
} else {
|
||||
if (i == 1) { // Auto-refit to available cargo type.
|
||||
Command<CMD_ORDER_REFIT>::Post(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CT_AUTO_REFIT);
|
||||
Command<CMD_ORDER_REFIT>::Post(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CARGO_AUTO_REFIT);
|
||||
} else {
|
||||
ShowVehicleRefitWindow(this->vehicle, this->OrderGetSel(), this, auto_refit);
|
||||
}
|
||||
@@ -770,10 +799,10 @@ public:
|
||||
|
||||
this->CreateNestedTree();
|
||||
this->vscroll = this->GetScrollbar(WID_O_SCROLLBAR);
|
||||
this->FinishInitNested(v->index);
|
||||
if (v->owner == _local_company) {
|
||||
this->DisableWidget(WID_O_EMPTY);
|
||||
if (NWidgetCore *nwid = this->GetWidget<NWidgetCore>(WID_O_DEPOT_ACTION); nwid != nullptr) {
|
||||
nwid->tool_tip = STR_ORDER_TRAIN_DEPOT_ACTION_TOOLTIP + v->type;
|
||||
}
|
||||
this->FinishInitNested(v->index);
|
||||
|
||||
this->selected_order = -1;
|
||||
this->order_over = INVALID_VEH_ORDER_ID;
|
||||
@@ -785,7 +814,7 @@ public:
|
||||
if (_settings_client.gui.quick_goto && v->owner == _local_company) {
|
||||
/* If there are less than 2 station, make Go To active. */
|
||||
int station_orders = 0;
|
||||
for(const Order *order : v->Orders()) {
|
||||
for (const Order *order : v->Orders()) {
|
||||
if (order->IsType(OT_GOTO_STATION)) station_orders++;
|
||||
}
|
||||
|
||||
@@ -794,11 +823,11 @@ public:
|
||||
this->OnInvalidateData(VIWD_MODIFY_ORDERS);
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_O_ORDER_LIST:
|
||||
resize->height = FONT_HEIGHT_NORMAL;
|
||||
resize->height = GetCharacterHeight(FS_NORMAL);
|
||||
size->height = 6 * resize->height + padding.height;
|
||||
break;
|
||||
|
||||
@@ -831,7 +860,7 @@ public:
|
||||
* @param data Information about the changed data.
|
||||
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
||||
*/
|
||||
void OnInvalidateData(int data = 0, bool gui_scope = true) override
|
||||
void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
|
||||
{
|
||||
VehicleOrderID from = INVALID_VEH_ORDER_ID;
|
||||
VehicleOrderID to = INVALID_VEH_ORDER_ID;
|
||||
@@ -840,7 +869,7 @@ public:
|
||||
case VIWD_AUTOREPLACE:
|
||||
/* Autoreplace replaced the vehicle */
|
||||
this->vehicle = Vehicle::Get(this->window_number);
|
||||
FALLTHROUGH;
|
||||
[[fallthrough]];
|
||||
|
||||
case VIWD_CONSIST_CHANGED:
|
||||
/* Vehicle composition was changed. */
|
||||
@@ -852,7 +881,6 @@ public:
|
||||
if (this->selected_order == -1) break;
|
||||
|
||||
this->CloseChildWindows();
|
||||
HideDropDownMenu(this);
|
||||
this->selected_order = -1;
|
||||
break;
|
||||
|
||||
@@ -884,7 +912,6 @@ public:
|
||||
if (to == INVALID_VEH_ORDER_ID) {
|
||||
/* Deleting selected order */
|
||||
this->CloseChildWindows();
|
||||
HideDropDownMenu(this);
|
||||
this->selected_order = -1;
|
||||
break;
|
||||
}
|
||||
@@ -939,7 +966,6 @@ public:
|
||||
/* First row. */
|
||||
this->RaiseWidget(WID_O_FULL_LOAD);
|
||||
this->RaiseWidget(WID_O_UNLOAD);
|
||||
this->RaiseWidget(WID_O_SERVICE);
|
||||
|
||||
/* Selection widgets. */
|
||||
/* Train or road vehicle. */
|
||||
@@ -1025,7 +1051,6 @@ public:
|
||||
this->SetWidgetDisabledState(WID_O_REFIT,
|
||||
(order->GetDepotOrderType() & ODTFB_SERVICE) || (order->GetDepotActionType() & ODATFB_HALT) ||
|
||||
(!this->can_do_refit && !order->IsRefit()));
|
||||
this->SetWidgetLoweredState(WID_O_SERVICE, order->GetDepotOrderType() & ODTFB_SERVICE);
|
||||
break;
|
||||
|
||||
case OT_CONDITIONAL: {
|
||||
@@ -1076,7 +1101,7 @@ public:
|
||||
this->DrawWidgets();
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
void DrawWidget(const Rect &r, WidgetID widget) const override
|
||||
{
|
||||
if (widget != WID_O_ORDER_LIST) return;
|
||||
|
||||
@@ -1135,7 +1160,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void SetStringParameters(int widget) const override
|
||||
void SetStringParameters(WidgetID widget) const override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_O_COND_VALUE: {
|
||||
@@ -1144,7 +1169,7 @@ public:
|
||||
|
||||
if (order != nullptr && order->IsType(OT_CONDITIONAL)) {
|
||||
uint value = order->GetConditionValue();
|
||||
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
||||
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value, this->vehicle->type);
|
||||
SetDParam(0, value);
|
||||
}
|
||||
break;
|
||||
@@ -1153,10 +1178,32 @@ public:
|
||||
case WID_O_CAPTION:
|
||||
SetDParam(0, this->vehicle->index);
|
||||
break;
|
||||
|
||||
case WID_O_DEPOT_ACTION: {
|
||||
VehicleOrderID sel = this->OrderGetSel();
|
||||
const Order *order = this->vehicle->GetOrder(sel);
|
||||
if (order == nullptr || !order->IsType(OT_GOTO_DEPOT)) {
|
||||
/* We can't leave this param unset or the undefined behavior can cause a crash. */
|
||||
SetDParam(0, STR_EMPTY);
|
||||
break;
|
||||
};
|
||||
|
||||
/* Select the current action selected in the dropdown. The flags don't match the dropdown so we can't just use an index. */
|
||||
if (order->GetDepotOrderType() & ODTFB_SERVICE) {
|
||||
SetDParam(0, STR_ORDER_DROP_SERVICE_DEPOT);
|
||||
} else if (order->GetDepotActionType() & ODATFB_HALT) {
|
||||
SetDParam(0, STR_ORDER_DROP_HALT_DEPOT);
|
||||
} else if (order->GetDepotActionType() & ODATFB_UNBUNCH) {
|
||||
SetDParam(0, STR_ORDER_DROP_UNBUNCH);
|
||||
} else {
|
||||
SetDParam(0, STR_ORDER_DROP_GO_ALWAYS_DEPOT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnClick(Point pt, int widget, int click_count) override
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_O_ORDER_LIST: {
|
||||
@@ -1184,7 +1231,6 @@ public:
|
||||
|
||||
/* This order won't be selected any more, close all child windows and dropdowns */
|
||||
this->CloseChildWindows();
|
||||
HideDropDownMenu(this);
|
||||
|
||||
if (sel == INVALID_VEH_ORDER_ID || this->vehicle->owner != _local_company) {
|
||||
/* Deselect clicked order */
|
||||
@@ -1226,6 +1272,7 @@ public:
|
||||
this->OrderClick_Nonstop(-1);
|
||||
} else {
|
||||
const Order *o = this->vehicle->GetOrder(this->OrderGetSel());
|
||||
assert(o != nullptr);
|
||||
ShowDropDownMenu(this, _order_non_stop_drowdown, o->GetNonStopType(), WID_O_NON_STOP, 0,
|
||||
o->IsType(OT_GOTO_STATION) ? 0 : (o->IsType(OT_GOTO_WAYPOINT) ? 3 : 12));
|
||||
}
|
||||
@@ -1271,12 +1318,8 @@ public:
|
||||
this->OrderClick_Refit(0, false);
|
||||
break;
|
||||
|
||||
case WID_O_SERVICE:
|
||||
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
||||
this->OrderClick_Service(-1);
|
||||
} else {
|
||||
ShowDropDownMenu(this, _order_depot_action_dropdown, DepotActionStringIndex(this->vehicle->GetOrder(this->OrderGetSel())), WID_O_SERVICE, 0, 0);
|
||||
}
|
||||
case WID_O_DEPOT_ACTION:
|
||||
ShowDropDownMenu(this, _order_depot_action_dropdown, DepotActionStringIndex(this->vehicle->GetOrder(this->OrderGetSel())), WID_O_DEPOT_ACTION, 0, 0);
|
||||
break;
|
||||
|
||||
case WID_O_REFIT_DROPDOWN:
|
||||
@@ -1294,7 +1337,7 @@ public:
|
||||
case WID_O_COND_VARIABLE: {
|
||||
DropDownList list;
|
||||
for (uint i = 0; i < lengthof(_order_conditional_variable); i++) {
|
||||
list.emplace_back(new DropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i], _order_conditional_variable[i], false));
|
||||
list.push_back(std::make_unique<DropDownListStringItem>(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i], _order_conditional_variable[i], false));
|
||||
}
|
||||
ShowDropDownList(this, std::move(list), this->vehicle->GetOrder(this->OrderGetSel())->GetConditionVariable(), WID_O_COND_VARIABLE);
|
||||
break;
|
||||
@@ -1302,14 +1345,16 @@ public:
|
||||
|
||||
case WID_O_COND_COMPARATOR: {
|
||||
const Order *o = this->vehicle->GetOrder(this->OrderGetSel());
|
||||
assert(o != nullptr);
|
||||
ShowDropDownMenu(this, _order_conditional_condition, o->GetConditionComparator(), WID_O_COND_COMPARATOR, 0, (o->GetConditionVariable() == OCV_REQUIRES_SERVICE) ? 0x3F : 0xC0);
|
||||
break;
|
||||
}
|
||||
|
||||
case WID_O_COND_VALUE: {
|
||||
const Order *order = this->vehicle->GetOrder(this->OrderGetSel());
|
||||
assert(order != nullptr);
|
||||
uint value = order->GetConditionValue();
|
||||
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
||||
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value, this->vehicle->type);
|
||||
SetDParam(0, value);
|
||||
ShowQueryString(STR_JUST_INT, STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, this, CS_NUMERAL, QSF_NONE);
|
||||
break;
|
||||
@@ -1329,7 +1374,7 @@ public:
|
||||
|
||||
switch (this->vehicle->GetOrder(sel)->GetConditionVariable()) {
|
||||
case OCV_MAX_SPEED:
|
||||
value = ConvertDisplaySpeedToSpeed(value);
|
||||
value = ConvertDisplaySpeedToSpeed(value, this->vehicle->type);
|
||||
break;
|
||||
|
||||
case OCV_RELIABILITY:
|
||||
@@ -1344,7 +1389,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void OnDropdownSelect(int widget, int index) override
|
||||
void OnDropdownSelect(WidgetID widget, int index) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_O_NON_STOP:
|
||||
@@ -1369,7 +1414,7 @@ public:
|
||||
}
|
||||
break;
|
||||
|
||||
case WID_O_SERVICE:
|
||||
case WID_O_DEPOT_ACTION:
|
||||
this->OrderClick_Service(index);
|
||||
break;
|
||||
|
||||
@@ -1387,7 +1432,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void OnDragDrop(Point pt, int widget) override
|
||||
void OnDragDrop(Point pt, WidgetID widget) override
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_O_ORDER_LIST: {
|
||||
@@ -1441,7 +1486,7 @@ public:
|
||||
return ES_HANDLED;
|
||||
}
|
||||
|
||||
void OnPlaceObject(Point pt, TileIndex tile) override
|
||||
void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
|
||||
{
|
||||
if (this->goto_type == OPOS_GOTO) {
|
||||
const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
|
||||
@@ -1518,7 +1563,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void OnMouseDrag(Point pt, int widget) override
|
||||
void OnMouseDrag(Point pt, WidgetID widget) override
|
||||
{
|
||||
if (this->selected_order != -1 && widget == WID_O_ORDER_LIST) {
|
||||
/* An order is dragged.. */
|
||||
@@ -1544,27 +1589,23 @@ public:
|
||||
this->vscroll->SetCapacityFromWidget(this, WID_O_ORDER_LIST);
|
||||
}
|
||||
|
||||
static HotkeyList hotkeys;
|
||||
static inline HotkeyList hotkeys{"order", {
|
||||
Hotkey('D', "skip", OHK_SKIP),
|
||||
Hotkey('F', "delete", OHK_DELETE),
|
||||
Hotkey('G', "goto", OHK_GOTO),
|
||||
Hotkey('H', "nonstop", OHK_NONSTOP),
|
||||
Hotkey('J', "fullload", OHK_FULLLOAD),
|
||||
Hotkey('K', "unload", OHK_UNLOAD),
|
||||
Hotkey(0, "nearest_depot", OHK_NEAREST_DEPOT),
|
||||
Hotkey(0, "always_service", OHK_ALWAYS_SERVICE),
|
||||
Hotkey(0, "transfer", OHK_TRANSFER),
|
||||
Hotkey(0, "no_unload", OHK_NO_UNLOAD),
|
||||
Hotkey(0, "no_load", OHK_NO_LOAD),
|
||||
}};
|
||||
};
|
||||
|
||||
static Hotkey order_hotkeys[] = {
|
||||
Hotkey('D', "skip", OHK_SKIP),
|
||||
Hotkey('F', "delete", OHK_DELETE),
|
||||
Hotkey('G', "goto", OHK_GOTO),
|
||||
Hotkey('H', "nonstop", OHK_NONSTOP),
|
||||
Hotkey('J', "fullload", OHK_FULLLOAD),
|
||||
Hotkey('K', "unload", OHK_UNLOAD),
|
||||
Hotkey((uint16)0, "nearest_depot", OHK_NEAREST_DEPOT),
|
||||
Hotkey((uint16)0, "always_service", OHK_ALWAYS_SERVICE),
|
||||
Hotkey((uint16)0, "transfer", OHK_TRANSFER),
|
||||
Hotkey((uint16)0, "no_unload", OHK_NO_UNLOAD),
|
||||
Hotkey((uint16)0, "no_load", OHK_NO_LOAD),
|
||||
HOTKEY_LIST_END
|
||||
};
|
||||
HotkeyList OrdersWindow::hotkeys("order", order_hotkeys);
|
||||
|
||||
/** Nested widget definition for "your" train orders. */
|
||||
static const NWidgetPart _nested_orders_train_widgets[] = {
|
||||
static constexpr NWidgetPart _nested_orders_train_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
@@ -1592,12 +1633,11 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_MIDDLE),
|
||||
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_UNLOAD), SetMinimalSize(93, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD), SetResize(1, 0),
|
||||
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_SERVICE), SetMinimalSize(93, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDER_SERVICE, STR_ORDER_SERVICE_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_DEPOT_ACTION), SetMinimalSize(93, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_JUST_STRING, STR_NULL), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_RIGHT),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_O_EMPTY), SetMinimalSize(93, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(93, 12), SetFill(1, 0), SetResize(1, 0), EndContainer(),
|
||||
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_REFIT_DROPDOWN), SetMinimalSize(93, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDER_REFIT_AUTO, STR_ORDER_REFIT_AUTO_TOOLTIP), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
@@ -1608,7 +1648,7 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_COND_VALUE), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_BLACK_COMMA, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP), SetResize(1, 0),
|
||||
SetDataTip(STR_JUST_COMMA, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_O_SHARED_ORDER_LIST), SetMinimalSize(12, 12), SetDataTip(SPR_SHARED_ORDERS_ICON, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP),
|
||||
@@ -1633,16 +1673,16 @@ static const NWidgetPart _nested_orders_train_widgets[] = {
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
static WindowDesc _orders_train_desc(
|
||||
static WindowDesc _orders_train_desc(__FILE__, __LINE__,
|
||||
WDP_AUTO, "view_vehicle_orders_train", 384, 100,
|
||||
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_orders_train_widgets, lengthof(_nested_orders_train_widgets),
|
||||
std::begin(_nested_orders_train_widgets), std::end(_nested_orders_train_widgets),
|
||||
&OrdersWindow::hotkeys
|
||||
);
|
||||
|
||||
/** Nested widget definition for "your" orders (non-train). */
|
||||
static const NWidgetPart _nested_orders_widgets[] = {
|
||||
static constexpr NWidgetPart _nested_orders_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
@@ -1671,8 +1711,8 @@ static const NWidgetPart _nested_orders_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_REFIT), SetMinimalSize(186, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_SERVICE), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_ORDER_SERVICE, STR_ORDER_SERVICE_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_DEPOT_ACTION), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_JUST_STRING, STR_NULL), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
|
||||
/* Buttons for setting a condition. */
|
||||
@@ -1682,7 +1722,7 @@ static const NWidgetPart _nested_orders_widgets[] = {
|
||||
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
|
||||
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_COND_VALUE), SetMinimalSize(124, 12), SetFill(1, 0),
|
||||
SetDataTip(STR_BLACK_COMMA, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP), SetResize(1, 0),
|
||||
SetDataTip(STR_JUST_COMMA, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP), SetResize(1, 0),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
||||
@@ -1706,16 +1746,16 @@ static const NWidgetPart _nested_orders_widgets[] = {
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
static WindowDesc _orders_desc(
|
||||
static WindowDesc _orders_desc(__FILE__, __LINE__,
|
||||
WDP_AUTO, "view_vehicle_orders", 384, 100,
|
||||
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_orders_widgets, lengthof(_nested_orders_widgets),
|
||||
std::begin(_nested_orders_widgets), std::end(_nested_orders_widgets),
|
||||
&OrdersWindow::hotkeys
|
||||
);
|
||||
|
||||
/** Nested widget definition for competitor orders. */
|
||||
static const NWidgetPart _nested_other_orders_widgets[] = {
|
||||
static constexpr NWidgetPart _nested_other_orders_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
@@ -1735,11 +1775,11 @@ static const NWidgetPart _nested_other_orders_widgets[] = {
|
||||
EndContainer(),
|
||||
};
|
||||
|
||||
static WindowDesc _other_orders_desc(
|
||||
static WindowDesc _other_orders_desc(__FILE__, __LINE__,
|
||||
WDP_AUTO, "view_vehicle_orders_competitor", 384, 86,
|
||||
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
||||
WDF_CONSTRUCTION,
|
||||
_nested_other_orders_widgets, lengthof(_nested_other_orders_widgets),
|
||||
std::begin(_nested_other_orders_widgets), std::end(_nested_other_orders_widgets),
|
||||
&OrdersWindow::hotkeys
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user