mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-02 05:49:13 +01:00
refactor(editor): the helpers repeated over the editor files are shared
The name of a node or "(no name)" was written out in twenty places and four local functions, a lower-case copy of a text in four files, the test for a number, the file name of a template made comparable and the heading of a direction in three and two, the green main button of a panel in five and the key=value parameters of a self-test command in five. Each of them is one helper now: name_of, tall_button_height and main_button with the panel helpers, numeric with format, normalized with the include helpers, heading_of with the plan geometry and selftest_values with the tools; lower gives way to ToLower.
This commit is contained in:
@@ -527,7 +527,7 @@ editor_mode::editor_mode() {
|
||||
std::string reason;
|
||||
if (Node->from_template() || false == scene::Layers.editable(Node, &reason))
|
||||
{
|
||||
ui()->set_status(format(STR_C("\"%s\" can't be edited: %s"), (Node->name().empty() ? std::string{STR_C("(no name)")} : Node->name()).c_str(), reason.c_str()), true);
|
||||
ui()->set_status(format(STR_C("\"%s\" can't be edited: %s"), name_of(*Node).c_str(), reason.c_str()), true);
|
||||
return;
|
||||
}
|
||||
m_track_window_open = false;
|
||||
@@ -6594,7 +6594,7 @@ void editor_mode::on_mouse_button(int const Button, int const Action, int const
|
||||
}
|
||||
else if (node->from_template() || false == scene::Layers.editable(node, &reason))
|
||||
{
|
||||
ui()->set_status(format(STR_C("\"%s\" can't be edited: %s"), (node->name().empty() ? std::string{STR_C("(no name)")} : node->name()).c_str(), reason.c_str()), true);
|
||||
ui()->set_status(format(STR_C("\"%s\" can't be edited: %s"), name_of(*node).c_str(), reason.c_str()), true);
|
||||
node = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user