mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-26 01:02:26 +01:00
feat(track): rails and ballast blended into those of the tracks joined, where their textures differ
This commit is contained in:
@@ -1797,7 +1797,7 @@ class editor_mode : public application_mode, private editor_track::observer
|
||||
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>;
|
||||
using track_groups = std::array<bool, 12>;
|
||||
// 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);
|
||||
@@ -1850,8 +1850,8 @@ class editor_mode : public application_mode, private editor_track::observer
|
||||
{
|
||||
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, sleeper placement
|
||||
track_groups groups{false, false, false, false, true, true, true, true, false, true, true};
|
||||
// speed, environment, overhead line, track circuits, rails, trackbed, its shape, sleepers, ride and sound, frogs, sleeper placement, texture blending
|
||||
track_groups groups{false, false, false, false, true, true, true, true, false, true, true, true};
|
||||
bool open{false};
|
||||
bool picking{false}; // the next click on a track in the view copies its properties
|
||||
};
|
||||
|
||||
@@ -226,12 +226,13 @@ enum group : int
|
||||
ride_sound,
|
||||
frogs,
|
||||
sleeper_placement, // spacing and shift of the sleepers and of the trackbed under them, apart from their models
|
||||
blending, // how far from the ends the textures blend into those of the tracks joined there
|
||||
group_count
|
||||
};
|
||||
|
||||
char const *const kGroupLabels[group_count] = {"Speed", "Environment", "Overhead line", "Track circuits", "Rails", "Trackbed", "Shape of the trackbed", "Sleepers", "Ride and sound", "Frog and check rails", "Sleeper placement"};
|
||||
char const *const kGroupLabels[group_count] = {"Speed", "Environment", "Overhead line", "Track circuits", "Rails", "Trackbed", "Shape of the trackbed", "Sleepers", "Ride and sound", "Frog and check rails", "Sleeper placement", "Texture blending"};
|
||||
// the groups as the presets keep them in their file, by names which don't change with the order of the groups
|
||||
char const *const kGroupKeys[group_count] = {"speed", "environment", "overhead", "circuits", "rails", "trackbed", "bedshape", "sleepers", "ride", "frogs", "sleeperplacement"};
|
||||
char const *const kGroupKeys[group_count] = {"speed", "environment", "overhead", "circuits", "rails", "trackbed", "bedshape", "sleepers", "ride", "frogs", "sleeperplacement", "blending"};
|
||||
|
||||
struct track_property
|
||||
{
|
||||
@@ -504,6 +505,30 @@ std::vector<track_property> make_properties()
|
||||
blades("bladeheel", "Blade heel (m)", "Where the moving blades end, from the start of the switch, as the template of the switch gives it.\n0: as long as the flangeway of 58 mm behind them needs", &TSwitchExtension::m_bladeheel);
|
||||
blades("bladethrow", "Blade throw (m)", "How far the tips of the blades move over between the two paths.\n0: the usual 0.160 m", &TSwitchExtension::m_bladethrow);
|
||||
}
|
||||
{
|
||||
// the ends of a plain track are p1 and p2, a switch has p4 as the end of its second path
|
||||
char const *const ends[][3] = {{"blend1", "Texture blending at p1 (m)", "How far from the end p1 the rails and the ballast blend into those of the track joined there, where their textures differ.\nThe ballast comes in as stones mixed together, the rails fade into each other; 0: not blended"},
|
||||
{"blend2", "Texture blending at p2 (m)", "How far from the end p2 the rails and the ballast blend into those of the track joined there, where their textures differ.\nThe ballast comes in as stones mixed together, the rails fade into each other; 0: not blended"},
|
||||
{"blend3", "Texture blending at p4 (m)", "How far from the end p4 of the switch its trackbed blends into the ballast of the track joined there, where their textures differ; 0: not blended"}};
|
||||
for (int end = 0; end < 3; ++end)
|
||||
{
|
||||
auto &property{add(list, ends[end][0], field::number, section::look, group::blending, ends[end][1], ends[end][2])};
|
||||
property.rebuild = true;
|
||||
property.more = true;
|
||||
property.applies = [end](TTrack const &Track) { return Track.m_visible && (Track.iCategoryFlag & 15) == kRailCategory && (Track.eType == tt_Switch || (Track.eType == tt_Normal && end < 2)); };
|
||||
property.get = [end](TTrack const &Track) { return decimal(Track.m_blend[end], 2); };
|
||||
property.set = [end](TTrack &Track, std::string const &Text) {
|
||||
double length;
|
||||
if (false == parse_number(Text, length))
|
||||
return false;
|
||||
auto const clamped{static_cast<float>(std::max(0.0, length))};
|
||||
if (decimal(clamped, 2) == decimal(Track.m_blend[end], 2))
|
||||
return false;
|
||||
Track.m_blend[end] = clamped;
|
||||
return true;
|
||||
};
|
||||
}
|
||||
}
|
||||
add_float(list, "texlength", section::look_bed, group::trackbed_shape, "Texture length (m)", "Length after which the texture of the rails and the trackbed repeats", &TTrack::fTexLength, 2, 0.01f, true);
|
||||
{
|
||||
auto &property{add(list, "bedheight", field::number, section::look_bed, group::trackbed_shape, "Trackbed height (m)", "Height of the trackbed edge below the rail top")};
|
||||
@@ -1466,7 +1491,7 @@ void editor_mode::render_track_presets(std::vector<TTrack *> const &Tracks)
|
||||
{
|
||||
// rails, trackbed, its shape, sleepers, frogs and sleeper placement at first, the look of the track
|
||||
std::array<bool, group_count> groups{};
|
||||
for (auto const group : {group::rails, group::trackbed, group::trackbed_shape, group::sleepers, group::frogs, group::sleeper_placement})
|
||||
for (auto const group : {group::rails, group::trackbed, group::trackbed_shape, group::sleepers, group::frogs, group::sleeper_placement, group::blending})
|
||||
groups[group] = true;
|
||||
panel.selected = EditorTrackPresets.create(STR_C("New preset"), name_of(*Tracks.front()), values_of_track(*Tracks.front()), group_keys(groups));
|
||||
panel.nameid = 0;
|
||||
@@ -1855,7 +1880,7 @@ editor_mode::selftest_result editor_mode::selftest_props(std::string const &Comm
|
||||
}
|
||||
else if (action == "groups")
|
||||
{
|
||||
// the groups pasted, as their numbers: 0 speed ... 9 frogs, 10 sleeper placement
|
||||
// the groups pasted, as their numbers: 0 speed ... 9 frogs, 10 sleeper placement, 11 texture blending
|
||||
m_track_style.groups.fill(false);
|
||||
for (int group; Words >> group;)
|
||||
if (group >= 0 && group < group_count)
|
||||
|
||||
Reference in New Issue
Block a user