2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-03-21 15:19:33 +00:00
|
|
|
/** @file order_gui.cpp */
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
2005-06-02 19:30:21 +00:00
|
|
|
#include "openttd.h"
|
2006-03-05 10:19:33 +00:00
|
|
|
#include "road_map.h"
|
2006-03-24 08:55:08 +00:00
|
|
|
#include "station_map.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "gui.h"
|
2007-12-19 20:45:46 +00:00
|
|
|
#include "window_gui.h"
|
2008-03-31 00:06:17 +00:00
|
|
|
#include "station_base.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "town.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"
|
|
|
|
#include "gfx_func.h"
|
2008-04-17 19:10:30 +00:00
|
|
|
#include "depot_base.h"
|
2005-03-24 17:03:37 +00:00
|
|
|
#include "waypoint.h"
|
2005-11-18 23:41:03 +00:00
|
|
|
#include "train.h"
|
2006-03-31 10:47:06 +00:00
|
|
|
#include "water_map.h"
|
2006-09-28 23:05:03 +00:00
|
|
|
#include "vehicle_gui.h"
|
2007-06-20 19:17:22 +00:00
|
|
|
#include "timetable.h"
|
2007-02-20 22:09:21 +00:00
|
|
|
#include "cargotype.h"
|
2007-12-21 19:49:27 +00:00
|
|
|
#include "strings_func.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "window_func.h"
|
2007-12-27 13:35:39 +00:00
|
|
|
#include "vehicle_func.h"
|
2008-01-07 00:57:19 +00:00
|
|
|
#include "settings_type.h"
|
2008-01-12 14:10:35 +00:00
|
|
|
#include "player_func.h"
|
2008-03-31 06:42:26 +00:00
|
|
|
#include "newgrf_cargo.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-04-17 19:10:30 +00:00
|
|
|
#include "depot_base.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/sprites.h"
|
|
|
|
#include "table/strings.h"
|
|
|
|
|
2007-01-24 18:22:31 +00:00
|
|
|
enum OrderWindowWidgets {
|
|
|
|
ORDER_WIDGET_CLOSEBOX = 0,
|
|
|
|
ORDER_WIDGET_CAPTION,
|
2007-06-20 19:17:22 +00:00
|
|
|
ORDER_WIDGET_TIMETABLE_VIEW,
|
2007-01-24 18:22:31 +00:00
|
|
|
ORDER_WIDGET_ORDER_LIST,
|
|
|
|
ORDER_WIDGET_SCROLLBAR,
|
|
|
|
ORDER_WIDGET_SKIP,
|
|
|
|
ORDER_WIDGET_DELETE,
|
|
|
|
ORDER_WIDGET_NON_STOP,
|
|
|
|
ORDER_WIDGET_GOTO,
|
2008-04-11 15:58:46 +00:00
|
|
|
ORDER_WIDGET_GOTO_DROPDOWN,
|
2007-01-24 18:22:31 +00:00
|
|
|
ORDER_WIDGET_FULL_LOAD,
|
|
|
|
ORDER_WIDGET_UNLOAD,
|
2007-01-24 18:41:27 +00:00
|
|
|
ORDER_WIDGET_REFIT,
|
2008-04-09 19:52:33 +00:00
|
|
|
ORDER_WIDGET_SERVICE,
|
2008-04-12 11:58:19 +00:00
|
|
|
ORDER_WIDGET_COND_VARIABLE,
|
|
|
|
ORDER_WIDGET_COND_COMPARATOR,
|
|
|
|
ORDER_WIDGET_COND_VALUE,
|
2007-01-24 18:22:31 +00:00
|
|
|
ORDER_WIDGET_RESIZE_BAR,
|
2008-04-09 19:52:33 +00:00
|
|
|
ORDER_WIDGET_SHARED_ORDER_LIST,
|
2007-01-24 18:22:31 +00:00
|
|
|
ORDER_WIDGET_RESIZE,
|
|
|
|
};
|
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
/** Under what reason are we using the PlaceObject functionality? */
|
|
|
|
enum OrderPlaceObjectState {
|
|
|
|
OPOS_GOTO,
|
|
|
|
OPOS_CONDITIONAL,
|
|
|
|
};
|
|
|
|
|
2008-04-11 21:19:03 +00:00
|
|
|
struct order_d {
|
|
|
|
int sel;
|
2008-04-12 11:58:19 +00:00
|
|
|
OrderPlaceObjectState goto_type;
|
2008-04-11 21:19:03 +00:00
|
|
|
};
|
|
|
|
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d));
|
|
|
|
|
2007-06-08 18:59:29 +00:00
|
|
|
/**
|
|
|
|
* Return the memorised selected order.
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @return the memorised order if it is a vaild one
|
|
|
|
* else return the number of orders
|
|
|
|
*/
|
2006-07-26 03:33:12 +00:00
|
|
|
static int OrderGetSel(const Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2006-07-26 03:33:12 +00:00
|
|
|
const Vehicle *v = GetVehicle(w->window_number);
|
2007-12-16 10:54:08 +00:00
|
|
|
int num = WP(w, order_d).sel;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-10-23 13:04:44 +00:00
|
|
|
return (num >= 0 && num < v->num_orders) ? num : v->num_orders;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-06-08 18:59:29 +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 w current window
|
|
|
|
* @param y Y-value of the click relative to the window origin
|
|
|
|
* @param v current vehicle
|
|
|
|
* @return the new selected order if the order is valid else return that
|
|
|
|
* an invalid one has been selected.
|
|
|
|
*/
|
|
|
|
static int GetOrderFromOrderWndPt(Window *w, int y, const Vehicle *v)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Calculation description:
|
|
|
|
* 15 = 14 (w->widget[ORDER_WIDGET_ORDER_LIST].top) + 1 (frame-line)
|
|
|
|
* 10 = order text hight
|
|
|
|
*/
|
2008-04-12 11:58:19 +00:00
|
|
|
int sel = (y - w->widget[ORDER_WIDGET_ORDER_LIST].top - 1) / 10;
|
2007-06-08 18:59:29 +00:00
|
|
|
|
|
|
|
if ((uint)sel >= w->vscroll.cap) return INVALID_ORDER;
|
|
|
|
|
|
|
|
sel += w->vscroll.pos;
|
|
|
|
|
|
|
|
return (sel <= v->num_orders && sel >= 0) ? sel : INVALID_ORDER;
|
|
|
|
}
|
|
|
|
|
2008-04-09 22:01:23 +00:00
|
|
|
/** Order load types that could be given to station orders. */
|
|
|
|
static const StringID _station_load_types[][5] = {
|
2008-04-06 21:54:22 +00:00
|
|
|
{
|
2008-04-09 22:01:23 +00:00
|
|
|
STR_EMPTY,
|
2008-04-10 17:23:51 +00:00
|
|
|
INVALID_STRING_ID,
|
2008-04-09 22:01:23 +00:00
|
|
|
STR_ORDER_FULL_LOAD,
|
|
|
|
STR_ORDER_FULL_LOAD_ANY,
|
|
|
|
STR_ORDER_NO_LOAD,
|
2008-04-10 17:23:51 +00:00
|
|
|
}, {
|
|
|
|
STR_ORDER_UNLOAD,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
STR_ORDER_UNLOAD_FULL_LOAD,
|
|
|
|
STR_ORDER_UNLOAD_FULL_LOAD_ANY,
|
|
|
|
STR_ORDER_UNLOAD_NO_LOAD,
|
2008-04-06 21:54:22 +00:00
|
|
|
}, {
|
2008-04-09 22:01:23 +00:00
|
|
|
STR_ORDER_TRANSFER,
|
2008-04-10 17:23:51 +00:00
|
|
|
INVALID_STRING_ID,
|
2008-04-09 22:01:23 +00:00
|
|
|
STR_ORDER_TRANSFER_FULL_LOAD,
|
|
|
|
STR_ORDER_TRANSFER_FULL_LOAD_ANY,
|
2008-04-10 17:23:51 +00:00
|
|
|
STR_ORDER_TRANSFER_NO_LOAD,
|
|
|
|
}, {
|
|
|
|
/* Unload and transfer do not work together. */
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
INVALID_STRING_ID,
|
2008-04-09 22:01:23 +00:00
|
|
|
INVALID_STRING_ID,
|
2008-04-10 10:18:03 +00:00
|
|
|
}, {
|
|
|
|
STR_ORDER_NO_UNLOAD,
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
STR_ORDER_NO_UNLOAD_FULL_LOAD,
|
|
|
|
STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
|
|
|
|
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,
|
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,
|
2008-04-11 15:58:46 +00:00
|
|
|
INVALID_STRING_ID
|
|
|
|
};
|
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
static const StringID _order_conditional_variable[] = {
|
|
|
|
STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE,
|
|
|
|
STR_ORDER_CONDITIONAL_RELIABILITY,
|
|
|
|
STR_ORDER_CONDITIONAL_MAX_SPEED,
|
|
|
|
STR_ORDER_CONDITIONAL_AGE,
|
|
|
|
STR_ORDER_CONDITIONAL_REQUIRES_SERVICE,
|
2008-04-12 13:07:25 +00:00
|
|
|
STR_ORDER_CONDITIONAL_UNCONDITIONALLY,
|
2008-04-12 11:58:19 +00:00
|
|
|
INVALID_STRING_ID,
|
|
|
|
};
|
|
|
|
|
|
|
|
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-04-14 12:40:09 +00:00
|
|
|
void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable)
|
|
|
|
{
|
|
|
|
StringID str = (v->cur_order_index == order_index) ? STR_8805 : STR_8804;
|
|
|
|
SetDParam(6, STR_EMPTY);
|
|
|
|
|
|
|
|
switch (order->GetType()) {
|
|
|
|
case OT_DUMMY:
|
|
|
|
SetDParam(1, STR_INVALID_ORDER);
|
|
|
|
SetDParam(2, order->GetDestination());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OT_GOTO_STATION: {
|
|
|
|
OrderLoadFlags load = order->GetLoadType();
|
|
|
|
OrderUnloadFlags unload = order->GetUnloadType();
|
|
|
|
|
|
|
|
SetDParam(1, STR_GO_TO_STATION);
|
|
|
|
SetDParam(2, STR_ORDER_GO_TO + ((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? order->GetNonStopType() : 0));
|
|
|
|
SetDParam(3, order->GetDestination());
|
|
|
|
|
|
|
|
if (timetable) {
|
|
|
|
SetDParam(4, STR_EMPTY);
|
|
|
|
|
|
|
|
if (order->wait_time > 0) {
|
|
|
|
SetDParam(6, STR_TIMETABLE_STAY_FOR);
|
|
|
|
SetTimetableParams(7, 8, order->wait_time);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SetDParam(4, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ? STR_EMPTY : _station_load_types[unload][load]);
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case OT_GOTO_DEPOT:
|
|
|
|
if (v->type == VEH_AIRCRAFT) {
|
|
|
|
if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
|
|
|
|
SetDParam(1, STR_GO_TO_NEAREST_DEPOT);
|
|
|
|
SetDParam(3, STR_ORDER_NEAREST_HANGAR);
|
|
|
|
} else {
|
|
|
|
SetDParam(1, STR_GO_TO_HANGAR);
|
|
|
|
SetDParam(3, order->GetDestination());
|
|
|
|
}
|
|
|
|
SetDParam(4, STR_EMPTY);
|
|
|
|
} else {
|
|
|
|
if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
|
|
|
|
SetDParam(1, STR_GO_TO_NEAREST_DEPOT);
|
|
|
|
SetDParam(3, STR_ORDER_NEAREST_DEPOT);
|
|
|
|
} else {
|
|
|
|
SetDParam(1, STR_GO_TO_DEPOT);
|
|
|
|
SetDParam(3, GetDepot(order->GetDestination())->town_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (v->type) {
|
|
|
|
case VEH_TRAIN: SetDParam(4, STR_ORDER_TRAIN_DEPOT); break;
|
|
|
|
case VEH_ROAD: SetDParam(4, STR_ORDER_ROAD_DEPOT); break;
|
|
|
|
case VEH_SHIP: SetDParam(4, STR_ORDER_SHIP_DEPOT); break;
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (order->GetDepotOrderType() & ODTFB_SERVICE) {
|
|
|
|
SetDParam(2, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_SERVICE_NON_STOP_AT : STR_ORDER_SERVICE_AT);
|
|
|
|
} else {
|
|
|
|
SetDParam(2, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO : STR_ORDER_GO_TO);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!timetable && order->IsRefit()) {
|
|
|
|
SetDParam(6, STR_REFIT_ORDER);
|
|
|
|
SetDParam(7, GetCargo(order->GetRefitCargo())->name);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OT_GOTO_WAYPOINT:
|
|
|
|
SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
|
|
|
|
SetDParam(2, order->GetDestination());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OT_CONDITIONAL:
|
|
|
|
SetDParam(2, order->GetConditionSkipToOrder() + 1);
|
|
|
|
if (order->GetConditionVariable() == OCV_UNCONDITIONALLY) {
|
|
|
|
SetDParam(1, STR_CONDITIONAL_UNCONDITIONAL);
|
|
|
|
} else {
|
|
|
|
OrderConditionComparator occ = order->GetConditionComparator();
|
|
|
|
SetDParam(1, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_CONDITIONAL_TRUE_FALSE : STR_CONDITIONAL_NUM);
|
|
|
|
SetDParam(3, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable());
|
|
|
|
SetDParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
|
|
|
|
|
|
|
|
uint value = order->GetConditionValue();
|
|
|
|
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
|
|
|
SetDParam(5, value);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
SetDParam(0, order_index + 1);
|
|
|
|
DrawString(2, y, str, selected ? TC_WHITE : TC_BLACK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
static void DrawOrdersWindow(Window *w)
|
|
|
|
{
|
2008-04-09 16:16:04 +00:00
|
|
|
const Vehicle *v = GetVehicle(w->window_number);
|
|
|
|
bool shared_orders = v->IsOrderListShared();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-15 19:06:22 +00:00
|
|
|
SetVScrollCount(w, v->num_orders + 1);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
int sel = OrderGetSel(w);
|
|
|
|
const Order *order = GetVehicleOrder(v, sel);
|
2004-12-19 21:03:16 +00:00
|
|
|
|
2006-10-24 23:11:40 +00:00
|
|
|
if (v->owner == _local_player) {
|
2008-04-10 22:17:06 +00:00
|
|
|
/* Set the strings for the dropdown boxes. */
|
2008-04-12 11:58:19 +00:00
|
|
|
w->widget[ORDER_WIDGET_NON_STOP].data = _order_non_stop_drowdown[order == NULL ? 0 : order->GetNonStopType()];
|
|
|
|
w->widget[ORDER_WIDGET_FULL_LOAD].data = _order_full_load_drowdown[order == NULL ? 0 : order->GetLoadType()];
|
|
|
|
w->widget[ORDER_WIDGET_UNLOAD].data = _order_unload_drowdown[order == NULL ? 0 : order->GetUnloadType()];
|
|
|
|
w->widget[ORDER_WIDGET_COND_VARIABLE].data = _order_conditional_variable[order == NULL ? 0 : order->GetConditionVariable()];
|
|
|
|
w->widget[ORDER_WIDGET_COND_COMPARATOR].data = _order_conditional_condition[order == NULL ? 0 : order->GetConditionComparator()];
|
2008-04-10 22:17:06 +00:00
|
|
|
|
2006-10-24 23:11:40 +00:00
|
|
|
/* skip */
|
2007-12-02 14:29:48 +00:00
|
|
|
w->SetWidgetDisabledState(ORDER_WIDGET_SKIP, v->num_orders <= 1);
|
2006-10-24 23:11:40 +00:00
|
|
|
|
|
|
|
/* delete */
|
2007-12-02 14:29:48 +00:00
|
|
|
w->SetWidgetDisabledState(ORDER_WIDGET_DELETE,
|
2007-02-12 00:38:15 +00:00
|
|
|
(uint)v->num_orders + ((shared_orders || v->num_orders != 0) ? 1 : 0) <= (uint)WP(w, order_d).sel);
|
2006-10-24 23:11:40 +00:00
|
|
|
|
|
|
|
/* non-stop only for trains */
|
2008-04-13 16:54:19 +00:00
|
|
|
w->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP, (v->type != VEH_TRAIN && v->type != VEH_ROAD) || order == NULL);
|
2008-04-10 17:52:48 +00:00
|
|
|
w->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD, order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // full load
|
|
|
|
w->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD, order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload
|
2006-10-24 23:11:40 +00:00
|
|
|
/* Disable list of vehicles with the same shared orders if there is no list */
|
2007-12-02 14:29:48 +00:00
|
|
|
w->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || v->orders == NULL);
|
|
|
|
w->SetWidgetDisabledState(ORDER_WIDGET_REFIT, order == NULL); // Refit
|
2008-04-09 19:52:33 +00:00
|
|
|
w->SetWidgetDisabledState(ORDER_WIDGET_SERVICE, order == NULL); // Refit
|
2007-12-02 14:29:48 +00:00
|
|
|
w->HideWidget(ORDER_WIDGET_REFIT); // Refit
|
2008-04-09 19:52:33 +00:00
|
|
|
w->HideWidget(ORDER_WIDGET_SERVICE); // Service
|
2008-04-12 11:58:19 +00:00
|
|
|
|
|
|
|
w->HideWidget(ORDER_WIDGET_COND_VARIABLE);
|
|
|
|
w->HideWidget(ORDER_WIDGET_COND_COMPARATOR);
|
|
|
|
w->HideWidget(ORDER_WIDGET_COND_VALUE);
|
2006-10-24 23:11:40 +00:00
|
|
|
}
|
2006-10-03 14:52:39 +00:00
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
w->ShowWidget(ORDER_WIDGET_NON_STOP);
|
2008-04-09 19:52:33 +00:00
|
|
|
w->ShowWidget(ORDER_WIDGET_UNLOAD);
|
2008-04-10 17:23:51 +00:00
|
|
|
w->ShowWidget(ORDER_WIDGET_FULL_LOAD);
|
2006-10-03 02:08:15 +00:00
|
|
|
|
2005-01-15 19:06:22 +00:00
|
|
|
if (order != NULL) {
|
2008-04-05 23:36:54 +00:00
|
|
|
switch (order->GetType()) {
|
2007-12-11 17:44:55 +00:00
|
|
|
case OT_GOTO_STATION:
|
2008-04-06 07:48:51 +00:00
|
|
|
if (!GetStation(order->GetDestination())->IsBuoy()) break;
|
2007-12-11 17:44:55 +00:00
|
|
|
/* Fall-through */
|
|
|
|
|
|
|
|
case OT_GOTO_WAYPOINT:
|
|
|
|
w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
|
|
|
|
w->DisableWidget(ORDER_WIDGET_UNLOAD);
|
|
|
|
break;
|
2005-10-23 13:04:44 +00:00
|
|
|
|
2005-01-15 19:06:22 +00:00
|
|
|
case OT_GOTO_DEPOT:
|
2008-04-09 19:52:33 +00:00
|
|
|
w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
|
2006-10-03 14:52:39 +00:00
|
|
|
|
|
|
|
/* Remove unload and replace it with refit */
|
2007-12-02 14:29:48 +00:00
|
|
|
w->HideWidget(ORDER_WIDGET_UNLOAD);
|
|
|
|
w->ShowWidget(ORDER_WIDGET_REFIT);
|
2008-04-10 17:23:51 +00:00
|
|
|
w->HideWidget(ORDER_WIDGET_FULL_LOAD);
|
2008-04-09 19:52:33 +00:00
|
|
|
w->ShowWidget(ORDER_WIDGET_SERVICE);
|
2005-01-15 19:06:22 +00:00
|
|
|
break;
|
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
case OT_CONDITIONAL: {
|
|
|
|
w->HideWidget(ORDER_WIDGET_NON_STOP);
|
|
|
|
w->HideWidget(ORDER_WIDGET_UNLOAD);
|
|
|
|
w->HideWidget(ORDER_WIDGET_FULL_LOAD);
|
|
|
|
w->ShowWidget(ORDER_WIDGET_COND_VARIABLE);
|
|
|
|
w->ShowWidget(ORDER_WIDGET_COND_COMPARATOR);
|
|
|
|
w->ShowWidget(ORDER_WIDGET_COND_VALUE);
|
|
|
|
|
|
|
|
OrderConditionVariable ocv = order->GetConditionVariable();
|
2008-04-12 13:07:25 +00:00
|
|
|
w->SetWidgetDisabledState(ORDER_WIDGET_COND_COMPARATOR, ocv == OCV_UNCONDITIONALLY);
|
|
|
|
w->SetWidgetDisabledState(ORDER_WIDGET_COND_VALUE, ocv == OCV_REQUIRES_SERVICE || ocv == OCV_UNCONDITIONALLY);
|
2008-04-12 11:58:19 +00:00
|
|
|
|
|
|
|
uint value = order->GetConditionValue();
|
|
|
|
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
|
|
|
SetDParam(1, value);
|
|
|
|
} break;
|
|
|
|
|
2006-10-03 02:08:15 +00:00
|
|
|
default: // every other orders
|
2007-12-02 14:29:48 +00:00
|
|
|
w->DisableWidget(ORDER_WIDGET_NON_STOP);
|
|
|
|
w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
|
|
|
|
w->DisableWidget(ORDER_WIDGET_UNLOAD);
|
2005-01-15 19:06:22 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2007-06-24 22:42:11 +00:00
|
|
|
SetDParam(0, v->index);
|
2004-08-09 17:04:08 +00:00
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
int y = 15;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
int i = w->vscroll.pos;
|
2005-01-15 19:06:22 +00:00
|
|
|
order = GetVehicleOrder(v, i);
|
2008-04-09 16:16:04 +00:00
|
|
|
StringID str;
|
2005-01-15 19:06:22 +00:00
|
|
|
while (order != NULL) {
|
2008-04-14 12:40:09 +00:00
|
|
|
/* Don't draw anything if it extends past the end of the window. */
|
|
|
|
if (i - w->vscroll.pos >= w->vscroll.cap) break;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2008-04-14 12:40:09 +00:00
|
|
|
DrawOrderString(v, order, i, y, i == WP(w, order_d).sel, false);
|
|
|
|
y += 10;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
i++;
|
2005-01-15 19:06:22 +00:00
|
|
|
order = order->next;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-30 23:41:57 +00:00
|
|
|
if (i - w->vscroll.pos < w->vscroll.cap) {
|
2005-01-15 19:06:22 +00:00
|
|
|
str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS;
|
2007-12-16 10:54:08 +00:00
|
|
|
DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK);
|
2004-08-09 17:04:08 +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 */
|
2004-08-09 17:04:08 +00:00
|
|
|
if (_patches.gotodepot) {
|
2005-01-29 15:12:40 +00:00
|
|
|
switch (GetTileType(tile)) {
|
2008-04-09 16:16:04 +00:00
|
|
|
case MP_RAILWAY:
|
|
|
|
if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_player)) {
|
|
|
|
if (IsRailDepot(tile)) {
|
|
|
|
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
|
2008-04-13 16:50:55 +00:00
|
|
|
if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
2008-04-09 16:16:04 +00:00
|
|
|
return order;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MP_ROAD:
|
|
|
|
if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) {
|
2008-04-07 19:18:56 +00:00
|
|
|
order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS);
|
2008-04-13 16:54:19 +00:00
|
|
|
if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
2004-12-05 21:30:58 +00:00
|
|
|
return order;
|
2004-12-06 00:03:26 +00:00
|
|
|
}
|
2008-04-09 16:16:04 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case MP_STATION:
|
|
|
|
if (v->type != VEH_AIRCRAFT) break;
|
|
|
|
if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
|
|
|
|
order.MakeGoToDepot(GetStationIndex(tile), ODTFB_PART_OF_ORDERS);
|
|
|
|
return order;
|
|
|
|
}
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case MP_WATER:
|
|
|
|
if (v->type != VEH_SHIP) break;
|
2008-04-17 18:24:45 +00:00
|
|
|
if (IsShipDepot(tile) && IsTileOwner(tile, _local_player)) {
|
2008-04-09 16:16:04 +00:00
|
|
|
TileIndex tile2 = GetOtherShipDepotTile(tile);
|
2006-03-31 10:47:06 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS);
|
|
|
|
return order;
|
|
|
|
}
|
2005-01-29 15:12:40 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
/* check waypoint */
|
2005-06-04 11:56:32 +00:00
|
|
|
if (IsTileType(tile, MP_RAILWAY) &&
|
2007-03-08 16:27:54 +00:00
|
|
|
v->type == VEH_TRAIN &&
|
2005-06-04 11:56:32 +00:00
|
|
|
IsTileOwner(tile, _local_player) &&
|
2005-11-16 14:41:01 +00:00
|
|
|
IsRailWaypoint(tile)) {
|
2008-04-05 23:36:54 +00:00
|
|
|
order.MakeGoToWaypoint(GetWaypointByTile(tile)->index);
|
2008-04-13 16:50:55 +00:00
|
|
|
if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
2004-12-05 21:30:58 +00:00
|
|
|
return order;
|
|
|
|
}
|
2004-09-27 14:30:17 +00:00
|
|
|
|
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);
|
2006-07-26 03:33:12 +00:00
|
|
|
const Station *st = GetStation(st_index);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (st->owner == _current_player || st->owner == OWNER_NONE) {
|
|
|
|
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) ||
|
|
|
|
(facil = FACIL_BUS_STOP, v->type == VEH_ROAD && IsCargoInClass(v->cargo_type, CC_PASSENGERS)) ||
|
|
|
|
(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);
|
2008-04-13 16:54:19 +00:00
|
|
|
if (_patches.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
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
|
|
|
}
|
|
|
|
|
2006-07-26 03:33:12 +00:00
|
|
|
static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2005-10-23 13:04:44 +00:00
|
|
|
if (u->type != v->type) return false;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2007-09-09 11:23:49 +00:00
|
|
|
if (!u->IsPrimaryVehicle()) {
|
2007-08-30 21:11:12 +00:00
|
|
|
u = u->First();
|
2007-06-01 12:03:10 +00:00
|
|
|
if (!u->IsPrimaryVehicle()) return false;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
/* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet
|
|
|
|
* obviously if you press CTRL on a non-empty orders vehicle you know what you are doing */
|
2005-10-23 13:04:44 +00:00
|
|
|
if (v->num_orders != 0 && _ctrl_pressed == 0) return false;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2007-12-12 14:37:35 +00:00
|
|
|
if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY, NULL,
|
2004-08-09 17:04:08 +00:00
|
|
|
_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) {
|
2007-12-16 10:54:08 +00:00
|
|
|
WP(w, order_d).sel = -1;
|
2004-08-09 17:04:08 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-07-26 03:33:12 +00:00
|
|
|
static void OrdersPlaceObj(const Vehicle *v, TileIndex tile, Window *w)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
2008-04-09 16:16:04 +00:00
|
|
|
/* check if we're clicking on a vehicle first.. clone orders in that case. */
|
|
|
|
const Vehicle *u = CheckMouseOverVehicle();
|
2005-10-23 13:04:44 +00:00
|
|
|
if (u != NULL && HandleOrderVehClick(v, u, w)) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
const Order cmd = GetOrderCmdFromTile(v, tile);
|
2007-03-08 21:39:34 +00:00
|
|
|
if (!cmd.IsValid()) return;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-06 07:22:26 +00:00
|
|
|
if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), cmd.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
|
2008-04-18 04:37:06 +00:00
|
|
|
if (WP(w, order_d).sel != -1) WP(w, order_d).sel++;
|
2004-08-09 17:04:08 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the goto button.
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @param v current vehicle
|
|
|
|
*/
|
2008-04-09 23:00:12 +00:00
|
|
|
static void OrderClick_Goto(Window *w, const Vehicle *v, int i)
|
2005-01-13 16:55:17 +00:00
|
|
|
{
|
2007-12-07 18:05:49 +00:00
|
|
|
w->InvalidateWidget(ORDER_WIDGET_GOTO);
|
2007-12-02 14:29:48 +00:00
|
|
|
w->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO);
|
|
|
|
if (w->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
|
2005-01-13 16:55:17 +00:00
|
|
|
_place_clicked_vehicle = NULL;
|
2007-11-15 18:28:00 +00:00
|
|
|
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, VHM_RECT, w);
|
2008-04-12 11:58:19 +00:00
|
|
|
WP(w, order_d).goto_type = OPOS_GOTO;
|
2005-01-13 16:55:17 +00:00
|
|
|
} else {
|
|
|
|
ResetObjectToPlace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the full load button.
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @param v current vehicle
|
2008-04-09 23:00:12 +00:00
|
|
|
* @param load_type the way to load.
|
2007-06-05 22:17:03 +00:00
|
|
|
*/
|
2008-04-09 23:00:12 +00:00
|
|
|
static void OrderClick_FullLoad(Window *w, const Vehicle *v, int load_type)
|
2005-01-13 16:55:17 +00:00
|
|
|
{
|
2008-04-09 12:46:43 +00:00
|
|
|
VehicleOrderID sel_ord = OrderGetSel(w);
|
|
|
|
const Order *order = GetVehicleOrder(v, sel_ord);
|
|
|
|
|
2008-04-10 17:23:51 +00:00
|
|
|
if (order->GetLoadType() == load_type) return;
|
2008-04-10 08:30:15 +00:00
|
|
|
|
|
|
|
if (load_type < 0) {
|
|
|
|
switch (order->GetLoadType()) {
|
|
|
|
case OLF_LOAD_IF_POSSIBLE: load_type = OLFB_FULL_LOAD; break;
|
|
|
|
case OLFB_FULL_LOAD: load_type = OLF_FULL_LOAD_ANY; break;
|
2008-04-10 10:18:03 +00:00
|
|
|
case OLF_FULL_LOAD_ANY: load_type = OLFB_NO_LOAD; break;
|
|
|
|
case OLFB_NO_LOAD: load_type = OLF_LOAD_IF_POSSIBLE; break;
|
2008-04-10 08:30:15 +00:00
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
2008-04-12 11:58:19 +00:00
|
|
|
DoCommandP(v->tile, v->index + (sel_ord << 16), MOF_LOAD | (load_type << 4), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
|
2008-04-09 19:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the click on the service.
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @param v current vehicle
|
|
|
|
*/
|
2008-04-09 23:00:12 +00:00
|
|
|
static void OrderClick_Service(Window *w, const Vehicle *v, int i)
|
2008-04-09 19:52:33 +00:00
|
|
|
{
|
|
|
|
DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), MOF_DEPOT_ACTION, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
|
2005-01-13 16:55:17 +00:00
|
|
|
}
|
|
|
|
|
2008-04-11 15:58:46 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the service in nearest depot button.
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @param v current vehicle
|
|
|
|
*/
|
|
|
|
static void OrderClick_NearestDepot(Window *w, const Vehicle *v, int i)
|
|
|
|
{
|
|
|
|
Order order;
|
|
|
|
order.next = NULL;
|
|
|
|
order.index = 0;
|
|
|
|
order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS);
|
|
|
|
order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
|
|
|
|
|
|
|
|
DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), order.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER));
|
|
|
|
}
|
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the conditional order button.
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @param v current vehicle
|
|
|
|
*/
|
|
|
|
static void OrderClick_Conditional(Window *w, const Vehicle *v, int i)
|
|
|
|
{
|
|
|
|
w->InvalidateWidget(ORDER_WIDGET_GOTO);
|
|
|
|
w->LowerWidget(ORDER_WIDGET_GOTO);
|
|
|
|
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, VHM_RECT, w);
|
|
|
|
WP(w, order_d).goto_type = OPOS_CONDITIONAL;
|
|
|
|
}
|
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the unload button.
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @param v current vehicle
|
|
|
|
*/
|
2008-04-10 10:18:03 +00:00
|
|
|
static void OrderClick_Unload(Window *w, const Vehicle *v, int unload_type)
|
2005-01-13 16:55:17 +00:00
|
|
|
{
|
2008-04-09 12:46:43 +00:00
|
|
|
VehicleOrderID sel_ord = OrderGetSel(w);
|
|
|
|
const Order *order = GetVehicleOrder(v, sel_ord);
|
|
|
|
|
2008-04-10 17:23:51 +00:00
|
|
|
if (order->GetUnloadType() == unload_type) return;
|
|
|
|
|
2008-04-10 10:18:03 +00:00
|
|
|
if (unload_type < 0) {
|
|
|
|
switch (order->GetUnloadType()) {
|
|
|
|
case OUF_UNLOAD_IF_POSSIBLE: unload_type = OUFB_UNLOAD; break;
|
2008-04-10 17:23:51 +00:00
|
|
|
case OUFB_UNLOAD: unload_type = OUFB_TRANSFER; break;
|
|
|
|
case OUFB_TRANSFER: unload_type = OUFB_NO_UNLOAD; break;
|
2008-04-10 10:18:03 +00:00
|
|
|
case OUFB_NO_UNLOAD: unload_type = OUF_UNLOAD_IF_POSSIBLE; break;
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
DoCommandP(v->tile, v->index + (sel_ord << 16), MOF_UNLOAD | (unload_type << 4), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
|
2005-01-13 16:55:17 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the nonstop button.
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @param v current vehicle
|
2008-04-09 23:00:12 +00:00
|
|
|
* @param non_stop what non-stop type to use; -1 to use the 'next' one.
|
2007-06-05 22:17:03 +00:00
|
|
|
*/
|
2008-04-09 23:00:12 +00:00
|
|
|
static void OrderClick_Nonstop(Window *w, const Vehicle *v, int non_stop)
|
2005-01-13 16:55:17 +00:00
|
|
|
{
|
2008-04-09 12:46:43 +00:00
|
|
|
VehicleOrderID sel_ord = OrderGetSel(w);
|
|
|
|
const Order *order = GetVehicleOrder(v, sel_ord);
|
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
if (order->GetNonStopType() == non_stop) return;
|
|
|
|
|
|
|
|
/* Keypress if negative, so 'toggle' to the next */
|
|
|
|
if (non_stop < 0) {
|
|
|
|
non_stop = (order->GetNonStopType() + 1) % ONSF_END;
|
|
|
|
}
|
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
DoCommandP(v->tile, v->index + (sel_ord << 16), MOF_NON_STOP | non_stop << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
|
2005-01-13 16:55:17 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the transfer button.
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @param v current vehicle
|
|
|
|
*/
|
2008-04-09 23:00:12 +00:00
|
|
|
static void OrderClick_Transfer(Window *w, const Vehicle *v, int i)
|
2005-06-15 16:58:15 +00:00
|
|
|
{
|
2008-04-09 12:46:43 +00:00
|
|
|
VehicleOrderID sel_ord = OrderGetSel(w);
|
|
|
|
const Order *order = GetVehicleOrder(v, sel_ord);
|
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
DoCommandP(v->tile, v->index + (sel_ord << 16), MOF_UNLOAD | ((order->GetUnloadType() & ~OUFB_NO_UNLOAD) ^ OUFB_TRANSFER) << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
|
2005-06-15 16:58:15 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the skip button.
|
|
|
|
* If ctrl is pressed skip to selected order.
|
|
|
|
* Else skip to current order + 1
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @param v current vehicle
|
|
|
|
*/
|
2008-04-09 23:00:12 +00:00
|
|
|
static void OrderClick_Skip(Window *w, const Vehicle *v, int i)
|
2005-01-13 16:55:17 +00:00
|
|
|
{
|
2007-06-04 19:32:45 +00:00
|
|
|
/* Don't skip when there's nothing to skip */
|
|
|
|
if (_ctrl_pressed && v->cur_order_index == OrderGetSel(w)) return;
|
|
|
|
|
|
|
|
DoCommandP(v->tile, v->index, _ctrl_pressed ? OrderGetSel(w) : ((v->cur_order_index + 1) % v->num_orders),
|
|
|
|
NULL, CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_CAN_T_SKIP_TO_ORDER : STR_CAN_T_SKIP_ORDER));
|
2005-01-13 16:55:17 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the unload button.
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @param v current vehicle
|
|
|
|
*/
|
2008-04-09 23:00:12 +00:00
|
|
|
static void OrderClick_Delete(Window *w, const Vehicle *v, int i)
|
2005-01-13 16:55:17 +00:00
|
|
|
{
|
2005-01-15 19:06:22 +00:00
|
|
|
DoCommandP(v->tile, v->index, OrderGetSel(w), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER));
|
2005-01-13 16:55:17 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Handle the click on the refit button.
|
|
|
|
* If ctrl is pressed cancel refitting.
|
|
|
|
* Else show the refit window.
|
|
|
|
*
|
|
|
|
* @param w current window
|
|
|
|
* @param v current vehicle
|
|
|
|
*/
|
2008-04-09 23:00:12 +00:00
|
|
|
static void OrderClick_Refit(Window *w, const Vehicle *v, int i)
|
2006-10-03 14:52:39 +00:00
|
|
|
{
|
|
|
|
if (_ctrl_pressed) {
|
|
|
|
/* Cancel refitting */
|
2007-12-16 10:54:08 +00:00
|
|
|
DoCommandP(v->tile, v->index, (WP(w, order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT);
|
2006-10-03 14:52:39 +00:00
|
|
|
} else {
|
2007-12-16 10:54:08 +00:00
|
|
|
ShowVehicleRefitWindow(v, WP(w, order_d).sel);
|
2006-10-03 14:52:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
typedef void OnButtonVehClick(Window *w, const Vehicle *v, int i);
|
2005-01-13 16:55:17 +00:00
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Keycode function mapping.
|
|
|
|
*
|
|
|
|
* @see _order_keycodes[]
|
|
|
|
* @note Keep them allways in sync with _order_keycodes[]!
|
|
|
|
*/
|
2006-07-26 03:33:12 +00:00
|
|
|
static OnButtonVehClick* const _order_button_proc[] = {
|
2005-01-13 16:55:17 +00:00
|
|
|
OrderClick_Skip,
|
|
|
|
OrderClick_Delete,
|
|
|
|
OrderClick_Nonstop,
|
|
|
|
OrderClick_Goto,
|
|
|
|
OrderClick_FullLoad,
|
2005-06-15 16:58:15 +00:00
|
|
|
OrderClick_Unload,
|
2008-04-09 19:52:33 +00:00
|
|
|
OrderClick_Transfer,
|
|
|
|
OrderClick_Service,
|
2005-01-13 16:55:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const uint16 _order_keycodes[] = {
|
|
|
|
'D', //skip order
|
|
|
|
'F', //delete order
|
|
|
|
'G', //non-stop
|
|
|
|
'H', //goto order
|
|
|
|
'J', //full load
|
|
|
|
'K' //unload
|
|
|
|
};
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
static void OrdersWndProc(Window *w, WindowEvent *e)
|
|
|
|
{
|
2008-04-09 16:16:04 +00:00
|
|
|
const Vehicle *v = GetVehicle(w->window_number);
|
|
|
|
|
2005-10-23 13:04:44 +00:00
|
|
|
switch (e->event) {
|
2006-10-03 14:52:39 +00:00
|
|
|
case WE_CREATE:
|
2007-06-20 19:17:22 +00:00
|
|
|
if (_patches.timetabling) {
|
|
|
|
w->widget[ORDER_WIDGET_CAPTION].right -= 61;
|
|
|
|
} else {
|
2007-12-02 14:29:48 +00:00
|
|
|
w->HideWidget(ORDER_WIDGET_TIMETABLE_VIEW);
|
2007-06-20 19:17:22 +00:00
|
|
|
}
|
|
|
|
|
2006-10-03 14:52:39 +00:00
|
|
|
break;
|
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case WE_PAINT:
|
|
|
|
DrawOrdersWindow(w);
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case WE_CLICK:
|
2008-04-10 22:07:24 +00:00
|
|
|
if (w->widget[e->we.click.widget].type != WWT_DROPDOWN) HideDropDownMenu(w);
|
2008-04-09 16:16:04 +00:00
|
|
|
switch (e->we.click.widget) {
|
|
|
|
case ORDER_WIDGET_ORDER_LIST: {
|
|
|
|
ResetObjectToPlace();
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
int sel = GetOrderFromOrderWndPt(w, e->we.click.pt.y, v);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
if (sel == INVALID_ORDER) {
|
|
|
|
/* This was a click on an empty part of the orders window, so
|
|
|
|
* deselect the currently selected order. */
|
|
|
|
WP(w, order_d).sel = -1;
|
|
|
|
SetWindowDirty(w);
|
|
|
|
return;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
if (_ctrl_pressed && sel < v->num_orders) {
|
|
|
|
const Order *ord = GetVehicleOrder(v, sel);
|
|
|
|
TileIndex xy;
|
2006-06-27 21:25:53 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
switch (ord->GetType()) {
|
|
|
|
case OT_GOTO_STATION: xy = GetStation(ord->GetDestination())->xy ; break;
|
|
|
|
case OT_GOTO_DEPOT: xy = (v->type == VEH_AIRCRAFT) ? GetStation(ord->GetDestination())->xy : GetDepot(ord->GetDestination())->xy; break;
|
|
|
|
case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->GetDestination())->xy; break;
|
|
|
|
default: xy = 0; break;
|
|
|
|
}
|
2004-08-13 20:30:45 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
if (xy != 0) ScrollMainWindowToTile(xy);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
if (sel == WP(w, order_d).sel) {
|
|
|
|
/* Deselect clicked order */
|
|
|
|
WP(w, order_d).sel = -1;
|
|
|
|
} else {
|
|
|
|
/* Select clicked order */
|
|
|
|
WP(w, order_d).sel = sel;
|
|
|
|
|
|
|
|
if (v->owner == _local_player) {
|
|
|
|
/* Activate drag and drop */
|
|
|
|
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, VHM_DRAG, w);
|
|
|
|
}
|
|
|
|
}
|
2007-06-08 18:59:29 +00:00
|
|
|
}
|
2004-08-13 20:30:45 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
SetWindowDirty(w);
|
|
|
|
} break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case ORDER_WIDGET_SKIP:
|
2008-04-09 23:00:12 +00:00
|
|
|
OrderClick_Skip(w, v, 0);
|
2008-04-09 16:16:04 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case ORDER_WIDGET_DELETE:
|
2008-04-09 23:00:12 +00:00
|
|
|
OrderClick_Delete(w, v, 0);
|
2008-04-09 16:16:04 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-10 10:02:15 +00:00
|
|
|
case ORDER_WIDGET_NON_STOP: {
|
|
|
|
const Order *o = GetVehicleOrder(v, OrderGetSel(w));
|
2008-04-10 17:23:51 +00:00
|
|
|
ShowDropDownMenu(w, _order_non_stop_drowdown, o->GetNonStopType(), ORDER_WIDGET_NON_STOP, 0, o->IsType(OT_GOTO_STATION) ? 0 : (o->IsType(OT_GOTO_WAYPOINT) ? 3 : 12));
|
2008-04-10 10:02:15 +00:00
|
|
|
} break;
|
2005-01-15 08:58:31 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case ORDER_WIDGET_GOTO:
|
2008-04-09 23:00:12 +00:00
|
|
|
OrderClick_Goto(w, v, 0);
|
2008-04-09 16:16:04 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-11 15:58:46 +00:00
|
|
|
case ORDER_WIDGET_GOTO_DROPDOWN:
|
|
|
|
ShowDropDownMenu(w, v->type == VEH_AIRCRAFT ? _order_goto_dropdown_aircraft : _order_goto_dropdown, 0, ORDER_WIDGET_GOTO, 0, 0, w->widget[ORDER_WIDGET_GOTO_DROPDOWN].right - w->widget[ORDER_WIDGET_GOTO].left);
|
|
|
|
break;
|
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case ORDER_WIDGET_FULL_LOAD:
|
2008-04-10 17:23:51 +00:00
|
|
|
ShowDropDownMenu(w, _order_full_load_drowdown, GetVehicleOrder(v, OrderGetSel(w))->GetLoadType(), ORDER_WIDGET_FULL_LOAD, 0, 2);
|
2008-04-09 16:16:04 +00:00
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case ORDER_WIDGET_UNLOAD:
|
2008-04-10 17:23:51 +00:00
|
|
|
ShowDropDownMenu(w, _order_unload_drowdown, GetVehicleOrder(v, OrderGetSel(w))->GetUnloadType(), ORDER_WIDGET_UNLOAD, 0, 8);
|
2008-04-09 16:16:04 +00:00
|
|
|
break;
|
2008-04-09 19:52:33 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case ORDER_WIDGET_REFIT:
|
2008-04-09 23:00:12 +00:00
|
|
|
OrderClick_Refit(w, v, 0);
|
2008-04-09 16:16:04 +00:00
|
|
|
break;
|
2007-01-24 18:41:27 +00:00
|
|
|
|
2008-04-09 19:52:33 +00:00
|
|
|
case ORDER_WIDGET_SERVICE:
|
2008-04-09 23:00:12 +00:00
|
|
|
OrderClick_Service(w, v, 0);
|
2008-04-09 19:52:33 +00:00
|
|
|
break;
|
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case ORDER_WIDGET_TIMETABLE_VIEW:
|
|
|
|
ShowTimetableWindow(v);
|
|
|
|
break;
|
2007-06-20 19:17:22 +00:00
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
case ORDER_WIDGET_COND_VARIABLE:
|
|
|
|
ShowDropDownMenu(w, _order_conditional_variable, GetVehicleOrder(v, OrderGetSel(w))->GetConditionVariable(), ORDER_WIDGET_COND_VARIABLE, 0, 0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_WIDGET_COND_COMPARATOR: {
|
|
|
|
const Order *o = GetVehicleOrder(v, OrderGetSel(w));
|
|
|
|
ShowDropDownMenu(w, _order_conditional_condition, o->GetConditionComparator(), ORDER_WIDGET_COND_COMPARATOR, 0, (o->GetConditionVariable() == OCV_REQUIRES_SERVICE) ? 0x3F : 0xC0);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case ORDER_WIDGET_COND_VALUE: {
|
|
|
|
const Order *order = GetVehicleOrder(v, OrderGetSel(w));
|
|
|
|
uint value = order->GetConditionValue();
|
|
|
|
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
|
|
|
|
SetDParam(0, value);
|
|
|
|
ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, 100, w, CS_NUMERAL);
|
|
|
|
} break;
|
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case ORDER_WIDGET_SHARED_ORDER_LIST:
|
|
|
|
ShowVehicleListWindow(v);
|
|
|
|
break;
|
|
|
|
}
|
2006-08-26 22:28:40 +00:00
|
|
|
break;
|
2005-01-15 08:58:31 +00:00
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
case WE_ON_EDIT_TEXT:
|
|
|
|
if (!StrEmpty(e->we.edittext.str)) {
|
|
|
|
VehicleOrderID sel = OrderGetSel(w);
|
|
|
|
uint value = atoi(e->we.edittext.str);
|
|
|
|
|
|
|
|
switch (GetVehicleOrder(v, sel)->GetConditionVariable()) {
|
|
|
|
case OCV_MAX_SPEED:
|
|
|
|
value = ConvertDisplaySpeedToSpeed(value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OCV_RELIABILITY:
|
|
|
|
case OCV_LOAD_PERCENTAGE:
|
|
|
|
value = Clamp(value, 0, 100);
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
DoCommandP(v->tile, v->index + (sel << 16), MOF_COND_VALUE | Clamp(value, 0, 2047) << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list
|
|
|
|
switch (e->we.dropdown.button) {
|
|
|
|
case ORDER_WIDGET_NON_STOP:
|
|
|
|
OrderClick_Nonstop(w, v, e->we.dropdown.index);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_WIDGET_FULL_LOAD:
|
2008-04-10 10:18:03 +00:00
|
|
|
OrderClick_FullLoad(w, v, e->we.dropdown.index);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_WIDGET_UNLOAD:
|
|
|
|
OrderClick_Unload(w, v, e->we.dropdown.index);
|
2008-04-09 23:00:12 +00:00
|
|
|
break;
|
2008-04-11 15:58:46 +00:00
|
|
|
|
|
|
|
case ORDER_WIDGET_GOTO:
|
|
|
|
switch (e->we.dropdown.index) {
|
2008-04-12 11:58:19 +00:00
|
|
|
case 0:
|
|
|
|
w->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO);
|
|
|
|
OrderClick_Goto(w, v, 0);
|
|
|
|
break;
|
|
|
|
|
2008-04-11 15:58:46 +00:00
|
|
|
case 1: OrderClick_NearestDepot(w, v, 0); break;
|
2008-04-12 11:58:19 +00:00
|
|
|
case 2: OrderClick_Conditional(w, v, 0); break;
|
2008-04-11 15:58:46 +00:00
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
2008-04-12 11:58:19 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_WIDGET_COND_VARIABLE:
|
|
|
|
DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), MOF_COND_VARIABLE | e->we.dropdown.index << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORDER_WIDGET_COND_COMPARATOR:
|
|
|
|
DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), MOF_COND_COMPARATOR | e->we.dropdown.index << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
|
|
|
|
break;
|
2008-04-09 23:00:12 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case WE_DRAGDROP:
|
|
|
|
switch (e->we.click.widget) {
|
|
|
|
case ORDER_WIDGET_ORDER_LIST: {
|
|
|
|
int from_order = OrderGetSel(w);
|
|
|
|
int to_order = GetOrderFromOrderWndPt(w, e->we.dragdrop.pt.y, v);
|
2007-06-08 18:59:29 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
if (!(from_order == to_order || from_order == INVALID_ORDER || from_order > v->num_orders || to_order == INVALID_ORDER || to_order > v->num_orders) &&
|
|
|
|
DoCommandP(v->tile, v->index, from_order | (to_order << 16), NULL, CMD_MOVE_ORDER | CMD_MSG(STR_CAN_T_MOVE_THIS_ORDER))) {
|
|
|
|
WP(w, order_d).sel = -1;
|
|
|
|
}
|
2007-06-08 18:59:29 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
} break;
|
2007-06-08 18:59:29 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case ORDER_WIDGET_DELETE:
|
2008-04-09 23:00:12 +00:00
|
|
|
OrderClick_Delete(w, v, 0);
|
2008-04-09 16:16:04 +00:00
|
|
|
break;
|
2007-06-08 18:59:29 +00:00
|
|
|
}
|
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
ResetObjectToPlace();
|
|
|
|
break;
|
2007-06-08 18:59:29 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case WE_KEYPRESS:
|
|
|
|
if (v->owner != _local_player) break;
|
2007-06-08 18:59:29 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
for (uint i = 0; i < lengthof(_order_keycodes); i++) {
|
|
|
|
if (e->we.keypress.keycode == _order_keycodes[i]) {
|
|
|
|
e->we.keypress.cont = false;
|
|
|
|
/* see if the button is disabled */
|
2008-04-09 23:00:12 +00:00
|
|
|
if (!w->IsWidgetDisabled(i + ORDER_WIDGET_SKIP)) _order_button_proc[i](w, v, -1);
|
2008-04-09 16:16:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2005-01-13 16:55:17 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case WE_PLACE_OBJ:
|
2008-04-12 11:58:19 +00:00
|
|
|
if (WP(w, order_d).goto_type == OPOS_GOTO) {
|
|
|
|
OrdersPlaceObj(GetVehicle(w->window_number), e->we.place.tile, w);
|
|
|
|
}
|
2008-04-09 16:16:04 +00:00
|
|
|
break;
|
2005-11-14 19:48:04 +00:00
|
|
|
|
2008-04-09 16:16:04 +00:00
|
|
|
case WE_ABORT_PLACE_OBJ:
|
2008-04-12 11:58:19 +00:00
|
|
|
if (WP(w, order_d).goto_type == OPOS_CONDITIONAL) {
|
|
|
|
WP(w, order_d).goto_type = OPOS_GOTO;
|
|
|
|
if (_cursor.pos.x >= (w->left + w->widget[ORDER_WIDGET_ORDER_LIST].left) &&
|
|
|
|
_cursor.pos.y >= (w->top + w->widget[ORDER_WIDGET_ORDER_LIST].top) &&
|
|
|
|
_cursor.pos.x <= (w->left + w->widget[ORDER_WIDGET_ORDER_LIST].right) &&
|
|
|
|
_cursor.pos.y <= (w->top + w->widget[ORDER_WIDGET_ORDER_LIST].bottom)) {
|
|
|
|
int order_id = GetOrderFromOrderWndPt(w, _cursor.pos.y - w->top, v);
|
|
|
|
if (order_id != INVALID_ORDER) {
|
|
|
|
Order order;
|
|
|
|
order.next = NULL;
|
|
|
|
order.index = 0;
|
|
|
|
order.MakeConditional(order_id);
|
|
|
|
|
|
|
|
DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), order.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-04-09 16:16:04 +00:00
|
|
|
w->RaiseWidget(ORDER_WIDGET_GOTO);
|
|
|
|
w->InvalidateWidget(ORDER_WIDGET_GOTO);
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* check if a vehicle in a depot was clicked.. */
|
|
|
|
case WE_MOUSELOOP:
|
|
|
|
v = _place_clicked_vehicle;
|
|
|
|
/*
|
|
|
|
* Check if we clicked on a vehicle
|
|
|
|
* and if the GOTO button of this window is pressed
|
|
|
|
* This is because of all open order windows WE_MOUSELOOP is called
|
|
|
|
* and if you have 3 windows open, and this check is not done
|
|
|
|
* the order is copied to the last open window instead of the
|
|
|
|
* one where GOTO is enabled
|
|
|
|
*/
|
|
|
|
if (v != NULL && w->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
|
|
|
|
_place_clicked_vehicle = NULL;
|
|
|
|
HandleOrderVehClick(GetVehicle(w->window_number), v, w);
|
2006-11-02 23:51:05 +00:00
|
|
|
}
|
2008-04-09 16:16:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_RESIZE:
|
|
|
|
/* Update the scroll + matrix */
|
|
|
|
w->vscroll.cap = (w->widget[ORDER_WIDGET_ORDER_LIST].bottom - w->widget[ORDER_WIDGET_ORDER_LIST].top) / 10;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WE_TIMEOUT: // handle button unclick ourselves...
|
|
|
|
/* unclick all buttons except for the 'goto' button (ORDER_WIDGET_GOTO), which is 'persistent' */
|
|
|
|
for (uint i = 0; i < w->widget_count; i++) {
|
|
|
|
if (w->IsWidgetLowered(i) && i != ORDER_WIDGET_GOTO) {
|
|
|
|
w->RaiseWidget(i);
|
|
|
|
w->InvalidateWidget(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2005-01-30 23:41:57 +00:00
|
|
|
}
|
2005-01-13 16:55:17 +00:00
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Widget definition for player train orders
|
|
|
|
*/
|
2005-01-21 18:36:17 +00:00
|
|
|
static const Widget _orders_train_widgets[] = {
|
2007-06-05 22:17:03 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // ORDER_WIDGET_CLOSEBOX
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 385, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, // ORDER_WIDGET_CAPTION
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_LR, 14, 325, 385, 0, 13, STR_TIMETABLE_VIEW, STR_TIMETABLE_VIEW_TOOLTIP}, // ORDER_WIDGET_TIMETABLE_VIEW
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_PANEL, RESIZE_RB, 14, 0, 373, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 374, 385, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // ORDER_WIDGET_SCROLLBAR
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 123, 88, 99, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, // ORDER_WIDGET_SKIP
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 124, 247, 88, 99, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, // ORDER_WIDGET_DELETE
|
2008-04-10 22:18:33 +00:00
|
|
|
{ WWT_DROPDOWN, RESIZE_TB, 14, 0, 123, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_NON_STOP}, // ORDER_WIDGET_NON_STOP
|
2008-04-11 15:58:46 +00:00
|
|
|
{ WWT_TEXTBTN, RESIZE_TB, 14, 248, 359, 88, 99, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, // ORDER_WIDGET_GOTO
|
|
|
|
{ WWT_DROPDOWN, RESIZE_TB, 14, 360, 371, 88, 99, STR_EMPTY, STR_ORDER_GO_TO_DROPDOWN_TOOLTIP}, // ORDER_WIDGET_GOTO_DROPDOWN
|
2008-04-10 22:18:33 +00:00
|
|
|
{ WWT_DROPDOWN, RESIZE_TB, 14, 124, 247, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_FULL_LOAD}, // ORDER_WIDGET_FULL_LOAD
|
|
|
|
{ WWT_DROPDOWN, RESIZE_TB, 14, 248, 371, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_UNLOAD}, // ORDER_WIDGET_UNLOAD
|
2008-04-10 17:23:51 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 124, 247, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT
|
2008-04-10 22:07:24 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 248, 371, 76, 87, STR_SERVICE, STR_SERVICE_HINT}, // ORDER_WIDGET_SERVICE
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
{ WWT_DROPDOWN, RESIZE_TB, 14, 0, 123, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP}, // ORDER_WIDGET_COND_VARIABLE
|
|
|
|
{ WWT_DROPDOWN, RESIZE_TB, 14, 124, 247, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP}, // ORDER_WIDGET_COND_COMPARATOR
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 248, 371, 76, 87, STR_CONDITIONAL_VALUE, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP}, // ORDER_WIDGET_COND_VALUE
|
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_PANEL, RESIZE_RTB, 14, 372, 373, 76, 99, 0x0, STR_NULL}, // ORDER_WIDGET_RESIZE_BAR
|
|
|
|
{ WWT_PUSHIMGBTN, RESIZE_LRTB, 14, 372, 385, 76, 87, SPR_SHARED_ORDERS_ICON, STR_VEH_WITH_SHARED_ORDERS_LIST_TIP}, // ORDER_WIDGET_SHARED_ORDER_LIST
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 374, 385, 88, 99, 0x0, STR_RESIZE_BUTTON}, // ORDER_WIDGET_RESIZE
|
2007-06-05 22:17:03 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2005-01-21 18:36:17 +00:00
|
|
|
static const WindowDesc _orders_train_desc = {
|
2008-04-09 23:00:12 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 386, 100, 386, 100,
|
2008-04-18 04:37:06 +00:00
|
|
|
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
2006-11-02 23:51:05 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
|
2005-01-21 18:36:17 +00:00
|
|
|
_orders_train_widgets,
|
|
|
|
OrdersWndProc
|
|
|
|
};
|
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Widget definition for player orders (!train)
|
|
|
|
*/
|
2005-01-21 18:36:17 +00:00
|
|
|
static const Widget _orders_widgets[] = {
|
2007-06-05 22:17:03 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // ORDER_WIDGET_CLOSEBOX
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 385, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, // ORDER_WIDGET_CAPTION
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_LR, 14, 325, 385, 0, 13, STR_TIMETABLE_VIEW, STR_TIMETABLE_VIEW_TOOLTIP}, // ORDER_WIDGET_TIMETABLE_VIEW
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_PANEL, RESIZE_RB, 14, 0, 373, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 374, 385, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // ORDER_WIDGET_SCROLLBAR
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 123, 88, 99, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, // ORDER_WIDGET_SKIP
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 124, 247, 88, 99, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, // ORDER_WIDGET_DELETE
|
2007-06-05 22:17:03 +00:00
|
|
|
{ WWT_EMPTY, RESIZE_TB, 14, 0, 0, 76, 87, 0x0, 0x0}, // ORDER_WIDGET_NON_STOP
|
2008-04-11 15:58:46 +00:00
|
|
|
{ WWT_TEXTBTN, RESIZE_TB, 14, 248, 359, 88, 99, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, // ORDER_WIDGET_GOTO
|
|
|
|
{ WWT_DROPDOWN, RESIZE_TB, 14, 360, 371, 88, 99, STR_EMPTY, STR_ORDER_GO_TO_DROPDOWN_TOOLTIP}, // ORDER_WIDGET_GOTO_DROPDOWN
|
2008-04-10 22:18:33 +00:00
|
|
|
{ WWT_DROPDOWN, RESIZE_TB, 14, 0, 185, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_FULL_LOAD}, // ORDER_WIDGET_FULL_LOAD
|
2008-04-12 11:58:19 +00:00
|
|
|
{ WWT_DROPDOWN, RESIZE_TB, 14, 186, 371, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_UNLOAD}, // ORDER_WIDGET_UNLOAD
|
2008-04-10 17:23:51 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 185, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT
|
2008-04-12 11:58:19 +00:00
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 186, 371, 76, 87, STR_SERVICE, STR_SERVICE_HINT}, // ORDER_WIDGET_SERVICE
|
|
|
|
|
|
|
|
{ WWT_DROPDOWN, RESIZE_TB, 14, 0, 123, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP}, // ORDER_WIDGET_COND_VARIABLE
|
|
|
|
{ WWT_DROPDOWN, RESIZE_TB, 14, 124, 247, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP}, // ORDER_WIDGET_COND_COMPARATOR
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 248, 371, 76, 87, STR_CONDITIONAL_VALUE, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP}, // ORDER_WIDGET_COND_VALUE
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_PANEL, RESIZE_RTB, 14, 372, 373, 76, 99, 0x0, STR_NULL}, // ORDER_WIDGET_RESIZE_BAR
|
|
|
|
{ WWT_PUSHIMGBTN, RESIZE_LRTB, 14, 372, 385, 76, 87, SPR_SHARED_ORDERS_ICON, STR_VEH_WITH_SHARED_ORDERS_LIST_TIP}, // ORDER_WIDGET_SHARED_ORDER_LIST
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 374, 385, 88, 99, 0x0, STR_RESIZE_BUTTON}, // ORDER_WIDGET_RESIZE
|
2007-06-05 22:17:03 +00:00
|
|
|
{ WIDGETS_END},
|
2005-01-21 18:36:17 +00:00
|
|
|
};
|
|
|
|
|
2005-01-12 22:09:21 +00:00
|
|
|
static const WindowDesc _orders_desc = {
|
2008-04-09 23:00:12 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 386, 100, 386, 100,
|
2008-04-18 04:37:06 +00:00
|
|
|
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
2006-11-02 23:51:05 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
|
2005-01-12 22:09:21 +00:00
|
|
|
_orders_widgets,
|
2004-08-09 17:04:08 +00:00
|
|
|
OrdersWndProc
|
|
|
|
};
|
|
|
|
|
2007-06-05 22:17:03 +00:00
|
|
|
/**
|
|
|
|
* Widget definition for competitor orders
|
|
|
|
*/
|
2005-01-12 22:09:21 +00:00
|
|
|
static const Widget _other_orders_widgets[] = {
|
2007-06-20 19:17:22 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // ORDER_WIDGET_CLOSEBOX
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 385, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, // ORDER_WIDGET_CAPTION
|
|
|
|
{ WWT_PUSHTXTBTN, RESIZE_LR, 14, 325, 385, 0, 13, STR_TIMETABLE_VIEW, STR_TIMETABLE_VIEW_TOOLTIP}, // ORDER_WIDGET_TIMETABLE_VIEW
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_PANEL, RESIZE_RB, 14, 0, 373, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 374, 385, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // ORDER_WIDGET_SCROLLBAR
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-09 19:52:33 +00:00
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_SKIP
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_DELETE
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_NON_STOP
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_GOTO
|
2008-04-11 15:58:46 +00:00
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_GOTO_DROPDOWN
|
2008-04-09 19:52:33 +00:00
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_FULL_LOAD
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_UNLOAD
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_REFIT
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_SERVICE
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-12 11:58:19 +00:00
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_COND_VARIABLE
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_COND_COMPARATOR
|
|
|
|
{ WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_COND_VALUE
|
|
|
|
|
2008-04-09 23:00:12 +00:00
|
|
|
{ WWT_PANEL, RESIZE_RTB, 14, 0, 373, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_RESIZE_BAR
|
2008-04-09 19:52:33 +00:00
|
|
|
{ WWT_EMPTY, RESIZE_TB, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_SHARED_ORDER_LIST
|
2007-06-05 22:17:03 +00:00
|
|
|
|
2008-04-12 20:15:57 +00:00
|
|
|
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 374, 385, 76, 87, 0x0, STR_RESIZE_BUTTON}, // ORDER_WIDGET_RESIZE
|
2007-06-05 22:17:03 +00:00
|
|
|
{ WIDGETS_END},
|
2004-08-09 17:04:08 +00:00
|
|
|
};
|
|
|
|
|
2005-01-12 22:09:21 +00:00
|
|
|
static const WindowDesc _other_orders_desc = {
|
2008-04-09 23:00:12 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 386, 88, 386, 88,
|
2008-04-18 04:37:06 +00:00
|
|
|
WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
|
2005-01-30 23:41:57 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
|
2005-01-12 22:09:21 +00:00
|
|
|
_other_orders_widgets,
|
2004-08-09 17:04:08 +00:00
|
|
|
OrdersWndProc
|
|
|
|
};
|
|
|
|
|
2006-07-26 03:33:12 +00:00
|
|
|
void ShowOrdersWindow(const Vehicle *v)
|
2004-08-09 17:04:08 +00:00
|
|
|
{
|
|
|
|
Window *w;
|
|
|
|
VehicleID veh = v->index;
|
|
|
|
|
|
|
|
DeleteWindowById(WC_VEHICLE_ORDERS, veh);
|
|
|
|
DeleteWindowById(WC_VEHICLE_DETAILS, veh);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2005-01-21 18:36:17 +00:00
|
|
|
if (v->owner != _local_player) {
|
2006-11-11 09:47:44 +00:00
|
|
|
w = AllocateWindowDescFront(&_other_orders_desc, veh);
|
2005-10-23 13:04:44 +00:00
|
|
|
} else {
|
2008-04-13 16:54:19 +00:00
|
|
|
w = AllocateWindowDescFront((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? &_orders_train_desc : &_orders_desc, veh);
|
2005-10-23 13:04:44 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
2005-01-30 23:41:57 +00:00
|
|
|
if (w != NULL) {
|
|
|
|
w->caption_color = v->owner;
|
|
|
|
w->vscroll.cap = 6;
|
|
|
|
w->resize.step_height = 10;
|
2007-12-16 10:54:08 +00:00
|
|
|
WP(w, order_d).sel = -1;
|
2005-01-30 23:41:57 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|