mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-23 07:41:10 +02:00
feat(editor): a less crowded track editor and one choice of what the switch tool places
- the switch tool asks what to place: a switch, a slip switch, a crossing or a connection of tracks (crossover, double, scissors, ladder), with the templates and the options of that kind only and one line of how to place it with the mouse; the bar of hints says the same, the wheel keys of a connection included; panel in its own editormodeswitchtool.cpp - templates are listed by their names, the lengths a and b and the rest of the label in the tooltip - the panel of a selected switch shows its length, its type and its drive; the name, number, rail, kilometre and angle are under Details - one toolbar: the tools are no longer drawn a second time down the edge of the view; the track tools show select, lay, plan, switch and parallel, the others behind More, which starts closed again (setting track_tools_all) - the infrastructure tool has no button nor key - the gizmo options start closed, the node bank isn't drawn in the track mode - no drive models: said in plain words - self-test switchkind
This commit is contained in:
@@ -34,6 +34,7 @@ http:
|
||||
#include <map>
|
||||
#include <numeric>
|
||||
#include <functional>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
#include <tuple>
|
||||
#include <unordered_set>
|
||||
@@ -3417,3 +3418,32 @@ void editor_track::rebuild_geometry(TTrack &Track)
|
||||
if (crossing != &Track && false == crossing->m_editorremoved)
|
||||
rebuild(*crossing);
|
||||
}
|
||||
|
||||
std::string editor_track::switch_template::title() const
|
||||
{
|
||||
std::istringstream words(label);
|
||||
std::vector<std::string> kept;
|
||||
std::vector<std::string> all;
|
||||
for (std::string word; words >> word;)
|
||||
all.push_back(word);
|
||||
for (std::size_t i = 0; i < all.size(); ++i)
|
||||
{
|
||||
if (all[i].front() == '(')
|
||||
break;
|
||||
auto const number = [](std::string const &Word) {
|
||||
char *end{nullptr};
|
||||
std::strtod(Word.c_str(), &end);
|
||||
return end != Word.c_str() && *end == '\0';
|
||||
};
|
||||
if ((all[i] == "a" || all[i] == "b") && i + 1 < all.size() && number(all[i + 1]))
|
||||
{
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
kept.push_back(all[i]);
|
||||
}
|
||||
std::string result;
|
||||
for (auto const &word : kept)
|
||||
result += (result.empty() ? "" : " ") + word;
|
||||
return result.empty() ? label : result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user