tron@2186: /* $Id$ */ tron@2186: rubidium@10429: /** @file order_gui.cpp GUI related to orders. */ belugas@6677: truelight@0: #include "stdafx.h" Darkvater@1891: #include "openttd.h" tron@3144: #include "road_map.h" tron@3315: #include "station_map.h" truelight@0: #include "gui.h" rubidium@8603: #include "window_gui.h" rubidium@9281: #include "station_base.h" truelight@0: #include "town.h" rubidium@8612: #include "command_func.h" rubidium@8720: #include "viewport_func.h" rubidium@8720: #include "gfx_func.h" rubidium@10222: #include "depot_base.h" truelight@1542: #include "waypoint.h" bjarni@2676: #include "train.h" celestar@3392: #include "water_map.h" bjarni@4668: #include "vehicle_gui.h" maedhros@7476: #include "timetable.h" peter1138@6417: #include "cargotype.h" rubidium@8610: #include "strings_func.h" rubidium@8627: #include "window_func.h" rubidium@8640: #include "vehicle_func.h" rubidium@8707: #include "settings_type.h" rubidium@8750: #include "player_func.h" rubidium@9283: #include "newgrf_cargo.h" rubidium@10113: #include "widgets/dropdown_func.h" rubidium@10136: #include "textbuf_gui.h" rubidium@10136: #include "string_func.h" rubidium@10222: #include "depot_base.h" rubidium@10445: #include "tilehighlight_func.h" truelight@0: rubidium@8760: #include "table/sprites.h" rubidium@8760: #include "table/strings.h" rubidium@8760: bjarni@6079: enum OrderWindowWidgets { bjarni@6079: ORDER_WIDGET_CLOSEBOX = 0, bjarni@6079: ORDER_WIDGET_CAPTION, maedhros@7476: ORDER_WIDGET_TIMETABLE_VIEW, bjarni@6079: ORDER_WIDGET_ORDER_LIST, bjarni@6079: ORDER_WIDGET_SCROLLBAR, bjarni@6079: ORDER_WIDGET_SKIP, bjarni@6079: ORDER_WIDGET_DELETE, bjarni@6079: ORDER_WIDGET_NON_STOP, bjarni@6079: ORDER_WIDGET_GOTO, rubidium@10130: ORDER_WIDGET_GOTO_DROPDOWN, bjarni@6079: ORDER_WIDGET_FULL_LOAD, bjarni@6079: ORDER_WIDGET_UNLOAD, bjarni@6080: ORDER_WIDGET_REFIT, rubidium@10110: ORDER_WIDGET_SERVICE, rubidium@10136: ORDER_WIDGET_COND_VARIABLE, rubidium@10136: ORDER_WIDGET_COND_COMPARATOR, rubidium@10136: ORDER_WIDGET_COND_VALUE, rubidium@10110: ORDER_WIDGET_RESIZE_BAR, bjarni@6079: ORDER_WIDGET_SHARED_ORDER_LIST, bjarni@6079: ORDER_WIDGET_RESIZE, bjarni@6079: }; bjarni@6079: rubidium@10136: /** Under what reason are we using the PlaceObject functionality? */ rubidium@10136: enum OrderPlaceObjectState { rubidium@10136: OPOS_GOTO, rubidium@10136: OPOS_CONDITIONAL, rubidium@10136: }; rubidium@10136: rubidium@10132: struct order_d { rubidium@10132: int sel; rubidium@10136: OrderPlaceObjectState goto_type; rubidium@10132: }; rubidium@10132: assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(order_d)); rubidium@10132: rubidium@7328: /** rubidium@7328: * Return the memorised selected order. rubidium@7328: * rubidium@7328: * @param w current window rubidium@7328: * @return the memorised order if it is a vaild one rubidium@7328: * else return the number of orders rubidium@7328: */ belugas@4171: static int OrderGetSel(const Window *w) truelight@0: { belugas@4171: const Vehicle *v = GetVehicle(w->window_number); rubidium@8578: int num = WP(w, order_d).sel; truelight@0: tron@2549: return (num >= 0 && num < v->num_orders) ? num : v->num_orders; truelight@0: } truelight@0: rubidium@7328: /** rubidium@7328: * Calculate the selected order. rubidium@7328: * The calculation is based on the relative (to the window) y click position and rubidium@7328: * the position of the scrollbar. rubidium@7328: * rubidium@7328: * @param w current window rubidium@7328: * @param y Y-value of the click relative to the window origin rubidium@7328: * @param v current vehicle rubidium@7328: * @return the new selected order if the order is valid else return that rubidium@7328: * an invalid one has been selected. rubidium@7328: */ rubidium@7328: static int GetOrderFromOrderWndPt(Window *w, int y, const Vehicle *v) rubidium@7328: { rubidium@7328: /* rubidium@7328: * Calculation description: rubidium@7328: * 15 = 14 (w->widget[ORDER_WIDGET_ORDER_LIST].top) + 1 (frame-line) rubidium@7328: * 10 = order text hight rubidium@7328: */ rubidium@10136: int sel = (y - w->widget[ORDER_WIDGET_ORDER_LIST].top - 1) / 10; rubidium@7328: rubidium@7328: if ((uint)sel >= w->vscroll.cap) return INVALID_ORDER; rubidium@7328: rubidium@7328: sel += w->vscroll.pos; rubidium@7328: rubidium@7328: return (sel <= v->num_orders && sel >= 0) ? sel : INVALID_ORDER; rubidium@7328: } rubidium@7328: rubidium@10112: /** Order load types that could be given to station orders. */ rubidium@10112: static const StringID _station_load_types[][5] = { rubidium@9341: { rubidium@10112: STR_EMPTY, rubidium@10121: INVALID_STRING_ID, rubidium@10112: STR_ORDER_FULL_LOAD, rubidium@10112: STR_ORDER_FULL_LOAD_ANY, rubidium@10112: STR_ORDER_NO_LOAD, rubidium@9341: }, { rubidium@10121: STR_ORDER_UNLOAD, rubidium@10121: INVALID_STRING_ID, rubidium@10121: STR_ORDER_UNLOAD_FULL_LOAD, rubidium@10121: STR_ORDER_UNLOAD_FULL_LOAD_ANY, rubidium@10121: STR_ORDER_UNLOAD_NO_LOAD, rubidium@10121: }, { rubidium@10112: STR_ORDER_TRANSFER, rubidium@10121: INVALID_STRING_ID, rubidium@10112: STR_ORDER_TRANSFER_FULL_LOAD, rubidium@10112: STR_ORDER_TRANSFER_FULL_LOAD_ANY, rubidium@10121: STR_ORDER_TRANSFER_NO_LOAD, rubidium@10121: }, { rubidium@10121: /* Unload and transfer do not work together. */ rubidium@10121: INVALID_STRING_ID, rubidium@10121: INVALID_STRING_ID, rubidium@10121: INVALID_STRING_ID, rubidium@10112: INVALID_STRING_ID, rubidium@10119: }, { rubidium@10119: STR_ORDER_NO_UNLOAD, rubidium@10119: INVALID_STRING_ID, rubidium@10119: STR_ORDER_NO_UNLOAD_FULL_LOAD, rubidium@10119: STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY, rubidium@10119: INVALID_STRING_ID, rubidium@9341: } celestar@1935: }; celestar@1935: rubidium@10124: static const StringID _order_non_stop_drowdown[] = { rubidium@10124: STR_ORDER_GO_TO, rubidium@10124: STR_ORDER_GO_NON_STOP_TO, rubidium@10124: STR_ORDER_GO_VIA, rubidium@10124: STR_ORDER_GO_NON_STOP_VIA, rubidium@10124: INVALID_STRING_ID rubidium@10124: }; rubidium@10124: rubidium@10124: static const StringID _order_full_load_drowdown[] = { rubidium@10124: STR_ORDER_DROP_LOAD_IF_POSSIBLE, rubidium@10124: STR_EMPTY, rubidium@10124: STR_ORDER_DROP_FULL_LOAD_ALL, rubidium@10124: STR_ORDER_DROP_FULL_LOAD_ANY, rubidium@10124: STR_ORDER_DROP_NO_LOADING, rubidium@10124: INVALID_STRING_ID rubidium@10124: }; rubidium@10124: rubidium@10124: static const StringID _order_unload_drowdown[] = { rubidium@10124: STR_ORDER_DROP_UNLOAD_IF_ACCEPTED, rubidium@10124: STR_ORDER_DROP_UNLOAD, rubidium@10124: STR_ORDER_DROP_TRANSFER, rubidium@10124: STR_EMPTY, rubidium@10124: STR_ORDER_DROP_NO_UNLOADING, rubidium@10124: INVALID_STRING_ID rubidium@10124: }; rubidium@10124: rubidium@10130: static const StringID _order_goto_dropdown[] = { rubidium@10130: STR_ORDER_GO_TO, rubidium@10130: STR_ORDER_GO_TO_NEAREST_DEPOT, rubidium@10136: STR_ORDER_CONDITIONAL, rubidium@10130: INVALID_STRING_ID rubidium@10130: }; rubidium@10130: rubidium@10130: static const StringID _order_goto_dropdown_aircraft[] = { rubidium@10130: STR_ORDER_GO_TO, rubidium@10130: STR_ORDER_GO_TO_NEAREST_HANGAR, rubidium@10136: STR_ORDER_CONDITIONAL, rubidium@10130: INVALID_STRING_ID rubidium@10130: }; rubidium@10130: rubidium@10136: static const StringID _order_conditional_variable[] = { rubidium@10136: STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE, rubidium@10136: STR_ORDER_CONDITIONAL_RELIABILITY, rubidium@10136: STR_ORDER_CONDITIONAL_MAX_SPEED, rubidium@10136: STR_ORDER_CONDITIONAL_AGE, rubidium@10136: STR_ORDER_CONDITIONAL_REQUIRES_SERVICE, rubidium@10139: STR_ORDER_CONDITIONAL_UNCONDITIONALLY, rubidium@10136: INVALID_STRING_ID, rubidium@10136: }; rubidium@10136: rubidium@10136: static const StringID _order_conditional_condition[] = { rubidium@10136: STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS, rubidium@10136: STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS, rubidium@10136: STR_ORDER_CONDITIONAL_COMPARATOR_LESS_THAN, rubidium@10136: STR_ORDER_CONDITIONAL_COMPARATOR_LESS_EQUALS, rubidium@10136: STR_ORDER_CONDITIONAL_COMPARATOR_MORE_THAN, rubidium@10136: STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS, rubidium@10136: STR_ORDER_CONDITIONAL_COMPARATOR_IS_TRUE, rubidium@10136: STR_ORDER_CONDITIONAL_COMPARATOR_IS_FALSE, rubidium@10136: INVALID_STRING_ID, rubidium@10136: }; rubidium@10136: rubidium@10136: extern uint ConvertSpeedToDisplaySpeed(uint speed); rubidium@10136: extern uint ConvertDisplaySpeedToSpeed(uint speed); rubidium@10136: rubidium@10136: maedhros@10168: void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable) maedhros@10168: { maedhros@10168: StringID str = (v->cur_order_index == order_index) ? STR_8805 : STR_8804; maedhros@10168: SetDParam(6, STR_EMPTY); maedhros@10168: maedhros@10168: switch (order->GetType()) { maedhros@10168: case OT_DUMMY: maedhros@10168: SetDParam(1, STR_INVALID_ORDER); maedhros@10168: SetDParam(2, order->GetDestination()); maedhros@10168: break; maedhros@10168: maedhros@10168: case OT_GOTO_STATION: { maedhros@10168: OrderLoadFlags load = order->GetLoadType(); maedhros@10168: OrderUnloadFlags unload = order->GetUnloadType(); maedhros@10168: maedhros@10168: SetDParam(1, STR_GO_TO_STATION); maedhros@10168: SetDParam(2, STR_ORDER_GO_TO + ((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? order->GetNonStopType() : 0)); maedhros@10168: SetDParam(3, order->GetDestination()); maedhros@10168: maedhros@10168: if (timetable) { maedhros@10168: SetDParam(4, STR_EMPTY); maedhros@10168: maedhros@10168: if (order->wait_time > 0) { maedhros@10168: SetDParam(6, STR_TIMETABLE_STAY_FOR); maedhros@10168: SetTimetableParams(7, 8, order->wait_time); maedhros@10168: } maedhros@10168: } else { maedhros@10168: SetDParam(4, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ? STR_EMPTY : _station_load_types[unload][load]); maedhros@10168: } maedhros@10168: } break; maedhros@10168: maedhros@10168: case OT_GOTO_DEPOT: maedhros@10168: if (v->type == VEH_AIRCRAFT) { maedhros@10168: if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) { maedhros@10168: SetDParam(1, STR_GO_TO_NEAREST_DEPOT); maedhros@10168: SetDParam(3, STR_ORDER_NEAREST_HANGAR); maedhros@10168: } else { maedhros@10168: SetDParam(1, STR_GO_TO_HANGAR); maedhros@10168: SetDParam(3, order->GetDestination()); maedhros@10168: } maedhros@10168: SetDParam(4, STR_EMPTY); maedhros@10168: } else { maedhros@10168: if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) { maedhros@10168: SetDParam(1, STR_GO_TO_NEAREST_DEPOT); maedhros@10168: SetDParam(3, STR_ORDER_NEAREST_DEPOT); maedhros@10168: } else { maedhros@10168: SetDParam(1, STR_GO_TO_DEPOT); maedhros@10168: SetDParam(3, GetDepot(order->GetDestination())->town_index); maedhros@10168: } maedhros@10168: maedhros@10168: switch (v->type) { maedhros@10168: case VEH_TRAIN: SetDParam(4, STR_ORDER_TRAIN_DEPOT); break; maedhros@10168: case VEH_ROAD: SetDParam(4, STR_ORDER_ROAD_DEPOT); break; maedhros@10168: case VEH_SHIP: SetDParam(4, STR_ORDER_SHIP_DEPOT); break; maedhros@10168: default: NOT_REACHED(); maedhros@10168: } maedhros@10168: } maedhros@10168: maedhros@10168: if (order->GetDepotOrderType() & ODTFB_SERVICE) { maedhros@10168: SetDParam(2, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_SERVICE_NON_STOP_AT : STR_ORDER_SERVICE_AT); maedhros@10168: } else { maedhros@10168: SetDParam(2, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO : STR_ORDER_GO_TO); maedhros@10168: } maedhros@10168: maedhros@10168: if (!timetable && order->IsRefit()) { maedhros@10168: SetDParam(6, STR_REFIT_ORDER); maedhros@10168: SetDParam(7, GetCargo(order->GetRefitCargo())->name); maedhros@10168: } maedhros@10168: break; maedhros@10168: maedhros@10168: case OT_GOTO_WAYPOINT: maedhros@10168: SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT); maedhros@10168: SetDParam(2, order->GetDestination()); maedhros@10168: break; maedhros@10168: maedhros@10168: case OT_CONDITIONAL: maedhros@10168: SetDParam(2, order->GetConditionSkipToOrder() + 1); maedhros@10168: if (order->GetConditionVariable() == OCV_UNCONDITIONALLY) { maedhros@10168: SetDParam(1, STR_CONDITIONAL_UNCONDITIONAL); maedhros@10168: } else { maedhros@10168: OrderConditionComparator occ = order->GetConditionComparator(); maedhros@10168: SetDParam(1, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_CONDITIONAL_TRUE_FALSE : STR_CONDITIONAL_NUM); maedhros@10168: SetDParam(3, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable()); maedhros@10168: SetDParam(4, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ); maedhros@10168: maedhros@10168: uint value = order->GetConditionValue(); maedhros@10168: if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value); maedhros@10168: SetDParam(5, value); maedhros@10168: } maedhros@10168: break; maedhros@10168: maedhros@10168: default: NOT_REACHED(); maedhros@10168: } maedhros@10168: maedhros@10168: SetDParam(0, order_index + 1); maedhros@10168: DrawString(2, y, str, selected ? TC_WHITE : TC_BLACK); maedhros@10168: } maedhros@10168: maedhros@10168: truelight@0: static void DrawOrdersWindow(Window *w) truelight@0: { rubidium@10107: const Vehicle *v = GetVehicle(w->window_number); rubidium@10107: bool shared_orders = v->IsOrderListShared(); truelight@0: truelight@1024: SetVScrollCount(w, v->num_orders + 1); truelight@0: rubidium@10107: int sel = OrderGetSel(w); rubidium@10107: const Order *order = GetVehicleOrder(v, sel); tron@725: Darkvater@4949: if (v->owner == _local_player) { rubidium@10124: /* Set the strings for the dropdown boxes. */ rubidium@10136: w->widget[ORDER_WIDGET_NON_STOP].data = _order_non_stop_drowdown[order == NULL ? 0 : order->GetNonStopType()]; rubidium@10136: w->widget[ORDER_WIDGET_FULL_LOAD].data = _order_full_load_drowdown[order == NULL ? 0 : order->GetLoadType()]; rubidium@10136: w->widget[ORDER_WIDGET_UNLOAD].data = _order_unload_drowdown[order == NULL ? 0 : order->GetUnloadType()]; rubidium@10136: w->widget[ORDER_WIDGET_COND_VARIABLE].data = _order_conditional_variable[order == NULL ? 0 : order->GetConditionVariable()]; rubidium@10136: w->widget[ORDER_WIDGET_COND_COMPARATOR].data = _order_conditional_condition[order == NULL ? 0 : order->GetConditionComparator()]; rubidium@10124: Darkvater@4949: /* skip */ rubidium@8493: w->SetWidgetDisabledState(ORDER_WIDGET_SKIP, v->num_orders <= 1); belugas@4709: Darkvater@4949: /* delete */ rubidium@8493: w->SetWidgetDisabledState(ORDER_WIDGET_DELETE, bjarni@6310: (uint)v->num_orders + ((shared_orders || v->num_orders != 0) ? 1 : 0) <= (uint)WP(w, order_d).sel); bjarni@4712: Darkvater@4949: /* non-stop only for trains */ rubidium@10158: w->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP, (v->type != VEH_TRAIN && v->type != VEH_ROAD) || order == NULL); rubidium@10122: w->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD, order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // full load rubidium@10122: w->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD, order == NULL || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload Darkvater@4949: /* Disable list of vehicles with the same shared orders if there is no list */ rubidium@8493: w->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || v->orders == NULL); rubidium@8493: w->SetWidgetDisabledState(ORDER_WIDGET_REFIT, order == NULL); // Refit rubidium@10110: w->SetWidgetDisabledState(ORDER_WIDGET_SERVICE, order == NULL); // Refit rubidium@8493: w->HideWidget(ORDER_WIDGET_REFIT); // Refit rubidium@10110: w->HideWidget(ORDER_WIDGET_SERVICE); // Service rubidium@10136: rubidium@10136: w->HideWidget(ORDER_WIDGET_COND_VARIABLE); rubidium@10136: w->HideWidget(ORDER_WIDGET_COND_COMPARATOR); rubidium@10136: w->HideWidget(ORDER_WIDGET_COND_VALUE); Darkvater@4949: } bjarni@4712: rubidium@10136: w->ShowWidget(ORDER_WIDGET_NON_STOP); rubidium@10110: w->ShowWidget(ORDER_WIDGET_UNLOAD); rubidium@10121: w->ShowWidget(ORDER_WIDGET_FULL_LOAD); belugas@4709: truelight@1024: if (order != NULL) { rubidium@9332: switch (order->GetType()) { glx@8553: case OT_GOTO_STATION: rubidium@9336: if (!GetStation(order->GetDestination())->IsBuoy()) break; glx@8553: /* Fall-through */ glx@8553: glx@8553: case OT_GOTO_WAYPOINT: glx@8553: w->DisableWidget(ORDER_WIDGET_FULL_LOAD); glx@8553: w->DisableWidget(ORDER_WIDGET_UNLOAD); glx@8553: break; tron@2549: truelight@1024: case OT_GOTO_DEPOT: rubidium@10110: w->DisableWidget(ORDER_WIDGET_FULL_LOAD); bjarni@4712: bjarni@4712: /* Remove unload and replace it with refit */ rubidium@8493: w->HideWidget(ORDER_WIDGET_UNLOAD); rubidium@8493: w->ShowWidget(ORDER_WIDGET_REFIT); rubidium@10121: w->HideWidget(ORDER_WIDGET_FULL_LOAD); rubidium@10110: w->ShowWidget(ORDER_WIDGET_SERVICE); truelight@1024: break; tron@725: rubidium@10136: case OT_CONDITIONAL: { rubidium@10136: w->HideWidget(ORDER_WIDGET_NON_STOP); rubidium@10136: w->HideWidget(ORDER_WIDGET_UNLOAD); rubidium@10136: w->HideWidget(ORDER_WIDGET_FULL_LOAD); rubidium@10136: w->ShowWidget(ORDER_WIDGET_COND_VARIABLE); rubidium@10136: w->ShowWidget(ORDER_WIDGET_COND_COMPARATOR); rubidium@10136: w->ShowWidget(ORDER_WIDGET_COND_VALUE); rubidium@10136: rubidium@10136: OrderConditionVariable ocv = order->GetConditionVariable(); rubidium@10139: w->SetWidgetDisabledState(ORDER_WIDGET_COND_COMPARATOR, ocv == OCV_UNCONDITIONALLY); rubidium@10139: w->SetWidgetDisabledState(ORDER_WIDGET_COND_VALUE, ocv == OCV_REQUIRES_SERVICE || ocv == OCV_UNCONDITIONALLY); rubidium@10136: rubidium@10136: uint value = order->GetConditionValue(); rubidium@10136: if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value); rubidium@10136: SetDParam(1, value); rubidium@10136: } break; rubidium@10136: belugas@4709: default: // every other orders rubidium@8493: w->DisableWidget(ORDER_WIDGET_NON_STOP); rubidium@8493: w->DisableWidget(ORDER_WIDGET_FULL_LOAD); rubidium@8493: w->DisableWidget(ORDER_WIDGET_UNLOAD); truelight@1024: } truelight@0: } truelight@0: peter1138@7545: SetDParam(0, v->index); truelight@0: DrawWindowWidgets(w); truelight@0: rubidium@10107: int y = 15; truelight@0: rubidium@10107: int i = w->vscroll.pos; truelight@1024: order = GetVehicleOrder(v, i); rubidium@10107: StringID str; truelight@1024: while (order != NULL) { maedhros@10168: /* Don't draw anything if it extends past the end of the window. */ maedhros@10168: if (i - w->vscroll.pos >= w->vscroll.cap) break; tron@2631: maedhros@10168: DrawOrderString(v, order, i, y, i == WP(w, order_d).sel, false); maedhros@10168: y += 10; truelight@0: truelight@0: i++; truelight@1024: order = order->next; truelight@1024: } truelight@0: darkvater@1242: if (i - w->vscroll.pos < w->vscroll.cap) { truelight@1024: str = shared_orders ? STR_END_OF_SHARED_ORDERS : STR_882A_END_OF_ORDERS; rubidium@8578: DrawString(2, y, str, (i == WP(w, order_d).sel) ? TC_WHITE : TC_BLACK); truelight@0: } truelight@0: } truelight@0: Darkvater@2436: static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) truelight@0: { darkvater@558: Order order; peter1138@3387: order.next = NULL; peter1138@3387: order.index = 0; truelight@0: rubidium@10107: /* check depot first */ truelight@0: if (_patches.gotodepot) { tron@1214: switch (GetTileType(tile)) { rubidium@10107: case MP_RAILWAY: rubidium@10107: if (v->type == VEH_TRAIN && IsTileOwner(tile, _local_player)) { rubidium@10107: if (IsRailDepot(tile)) { rubidium@10107: order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS); rubidium@10157: if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); rubidium@10107: return order; rubidium@10107: } rubidium@10107: } rubidium@10107: break; rubidium@10107: rubidium@10107: case MP_ROAD: rubidium@10107: if (IsRoadDepot(tile) && v->type == VEH_ROAD && IsTileOwner(tile, _local_player)) { rubidium@10079: order.MakeGoToDepot(GetDepotByTile(tile)->index, ODTFB_PART_OF_ORDERS); rubidium@10158: if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); darkvater@558: return order; Celestar@560: } rubidium@10107: break; truelight@0: rubidium@10107: case MP_STATION: rubidium@10107: if (v->type != VEH_AIRCRAFT) break; rubidium@10107: if (IsHangar(tile) && IsTileOwner(tile, _local_player)) { rubidium@10107: order.MakeGoToDepot(GetStationIndex(tile), ODTFB_PART_OF_ORDERS); rubidium@10107: return order; rubidium@10107: } rubidium@10107: break; truelight@0: rubidium@10107: case MP_WATER: rubidium@10107: if (v->type != VEH_SHIP) break; smatz@10221: if (IsShipDepot(tile) && IsTileOwner(tile, _local_player)) { rubidium@10107: TileIndex tile2 = GetOtherShipDepotTile(tile); celestar@3392: rubidium@10107: order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS); rubidium@10107: return order; rubidium@10107: } tron@1214: tron@1214: default: tron@1214: break; truelight@0: } truelight@0: } truelight@0: rubidium@10107: /* check waypoint */ tron@1901: if (IsTileType(tile, MP_RAILWAY) && rubidium@6585: v->type == VEH_TRAIN && tron@1901: IsTileOwner(tile, _local_player) && truelight@2668: IsRailWaypoint(tile)) { rubidium@9332: order.MakeGoToWaypoint(GetWaypointByTile(tile)->index); rubidium@10157: if (_patches.new_nonstop) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); darkvater@558: return order; darkvater@558: } dominik@319: tron@1035: if (IsTileType(tile, MP_STATION)) { tron@3315: StationID st_index = GetStationIndex(tile); belugas@4171: const Station *st = GetStation(st_index); truelight@0: truelight@0: if (st->owner == _current_player || st->owner == OWNER_NONE) { truelight@0: byte facil; rubidium@10107: (facil = FACIL_DOCK, v->type == VEH_SHIP) || rubidium@10107: (facil = FACIL_TRAIN, v->type == VEH_TRAIN) || rubidium@10107: (facil = FACIL_AIRPORT, v->type == VEH_AIRCRAFT) || rubidium@10107: (facil = FACIL_BUS_STOP, v->type == VEH_ROAD && IsCargoInClass(v->cargo_type, CC_PASSENGERS)) || rubidium@10107: (facil = FACIL_TRUCK_STOP, 1); darkvater@558: if (st->facilities & facil) { rubidium@9332: order.MakeGoToStation(st_index); rubidium@10158: if (_patches.new_nonstop && (v->type == VEH_TRAIN || v->type == VEH_ROAD)) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS); darkvater@558: return order; darkvater@558: } truelight@0: } truelight@0: } truelight@0: rubidium@10107: /* not found */ bjarni@6589: order.Free(); darkvater@558: return order; truelight@0: } truelight@0: belugas@4171: static bool HandleOrderVehClick(const Vehicle *v, const Vehicle *u, Window *w) truelight@0: { tron@2549: if (u->type != v->type) return false; truelight@0: rubidium@8044: if (!u->IsPrimaryVehicle()) { rubidium@7993: u = u->First(); maedhros@7269: if (!u->IsPrimaryVehicle()) return false; truelight@0: } truelight@0: rubidium@10107: /* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet rubidium@10107: * obviously if you press CTRL on a non-empty orders vehicle you know what you are doing */ tron@2549: if (v->num_orders != 0 && _ctrl_pressed == 0) return false; truelight@193: smatz@8560: if (DoCommandP(v->tile, v->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY, 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))) { rubidium@8578: WP(w, order_d).sel = -1; truelight@0: ResetObjectToPlace(); truelight@0: } truelight@0: truelight@0: return true; truelight@0: } truelight@0: belugas@4171: static void OrdersPlaceObj(const Vehicle *v, TileIndex tile, Window *w) truelight@0: { rubidium@10107: /* check if we're clicking on a vehicle first.. clone orders in that case. */ rubidium@10107: const Vehicle *u = CheckMouseOverVehicle(); tron@2549: if (u != NULL && HandleOrderVehClick(v, u, w)) return; truelight@0: rubidium@10107: const Order cmd = GetOrderCmdFromTile(v, tile); bjarni@6589: if (!cmd.IsValid()) return; truelight@0: rubidium@9335: if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), cmd.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) { rubidium@10229: if (WP(w, order_d).sel != -1) WP(w, order_d).sel++; truelight@0: ResetObjectToPlace(); truelight@0: } truelight@0: } truelight@0: rubidium@7303: /** rubidium@7303: * Handle the click on the goto button. rubidium@7303: * rubidium@7303: * @param w current window rubidium@7303: * @param v current vehicle rubidium@7303: */ rubidium@10113: static void OrderClick_Goto(Window *w, const Vehicle *v, int i) Celestar@1000: { glx@8524: w->InvalidateWidget(ORDER_WIDGET_GOTO); rubidium@8493: w->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO); rubidium@8493: if (w->IsWidgetLowered(ORDER_WIDGET_GOTO)) { Celestar@1000: _place_clicked_vehicle = NULL; rubidium@8385: SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, VHM_RECT, w); rubidium@10136: WP(w, order_d).goto_type = OPOS_GOTO; Celestar@1000: } else { Celestar@1000: ResetObjectToPlace(); Celestar@1000: } Celestar@1000: } Celestar@1000: rubidium@7303: /** rubidium@7303: * Handle the click on the full load button. rubidium@7303: * rubidium@7303: * @param w current window rubidium@7303: * @param v current vehicle rubidium@10113: * @param load_type the way to load. rubidium@7303: */ rubidium@10113: static void OrderClick_FullLoad(Window *w, const Vehicle *v, int load_type) Celestar@1000: { rubidium@10105: VehicleOrderID sel_ord = OrderGetSel(w); rubidium@10105: const Order *order = GetVehicleOrder(v, sel_ord); rubidium@10105: rubidium@10121: if (order->GetLoadType() == load_type) return; rubidium@10117: rubidium@10117: if (load_type < 0) { rubidium@10117: switch (order->GetLoadType()) { rubidium@10117: case OLF_LOAD_IF_POSSIBLE: load_type = OLFB_FULL_LOAD; break; rubidium@10117: case OLFB_FULL_LOAD: load_type = OLF_FULL_LOAD_ANY; break; rubidium@10119: case OLF_FULL_LOAD_ANY: load_type = OLFB_NO_LOAD; break; rubidium@10119: case OLFB_NO_LOAD: load_type = OLF_LOAD_IF_POSSIBLE; break; rubidium@10117: default: NOT_REACHED(); rubidium@10117: } rubidium@10117: } rubidium@10136: 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)); rubidium@10110: } rubidium@10110: rubidium@10110: /** rubidium@10110: * Handle the click on the service. rubidium@10110: * rubidium@10110: * @param w current window rubidium@10110: * @param v current vehicle rubidium@10110: */ rubidium@10113: static void OrderClick_Service(Window *w, const Vehicle *v, int i) rubidium@10110: { rubidium@10110: DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), MOF_DEPOT_ACTION, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); Celestar@1000: } Celestar@1000: rubidium@7303: /** rubidium@10130: * Handle the click on the service in nearest depot button. rubidium@10130: * rubidium@10130: * @param w current window rubidium@10130: * @param v current vehicle rubidium@10130: */ rubidium@10130: static void OrderClick_NearestDepot(Window *w, const Vehicle *v, int i) rubidium@10130: { rubidium@10130: Order order; rubidium@10130: order.next = NULL; rubidium@10130: order.index = 0; rubidium@10130: order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS); rubidium@10130: order.SetDepotActionType(ODATFB_NEAREST_DEPOT); rubidium@10130: rubidium@10130: DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), order.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER)); rubidium@10130: } rubidium@10130: rubidium@10130: /** rubidium@10136: * Handle the click on the conditional order button. rubidium@10136: * rubidium@10136: * @param w current window rubidium@10136: * @param v current vehicle rubidium@10136: */ rubidium@10136: static void OrderClick_Conditional(Window *w, const Vehicle *v, int i) rubidium@10136: { rubidium@10136: w->InvalidateWidget(ORDER_WIDGET_GOTO); rubidium@10136: w->LowerWidget(ORDER_WIDGET_GOTO); rubidium@10136: SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, VHM_RECT, w); rubidium@10136: WP(w, order_d).goto_type = OPOS_CONDITIONAL; rubidium@10136: } rubidium@10136: rubidium@10136: /** rubidium@7303: * Handle the click on the unload button. rubidium@7303: * rubidium@7303: * @param w current window rubidium@7303: * @param v current vehicle rubidium@7303: */ rubidium@10119: static void OrderClick_Unload(Window *w, const Vehicle *v, int unload_type) Celestar@1000: { rubidium@10105: VehicleOrderID sel_ord = OrderGetSel(w); rubidium@10105: const Order *order = GetVehicleOrder(v, sel_ord); rubidium@10105: rubidium@10121: if (order->GetUnloadType() == unload_type) return; rubidium@10121: rubidium@10119: if (unload_type < 0) { rubidium@10119: switch (order->GetUnloadType()) { rubidium@10119: case OUF_UNLOAD_IF_POSSIBLE: unload_type = OUFB_UNLOAD; break; rubidium@10121: case OUFB_UNLOAD: unload_type = OUFB_TRANSFER; break; rubidium@10121: case OUFB_TRANSFER: unload_type = OUFB_NO_UNLOAD; break; rubidium@10119: case OUFB_NO_UNLOAD: unload_type = OUF_UNLOAD_IF_POSSIBLE; break; rubidium@10119: default: NOT_REACHED(); rubidium@10119: } rubidium@10119: } rubidium@10119: rubidium@10136: 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)); truelight@1024: } truelight@1024: rubidium@7303: /** rubidium@7303: * Handle the click on the nonstop button. rubidium@7303: * rubidium@7303: * @param w current window rubidium@7303: * @param v current vehicle rubidium@10113: * @param non_stop what non-stop type to use; -1 to use the 'next' one. rubidium@7303: */ rubidium@10113: static void OrderClick_Nonstop(Window *w, const Vehicle *v, int non_stop) truelight@1024: { rubidium@10105: VehicleOrderID sel_ord = OrderGetSel(w); rubidium@10105: const Order *order = GetVehicleOrder(v, sel_ord); rubidium@10105: rubidium@10113: if (order->GetNonStopType() == non_stop) return; rubidium@10113: rubidium@10113: /* Keypress if negative, so 'toggle' to the next */ rubidium@10113: if (non_stop < 0) { rubidium@10113: non_stop = (order->GetNonStopType() + 1) % ONSF_END; rubidium@10113: } rubidium@10113: rubidium@10136: 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)); Celestar@1000: } Celestar@1000: rubidium@7303: /** rubidium@7303: * Handle the click on the transfer button. rubidium@7303: * rubidium@7303: * @param w current window rubidium@7303: * @param v current vehicle rubidium@7303: */ rubidium@10113: static void OrderClick_Transfer(Window *w, const Vehicle *v, int i) celestar@1935: { rubidium@10105: VehicleOrderID sel_ord = OrderGetSel(w); rubidium@10105: const Order *order = GetVehicleOrder(v, sel_ord); rubidium@10105: rubidium@10136: 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)); celestar@1935: } celestar@1935: rubidium@7303: /** rubidium@7303: * Handle the click on the skip button. rubidium@7303: * If ctrl is pressed skip to selected order. rubidium@7303: * Else skip to current order + 1 rubidium@7303: * rubidium@7303: * @param w current window rubidium@7303: * @param v current vehicle rubidium@7303: */ rubidium@10113: static void OrderClick_Skip(Window *w, const Vehicle *v, int i) Celestar@1000: { rubidium@7290: /* Don't skip when there's nothing to skip */ rubidium@7290: if (_ctrl_pressed && v->cur_order_index == OrderGetSel(w)) return; rubidium@7290: rubidium@7290: DoCommandP(v->tile, v->index, _ctrl_pressed ? OrderGetSel(w) : ((v->cur_order_index + 1) % v->num_orders), rubidium@7290: NULL, CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_CAN_T_SKIP_TO_ORDER : STR_CAN_T_SKIP_ORDER)); Celestar@1000: } Celestar@1000: rubidium@7303: /** rubidium@7303: * Handle the click on the unload button. rubidium@7303: * rubidium@7303: * @param w current window rubidium@7303: * @param v current vehicle rubidium@7303: */ rubidium@10113: static void OrderClick_Delete(Window *w, const Vehicle *v, int i) Celestar@1000: { truelight@1024: DoCommandP(v->tile, v->index, OrderGetSel(w), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER)); Celestar@1000: } Celestar@1000: rubidium@7303: /** rubidium@7303: * Handle the click on the refit button. rubidium@7303: * If ctrl is pressed cancel refitting. rubidium@7303: * Else show the refit window. rubidium@7303: * rubidium@7303: * @param w current window rubidium@7303: * @param v current vehicle rubidium@7303: */ rubidium@10113: static void OrderClick_Refit(Window *w, const Vehicle *v, int i) bjarni@4712: { bjarni@4712: if (_ctrl_pressed) { bjarni@4712: /* Cancel refitting */ rubidium@8578: DoCommandP(v->tile, v->index, (WP(w, order_d).sel << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT); bjarni@4712: } else { rubidium@8578: ShowVehicleRefitWindow(v, WP(w, order_d).sel); bjarni@4712: } bjarni@4712: } bjarni@4712: rubidium@10113: typedef void OnButtonVehClick(Window *w, const Vehicle *v, int i); Celestar@1000: rubidium@7303: /** rubidium@7303: * Keycode function mapping. rubidium@7303: * rubidium@7303: * @see _order_keycodes[] rubidium@7303: * @note Keep them allways in sync with _order_keycodes[]! rubidium@7303: */ belugas@4171: static OnButtonVehClick* const _order_button_proc[] = { Celestar@1000: OrderClick_Skip, Celestar@1000: OrderClick_Delete, Celestar@1000: OrderClick_Nonstop, Celestar@1000: OrderClick_Goto, Celestar@1000: OrderClick_FullLoad, celestar@1935: OrderClick_Unload, rubidium@10110: OrderClick_Transfer, rubidium@10110: OrderClick_Service, Celestar@1000: }; Celestar@1000: Celestar@1000: static const uint16 _order_keycodes[] = { Celestar@1000: 'D', //skip order Celestar@1000: 'F', //delete order Celestar@1000: 'G', //non-stop Celestar@1000: 'H', //goto order Celestar@1000: 'J', //full load Celestar@1000: 'K' //unload Celestar@1000: }; truelight@0: truelight@0: static void OrdersWndProc(Window *w, WindowEvent *e) truelight@0: { rubidium@10107: const Vehicle *v = GetVehicle(w->window_number); rubidium@10107: tron@2549: switch (e->event) { bjarni@4712: case WE_CREATE: maedhros@7476: if (_patches.timetabling) { maedhros@7476: w->widget[ORDER_WIDGET_CAPTION].right -= 61; maedhros@7476: } else { rubidium@8493: w->HideWidget(ORDER_WIDGET_TIMETABLE_VIEW); maedhros@7476: } maedhros@7476: bjarni@4712: break; bjarni@4712: rubidium@10107: case WE_PAINT: rubidium@10107: DrawOrdersWindow(w); maedhros@7476: break; maedhros@7476: rubidium@10107: case WE_CLICK: rubidium@10123: if (w->widget[e->we.click.widget].type != WWT_DROPDOWN) HideDropDownMenu(w); rubidium@10107: switch (e->we.click.widget) { rubidium@10107: case ORDER_WIDGET_ORDER_LIST: { rubidium@10107: ResetObjectToPlace(); rubidium@7328: rubidium@10107: int sel = GetOrderFromOrderWndPt(w, e->we.click.pt.y, v); rubidium@7328: rubidium@10107: if (sel == INVALID_ORDER) { rubidium@10107: /* This was a click on an empty part of the orders window, so rubidium@10107: * deselect the currently selected order. */ rubidium@10107: WP(w, order_d).sel = -1; rubidium@10434: w->SetDirty(); rubidium@10107: return; rubidium@10107: } rubidium@7328: rubidium@10107: if (_ctrl_pressed && sel < v->num_orders) { rubidium@10107: const Order *ord = GetVehicleOrder(v, sel); rubidium@10107: TileIndex xy; rubidium@10107: rubidium@10107: switch (ord->GetType()) { rubidium@10107: case OT_GOTO_STATION: xy = GetStation(ord->GetDestination())->xy ; break; rubidium@10107: case OT_GOTO_DEPOT: xy = (v->type == VEH_AIRCRAFT) ? GetStation(ord->GetDestination())->xy : GetDepot(ord->GetDestination())->xy; break; rubidium@10107: case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->GetDestination())->xy; break; rubidium@10107: default: xy = 0; break; rubidium@10107: } rubidium@10107: rubidium@10107: if (xy != 0) ScrollMainWindowToTile(xy); rubidium@10107: return; rubidium@10107: } else { rubidium@10107: if (sel == WP(w, order_d).sel) { rubidium@10107: /* Deselect clicked order */ rubidium@10107: WP(w, order_d).sel = -1; rubidium@10107: } else { rubidium@10107: /* Select clicked order */ rubidium@10107: WP(w, order_d).sel = sel; rubidium@10107: rubidium@10107: if (v->owner == _local_player) { rubidium@10107: /* Activate drag and drop */ rubidium@10107: SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, VHM_DRAG, w); rubidium@10107: } rubidium@10107: } rubidium@10107: } rubidium@10107: rubidium@10434: w->SetDirty(); rubidium@10107: } break; rubidium@10107: rubidium@10107: case ORDER_WIDGET_SKIP: rubidium@10113: OrderClick_Skip(w, v, 0); rubidium@10107: break; rubidium@10107: rubidium@10107: case ORDER_WIDGET_DELETE: rubidium@10113: OrderClick_Delete(w, v, 0); rubidium@10107: break; rubidium@10107: rubidium@10118: case ORDER_WIDGET_NON_STOP: { rubidium@10118: const Order *o = GetVehicleOrder(v, OrderGetSel(w)); rubidium@10121: 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)); rubidium@10118: } break; rubidium@10107: rubidium@10107: case ORDER_WIDGET_GOTO: rubidium@10113: OrderClick_Goto(w, v, 0); rubidium@10107: break; rubidium@10107: rubidium@10130: case ORDER_WIDGET_GOTO_DROPDOWN: rubidium@10130: 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); rubidium@10130: break; rubidium@10130: rubidium@10107: case ORDER_WIDGET_FULL_LOAD: rubidium@10121: ShowDropDownMenu(w, _order_full_load_drowdown, GetVehicleOrder(v, OrderGetSel(w))->GetLoadType(), ORDER_WIDGET_FULL_LOAD, 0, 2); rubidium@10107: break; rubidium@10107: rubidium@10107: case ORDER_WIDGET_UNLOAD: rubidium@10121: ShowDropDownMenu(w, _order_unload_drowdown, GetVehicleOrder(v, OrderGetSel(w))->GetUnloadType(), ORDER_WIDGET_UNLOAD, 0, 8); rubidium@10107: break; rubidium@10110: rubidium@10107: case ORDER_WIDGET_REFIT: rubidium@10113: OrderClick_Refit(w, v, 0); rubidium@10107: break; rubidium@10107: rubidium@10110: case ORDER_WIDGET_SERVICE: rubidium@10113: OrderClick_Service(w, v, 0); rubidium@10110: break; rubidium@10110: rubidium@10107: case ORDER_WIDGET_TIMETABLE_VIEW: rubidium@10107: ShowTimetableWindow(v); rubidium@10107: break; rubidium@10107: rubidium@10136: case ORDER_WIDGET_COND_VARIABLE: rubidium@10136: ShowDropDownMenu(w, _order_conditional_variable, GetVehicleOrder(v, OrderGetSel(w))->GetConditionVariable(), ORDER_WIDGET_COND_VARIABLE, 0, 0); rubidium@10136: break; rubidium@10136: rubidium@10136: case ORDER_WIDGET_COND_COMPARATOR: { rubidium@10136: const Order *o = GetVehicleOrder(v, OrderGetSel(w)); rubidium@10136: ShowDropDownMenu(w, _order_conditional_condition, o->GetConditionComparator(), ORDER_WIDGET_COND_COMPARATOR, 0, (o->GetConditionVariable() == OCV_REQUIRES_SERVICE) ? 0x3F : 0xC0); rubidium@10136: } break; rubidium@10136: rubidium@10136: case ORDER_WIDGET_COND_VALUE: { rubidium@10136: const Order *order = GetVehicleOrder(v, OrderGetSel(w)); rubidium@10136: uint value = order->GetConditionValue(); rubidium@10136: if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value); rubidium@10136: SetDParam(0, value); rubidium@10136: ShowQueryString(STR_CONFIG_PATCHES_INT32, STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, 100, w, CS_NUMERAL); rubidium@10136: } break; rubidium@10136: rubidium@10107: case ORDER_WIDGET_SHARED_ORDER_LIST: rubidium@10107: ShowVehicleListWindow(v); rubidium@10107: break; rubidium@10107: } rubidium@10107: break; rubidium@10107: rubidium@10136: case WE_ON_EDIT_TEXT: rubidium@10136: if (!StrEmpty(e->we.edittext.str)) { rubidium@10136: VehicleOrderID sel = OrderGetSel(w); rubidium@10136: uint value = atoi(e->we.edittext.str); rubidium@10136: rubidium@10136: switch (GetVehicleOrder(v, sel)->GetConditionVariable()) { rubidium@10136: case OCV_MAX_SPEED: rubidium@10136: value = ConvertDisplaySpeedToSpeed(value); rubidium@10136: break; rubidium@10136: rubidium@10136: case OCV_RELIABILITY: rubidium@10136: case OCV_LOAD_PERCENTAGE: rubidium@10136: value = Clamp(value, 0, 100); rubidium@10136: rubidium@10136: default: rubidium@10136: break; rubidium@10136: } rubidium@10136: 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)); rubidium@10136: } rubidium@10136: break; rubidium@10136: rubidium@10113: case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list rubidium@10113: switch (e->we.dropdown.button) { rubidium@10113: case ORDER_WIDGET_NON_STOP: rubidium@10113: OrderClick_Nonstop(w, v, e->we.dropdown.index); rubidium@10113: break; rubidium@10113: rubidium@10113: case ORDER_WIDGET_FULL_LOAD: rubidium@10119: OrderClick_FullLoad(w, v, e->we.dropdown.index); rubidium@10119: break; rubidium@10119: rubidium@10119: case ORDER_WIDGET_UNLOAD: rubidium@10119: OrderClick_Unload(w, v, e->we.dropdown.index); rubidium@10113: break; rubidium@10130: rubidium@10130: case ORDER_WIDGET_GOTO: rubidium@10130: switch (e->we.dropdown.index) { rubidium@10136: case 0: rubidium@10136: w->ToggleWidgetLoweredState(ORDER_WIDGET_GOTO); rubidium@10136: OrderClick_Goto(w, v, 0); rubidium@10136: break; rubidium@10136: rubidium@10130: case 1: OrderClick_NearestDepot(w, v, 0); break; rubidium@10136: case 2: OrderClick_Conditional(w, v, 0); break; rubidium@10130: default: NOT_REACHED(); rubidium@10130: } rubidium@10136: break; rubidium@10136: rubidium@10136: case ORDER_WIDGET_COND_VARIABLE: rubidium@10136: 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)); rubidium@10136: break; rubidium@10136: rubidium@10136: case ORDER_WIDGET_COND_COMPARATOR: rubidium@10136: 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)); rubidium@10136: break; rubidium@10113: } rubidium@10113: break; rubidium@10113: rubidium@10107: case WE_DRAGDROP: rubidium@10107: switch (e->we.click.widget) { rubidium@10107: case ORDER_WIDGET_ORDER_LIST: { rubidium@10107: int from_order = OrderGetSel(w); rubidium@10107: int to_order = GetOrderFromOrderWndPt(w, e->we.dragdrop.pt.y, v); rubidium@10107: rubidium@10107: if (!(from_order == to_order || from_order == INVALID_ORDER || from_order > v->num_orders || to_order == INVALID_ORDER || to_order > v->num_orders) && rubidium@10107: DoCommandP(v->tile, v->index, from_order | (to_order << 16), NULL, CMD_MOVE_ORDER | CMD_MSG(STR_CAN_T_MOVE_THIS_ORDER))) { rubidium@10107: WP(w, order_d).sel = -1; rubidium@10107: } rubidium@10107: rubidium@10107: } break; rubidium@10107: rubidium@10107: case ORDER_WIDGET_DELETE: rubidium@10113: OrderClick_Delete(w, v, 0); rubidium@10107: break; rubidium@7328: } rubidium@7328: rubidium@10107: ResetObjectToPlace(); rubidium@10107: break; truelight@0: rubidium@10107: case WE_KEYPRESS: rubidium@10107: if (v->owner != _local_player) break; truelight@0: rubidium@10107: for (uint i = 0; i < lengthof(_order_keycodes); i++) { rubidium@10107: if (e->we.keypress.keycode == _order_keycodes[i]) { rubidium@10107: e->we.keypress.cont = false; rubidium@10107: /* see if the button is disabled */ rubidium@10113: if (!w->IsWidgetDisabled(i + ORDER_WIDGET_SKIP)) _order_button_proc[i](w, v, -1); rubidium@10107: break; rubidium@10107: } rubidium@10107: } rubidium@10107: break; truelight@193: rubidium@10107: case WE_PLACE_OBJ: rubidium@10136: if (WP(w, order_d).goto_type == OPOS_GOTO) { rubidium@10136: OrdersPlaceObj(GetVehicle(w->window_number), e->we.place.tile, w); rubidium@10136: } rubidium@10107: break; rubidium@10107: rubidium@10107: case WE_ABORT_PLACE_OBJ: rubidium@10136: if (WP(w, order_d).goto_type == OPOS_CONDITIONAL) { rubidium@10136: WP(w, order_d).goto_type = OPOS_GOTO; rubidium@10136: if (_cursor.pos.x >= (w->left + w->widget[ORDER_WIDGET_ORDER_LIST].left) && rubidium@10136: _cursor.pos.y >= (w->top + w->widget[ORDER_WIDGET_ORDER_LIST].top) && rubidium@10136: _cursor.pos.x <= (w->left + w->widget[ORDER_WIDGET_ORDER_LIST].right) && rubidium@10136: _cursor.pos.y <= (w->top + w->widget[ORDER_WIDGET_ORDER_LIST].bottom)) { rubidium@10136: int order_id = GetOrderFromOrderWndPt(w, _cursor.pos.y - w->top, v); rubidium@10136: if (order_id != INVALID_ORDER) { rubidium@10136: Order order; rubidium@10136: order.next = NULL; rubidium@10136: order.index = 0; rubidium@10136: order.MakeConditional(order_id); rubidium@10136: rubidium@10136: DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), order.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER)); rubidium@10136: } rubidium@10136: } rubidium@10136: } rubidium@10107: w->RaiseWidget(ORDER_WIDGET_GOTO); rubidium@10107: w->InvalidateWidget(ORDER_WIDGET_GOTO); rubidium@10107: break; rubidium@10107: rubidium@10107: /* check if a vehicle in a depot was clicked.. */ rubidium@10107: case WE_MOUSELOOP: rubidium@10107: v = _place_clicked_vehicle; rubidium@10107: /* rubidium@10107: * Check if we clicked on a vehicle rubidium@10107: * and if the GOTO button of this window is pressed rubidium@10107: * This is because of all open order windows WE_MOUSELOOP is called rubidium@10107: * and if you have 3 windows open, and this check is not done rubidium@10107: * the order is copied to the last open window instead of the rubidium@10107: * one where GOTO is enabled rubidium@10107: */ rubidium@10107: if (v != NULL && w->IsWidgetLowered(ORDER_WIDGET_GOTO)) { rubidium@10107: _place_clicked_vehicle = NULL; rubidium@10107: HandleOrderVehClick(GetVehicle(w->window_number), v, w); rubidium@10107: } rubidium@10107: break; rubidium@10107: rubidium@10107: case WE_RESIZE: rubidium@10107: /* Update the scroll + matrix */ rubidium@10107: w->vscroll.cap = (w->widget[ORDER_WIDGET_ORDER_LIST].bottom - w->widget[ORDER_WIDGET_ORDER_LIST].top) / 10; rubidium@10107: break; rubidium@10107: rubidium@10107: case WE_TIMEOUT: // handle button unclick ourselves... rubidium@10107: /* unclick all buttons except for the 'goto' button (ORDER_WIDGET_GOTO), which is 'persistent' */ rubidium@10107: for (uint i = 0; i < w->widget_count; i++) { rubidium@10107: if (w->IsWidgetLowered(i) && i != ORDER_WIDGET_GOTO) { rubidium@10107: w->RaiseWidget(i); rubidium@10107: w->InvalidateWidget(i); rubidium@10107: } rubidium@10107: } rubidium@10107: break; truelight@0: } truelight@0: } truelight@0: rubidium@7303: /** rubidium@7303: * Widget definition for player train orders rubidium@7303: */ dominik@1081: static const Widget _orders_train_widgets[] = { rubidium@7303: { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // ORDER_WIDGET_CLOSEBOX rubidium@10113: { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 385, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, // ORDER_WIDGET_CAPTION rubidium@10113: { WWT_PUSHTXTBTN, RESIZE_LR, 14, 325, 385, 0, 13, STR_TIMETABLE_VIEW, STR_TIMETABLE_VIEW_TOOLTIP}, // ORDER_WIDGET_TIMETABLE_VIEW rubidium@7303: rubidium@10113: { WWT_PANEL, RESIZE_RB, 14, 0, 373, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST rubidium@7303: rubidium@10113: { WWT_SCROLLBAR, RESIZE_LRB, 14, 374, 385, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // ORDER_WIDGET_SCROLLBAR rubidium@7303: rubidium@10113: { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 123, 88, 99, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, // ORDER_WIDGET_SKIP rubidium@10113: { WWT_PUSHTXTBTN, RESIZE_TB, 14, 124, 247, 88, 99, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, // ORDER_WIDGET_DELETE rubidium@10125: { WWT_DROPDOWN, RESIZE_TB, 14, 0, 123, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_NON_STOP}, // ORDER_WIDGET_NON_STOP rubidium@10130: { WWT_TEXTBTN, RESIZE_TB, 14, 248, 359, 88, 99, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, // ORDER_WIDGET_GOTO rubidium@10130: { WWT_DROPDOWN, RESIZE_TB, 14, 360, 371, 88, 99, STR_EMPTY, STR_ORDER_GO_TO_DROPDOWN_TOOLTIP}, // ORDER_WIDGET_GOTO_DROPDOWN rubidium@10125: { WWT_DROPDOWN, RESIZE_TB, 14, 124, 247, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_FULL_LOAD}, // ORDER_WIDGET_FULL_LOAD rubidium@10125: { WWT_DROPDOWN, RESIZE_TB, 14, 248, 371, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_UNLOAD}, // ORDER_WIDGET_UNLOAD rubidium@10121: { WWT_PUSHTXTBTN, RESIZE_TB, 14, 124, 247, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT rubidium@10123: { WWT_PUSHTXTBTN, RESIZE_TB, 14, 248, 371, 76, 87, STR_SERVICE, STR_SERVICE_HINT}, // ORDER_WIDGET_SERVICE rubidium@10113: rubidium@10136: { WWT_DROPDOWN, RESIZE_TB, 14, 0, 123, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP}, // ORDER_WIDGET_COND_VARIABLE rubidium@10136: { WWT_DROPDOWN, RESIZE_TB, 14, 124, 247, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP}, // ORDER_WIDGET_COND_COMPARATOR rubidium@10136: { WWT_PUSHTXTBTN, RESIZE_TB, 14, 248, 371, 76, 87, STR_CONDITIONAL_VALUE, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP}, // ORDER_WIDGET_COND_VALUE rubidium@10136: rubidium@10113: { WWT_PANEL, RESIZE_RTB, 14, 372, 373, 76, 99, 0x0, STR_NULL}, // ORDER_WIDGET_RESIZE_BAR rubidium@10113: { 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 rubidium@10113: rubidium@10113: { WWT_RESIZEBOX, RESIZE_LRTB, 14, 374, 385, 88, 99, 0x0, STR_RESIZE_BUTTON}, // ORDER_WIDGET_RESIZE rubidium@7303: { WIDGETS_END}, truelight@0: }; truelight@0: dominik@1081: static const WindowDesc _orders_train_desc = { rubidium@10113: WDP_AUTO, WDP_AUTO, 386, 100, 386, 100, rubidium@10229: WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, Darkvater@5013: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE, dominik@1081: _orders_train_widgets, dominik@1081: OrdersWndProc dominik@1081: }; dominik@1081: rubidium@7303: /** rubidium@7303: * Widget definition for player orders (!train) rubidium@7303: */ dominik@1081: static const Widget _orders_widgets[] = { rubidium@7303: { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // ORDER_WIDGET_CLOSEBOX rubidium@10113: { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 385, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, // ORDER_WIDGET_CAPTION rubidium@10113: { WWT_PUSHTXTBTN, RESIZE_LR, 14, 325, 385, 0, 13, STR_TIMETABLE_VIEW, STR_TIMETABLE_VIEW_TOOLTIP}, // ORDER_WIDGET_TIMETABLE_VIEW rubidium@7303: rubidium@10113: { WWT_PANEL, RESIZE_RB, 14, 0, 373, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST rubidium@7303: rubidium@10113: { WWT_SCROLLBAR, RESIZE_LRB, 14, 374, 385, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // ORDER_WIDGET_SCROLLBAR rubidium@7303: rubidium@10113: { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 123, 88, 99, STR_8823_SKIP, STR_8853_SKIP_THE_CURRENT_ORDER}, // ORDER_WIDGET_SKIP rubidium@10113: { WWT_PUSHTXTBTN, RESIZE_TB, 14, 124, 247, 88, 99, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, // ORDER_WIDGET_DELETE rubidium@7303: { WWT_EMPTY, RESIZE_TB, 14, 0, 0, 76, 87, 0x0, 0x0}, // ORDER_WIDGET_NON_STOP rubidium@10130: { WWT_TEXTBTN, RESIZE_TB, 14, 248, 359, 88, 99, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, // ORDER_WIDGET_GOTO rubidium@10130: { WWT_DROPDOWN, RESIZE_TB, 14, 360, 371, 88, 99, STR_EMPTY, STR_ORDER_GO_TO_DROPDOWN_TOOLTIP}, // ORDER_WIDGET_GOTO_DROPDOWN rubidium@10125: { WWT_DROPDOWN, RESIZE_TB, 14, 0, 185, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_FULL_LOAD}, // ORDER_WIDGET_FULL_LOAD rubidium@10136: { WWT_DROPDOWN, RESIZE_TB, 14, 186, 371, 76, 87, STR_NULL, STR_ORDER_TOOLTIP_UNLOAD}, // ORDER_WIDGET_UNLOAD rubidium@10121: { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 185, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT rubidium@10136: { WWT_PUSHTXTBTN, RESIZE_TB, 14, 186, 371, 76, 87, STR_SERVICE, STR_SERVICE_HINT}, // ORDER_WIDGET_SERVICE rubidium@10136: rubidium@10136: { WWT_DROPDOWN, RESIZE_TB, 14, 0, 123, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP}, // ORDER_WIDGET_COND_VARIABLE rubidium@10136: { WWT_DROPDOWN, RESIZE_TB, 14, 124, 247, 76, 87, STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP}, // ORDER_WIDGET_COND_COMPARATOR rubidium@10136: { WWT_PUSHTXTBTN, RESIZE_TB, 14, 248, 371, 76, 87, STR_CONDITIONAL_VALUE, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP}, // ORDER_WIDGET_COND_VALUE rubidium@7303: rubidium@10113: { WWT_PANEL, RESIZE_RTB, 14, 372, 373, 76, 99, 0x0, STR_NULL}, // ORDER_WIDGET_RESIZE_BAR rubidium@10113: { 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 rubidium@7303: rubidium@10113: { WWT_RESIZEBOX, RESIZE_LRTB, 14, 374, 385, 88, 99, 0x0, STR_RESIZE_BUTTON}, // ORDER_WIDGET_RESIZE rubidium@7303: { WIDGETS_END}, dominik@1081: }; dominik@1081: celestar@995: static const WindowDesc _orders_desc = { rubidium@10113: WDP_AUTO, WDP_AUTO, 386, 100, 386, 100, rubidium@10229: WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, Darkvater@5013: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE, celestar@995: _orders_widgets, truelight@0: OrdersWndProc truelight@0: }; truelight@0: rubidium@7303: /** rubidium@7303: * Widget definition for competitor orders rubidium@7303: */ celestar@995: static const Widget _other_orders_widgets[] = { maedhros@7476: { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // ORDER_WIDGET_CLOSEBOX rubidium@10113: { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 385, 0, 13, STR_8829_ORDERS, STR_018C_WINDOW_TITLE_DRAG_THIS}, // ORDER_WIDGET_CAPTION rubidium@10113: { WWT_PUSHTXTBTN, RESIZE_LR, 14, 325, 385, 0, 13, STR_TIMETABLE_VIEW, STR_TIMETABLE_VIEW_TOOLTIP}, // ORDER_WIDGET_TIMETABLE_VIEW rubidium@7303: rubidium@10113: { WWT_PANEL, RESIZE_RB, 14, 0, 373, 14, 75, 0x0, STR_8852_ORDERS_LIST_CLICK_ON_ORDER}, // ORDER_WIDGET_ORDER_LIST rubidium@7303: rubidium@10113: { WWT_SCROLLBAR, RESIZE_LRB, 14, 374, 385, 14, 75, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // ORDER_WIDGET_SCROLLBAR rubidium@7303: rubidium@10110: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_SKIP rubidium@10110: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_DELETE rubidium@10110: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_NON_STOP rubidium@10110: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_GOTO rubidium@10130: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_GOTO_DROPDOWN rubidium@10110: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_FULL_LOAD rubidium@10110: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_UNLOAD rubidium@10110: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_REFIT rubidium@10110: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_SERVICE maedhros@7476: rubidium@10136: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_COND_VARIABLE rubidium@10136: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_COND_COMPARATOR rubidium@10136: { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_COND_VALUE rubidium@10136: rubidium@10113: { WWT_PANEL, RESIZE_RTB, 14, 0, 373, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_RESIZE_BAR rubidium@10110: { WWT_EMPTY, RESIZE_TB, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_SHARED_ORDER_LIST maedhros@7476: smatz@10140: { WWT_RESIZEBOX, RESIZE_LRTB, 14, 374, 385, 76, 87, 0x0, STR_RESIZE_BUTTON}, // ORDER_WIDGET_RESIZE rubidium@7303: { WIDGETS_END}, truelight@0: }; truelight@0: celestar@995: static const WindowDesc _other_orders_desc = { rubidium@10113: WDP_AUTO, WDP_AUTO, 386, 88, 386, 88, rubidium@10229: WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, darkvater@1242: WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE, celestar@995: _other_orders_widgets, truelight@0: OrdersWndProc truelight@0: }; truelight@0: belugas@4171: void ShowOrdersWindow(const 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: dominik@1081: if (v->owner != _local_player) { rubidium@10462: w = AllocateWindowDescFront(&_other_orders_desc, veh); tron@2549: } else { rubidium@10462: w = AllocateWindowDescFront((v->type == VEH_TRAIN || v->type == VEH_ROAD) ? &_orders_train_desc : &_orders_desc, veh); tron@2549: } truelight@0: darkvater@1242: if (w != NULL) { darkvater@1242: w->caption_color = v->owner; darkvater@1242: w->vscroll.cap = 6; darkvater@1242: w->resize.step_height = 10; rubidium@8578: WP(w, order_d).sel = -1; darkvater@1242: } truelight@0: }