--- a/src/order_gui.cpp Mon Dec 03 23:39:38 2007 +0000
+++ b/src/order_gui.cpp Tue Jan 22 21:00:30 2008 +0000
@@ -6,20 +6,13 @@
#include "openttd.h"
#include "road_map.h"
#include "station_map.h"
-#include "table/sprites.h"
-#include "table/strings.h"
-#include "strings.h"
-#include "functions.h"
-#include "map.h"
-#include "tile.h"
-#include "window.h"
#include "gui.h"
-#include "gfx.h"
-#include "vehicle.h"
+#include "window_gui.h"
#include "station.h"
#include "town.h"
-#include "command.h"
-#include "viewport.h"
+#include "command_func.h"
+#include "viewport_func.h"
+#include "gfx_func.h"
#include "depot.h"
#include "waypoint.h"
#include "train.h"
@@ -27,6 +20,15 @@
#include "vehicle_gui.h"
#include "timetable.h"
#include "cargotype.h"
+#include "order.h"
+#include "strings_func.h"
+#include "window_func.h"
+#include "vehicle_func.h"
+#include "settings_type.h"
+#include "player_func.h"
+
+#include "table/sprites.h"
+#include "table/strings.h"
enum OrderWindowWidgets {
ORDER_WIDGET_CLOSEBOX = 0,
@@ -57,7 +59,7 @@
static int OrderGetSel(const Window *w)
{
const Vehicle *v = GetVehicle(w->window_number);
- int num = WP(w,order_d).sel;
+ int num = WP(w, order_d).sel;
return (num >= 0 && num < v->num_orders) ? num : v->num_orders;
}
@@ -152,7 +154,15 @@
if (order != NULL) {
switch (order->type) {
- case OT_GOTO_STATION: break;
+ case OT_GOTO_STATION:
+ if (!GetStation(order->dest)->IsBuoy()) break;
+ /* Fall-through */
+
+ case OT_GOTO_WAYPOINT:
+ w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
+ w->DisableWidget(ORDER_WIDGET_UNLOAD);
+ w->DisableWidget(ORDER_WIDGET_TRANSFER);
+ break;
case OT_GOTO_DEPOT:
w->DisableWidget(ORDER_WIDGET_TRANSFER);
@@ -163,12 +173,6 @@
SetDParam(2,STR_SERVICE);
break;
- case OT_GOTO_WAYPOINT:
- w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
- w->DisableWidget(ORDER_WIDGET_UNLOAD);
- w->DisableWidget(ORDER_WIDGET_TRANSFER);
- break;
-
default: // every other orders
w->DisableWidget(ORDER_WIDGET_NON_STOP);
w->DisableWidget(ORDER_WIDGET_FULL_LOAD);
@@ -211,14 +215,14 @@
SetDParam(2, GetDepot(order->dest)->town_index);
switch (v->type) {
- case VEH_TRAIN: s = (order->flags & OF_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
+ case VEH_TRAIN: s = (order->flags & OFB_NON_STOP) ? STR_880F_GO_NON_STOP_TO_TRAIN_DEPOT : STR_GO_TO_TRAIN_DEPOT; break;
case VEH_ROAD: s = STR_9038_GO_TO_ROADVEH_DEPOT; break;
case VEH_SHIP: s = STR_GO_TO_SHIP_DEPOT; break;
default: break;
}
}
- if (order->flags & OF_FULL_LOAD) s++; /* service at */
+ if (order->flags & OFB_FULL_LOAD) s++; /* service at */
SetDParam(1, s);
if (order->refit_cargo < NUM_CARGO) {
@@ -231,7 +235,7 @@
}
case OT_GOTO_WAYPOINT:
- SetDParam(1, (order->flags & OF_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
+ SetDParam(1, (order->flags & OFB_NON_STOP) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
SetDParam(2, order->dest);
break;
@@ -239,7 +243,7 @@
}
SetDParam(0, i + 1);
- DrawString(2, y, str, (i == WP(w,order_d).sel) ? TC_WHITE : TC_BLACK);
+ DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK);
y += 10;
}
@@ -250,7 +254,7 @@
if (i - w->vscroll.pos < w->vscroll.cap) {
str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS;
- DrawString(2, y, str, (i == WP(w,order_d).sel) ? TC_WHITE : TC_BLACK);
+ DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK);
}
}
@@ -269,7 +273,7 @@
if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_player)) {
if (IsRailDepot(tile)) {
order.type = OT_GOTO_DEPOT;
- order.flags = OF_PART_OF_ORDERS;
+ order.flags = OFB_PART_OF_ORDERS;
order.dest = GetDepotByTile(tile)->index;
return order;
}
@@ -279,7 +283,7 @@
case MP_ROAD:
if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) {
order.type = OT_GOTO_DEPOT;
- order.flags = OF_PART_OF_ORDERS;
+ order.flags = OFB_PART_OF_ORDERS;
order.dest = GetDepotByTile(tile)->index;
return order;
}
@@ -289,7 +293,7 @@
if (v->type != VEH_AIRCRAFT) break;
if (IsHangar(tile) && IsTileOwner(tile, _local_player)) {
order.type = OT_GOTO_DEPOT;
- order.flags = OF_PART_OF_ORDERS;
+ order.flags = OFB_PART_OF_ORDERS;
order.dest = GetStationIndex(tile);
return order;
}
@@ -302,7 +306,7 @@
TileIndex tile2 = GetOtherShipDepotTile(tile);
order.type = OT_GOTO_DEPOT;
- order.flags = OF_PART_OF_ORDERS;
+ order.flags = OFB_PART_OF_ORDERS;
order.dest = GetDepotByTile(tile < tile2 ? tile : tile2)->index;
return order;
}
@@ -362,9 +366,9 @@
// obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
if (v->num_orders != 0 && _ctrl_pressed == 0) return false;
- if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? 0 : 1, NULL,
+ if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY, NULL,
_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) {
- WP(w,order_d).sel = -1;
+ WP(w, order_d).sel = -1;
ResetObjectToPlace();
}
@@ -384,7 +388,7 @@
if (!cmd.IsValid()) return;
if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), PackOrder(&cmd), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
- if (WP(w,order_d).sel != -1) WP(w,order_d).sel++;
+ if (WP(w, order_d).sel != -1) WP(w,order_d).sel++;
ResetObjectToPlace();
}
}
@@ -397,7 +401,7 @@
*/
static void OrderClick_Goto(Window *w, const Vehicle *v)
{
- InvalidateWidget(w, ORDER_WIDGET_GOTO);
+ w->InvalidateWidget(ORDER_WIDGET_GOTO);
w->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO);
if (w->IsWidgetLowered(ORDER_WIDGET_GOTO)) {
_place_clicked_vehicle = NULL;
@@ -415,7 +419,7 @@
*/
static void OrderClick_FullLoad(Window *w, const Vehicle *v)
{
- DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_FULL_LOAD, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
+ DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OF_FULL_LOAD, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
}
/**
@@ -426,7 +430,7 @@
*/
static void OrderClick_Unload(Window *w, const Vehicle *v)
{
- DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_UNLOAD, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
+ DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OF_UNLOAD, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
}
/**
@@ -437,7 +441,7 @@
*/
static void OrderClick_Nonstop(Window *w, const Vehicle *v)
{
- DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_NON_STOP, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
+ DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OF_NON_STOP, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
}
/**
@@ -448,7 +452,7 @@
*/
static void OrderClick_Transfer(Window* w, const Vehicle* v)
{
- DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OFB_TRANSFER, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
+ DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), OF_TRANSFER, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
}
/**
@@ -491,9 +495,9 @@
{
if (_ctrl_pressed) {
/* Cancel refitting */
- DoCommandP(v->tile, v->index, (WP(w,order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT);
+ DoCommandP(v->tile, v->index, (WP(w, order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT);
} else {
- ShowVehicleRefitWindow(v, WP(w,order_d).sel);
+ ShowVehicleRefitWindow(v, WP(w, order_d).sel);
}
}
@@ -563,7 +567,7 @@
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;
+ WP(w, order_d).sel = -1;
SetWindowDirty(w);
return;
}
@@ -582,12 +586,12 @@
if (xy != 0) ScrollMainWindowToTile(xy);
return;
} else {
- if (sel == WP(w,order_d).sel) {
+ if (sel == WP(w, order_d).sel) {
/* Deselect clicked order */
- WP(w,order_d).sel = -1;
+ WP(w, order_d).sel = -1;
} else {
/* Select clicked order */
- WP(w,order_d).sel = sel;
+ WP(w, order_d).sel = sel;
if (v->owner == _local_player) {
/* Activate drag and drop */
@@ -700,7 +704,7 @@
case WE_ABORT_PLACE_OBJ: {
w->RaiseWidget(ORDER_WIDGET_GOTO);
- InvalidateWidget( w, ORDER_WIDGET_GOTO);
+ w->InvalidateWidget(ORDER_WIDGET_GOTO);
} break;
// check if a vehicle in a depot was clicked..
@@ -731,7 +735,7 @@
for (i = 0; i < w->widget_count; i++) {
if (w->IsWidgetLowered(i) && i != ORDER_WIDGET_GOTO) {
w->RaiseWidget(i);
- InvalidateWidget(w, i);
+ w->InvalidateWidget(i);
}
}
} break;
@@ -867,6 +871,6 @@
w->caption_color = v->owner;
w->vscroll.cap = 6;
w->resize.step_height = 10;
- WP(w,order_d).sel = -1;
+ WP(w, order_d).sel = -1;
}
}