17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-31 05:20:52 +01:00

feat(editor): a block signal template knows its aspects, 4 where its events give S3, the green light flashing with the next signal at S5, else 3; one step of the signalling takes includes away too, the signals among them with their read events, Ctrl+Z bringing them back with the rest of it

This commit is contained in:
maj00r
2026-10-22 19:26:25 +02:00
parent fc0b9b46e8
commit b92d1283ac
5 changed files with 50 additions and 2 deletions

View File

@@ -537,6 +537,25 @@ bool signal_speeds(std::string const &File, std::vector<int> &Speeds)
return true;
}
int block_aspects(std::string const &File)
{
template_text text;
std::string error;
if (false == read_template(File, text, error))
{
return 0;
}
auto const tokens{tokenize(text.content)};
for (std::size_t idx = 0; idx + 1 < tokens.size(); ++idx)
{
if (tokens[idx] == "event" && tokens[idx + 1].size() > 3 && tokens[idx + 1].ends_with("_s3"))
{
return 4;
}
}
return 3;
}
void suggest(std::string const &File, include_info &Info)
{
template_text text;

View File

@@ -71,6 +71,9 @@ int parameter_count(std::string const &File);
// the speeds the events of a signal template set it to show, by their SetVelocity: of the signal itself, km/h, -1 the highest
// allowed, 20 the substitute signal. returns: false if the file can't be read
bool signal_speeds(std::string const &File, std::vector<int> &Speeds);
// the aspects of a block signal of the template: 4 where its events give S3, the green light flashing with the next signal at S5,
// the warning two signals ahead, else 3. returns: 0 if the file can't be read
int block_aspects(std::string const &File);
// sets roles of the parameters whose use in the template makes their meaning clear. roles already set are left alone
void suggest(std::string const &File, include_info &Info);
// true if value of a parameter with specified role is supplied by the editor when the template is placed