Initial implementation of tracerestrict speed restriction feature

This commit is contained in:
Jonathan G Rennison
2019-12-05 18:34:05 +00:00
parent 030e8bf762
commit aa8aae9a62
14 changed files with 182 additions and 6 deletions

View File

@@ -151,6 +151,7 @@ static const StringID _program_insert_str[] = {
STR_TRACE_RESTRICT_WAIT_AT_PBS,
STR_TRACE_RESTRICT_SLOT_OP,
STR_TRACE_RESTRICT_REVERSE,
STR_TRACE_RESTRICT_SPEED_RESTRICTION,
INVALID_STRING_ID
};
static const uint32 _program_insert_else_hide_mask = 8; ///< disable bitmask for else
@@ -159,6 +160,7 @@ static const uint32 _program_insert_else_if_hide_mask = 2; ///< disable bitm
static const uint32 _program_wait_pbs_hide_mask = 0x100; ///< disable bitmask for wait at PBS
static const uint32 _program_slot_hide_mask = 0x200; ///< disable bitmask for slot
static const uint32 _program_reverse_hide_mask = 0x400; ///< disable bitmask for reverse
static const uint32 _program_speed_res_hide_mask = 0x800; ///< disable bitmask for speed restriction
static const uint _program_insert_val[] = {
TRIT_COND_UNDEFINED, // if block
TRIT_COND_UNDEFINED | (TRCF_ELSE << 16), // elif block
@@ -171,6 +173,7 @@ static const uint _program_insert_val[] = {
TRIT_WAIT_AT_PBS, // wait at PBS signal
TRIT_SLOT, // slot operation
TRIT_REVERSE, // reverse
TRIT_SPEED_RESTRICTION, // speed restriction
};
/** insert drop down list strings and values */
@@ -370,6 +373,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG
STR_TRACE_RESTRICT_WAIT_AT_PBS,
STR_TRACE_RESTRICT_SLOT_OP,
STR_TRACE_RESTRICT_REVERSE,
STR_TRACE_RESTRICT_SPEED_RESTRICTION,
INVALID_STRING_ID,
};
static const uint val_action[] = {
@@ -380,6 +384,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG
TRIT_WAIT_AT_PBS,
TRIT_SLOT,
TRIT_REVERSE,
TRIT_SPEED_RESTRICTION,
};
static const TraceRestrictDropDownListSet set_action = {
str_action, val_action,
@@ -441,7 +446,7 @@ static const TraceRestrictDropDownListSet *GetTypeDropDownListSet(TraceRestrictG
if (_settings_client.gui.show_adv_tracerestrict_features) {
*hide_mask = 0;
} else {
*hide_mask = is_conditional ? 0xE0000 : 0x70;
*hide_mask = is_conditional ? 0xE0000 : 0xF0;
}
}
return is_conditional ? &set_cond : &set_action;
@@ -1230,6 +1235,15 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric
}
break;
case TRIT_SPEED_RESTRICTION:
if (GetTraceRestrictValue(item) != 0) {
SetDParam(0, GetTraceRestrictValue(item));
instruction_string = STR_TRACE_RESTRICT_SET_SPEED_RESTRICTION;
} else {
instruction_string = STR_TRACE_RESTRICT_REMOVE_SPEED_RESTRICTION;
}
break;
default:
NOT_REACHED();
break;
@@ -1353,7 +1367,7 @@ public:
if (ElseIfInsertionDryRun(false)) disabled &= ~_program_insert_or_if_hide_mask;
}
}
if (!_settings_client.gui.show_adv_tracerestrict_features) hidden |= _program_slot_hide_mask | _program_wait_pbs_hide_mask | _program_reverse_hide_mask;
if (!_settings_client.gui.show_adv_tracerestrict_features) hidden |= _program_slot_hide_mask | _program_wait_pbs_hide_mask | _program_reverse_hide_mask | _program_speed_res_hide_mask;
this->ShowDropDownListWithValue(&_program_insert, 0, true, TR_WIDGET_INSERT, disabled, hidden, 0);
break;