Tracerestrict GUI: Refactor string handling for realistic braking warning
This commit is contained in:
@@ -3242,7 +3242,6 @@ STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL :PBS entry signa
|
||||
STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL_LONG :entered signal of PBS block
|
||||
STR_TRACE_RESTRICT_VARIABLE_PBS_RES_END_SIGNAL :PBS end signal
|
||||
STR_TRACE_RESTRICT_VARIABLE_PBS_RES_END_SIGNAL_LONG :signal at current end of PBS reservation
|
||||
STR_TRACE_RESTRICT_VARIABLE_PBS_RES_END_SIGNAL_LONG_WARN :signal at current end of PBS reservation {PUSH_COLOUR}{RED}(requires realistic braking){POP_COLOUR}
|
||||
STR_TRACE_RESTRICT_VARIABLE_TRAIN_GROUP :train group
|
||||
STR_TRACE_RESTRICT_VARIABLE_TRAIN_SLOT :train in slot
|
||||
STR_TRACE_RESTRICT_VARIABLE_SLOT_OCCUPANCY :slot occupancy
|
||||
@@ -3461,6 +3460,7 @@ STR_TRACE_RESTRICT_UNSHARE_TOOLTIP :{BLACK}Stop sha
|
||||
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_HIGHLIGHT_TOOLTIP :{BLACK}Toggle highlighting all signals sharing this program
|
||||
STR_TRACE_RESTRICT_WARNING_REQUIRES_REALISTIC_BRAKING :{STRING} {PUSH_COLOUR}{RED}(requires realistic braking){POP_COLOUR}
|
||||
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
|
||||
|
@@ -1207,18 +1207,28 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric
|
||||
SetDParam(3, TileX(tile));
|
||||
SetDParam(4, TileY(tile));
|
||||
}
|
||||
auto insert_warning = [&](StringID warning) {
|
||||
char buf[256];
|
||||
int64 args_array[] = { (int64)GetDParam(1) };
|
||||
StringParameters tmp_params(args_array);
|
||||
char *end = GetStringWithArgs(buf, warning, &tmp_params, lastof(buf));
|
||||
_temp_special_strings[0].assign(buf, end);
|
||||
SetDParam(1, SPECSTR_TEMP_START);
|
||||
};
|
||||
switch (static_cast<TraceRestrictPBSEntrySignalAuxField>(GetTraceRestrictAuxField(item))) {
|
||||
case TRPESAF_VEH_POS:
|
||||
SetDParam(1, STR_TRACE_RESTRICT_VARIABLE_PBS_ENTRY_SIGNAL_LONG);
|
||||
break;
|
||||
|
||||
case TRPESAF_RES_END:
|
||||
SetDParam(1, _settings_game.vehicle.train_braking_model == TBM_REALISTIC ? STR_TRACE_RESTRICT_VARIABLE_PBS_RES_END_SIGNAL_LONG : STR_TRACE_RESTRICT_VARIABLE_PBS_RES_END_SIGNAL_LONG_WARN);
|
||||
SetDParam(1, STR_TRACE_RESTRICT_VARIABLE_PBS_RES_END_SIGNAL_LONG);
|
||||
if (_settings_game.vehicle.train_braking_model != TBM_REALISTIC) insert_warning(STR_TRACE_RESTRICT_WARNING_REQUIRES_REALISTIC_BRAKING);
|
||||
break;
|
||||
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user