18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 22:07:55 +01:00
Files
maszyna/editor/editorProjectSetup.hpp
T
maj00r 075a66d169 feat(editor): the assumptions of the project asked for at the start, what's drawn, kept with the map
editor-project-setup.md: a new user drew with no word of what: the norms, the speed, the gauge and the rail lay about the panels, set
on the way. Now one short step, "What do you draw?" (Co rysujesz?), one screen of defaults and one button:

- The fields: the norms (PLK ST-T1-A6, TSI alone, EN 13803, CH; PLK by default, no "none": a fictional scenery has a profile too), the
  speed of the line (chips 40..200, 100 km/h), the traffic, a main or a side track, the gauge (1435 / 1520 / 1000 / 750 / 600 mm),
  the rail (60E1 / 49E1 / S42), the look of the tracks under More (the rails and the trackbed as now where left empty).
  application/editorsetupui.* draws them for all three places below.
- Asked for as the last step of the wizard of a new scenery (4., or 2. for a fictional one; its button Start: create and open in the
  editor), which writes them into the new scenery; and in a scenery with none, as a card in the inspector of the tracks in place of the
  first steps, until its Start. Changed later in their window, Assumptions of the project, from the editor settings or the line of
  them under the first steps in Tracks; a change checks the lines laid before against them, the report in the window of the norms,
  nothing laid changed by it.
- Kept with the map (editor/editorProjectSetup.*, one record "setup norms plk speed 100 traffic mixed track main gauge 1435 rail 60E1"):
  in its project file where it has one (a record of its own; the profile of the scenery the model judges by set with it), else in the
  scenery as //$u lines, which the simulator skips and the scene layers keep as a mark of the editor. Read when the map is opened, the
  project file first. A scenery saved without them holds nothing new.
- The defaults of the tools from them: the speed of the laying and of the route design, the gauge and the rails and the trackbed of the
  tracks laid, the norms checked against, the rail of the switch tool and the usual switch of the rail for the speed on its diverging
  track (the closest speed, the ratio usual for it). A route with no speed of its own takes the speed of the assumptions.

Self-test: setup [<key> <value>]..., setupwindow [close]; expect setup none|<key> <value>, expect setupmark <present|absent>, expect layspeed <km/h>. The cases
ps_1_setup_saved (set, saved into the scenery, read back after a reopen) and ps_2_setup_project (into the project file with the
editing on the model, read from there after a reopen with it off).

Tests: U: the record written and read back, the defaults, what it can't read, the class of the line, kept in the project file.

lang/editor_pl.po: the Polish of the new texts.
2026-11-23 23:24:28 +01:00

66 lines
3.0 KiB
C++

/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "editor/norms/norms.hpp"
#include <array>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
// The assumptions of the project ("Co rysujesz?"): what the user draws, said once at the start of a scenery and changed later in a
// window of their own: the norms, the speed of the line, the traffic, a main or a side track, the gauge, the rail and the look of the
// tracks. They're kept with the map, in its project file where it has one, else in the scenery as the line //$u setup ..., and they're
// the defaults of the laying, the plan, the switches, the parallel tool and the profile. There's no "no norms": every scenery has a
// profile, a fictional one too, PLK where nothing was said; the TSI alone are the loosest
namespace project_setup
{
struct setup
{
norms::profile_id profile{norms::profile_id::plk};
double speed{100.0}; // km/h of the line
norms::traffic traffic{norms::traffic::mixed};
norms::track_kind track{norms::track_kind::main};
int gauge{1435}; // mm
std::string rail{"60E1"}; // the switches of this rail first
std::string rails; // the texture of the rails of the tracks laid; empty: as the lay tool has it
std::string ballast; // the texture of the trackbed; empty: as the lay tool has it
bool operator==(setup const &) const = default;
};
inline constexpr std::array<int, 5> gauges{1435, 1520, 1000, 750, 600};
inline constexpr std::array<std::string_view, 3> rail_kinds{"60E1", "49E1", "S42"};
inline constexpr std::array<double, 8> speeds{40.0, 60.0, 80.0, 100.0, 120.0, 140.0, 160.0, 200.0};
// the words the profiles are written with, as in the project file: plk, tsi, en13803, ch
std::string_view profile_key(norms::profile_id const Profile);
std::optional<norms::profile_id> profile_of_key(std::string_view const Key);
// the class of the line the norms judge the tracks laid by: the traffic and the track of the setup, the speed given (the one of the
// line laid), or the setup's own
norms::line_class line_class(setup const &Setup, double const Speed = 0.0);
// mm between the axes of the rails the cant is measured on: the gauge and the head of a rail, 1500 for 1435
double rail_axes(setup const &Setup);
// km/h through the diverging track of the switches laid by default: as the line and the track have it
double diverging_speed(setup const &Setup);
// one line: "setup norms plk speed 100 traffic mixed track main gauge 1435 rail 60E1", the textures after it where given
std::string record(setup const &Setup);
// the line of record(); none where it isn't one. The words it doesn't know are passed over, a value it can't read keeps the default
std::optional<setup> read(std::string_view const Line);
// the first line of the //$u lines (the mark taken off) which reads
std::optional<setup> read(std::vector<std::string> const &Lines);
} // namespace project_setup