2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file order_gui.cpp GUI related to orders. */
|
2007-03-21 15:19:33 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "viewport_func.h"
|
2010-08-26 22:01:16 +00:00
|
|
|
#include "depot_map.h"
|
2009-12-02 17:37:02 +00:00
|
|
|
#include "roadveh.h"
|
2007-06-20 19:17:22 +00:00
|
|
|
#include "timetable.h"
|
2007-12-21 19:49:27 +00:00
|
|
|
#include "strings_func.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_func.h"
|
2011-08-30 20:21:01 +00:00
|
|
|
#include "widgets/dropdown_type.h"
|
2008-04-09 23:00:12 +00:00
|
|
|
#include "widgets/dropdown_func.h"
|
2008-04-12 11:58:19 +00:00
|
|
|
#include "textbuf_gui.h"
|
|
|
|
#include "string_func.h"
|
2008-05-07 13:10:15 +00:00
|
|
|
#include "tilehighlight_func.h"
|
2008-09-24 16:40:06 +00:00
|
|
|
#include "network/network.h"
|
2009-06-24 17:39:54 +00:00
|
|
|
#include "station_base.h"
|
2009-07-22 10:18:19 +00:00
|
|
|
#include "waypoint_base.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "core/geometry_func.hpp"
|
2010-07-03 13:29:19 +00:00
|
|
|
#include "hotkeys.h"
|
2011-12-13 00:43:48 +00:00
|
|
|
#include "aircraft.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2011-12-15 22:22:55 +00:00
|
|
|
#include "widgets/order_widget.h"
|
2008-01-13 01:21:35 +00:00
|
|
|
|
2007-01-24 18:22:31 +00:00
|
|
|
|
2008-04-09 22:01:23 +00:00
|
|
|
/** Order load types that could be given to station orders. */
|
2011-11-04 00:38:59 +00:00
|
|
|
static const StringID _station_load_types[][5][5] = {
|
2008-04-06 21:54:22 +00:00
|
|
|
{
|
2011-11-04 00:38:59 +00:00
|
|
|
/* No refitting. */
|
|
|
|
{
|
|
|
|
STR_EMPTY,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
STR_ORDER_FULL_LOAD,
|
|
|
|
STR_ORDER_FULL_LOAD_ANY,
|
|
|
|
STR_ORDER_NO_LOAD,
|
|
|
|
}, {
|
|
|
|
STR_ORDER_UNLOAD,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
STR_ORDER_UNLOAD_FULL_LOAD,
|
|
|
|
STR_ORDER_UNLOAD_FULL_LOAD_ANY,
|
|
|
|
STR_ORDER_UNLOAD_NO_LOAD,
|
|
|
|
}, {
|
|
|
|
STR_ORDER_TRANSFER,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
STR_ORDER_TRANSFER_FULL_LOAD,
|
|
|
|
STR_ORDER_TRANSFER_FULL_LOAD_ANY,
|
|
|
|
STR_ORDER_TRANSFER_NO_LOAD,
|
|
|
|
}, {
|
|
|
|
/* Unload and transfer do not work together. */
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
}, {
|
|
|
|
STR_ORDER_NO_UNLOAD,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
STR_ORDER_NO_UNLOAD_FULL_LOAD,
|
|
|
|
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
|
|
|
|
STR_ORDER_NO_UNLOAD_NO_LOAD,
|
|
|
|
}
|
2008-04-10 10:18:03 +00:00
|
|
|
}, {
|
2011-11-04 00:38:59 +00:00
|
|
|
/* With auto-refitting. No loading and auto-refitting do not work together. */
|
|
|
|
{
|
|
|
|
STR_ORDER_AUTO_REFIT,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
STR_ORDER_FULL_LOAD_REFIT,
|
|
|
|
STR_ORDER_FULL_LOAD_ANY_REFIT,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
}, {
|
|
|
|
STR_ORDER_UNLOAD_REFIT,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
STR_ORDER_UNLOAD_FULL_LOAD_REFIT,
|
|
|
|
STR_ORDER_UNLOAD_FULL_LOAD_ANY_REFIT,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
}, {
|
|
|
|
STR_ORDER_TRANSFER_REFIT,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
STR_ORDER_TRANSFER_FULL_LOAD_REFIT,
|
|
|
|
STR_ORDER_TRANSFER_FULL_LOAD_ANY_REFIT,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
}, {
|
|
|
|
/* Unload and transfer do not work together. */
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
}, {
|
|
|
|
STR_ORDER_NO_UNLOAD_REFIT,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
STR_ORDER_NO_UNLOAD_FULL_LOAD_REFIT,
|
|
|
|
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY_REFIT,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
}
|
2008-04-06 21:54:22 +00:00
|
|
|
}
|
2005-06-15 16:58:15 +00:00
|
|
|
};
|
|
|
|
|
2008-04-10 22:17:06 +00:00
|
|
|
static const StringID _order_non_stop_drowdown[] = {
|
|
|
|
STR_ORDER_GO_TO,
|
|
|
|
STR_ORDER_GO_NON_STOP_TO,
|
|
|
|
STR_ORDER_GO_VIA,
|
|
|
|
STR_ORDER_GO_NON_STOP_VIA,
|
|
|
|
INVALID_STRING_ID
|
|
|
|
};
|
|
|
|
|
|
|
|
static const StringID _order_full_load_drowdown[] = {
|
|
|
|
STR_ORDER_DROP_LOAD_IF_POSSIBLE,
|
|
|
|
STR_EMPTY,
|
|
|
|
STR_ORDER_DROP_FULL_LOAD_ALL,
|
|
|
|
STR_ORDER_DROP_FULL_LOAD_ANY,
|
|
|
|
STR_ORDER_DROP_NO_LOADING,
|
|
|
|
INVALID_STRING_ID
|
|
|
|
};
|
|
|
|
|
|
|
|
static const StringID _order_unload_drowdown[] = {
|
|
|
|
STR_ORDER_DROP_UNLOAD_IF_ACCEPTED,
|
|
|
|
STR_ORDER_DROP_UNLOAD,
|
|
|
|
STR_ORDER_DROP_TRANSFER,
|
|
|
|
STR_EMPTY,
|
|
|
|
STR_ORDER_DROP_NO_UNLOADING,
|
|
|
|
INVALID_STRING_ID
|
|
|
|
};
|
|
|
|
|
2008-04-11 15:58:46 +00:00
|
|
|
static const StringID _order_goto_dropdown[] = {
|
|
|
|
STR_ORDER_GO_TO,
|
|
|
|
STR_ORDER_GO_TO_NEAREST_DEPOT,
|
2008-04-12 11:58:19 +00:00
|
|
|
STR_ORDER_CONDITIONAL,
|
2010-12-11 13:38:35 +00:00
|
|
|
STR_ORDER_SHARE,
|
2008-04-11 15:58:46 +00:00
|
|
|
INVALID_STRING_ID
|
|
|
|
};
|
|
|
|
|
|
|
|
static const StringID _order_goto_dropdown_aircraft[] = {
|
|
|
|
STR_ORDER_GO_TO,
|
|
|
|
STR_ORDER_GO_TO_NEAREST_HANGAR,
|
2008-04-12 11:58:19 +00:00
|
|
|
STR_ORDER_CONDITIONAL,
|
2010-12-11 13:38:35 +00:00
|
|
|
STR_ORDER_SHARE,
|
2008-04-11 15:58:46 +00:00
|
|
|
INVALID_STRING_ID
|
|
|
|
};
|
|
|
|
|
2011-08-30 20:21:01 +00:00
|
|
|
/** Variables for conditional orders; this defines the order of appearance in the dropdown box */
|
|
|
|
static const OrderConditionVariable _order_conditional_variable[] = {
|
|
|
|
OCV_LOAD_PERCENTAGE,
|
|
|
|
OCV_RELIABILITY,
|
|
|
|
OCV_MAX_SPEED,
|
|
|
|
OCV_AGE,
|
|
|
|
OCV_REMAINING_LIFETIME,
|
|
|
|
OCV_REQUIRES_SERVICE,
|
|
|
|
OCV_UNCONDITIONALLY,
|
2008-04-12 11:58:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const StringID _order_conditional_condition[] = {
|
|
|
|
STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS,
|
|
|
|
STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS,
|
|
|
|
STR_ORDER_CONDITIONAL_COMPARATOR_LESS_THAN,
|
|
|
|
STR_ORDER_CONDITIONAL_COMPARATOR_LESS_EQUALS,
|
|
|
|
STR_ORDER_CONDITIONAL_COMPARATOR_MORE_THAN,
|
|
|
|
STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS,
|
|
|
|
STR_ORDER_CONDITIONAL_COMPARATOR_IS_TRUE,
|
|
|
|
STR_ORDER_CONDITIONAL_COMPARATOR_IS_FALSE,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
};
|
|
|
|
|
|
|
|
extern uint ConvertSpeedToDisplaySpeed(uint speed);
|
|
|
|
extern uint ConvertDisplaySpeedToSpeed(uint speed);
|
|
|
|
|
2008-10-24 14:49:45 +00:00
|
|
|
static const StringID _order_depot_action_dropdown[] = {
|
|
|
|
STR_ORDER_DROP_GO_ALWAYS_DEPOT,
|
|
|
|
STR_ORDER_DROP_SERVICE_DEPOT,
|
|
|
|
STR_ORDER_DROP_HALT_DEPOT,
|
|
|
|
INVALID_STRING_ID
|
|
|
|
};
|
|
|
|
|
|
|
|
static int DepotActionStringIndex(const Order *order)
|
|
|
|
{
|
|
|
|
if (order->GetDepotActionType() & ODATFB_HALT) {
|
|
|
|
return DA_STOP;
|
|
|
|
} else if (order->GetDepotOrderType() & ODTFB_SERVICE) {
|
|
|
|
return DA_SERVICE;
|
|
|
|
} else {
|
|
|
|
return DA_ALWAYS_GO;
|
|
|
|
}
|
|
|
|
}
|
2008-04-12 11:58:19 +00:00
|
|
|
|
2011-11-04 00:38:59 +00:00
|
|
|
static const StringID _order_refit_action_dropdown[] = {
|
|
|
|
STR_ORDER_DROP_REFIT_AUTO,
|
|
|
|
STR_ORDER_DROP_REFIT_AUTO_ANY,
|
|
|
|
INVALID_STRING_ID
|
|
|
|
};
|
|
|
|
|
2009-11-28 15:12:24 +00:00
|
|
|
/**
|
|
|
|
* Draws an order in order or timetable GUI
|
|
|
|
* @param v Vehicle the order belongs to
|
|
|
|
* @param order The order to draw
|
|
|
|
* @param order_index Index of the order in the orders of the vehicle
|
|
|
|
* @param y Y position for drawing
|
|
|
|
* @param selected True, if the order is selected
|
|
|
|
* @param timetable True, when drawing in the timetable GUI
|
|
|
|
* @param left Left border for text drawing
|
|
|
|
* @param middle X position between order index and order text
|
|
|
|
* @param right Right border for text drawing
|
|
|
|
*/
|
|
|
|
void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable, int left, int middle, int right)
|
2008-04-14 12:40:09 +00:00
|
|
|
{
|
2010-11-13 09:56:25 +00:00
|
|
|
bool rtl = _current_text_dir == TD_RTL;
|
2009-11-28 15:12:24 +00:00
|
|
|
|
|
|
|
SpriteID sprite = rtl ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT;
|
|
|
|
Dimension sprite_size = GetSpriteSize(sprite);
|
2011-01-31 20:44:15 +00:00
|
|
|
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);
|
2011-05-18 12:19:58 +00:00
|
|
|
} else if (v->cur_implicit_order_index == order_index) {
|
2011-01-31 20:44:15 +00:00
|
|
|
DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
|
2009-11-28 15:12:24 +00:00
|
|
|
}
|
|
|
|
|
2010-12-26 09:03:19 +00:00
|
|
|
TextColour colour = TC_BLACK;
|
2011-05-18 12:19:58 +00:00
|
|
|
if (order->IsType(OT_IMPLICIT)) {
|
2010-12-26 09:03:19 +00:00
|
|
|
colour = (selected ? TC_SILVER : TC_GREY) | TC_NO_SHADE;
|
|
|
|
} else if (selected) {
|
|
|
|
colour = TC_WHITE;
|
|
|
|
}
|
|
|
|
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(0, order_index + 1);
|
2011-01-31 20:44:15 +00:00
|
|
|
DrawString(left, rtl ? right - 2 * sprite_size.width - 3 : middle, y, STR_ORDER_INDEX, colour, SA_RIGHT | SA_FORCE);
|
2009-11-28 15:12:24 +00:00
|
|
|
|
|
|
|
SetDParam(5, STR_EMPTY);
|
2011-12-13 00:43:48 +00:00
|
|
|
SetDParam(8, STR_EMPTY);
|
|
|
|
|
|
|
|
/* Check range for aircraft. */
|
|
|
|
if (v->type == VEH_AIRCRAFT && Aircraft::From(v)->GetRange() > 0 && order->IsGotoOrder()) {
|
|
|
|
const Order *next = order->next != NULL ? order->next : v->GetFirstOrder();
|
|
|
|
if (GetOrderDistance(order, next, v) > Aircraft::From(v)->acache.cached_max_range_sqr) SetDParam(8, STR_ORDER_OUT_OF_RANGE);
|
|
|
|
}
|
2008-04-14 12:40:09 +00:00
|
|
|
|
|
|
|
switch (order->GetType()) {
|
|
|
|
case OT_DUMMY:
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(0, STR_INVALID_ORDER);
|
|
|
|
SetDParam(1, order->GetDestination());
|
2008-04-14 12:40:09 +00:00
|
|
|
break;
|
|
|
|
|
2011-05-18 12:19:58 +00:00
|
|
|
case OT_IMPLICIT:
|
2010-12-26 09:03:19 +00:00
|
|
|
SetDParam(0, STR_ORDER_GO_TO_STATION);
|
|
|
|
SetDParam(1, STR_ORDER_GO_TO);
|
|
|
|
SetDParam(2, order->GetDestination());
|
2011-05-18 12:19:58 +00:00
|
|
|
SetDParam(3, timetable ? STR_EMPTY : STR_ORDER_IMPLICIT);
|
2010-12-26 09:03:19 +00:00
|
|
|
break;
|
|
|
|
|
2008-04-14 12:40:09 +00:00
|
|
|
case OT_GOTO_STATION: {
|
|
|
|
OrderLoadFlags load = order->GetLoadType();
|
|
|
|
OrderUnloadFlags unload = order->GetUnloadType();
|
|
|
|
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(0, STR_ORDER_GO_TO_STATION);
|
2010-12-14 21:26:03 +00:00
|
|
|
SetDParam(1, STR_ORDER_GO_TO + (v->IsGroundVehicle() ? order->GetNonStopType() : 0));
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(2, order->GetDestination());
|
2008-04-14 12:40:09 +00:00
|
|
|
|
|
|
|
if (timetable) {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(3, STR_EMPTY);
|
2008-04-14 12:40:09 +00:00
|
|
|
|
|
|
|
if (order->wait_time > 0) {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(5, STR_TIMETABLE_STAY_FOR);
|
|
|
|
SetTimetableParams(6, 7, order->wait_time);
|
2008-04-14 12:40:09 +00:00
|
|
|
}
|
|
|
|
} else {
|
2011-11-04 00:38:59 +00:00
|
|
|
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);
|
|
|
|
}
|
2009-04-18 13:21:51 +00:00
|
|
|
if (v->type == VEH_TRAIN && (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) == 0) {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(5, order->GetStopLocation() + STR_ORDER_STOP_LOCATION_NEAR_END);
|
2009-04-12 14:11:14 +00:00
|
|
|
}
|
2008-04-14 12:40:09 +00:00
|
|
|
}
|
2010-08-01 18:53:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-14 12:40:09 +00:00
|
|
|
|
|
|
|
case OT_GOTO_DEPOT:
|
2010-05-12 18:19:36 +00:00
|
|
|
if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
|
|
|
|
SetDParam(0, STR_ORDER_GO_TO_NEAREST_DEPOT_FORMAT);
|
|
|
|
if (v->type == VEH_AIRCRAFT) {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(2, STR_ORDER_NEAREST_HANGAR);
|
2010-05-12 18:19:36 +00:00
|
|
|
SetDParam(3, STR_EMPTY);
|
2008-04-14 12:40:09 +00:00
|
|
|
} else {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(2, STR_ORDER_NEAREST_DEPOT);
|
2010-05-12 18:19:36 +00:00
|
|
|
SetDParam(3, STR_ORDER_TRAIN_DEPOT + v->type);
|
2008-04-14 12:40:09 +00:00
|
|
|
}
|
2010-05-12 18:19:36 +00:00
|
|
|
} else {
|
|
|
|
SetDParam(0, STR_ORDER_GO_TO_DEPOT_FORMAT);
|
|
|
|
SetDParam(2, v->type);
|
|
|
|
SetDParam(3, order->GetDestination());
|
2008-04-14 12:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (order->GetDepotOrderType() & ODTFB_SERVICE) {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_SERVICE_NON_STOP_AT : STR_ORDER_SERVICE_AT);
|
2008-04-14 12:40:09 +00:00
|
|
|
} else {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO : STR_ORDER_GO_TO);
|
2008-04-14 12:40:09 +00:00
|
|
|
}
|
|
|
|
|
2008-10-24 14:49:45 +00:00
|
|
|
if (!timetable && (order->GetDepotActionType() & ODATFB_HALT)) {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(5, STR_ORDER_STOP_ORDER);
|
2008-10-24 14:49:45 +00:00
|
|
|
}
|
|
|
|
|
2008-04-14 12:40:09 +00:00
|
|
|
if (!timetable && order->IsRefit()) {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(5, (order->GetDepotActionType() & ODATFB_HALT) ? STR_ORDER_REFIT_STOP_ORDER : STR_ORDER_REFIT_ORDER);
|
|
|
|
SetDParam(6, CargoSpec::Get(order->GetRefitCargo())->name);
|
2008-04-14 12:40:09 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OT_GOTO_WAYPOINT:
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(0, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO_WAYPOINT : STR_ORDER_GO_TO_WAYPOINT);
|
|
|
|
SetDParam(1, order->GetDestination());
|
2008-04-14 12:40:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OT_CONDITIONAL:
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(1, order->GetConditionSkipToOrder() + 1);
|
2008-04-14 12:40:09 +00:00
|
|
|
if (order->GetConditionVariable() == OCV_UNCONDITIONALLY) {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(0, STR_ORDER_CONDITIONAL_UNCONDITIONAL);
|
2008-04-14 12:40:09 +00:00
|
|
|
} else {
|
|
|
|
OrderConditionComparator occ = order->GetConditionComparator();
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(0, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_ORDER_CONDITIONAL_TRUE_FALSE : STR_ORDER_CONDITIONAL_NUM);
|
|
|
|
SetDParam(2, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable());
|
|
|
|
SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
|
2008-04-14 12:40:09 +00:00
|
|
|
|
|
|
|
uint value = order->GetConditionValue();
|
|
|
|
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(4, value);
|
2008-04-14 12:40:09 +00:00
|
|
|
}
|
2008-07-14 21:01:49 +00:00
|
|
|
|
|
|
|
if (timetable && order->wait_time > 0) {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(5, STR_TIMETABLE_AND_TRAVEL_FOR);
|
|
|
|
SetTimetableParams(6, 7, order->wait_time);
|
2008-07-14 21:01:49 +00:00
|
|
|
} else {
|
2009-11-28 15:12:24 +00:00
|
|
|
SetDParam(5, STR_EMPTY);
|
2008-07-14 21:01:49 +00:00
|
|
|
}
|
2008-04-14 12:40:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
|
2010-12-26 09:03:19 +00:00
|
|
|
DrawString(rtl ? left : middle, rtl ? middle : right, y, STR_ORDER_TEXT, colour);
|
2008-04-14 12:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-18 20:56:44 +00:00
|
|
|
static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2004-12-05 21:30:58 +00:00
|
|
|
Order order;
|
2006-03-31 09:08:02 +00:00
|
|
|
order.next = NULL;
|
|
|
|
order.index = 0;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
/* check depot first */
|
2011-02-04 15:13:20 +00:00
|
|
|
switch (GetTileType(tile)) {
|
|
|
|
case MP_RAILWAY:
|
|
|
|
if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_company)) {
|
|
|
|
if (IsRailDepot(tile)) {
|
2009-09-10 14:37:55 +00:00
|
|
|
order.MakeGoToDepot(GetDepotIndex(tile), ODTFB_PART_OF_ORDERS,
|
2009-05-02 00:10:24 +00:00
|
|
|
_settings_client.gui.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
|
2009-01-04 14:51:49 +00:00
|
|
|
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
2004-12-05 21:30:58 +00:00
|
|
|
return order;
|
2004-12-06 00:03:26 +00:00
|
|
|
}
|
2011-02-04 15:13:20 +00:00
|
|
|
}
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2011-02-04 15:13:20 +00:00
|
|
|
case MP_ROAD:
|
|
|
|
if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_company)) {
|
|
|
|
order.MakeGoToDepot(GetDepotIndex(tile), ODTFB_PART_OF_ORDERS,
|
|
|
|
_settings_client.gui.new_nonstop ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
|
|
|
|
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
|
|
|
return order;
|
|
|
|
}
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2011-02-04 15:13:20 +00:00
|
|
|
case MP_STATION:
|
|
|
|
if (v->type != VEH_AIRCRAFT) break;
|
|
|
|
if (IsHangar(tile) && IsTileOwner(tile, _local_company)) {
|
|
|
|
order.MakeGoToDepot(GetStationIndex(tile), ODTFB_PART_OF_ORDERS, ONSF_STOP_EVERYWHERE);
|
|
|
|
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
|
|
|
return order;
|
|
|
|
}
|
|
|
|
break;
|
2005-01-29 15:12:40 +00:00
|
|
|
|
2011-02-04 15:13:20 +00:00
|
|
|
case MP_WATER:
|
|
|
|
if (v->type != VEH_SHIP) break;
|
|
|
|
if (IsShipDepot(tile) && IsTileOwner(tile, _local_company)) {
|
|
|
|
order.MakeGoToDepot(GetDepotIndex(tile), ODTFB_PART_OF_ORDERS, ONSF_STOP_EVERYWHERE);
|
|
|
|
if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
|
|
|
|
return order;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
/* check waypoint */
|
2008-09-09 12:26:25 +00:00
|
|
|
if (IsRailWaypointTile(tile) &&
|
2007-03-08 16:27:54 +00:00
|
|
|
v->type == VEH_TRAIN &&
|
2008-09-30 20:39:50 +00:00
|
|
|
IsTileOwner(tile, _local_company)) {
|
2009-07-17 20:51:24 +00:00
|
|
|
order.MakeGoToWaypoint(Waypoint::GetByTile(tile)->index);
|
2009-01-04 14:51:49 +00:00
|
|
|
if (_settings_client.gui.new_nonstop != _ctrl_pressed) order.SetNonStopType(ONSF_NO_STOP_AT_ANY_STATION);
|
2004-12-05 21:30:58 +00:00
|
|
|
return order;
|
|
|
|
}
|
2004-09-27 14:30:17 +00:00
|
|
|
|
2009-07-22 08:59:57 +00:00
|
|
|
if ((IsBuoyTile(tile) && v->type == VEH_SHIP) || (IsRailWaypointTile(tile) && v->type == VEH_TRAIN)) {
|
2009-07-10 18:30:02 +00:00
|
|
|
order.MakeGoToWaypoint(GetStationIndex(tile));
|
|
|
|
return order;
|
|
|
|
}
|
|
|
|
|
2005-01-16 11:24:58 +00:00
|
|
|
if (IsTileType(tile, MP_STATION)) {
|
2006-03-24 08:55:08 +00:00
|
|
|
StationID st_index = GetStationIndex(tile);
|
2009-05-16 23:34:14 +00:00
|
|
|
const Station *st = Station::Get(st_index);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-02-04 16:45:07 +00:00
|
|
|
if (st->owner == _local_company || st->owner == OWNER_NONE) {
|
2004-08-09 17:04:08 +00:00
|
|
|
byte facil;
|
2008-04-09 16:16:04 +00:00
|
|
|
(facil = FACIL_DOCK, v->type == VEH_SHIP) ||
|
|
|
|
(facil = FACIL_TRAIN, v->type == VEH_TRAIN) ||
|
|
|
|
(facil = FACIL_AIRPORT, v->type == VEH_AIRCRAFT) ||
|
2009-12-02 17:37:02 +00:00
|
|
|
(facil = FACIL_BUS_STOP, v->type == VEH_ROAD && RoadVehicle::From(v)->IsBus()) ||
|
2008-04-09 16:16:04 +00:00
|
|
|
(facil = FACIL_TRUCK_STOP, 1);
|
2004-12-05 21:30:58 +00:00
|
|
|
if (st->facilities & facil) {
|
2008-04-05 23:36:54 +00:00
|
|
|
order.MakeGoToStation(st_index);
|
2009-01-04 14:51:49 +00:00
|
|
|
if (_ctrl_pressed) order.SetLoadType(OLF_FULL_LOAD_ANY);
|
2010-12-14 21:26:03 +00:00
|
|
|
if (_settings_client.gui.new_nonstop && v->IsGroundVehicle()) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
2009-04-12 14:11:14 +00:00
|
|
|
order.SetStopLocation(v->type == VEH_TRAIN ? (OrderStopLocation)(_settings_client.gui.stop_location) : OSL_PLATFORM_FAR_END);
|
2004-12-05 21:30:58 +00:00
|
|
|
return order;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
/* not found */
|
2007-03-08 21:39:34 +00:00
|
|
|
order.Free();
|
2004-12-05 21:30:58 +00:00
|
|
|
return order;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2010-08-01 19:22:34 +00:00
|
|
|
/**
|
|
|
|
* %Order window code for all vehicles.
|
2009-09-19 13:57:02 +00:00
|
|
|
*
|
|
|
|
* At the bottom of the window two button rows are located for changing the orders of the vehicle.
|
|
|
|
*
|
|
|
|
* \section top-row Top row
|
|
|
|
* The top-row is for manipulating an individual order. What row is displayed depends on the type of vehicle, and whether or not you are the owner of the vehicle.
|
|
|
|
*
|
|
|
|
* The top-row buttons of one of your trains or road vehicles is one of the following three cases:
|
|
|
|
* \verbatim
|
2011-11-04 00:38:56 +00:00
|
|
|
* +-----------------+-----------------+-----------------+-----------------+
|
2011-11-04 00:38:59 +00:00
|
|
|
* | NON-STOP | FULL_LOAD | UNLOAD | REFIT | (normal)
|
2011-11-04 00:38:56 +00:00
|
|
|
* +-----------------+-----+-----------+-----------+-----+-----------------+
|
|
|
|
* | COND_VAR | COND_COMPARATOR | COND_VALUE | (for conditional orders)
|
|
|
|
* +-----------------+-----+-----------+-----------+-----+-----------------+
|
|
|
|
* | NON-STOP | REFIT | SERVICE | (empty) | (for depot orders)
|
|
|
|
* +-----------------+-----------------+-----------------+-----------------+
|
2009-09-19 13:57:02 +00:00
|
|
|
* \endverbatim
|
|
|
|
*
|
|
|
|
* Airplanes and ships have one of the following three top-row button rows:
|
|
|
|
* \verbatim
|
2011-11-04 00:38:59 +00:00
|
|
|
* +-----------------+-----------------+-----------------+
|
|
|
|
* | FULL_LOAD | UNLOAD | REFIT | (normal)
|
|
|
|
* +-----------------+-----------------+-----------------+
|
2009-09-19 13:57:02 +00:00
|
|
|
* | COND_VAR | COND_COMPARATOR | COND_VALUE | (for conditional orders)
|
|
|
|
* +-----------------+--------+--------+-----------------+
|
|
|
|
* | REFIT | SERVICE | (for depot order)
|
|
|
|
* +--------------------------+--------------------------+
|
|
|
|
* \endverbatim
|
|
|
|
*
|
|
|
|
* \section bottom-row Bottom row
|
|
|
|
* The second row (the bottom row) is for manipulating the list of orders:
|
|
|
|
* \verbatim
|
|
|
|
* +-----------------+-----------------+-----------------+
|
|
|
|
* | SKIP | DELETE | GOTO |
|
|
|
|
* +-----------------+-----------------+-----------------+
|
|
|
|
* \endverbatim
|
|
|
|
*
|
|
|
|
* For vehicles of other companies, both button rows are not displayed.
|
|
|
|
*/
|
2008-05-16 20:08:20 +00:00
|
|
|
struct OrdersWindow : public Window {
|
2009-04-30 19:22:44 +00:00
|
|
|
private:
|
2008-05-16 20:08:20 +00:00
|
|
|
/** Under what reason are we using the PlaceObject functionality? */
|
|
|
|
enum OrderPlaceObjectState {
|
|
|
|
OPOS_GOTO,
|
|
|
|
OPOS_CONDITIONAL,
|
2010-12-11 13:38:35 +00:00
|
|
|
OPOS_SHARE,
|
2008-05-16 20:08:20 +00:00
|
|
|
};
|
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
/** Displayed planes of the #NWID_SELECTION widgets. */
|
|
|
|
enum DisplayPane {
|
2011-12-16 18:25:06 +00:00
|
|
|
/* WID_O_SEL_TOP_ROW_GROUNDVEHICLE */
|
2011-11-04 00:38:56 +00:00
|
|
|
DP_GROUNDVEHICLE_ROW_NORMAL = 0, ///< Display the row for normal/depot orders in the top row of the train/rv order window.
|
|
|
|
DP_GROUNDVEHICLE_ROW_CONDITIONAL = 1, ///< Display the row for conditional orders in the top row of the train/rv order window.
|
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
/* WID_O_SEL_TOP_LEFT */
|
2011-11-04 00:38:56 +00:00
|
|
|
DP_LEFT_LOAD = 0, ///< Display 'load' in the left button of the top row of the train/rv order window.
|
|
|
|
DP_LEFT_REFIT = 1, ///< Display 'refit' in the left button of the top row of the train/rv order window.
|
2009-09-19 13:57:02 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
/* WID_O_SEL_TOP_MIDDLE */
|
2011-11-04 00:38:56 +00:00
|
|
|
DP_MIDDLE_UNLOAD = 0, ///< Display 'unload' in the middle button of the top row of the train/rv order window.
|
|
|
|
DP_MIDDLE_SERVICE = 1, ///< Display 'service' in the middle button of the top row of the train/rv order window.
|
2009-09-19 13:57:02 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
/* WID_O_SEL_TOP_RIGHT */
|
2011-11-04 00:38:56 +00:00
|
|
|
DP_RIGHT_EMPTY = 0, ///< Display an empty panel in the right button of the top row of the train/rv order window.
|
2011-11-04 00:38:59 +00:00
|
|
|
DP_RIGHT_REFIT = 1, ///< Display 'refit' in the right button of the top row of the train/rv order window.
|
2009-09-19 13:57:02 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
/* WID_O_SEL_TOP_ROW */
|
2011-11-04 00:38:59 +00:00
|
|
|
DP_ROW_LOAD = 0, ///< Display 'load' / 'unload' / 'refit' buttons in the top row of the ship/airplane order window.
|
2009-09-19 13:57:02 +00:00
|
|
|
DP_ROW_DEPOT = 1, ///< Display 'refit' / 'service' buttons in the top row of the ship/airplane order window.
|
|
|
|
DP_ROW_CONDITIONAL = 2, ///< Display the conditional order buttons in the top row of the ship/airplane order window.
|
2010-12-11 10:52:45 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
/* WID_O_SEL_BOTTOM_MIDDLE */
|
2010-12-11 10:52:45 +00:00
|
|
|
DP_BOTTOM_MIDDLE_DELETE = 0, ///< Display 'delete' in the middle button of the bottom row of the vehicle order window.
|
|
|
|
DP_BOTTOM_MIDDLE_STOP_SHARING = 1, ///< Display 'stop sharing' in the middle button of the bottom row of the vehicle order window.
|
2009-09-19 13:57:02 +00:00
|
|
|
};
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
int selected_order;
|
2011-02-05 20:26:55 +00:00
|
|
|
VehicleOrderID order_over; ///< Order over which another order is dragged, \c INVALID_VEH_ORDER_ID if none.
|
2008-05-16 20:08:20 +00:00
|
|
|
OrderPlaceObjectState goto_type;
|
2009-09-19 13:57:02 +00:00
|
|
|
const Vehicle *vehicle; ///< Vehicle owning the orders being displayed and manipulated.
|
2010-08-12 08:37:01 +00:00
|
|
|
Scrollbar *vscroll;
|
2011-11-04 00:38:59 +00:00
|
|
|
bool can_do_autorefit; ///< Vehicle chain can be auto-refitted.
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* Return the memorised selected order.
|
2013-01-08 22:46:42 +00:00
|
|
|
* @return the memorised order if it is a valid one
|
2008-05-16 20:08:20 +00:00
|
|
|
* else return the number of orders
|
|
|
|
*/
|
2011-02-05 20:26:55 +00:00
|
|
|
VehicleOrderID OrderGetSel() const
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
|
|
|
int num = this->selected_order;
|
2009-01-03 13:20:32 +00:00
|
|
|
return (num >= 0 && num < vehicle->GetNumOrders()) ? num : vehicle->GetNumOrders();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* Calculate the selected order.
|
|
|
|
* The calculation is based on the relative (to the window) y click position and
|
|
|
|
* the position of the scrollbar.
|
|
|
|
*
|
|
|
|
* @param y Y-value of the click relative to the window origin
|
2011-02-05 20:26:55 +00:00
|
|
|
* @return The selected order if the order is valid, else return \c INVALID_VEH_ORDER_ID.
|
2008-05-16 20:08:20 +00:00
|
|
|
*/
|
2011-02-05 20:26:55 +00:00
|
|
|
VehicleOrderID GetOrderFromPt(int y)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_O_ORDER_LIST);
|
|
|
|
int sel = (y - nwid->pos_y - WD_FRAMERECT_TOP) / nwid->resize_y; // Selected line in the WID_O_ORDER_LIST panel.
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2011-02-05 20:26:55 +00:00
|
|
|
if ((uint)sel >= this->vscroll->GetCapacity()) return INVALID_VEH_ORDER_ID;
|
2008-05-16 20:08:20 +00:00
|
|
|
|
2010-08-12 08:37:01 +00:00
|
|
|
sel += this->vscroll->GetPosition();
|
2008-05-16 20:08:20 +00:00
|
|
|
|
2011-02-05 20:26:55 +00:00
|
|
|
return (sel <= vehicle->GetNumOrders() && sel >= 0) ? sel : INVALID_VEH_ORDER_ID;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the goto button.
|
2009-09-12 10:25:23 +00:00
|
|
|
* @param i Dummy parameter.
|
2008-05-16 20:08:20 +00:00
|
|
|
*/
|
2009-09-12 10:25:23 +00:00
|
|
|
void OrderClick_Goto(int i)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetDirty(WID_O_GOTO);
|
|
|
|
this->ToggleWidgetLoweredState(WID_O_GOTO);
|
|
|
|
if (this->IsWidgetLowered(WID_O_GOTO)) {
|
2010-09-06 14:14:09 +00:00
|
|
|
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_RECT | HT_VEHICLE, this);
|
2009-09-12 10:25:23 +00:00
|
|
|
this->goto_type = OPOS_GOTO;
|
2008-05-16 20:08:20 +00:00
|
|
|
} else {
|
|
|
|
ResetObjectToPlace();
|
|
|
|
}
|
2005-01-13 16:55:17 +00:00
|
|
|
}
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the full load button.
|
|
|
|
* @param load_type the way to load.
|
|
|
|
*/
|
2009-09-12 10:25:23 +00:00
|
|
|
void OrderClick_FullLoad(int load_type)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2009-09-12 10:25:23 +00:00
|
|
|
VehicleOrderID sel_ord = this->OrderGetSel();
|
|
|
|
const Order *order = this->vehicle->GetOrder(sel_ord);
|
2008-05-16 20:08:20 +00:00
|
|
|
|
|
|
|
if (order == NULL || order->GetLoadType() == load_type) return;
|
|
|
|
|
|
|
|
if (load_type < 0) {
|
2008-06-10 16:46:11 +00:00
|
|
|
load_type = order->GetLoadType() == OLF_LOAD_IF_POSSIBLE ? OLF_FULL_LOAD_ANY : OLF_LOAD_IF_POSSIBLE;
|
2008-04-10 08:30:15 +00:00
|
|
|
}
|
2010-08-19 20:39:12 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (load_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
2008-04-10 08:30:15 +00:00
|
|
|
}
|
2008-04-09 19:52:33 +00:00
|
|
|
|
2010-07-21 14:28:06 +00:00
|
|
|
/**
|
|
|
|
* Handle the 'no loading' hotkey
|
|
|
|
*/
|
|
|
|
void OrderHotkey_NoLoad(int i)
|
|
|
|
{
|
|
|
|
this->OrderClick_FullLoad(OLFB_NO_LOAD);
|
|
|
|
}
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the service.
|
|
|
|
*/
|
2009-09-12 10:25:23 +00:00
|
|
|
void OrderClick_Service(int i)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2009-09-12 10:25:23 +00:00
|
|
|
VehicleOrderID sel_ord = this->OrderGetSel();
|
2008-10-24 14:49:45 +00:00
|
|
|
|
|
|
|
if (i < 0) {
|
2009-09-12 10:25:23 +00:00
|
|
|
const Order *order = this->vehicle->GetOrder(sel_ord);
|
2008-10-24 14:49:45 +00:00
|
|
|
if (order == NULL) return;
|
|
|
|
i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE;
|
|
|
|
}
|
2010-08-19 20:39:12 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_DEPOT_ACTION | (i << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
2005-01-13 16:55:17 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the service in nearest depot button.
|
2009-09-12 10:25:23 +00:00
|
|
|
* @param i Dummy parameter.
|
2008-05-16 20:08:20 +00:00
|
|
|
*/
|
2009-09-12 10:25:23 +00:00
|
|
|
void OrderClick_NearestDepot(int i)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
|
|
|
Order order;
|
|
|
|
order.next = NULL;
|
|
|
|
order.index = 0;
|
2009-05-02 00:10:24 +00:00
|
|
|
order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS,
|
2010-12-14 21:26:03 +00:00
|
|
|
_settings_client.gui.new_nonstop && this->vehicle->IsGroundVehicle() ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
|
2008-05-16 20:08:20 +00:00
|
|
|
order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
|
2008-04-11 15:58:46 +00:00
|
|
|
|
2010-08-19 20:39:12 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
2008-04-11 15:58:46 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the conditional order button.
|
2009-09-12 10:25:23 +00:00
|
|
|
* @param i Dummy parameter.
|
2008-05-16 20:08:20 +00:00
|
|
|
*/
|
2009-09-12 10:25:23 +00:00
|
|
|
void OrderClick_Conditional(int i)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2011-12-16 18:25:06 +00:00
|
|
|
this->LowerWidget(WID_O_GOTO);
|
|
|
|
this->SetWidgetDirty(WID_O_GOTO);
|
2010-12-24 13:13:28 +00:00
|
|
|
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_NONE, this);
|
2009-09-12 10:25:23 +00:00
|
|
|
this->goto_type = OPOS_CONDITIONAL;
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
2008-04-12 11:58:19 +00:00
|
|
|
|
2010-12-11 13:38:35 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the share button.
|
|
|
|
* @param i Dummy parameter.
|
|
|
|
*/
|
|
|
|
void OrderClick_Share(int i)
|
|
|
|
{
|
2011-12-16 18:25:06 +00:00
|
|
|
this->LowerWidget(WID_O_GOTO);
|
|
|
|
this->SetWidgetDirty(WID_O_GOTO);
|
2010-12-24 13:13:28 +00:00
|
|
|
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_VEHICLE, this);
|
2010-12-11 13:38:35 +00:00
|
|
|
this->goto_type = OPOS_SHARE;
|
|
|
|
}
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the unload button.
|
|
|
|
*/
|
2009-09-12 10:25:23 +00:00
|
|
|
void OrderClick_Unload(int unload_type)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2009-09-12 10:25:23 +00:00
|
|
|
VehicleOrderID sel_ord = this->OrderGetSel();
|
|
|
|
const Order *order = this->vehicle->GetOrder(sel_ord);
|
2008-05-16 20:08:20 +00:00
|
|
|
|
|
|
|
if (order == NULL || order->GetUnloadType() == unload_type) return;
|
|
|
|
|
|
|
|
if (unload_type < 0) {
|
2008-06-10 16:46:11 +00:00
|
|
|
unload_type = order->GetUnloadType() == OUF_UNLOAD_IF_POSSIBLE ? OUFB_UNLOAD : OUF_UNLOAD_IF_POSSIBLE;
|
2008-04-10 10:18:03 +00:00
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
|
2010-08-19 20:39:12 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_UNLOAD | (unload_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
2010-10-15 18:15:01 +00:00
|
|
|
|
|
|
|
/* Transfer orders with leave empty as default */
|
|
|
|
if (unload_type == OUFB_TRANSFER) {
|
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (OLFB_NO_LOAD << 4), CMD_MODIFY_ORDER);
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetDirty(WID_O_FULL_LOAD);
|
2010-10-15 18:15:01 +00:00
|
|
|
}
|
2008-04-10 10:18:03 +00:00
|
|
|
}
|
|
|
|
|
2010-07-21 14:28:06 +00:00
|
|
|
/**
|
|
|
|
* Handle the transfer hotkey
|
|
|
|
*/
|
|
|
|
void OrderHotkey_Transfer(int i)
|
|
|
|
{
|
|
|
|
this->OrderClick_Unload(OUFB_TRANSFER);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the 'no unload' hotkey
|
|
|
|
*/
|
|
|
|
void OrderHotkey_NoUnload(int i)
|
|
|
|
{
|
|
|
|
this->OrderClick_Unload(OUFB_NO_UNLOAD);
|
|
|
|
}
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the nonstop button.
|
|
|
|
* @param non_stop what non-stop type to use; -1 to use the 'next' one.
|
|
|
|
*/
|
2009-09-12 10:25:23 +00:00
|
|
|
void OrderClick_Nonstop(int non_stop)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2010-12-14 21:26:03 +00:00
|
|
|
if (!this->vehicle->IsGroundVehicle()) return;
|
2010-04-08 15:29:20 +00:00
|
|
|
|
2009-09-12 10:25:23 +00:00
|
|
|
VehicleOrderID sel_ord = this->OrderGetSel();
|
|
|
|
const Order *order = this->vehicle->GetOrder(sel_ord);
|
2005-01-13 16:55:17 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
if (order == NULL || order->GetNonStopType() == non_stop) return;
|
2008-04-09 12:46:43 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/* Keypress if negative, so 'toggle' to the next */
|
|
|
|
if (non_stop < 0) {
|
2008-06-10 16:46:11 +00:00
|
|
|
non_stop = order->GetNonStopType() ^ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS;
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
2008-04-09 23:00:12 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetDirty(WID_O_NON_STOP);
|
2010-08-19 20:39:12 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_NON_STOP | non_stop << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
2008-04-09 23:00:12 +00:00
|
|
|
}
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the skip button.
|
2009-09-12 10:25:23 +00:00
|
|
|
* If ctrl is pressed, skip to selected order, else skip to current order + 1
|
|
|
|
* @param i Dummy parameter.
|
2008-05-16 20:08:20 +00:00
|
|
|
*/
|
2009-09-12 10:25:23 +00:00
|
|
|
void OrderClick_Skip(int i)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
|
|
|
/* Don't skip when there's nothing to skip */
|
2011-05-18 12:19:58 +00:00
|
|
|
if (_ctrl_pressed && this->vehicle->cur_implicit_order_index == this->OrderGetSel()) return;
|
2009-09-12 10:25:23 +00:00
|
|
|
if (this->vehicle->GetNumOrders() <= 1) return;
|
2007-06-04 19:32:45 +00:00
|
|
|
|
2011-05-18 12:19:58 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index, _ctrl_pressed ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders()),
|
2009-04-21 23:40:56 +00:00
|
|
|
CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER));
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
2005-01-13 16:55:17 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
2008-09-24 16:40:06 +00:00
|
|
|
* Handle the click on the delete button.
|
2009-09-12 10:25:23 +00:00
|
|
|
* @param i Dummy parameter.
|
2008-05-16 20:08:20 +00:00
|
|
|
*/
|
2009-09-12 10:25:23 +00:00
|
|
|
void OrderClick_Delete(int i)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2008-09-24 16:40:06 +00:00
|
|
|
/* When networking, move one order lower */
|
2009-09-12 10:25:23 +00:00
|
|
|
int selected = this->selected_order + (int)_networking;
|
2008-09-24 16:40:06 +00:00
|
|
|
|
2009-09-12 10:25:23 +00:00
|
|
|
if (DoCommandP(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CMD_DELETE_ORDER | CMD_MSG(STR_ERROR_CAN_T_DELETE_THIS_ORDER))) {
|
|
|
|
this->selected_order = selected >= this->vehicle->GetNumOrders() ? -1 : selected;
|
|
|
|
this->UpdateButtonState();
|
2008-09-24 16:40:06 +00:00
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
2005-01-13 16:55:17 +00:00
|
|
|
|
2010-12-11 10:52:45 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the 'stop sharing' button.
|
|
|
|
* If 'End of Shared Orders' isn't selected, do nothing. If Ctrl is pressed, call OrderClick_Delete and exit.
|
|
|
|
* To stop sharing this vehicle order list, we copy the orders of a vehicle that share this order list. That way we
|
|
|
|
* exit the group of shared vehicles while keeping the same order list.
|
|
|
|
* @param i Dummy parameter.
|
|
|
|
*/
|
|
|
|
void OrderClick_StopSharing(int i)
|
|
|
|
{
|
|
|
|
/* Don't try to stop sharing orders if 'End of Shared Orders' isn't selected. */
|
|
|
|
if (!this->vehicle->IsOrderListShared() || this->selected_order != this->vehicle->GetNumOrders()) return;
|
|
|
|
/* If Ctrl is pressed, delete the order list as if we clicked the 'Delete' button. */
|
|
|
|
if (_ctrl_pressed) {
|
2010-12-12 14:46:42 +00:00
|
|
|
this->OrderClick_Delete(0);
|
2010-12-11 10:52:45 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get another vehicle that share orders with this vehicle. */
|
|
|
|
Vehicle *other_shared = (this->vehicle->FirstShared() == this->vehicle) ? this->vehicle->NextShared() : this->vehicle->PreviousShared();
|
|
|
|
/* Copy the order list of the other vehicle. */
|
|
|
|
if (DoCommandP(this->vehicle->tile, this->vehicle->index | CO_COPY << 30, other_shared->index, CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST))) {
|
|
|
|
this->UpdateButtonState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the refit button.
|
2009-09-12 10:25:23 +00:00
|
|
|
* If ctrl is pressed, cancel refitting, else show the refit window.
|
2011-11-04 00:38:59 +00:00
|
|
|
* @param i Selected refit command.
|
|
|
|
* @param auto_refit Select refit for auto-refitting.
|
2008-05-16 20:08:20 +00:00
|
|
|
*/
|
2011-11-04 00:38:59 +00:00
|
|
|
void OrderClick_Refit(int i, bool auto_refit)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
|
|
|
if (_ctrl_pressed) {
|
|
|
|
/* Cancel refitting */
|
2009-09-12 10:25:23 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, CMD_ORDER_REFIT);
|
2008-05-16 20:08:20 +00:00
|
|
|
} else {
|
2011-11-04 00:38:59 +00:00
|
|
|
if (i == 1) { // Auto-refit to available cargo type.
|
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | CT_AUTO_REFIT, CMD_ORDER_REFIT);
|
|
|
|
} else {
|
|
|
|
ShowVehicleRefitWindow(this->vehicle, this->OrderGetSel(), this, auto_refit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Cache auto-refittability of the vehicle chain. */
|
|
|
|
void UpdateAutoRefitState()
|
|
|
|
{
|
|
|
|
this->can_do_autorefit = false;
|
|
|
|
for (const Vehicle *w = this->vehicle; w != NULL; w = w->Next()) {
|
|
|
|
if (HasBit(Engine::Get(w->engine_type)->info.misc_flags, EF_AUTO_REFIT)) this->can_do_autorefit = true;
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2013-05-26 19:23:42 +00:00
|
|
|
OrdersWindow(WindowDesc *desc, const Vehicle *v) : Window(desc)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2009-09-19 13:57:02 +00:00
|
|
|
this->vehicle = v;
|
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
this->CreateNestedTree();
|
2011-12-16 18:25:06 +00:00
|
|
|
this->vscroll = this->GetScrollbar(WID_O_SCROLLBAR);
|
2013-05-26 19:23:42 +00:00
|
|
|
this->FinishInitNested(v->index);
|
2011-11-09 11:44:12 +00:00
|
|
|
if (v->owner == _local_company) {
|
2011-12-16 18:25:06 +00:00
|
|
|
this->DisableWidget(WID_O_EMPTY);
|
2011-11-09 11:44:12 +00:00
|
|
|
}
|
2009-04-19 10:41:48 +00:00
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
this->selected_order = -1;
|
2011-02-05 20:26:55 +00:00
|
|
|
this->order_over = INVALID_VEH_ORDER_ID;
|
2009-02-09 02:33:10 +00:00
|
|
|
this->owner = v->owner;
|
2009-09-19 13:57:02 +00:00
|
|
|
|
2011-11-04 00:38:59 +00:00
|
|
|
this->UpdateAutoRefitState();
|
|
|
|
|
2009-01-22 00:08:15 +00:00
|
|
|
if (_settings_client.gui.quick_goto && v->owner == _local_company) {
|
2009-01-04 14:51:49 +00:00
|
|
|
/* If there are less than 2 station, make Go To active. */
|
|
|
|
int station_orders = 0;
|
|
|
|
const Order *order;
|
|
|
|
FOR_VEHICLE_ORDERS(v, order) {
|
|
|
|
if (order->IsType(OT_GOTO_STATION)) station_orders++;
|
|
|
|
}
|
|
|
|
|
2009-09-12 10:25:23 +00:00
|
|
|
if (station_orders < 2) this->OrderClick_Goto(0);
|
2009-01-04 14:51:49 +00:00
|
|
|
}
|
2012-12-20 19:44:02 +00:00
|
|
|
this->OnInvalidateData(VIWD_MODIFY_ORDERS);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2009-01-04 14:51:49 +00:00
|
|
|
|
2009-11-22 18:28:14 +00:00
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
2009-09-19 13:57:02 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_ORDER_LIST:
|
2009-09-19 13:57:02 +00:00
|
|
|
resize->height = FONT_HEIGHT_NORMAL;
|
|
|
|
size->height = 6 * resize->height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
|
|
|
break;
|
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_COND_VARIABLE: {
|
2009-09-19 13:57:02 +00:00
|
|
|
Dimension d = {0, 0};
|
2011-08-30 20:21:01 +00:00
|
|
|
for (uint i = 0; i < lengthof(_order_conditional_variable); i++) {
|
|
|
|
d = maxdim(d, GetStringBoundingBox(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i]));
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
|
|
|
d.width += padding.width;
|
|
|
|
d.height += padding.height;
|
|
|
|
*size = maxdim(*size, d);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_COND_COMPARATOR: {
|
2009-09-19 13:57:02 +00:00
|
|
|
Dimension d = {0, 0};
|
|
|
|
for (int i = 0; _order_conditional_condition[i] != INVALID_STRING_ID; i++) {
|
|
|
|
d = maxdim(d, GetStringBoundingBox(_order_conditional_condition[i]));
|
|
|
|
}
|
|
|
|
d.width += padding.width;
|
|
|
|
d.height += padding.height;
|
|
|
|
*size = maxdim(*size, d);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-10-03 14:52:39 +00:00
|
|
|
}
|
|
|
|
|
2011-03-13 21:31:29 +00:00
|
|
|
/**
|
|
|
|
* Some data on this window has become invalid.
|
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
2008-08-06 19:00:31 +00:00
|
|
|
{
|
2011-03-13 10:43:41 +00:00
|
|
|
VehicleOrderID from = INVALID_VEH_ORDER_ID;
|
|
|
|
VehicleOrderID to = INVALID_VEH_ORDER_ID;
|
2010-12-10 22:32:53 +00:00
|
|
|
|
2008-09-24 16:40:06 +00:00
|
|
|
switch (data) {
|
2012-12-20 19:44:02 +00:00
|
|
|
case VIWD_AUTOREPLACE:
|
2008-09-24 16:40:06 +00:00
|
|
|
/* Autoreplace replaced the vehicle */
|
2009-05-16 23:34:14 +00:00
|
|
|
this->vehicle = Vehicle::Get(this->window_number);
|
2012-12-20 19:44:06 +00:00
|
|
|
/* FALL THROUGH */
|
|
|
|
|
|
|
|
case VIWD_CONSIST_CHANGED:
|
|
|
|
/* Vehicle composition was changed. */
|
2011-11-04 00:38:59 +00:00
|
|
|
this->UpdateAutoRefitState();
|
2008-09-24 16:40:06 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-20 19:44:02 +00:00
|
|
|
case VIWD_REMOVE_ALL_ORDERS:
|
2008-09-24 16:40:06 +00:00
|
|
|
/* Removed / replaced all orders (after deleting / sharing) */
|
|
|
|
if (this->selected_order == -1) break;
|
|
|
|
|
|
|
|
this->DeleteChildWindows();
|
|
|
|
HideDropDownMenu(this);
|
|
|
|
this->selected_order = -1;
|
|
|
|
break;
|
|
|
|
|
2012-12-20 19:44:02 +00:00
|
|
|
case VIWD_MODIFY_ORDERS:
|
2009-09-02 17:54:40 +00:00
|
|
|
/* Some other order changes */
|
|
|
|
break;
|
|
|
|
|
2010-12-10 22:32:53 +00:00
|
|
|
default:
|
2011-03-13 10:43:41 +00:00
|
|
|
if (data < 0) break;
|
2011-03-13 21:33:57 +00:00
|
|
|
|
|
|
|
if (gui_scope) break; // only do this once; from command scope
|
2011-03-13 10:43:41 +00:00
|
|
|
from = GB(data, 0, 8);
|
|
|
|
to = GB(data, 8, 8);
|
2008-09-24 16:40:06 +00:00
|
|
|
/* Moving an order. If one of these is INVALID_VEH_ORDER_ID, then
|
|
|
|
* the order is being created / removed */
|
|
|
|
if (this->selected_order == -1) break;
|
|
|
|
|
|
|
|
if (from == to) break; // no need to change anything
|
|
|
|
|
|
|
|
if (from != this->selected_order) {
|
2010-02-01 12:43:28 +00:00
|
|
|
/* Moving from preceding order? */
|
2008-09-24 16:40:06 +00:00
|
|
|
this->selected_order -= (int)(from <= this->selected_order);
|
2010-02-01 12:43:28 +00:00
|
|
|
/* Moving to preceding order? */
|
2008-09-24 16:40:06 +00:00
|
|
|
this->selected_order += (int)(to <= this->selected_order);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now we are modifying the selected order */
|
|
|
|
if (to == INVALID_VEH_ORDER_ID) {
|
|
|
|
/* Deleting selected order */
|
|
|
|
this->DeleteChildWindows();
|
|
|
|
HideDropDownMenu(this);
|
|
|
|
this->selected_order = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Moving selected order */
|
|
|
|
this->selected_order = to;
|
2010-08-01 18:53:30 +00:00
|
|
|
break;
|
2008-09-24 16:40:06 +00:00
|
|
|
}
|
2009-09-02 17:54:40 +00:00
|
|
|
|
2010-08-12 08:37:01 +00:00
|
|
|
this->vscroll->SetCount(this->vehicle->GetNumOrders() + 1);
|
2011-03-13 21:33:02 +00:00
|
|
|
if (gui_scope) this->UpdateButtonState();
|
2010-12-10 22:32:53 +00:00
|
|
|
|
|
|
|
/* Scroll to the new order. */
|
|
|
|
if (from == INVALID_VEH_ORDER_ID && to != INVALID_VEH_ORDER_ID && !this->vscroll->IsVisible(to)) {
|
|
|
|
this->vscroll->ScrollTowards(to);
|
|
|
|
}
|
2008-08-06 19:00:31 +00:00
|
|
|
}
|
|
|
|
|
2009-09-02 17:54:40 +00:00
|
|
|
void UpdateButtonState()
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2009-09-19 13:57:02 +00:00
|
|
|
if (this->vehicle->owner != _local_company) return; // No buttons are displayed with competitor order windows.
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
bool shared_orders = this->vehicle->IsOrderListShared();
|
2011-02-05 20:26:55 +00:00
|
|
|
VehicleOrderID sel = this->OrderGetSel();
|
2009-05-23 12:27:42 +00:00
|
|
|
const Order *order = this->vehicle->GetOrder(sel);
|
2008-05-16 20:08:20 +00:00
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
/* Second row. */
|
|
|
|
/* skip */
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetDisabledState(WID_O_SKIP, this->vehicle->GetNumOrders() <= 1);
|
2005-01-13 16:55:17 +00:00
|
|
|
|
2010-12-11 10:52:45 +00:00
|
|
|
/* delete / stop sharing */
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidgetStacked *delete_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_BOTTOM_MIDDLE);
|
2010-12-11 10:52:45 +00:00
|
|
|
if (shared_orders && this->selected_order == this->vehicle->GetNumOrders()) {
|
|
|
|
/* The 'End of Shared Orders' order is selected, show the 'stop sharing' button. */
|
|
|
|
delete_sel->SetDisplayedPlane(DP_BOTTOM_MIDDLE_STOP_SHARING);
|
|
|
|
} else {
|
|
|
|
/* The 'End of Shared Orders' order isn't selected, show the 'delete' button. */
|
|
|
|
delete_sel->SetDisplayedPlane(DP_BOTTOM_MIDDLE_DELETE);
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetDisabledState(WID_O_DELETE,
|
2009-09-19 13:57:02 +00:00
|
|
|
(uint)this->vehicle->GetNumOrders() + ((shared_orders || this->vehicle->GetNumOrders() != 0) ? 1 : 0) <= (uint)this->selected_order);
|
2010-12-12 14:46:42 +00:00
|
|
|
|
|
|
|
/* Set the tooltip of the 'delete' button depending on whether the
|
|
|
|
* 'End of Orders' order or a regular order is selected. */
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_O_DELETE);
|
2010-12-12 14:46:42 +00:00
|
|
|
if (this->selected_order == this->vehicle->GetNumOrders()) {
|
|
|
|
nwi->SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_ALL_TOOLTIP);
|
|
|
|
} else {
|
|
|
|
nwi->SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP);
|
|
|
|
}
|
2010-12-11 10:52:45 +00:00
|
|
|
}
|
2005-01-13 16:55:17 +00:00
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
/* First row. */
|
2011-12-16 18:25:06 +00:00
|
|
|
this->RaiseWidget(WID_O_FULL_LOAD);
|
|
|
|
this->RaiseWidget(WID_O_UNLOAD);
|
|
|
|
this->RaiseWidget(WID_O_SERVICE);
|
2008-06-10 16:46:11 +00:00
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
/* Selection widgets. */
|
|
|
|
/* Train or road vehicle. */
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidgetStacked *train_row_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_ROW_GROUNDVEHICLE);
|
|
|
|
NWidgetStacked *left_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_LEFT);
|
|
|
|
NWidgetStacked *middle_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_MIDDLE);
|
|
|
|
NWidgetStacked *right_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_RIGHT);
|
2009-09-19 13:57:02 +00:00
|
|
|
/* Ship or airplane. */
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidgetStacked *row_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_ROW);
|
2011-11-04 00:38:56 +00:00
|
|
|
assert(row_sel != NULL || (train_row_sel != NULL && left_sel != NULL && middle_sel != NULL && right_sel != NULL));
|
2009-09-19 13:57:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (order == NULL) {
|
|
|
|
if (row_sel != NULL) {
|
|
|
|
row_sel->SetDisplayedPlane(DP_ROW_LOAD);
|
|
|
|
} else {
|
2011-11-04 00:38:56 +00:00
|
|
|
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
|
|
|
|
left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
|
|
|
|
middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
|
|
|
|
right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
|
2011-12-16 18:25:06 +00:00
|
|
|
this->DisableWidget(WID_O_NON_STOP);
|
|
|
|
this->RaiseWidget(WID_O_NON_STOP);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2011-12-16 18:25:06 +00:00
|
|
|
this->DisableWidget(WID_O_FULL_LOAD);
|
|
|
|
this->DisableWidget(WID_O_UNLOAD);
|
|
|
|
this->DisableWidget(WID_O_REFIT_DROPDOWN);
|
2009-09-19 13:57:02 +00:00
|
|
|
} else {
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetDisabledState(WID_O_FULL_LOAD, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // full load
|
|
|
|
this->SetWidgetDisabledState(WID_O_UNLOAD, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload
|
2009-09-19 13:57:02 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
switch (order->GetType()) {
|
|
|
|
case OT_GOTO_STATION:
|
2009-09-19 13:57:02 +00:00
|
|
|
if (row_sel != NULL) {
|
|
|
|
row_sel->SetDisplayedPlane(DP_ROW_LOAD);
|
|
|
|
} else {
|
2011-11-04 00:38:56 +00:00
|
|
|
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
|
|
|
|
left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
|
|
|
|
middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
|
2011-11-04 00:38:59 +00:00
|
|
|
right_sel->SetDisplayedPlane(DP_RIGHT_REFIT);
|
2011-12-16 18:25:06 +00:00
|
|
|
this->EnableWidget(WID_O_NON_STOP);
|
|
|
|
this->SetWidgetLoweredState(WID_O_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetLoweredState(WID_O_FULL_LOAD, order->GetLoadType() == OLF_FULL_LOAD_ANY);
|
|
|
|
this->SetWidgetLoweredState(WID_O_UNLOAD, order->GetUnloadType() == OUFB_UNLOAD);
|
2011-11-04 00:38:59 +00:00
|
|
|
|
|
|
|
/* Can only do refitting when stopping at the destination and loading cargo. */
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetDisabledState(WID_O_REFIT_DROPDOWN, !this->can_do_autorefit || order->GetLoadType() == OLFB_NO_LOAD || order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION);
|
2011-11-04 00:38:59 +00:00
|
|
|
|
2009-07-22 08:59:57 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
case OT_GOTO_WAYPOINT:
|
2009-09-19 13:57:02 +00:00
|
|
|
if (row_sel != NULL) {
|
|
|
|
row_sel->SetDisplayedPlane(DP_ROW_LOAD);
|
|
|
|
} else {
|
2011-11-04 00:38:56 +00:00
|
|
|
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
|
|
|
|
left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
|
|
|
|
middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
|
|
|
|
right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
|
2011-12-16 18:25:06 +00:00
|
|
|
this->EnableWidget(WID_O_NON_STOP);
|
|
|
|
this->SetWidgetLoweredState(WID_O_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2011-12-16 18:25:06 +00:00
|
|
|
this->DisableWidget(WID_O_FULL_LOAD);
|
|
|
|
this->DisableWidget(WID_O_UNLOAD);
|
|
|
|
this->DisableWidget(WID_O_REFIT_DROPDOWN);
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2008-04-09 16:16:04 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
case OT_GOTO_DEPOT:
|
2009-09-19 13:57:02 +00:00
|
|
|
if (row_sel != NULL) {
|
|
|
|
row_sel->SetDisplayedPlane(DP_ROW_DEPOT);
|
|
|
|
} else {
|
2011-11-04 00:38:56 +00:00
|
|
|
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
|
|
|
|
left_sel->SetDisplayedPlane(DP_LEFT_REFIT);
|
|
|
|
middle_sel->SetDisplayedPlane(DP_MIDDLE_SERVICE);
|
|
|
|
right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
|
2011-12-16 18:25:06 +00:00
|
|
|
this->EnableWidget(WID_O_NON_STOP);
|
|
|
|
this->SetWidgetLoweredState(WID_O_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2011-07-02 16:45:54 +00:00
|
|
|
/* Disable refit button if the order is no 'always go' order.
|
|
|
|
* However, keep the service button enabled for refit-orders to allow clearing refits (without knowing about ctrl). */
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetDisabledState(WID_O_REFIT, (order->GetDepotOrderType() & ODTFB_SERVICE) || (order->GetDepotActionType() & ODATFB_HALT));
|
|
|
|
this->SetWidgetLoweredState(WID_O_SERVICE, order->GetDepotOrderType() & ODTFB_SERVICE);
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2006-10-03 14:52:39 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
case OT_CONDITIONAL: {
|
2009-09-19 13:57:02 +00:00
|
|
|
if (row_sel != NULL) {
|
|
|
|
row_sel->SetDisplayedPlane(DP_ROW_CONDITIONAL);
|
|
|
|
} else {
|
2011-11-04 00:38:56 +00:00
|
|
|
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_CONDITIONAL);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
OrderConditionVariable ocv = order->GetConditionVariable();
|
2009-09-19 13:57:02 +00:00
|
|
|
/* Set the strings for the dropdown boxes. */
|
2011-12-16 18:25:06 +00:00
|
|
|
this->GetWidget<NWidgetCore>(WID_O_COND_VARIABLE)->widget_data = STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + (order == NULL ? 0 : ocv);
|
|
|
|
this->GetWidget<NWidgetCore>(WID_O_COND_COMPARATOR)->widget_data = _order_conditional_condition[order == NULL ? 0 : order->GetConditionComparator()];
|
|
|
|
this->SetWidgetDisabledState(WID_O_COND_COMPARATOR, ocv == OCV_UNCONDITIONALLY);
|
|
|
|
this->SetWidgetDisabledState(WID_O_COND_VALUE, ocv == OCV_REQUIRES_SERVICE || ocv == OCV_UNCONDITIONALLY);
|
2009-09-19 13:57:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
default: // every other order
|
|
|
|
if (row_sel != NULL) {
|
|
|
|
row_sel->SetDisplayedPlane(DP_ROW_LOAD);
|
|
|
|
} else {
|
2011-11-04 00:38:56 +00:00
|
|
|
train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
|
|
|
|
left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
|
|
|
|
middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
|
|
|
|
right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
|
2011-12-16 18:25:06 +00:00
|
|
|
this->DisableWidget(WID_O_NON_STOP);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2011-12-16 18:25:06 +00:00
|
|
|
this->DisableWidget(WID_O_FULL_LOAD);
|
|
|
|
this->DisableWidget(WID_O_UNLOAD);
|
|
|
|
this->DisableWidget(WID_O_REFIT_DROPDOWN);
|
2009-09-02 17:54:40 +00:00
|
|
|
break;
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
/* Disable list of vehicles with the same shared orders if there is no list */
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetDisabledState(WID_O_SHARED_ORDER_LIST, !shared_orders);
|
2009-09-19 13:57:02 +00:00
|
|
|
|
2009-09-02 17:54:40 +00:00
|
|
|
this->SetDirty();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
2009-12-22 10:28:58 +00:00
|
|
|
if (this->vehicle->owner != _local_company) this->selected_order = -1; // Disable selection any selected row at a competitor order window.
|
2008-05-17 12:48:06 +00:00
|
|
|
this->DrawWidgets();
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2006-06-27 21:25:53 +00:00
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
|
{
|
2011-12-16 18:25:06 +00:00
|
|
|
if (widget != WID_O_ORDER_LIST) return;
|
2009-09-19 13:57:02 +00:00
|
|
|
|
2010-11-13 09:56:25 +00:00
|
|
|
bool rtl = _current_text_dir == TD_RTL;
|
2012-12-08 17:18:51 +00:00
|
|
|
SetDParamMaxValue(0, this->vehicle->GetNumOrders(), 2);
|
2011-01-31 20:44:15 +00:00
|
|
|
int index_column_width = GetStringBoundingBox(STR_ORDER_INDEX).width + 2 * GetSpriteSize(rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT).width + 3;
|
2009-11-28 15:12:24 +00:00
|
|
|
int middle = rtl ? r.right - WD_FRAMETEXT_RIGHT - index_column_width : r.left + WD_FRAMETEXT_LEFT + index_column_width;
|
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
int y = r.top + WD_FRAMERECT_TOP;
|
2011-12-16 18:25:06 +00:00
|
|
|
int line_height = this->GetWidget<NWidgetBase>(WID_O_ORDER_LIST)->resize_y;
|
2004-08-13 20:30:45 +00:00
|
|
|
|
2010-08-12 08:37:01 +00:00
|
|
|
int i = this->vscroll->GetPosition();
|
2009-09-19 13:57:02 +00:00
|
|
|
const Order *order = this->vehicle->GetOrder(i);
|
2010-05-23 15:06:44 +00:00
|
|
|
/* First draw the highlighting underground if it exists. */
|
2011-02-05 20:26:55 +00:00
|
|
|
if (this->order_over != INVALID_VEH_ORDER_ID) {
|
2010-05-23 15:06:44 +00:00
|
|
|
while (order != NULL) {
|
|
|
|
/* Don't draw anything if it extends past the end of the window. */
|
2010-08-12 08:37:01 +00:00
|
|
|
if (!this->vscroll->IsVisible(i)) break;
|
2010-05-23 15:06:44 +00:00
|
|
|
|
|
|
|
if (i != this->selected_order && i == this->order_over) {
|
|
|
|
/* Highlight dragged order destination. */
|
|
|
|
int top = (this->order_over < this->selected_order ? y : y + line_height) - WD_FRAMERECT_TOP;
|
|
|
|
int bottom = min(top + 2, r.bottom - WD_FRAMERECT_BOTTOM);
|
|
|
|
top = max(top - 3, r.top + WD_FRAMERECT_TOP);
|
|
|
|
GfxFillRect(r.left + WD_FRAMETEXT_LEFT, top, r.right - WD_FRAMETEXT_RIGHT, bottom, _colour_gradient[COLOUR_GREY][7]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
y += line_height;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
order = order->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset counters for drawing the orders. */
|
|
|
|
y = r.top + WD_FRAMERECT_TOP;
|
2010-08-12 08:37:01 +00:00
|
|
|
i = this->vscroll->GetPosition();
|
2010-05-23 15:06:44 +00:00
|
|
|
order = this->vehicle->GetOrder(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the orders. */
|
2008-05-16 20:08:20 +00:00
|
|
|
while (order != NULL) {
|
|
|
|
/* Don't draw anything if it extends past the end of the window. */
|
2010-08-12 08:37:01 +00:00
|
|
|
if (!this->vscroll->IsVisible(i)) break;
|
2004-08-13 20:30:45 +00:00
|
|
|
|
2009-11-28 15:12:24 +00:00
|
|
|
DrawOrderString(this->vehicle, order, i, y, i == this->selected_order, false, r.left + WD_FRAMETEXT_LEFT, middle, r.right - WD_FRAMETEXT_RIGHT);
|
2009-12-22 11:22:07 +00:00
|
|
|
y += line_height;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
i++;
|
|
|
|
order = order->next;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2010-08-12 08:37:01 +00:00
|
|
|
if (this->vscroll->IsVisible(i)) {
|
2010-05-23 15:06:44 +00:00
|
|
|
StringID str = this->vehicle->IsOrderListShared() ? STR_ORDERS_END_OF_SHARED_ORDERS : STR_ORDERS_END_OF_ORDERS;
|
2009-11-28 15:12:24 +00:00
|
|
|
DrawString(rtl ? r.left + WD_FRAMETEXT_LEFT : middle, rtl ? middle : r.right - WD_FRAMETEXT_RIGHT, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void SetStringParameters(int widget) const
|
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_COND_VALUE: {
|
2011-02-05 20:26:55 +00:00
|
|
|
VehicleOrderID sel = this->OrderGetSel();
|
2009-09-19 13:57:02 +00:00
|
|
|
const Order *order = this->vehicle->GetOrder(sel);
|
|
|
|
|
|
|
|
if (order != NULL && order->IsType(OT_CONDITIONAL)) {
|
|
|
|
uint value = order->GetConditionValue();
|
|
|
|
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
2009-11-14 12:55:48 +00:00
|
|
|
SetDParam(0, value);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_CAPTION:
|
2009-09-19 13:57:02 +00:00
|
|
|
SetDParam(0, this->vehicle->index);
|
|
|
|
break;
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_ORDER_LIST: {
|
2010-12-25 12:48:23 +00:00
|
|
|
if (this->goto_type == OPOS_CONDITIONAL) {
|
|
|
|
this->goto_type = OPOS_GOTO;
|
2011-02-05 20:26:55 +00:00
|
|
|
VehicleOrderID order_id = this->GetOrderFromPt(_cursor.pos.y - this->top);
|
|
|
|
if (order_id != INVALID_VEH_ORDER_ID) {
|
2010-12-25 12:48:23 +00:00
|
|
|
Order order;
|
|
|
|
order.next = NULL;
|
|
|
|
order.index = 0;
|
|
|
|
order.MakeConditional(order_id);
|
|
|
|
|
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
|
|
|
|
}
|
|
|
|
ResetObjectToPlace();
|
|
|
|
break;
|
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
|
2011-02-05 20:26:55 +00:00
|
|
|
VehicleOrderID sel = this->GetOrderFromPt(pt.y);
|
2008-05-16 20:08:20 +00:00
|
|
|
|
2009-01-03 13:20:32 +00:00
|
|
|
if (_ctrl_pressed && sel < this->vehicle->GetNumOrders()) {
|
2010-02-22 20:36:20 +00:00
|
|
|
TileIndex xy = this->vehicle->GetOrder(sel)->GetLocation(this->vehicle);
|
2009-01-03 16:06:58 +00:00
|
|
|
if (xy != INVALID_TILE) ScrollMainWindowToTile(xy);
|
2008-05-16 20:08:20 +00:00
|
|
|
return;
|
2008-09-24 16:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This order won't be selected any more, close all child windows and dropdowns */
|
|
|
|
this->DeleteChildWindows();
|
|
|
|
HideDropDownMenu(this);
|
|
|
|
|
2011-02-05 20:26:55 +00:00
|
|
|
if (sel == INVALID_VEH_ORDER_ID || this->vehicle->owner != _local_company) {
|
2008-09-24 16:40:06 +00:00
|
|
|
/* Deselect clicked order */
|
|
|
|
this->selected_order = -1;
|
2009-04-12 14:11:14 +00:00
|
|
|
} else if (sel == this->selected_order) {
|
2009-04-13 21:30:21 +00:00
|
|
|
if (this->vehicle->type == VEH_TRAIN && sel < this->vehicle->GetNumOrders()) {
|
2010-08-19 20:39:12 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel << 20),
|
2009-05-23 12:27:42 +00:00
|
|
|
MOF_STOP_LOCATION | ((this->vehicle->GetOrder(sel)->GetStopLocation() + 1) % OSL_END) << 4,
|
2009-04-21 23:40:56 +00:00
|
|
|
CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
2009-04-12 14:11:14 +00:00
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
} else {
|
2008-09-24 16:40:06 +00:00
|
|
|
/* Select clicked order */
|
|
|
|
this->selected_order = sel;
|
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
if (this->vehicle->owner == _local_company) {
|
2008-09-24 16:40:06 +00:00
|
|
|
/* Activate drag and drop */
|
2009-04-19 10:31:30 +00:00
|
|
|
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-09 19:52:33 +00:00
|
|
|
|
2009-09-02 17:54:40 +00:00
|
|
|
this->UpdateButtonState();
|
2010-08-01 18:53:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-01-24 18:41:27 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_SKIP:
|
2009-09-12 10:25:23 +00:00
|
|
|
this->OrderClick_Skip(0);
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2008-04-09 19:52:33 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_DELETE:
|
2009-09-12 10:25:23 +00:00
|
|
|
this->OrderClick_Delete(0);
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2007-06-20 19:17:22 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_STOP_SHARING:
|
2010-12-11 10:52:45 +00:00
|
|
|
this->OrderClick_StopSharing(0);
|
|
|
|
break;
|
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_NON_STOP:
|
2009-12-22 19:40:23 +00:00
|
|
|
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
2009-09-19 13:57:02 +00:00
|
|
|
this->OrderClick_Nonstop(-1);
|
|
|
|
} else {
|
|
|
|
const Order *o = this->vehicle->GetOrder(this->OrderGetSel());
|
2011-12-16 18:25:06 +00:00
|
|
|
ShowDropDownMenu(this, _order_non_stop_drowdown, o->GetNonStopType(), WID_O_NON_STOP, 0,
|
2009-09-19 13:57:02 +00:00
|
|
|
o->IsType(OT_GOTO_STATION) ? 0 : (o->IsType(OT_GOTO_WAYPOINT) ? 3 : 12));
|
|
|
|
}
|
2008-06-10 16:46:11 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_GOTO:
|
2009-12-22 19:40:23 +00:00
|
|
|
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
2009-09-19 13:57:02 +00:00
|
|
|
this->OrderClick_Goto(0);
|
|
|
|
} else {
|
2011-12-16 18:25:06 +00:00
|
|
|
ShowDropDownMenu(this, this->vehicle->type == VEH_AIRCRAFT ? _order_goto_dropdown_aircraft : _order_goto_dropdown, 0, WID_O_GOTO, 0, 0);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2008-04-12 11:58:19 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_FULL_LOAD:
|
2009-12-22 19:40:23 +00:00
|
|
|
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
2009-09-19 13:57:02 +00:00
|
|
|
this->OrderClick_FullLoad(-1);
|
|
|
|
} else {
|
2011-12-16 18:25:06 +00:00
|
|
|
ShowDropDownMenu(this, _order_full_load_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetLoadType(), WID_O_FULL_LOAD, 0, 2);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2005-01-15 08:58:31 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_UNLOAD:
|
2009-12-22 19:40:23 +00:00
|
|
|
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
2009-09-19 13:57:02 +00:00
|
|
|
this->OrderClick_Unload(-1);
|
|
|
|
} else {
|
2011-12-16 18:25:06 +00:00
|
|
|
ShowDropDownMenu(this, _order_unload_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetUnloadType(), WID_O_UNLOAD, 0, 8);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2008-04-12 11:58:19 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_REFIT:
|
2011-11-04 00:38:59 +00:00
|
|
|
this->OrderClick_Refit(0, false);
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2008-04-12 11:58:19 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_SERVICE:
|
2009-12-22 19:40:23 +00:00
|
|
|
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
2009-09-19 13:57:02 +00:00
|
|
|
this->OrderClick_Service(-1);
|
|
|
|
} else {
|
2011-12-16 18:25:06 +00:00
|
|
|
ShowDropDownMenu(this, _order_depot_action_dropdown, DepotActionStringIndex(this->vehicle->GetOrder(this->OrderGetSel())), WID_O_SERVICE, 0, 0);
|
2009-09-19 13:57:02 +00:00
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2008-04-12 11:58:19 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_REFIT_DROPDOWN:
|
2011-11-04 00:38:59 +00:00
|
|
|
if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
|
|
|
|
this->OrderClick_Refit(0, true);
|
|
|
|
} else {
|
2011-12-16 18:25:06 +00:00
|
|
|
ShowDropDownMenu(this, _order_refit_action_dropdown, 0, WID_O_REFIT_DROPDOWN, 0, 0);
|
2011-11-04 00:38:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_TIMETABLE_VIEW:
|
2008-05-16 20:08:20 +00:00
|
|
|
ShowTimetableWindow(this->vehicle);
|
|
|
|
break;
|
2008-04-12 11:58:19 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_COND_VARIABLE: {
|
2011-08-30 20:21:01 +00:00
|
|
|
DropDownList *list = new DropDownList();
|
|
|
|
for (uint i = 0; i < lengthof(_order_conditional_variable); i++) {
|
|
|
|
list->push_back(new DropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i], _order_conditional_variable[i], false));
|
|
|
|
}
|
2011-12-16 18:25:06 +00:00
|
|
|
ShowDropDownList(this, list, this->vehicle->GetOrder(this->OrderGetSel())->GetConditionVariable(), WID_O_COND_VARIABLE);
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2011-08-30 20:21:01 +00:00
|
|
|
}
|
2008-04-09 23:00:12 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_COND_COMPARATOR: {
|
2009-05-23 12:27:42 +00:00
|
|
|
const Order *o = this->vehicle->GetOrder(this->OrderGetSel());
|
2011-12-16 18:25:06 +00:00
|
|
|
ShowDropDownMenu(this, _order_conditional_condition, o->GetConditionComparator(), WID_O_COND_COMPARATOR, 0, (o->GetConditionVariable() == OCV_REQUIRES_SERVICE) ? 0x3F : 0xC0);
|
2010-08-01 18:53:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-10 10:18:03 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_COND_VALUE: {
|
2009-05-23 12:27:42 +00:00
|
|
|
const Order *order = this->vehicle->GetOrder(this->OrderGetSel());
|
2008-05-16 20:08:20 +00:00
|
|
|
uint value = order->GetConditionValue();
|
|
|
|
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
|
|
|
SetDParam(0, value);
|
2011-04-17 18:42:17 +00:00
|
|
|
ShowQueryString(STR_JUST_INT, STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, this, CS_NUMERAL, QSF_NONE);
|
2010-08-01 18:53:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-04-11 15:58:46 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_SHARED_ORDER_LIST:
|
2008-05-16 20:08:20 +00:00
|
|
|
ShowVehicleListWindow(this->vehicle);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-04-12 11:58:19 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
virtual void OnQueryTextFinished(char *str)
|
|
|
|
{
|
|
|
|
if (!StrEmpty(str)) {
|
|
|
|
VehicleOrderID sel = this->OrderGetSel();
|
|
|
|
uint value = atoi(str);
|
2008-04-12 11:58:19 +00:00
|
|
|
|
2009-05-23 12:27:42 +00:00
|
|
|
switch (this->vehicle->GetOrder(sel)->GetConditionVariable()) {
|
2008-05-16 20:08:20 +00:00
|
|
|
case OCV_MAX_SPEED:
|
|
|
|
value = ConvertDisplaySpeedToSpeed(value);
|
2008-04-12 11:58:19 +00:00
|
|
|
break;
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
case OCV_RELIABILITY:
|
|
|
|
case OCV_LOAD_PERCENTAGE:
|
|
|
|
value = Clamp(value, 0, 100);
|
2011-08-30 20:21:01 +00:00
|
|
|
break;
|
2008-05-16 20:08:20 +00:00
|
|
|
|
|
|
|
default:
|
2008-04-12 11:58:19 +00:00
|
|
|
break;
|
2008-04-09 23:00:12 +00:00
|
|
|
}
|
2010-08-19 20:39:12 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel << 20), MOF_COND_VALUE | Clamp(value, 0, 2047) << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
2008-04-09 23:00:12 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
virtual void OnDropdownSelect(int widget, int index)
|
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_NON_STOP:
|
2009-09-12 10:25:23 +00:00
|
|
|
this->OrderClick_Nonstop(index);
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2007-06-08 18:59:29 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_FULL_LOAD:
|
2009-09-12 10:25:23 +00:00
|
|
|
this->OrderClick_FullLoad(index);
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2007-06-08 18:59:29 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_UNLOAD:
|
2009-09-12 10:25:23 +00:00
|
|
|
this->OrderClick_Unload(index);
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2007-06-08 18:59:29 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_GOTO:
|
2008-05-16 20:08:20 +00:00
|
|
|
switch (index) {
|
2009-09-12 10:25:23 +00:00
|
|
|
case 0: this->OrderClick_Goto(0); break;
|
|
|
|
case 1: this->OrderClick_NearestDepot(0); break;
|
|
|
|
case 2: this->OrderClick_Conditional(0); break;
|
2010-12-11 13:38:35 +00:00
|
|
|
case 3: this->OrderClick_Share(0); break;
|
2008-05-16 20:08:20 +00:00
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
break;
|
2007-06-08 18:59:29 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_SERVICE:
|
2009-09-12 10:25:23 +00:00
|
|
|
this->OrderClick_Service(index);
|
2008-10-24 14:49:45 +00:00
|
|
|
break;
|
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_REFIT_DROPDOWN:
|
2011-11-04 00:38:59 +00:00
|
|
|
this->OrderClick_Refit(index, true);
|
|
|
|
break;
|
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_COND_VARIABLE:
|
2010-08-19 20:39:12 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VARIABLE | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2007-06-08 18:59:29 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_COND_COMPARATOR:
|
2010-08-19 20:39:12 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_COMPARATOR | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnDragDrop(Point pt, int widget)
|
|
|
|
{
|
|
|
|
switch (widget) {
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_ORDER_LIST: {
|
2011-02-05 20:26:55 +00:00
|
|
|
VehicleOrderID from_order = this->OrderGetSel();
|
|
|
|
VehicleOrderID to_order = this->GetOrderFromPt(pt.y);
|
2008-05-16 20:08:20 +00:00
|
|
|
|
2011-02-05 20:26:55 +00:00
|
|
|
if (!(from_order == to_order || from_order == INVALID_VEH_ORDER_ID || from_order > this->vehicle->GetNumOrders() || to_order == INVALID_VEH_ORDER_ID || to_order > this->vehicle->GetNumOrders()) &&
|
2009-04-21 23:40:56 +00:00
|
|
|
DoCommandP(this->vehicle->tile, this->vehicle->index, from_order | (to_order << 16), CMD_MOVE_ORDER | CMD_MSG(STR_ERROR_CAN_T_MOVE_THIS_ORDER))) {
|
2008-05-16 20:08:20 +00:00
|
|
|
this->selected_order = -1;
|
2009-09-03 10:58:26 +00:00
|
|
|
this->UpdateButtonState();
|
2008-04-09 16:16:04 +00:00
|
|
|
}
|
2010-08-01 18:53:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_DELETE:
|
2009-09-12 10:25:23 +00:00
|
|
|
this->OrderClick_Delete(0);
|
2008-05-16 20:08:20 +00:00
|
|
|
break;
|
2010-12-11 10:52:45 +00:00
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
case WID_O_STOP_SHARING:
|
2010-12-11 10:52:45 +00:00
|
|
|
this->OrderClick_StopSharing(0);
|
|
|
|
break;
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ResetObjectToPlace();
|
2010-05-23 15:06:44 +00:00
|
|
|
|
2011-02-05 20:26:55 +00:00
|
|
|
if (this->order_over != INVALID_VEH_ORDER_ID) {
|
2010-05-23 15:06:44 +00:00
|
|
|
/* End of drag-and-drop, hide dragged order destination highlight. */
|
2011-02-05 20:26:55 +00:00
|
|
|
this->order_over = INVALID_VEH_ORDER_ID;
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetDirty(WID_O_ORDER_LIST);
|
2010-05-23 15:06:44 +00:00
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
|
|
|
|
2008-05-17 23:11:06 +00:00
|
|
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
if (this->vehicle->owner != _local_company) return ES_NOT_HANDLED;
|
2008-05-16 20:08:20 +00:00
|
|
|
|
2010-07-03 13:29:19 +00:00
|
|
|
return CheckHotkeyMatch<OrdersWindow>(order_hotkeys, keycode, this) != -1 ? ES_HANDLED : ES_NOT_HANDLED;
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
2005-01-13 16:55:17 +00:00
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
virtual void OnPlaceObject(Point pt, TileIndex tile)
|
|
|
|
{
|
|
|
|
if (this->goto_type == OPOS_GOTO) {
|
|
|
|
const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
|
2009-05-22 15:13:50 +00:00
|
|
|
if (cmd.IsType(OT_NOTHING)) return;
|
2008-05-16 20:08:20 +00:00
|
|
|
|
2010-08-19 20:39:12 +00:00
|
|
|
if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), cmd.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER))) {
|
2009-01-04 14:51:49 +00:00
|
|
|
/* With quick goto the Go To button stays active */
|
|
|
|
if (!_settings_client.gui.quick_goto) ResetObjectToPlace();
|
2008-04-12 11:58:19 +00:00
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
2005-11-14 19:48:04 +00:00
|
|
|
|
2011-12-10 19:20:30 +00:00
|
|
|
virtual bool OnVehicleSelect(const Vehicle *v)
|
2010-09-06 14:14:09 +00:00
|
|
|
{
|
2010-12-11 13:38:35 +00:00
|
|
|
/* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet.
|
|
|
|
* We disallow copying orders of other vehicles if we already have at least one order entry
|
|
|
|
* ourself as it easily copies orders of vehicles within a station when we mean the station.
|
|
|
|
* Obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
|
2010-09-06 14:14:09 +00:00
|
|
|
* TODO: give a warning message */
|
2010-12-11 13:38:35 +00:00
|
|
|
bool share_order = _ctrl_pressed || this->goto_type == OPOS_SHARE;
|
2011-12-10 19:20:30 +00:00
|
|
|
if (this->vehicle->GetNumOrders() != 0 && !share_order) return false;
|
2010-09-06 14:14:09 +00:00
|
|
|
|
2010-12-11 13:38:35 +00:00
|
|
|
if (DoCommandP(this->vehicle->tile, this->vehicle->index | (share_order ? CO_SHARE : CO_COPY) << 30, v->index,
|
|
|
|
share_order ? CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_COPY_ORDER_LIST))) {
|
2010-09-06 14:14:09 +00:00
|
|
|
this->selected_order = -1;
|
|
|
|
ResetObjectToPlace();
|
|
|
|
}
|
2011-12-10 19:20:30 +00:00
|
|
|
return true;
|
2010-09-06 14:14:09 +00:00
|
|
|
}
|
|
|
|
|
2008-05-16 20:08:20 +00:00
|
|
|
virtual void OnPlaceObjectAbort()
|
|
|
|
{
|
2011-12-16 18:25:06 +00:00
|
|
|
this->RaiseWidget(WID_O_GOTO);
|
|
|
|
this->SetWidgetDirty(WID_O_GOTO);
|
2010-06-11 15:37:00 +00:00
|
|
|
|
|
|
|
/* Remove drag highlighting if it exists. */
|
2011-02-05 20:26:55 +00:00
|
|
|
if (this->order_over != INVALID_VEH_ORDER_ID) {
|
|
|
|
this->order_over = INVALID_VEH_ORDER_ID;
|
2011-12-16 18:25:06 +00:00
|
|
|
this->SetWidgetDirty(WID_O_ORDER_LIST);
|
2010-06-11 15:37:00 +00:00
|
|
|
}
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
2008-04-09 16:16:04 +00:00
|
|
|
|
2010-05-23 15:06:44 +00:00
|
|
|
virtual void OnMouseDrag(Point pt, int widget)
|
|
|
|
{
|
2011-12-16 18:25:06 +00:00
|
|
|
if (this->selected_order != -1 && widget == WID_O_ORDER_LIST) {
|
2010-05-23 15:06:44 +00:00
|
|
|
/* An order is dragged.. */
|
2011-02-05 20:26:55 +00:00
|
|
|
VehicleOrderID from_order = this->OrderGetSel();
|
|
|
|
VehicleOrderID to_order = this->GetOrderFromPt(pt.y);
|
2010-05-23 15:06:44 +00:00
|
|
|
uint num_orders = this->vehicle->GetNumOrders();
|
|
|
|
|
2011-02-05 20:26:55 +00:00
|
|
|
if (from_order != INVALID_VEH_ORDER_ID && from_order <= num_orders) {
|
|
|
|
if (to_order != INVALID_VEH_ORDER_ID && to_order <= num_orders) { // ..over an existing order.
|
2010-05-23 15:06:44 +00:00
|
|
|
this->order_over = to_order;
|
|
|
|
this->SetWidgetDirty(widget);
|
2011-02-05 20:26:55 +00:00
|
|
|
} else if (from_order != to_order && this->order_over != INVALID_VEH_ORDER_ID) { // ..outside of the order list.
|
|
|
|
this->order_over = INVALID_VEH_ORDER_ID;
|
2010-05-23 15:06:44 +00:00
|
|
|
this->SetWidgetDirty(widget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-24 14:53:55 +00:00
|
|
|
virtual void OnResize()
|
2008-05-16 20:08:20 +00:00
|
|
|
{
|
2009-10-17 14:29:10 +00:00
|
|
|
/* Update the scroll bar */
|
2011-12-16 18:25:06 +00:00
|
|
|
this->vscroll->SetCapacityFromWidget(this, WID_O_ORDER_LIST);
|
2008-05-16 20:08:20 +00:00
|
|
|
}
|
2008-04-09 16:16:04 +00:00
|
|
|
|
2010-07-03 13:29:19 +00:00
|
|
|
static Hotkey<OrdersWindow> order_hotkeys[];
|
|
|
|
};
|
|
|
|
|
2011-01-26 08:14:36 +00:00
|
|
|
Hotkey<OrdersWindow> OrdersWindow::order_hotkeys[] = {
|
2010-07-03 13:29:19 +00:00
|
|
|
Hotkey<OrdersWindow>('D', "skip", 0, &OrdersWindow::OrderClick_Skip),
|
|
|
|
Hotkey<OrdersWindow>('F', "delete", 0, &OrdersWindow::OrderClick_Delete),
|
|
|
|
Hotkey<OrdersWindow>('G', "goto", 0, &OrdersWindow::OrderClick_Goto),
|
|
|
|
Hotkey<OrdersWindow>('H', "nonstop", 0, &OrdersWindow::OrderClick_Nonstop),
|
|
|
|
Hotkey<OrdersWindow>('J', "fullload", 0, &OrdersWindow::OrderClick_FullLoad),
|
|
|
|
Hotkey<OrdersWindow>('K', "unload", 0, &OrdersWindow::OrderClick_Unload),
|
2010-07-21 14:28:06 +00:00
|
|
|
Hotkey<OrdersWindow>((uint16)0, "nearest_depot", 0, &OrdersWindow::OrderClick_NearestDepot),
|
|
|
|
Hotkey<OrdersWindow>((uint16)0, "always_service", 0, &OrdersWindow::OrderClick_Service),
|
|
|
|
Hotkey<OrdersWindow>((uint16)0, "force_unload", 0, &OrdersWindow::OrderClick_Unload),
|
|
|
|
Hotkey<OrdersWindow>((uint16)0, "transfer", 0, &OrdersWindow::OrderHotkey_Transfer),
|
|
|
|
Hotkey<OrdersWindow>((uint16)0, "no_unload", 0, &OrdersWindow::OrderHotkey_NoUnload),
|
|
|
|
Hotkey<OrdersWindow>((uint16)0, "no_load", 0, &OrdersWindow::OrderHotkey_NoLoad),
|
2010-07-03 13:29:19 +00:00
|
|
|
HOTKEY_LIST_END(OrdersWindow)
|
2008-05-16 20:08:20 +00:00
|
|
|
};
|
2010-07-03 13:29:19 +00:00
|
|
|
Hotkey<OrdersWindow> *_order_hotkeys = OrdersWindow::order_hotkeys;
|
2005-01-13 16:55:17 +00:00
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
/** Nested widget definition for "your" train orders. */
|
2009-04-30 19:22:44 +00:00
|
|
|
static const NWidgetPart _nested_orders_train_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_TIMETABLE_VIEW), SetMinimalSize(61, 14), SetDataTip(STR_ORDERS_TIMETABLE_VIEW, STR_ORDERS_TIMETABLE_VIEW_TOOLTIP),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
2013-05-26 19:30:07 +00:00
|
|
|
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
2009-04-30 19:22:44 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_O_ORDER_LIST), SetMinimalSize(372, 62), SetDataTip(0x0, STR_ORDERS_LIST_TOOLTIP), SetResize(1, 1), SetScrollbar(WID_O_SCROLLBAR), EndContainer(),
|
|
|
|
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_O_SCROLLBAR),
|
2009-04-30 19:22:44 +00:00
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
/* First button row. */
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_ROW_GROUNDVEHICLE),
|
2011-11-04 00:38:56 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_NON_STOP), SetMinimalSize(93, 12), SetFill(1, 0),
|
2011-11-04 00:38:56 +00:00
|
|
|
SetDataTip(STR_ORDER_NON_STOP, STR_ORDER_TOOLTIP_NON_STOP), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_LEFT),
|
|
|
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_FULL_LOAD), SetMinimalSize(93, 12), SetFill(1, 0),
|
2011-11-04 00:38:56 +00:00
|
|
|
SetDataTip(STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_REFIT), SetMinimalSize(93, 12), SetFill(1, 0),
|
2011-11-04 00:38:56 +00:00
|
|
|
SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
|
|
|
|
EndContainer(),
|
2011-12-16 18:25:06 +00:00
|
|
|
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),
|
2011-11-04 00:38:56 +00:00
|
|
|
SetDataTip(STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_SERVICE), SetMinimalSize(93, 12), SetFill(1, 0),
|
2011-11-04 00:38:56 +00:00
|
|
|
SetDataTip(STR_ORDER_SERVICE, STR_ORDER_SERVICE_TOOLTIP), SetResize(1, 0),
|
|
|
|
EndContainer(),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_RIGHT),
|
2012-11-11 16:07:46 +00:00
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_O_EMPTY), SetMinimalSize(93, 12), SetFill(1, 0),
|
2011-11-04 00:38:56 +00:00
|
|
|
SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_REFIT_DROPDOWN), SetMinimalSize(93, 12), SetFill(1, 0),
|
2011-11-04 00:38:59 +00:00
|
|
|
SetDataTip(STR_ORDER_REFIT_AUTO, STR_ORDER_REFIT_AUTO_TOOLTIP), SetResize(1, 0),
|
2011-11-04 00:38:56 +00:00
|
|
|
EndContainer(),
|
2009-04-30 19:22:44 +00:00
|
|
|
EndContainer(),
|
2011-11-04 00:38:56 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_VARIABLE), SetMinimalSize(124, 12), SetFill(1, 0),
|
2011-11-04 00:38:56 +00:00
|
|
|
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
|
2011-11-04 00:38:56 +00:00
|
|
|
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_COND_VALUE), SetMinimalSize(124, 12), SetFill(1, 0),
|
2011-11-04 00:38:56 +00:00
|
|
|
SetDataTip(STR_BLACK_COMMA, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP), SetResize(1, 0),
|
2009-05-01 19:37:59 +00:00
|
|
|
EndContainer(),
|
2009-04-30 19:22:44 +00:00
|
|
|
EndContainer(),
|
2011-12-16 18:25:06 +00:00
|
|
|
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),
|
2009-04-30 19:22:44 +00:00
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
/* Second button row. */
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-09-19 13:57:02 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_SKIP), SetMinimalSize(124, 12), SetFill(1, 0),
|
2009-09-19 13:57:02 +00:00
|
|
|
SetDataTip(STR_ORDERS_SKIP_BUTTON, STR_ORDERS_SKIP_TOOLTIP), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_BOTTOM_MIDDLE),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_DELETE), SetMinimalSize(124, 12), SetFill(1, 0),
|
2010-12-11 10:52:45 +00:00
|
|
|
SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_STOP_SHARING), SetMinimalSize(124, 12), SetFill(1, 0),
|
2010-12-11 10:52:45 +00:00
|
|
|
SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP), SetResize(1, 0),
|
|
|
|
EndContainer(),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_GOTO), SetMinimalSize(124, 12), SetFill(1, 0),
|
2009-09-19 13:57:02 +00:00
|
|
|
SetDataTip(STR_ORDERS_GO_TO_BUTTON, STR_ORDERS_GO_TO_TOOLTIP), SetResize(1, 0),
|
2009-04-30 19:22:44 +00:00
|
|
|
EndContainer(),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
2009-04-30 19:22:44 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
static WindowDesc _orders_train_desc(
|
2013-05-26 19:25:01 +00:00
|
|
|
WDP_AUTO, "view_vehicle_orders_train", 384, 100,
|
2008-04-18 04:37:06 +00:00
|
|
|
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
2012-11-11 16:10:43 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_orders_train_widgets, lengthof(_nested_orders_train_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2005-01-21 18:36:17 +00:00
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
/** Nested widget definition for "your" orders (non-train). */
|
2009-05-01 19:33:58 +00:00
|
|
|
static const NWidgetPart _nested_orders_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_TIMETABLE_VIEW), SetMinimalSize(61, 14), SetDataTip(STR_ORDERS_TIMETABLE_VIEW, STR_ORDERS_TIMETABLE_VIEW_TOOLTIP),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
2013-05-26 19:30:07 +00:00
|
|
|
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
2009-05-01 19:33:58 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_O_ORDER_LIST), SetMinimalSize(372, 62), SetDataTip(0x0, STR_ORDERS_LIST_TOOLTIP), SetResize(1, 1), SetScrollbar(WID_O_SCROLLBAR), EndContainer(),
|
|
|
|
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_O_SCROLLBAR),
|
2009-05-01 19:33:58 +00:00
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
/* First button row. */
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_ROW),
|
2011-11-04 00:38:59 +00:00
|
|
|
/* Load + unload + refit buttons. */
|
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_FULL_LOAD), SetMinimalSize(124, 12), SetFill(1, 0),
|
2009-09-19 13:57:02 +00:00
|
|
|
SetDataTip(STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_UNLOAD), SetMinimalSize(124, 12), SetFill(1, 0),
|
2009-09-19 13:57:02 +00:00
|
|
|
SetDataTip(STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_REFIT_DROPDOWN), SetMinimalSize(124, 12), SetFill(1, 0),
|
2011-11-04 00:38:59 +00:00
|
|
|
SetDataTip(STR_ORDER_REFIT_AUTO, STR_ORDER_REFIT_AUTO_TOOLTIP), SetResize(1, 0),
|
2009-09-19 13:57:02 +00:00
|
|
|
EndContainer(),
|
|
|
|
/* Refit + service buttons. */
|
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_REFIT), SetMinimalSize(186, 12), SetFill(1, 0),
|
2009-09-19 13:57:02 +00:00
|
|
|
SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_SERVICE), SetMinimalSize(124, 12), SetFill(1, 0),
|
2009-09-19 13:57:02 +00:00
|
|
|
SetDataTip(STR_ORDER_SERVICE, STR_ORDER_SERVICE_TOOLTIP), SetResize(1, 0),
|
2009-05-01 19:33:58 +00:00
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
/* Buttons for setting a condition. */
|
2009-09-19 13:57:02 +00:00
|
|
|
NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_VARIABLE), SetMinimalSize(124, 12), SetFill(1, 0),
|
2009-09-19 13:57:02 +00:00
|
|
|
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
|
2009-09-19 13:57:02 +00:00
|
|
|
SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_COND_VALUE), SetMinimalSize(124, 12), SetFill(1, 0),
|
2009-11-14 12:55:48 +00:00
|
|
|
SetDataTip(STR_BLACK_COMMA, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP), SetResize(1, 0),
|
2009-05-01 19:33:58 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
|
2011-12-16 18:25:06 +00:00
|
|
|
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),
|
2009-05-01 19:33:58 +00:00
|
|
|
EndContainer(),
|
|
|
|
|
|
|
|
/* Second button row. */
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_SKIP), SetMinimalSize(124, 12), SetFill(1, 0),
|
2009-09-19 13:57:02 +00:00
|
|
|
SetDataTip(STR_ORDERS_SKIP_BUTTON, STR_ORDERS_SKIP_TOOLTIP), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_BOTTOM_MIDDLE),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_DELETE), SetMinimalSize(124, 12), SetFill(1, 0),
|
2010-12-11 10:52:45 +00:00
|
|
|
SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_STOP_SHARING), SetMinimalSize(124, 12), SetFill(1, 0),
|
2010-12-11 10:52:45 +00:00
|
|
|
SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP), SetResize(1, 0),
|
|
|
|
EndContainer(),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_GOTO), SetMinimalSize(124, 12), SetFill(1, 0),
|
2009-09-19 13:57:02 +00:00
|
|
|
SetDataTip(STR_ORDERS_GO_TO_BUTTON, STR_ORDERS_GO_TO_TOOLTIP), SetResize(1, 0),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
2009-05-01 19:33:58 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
static WindowDesc _orders_desc(
|
2013-05-26 19:25:01 +00:00
|
|
|
WDP_AUTO, "view_vehicle_orders", 384, 100,
|
2008-04-18 04:37:06 +00:00
|
|
|
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
2012-11-11 16:10:43 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_orders_widgets, lengthof(_nested_orders_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2009-09-19 13:57:02 +00:00
|
|
|
/** Nested widget definition for competitor orders. */
|
2009-05-01 19:33:58 +00:00
|
|
|
static const NWidgetPart _nested_other_orders_widgets[] = {
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_TIMETABLE_VIEW), SetMinimalSize(61, 14), SetDataTip(STR_ORDERS_TIMETABLE_VIEW, STR_ORDERS_TIMETABLE_VIEW_TOOLTIP),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
2013-05-26 19:30:07 +00:00
|
|
|
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, WID_O_ORDER_LIST), SetMinimalSize(372, 72), SetDataTip(0x0, STR_ORDERS_LIST_TOOLTIP), SetResize(1, 1), SetScrollbar(WID_O_SCROLLBAR), EndContainer(),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(NWID_VERTICAL),
|
2011-12-16 18:25:06 +00:00
|
|
|
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_O_SCROLLBAR),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
2009-05-01 19:33:58 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2013-05-26 19:23:42 +00:00
|
|
|
static WindowDesc _other_orders_desc(
|
2013-05-26 19:25:01 +00:00
|
|
|
WDP_AUTO, "view_vehicle_orders_competitor", 384, 86,
|
2008-04-18 04:37:06 +00:00
|
|
|
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
2012-11-11 16:10:43 +00:00
|
|
|
WDF_CONSTRUCTION,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_other_orders_widgets, lengthof(_nested_other_orders_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2006-07-26 03:33:12 +00:00
|
|
|
void ShowOrdersWindow(const Vehicle *v)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2009-01-03 23:32:59 +00:00
|
|
|
DeleteWindowById(WC_VEHICLE_DETAILS, v->index, false);
|
|
|
|
DeleteWindowById(WC_VEHICLE_TIMETABLE, v->index, false);
|
2009-01-02 20:01:28 +00:00
|
|
|
if (BringWindowToFrontById(WC_VEHICLE_ORDERS, v->index) != NULL) return;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
if (v->owner != _local_company) {
|
2008-05-16 20:08:20 +00:00
|
|
|
new OrdersWindow(&_other_orders_desc, v);
|
2005-10-23 13:04:44 +00:00
|
|
|
} else {
|
2010-12-14 21:26:03 +00:00
|
|
|
new OrdersWindow(v->IsGroundVehicle() ? &_orders_train_desc : &_orders_desc, v);
|
2005-01-30 23:41:57 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|