From 270a748b6438a881d6dfc4ab7a5e871787685aae Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 27 Nov 2020 18:43:32 +0000 Subject: [PATCH] Tracerestrict: Add time/date conditional --- src/lang/english.txt | 13 ++++++ src/saveload/extended_ver_sl.cpp | 1 + src/saveload/extended_ver_sl.h | 1 + src/strings.cpp | 14 +++++++ src/table/control_codes.h | 2 + src/table/strgen_tables.h | 2 + src/tracerestrict.cpp | 31 ++++++++++++++ src/tracerestrict.h | 19 ++++++++- src/tracerestrict_gui.cpp | 70 +++++++++++++++++++++++++++----- 9 files changed, 142 insertions(+), 11 deletions(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index 62c9251a9d..a4139834a5 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -2751,6 +2751,7 @@ STR_TRACE_RESTRICT_VARIABLE_SLOT_OCCUPANCY_REMAINING :slot occupancy STR_TRACE_RESTRICT_VARIABLE_SLOT_OCCUPANCY_SHORT :occupancy STR_TRACE_RESTRICT_VARIABLE_SLOT_OCCUPANCY_REMAINING_SHORT :occupancy remaining STR_TRACE_RESTRICT_VARIABLE_COUNTER_VALUE :counter value +STR_TRACE_RESTRICT_VARIABLE_TIME_DATE_VALUE :current time/date STR_TRACE_RESTRICT_VARIABLE_TRAIN_WEIGHT :weight STR_TRACE_RESTRICT_VARIABLE_TRAIN_POWER :power STR_TRACE_RESTRICT_VARIABLE_TRAIN_MAX_TE :max T.E. @@ -2767,6 +2768,7 @@ STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_POWER :{STRING} {STRIN STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_FORCE :{STRING} {STRING} {STRING} {FORCE} then STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_POWER_WEIGHT_RATIO :{STRING} {STRING} {STRING} {POWER_WEIGHT_RATIO} then STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_FORCE_WEIGHT_RATIO :{STRING} {STRING} {STRING} {FORCE_WEIGHT_RATIO} then +STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_TIME_HHMM :{STRING} {STRING} {STRING} {TIME_HHMM} 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 @@ -2865,6 +2867,15 @@ STR_TRACE_RESTRICT_TRAIN_NOT_STUCK :Train is not st STR_TRACE_RESTRICT_TRAIN_NOT_STUCK_CANCEL :Cancel train is not stuck, do not show news reports about waiting at this PBS signal STR_TRACE_RESTRICT_TRAIN_NOT_STUCK_SHORT :Train is not stuck... STR_TRACE_RESTRICT_TRAIN_NOT_STUCK_CANCEL_SHORT :Cancel train is not stuck... +STR_TRACE_RESTRICT_TIME_MINUTE :current minute (0 - 59) +STR_TRACE_RESTRICT_TIME_HOUR :current hour (0 - 23) +STR_TRACE_RESTRICT_TIME_HOUR_MINUTE :current hour and minute (0 - 2359) +STR_TRACE_RESTRICT_TIME_MINUTE_ITEM :current minute +STR_TRACE_RESTRICT_TIME_HOUR_ITEM :current hour +STR_TRACE_RESTRICT_TIME_HOUR_MINUTE_ITEM :current hour and minute +STR_TRACE_RESTRICT_TIME_MINUTE_SHORT :minute +STR_TRACE_RESTRICT_TIME_HOUR_SHORT :hour +STR_TRACE_RESTRICT_TIME_HOUR_MINUTE_SHORT :hour and minute STR_TRACE_RESTRICT_VALUE_CAPTION :{WHITE}Value STR_TRACE_RESTRICT_CAPTION :{WHITE}Routefinding restriction STR_TRACE_RESTRICT_CAPTION_SHARED :{WHITE}Routefinding restriction - shared by {COMMA} signals @@ -6198,6 +6209,7 @@ STR_JUST_DATE_WALLCLOCK_TINY :{DATE_WALLCLOCK STR_JUST_DATE_WALLCLOCK_SHORT :{DATE_WALLCLOCK_SHORT} STR_JUST_DATE_WALLCLOCK_LONG :{DATE_WALLCLOCK_LONG} STR_JUST_DATE_WALLCLOCK_ISO :{DATE_WALLCLOCK_ISO} +STR_JUST_TIME_HHMM :{TIME_HHMM} STR_JUST_STRING :{STRING} STR_JUST_STRING1 :{STRING1} STR_JUST_STRING2 :{STRING2} @@ -6221,6 +6233,7 @@ STR_WHITE_DATE_WALLCLOCK_LONG :{WHITE}{DATE_WA STR_WHITE_DATE_WALLCLOCK_SHORT :{WHITE}{DATE_WALLCLOCK_SHORT} STR_SHORT_DATE :{WHITE}{DATE_TINY} STR_DATE_LONG_SMALL :{TINY_FONT}{BLACK}{DATE_LONG} +STR_BLACK_TIME_HHMM :{BLACK}{TIME_HHMM} STR_TINY_GROUP :{TINY_FONT}{GROUP} STR_BLACK_INT :{BLACK}{NUM} STR_ORANGE_INT :{ORANGE}{NUM} diff --git a/src/saveload/extended_ver_sl.cpp b/src/saveload/extended_ver_sl.cpp index 1009625221..f6192b0528 100644 --- a/src/saveload/extended_ver_sl.cpp +++ b/src/saveload/extended_ver_sl.cpp @@ -75,6 +75,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = { { XSLFI_TRACE_RESTRICT_REVERSE, XSCF_NULL, 1, 1, "tracerestrict_reverse", nullptr, nullptr, nullptr }, { XSLFI_TRACE_RESTRICT_NEWSCTRL,XSCF_NULL, 1, 1, "tracerestrict_newsctrl", nullptr, nullptr, nullptr }, { XSLFI_TRACE_RESTRICT_COUNTER, XSCF_NULL, 1, 1, "tracerestrict_counter", nullptr, nullptr, "TRRC" }, + { XSLFI_TRACE_RESTRICT_TIMEDATE,XSCF_NULL, 1, 1, "tracerestrict_timedate", nullptr, nullptr, nullptr }, { XSLFI_PROG_SIGS, XSCF_NULL, 2, 2, "programmable_signals", nullptr, nullptr, "SPRG" }, { XSLFI_ADJACENT_CROSSINGS, XSCF_NULL, 1, 1, "adjacent_crossings", nullptr, nullptr, nullptr }, { XSLFI_SAFER_CROSSINGS, XSCF_NULL, 1, 1, "safer_crossings", nullptr, nullptr, nullptr }, diff --git a/src/saveload/extended_ver_sl.h b/src/saveload/extended_ver_sl.h index d04e31daf4..51c0634a7c 100644 --- a/src/saveload/extended_ver_sl.h +++ b/src/saveload/extended_ver_sl.h @@ -29,6 +29,7 @@ enum SlXvFeatureIndex { XSLFI_TRACE_RESTRICT_REVERSE, ///< Trace restrict: reverse XSLFI_TRACE_RESTRICT_NEWSCTRL, ///< Trace restrict: news control XSLFI_TRACE_RESTRICT_COUNTER, ///< Trace restrict: counters + XSLFI_TRACE_RESTRICT_TIMEDATE, ///< Trace restrict: time/date XSLFI_PROG_SIGS, ///< programmable pre-signals patch XSLFI_ADJACENT_CROSSINGS, ///< Adjacent level crossings closure patch XSLFI_SAFER_CROSSINGS, ///< Safer level crossings diff --git a/src/strings.cpp b/src/strings.cpp index 9d9901d50e..df4c7d2622 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -436,6 +436,16 @@ static char *FormatWallClockString(char *buff, DateTicksScaled ticks, const char } } +static char *FormatTimeHHMMString(char *buff, uint time, const char *last, uint case_index) +{ + char hour[9], minute[3]; + seprintf(hour, lastof(hour), "%02i", (int) time / 100); + seprintf(minute, lastof(minute), "%02i", (int) time % 100); + int64 args[2] = { (int64)hour, (int64)minute }; + StringParameters tmp_params(args); + return FormatString(buff, GetStringPtr(STR_FORMAT_DATE_MINUTES), &tmp_params, last, case_index); +} + static char *FormatYmdString(char *buff, Date date, const char *last, uint case_index) { YearMonthDay ymd; @@ -1463,6 +1473,10 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg buff = FormatTinyOrISODate(buff, args->GetInt32(), STR_FORMAT_DATE_ISO, last); break; + case SCC_TIME_HHMM: // {TIME_HHMM} + buff = FormatTimeHHMMString(buff, args->GetInt64(SCC_TIME_HHMM), last, next_substr_case_index); + break; + case SCC_FORCE: { // {FORCE} assert(_settings_game.locale.units_force < lengthof(_units_force)); int64 args_array[1] = {_units_force[_settings_game.locale.units_force].c.ToDisplay(args->GetInt64())}; diff --git a/src/table/control_codes.h b/src/table/control_codes.h index be5e00a555..5c7fb0f055 100644 --- a/src/table/control_codes.h +++ b/src/table/control_codes.h @@ -78,6 +78,8 @@ enum StringControlCode { SCC_DATE_WALLCLOCK_LONG, SCC_DATE_WALLCLOCK_ISO, + SCC_TIME_HHMM, + /* Must be consecutive */ SCC_STRING1, SCC_STRING2, diff --git a/src/table/strgen_tables.h b/src/table/strgen_tables.h index a3a841641e..e0fffb88a1 100644 --- a/src/table/strgen_tables.h +++ b/src/table/strgen_tables.h @@ -100,6 +100,8 @@ static const CmdStruct _cmd_structs[] = { {"DATE_WALLCLOCK_LONG", EmitSingleChar, SCC_DATE_WALLCLOCK_LONG, 1, -1, C_NONE}, {"DATE_WALLCLOCK_ISO", EmitSingleChar, SCC_DATE_WALLCLOCK_ISO, 1, -1, C_NONE}, + {"TIME_HHMM", EmitSingleChar, SCC_TIME_HHMM, 1, -1, C_NONE}, + {"STRING", EmitSingleChar, SCC_STRING, 1, -1, C_CASE | C_GENDER}, {"RAW_STRING", EmitSingleChar, SCC_RAW_STRING_POINTER, 1, -1, C_NONE | C_GENDER}, diff --git a/src/tracerestrict.cpp b/src/tracerestrict.cpp index 9c8c98eb86..b0366ea4c8 100644 --- a/src/tracerestrict.cpp +++ b/src/tracerestrict.cpp @@ -23,6 +23,7 @@ #include "pathfinder/yapf/yapf_cache.h" #include "scope_info.h" #include "vehicle_func.h" +#include "date_func.h" #include #include @@ -511,6 +512,14 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp break; } + case TRIT_COND_TIME_DATE_VALUE: { + // TRVT_TIME_DATE_INT value type uses the next slot + i++; + uint32_t value = this->items[i]; + result = TestCondition(GetTraceRestrictTimeDateValue(static_cast(GetTraceRestrictValue(item))), condop, value); + break; + } + default: NOT_REACHED(); } @@ -793,6 +802,7 @@ CommandCost TraceRestrictProgram::Validate(const std::vector case TRIT_COND_TRAIN_STATUS: case TRIT_COND_LOAD_PERCENT: case TRIT_COND_COUNTER_VALUE: + case TRIT_COND_TIME_DATE_VALUE: break; default: @@ -943,6 +953,7 @@ void SetTraceRestrictValueDefault(TraceRestrictItem &item, TraceRestrictValueTyp case TRVT_REVERSE: case TRVT_PERCENT: case TRVT_NEWS_CONTROL: + case TRVT_TIME_DATE_INT: SetTraceRestrictValue(item, 0); if (!IsTraceRestrictTypeAuxSubtype(GetTraceRestrictType(item))) { SetTraceRestrictAuxField(item, 0); @@ -1198,6 +1209,7 @@ static uint32 GetDualInstructionInitialValue(TraceRestrictItem item) case TRIT_COND_SLOT_OCCUPANCY: case TRIT_COND_COUNTER_VALUE: + case TRIT_COND_TIME_DATE_VALUE: return 0; case TRIT_COUNTER: @@ -1617,6 +1629,25 @@ CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag return CommandCost(); } +int GetTraceRestrictTimeDateValue(TraceRestrictTimeDateValueField type) +{ + Minutes minutes = (_scaled_date_ticks / _settings_game.game_time.ticks_per_minute) + _settings_game.game_time.clock_offset; + + switch (type) { + case TRTDVF_MINUTE: + return MINUTES_MINUTE(minutes); + + case TRTDVF_HOUR: + return MINUTES_HOUR(minutes); + + case TRTDVF_HOUR_MINUTE: + return (MINUTES_HOUR(minutes) * 100) + MINUTES_MINUTE(minutes); + + default: + return 0; + } +} + /** * This is called when a station, waypoint or depot is about to be deleted * Scan program pool and change any references to it to the invalid station ID, to avoid dangling references diff --git a/src/tracerestrict.h b/src/tracerestrict.h index 53de3b3b49..5c803a3689 100644 --- a/src/tracerestrict.h +++ b/src/tracerestrict.h @@ -150,6 +150,7 @@ enum TraceRestrictItemType { TRIT_COND_TRAIN_STATUS = 25, ///< Test train status TRIT_COND_LOAD_PERCENT = 26, ///< Test train load percentage TRIT_COND_COUNTER_VALUE = 27, ///< Test counter value + TRIT_COND_TIME_DATE_VALUE = 28, ///< Test time/date value TRIT_COND_END = 48, ///< End (exclusive) of conditional item types, note that this has the same value as TRIT_REVERSE TRIT_REVERSE = 48, ///< Reverse behind signal @@ -286,6 +287,15 @@ enum TraceRestrictTrainStatusValueField { TRTSVF_REQUIRES_SERVICE = 10, ///< Train requires service }; +/** + * TraceRestrictItem value field, for TRIT_COND_TIME_DATE_VALUE + */ +enum TraceRestrictTimeDateValueField { + TRTDVF_MINUTE = 0, ///< Minute + TRTDVF_HOUR = 1, ///< Hour + TRTDVF_HOUR_MINUTE = 2, ///< Hour and minute +}; + /** * TraceRestrictItem repurposed condition operator field, for slot operation type actions */ @@ -554,7 +564,7 @@ static inline bool IsTraceRestrictConditional(TraceRestrictItem item) static inline bool IsTraceRestrictDoubleItem(TraceRestrictItem item) { const TraceRestrictItemType type = GetTraceRestrictType(item); - return type == TRIT_COND_PBS_ENTRY_SIGNAL || type == TRIT_COND_SLOT_OCCUPANCY || type == TRIT_COUNTER || type == TRIT_COND_COUNTER_VALUE; + return type == TRIT_COND_PBS_ENTRY_SIGNAL || type == TRIT_COND_SLOT_OCCUPANCY || type == TRIT_COUNTER || type == TRIT_COND_COUNTER_VALUE || type == TRIT_COND_TIME_DATE_VALUE; } /** @@ -599,6 +609,7 @@ enum TraceRestrictValueType { TRVT_REVERSE = 42,///< takes a TraceRestrictReverseValueField TRVT_NEWS_CONTROL = 43,///< takes a TraceRestrictNewsControlField TRVT_COUNTER_INDEX_INT = 44,///< takes a TraceRestrictCounterID, and an integer in the next item slot + TRVT_TIME_DATE_INT = 45,///< takes a TraceRestrictTimeDateValueField, and an integer in the next item slot }; /** @@ -728,6 +739,10 @@ static inline TraceRestrictTypePropertySet GetTraceRestrictTypeProperties(TraceR out.value_type = TRVT_COUNTER_INDEX_INT; break; + case TRIT_COND_TIME_DATE_VALUE: + out.value_type = TRVT_TIME_DATE_INT; + break; + default: NOT_REACHED(); break; @@ -853,6 +868,8 @@ CommandCost TraceRestrictProgramMoveItemAt(std::vector &items void ShowTraceRestrictProgramWindow(TileIndex tile, Track track); +int GetTraceRestrictTimeDateValue(TraceRestrictTimeDateValueField type); + void TraceRestrictRemoveDestinationID(TraceRestrictOrderCondAuxField type, uint16 index); void TraceRestrictRemoveGroupID(GroupID index); void TraceRestrictUpdateCompanyID(CompanyID old_company, CompanyID new_company); diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index c345c2cc21..95adabb97f 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -339,6 +339,23 @@ static const TraceRestrictDropDownListSet _news_control_value = { _news_control_value_str, _news_control_value_val, }; +static const StringID _time_date_value_str[] = { + STR_TRACE_RESTRICT_TIME_MINUTE, + STR_TRACE_RESTRICT_TIME_HOUR, + STR_TRACE_RESTRICT_TIME_HOUR_MINUTE, + INVALID_STRING_ID +}; +static const uint _time_date_value_val[] = { + TRTDVF_MINUTE, + TRTDVF_HOUR, + TRTDVF_HOUR_MINUTE, +}; + +/** value drop down list for time/date types strings and values */ +static const TraceRestrictDropDownListSet _time_date_value = { + _time_date_value_str, _time_date_value_val, +}; + /** * Get index of @p value in @p list_set * if @p value is not present, assert if @p missing_ok is false, otherwise return -1 @@ -439,6 +456,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG STR_TRACE_RESTRICT_VARIABLE_SLOT_OCCUPANCY, STR_TRACE_RESTRICT_VARIABLE_SLOT_OCCUPANCY_REMAINING, STR_TRACE_RESTRICT_VARIABLE_COUNTER_VALUE, + STR_TRACE_RESTRICT_VARIABLE_TIME_DATE_VALUE, STR_TRACE_RESTRICT_VARIABLE_UNDEFINED, INVALID_STRING_ID, }; @@ -464,6 +482,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG TRIT_COND_SLOT_OCCUPANCY | (TRSOCAF_OCCUPANTS << 16), TRIT_COND_SLOT_OCCUPANCY | (TRSOCAF_REMAINING << 16), TRIT_COND_COUNTER_VALUE, + TRIT_COND_TIME_DATE_VALUE, TRIT_COND_UNDEFINED, }; static const TraceRestrictDropDownListSet set_cond = { @@ -475,8 +494,9 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG if (_settings_client.gui.show_adv_tracerestrict_features) { *hide_mask = 0; } else { - *hide_mask = is_conditional ? 0x1E0000 : 0x2F0; + *hide_mask = is_conditional ? 0x3E0000 : 0x2F0; } + if (is_conditional && !_settings_game.game_time.time_in_minutes) *hide_mask |= 0x200000; } return is_conditional ? &set_cond : &set_action; } @@ -1200,6 +1220,18 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric break; } + case TRVT_TIME_DATE_INT: { + assert(prog != nullptr); + assert(GetTraceRestrictType(item) == TRIT_COND_TIME_DATE_VALUE); + uint32 value = *(TraceRestrictProgram::InstructionAt(prog->items, index - 1) + 1); + SetDParam(0, _program_cond_type[GetTraceRestrictCondFlags(item)]); + instruction_string = GetTraceRestrictValue(item) == TRTDVF_HOUR_MINUTE ? STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_TIME_HHMM : STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_INTEGER; + SetDParam(1, STR_TRACE_RESTRICT_TIME_MINUTE_ITEM + GetTraceRestrictValue(item)); + SetDParam(2, GetDropDownStringByValue(GetCondOpDropDownListSet(properties), GetTraceRestrictCondOp(item))); + SetDParam(3, value); + break; + } + default: NOT_REACHED(); break; @@ -1617,7 +1649,7 @@ public: if (IsIntegerValueType(type)) { SetDParam(0, ConvertIntegerValue(type, GetTraceRestrictValue(item), true)); ShowQueryString(STR_JUST_INT, STR_TRACE_RESTRICT_VALUE_CAPTION, 10, this, CS_NUMERAL, QSF_NONE); - } else if (type == TRVT_SLOT_INDEX_INT || type == TRVT_COUNTER_INDEX_INT) { + } else if (type == TRVT_SLOT_INDEX_INT || type == TRVT_COUNTER_INDEX_INT || type == TRVT_TIME_DATE_INT) { SetDParam(0, *(TraceRestrictProgram::InstructionAt(this->GetProgram()->items, this->selected_instruction - 1) + 1)); ShowQueryString(STR_JUST_INT, STR_TRACE_RESTRICT_VALUE_CAPTION, 10, this, CS_NUMERAL, QSF_NONE); } @@ -1724,6 +1756,11 @@ public: break; } + case TRVT_TIME_DATE_INT: { + this->ShowDropDownListWithValue(&_time_date_value, GetTraceRestrictValue(item), false, TR_WIDGET_LEFT_AUX_DROPDOWN, 0, 0, UINT_MAX); + break; + } + default: break; } @@ -1799,7 +1836,7 @@ public: ShowErrorMessage(STR_TRACE_RESTRICT_ERROR_VALUE_TOO_LARGE, STR_EMPTY, WL_INFO); return; } - } else if (type == TRVT_SLOT_INDEX_INT || type == TRVT_COUNTER_INDEX_INT) { + } else if (type == TRVT_SLOT_INDEX_INT || type == TRVT_COUNTER_INDEX_INT || type == TRVT_TIME_DATE_INT) { value = atoi(str); TraceRestrictDoCommandP(this->tile, this->track, TRDCT_MODIFY_DUAL_ITEM, this->selected_instruction - 1, value, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM); return; @@ -1820,7 +1857,7 @@ public: if (widget == TR_WIDGET_VALUE_DROPDOWN || widget == TR_WIDGET_LEFT_AUX_DROPDOWN) { TraceRestrictTypePropertySet type = GetTraceRestrictTypeProperties(item); - if (this->value_drop_down_is_company || type.value_type == TRVT_GROUP_INDEX || type.value_type == TRVT_SLOT_INDEX || type.value_type == TRVT_SLOT_INDEX_INT || type.value_type == TRVT_COUNTER_INDEX_INT) { + if (this->value_drop_down_is_company || type.value_type == TRVT_GROUP_INDEX || type.value_type == TRVT_SLOT_INDEX || type.value_type == TRVT_SLOT_INDEX_INT || type.value_type == TRVT_COUNTER_INDEX_INT || type.value_type == TRVT_TIME_DATE_INT) { // this is a special company drop-down or group/slot-index drop-down SetTraceRestrictValue(item, index); TraceRestrictDoCommandP(this->tile, this->track, TRDCT_MODIFY_ITEM, this->selected_instruction - 1, item, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM); @@ -2148,13 +2185,17 @@ public: { switch (widget) { case TR_WIDGET_VALUE_INT: { - SetDParam(0, 0); + SetDParam(0, STR_BLACK_COMMA); TraceRestrictItem item = this->GetSelected(); TraceRestrictValueType type = GetTraceRestrictTypeProperties(item).value_type; + if (type == TRVT_TIME_DATE_INT && GetTraceRestrictValue(item) == TRTDVF_HOUR_MINUTE) { + SetDParam(0, STR_BLACK_TIME_HHMM); + } + SetDParam(1, 0); if (IsIntegerValueType(type)) { - SetDParam(0, ConvertIntegerValue(type, GetTraceRestrictValue(item), true)); - } else if (type == TRVT_SLOT_INDEX_INT || type == TRVT_COUNTER_INDEX_INT) { - SetDParam(0, *(TraceRestrictProgram::InstructionAt(this->GetProgram()->items, this->selected_instruction - 1) + 1)); + SetDParam(1, ConvertIntegerValue(type, GetTraceRestrictValue(item), true)); + } else if (type == TRVT_SLOT_INDEX_INT || type == TRVT_COUNTER_INDEX_INT || type == TRVT_TIME_DATE_INT) { + SetDParam(1, *(TraceRestrictProgram::InstructionAt(this->GetProgram()->items, this->selected_instruction - 1) + 1)); } break; } @@ -2198,7 +2239,7 @@ public: case TR_WIDGET_LEFT_AUX_DROPDOWN: { TraceRestrictItem item = this->GetSelected(); TraceRestrictTypePropertySet type = GetTraceRestrictTypeProperties(item); - if (type.value_type == TRVT_SLOT_INDEX_INT || type.value_type == TRVT_COUNTER_INDEX_INT) { + if (type.value_type == TRVT_SLOT_INDEX_INT || type.value_type == TRVT_COUNTER_INDEX_INT || type.value_type == TRVT_TIME_DATE_INT) { SetDParam(0, GetTraceRestrictValue(item)); } break; @@ -2738,6 +2779,15 @@ private: break; } + case TRVT_TIME_DATE_INT: { + right_sel->SetDisplayedPlane(DPR_VALUE_INT); + left_aux_sel->SetDisplayedPlane(DPLA_DROPDOWN); + this->EnableWidget(TR_WIDGET_VALUE_INT); + this->EnableWidget(TR_WIDGET_LEFT_AUX_DROPDOWN); + this->GetWidget(TR_WIDGET_LEFT_AUX_DROPDOWN)->widget_data = STR_TRACE_RESTRICT_TIME_MINUTE_SHORT + GetTraceRestrictValue(item); + break; + } + default: break; } @@ -2909,7 +2959,7 @@ static const NWidgetPart _nested_program_widgets[] = { EndContainer(), NWidget(NWID_SELECTION, INVALID_COLOUR, TR_WIDGET_SEL_TOP_RIGHT), NWidget(WWT_TEXTBTN, COLOUR_GREY, TR_WIDGET_VALUE_INT), SetMinimalSize(124, 12), SetFill(1, 0), - SetDataTip(STR_BLACK_COMMA, STR_TRACE_RESTRICT_COND_VALUE_TOOLTIP), SetResize(1, 0), + SetDataTip(STR_JUST_STRING1, STR_TRACE_RESTRICT_COND_VALUE_TOOLTIP), SetResize(1, 0), NWidget(WWT_TEXTBTN, COLOUR_GREY, TR_WIDGET_VALUE_DECIMAL), SetMinimalSize(124, 12), SetFill(1, 0), SetDataTip(STR_BLACK_DECIMAL, STR_TRACE_RESTRICT_COND_VALUE_TOOLTIP), SetResize(1, 0), NWidget(WWT_DROPDOWN, COLOUR_GREY, TR_WIDGET_VALUE_DROPDOWN), SetMinimalSize(124, 12), SetFill(1, 0),