diff --git a/src/depot.cpp b/src/depot.cpp index 821399fd2b..1890faa87d 100644 --- a/src/depot.cpp +++ b/src/depot.cpp @@ -17,6 +17,7 @@ #include "core/pool_func.hpp" #include "vehicle_gui.h" #include "vehiclelist.h" +#include "tracerestrict.h" #include "safeguards.h" @@ -42,6 +43,8 @@ Depot::~Depot() /* Clear the depot from all order-lists */ RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index); + TraceRestrictRemoveDestinationID(TROCAF_DEPOT, this->index); + /* Delete the depot-window */ DeleteWindowById(WC_VEHICLE_DEPOT, this->xy); diff --git a/src/lang/english.txt b/src/lang/english.txt index ad6272d37a..65ec673cd3 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2384,9 +2384,14 @@ STR_TRACE_RESTRICT_CONDITIONAL_ELSE :Else STR_TRACE_RESTRICT_CONDITIONAL_ENDIF :End if STR_TRACE_RESTRICT_VARIABLE_TRAIN_LENGTH :train length STR_TRACE_RESTRICT_VARIABLE_MAX_SPEED :max speed +STR_TRACE_RESTRICT_VARIABLE_CURRENT_ORDER :current order STR_TRACE_RESTRICT_VARIABLE_UNDEFINED :undefined STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_INTEGER :{STRING} {STRING} {STRING} {COMMA} then STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_SPEED :{STRING} {STRING} {STRING} {VELOCITY} then +STR_TRACE_RESTRICT_CONDITIONAL_ORDER_STATION :{STRING} {STRING} {STRING} {STATION} then +STR_TRACE_RESTRICT_CONDITIONAL_ORDER_WAYPOINT :{STRING} {STRING} {STRING} {WAYPOINT} then +STR_TRACE_RESTRICT_CONDITIONAL_ORDER_DEPOT :{STRING} {STRING} {STRING} {DEPOT} then +STR_TRACE_RESTRICT_CONDITIONAL_UNDEFINED :{STRING} {STRING} {STRING} {RED}undefined {BLACK}{STRING}then STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_UNDEFINED :{STRING} {RED}undefined {BLACK}{STRING}then STR_TRACE_RESTRICT_PF_PENALTY_ITEM :Add pathfinder penalty: {COMMA} STR_TRACE_RESTRICT_WHITE :{WHITE} @@ -2409,6 +2414,7 @@ STR_TRACE_RESTRICT_RESET :{BLACK}Reset STR_TRACE_RESTRICT_COPY :{BLACK}Copy STR_TRACE_RESTRICT_SHARE :{BLACK}Share STR_TRACE_RESTRICT_UNSHARE :{BLACK}Unshare +STR_TRACE_RESTRICT_SELECT_TARGET :{BLACK}Select Target STR_TRACE_RESTRICT_INSERT_TOOLTIP :{BLACK}Insert an instruction STR_TRACE_RESTRICT_REMOVE_TOOLTIP :{BLACK}Remove the selected instruction STR_TRACE_RESTRICT_RESET_TOOLTIP :{BLACK}Reset the current signal (without affecting shared programs) @@ -2416,6 +2422,7 @@ STR_TRACE_RESTRICT_COPY_TOOLTIP :{BLACK}Copy pro STR_TRACE_RESTRICT_SHARE_TOOLTIP :{BLACK}Share program with another signal STR_TRACE_RESTRICT_UNSHARE_TOOLTIP :{BLACK}Stop sharing program with other signals, create a copy of the program STR_TRACE_RESTRICT_SIGNAL_GUI_TOOLTIP :{BLACK}Routefinding restriction +STR_TRACE_RESTRICT_INSTRUCTION_LIST_TOOLTIP :{BLACK}Click an instruction to select it{}Ctrl+Click to scroll to the instruction's target (if any) STR_TRACE_RESTRICT_ERROR_CAN_T_INSERT_ITEM :{WHITE}Can't insert instruction STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM :{WHITE}Can't modify instruction STR_TRACE_RESTRICT_ERROR_CAN_T_REMOVE_ITEM :{WHITE}Can't remove instruction diff --git a/src/station.cpp b/src/station.cpp index 456262dea4..9b5dcfb4ca 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -26,6 +26,7 @@ #include "core/random_func.hpp" #include "linkgraph/linkgraph.h" #include "linkgraph/linkgraphschedule.h" +#include "tracerestrict.h" #include "table/strings.h" @@ -137,6 +138,8 @@ Station::~Station() /* Now delete all orders that go to the station */ RemoveOrderFromAllVehicles(OT_GOTO_STATION, this->index); + TraceRestrictRemoveDestinationID(TROCAF_STATION, this->index); + /* Remove all news items */ DeleteStationNews(this->index); diff --git a/src/tracerestrict.cpp b/src/tracerestrict.cpp index 5b25448dd6..737c57fddc 100644 --- a/src/tracerestrict.cpp +++ b/src/tracerestrict.cpp @@ -16,6 +16,7 @@ #include "company_func.h" #include "viewport_func.h" #include "window_func.h" +#include "order_base.h" #include "pathfinder/yapf/yapf_cache.h" #include @@ -131,6 +132,45 @@ static bool TestCondition(uint16 value, TraceRestrictCondOp condop, uint16 condv } } +/// Test order condition +/// order may be NULL +static bool TestOrderCondition(const Order *order, TraceRestrictItem item) +{ + bool result = false; + + if (order) { + DestinationID condvalue = GetTraceRestrictValue(item); + switch (static_cast(GetTraceRestrictAuxField(item))) { + case TROCAF_STATION: + result = order->IsType(OT_GOTO_STATION) && order->GetDestination() == condvalue; + break; + + case TROCAF_WAYPOINT: + result = order->IsType(OT_GOTO_WAYPOINT) && order->GetDestination() == condvalue; + break; + + case OT_GOTO_DEPOT: + result = order->IsType(OT_GOTO_DEPOT) && order->GetDestination() == condvalue; + break; + + default: + NOT_REACHED(); + } + } + + switch (GetTraceRestrictCondOp(item)) { + case TRCO_IS: + return result; + + case TRCO_ISNOT: + return !result; + + default: + NOT_REACHED(); + return false; + } +} + /// Execute program on train and store results in out void TraceRestrictProgram::Execute(const Train* v, TraceRestrictProgramResult& out) const { @@ -174,6 +214,10 @@ void TraceRestrictProgram::Execute(const Train* v, TraceRestrictProgramResult& o result = TestCondition(v->GetDisplayMaxSpeed(), condop, condvalue); break; + case TRIT_COND_CURRENT_ORDER: + result = TestOrderCondition(&(v->current_order), item); + break; + default: NOT_REACHED(); } @@ -266,6 +310,12 @@ void SetTraceRestrictValueDefault(TraceRestrictItem &item, TraceRestrictValueTyp case TRVT_DENY: case TRVT_SPEED: SetTraceRestrictValue(item, 0); + SetTraceRestrictAuxField(item, 0); + break; + + case TRVT_ORDER: + SetTraceRestrictValue(item, INVALID_STATION); + SetTraceRestrictAuxField(item, TROCAF_STATION); break; default: @@ -679,3 +729,22 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag return CommandCost(); } + +void TraceRestrictRemoveDestinationID(TraceRestrictOrderCondAuxField type, uint16 index) +{ + TraceRestrictProgram *prog; + + FOR_ALL_TRACE_RESTRICT_PROGRAMS(prog) { + for (size_t i = 0; i < prog->items.size(); i++) { + TraceRestrictItem &item = prog->items[i]; // note this is a reference, + if (GetTraceRestrictType(item) == TRIT_COND_CURRENT_ORDER) { + if (GetTraceRestrictAuxField(item) == type && GetTraceRestrictValue(item) == index) { + SetTraceRestrictValueDefault(item, TRVT_ORDER); // this updates the instruction in-place + } + } + } + } + + // update windows + InvalidateWindowClassesData(WC_TRACE_RESTRICT); +} diff --git a/src/tracerestrict.h b/src/tracerestrict.h index 87e8cb9b8d..2106d1060c 100644 --- a/src/tracerestrict.h +++ b/src/tracerestrict.h @@ -59,10 +59,11 @@ enum TraceRestrictItemFlagAllocation { /* 3 bits reserved for future use */ - TRIFA_COND_FLAGS_COUNT = 2, + TRIFA_COND_FLAGS_COUNT = 3, TRIFA_COND_FLAGS_OFFSET = 8, - /* 3 bits reserved for future use */ + TRIFA_AUX_FIELD_COUNT = 2, + TRIFA_AUX_FIELD_OFFSET = 11, TRIFA_COND_OP_COUNT = 3, TRIFA_COND_OP_OFFSET = 13, @@ -81,6 +82,7 @@ enum TraceRestrictItemType { TRIT_COND_UNDEFINED = 9, ///< This condition has no type defined (evaluate as false) TRIT_COND_TRAIN_LENGTH = 10, ///< Test train length TRIT_COND_MAX_SPEED = 11, ///< Test train max speed + TRIT_COND_CURRENT_ORDER = 12, ///< Test train current order (station, waypoint or depot) /* space up to 31 */ }; @@ -88,6 +90,7 @@ enum TraceRestrictItemType { enum TraceRestrictCondFlags { TRCF_ELSE = 1 << 0, TRCF_OR = 1 << 1, + /* 1 bit spare */ }; DECLARE_ENUM_AS_BIT_SET(TraceRestrictCondFlags) @@ -107,6 +110,13 @@ enum TraceRestrictCondOp { /* space up to 7 */ }; +enum TraceRestrictOrderCondAuxField { + TROCAF_STATION = 0, + TROCAF_WAYPOINT = 1, + TROCAF_DEPOT = 2, + /* space up to 7 */ +}; + enum TraceRestrictProgramResultFlags { TRPRF_DENY = 1 << 0, }; @@ -155,6 +165,11 @@ static inline TraceRestrictCondOp GetTraceRestrictCondOp(TraceRestrictItem item) return static_cast(GB(item, TRIFA_COND_OP_OFFSET, TRIFA_COND_OP_COUNT)); } +static inline uint8 GetTraceRestrictAuxField(TraceRestrictItem item) +{ + return GB(item, TRIFA_AUX_FIELD_OFFSET, TRIFA_AUX_FIELD_COUNT); +} + static inline uint16 GetTraceRestrictValue(TraceRestrictItem item) { return static_cast(GB(item, TRIFA_VALUE_OFFSET, TRIFA_VALUE_COUNT)); @@ -170,6 +185,11 @@ static inline void SetTraceRestrictCondOp(TraceRestrictItem &item, TraceRestrict SB(item, TRIFA_COND_OP_OFFSET, TRIFA_COND_OP_COUNT, condop); } +static inline void SetTraceRestrictAuxField(TraceRestrictItem &item, uint8 data) +{ + SB(item, TRIFA_AUX_FIELD_OFFSET, TRIFA_AUX_FIELD_COUNT, data); +} + void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type); static inline void SetTraceRestrictValue(TraceRestrictItem &item, uint16 value) @@ -199,6 +219,7 @@ enum TraceRestrictValueType { TRVT_INT = 2, ///< takes an integer value TRVT_DENY = 3, ///< takes a value 0 = deny, 1 = allow (cancel previous deny) TRVT_SPEED = 4, ///< takes an integer speed value + TRVT_ORDER = 5, ///< takes an order target ID, as per the auxiliary field as type: TraceRestrictOrderCondAuxField }; struct TraceRestrictTypePropertySet { @@ -229,6 +250,11 @@ static inline TraceRestrictTypePropertySet GetTraceRestrictTypeProperties(TraceR out.value_type = TRVT_SPEED; break; + case TRIT_COND_CURRENT_ORDER: + out.value_type = TRVT_ORDER; + out.cond_type = TRCOT_BINARY; + break; + default: NOT_REACHED(); break; @@ -311,4 +337,6 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag void ShowTraceRestrictProgramWindow(TileIndex tile, Track track); +void TraceRestrictRemoveDestinationID(TraceRestrictOrderCondAuxField type, uint16 index); + #endif /* TRACERESTRICT_H */ diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index b1e8251898..8f04d0203b 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -23,7 +23,11 @@ #include "gui.h" #include "gfx_func.h" #include "rail_map.h" +#include "depot_map.h" #include "tile_cmd.h" +#include "station_base.h" +#include "waypoint_base.h" +#include "depot_base.h" #include "error.h" #include "table/sprites.h" @@ -44,6 +48,7 @@ enum TraceRestrictWindowWidgets { TR_WIDGET_COMPARATOR, TR_WIDGET_VALUE_INT, TR_WIDGET_VALUE_DROPDOWN, + TR_WIDGET_VALUE_DEST, TR_WIDGET_BLANK_L, TR_WIDGET_BLANK_M, @@ -70,6 +75,7 @@ enum PanelWidgets { // Right DPR_VALUE_INT = 0, DPR_VALUE_DROPDOWN, + DPR_VALUE_DEST, DPR_BLANK, // Share @@ -152,12 +158,14 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictI static const StringID str_cond[] = { STR_TRACE_RESTRICT_VARIABLE_TRAIN_LENGTH, STR_TRACE_RESTRICT_VARIABLE_MAX_SPEED, + STR_TRACE_RESTRICT_VARIABLE_CURRENT_ORDER, STR_TRACE_RESTRICT_VARIABLE_UNDEFINED, INVALID_STRING_ID, }; static const uint val_cond[] = { TRIT_COND_TRAIN_LENGTH, TRIT_COND_MAX_SPEED, + TRIT_COND_CURRENT_ORDER, TRIT_COND_UNDEFINED, }; static const TraceRestrictDropDownListSet set_cond = { @@ -257,12 +265,17 @@ static const StringID _program_cond_type[] = { /* TRCF_OR */ STR_TRACE_RESTRICT_CONDITIONAL_ORIF, }; -static void DrawInstructionStringConditionalIntegerCommon(TraceRestrictItem item, const TraceRestrictTypePropertySet &properties) +static void DrawInstructionStringConditionalCommon(TraceRestrictItem item, const TraceRestrictTypePropertySet &properties) { assert(GetTraceRestrictCondFlags(item) <= TRCF_OR); SetDParam(0, _program_cond_type[GetTraceRestrictCondFlags(item)]); SetDParam(1, GetTypeString(GetTraceRestrictType(item))); SetDParam(2, GetDropDownStringByValue(GetCondOpDropDownListSet(properties.cond_type), GetTraceRestrictCondOp(item))); +} + +static void DrawInstructionStringConditionalIntegerCommon(TraceRestrictItem item, const TraceRestrictTypePropertySet &properties) +{ + DrawInstructionStringConditionalCommon(item, properties); SetDParam(3, GetTraceRestrictValue(item)); } @@ -292,14 +305,55 @@ static void DrawInstructionString(TraceRestrictItem item, int y, bool selected, instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_UNDEFINED; SetDParam(0, _program_cond_type[GetTraceRestrictCondFlags(item)]); SetDParam(1, selected ? STR_TRACE_RESTRICT_WHITE : STR_EMPTY); - } else if (properties.value_type == TRVT_INT) { - instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_INTEGER; - DrawInstructionStringConditionalIntegerCommon(item, properties); - } else if (properties.value_type == TRVT_SPEED) { - instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_SPEED; - DrawInstructionStringConditionalIntegerCommon(item, properties); } else { - NOT_REACHED(); + switch (properties.value_type) { + case TRVT_INT: + instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_INTEGER; + DrawInstructionStringConditionalIntegerCommon(item, properties); + break; + + case TRVT_SPEED: + instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_SPEED; + DrawInstructionStringConditionalIntegerCommon(item, properties); + break; + + case TRVT_ORDER: { + switch (static_cast(GetTraceRestrictAuxField(item))) { + case TROCAF_STATION: + if (GetTraceRestrictValue(item) != INVALID_STATION) { + instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_ORDER_STATION; + DrawInstructionStringConditionalIntegerCommon(item, properties); + } else { + // this is an invalid station, use a seperate string + instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_UNDEFINED; + DrawInstructionStringConditionalCommon(item, properties); + SetDParam(3, selected ? STR_TRACE_RESTRICT_WHITE : STR_EMPTY); + } + break; + + case TROCAF_WAYPOINT: + instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_ORDER_WAYPOINT; + DrawInstructionStringConditionalIntegerCommon(item, properties); + break; + + case TROCAF_DEPOT: + instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_ORDER_DEPOT; + DrawInstructionStringConditionalCommon(item, properties); + SetDParam(3, VEH_TRAIN); + SetDParam(4, GetTraceRestrictValue(item)); + break; + + default: + NOT_REACHED(); + break; + } + break; + } + + default: + NOT_REACHED(); + break; + } } } else { switch (GetTraceRestrictType(item)) { @@ -369,6 +423,35 @@ public: case TR_WIDGET_INSTRUCTION_LIST: { int sel = this->GetInstructionFromPt(pt.y); + if (_ctrl_pressed) { + // scroll to target (for stations, waypoints, depots) + + if (sel == -1) return; + + TraceRestrictItem item = this->GetItem(this->GetProgram(), sel); + if (GetTraceRestrictTypeProperties(item).value_type == TRVT_ORDER) { + switch (static_cast(GetTraceRestrictAuxField(item))) { + case TROCAF_STATION: + case TROCAF_WAYPOINT: { + BaseStation *st = BaseStation::GetIfValid(GetTraceRestrictValue(item)); + if (st) { + ScrollMainWindowToTile(st->xy); + } + break; + } + + case TROCAF_DEPOT: { + Depot *depot = Depot::GetIfValid(GetTraceRestrictValue(item)); + if (depot) { + ScrollMainWindowToTile(depot->xy); + } + break; + } + } + } + return; + } + this->DeleteChildWindows(); HideDropDownMenu(this); @@ -440,6 +523,11 @@ public: break; } + case TR_WIDGET_VALUE_DEST: { + SetObjectToPlaceAction(widget, ANIMCURSOR_PICKSTATION); + break; + } + case TR_WIDGET_GOTO_SIGNAL: ScrollMainWindowToTile(this->tile); break; @@ -451,7 +539,7 @@ public: case TR_WIDGET_COPY: case TR_WIDGET_SHARE: - SelectSignalAction(widget); + SetObjectToPlaceAction(widget, ANIMCURSOR_BUILDSIGNALS); break; case TR_WIDGET_UNSHARE: { @@ -527,7 +615,7 @@ public: } } - virtual void OnPlaceObject(Point pt, TileIndex source_tile) + virtual void OnPlaceObject(Point pt, TileIndex tile) { int widget = this->current_placement_widget; this->current_placement_widget = -1; @@ -539,8 +627,27 @@ public: return; } - int error_message = (widget == TR_WIDGET_COPY) ? STR_TRACE_RESTRICT_ERROR_CAN_T_COPY_PROGRAM : STR_TRACE_RESTRICT_ERROR_CAN_T_SHARE_PROGRAM; + switch (widget) { + case TR_WIDGET_COPY: + OnPlaceObjectSignal(pt, tile, widget, STR_TRACE_RESTRICT_ERROR_CAN_T_COPY_PROGRAM); + break; + case TR_WIDGET_SHARE: + OnPlaceObjectSignal(pt, tile, widget, STR_TRACE_RESTRICT_ERROR_CAN_T_SHARE_PROGRAM); + break; + + case TR_WIDGET_VALUE_DEST: + OnPlaceObjectDestination(pt, tile, widget, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM); + break; + + default: + NOT_REACHED(); + break; + } + } + + void OnPlaceObjectSignal(Point pt, TileIndex source_tile, int widget, int error_message) + { if (!IsPlainRailTile(source_tile)) { ShowErrorMessage(error_message, STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, WL_INFO); return; @@ -587,6 +694,38 @@ public: } } + void OnPlaceObjectDestination(Point pt, TileIndex tile, int widget, int error_message) + { + TraceRestrictItem item = GetSelected(); + if (GetTraceRestrictTypeProperties(item).value_type != TRVT_ORDER) return; + + if (IsDepotTypeTile(tile, TRANSPORT_RAIL)) { + SetTraceRestrictValue(item, GetDepotIndex(tile)); + SetTraceRestrictAuxField(item, TROCAF_DEPOT); + } else if (IsRailWaypointTile(tile)) { + SetTraceRestrictValue(item, GetStationIndex(tile)); + SetTraceRestrictAuxField(item, TROCAF_WAYPOINT); + } else if (IsTileType(tile, MP_STATION)) { + StationID st_index = GetStationIndex(tile); + const Station *st = Station::Get(st_index); + if (st->facilities & FACIL_TRAIN) { + SetTraceRestrictValue(item, st_index); + SetTraceRestrictAuxField(item, TROCAF_STATION); + } else { + return; + } + } else { + return; + } + + if (!IsTileOwner(tile, _local_company)) { + ShowErrorMessage(error_message, STR_ERROR_AREA_IS_OWNED_BY_ANOTHER, WL_INFO); + return; + } + + TraceRestrictDoCommandP(this->tile, this->track, TRDCT_MODIFY_ITEM, this->selected_instruction - 1, item, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM); + } + virtual void OnPlaceObjectAbort() { this->RaiseButtons(); @@ -789,6 +928,7 @@ private: this->RaiseWidget(TR_WIDGET_COMPARATOR); this->RaiseWidget(TR_WIDGET_VALUE_INT); this->RaiseWidget(TR_WIDGET_VALUE_DROPDOWN); + this->RaiseWidget(TR_WIDGET_VALUE_DEST); NWidgetStacked *left_sel = this->GetWidget(TR_WIDGET_SEL_TOP_LEFT); NWidgetStacked *middle_sel = this->GetWidget(TR_WIDGET_SEL_TOP_MIDDLE); @@ -799,6 +939,7 @@ private: this->DisableWidget(TR_WIDGET_COMPARATOR); this->DisableWidget(TR_WIDGET_VALUE_INT); this->DisableWidget(TR_WIDGET_VALUE_DROPDOWN); + this->DisableWidget(TR_WIDGET_VALUE_DEST); this->DisableWidget(TR_WIDGET_INSERT); this->DisableWidget(TR_WIDGET_REMOVE); @@ -892,11 +1033,23 @@ private: if (IsIntegerValueType(properties.value_type)) { right_sel->SetDisplayedPlane(DPR_VALUE_INT); this->EnableWidget(TR_WIDGET_VALUE_INT); - } else if (properties.value_type == TRVT_DENY) { - right_sel->SetDisplayedPlane(DPR_VALUE_DROPDOWN); - this->EnableWidget(TR_WIDGET_VALUE_DROPDOWN); - this->GetWidget(TR_WIDGET_VALUE_DROPDOWN)->widget_data = - GetTraceRestrictValue(item) ? STR_TRACE_RESTRICT_PF_ALLOW : STR_TRACE_RESTRICT_PF_DENY; + } else { + switch (properties.value_type) { + case TRVT_DENY: + right_sel->SetDisplayedPlane(DPR_VALUE_DROPDOWN); + this->EnableWidget(TR_WIDGET_VALUE_DROPDOWN); + this->GetWidget(TR_WIDGET_VALUE_DROPDOWN)->widget_data = + GetTraceRestrictValue(item) ? STR_TRACE_RESTRICT_PF_ALLOW : STR_TRACE_RESTRICT_PF_DENY; + break; + + case TRVT_ORDER: + right_sel->SetDisplayedPlane(DPR_VALUE_DEST); + this->EnableWidget(TR_WIDGET_VALUE_DEST); + break; + + default: + break; + } } this->EnableWidget(TR_WIDGET_INSERT); @@ -915,12 +1068,12 @@ private: ShowDropDownMenu(this, list_set->string_array, selected, button, disabled_mask, hidden_mask, width); } - void SelectSignalAction(int widget) + void SetObjectToPlaceAction(int widget, CursorID cursor) { this->ToggleWidgetLoweredState(widget); this->SetWidgetDirty(widget); if (this->IsWidgetLowered(widget)) { - SetObjectToPlaceWnd(ANIMCURSOR_BUILDSIGNALS, PAL_NONE, HT_RECT, this); + SetObjectToPlaceWnd(cursor, PAL_NONE, HT_RECT, this); this->current_placement_widget = widget; } else { ResetObjectToPlace(); @@ -940,7 +1093,7 @@ static const NWidgetPart _nested_program_widgets[] = { // Program display NWidget(NWID_HORIZONTAL), - NWidget(WWT_PANEL, COLOUR_GREY, TR_WIDGET_INSTRUCTION_LIST), SetMinimalSize(372, 62), SetDataTip(0x0, STR_TRACE_RESTRICT_SIGNAL_GUI_TOOLTIP), SetResize(1, 1), EndContainer(), + NWidget(WWT_PANEL, COLOUR_GREY, TR_WIDGET_INSTRUCTION_LIST), SetMinimalSize(372, 62), SetDataTip(0x0, STR_TRACE_RESTRICT_INSTRUCTION_LIST_TOOLTIP), SetResize(1, 1), EndContainer(), NWidget(NWID_VSCROLLBAR, COLOUR_GREY, TR_WIDGET_SCROLLBAR), EndContainer(), @@ -964,6 +1117,8 @@ static const NWidgetPart _nested_program_widgets[] = { SetDataTip(STR_BLACK_COMMA, STR_TRACE_RESTRICT_COND_VALUE_TOOLTIP), SetResize(1, 0), NWidget(WWT_DROPDOWN, COLOUR_GREY, TR_WIDGET_VALUE_DROPDOWN), SetMinimalSize(124, 12), SetFill(1, 0), SetDataTip(STR_NULL, STR_TRACE_RESTRICT_COND_VALUE_TOOLTIP), SetResize(1, 0), + NWidget(WWT_TEXTBTN, COLOUR_GREY, TR_WIDGET_VALUE_DEST), SetMinimalSize(124, 12), SetFill(1, 0), + SetDataTip(STR_TRACE_RESTRICT_SELECT_TARGET, STR_TRACE_RESTRICT_SELECT_TARGET), SetResize(1, 0), NWidget(WWT_TEXTBTN, COLOUR_GREY, TR_WIDGET_BLANK_R), SetMinimalSize(124, 12), SetFill(1, 0), SetDataTip(STR_EMPTY, STR_NULL), SetResize(1, 0), EndContainer(), diff --git a/src/waypoint.cpp b/src/waypoint.cpp index 857f8ba874..3e5f02f3c7 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -15,6 +15,7 @@ #include "window_func.h" #include "newgrf_station.h" #include "waypoint_base.h" +#include "tracerestrict.h" #include "safeguards.h" @@ -54,4 +55,5 @@ Waypoint::~Waypoint() if (CleaningPool()) return; DeleteWindowById(WC_WAYPOINT_VIEW, this->index); RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, this->index); + TraceRestrictRemoveDestinationID(TROCAF_WAYPOINT, this->index); }