17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-29 04:37:30 +01:00

feat(editor): presets of the track properties, applied on the selected tracks

(cherry picked from commit 83c8c23c80)
This commit is contained in:
2026-10-21 16:09:05 +02:00
committed by maj00r
parent 7e284b293d
commit a83d5c6978
11 changed files with 689 additions and 23 deletions

View File

@@ -1837,6 +1837,15 @@ class editor_mode : public application_mode, private editor_track::observer, pri
void render_track_style(std::vector<TTrack *> const &Tracks);
void copy_track_style(TTrack const &Track);
std::size_t paste_track_style(std::vector<TTrack *> const &Tracks);
// which groups of the properties are pasted or put on the tracks by a preset, in the order of the groups of editormodetrackprops.cpp
using track_groups = std::array<bool, 11>;
// the values of the properties of the chosen groups put on the tracks, in one step of the undo. returns: the number of the
// tracks changed, none when no value is of the chosen groups
std::optional<std::size_t> apply_track_values(std::vector<std::pair<std::string, std::string>> const &Values, track_groups const &Groups, std::vector<TTrack *> const &Tracks, char const *What);
// presets of the properties of the tracks (editorTrackPresets), made from a track and put on the selected ones
void render_track_presets(std::vector<TTrack *> const &Tracks);
void render_track_presets_menu();
std::size_t apply_track_preset(int const Id, std::vector<TTrack *> const &Tracks);
std::vector<TTrack *> similar_tracks(int const Property, std::vector<TTrack *> const &Tracks) const;
// values of the properties over the selected tracks, each with the number of the tracks having it
struct track_values
@@ -1882,12 +1891,19 @@ class editor_mode : public application_mode, private editor_track::observer, pri
{
std::string from;
std::vector<std::pair<std::string, std::string>> values;
// speed, environment, overhead line, track circuits, rails, trackbed, its shape, sleepers, ride and sound, frogs
std::array<bool, 10> groups{false, false, false, false, true, true, true, true, false, true};
// speed, environment, overhead line, track circuits, rails, trackbed, its shape, sleepers, ride and sound, frogs, sleeper placement
track_groups groups{false, false, false, false, true, true, true, true, false, true, true};
bool open{false};
bool picking{false}; // the next click on a track in the view copies its properties
};
track_style m_track_style;
struct track_presets_panel
{
int selected{0}; // id of the preset chosen in the inspector
int nameid{0}; // the preset whose name is in the field
char name[128]{};
};
track_presets_panel m_track_presets;
std::vector<std::vector<TTrack *>> m_track_similar;
TTrack const *m_track_list_hover{nullptr}; // in the list of the selected tracks
int m_track_list_hover_frame{-1};