|
|
|
@ -372,7 +372,7 @@ static bool IsIntegerValueType(TraceRestrictValueType type)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convert integer values between internal units and display units
|
|
|
|
|
* Convert integer values or custom penalty values between internal units and display units
|
|
|
|
|
*/
|
|
|
|
|
static uint ConvertIntegerValue(TraceRestrictValueType type, uint in, bool to_display)
|
|
|
|
|
{
|
|
|
|
@ -385,6 +385,9 @@ static uint ConvertIntegerValue(TraceRestrictValueType type, uint in, bool to_di
|
|
|
|
|
? ConvertSpeedToDisplaySpeed(in) * 10 / 16
|
|
|
|
|
: ConvertDisplaySpeedToSpeed(in) * 16 / 10;
|
|
|
|
|
|
|
|
|
|
case TRVT_PF_PENALTY:
|
|
|
|
|
return in;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
NOT_REACHED();
|
|
|
|
|
return 0;
|
|
|
|
@ -424,6 +427,41 @@ static const TraceRestrictDropDownListSet _condflags_dropdown = {
|
|
|
|
|
_condflags_dropdown_str, _condflags_dropdown_val,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const StringID _pf_penalty_dropdown_str[] = {
|
|
|
|
|
STR_TRACE_RESTRICT_PF_VALUE_SMALL,
|
|
|
|
|
STR_TRACE_RESTRICT_PF_VALUE_MEDIUM,
|
|
|
|
|
STR_TRACE_RESTRICT_PF_VALUE_LARGE,
|
|
|
|
|
STR_TRACE_RESTRICT_PF_VALUE_CUSTOM,
|
|
|
|
|
INVALID_STRING_ID,
|
|
|
|
|
};
|
|
|
|
|
static const uint _pf_penalty_dropdown_val[] = {
|
|
|
|
|
TRPPPI_SMALL,
|
|
|
|
|
TRPPPI_MEDIUM,
|
|
|
|
|
TRPPPI_LARGE,
|
|
|
|
|
TRPPPI_END, // this is a placeholder for "custom"
|
|
|
|
|
};
|
|
|
|
|
/** Pathfinder penalty dropdown set */
|
|
|
|
|
static const TraceRestrictDropDownListSet _pf_penalty_dropdown = {
|
|
|
|
|
_pf_penalty_dropdown_str, _pf_penalty_dropdown_val,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static uint GetPathfinderPenaltyDropdownIndex(TraceRestrictItem item)
|
|
|
|
|
{
|
|
|
|
|
switch (static_cast<TraceRestrictPathfinderPenaltyAuxField>(GetTraceRestrictAuxField(item))) {
|
|
|
|
|
case TRPPAF_VALUE:
|
|
|
|
|
return TRPPPI_END;
|
|
|
|
|
|
|
|
|
|
case TRPPAF_PRESET: {
|
|
|
|
|
uint16 index = GetTraceRestrictValue(item);
|
|
|
|
|
assert(index < TRPPPI_END);
|
|
|
|
|
return index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
NOT_REACHED();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Common function for drawing an ordinary conditional instruction */
|
|
|
|
|
static void DrawInstructionStringConditionalCommon(TraceRestrictItem item, const TraceRestrictTypePropertySet &properties)
|
|
|
|
|
{
|
|
|
|
@ -583,8 +621,23 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TRIT_PF_PENALTY:
|
|
|
|
|
instruction_string = STR_TRACE_RESTRICT_PF_PENALTY_ITEM;
|
|
|
|
|
SetDParam(0, GetTraceRestrictValue(item));
|
|
|
|
|
switch (static_cast<TraceRestrictPathfinderPenaltyAuxField>(GetTraceRestrictAuxField(item))) {
|
|
|
|
|
case TRPPAF_VALUE:
|
|
|
|
|
instruction_string = STR_TRACE_RESTRICT_PF_PENALTY_ITEM;
|
|
|
|
|
SetDParam(0, GetTraceRestrictValue(item));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TRPPAF_PRESET: {
|
|
|
|
|
instruction_string = STR_TRACE_RESTRICT_PF_PENALTY_ITEM_PRESET;
|
|
|
|
|
uint16 index = GetTraceRestrictValue(item);
|
|
|
|
|
assert(index < TRPPPI_END);
|
|
|
|
|
SetDParam(0, _pf_penalty_dropdown_str[index]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
NOT_REACHED();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
@ -775,6 +828,10 @@ public:
|
|
|
|
|
this->ShowDropDownListWithValue(&_direction_value, GetTraceRestrictValue(item), false, TR_WIDGET_VALUE_DROPDOWN, 0, 0, 0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TRVT_PF_PENALTY:
|
|
|
|
|
this->ShowDropDownListWithValue(&_pf_penalty_dropdown, GetPathfinderPenaltyDropdownIndex(item), false, TR_WIDGET_VALUE_DROPDOWN, 0, 0, 0);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -820,7 +877,7 @@ public:
|
|
|
|
|
|
|
|
|
|
TraceRestrictItem item = GetSelected();
|
|
|
|
|
TraceRestrictValueType type = GetTraceRestrictTypeProperties(item).value_type;
|
|
|
|
|
if (!IsIntegerValueType(type)) {
|
|
|
|
|
if (!IsIntegerValueType(type) && type != TRVT_PF_PENALTY) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -831,6 +888,10 @@ public:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type == TRVT_PF_PENALTY) {
|
|
|
|
|
SetTraceRestrictAuxField(item, TRPPAF_VALUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetTraceRestrictValue(item, value);
|
|
|
|
|
TraceRestrictDoCommandP(tile, track, TRDCT_MODIFY_ITEM, this->selected_instruction - 1, item, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM);
|
|
|
|
|
}
|
|
|
|
@ -902,7 +963,24 @@ public:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case TR_WIDGET_VALUE_DROPDOWN: {
|
|
|
|
|
SetTraceRestrictValue(item, value);
|
|
|
|
|
if (GetTraceRestrictTypeProperties(item).value_type == TRVT_PF_PENALTY) {
|
|
|
|
|
if (value == TRPPPI_END) {
|
|
|
|
|
uint16 penalty_value;
|
|
|
|
|
if (GetTraceRestrictAuxField(item) == TRPPAF_PRESET) {
|
|
|
|
|
penalty_value = _tracerestrict_pathfinder_penalty_preset_values[GetTraceRestrictValue(item)];
|
|
|
|
|
} else {
|
|
|
|
|
penalty_value = GetTraceRestrictValue(item);
|
|
|
|
|
}
|
|
|
|
|
SetDParam(0, penalty_value);
|
|
|
|
|
ShowQueryString(STR_JUST_INT, STR_TRACE_RESTRICT_VALUE_CAPTION, 10, this, CS_NUMERAL, QSF_NONE);
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
SetTraceRestrictValue(item, value);
|
|
|
|
|
SetTraceRestrictAuxField(item, TRPPAF_PRESET);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
SetTraceRestrictValue(item, value);
|
|
|
|
|
}
|
|
|
|
|
TraceRestrictDoCommandP(this->tile, this->track, TRDCT_MODIFY_ITEM, this->selected_instruction - 1, item, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -1152,6 +1230,15 @@ public:
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case TR_WIDGET_VALUE_DROPDOWN: {
|
|
|
|
|
TraceRestrictItem item = this->GetSelected();
|
|
|
|
|
if (GetTraceRestrictTypeProperties(item).value_type == TRVT_PF_PENALTY &&
|
|
|
|
|
GetTraceRestrictAuxField(item) == TRPPAF_VALUE) {
|
|
|
|
|
SetDParam(0, GetTraceRestrictValue(item));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1475,6 +1562,17 @@ private:
|
|
|
|
|
this->EnableWidget(TR_WIDGET_VALUE_SIGNAL);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case TRVT_PF_PENALTY:
|
|
|
|
|
right_sel->SetDisplayedPlane(DPR_VALUE_DROPDOWN);
|
|
|
|
|
this->EnableWidget(TR_WIDGET_VALUE_DROPDOWN);
|
|
|
|
|
if (GetTraceRestrictAuxField(item) == TRPPAF_VALUE) {
|
|
|
|
|
this->GetWidget<NWidgetCore>(TR_WIDGET_VALUE_DROPDOWN)->widget_data = STR_BLACK_COMMA;
|
|
|
|
|
} else {
|
|
|
|
|
this->GetWidget<NWidgetCore>(TR_WIDGET_VALUE_DROPDOWN)->widget_data =
|
|
|
|
|
GetDropDownStringByValue(&_pf_penalty_dropdown, GetPathfinderPenaltyDropdownIndex(item));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|