Mercurial > hg > openttd
changeset 8885:2d7e1a978a1a draft
(svn r12652) -Codechange: rework the order GUI a little more to make it a little more clear that 'transfer' is just an unload type.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 10 Apr 2008 17:23:51 +0000 |
parents | a91183e5f458 |
children | f0066989af5b |
files | src/economy.cpp src/lang/english.txt src/openttd.cpp src/order_cmd.cpp src/order_gui.cpp |
diffstat | 5 files changed, 70 insertions(+), 71 deletions(-) [+] |
line wrap: on
line diff
--- a/src/economy.cpp +++ b/src/economy.cpp @@ -1637,8 +1637,8 @@ continue; } - /* Do not pick up goods that we unloaded */ - if ((u->current_order.GetUnloadType() & OUFB_UNLOAD) || (u->current_order.GetLoadType() & OLFB_NO_LOAD)) continue; + /* Do not pick up goods when we have no-load set. */ + if (u->current_order.GetLoadType() & OLFB_NO_LOAD) continue; /* update stats */ int t;
--- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2664,15 +2664,19 @@ STR_ORDER_DROP_NO_LOADING :No loading STR_ORDER_DROP_UNLOAD_IF_ACCEPTED :Unload if accepted STR_ORDER_DROP_UNLOAD :Unload all +STR_ORDER_DROP_TRANSFER :Transfer STR_ORDER_DROP_NO_UNLOADING :No unloading -STR_ORDER_UNLOAD :(Unload) STR_ORDER_FULL_LOAD :(Full load) STR_ORDER_FULL_LOAD_ANY :(Full load any cargo) STR_ORDER_NO_LOAD :(No loading) +STR_ORDER_UNLOAD :(Unload and take cargo) +STR_ORDER_UNLOAD_FULL_LOAD :(Unload and wait for full load) +STR_ORDER_UNLOAD_FULL_LOAD_ANY :(Unload and wait for any full load) +STR_ORDER_UNLOAD_NO_LOAD :(Unload and leave empty) STR_ORDER_TRANSFER :(Transfer and take cargo) -STR_ORDER_TRANSFER_UNLOAD :(Transfer and leave empty) STR_ORDER_TRANSFER_FULL_LOAD :(Transfer and wait for full load) STR_ORDER_TRANSFER_FULL_LOAD_ANY :(Transfer and wait for any full load) +STR_ORDER_TRANSFER_NO_LOAD :(Transfer and leave empty) STR_ORDER_NO_UNLOAD :(No unload and take cargo) STR_ORDER_NO_UNLOAD_FULL_LOAD :(No unload and wait for full load) STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY :(No unload and wait for any full load)
--- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -2452,6 +2452,23 @@ Vehicle *v; FOR_ALL_VEHICLES(v) v->current_order.ConvertFromOldSavegame(); + } else if (CheckSavegameVersion(94)) { + /* Unload and transfer are now mutual exclusive. */ + Order *order; + FOR_ALL_ORDERS(order) { + if ((order->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) { + order->SetUnloadType(OUFB_TRANSFER); + order->SetLoadType(OLFB_NO_LOAD); + } + } + + Vehicle *v; + FOR_ALL_VEHICLES(v) { + if ((v->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) { + v->current_order.SetUnloadType(OUFB_TRANSFER); + v->current_order.SetLoadType(OLFB_NO_LOAD); + } + } } return InitializeWindowsAndCaches();
--- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -174,6 +174,11 @@ uint t = ((this->flags & 1) == 0) ? OUF_UNLOAD_IF_POSSIBLE : OUFB_TRANSFER; if ((this->flags & 2) != 0) t |= OUFB_UNLOAD; this->SetUnloadType((OrderUnloadFlags)t); + + if ((this->GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) == (OUFB_UNLOAD | OUFB_TRANSFER)) { + this->SetUnloadType(OUFB_TRANSFER); + this->SetLoadType(OLFB_NO_LOAD); + } } else { uint t = ((this->flags & 6) == 6) ? ODTFB_SERVICE : ODTF_MANUAL; if ((this->flags & 2) != 0) t |= ODTFB_PART_OF_ORDERS; @@ -820,32 +825,16 @@ case MOF_UNLOAD: order->SetUnloadType((OrderUnloadFlags)data); - /* Full loading gets disabled when un loading! */ - if ((data & OUFB_UNLOAD) != 0) { - order->SetLoadType((OrderLoadFlags)(order->GetLoadType() & ~(OLFB_FULL_LOAD | OLF_FULL_LOAD_ANY))); - } - if ((data & (OUFB_NO_UNLOAD | OUFB_TRANSFER)) != 0) { - if ((order->GetLoadType() & OLFB_NO_LOAD) != 0 && (data & OUFB_TRANSFER) != 0) { - order->SetUnloadType((OrderUnloadFlags)(data | OUFB_UNLOAD)); - } + if ((data & OUFB_NO_UNLOAD) != 0 && (order->GetLoadType() & OLFB_NO_LOAD) != 0) { order->SetLoadType((OrderLoadFlags)(order->GetLoadType() & ~OLFB_NO_LOAD)); } break; case MOF_LOAD: order->SetLoadType((OrderLoadFlags)data); - /* Unloading gets disabled when full loading! */ - if ((data & OLFB_FULL_LOAD) != 0) { - order->SetUnloadType((OrderUnloadFlags)(order->GetUnloadType() & ~OUFB_UNLOAD)); - } - if ((data & OLFB_NO_LOAD) != 0) { - if ((order->GetUnloadType() & OUFB_TRANSFER) != 0) { - /* No load + transfer == unload + transfer */ - order->SetUnloadType((OrderUnloadFlags)(order->GetUnloadType() | OUFB_UNLOAD)); - order->SetLoadType((OrderLoadFlags)(data & ~OLFB_NO_LOAD)); - } else { - order->SetUnloadType((OrderUnloadFlags)(order->GetUnloadType() & ~OUFB_NO_UNLOAD)); - } + if ((data & OLFB_NO_LOAD) != 0 && (order->GetUnloadType() & OUFB_NO_UNLOAD) != 0) { + /* No load + no unload isn't compatible */ + order->SetUnloadType((OrderUnloadFlags)(order->GetUnloadType() & ~OUFB_NO_UNLOAD)); } break;
--- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -44,7 +44,6 @@ ORDER_WIDGET_FULL_LOAD, ORDER_WIDGET_UNLOAD, ORDER_WIDGET_REFIT, - ORDER_WIDGET_TRANSFER, ORDER_WIDGET_SERVICE, ORDER_WIDGET_RESIZE_BAR, ORDER_WIDGET_SHARED_ORDER_LIST, @@ -97,15 +96,27 @@ static const StringID _station_load_types[][5] = { { STR_EMPTY, - STR_ORDER_UNLOAD, + INVALID_STRING_ID, STR_ORDER_FULL_LOAD, STR_ORDER_FULL_LOAD_ANY, STR_ORDER_NO_LOAD, }, { + STR_ORDER_UNLOAD, + INVALID_STRING_ID, + STR_ORDER_UNLOAD_FULL_LOAD, + STR_ORDER_UNLOAD_FULL_LOAD_ANY, + STR_ORDER_UNLOAD_NO_LOAD, + }, { STR_ORDER_TRANSFER, - STR_ORDER_TRANSFER_UNLOAD, + INVALID_STRING_ID, STR_ORDER_TRANSFER_FULL_LOAD, STR_ORDER_TRANSFER_FULL_LOAD_ANY, + STR_ORDER_TRANSFER_NO_LOAD, + }, { + /* Unload and transfer do not work together. */ + INVALID_STRING_ID, + INVALID_STRING_ID, + INVALID_STRING_ID, INVALID_STRING_ID, }, { STR_ORDER_NO_UNLOAD, @@ -138,7 +149,6 @@ w->SetWidgetDisabledState(ORDER_WIDGET_NON_STOP, v->type != VEH_TRAIN || order == NULL); w->SetWidgetDisabledState(ORDER_WIDGET_FULL_LOAD, order == NULL); // full load w->SetWidgetDisabledState(ORDER_WIDGET_UNLOAD, order == NULL); // unload - w->SetWidgetDisabledState(ORDER_WIDGET_TRANSFER, order == NULL); // transfer /* Disable list of vehicles with the same shared orders if there is no list */ w->SetWidgetDisabledState(ORDER_WIDGET_SHARED_ORDER_LIST, !shared_orders || v->orders == NULL); w->SetWidgetDisabledState(ORDER_WIDGET_REFIT, order == NULL); // Refit @@ -146,12 +156,11 @@ w->HideWidget(ORDER_WIDGET_REFIT); // Refit w->HideWidget(ORDER_WIDGET_SERVICE); // Service } else { - w->DisableWidget(ORDER_WIDGET_TRANSFER); w->DisableWidget(ORDER_WIDGET_FULL_LOAD); } w->ShowWidget(ORDER_WIDGET_UNLOAD); - w->ShowWidget(ORDER_WIDGET_TRANSFER); + w->ShowWidget(ORDER_WIDGET_FULL_LOAD); if (order != NULL) { switch (order->GetType()) { @@ -162,7 +171,6 @@ 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: @@ -171,7 +179,7 @@ /* Remove unload and replace it with refit */ w->HideWidget(ORDER_WIDGET_UNLOAD); w->ShowWidget(ORDER_WIDGET_REFIT); - w->HideWidget(ORDER_WIDGET_TRANSFER); + w->HideWidget(ORDER_WIDGET_FULL_LOAD); w->ShowWidget(ORDER_WIDGET_SERVICE); break; @@ -210,7 +218,7 @@ SetDParam(1, STR_GO_TO_STATION); SetDParam(2, STR_ORDER_GO_TO + (v->type == VEH_TRAIN ? order->GetNonStopType() : 0)); SetDParam(3, order->GetDestination()); - SetDParam(4, _station_load_types[unload >> 1][load | (unload & ~(OUFB_TRANSFER | OUFB_NO_UNLOAD))]); + SetDParam(4, _station_load_types[unload][load]); } break; case OT_GOTO_DEPOT: { @@ -412,7 +420,7 @@ VehicleOrderID sel_ord = OrderGetSel(w); const Order *order = GetVehicleOrder(v, sel_ord); - if (load_type >= 0 && order->GetLoadType() == load_type) return; + if (order->GetLoadType() == load_type) return; if (load_type < 0) { switch (order->GetLoadType()) { @@ -448,18 +456,18 @@ VehicleOrderID sel_ord = OrderGetSel(w); const Order *order = GetVehicleOrder(v, sel_ord); + if (order->GetUnloadType() == unload_type) return; + if (unload_type < 0) { switch (order->GetUnloadType()) { case OUF_UNLOAD_IF_POSSIBLE: unload_type = OUFB_UNLOAD; break; - case OUFB_UNLOAD: unload_type = OUFB_NO_UNLOAD; break; + case OUFB_UNLOAD: unload_type = OUFB_TRANSFER; break; + case OUFB_TRANSFER: unload_type = OUFB_NO_UNLOAD; break; case OUFB_NO_UNLOAD: unload_type = OUF_UNLOAD_IF_POSSIBLE; break; default: NOT_REACHED(); } } - if ((order->GetUnloadType() & OUFB_TRANSFER) != 0 && unload_type != OUFB_NO_UNLOAD) unload_type |= OUFB_TRANSFER; - if (order->GetUnloadType() == unload_type) return; - DoCommandP(v->tile, v->index + (sel_ord << 16), MOF_UNLOAD | (unload_type << 2), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); } @@ -593,7 +601,7 @@ static const StringID _order_unload_drowdown[] = { STR_ORDER_DROP_UNLOAD_IF_ACCEPTED, STR_ORDER_DROP_UNLOAD, - STR_EMPTY, + STR_ORDER_DROP_TRANSFER, STR_EMPTY, STR_ORDER_DROP_NO_UNLOADING, INVALID_STRING_ID @@ -605,18 +613,6 @@ switch (e->event) { case WE_CREATE: - /* Ensure that the refit and unload buttons always remain at the same location. - * Only one of them can be active at any one time and takes turns on being disabled. - * To ensure that they stay at the same location, we also verify that they behave the same - * when resizing. */ - if (v->owner == _local_player) { // only the vehicle owner got these buttons - assert(w->widget[ORDER_WIDGET_REFIT].left == w->widget[ORDER_WIDGET_UNLOAD].left); - assert(w->widget[ORDER_WIDGET_REFIT].right == w->widget[ORDER_WIDGET_UNLOAD].right); - assert(w->widget[ORDER_WIDGET_REFIT].top == w->widget[ORDER_WIDGET_UNLOAD].top); - assert(w->widget[ORDER_WIDGET_REFIT].bottom == w->widget[ORDER_WIDGET_UNLOAD].bottom); - assert(w->widget[ORDER_WIDGET_REFIT].display_flags == w->widget[ORDER_WIDGET_UNLOAD].display_flags); - } - if (_patches.timetabling) { w->widget[ORDER_WIDGET_CAPTION].right -= 61; } else { @@ -630,10 +626,10 @@ break; case WE_CLICK: + HideDropDownMenu(w); switch (e->we.click.widget) { case ORDER_WIDGET_ORDER_LIST: { ResetObjectToPlace(); - HideDropDownMenu(w); int sel = GetOrderFromOrderWndPt(w, e->we.click.pt.y, v); @@ -686,7 +682,7 @@ case ORDER_WIDGET_NON_STOP: { const Order *o = GetVehicleOrder(v, OrderGetSel(w)); - 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), 124); + 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)); } break; case ORDER_WIDGET_GOTO: @@ -694,21 +690,17 @@ break; case ORDER_WIDGET_FULL_LOAD: - ShowDropDownMenu(w, _order_full_load_drowdown, GetVehicleOrder(v, OrderGetSel(w))->GetLoadType(), ORDER_WIDGET_FULL_LOAD, 0, 2, 124); + ShowDropDownMenu(w, _order_full_load_drowdown, GetVehicleOrder(v, OrderGetSel(w))->GetLoadType(), ORDER_WIDGET_FULL_LOAD, 0, 2); break; case ORDER_WIDGET_UNLOAD: - ShowDropDownMenu(w, _order_unload_drowdown, GetVehicleOrder(v, OrderGetSel(w))->GetUnloadType(), ORDER_WIDGET_UNLOAD, 0, 12, 124); + ShowDropDownMenu(w, _order_unload_drowdown, GetVehicleOrder(v, OrderGetSel(w))->GetUnloadType(), ORDER_WIDGET_UNLOAD, 0, 8); break; case ORDER_WIDGET_REFIT: OrderClick_Refit(w, v, 0); break; - case ORDER_WIDGET_TRANSFER: - OrderClick_Transfer(w, v, 0); - break; - case ORDER_WIDGET_SERVICE: OrderClick_Service(w, v, 0); break; @@ -841,13 +833,12 @@ { 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 - { WWT_DROPDOWN, RESIZE_TB, 14, 0, 92, 76, 87, STR_8825_NON_STOP, STR_8855_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_NON_STOP + { WWT_DROPDOWN, RESIZE_TB, 14, 0, 123, 76, 87, STR_8825_NON_STOP, STR_8855_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_NON_STOP { WWT_TEXTBTN, RESIZE_TB, 14, 248, 371, 88, 99, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, // ORDER_WIDGET_GOTO - { WWT_DROPDOWN, RESIZE_TB, 14, 93, 185, 76, 87, STR_8827_FULL_LOAD, STR_8857_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_FULL_LOAD - { WWT_DROPDOWN, RESIZE_TB, 14, 186, 278, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_UNLOAD - { WWT_PUSHTXTBTN, RESIZE_TB, 14, 186, 278, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT - { WWT_PUSHTXTBTN, RESIZE_TB, 14, 279, 371, 76, 87, STR_TRANSFER, STR_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_TRANSFER - { WWT_PUSHTXTBTN, RESIZE_TB, 14, 279, 371, 76, 87, STR_SERVICE, STR_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_SERVICE + { WWT_DROPDOWN, RESIZE_TB, 14, 124, 247, 76, 87, STR_8827_FULL_LOAD, STR_8857_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_FULL_LOAD + { WWT_DROPDOWN, RESIZE_TB, 14, 248, 371, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_UNLOAD + { WWT_PUSHTXTBTN, RESIZE_TB, 14, 124, 247, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT + { WWT_PUSHTXTBTN, RESIZE_TB, 14, 248, 371, 76, 87, STR_SERVICE, STR_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_SERVICE { 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 @@ -880,11 +871,10 @@ { WWT_PUSHTXTBTN, RESIZE_TB, 14, 124, 247, 88, 99, STR_8824_DELETE, STR_8854_DELETE_THE_HIGHLIGHTED}, // ORDER_WIDGET_DELETE { WWT_EMPTY, RESIZE_TB, 14, 0, 0, 76, 87, 0x0, 0x0}, // ORDER_WIDGET_NON_STOP { WWT_TEXTBTN, RESIZE_TB, 14, 248, 371, 88, 99, STR_8826_GO_TO, STR_8856_INSERT_A_NEW_ORDER_BEFORE}, // ORDER_WIDGET_GOTO - { WWT_DROPDOWN, RESIZE_TB, 14, 0, 123, 76, 87, STR_8827_FULL_LOAD, STR_8857_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_FULL_LOAD - { WWT_DROPDOWN, RESIZE_TB, 14, 124, 247, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_UNLOAD - { WWT_PUSHTXTBTN, RESIZE_TB, 14, 124, 247, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT - { WWT_PUSHTXTBTN, RESIZE_TB, 14, 248, 372, 76, 87, STR_TRANSFER, STR_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_TRANSFER - { WWT_PUSHTXTBTN, RESIZE_TB, 14, 248, 372, 76, 87, STR_SERVICE, STR_NULL}, // ORDER_WIDGET_SERVICE + { WWT_DROPDOWN, RESIZE_TB, 14, 0, 185, 76, 87, STR_8827_FULL_LOAD, STR_8857_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_FULL_LOAD + { WWT_DROPDOWN, RESIZE_TB, 14, 186, 372, 76, 87, STR_8828_UNLOAD, STR_8858_MAKE_THE_HIGHLIGHTED_ORDER}, // ORDER_WIDGET_UNLOAD + { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 185, 76, 87, STR_REFIT, STR_REFIT_TIP}, // ORDER_WIDGET_REFIT + { WWT_PUSHTXTBTN, RESIZE_TB, 14, 186, 372, 76, 87, STR_SERVICE, STR_NULL}, // ORDER_WIDGET_SERVICE { 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 @@ -920,7 +910,6 @@ { 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_TRANSFER { WWT_EMPTY, RESIZE_NONE, 14, 0, 0, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_SERVICE { WWT_PANEL, RESIZE_RTB, 14, 0, 373, 76, 87, 0x0, STR_NULL}, // ORDER_WIDGET_RESIZE_BAR