truelight@0: #include "stdafx.h" truelight@0: #include "ttd.h" tron@507: #include "table/strings.h" truelight@0: #include "window.h" truelight@0: #include "gui.h" truelight@0: #include "gfx.h" truelight@0: #include "vehicle.h" truelight@0: #include "station.h" truelight@0: #include "town.h" truelight@0: #include "command.h" truelight@0: #include "viewport.h" truelight@0: truelight@0: static int OrderGetSel(Window *w) truelight@0: { truelight@0: Vehicle *v = &_vehicles[w->window_number]; tron@555: const Order *sched = v->schedule_ptr; truelight@0: int num = WP(w,order_d).sel; truelight@0: int count = 0; truelight@0: truelight@0: if (num == 0) truelight@0: return 0; truelight@0: tron@555: while (sched->type != OT_NOTHING) { truelight@0: sched++; truelight@0: count++; truelight@0: if (--num == 0) truelight@0: break; truelight@0: } truelight@0: truelight@0: return count; truelight@0: } truelight@0: truelight@0: static void DrawOrdersWindow(Window *w) truelight@0: { truelight@0: Vehicle *v; truelight@0: int num, sel; tron@555: const Order *sched; tron@555: Order ord; truelight@0: int y, i; truelight@0: StringID str; truelight@0: bool shared_schedule; truelight@0: truelight@0: v = &_vehicles[w->window_number]; truelight@0: truelight@0: w->disabled_state = (v->owner == _local_player) ? 0 : 0x3F0; truelight@0: truelight@0: shared_schedule = IsScheduleShared(v) != NULL; truelight@0: truelight@0: sched = v->schedule_ptr; truelight@0: num=0; tron@555: while (sched->type != OT_NOTHING) { tron@555: sched++; tron@555: num++; tron@555: } truelight@0: truelight@0: if ((uint)num + shared_schedule <= (uint)WP(w,order_d).sel) truelight@0: SETBIT(w->disabled_state, 5); /* delete */ truelight@0: truelight@0: if (num == 0) truelight@0: SETBIT(w->disabled_state, 4); /* skip */ truelight@0: truelight@0: SetVScrollCount(w, num+1); truelight@0: truelight@0: sel = OrderGetSel(w); truelight@193: tron@534: SetDParam(2,STR_8827_FULL_LOAD); tron@555: switch (v->schedule_ptr[sel].type) { truelight@0: case OT_GOTO_STATION: truelight@0: break; truelight@0: case OT_GOTO_DEPOT: truelight@0: SETBIT(w->disabled_state, 9); /* unload */ tron@534: SetDParam(2,STR_SERVICE); truelight@0: break; truelight@0: default: truelight@0: SETBIT(w->disabled_state, 6); /* nonstop */ truelight@0: SETBIT(w->disabled_state, 8); /* full load */ truelight@193: SETBIT(w->disabled_state, 9); /* unload */ truelight@0: } truelight@0: tron@534: SetDParam(0, v->string_id); tron@534: SetDParam(1, v->unitnumber); truelight@0: DrawWindowWidgets(w); truelight@0: truelight@0: y = 15; truelight@0: truelight@0: i = 0; truelight@0: for(;;) { truelight@0: str = ((byte)v->cur_order_index == i) ? STR_8805 : STR_8804; truelight@193: truelight@0: ord = v->schedule_ptr[i]; truelight@0: truelight@0: if ( (uint)(i - w->vscroll.pos) < 6) { truelight@193: tron@555: if (ord.type == OT_NOTHING) { truelight@0: str = shared_schedule ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS; truelight@0: } else { tron@534: SetDParam(1, 6); truelight@0: tron@555: if (ord.type == OT_GOTO_STATION) { tron@555: SetDParam(1, STR_8806_GO_TO + (ord.flags >> 1)); tron@555: SetDParam(2, ord.station); tron@555: } else if (ord.type == OT_GOTO_DEPOT) { truelight@0: StringID s = STR_NULL; truelight@0: if (v->type == VEH_Aircraft) { truelight@0: s = STR_GO_TO_AIRPORT_HANGAR; tron@555: SetDParam(2, ord.station); truelight@0: } else { tron@555: SetDParam(2, _depots[ord.station].town_index); truelight@0: switch (v->type) { truelight@0: case VEH_Train: s = STR_880E_GO_TO_TRAIN_DEPOT; break; truelight@0: case VEH_Road: s = STR_9038_GO_TO_ROADVEH_DEPOT; break; truelight@0: case VEH_Ship: s = STR_GO_TO_SHIP_DEPOT; break; truelight@0: } truelight@0: } tron@555: if (v->type == VEH_Train && ord.flags & OF_NON_STOP) s += 2; tron@555: if (ord.flags & OF_FULL_LOAD) ++s; /* XXX service */ tron@555: SetDParam(1, s); tron@555: } else if (ord.type == OT_GOTO_WAYPOINT) { tron@555: SetDParam(2, ord.station); tron@534: SetDParam(1, STR_GO_TO_WAYPOINT); truelight@0: } truelight@0: } truelight@0: { truelight@0: byte color = (i == WP(w,order_d).sel) ? 0xC : 0x10; tron@534: SetDParam(0, i+1); tron@555: if (ord.type != OT_DUMMY) { dominik@127: DrawString(2, y, str, color); dominik@127: } else { tron@534: SetDParam(1, STR_INVALID_ORDER); tron@555: SetDParam(2, ord.station); dominik@127: DrawString(2, y, str, color); dominik@127: } truelight@0: } truelight@0: y += 10; truelight@0: } truelight@0: truelight@0: i++; truelight@0: tron@555: if (ord.type == OT_NOTHING) truelight@0: break; truelight@0: } truelight@0: } truelight@0: truelight@0: truelight@0: // lookup a vehicle on a tile truelight@0: typedef struct { truelight@0: TileIndex tile; truelight@0: byte owner; truelight@0: byte type; truelight@0: } FindVehS; truelight@0: truelight@0: static void *FindVehicleCallb(Vehicle *v, FindVehS *f) truelight@0: { truelight@0: if (v->tile != f->tile || v->owner != f->owner || v->vehstatus & VS_HIDDEN ) return NULL; truelight@0: return v; truelight@193: } truelight@0: truelight@0: Vehicle *GetVehicleOnTile(TileIndex tile, byte owner) truelight@0: { tron@536: FindVehS fs = {tile, owner, 0}; truelight@0: return VehicleFromPos(tile, &fs, (VehicleFromPosProc*)FindVehicleCallb); truelight@0: } truelight@0: truelight@0: static uint GetOrderCmdFromTile(Vehicle *v, uint tile) truelight@0: { truelight@0: Station *st; truelight@0: int st_index; truelight@0: truelight@0: // check depot first truelight@0: if (_patches.gotodepot) { truelight@0: switch(GET_TILETYPE(tile)) { truelight@0: case MP_RAILWAY: truelight@0: if (v->type == VEH_Train && _map_owner[tile] == _local_player) { truelight@0: if ((_map5[tile]&0xFC)==0xC0) truelight@0: return (GetDepotByTile(tile)<<8) | OT_GOTO_DEPOT | OF_UNLOAD; truelight@0: } truelight@0: break; truelight@0: truelight@0: case MP_STREET: truelight@0: if ((_map5[tile] & 0xF0) == 0x20 && v->type == VEH_Road && _map_owner[tile] == _local_player) truelight@0: return (GetDepotByTile(tile)<<8) | OT_GOTO_DEPOT | OF_UNLOAD; truelight@0: break; truelight@0: truelight@0: case MP_STATION: truelight@0: if (v->type != VEH_Aircraft) break; truelight@0: if ( IsAircraftHangarTile(tile) && _map_owner[tile] == _local_player) truelight@0: return (_map2[tile]<<8) | OF_UNLOAD | OT_GOTO_DEPOT | OF_NON_STOP; truelight@0: break; truelight@0: truelight@0: case MP_WATER: truelight@0: if (v->type != VEH_Ship) break; truelight@0: if ( IsShipDepotTile(tile) && _map_owner[tile] == _local_player) { truelight@0: switch (_map5[tile]) { truelight@0: case 0x81: tile--; break; truelight@0: case 0x83: tile-= TILE_XY(0,1); break; truelight@0: } truelight@0: return (GetDepotByTile(tile)<<8) | OT_GOTO_DEPOT | OF_UNLOAD; truelight@0: } truelight@0: } truelight@0: } truelight@0: darkvater@395: // check waypoint dominik@319: if (IS_TILETYPE(tile, MP_RAILWAY) dominik@319: && v->type == VEH_Train dominik@319: && _map_owner[tile] == _local_player dominik@319: && (_map5[tile]&0xFE)==0xC4) darkvater@395: return (GetWaypointByTile(tile)<<8) | OT_GOTO_WAYPOINT; dominik@319: truelight@0: if (IS_TILETYPE(tile, MP_STATION)) { truelight@0: st = DEREF_STATION(st_index = _map2[tile]); truelight@0: truelight@0: if (st->owner == _current_player || st->owner == OWNER_NONE) { truelight@0: byte facil; truelight@0: (facil=FACIL_DOCK, v->type == VEH_Ship) || truelight@0: (facil=FACIL_TRAIN, v->type == VEH_Train) || truelight@0: (facil=FACIL_AIRPORT, v->type == VEH_Aircraft) || truelight@0: (facil=FACIL_BUS_STOP, v->type == VEH_Road && v->cargo_type == CT_PASSENGERS) || truelight@0: (facil=FACIL_TRUCK_STOP, 1); truelight@0: if (st->facilities & facil) truelight@0: return (st_index << 8) | OT_GOTO_STATION; truelight@0: } truelight@0: } truelight@0: truelight@0: // not found truelight@0: return (uint)-1; truelight@0: } truelight@0: truelight@0: static bool HandleOrderVehClick(Vehicle *v, Vehicle *u, Window *w) truelight@0: { truelight@0: if (u->type != v->type) truelight@0: return false; truelight@0: truelight@0: if (u->type == VEH_Train && u->subtype != 0) { truelight@0: u = GetFirstVehicleInChain(u); truelight@0: if (u->subtype != 0) truelight@0: return false; truelight@0: } truelight@0: truelight@0: // v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet truelight@0: // obviously if you press CTRL on a non-empty orders vehicle you know what you are doing truelight@0: if (v->num_orders != 0 && _ctrl_pressed == 0) {return false;} truelight@193: truelight@0: if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? 0 : 1, NULL, truelight@0: _ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) { truelight@0: WP(w,order_d).sel = -1; truelight@0: ResetObjectToPlace(); truelight@0: } truelight@0: truelight@0: return true; truelight@0: } truelight@0: truelight@0: static void OrdersPlaceObj(Vehicle *v, uint tile, Window *w) truelight@0: { truelight@0: uint cmd; truelight@0: Vehicle *u; truelight@193: truelight@0: // check if we're clicking on a vehicle first.. clone orders in that case. truelight@0: u = CheckMouseOverVehicle(); truelight@0: if (u && HandleOrderVehClick(v, u, w)) truelight@0: return; truelight@0: truelight@0: cmd = GetOrderCmdFromTile(v, tile); truelight@0: if ( cmd == (uint)-1) return; truelight@0: truelight@0: if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), cmd, NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) { truelight@0: if (WP(w,order_d).sel != -1) truelight@0: WP(w,order_d).sel++; truelight@0: ResetObjectToPlace(); truelight@0: } truelight@0: } truelight@0: truelight@0: truelight@0: static void OrdersWndProc(Window *w, WindowEvent *e) truelight@0: { truelight@0: switch(e->event) { truelight@0: case WE_PAINT: truelight@0: DrawOrdersWindow(w); truelight@0: break; truelight@0: truelight@0: case WE_CLICK: { truelight@0: Vehicle *v = &_vehicles[w->window_number]; truelight@0: int mode; truelight@0: switch(e->click.widget) { truelight@193: case 2: {/* orders list */ truelight@0: int sel; truelight@0: sel = (e->click.pt.y - 15) / 10; truelight@0: truelight@0: if ( (uint) sel >= 6) truelight@0: return; truelight@0: truelight@0: sel += w->vscroll.pos; truelight@0: darkvater@44: if (_ctrl_pressed && sel < v->num_orders) { // watch out for schedule_ptr overflow tron@555: Order ord = v->schedule_ptr[sel]; darkvater@44: int xy = 0; tron@555: switch (ord.type) { darkvater@44: case OT_GOTO_STATION: /* station order */ tron@555: xy = _stations[ord.station].xy ; darkvater@44: break; darkvater@44: case OT_GOTO_DEPOT: /* goto depot order */ tron@555: xy = _depots[ord.station].xy; darkvater@44: break; darkvater@395: case OT_GOTO_WAYPOINT: /* goto waypoint order */ tron@555: xy = _waypoints[ord.station].xy; darkvater@44: } darkvater@44: darkvater@44: if (xy) darkvater@44: ScrollMainWindowToTile(xy); truelight@193: darkvater@44: return; darkvater@44: } darkvater@44: truelight@0: if (sel == WP(w,order_d).sel) sel = -1; truelight@0: WP(w,order_d).sel = sel; truelight@0: SetWindowDirty(w); truelight@0: } break; truelight@0: truelight@0: case 4: /* skip button */ truelight@0: DoCommandP(v->tile,v->index, 0, NULL, CMD_SKIP_ORDER); truelight@0: break; truelight@0: truelight@0: case 5: /* delete button */ truelight@0: DoCommandP(v->tile,v->index, OrderGetSel(w), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER)); truelight@0: break; truelight@0: truelight@0: case 7: /* goto button */ truelight@0: InvalidateWidget(w, 7); truelight@0: w->click_state ^= 1<<7; truelight@0: if (HASBIT(w->click_state, 7)) { truelight@0: _place_clicked_vehicle = NULL; truelight@0: SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, 1, w); truelight@0: } else { truelight@0: ResetObjectToPlace(); truelight@0: } truelight@0: break; truelight@0: truelight@0: case 8: /* full load button */ truelight@0: mode = 0; truelight@0: DoCommandP(v->tile, v->index, OrderGetSel(w) | (mode << 8), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); truelight@0: break; truelight@0: truelight@0: case 9: /* unload button */ truelight@0: mode = 1; truelight@0: DoCommandP(v->tile, v->index, OrderGetSel(w) | (mode << 8), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); truelight@0: break; truelight@0: truelight@0: case 6: /* non stop button */ truelight@0: mode = 2; truelight@0: DoCommandP(v->tile, v->index, OrderGetSel(w) | (mode << 8), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); truelight@0: break; truelight@0: } truelight@0: } break; truelight@0: truelight@0: truelight@0: case WE_RCLICK: { truelight@0: Vehicle *v = &_vehicles[w->window_number]; truelight@0: if (e->click.widget != 8) break; tron@555: if (v->schedule_ptr[OrderGetSel(w)].type == OT_GOTO_DEPOT) truelight@0: GuiShowTooltips(STR_SERVICE_HINT); truelight@0: else truelight@0: GuiShowTooltips(STR_8857_MAKE_THE_HIGHLIGHTED_ORDER); truelight@0: } break; truelight@0: truelight@0: case WE_4: { truelight@0: if (FindWindowById(WC_VEHICLE_VIEW, w->window_number) == NULL) truelight@0: DeleteWindow(w); truelight@0: } break; truelight@0: truelight@0: case WE_PLACE_OBJ: { truelight@0: OrdersPlaceObj(&_vehicles[w->window_number], e->place.tile, w); truelight@0: } break; truelight@0: truelight@0: case WE_ABORT_PLACE_OBJ: { truelight@0: w->click_state &= ~(1<<7); truelight@0: InvalidateWidget(w, 7); truelight@0: } break; truelight@0: truelight@0: // check if a vehicle in a depot was clicked.. truelight@0: case WE_MOUSELOOP: { truelight@0: Vehicle *v = _place_clicked_vehicle; truelight@25: /* truelight@25: * Check if we clicked on a vehicle truelight@25: * and if the GOTO button of this window is pressed truelight@25: * This is because of all open order windows WE_MOUSELOOP is called truelight@25: * and if you have 3 windows open, and this check is not done truelight@25: * the order is copied to the last open window instead of the truelight@25: * one where GOTO is enalbed truelight@25: */ truelight@25: if (v && HASBIT(w->click_state, 7)) { truelight@0: _place_clicked_vehicle = NULL; truelight@0: HandleOrderVehClick(&_vehicles[w->window_number], v, w); truelight@0: } truelight@0: } break; truelight@193: truelight@0: } truelight@0: } truelight@0: truelight@0: static const Widget _train_orders_widgets[] = { darkvater@176: { WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, darkvater@176: { WWT_CAPTION, 14, 11, 319, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, darkvater@176: { WWT_PANEL, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, darkvater@176: { WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, darkvater@176: { WWT_PUSHTXTBTN, 14, 0, 52, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, darkvater@176: { WWT_PUSHTXTBTN, 14, 53, 105, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, darkvater@176: { WWT_PUSHTXTBTN, 14, 106, 158, 76, 87, STR_8825_NON_STOP, STR_8855_MAKE_THE_HIGHLIGHTED_ORDER}, darkvater@176: {WWT_NODISTXTBTN, 14, 159, 211, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, darkvater@176: { WWT_PUSHTXTBTN, 14, 212, 264, 76, 87, STR_FULLLOAD_OR_SERVICE, STR_NULL}, darkvater@176: { WWT_PUSHTXTBTN, 14, 265, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _train_orders_desc = { truelight@0: -1,-1, 320, 88, truelight@0: WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, truelight@0: _train_orders_widgets, truelight@0: OrdersWndProc truelight@0: }; truelight@0: truelight@0: static const Widget _other_train_orders_widgets[] = { truelight@0: { WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, truelight@0: { WWT_CAPTION, 14, 11, 319, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, truelight@0: { WWT_PANEL, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, truelight@0: { WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _other_train_orders_desc = { truelight@0: -1,-1, 320, 76, truelight@0: WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, truelight@0: _other_train_orders_widgets, truelight@0: OrdersWndProc truelight@0: }; truelight@0: truelight@0: truelight@0: static const Widget _roadveh_orders_widgets[] = { darkvater@176: { WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, darkvater@176: { WWT_CAPTION, 14, 11, 319, 0, 13, STR_900B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, darkvater@176: { WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, darkvater@176: { WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, darkvater@176: { WWT_PUSHTXTBTN, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, darkvater@176: { WWT_PUSHTXTBTN, 14, 64, 127, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, darkvater@176: { WWT_EMPTY, 0, 0, 0, 0, 0, 0x0, STR_NULL}, darkvater@176: {WWT_NODISTXTBTN, 14, 128, 191, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, darkvater@176: { WWT_PUSHTXTBTN, 14, 192, 255, 76, 87, STR_FULLLOAD_OR_SERVICE, STR_NULL}, darkvater@176: { WWT_PUSHTXTBTN, 14, 256, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _roadveh_orders_desc = { truelight@0: -1,-1, 320, 88, truelight@0: WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, truelight@0: _roadveh_orders_widgets, truelight@0: OrdersWndProc truelight@0: }; truelight@0: truelight@0: static const Widget _other_roadveh_orders_widgets[] = { darkvater@176: { WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, darkvater@176: { WWT_CAPTION, 14, 11, 319, 0, 13, STR_900B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, darkvater@176: { WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, darkvater@176: { WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _other_roadveh_orders_desc = { truelight@0: -1,-1, 320, 76, truelight@0: WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, truelight@0: _other_roadveh_orders_widgets, truelight@0: OrdersWndProc truelight@0: }; truelight@0: truelight@0: static const Widget _ship_orders_widgets[] = { darkvater@176: { WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, darkvater@176: { WWT_CAPTION, 14, 11, 319, 0, 13, STR_9810_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, darkvater@176: { WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, darkvater@176: { WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, darkvater@176: { WWT_PUSHTXTBTN, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, darkvater@176: { WWT_PUSHTXTBTN, 14, 64, 127, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, darkvater@176: { WWT_EMPTY, 0, 0, 0, 0, 0, 0x0, STR_NULL}, darkvater@176: {WWT_NODISTXTBTN, 14, 128, 191, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, darkvater@176: { WWT_PUSHTXTBTN, 14, 192, 255, 76, 87, STR_FULLLOAD_OR_SERVICE, STR_NULL}, darkvater@176: { WWT_PUSHTXTBTN, 14, 256, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _ship_orders_desc = { truelight@0: -1,-1, 320, 88, truelight@0: WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, truelight@0: _ship_orders_widgets, truelight@0: OrdersWndProc truelight@0: }; truelight@0: truelight@0: static const Widget _other_ship_orders_widgets[] = { darkvater@176: { WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, darkvater@176: { WWT_CAPTION, 14, 11, 319, 0, 13, STR_9810_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, darkvater@176: { WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, darkvater@176: { WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _other_ship_orders_desc = { truelight@0: -1,-1, 320, 76, truelight@0: WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, truelight@0: _other_ship_orders_widgets, truelight@0: OrdersWndProc truelight@0: }; truelight@0: truelight@0: truelight@0: static const Widget _aircraft_orders_widgets[] = { darkvater@176: { WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, darkvater@176: { WWT_CAPTION, 14, 11, 319, 0, 13, STR_A00B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, darkvater@176: { WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, darkvater@176: { WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, darkvater@176: { WWT_PUSHTXTBTN, 14, 0, 63, 76, 87, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, darkvater@176: { WWT_PUSHTXTBTN, 14, 64, 127, 76, 87, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, darkvater@176: { WWT_EMPTY, 0, 0, 0, 0, 0, 0x0, STR_NULL}, darkvater@176: {WWT_NODISTXTBTN, 14, 128, 191, 76, 87, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, darkvater@176: { WWT_PUSHTXTBTN, 14, 192, 255, 76, 87, STR_FULLLOAD_OR_SERVICE, STR_NULL}, darkvater@176: { WWT_PUSHTXTBTN, 14, 256, 319, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _aircraft_orders_desc = { truelight@0: -1,-1, 320, 88, truelight@0: WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM, truelight@0: _aircraft_orders_widgets, truelight@0: OrdersWndProc truelight@0: }; truelight@0: truelight@0: static const Widget _other_aircraft_orders_widgets[] = { darkvater@176: { WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, darkvater@176: { WWT_CAPTION, 14, 11, 319, 0, 13, STR_A00B_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, darkvater@176: { WWT_IMGBTN, 14, 0, 308, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, darkvater@176: { WWT_SCROLLBAR, 14, 309, 319, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, darkvater@176: { WIDGETS_END}, truelight@0: }; truelight@0: truelight@0: static const WindowDesc _other_aircraft_orders_desc = { truelight@0: -1,-1, 320, 76, truelight@0: WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW, truelight@0: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, truelight@0: _other_aircraft_orders_widgets, truelight@0: OrdersWndProc truelight@0: }; truelight@0: truelight@0: static const WindowDesc * const _order_window_desc[8] = { truelight@0: &_train_orders_desc, &_other_train_orders_desc, truelight@0: &_roadveh_orders_desc, &_other_roadveh_orders_desc, truelight@0: &_ship_orders_desc, &_other_ship_orders_desc, truelight@0: &_aircraft_orders_desc, &_other_aircraft_orders_desc, truelight@0: }; truelight@0: truelight@0: truelight@0: void ShowOrdersWindow(Vehicle *v) truelight@0: { truelight@0: Window *w; truelight@0: VehicleID veh = v->index; truelight@0: truelight@0: DeleteWindowById(WC_VEHICLE_ORDERS, veh); truelight@0: DeleteWindowById(WC_VEHICLE_DETAILS, veh); truelight@193: truelight@0: _alloc_wnd_parent_num = veh; truelight@0: w = AllocateWindowDesc( truelight@0: _order_window_desc[(v->type - VEH_Train)*2 + (v->owner != _local_player)]); truelight@0: truelight@0: w->window_number = veh; truelight@0: w->caption_color = v->owner; truelight@0: w->vscroll.cap = 6; truelight@0: WP(w,order_d).sel = -1; truelight@0: }