17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-08 13:19:17 +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:
maj00r
2026-10-21 10:28:42 +02:00
parent 747c6817f0
commit 87bacede74
27 changed files with 137 additions and 218 deletions

View File

@@ -11,6 +11,7 @@ http://mozilla.org/MPL/2.0/.
#include "stdafx.h"
#include "application/editormode.h"
#include "application/editormodeshared.h"
#include "application/editoruilayer.h"
#include "application/editorprojection.h"
#include "editor/editorFormat.hpp"
@@ -271,7 +272,7 @@ void editor_mode::group_selection()
{
if (reason.empty())
reason = STR("it's a part of a scenery template");
ui()->set_status(format(STR_C("\"%s\" can't be grouped: %s"), node->name().empty() ? STR_C("(no name)") : node->name().c_str(), reason.c_str()), true);
ui()->set_status(format(STR_C("\"%s\" can't be grouped: %s"), name_of(*node).c_str(), reason.c_str()), true);
return;
}
}
@@ -334,7 +335,7 @@ void editor_mode::render_context_menu()
if (count > 1)
ImGui::TextDisabled(STR_C("%zu models selected"), count);
else if (selected)
ImGui::TextDisabled("%s", m_node->name().empty() ? STR_C("(no name)") : m_node->name().c_str());
ImGui::TextDisabled("%s", name_of(*m_node).c_str());
else
ImGui::TextDisabled("%s", STR_C("Nothing selected"));
ImGui::Separator();