17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-09 08:00:04 +01:00

feat(editor): what the editor refuses shows by the mouse cursor

An error put in the status bar also shows for 4 s by the cursor, and the
refusals the tools kept in their panels (a curve which can't be laid,
a switch which doesn't fit, a signal which can't be moved, a drive
without the variant) go there as well.
This commit is contained in:
maj00r
2026-10-21 11:47:26 +02:00
parent 9d27fd1ace
commit da18883558
9 changed files with 70 additions and 27 deletions

View File

@@ -193,7 +193,7 @@ bool editor_mode::place_switch_drive(TTrack &Switch)
item.file = family.files[index];
if (item.file.empty())
{
tool.status = missing_drive_variant(tool.drive, spot->rightswitch, driveright);
tool.status = refused(missing_drive_variant(tool.drive, spot->rightswitch, driveright));
return false;
}
item.location = spot->location + glm::dvec3{0.0, family.heights[index], 0.0};
@@ -206,7 +206,7 @@ bool editor_mode::place_switch_drive(TTrack &Switch)
std::string error;
if (place_templates({item}, error) == 0)
{
tool.status = STR_C("The drive couldn't be placed: ") + error;
tool.status = refused(STR_C("The drive couldn't be placed: ") + error);
return false;
}
tool.status = format(STR_C("Switch %s with the drive %s: events %s+ and %s- switch it, also in the map"), Switch.name().c_str(), item.file.c_str(), Switch.name().c_str(), Switch.name().c_str());
@@ -253,7 +253,7 @@ bool editor_mode::replace_switch_drive(TTrack &Switch, int const Family, bool co
auto const present{find_switch_drive(Switch)};
if (false == present.has_value())
{
tool.status = format(STR_C("No drive of the switch %s among the described drives"), Switch.name().c_str());
tool.status = refused(format(STR_C("No drive of the switch %s among the described drives"), Switch.name().c_str()));
return false;
}
auto const &found{present->standing};
@@ -263,7 +263,7 @@ bool editor_mode::replace_switch_drive(TTrack &Switch, int const Family, bool co
item.file = tool.drives[family].files[index];
if (item.file.empty())
{
tool.status = Flip ? format(STR_C("The drive %s has no variant with the drive on the other side"), tool.drives[family].name.c_str()) : missing_drive_variant(family, (index & 2) != 0, (index & 1) != 0);
tool.status = refused(Flip ? format(STR_C("The drive %s has no variant with the drive on the other side"), tool.drives[family].name.c_str()) : missing_drive_variant(family, (index & 2) != 0, (index & 1) != 0));
return false;
}
if (drive_file(item.file) == found.file)
@@ -276,7 +276,7 @@ bool editor_mode::replace_switch_drive(TTrack &Switch, int const Family, bool co
item.tilt = {angle_value(found.values, 5), angle_value(found.values, 6)};
if (remove_templates({found.instance}) == 0)
{
tool.status = STR_C("The drive of this switch can't be changed in its file");
tool.status = refused(STR_C("The drive of this switch can't be changed in its file"));
return false;
}
std::string error;
@@ -284,7 +284,7 @@ bool editor_mode::replace_switch_drive(TTrack &Switch, int const Family, bool co
{
scene::Layers.removed(found.instance, false);
m_history.pop_back();
tool.status = STR_C("The drive couldn't be placed: ") + error;
tool.status = refused(STR_C("The drive couldn't be placed: ") + error);
return false;
}
join_last_steps();