mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 22:07:55 +01:00
9f6c4f87ae
* fix(editor): track edits keep the joints, the norms, the records and the saved speed together - The cant typed in the inspector goes on into the track joined at that end, as the gizmo and the joints tool do it; the neighbours go into the same undo step. The joint stepped before. - A track laid on from a canted joint takes the cant off along the ramp the norms ask for at the speed (`alignment::cant_ramp_length`), not at a fixed 1.5 mm a metre whatever the speed and the norms: 120 mm at 100 km/h over 120 m, not 80 m. - Deleting a track of the line under the route tool keeps the laying norms. They went back to the defaults, and every later lay, extend and join used those. - The gauge is a paste group of its own, off by default: pasting how a track rides or sounds no longer changes its gauge. - The speed of a turntable set in the editor is the one saved. The editor changed the speed the turntable runs at, while the file keeps the limit it was loaded with. - Deleting a set of tracks does what Del does with each: a double switch, a slip and a crossover go whole, the records of the switches go with them, and the model and events of a turntable too. The records stayed behind and on saving were given to another switch, which then showed a wrong type. - Deleting a switch of a crossover takes the crossover out whole, as the connection tools do: the outer track of a crossover on a curve comes down by its lift and the record of the connection goes. Alone, the switch left the outer track up for good, and the connection to the next switch given its name. A switch bent out of the shape of its record is found by its name. Tests: a unit test of the norm ramp. The other changes are in the editor's UI, which the unit tests don't reach. * test(editor): self-test scripts that fail, a runner, and a case for each fix of the track editing The editor's self-test scripts only logged: nothing made a run fail. Now: - `expect` commands check the state and log `SELFTEST PASS` or `SELFTEST FAIL ... got X, expected Y`: the cant at a track end, the joint at an end (gap, angle, cant step), the records of a switch and the connections naming it, speed, gauge, a track present or removed, the laying norms' gauge, heights and lifts against a mark, whether a track is in the line under the route tool, and the includes of a turntable. A command no group takes counts as a failure, so a mistyped one can't make the checks after it pass. - At `quit` the result is logged, and a script whose expectations failed ends the editor with exit code 2 (a failed start stays 1; the simulator's test mode is unchanged). - The commit of the inspector's cant field is `track_cant_commit`, which the inspector and the `trackcant` command both call; `routegauge` sets the laying norms as the route tool does, and `tracksetdelete` deletes a set of tracks by name. - `tests/editor/run.py` runs each script of `tests/editor/cases` on a copy of the fixture scenery in the game folder, with a wall-time limit and a memory cap, reads the exit code and the `SELFTEST` lines, and deletes the copy. A `#> reopen` line restarts the editor on the saved scenery. See `tests/editor/README.md`. - One case per fix of the track editing quick fixes (inspector cant, norms after deleting, the gauge paste group, turntable speed saved, deleting a set, a set with a double switch, a slip and a crossover, deleting a switch of a crossover, a bent switch). All pass; with the fixes reverted all fail. * feat(editor): the track tool panels keep their fields, results and buttons within the panel - The card of the tool: after a long gesture the action goes under it, at its indent, when what is left of the row is narrower than 8 font sizes or the longest word of the action. It was squeezed into a sliver and broken in the middle of its words. - A click on the title row of the card folds it to that row (icon, name, family, key, and a small triangle marker) and opens it again. One flag for all the tools, kept with the editor settings (`track_card_folded` in eu07_editor.ini), open by default: the card took 250-300 px at the top of every tool and repeats the hint bar of the view. - The grade labels of the vertical profile, on the graph and in the view, write the per mille as the panel does (the translated "per mille", the per mille sign in Polish), not "o/oo". - The track analysis window: the thresholds of the speed check and of the joints keep to their widest name and a field of 10 font sizes where the window is wider than that, as docked across the bottom (`begin_fields_fitted`). The results are tables with each column as wide as what is in it: the speed check with its column names kept at the top as the list scrolls, the joints with the kind, the value and the two tracks next to each other. A click on a row shows it as before. - `same_line_if_fits` puts the next button beside the one before only when it fits in what is left of the line, at the start of the next line otherwise. Used where the route design puts buttons side by side, for "Forget the design" in the profile panel, which was cut off at the edge, and for the buttons of a switch in the inspector. - The laying options: the speed, the curve radius and the longest path are fields with the name on the left in two columns (`begin_fields`/`field_row`), as in the inspector, the route and the profile, the chips of the quick values under them. The segmented choices give the short names less of the room when a long one doesn't fit in its even share, and go on in a second bar when they don't fit side by side: "Through the clicked points" overflowed its third of the bar. * test(editor): a mistyped track fails the self-test, indented comments are skipped, case 7b checks the switch got bent - A blank line or an indented `#` comment in a script is no longer a command no group takes. - `trackcant`, `routegauge` and `tracksetdelete` with a track that isn't there count as a failed expectation. - `expect shaped <switch> <yes|no>`: 7b checks that the gizmo drag bent the switch out of its record before deleting it. - The ramp-length loop of test_alignment counts in an integer (Sonar S2193).
161 lines
6.7 KiB
C++
161 lines
6.7 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <map>
|
|
#include <optional>
|
|
#include <string>
|
|
#include <utility>
|
|
#include <vector>
|
|
|
|
class editorSettings
|
|
{
|
|
public:
|
|
// camera movement key scheme in the editor
|
|
enum class movement_scheme
|
|
{
|
|
wsad, // new default: W/S/A/D + E/Q
|
|
legacy // old scheme: arrows + Page Up/Down
|
|
};
|
|
|
|
editorSettings() = default;
|
|
|
|
bool load();
|
|
bool save();
|
|
|
|
movement_scheme movement() const { return m_movement; }
|
|
void movement(movement_scheme scheme) { m_movement = scheme; }
|
|
|
|
// geoportal orthophoto layer (editor_orthophoto), how it's shown and whether it's on; the origin is kept per scenery, and the
|
|
// scenery keeps it too
|
|
struct orthophoto_settings
|
|
{
|
|
int radius{2};
|
|
float height{0.0f};
|
|
float opacity{0.6f};
|
|
int year{0};
|
|
bool hires{false};
|
|
bool drape{true};
|
|
float lift{0.05f};
|
|
bool in_scene{false};
|
|
// turned on or off by the user, for every scenery; none chosen yet: as the scenery keeps it, or the terrain model turns it on
|
|
std::optional<bool> on;
|
|
};
|
|
orthophoto_settings &orthophoto() { return m_orthophoto; }
|
|
// PUWG 1992 northing/easting of the scenery's (0,0,0) point; false when none was stored
|
|
bool orthophoto_origin(std::string const &Scenery, double &North, double &East) const;
|
|
void orthophoto_origin(std::string const &Scenery, double North, double East);
|
|
// the WMS layers the user added under the scenery, over the orthophoto, the top one first: the address of the service, the
|
|
// layers asked of it, its title and terms as its capabilities gave them. Kept with the editor, not with the scenery
|
|
struct wms_layer
|
|
{
|
|
std::string url;
|
|
std::string layers;
|
|
std::string title;
|
|
std::string terms;
|
|
float opacity{0.8f};
|
|
bool visible{true};
|
|
};
|
|
std::vector<wms_layer> &wms_layers() { return m_wms_layers; }
|
|
|
|
double platform_edge() const { return m_platform_edge; }
|
|
void platform_edge(double Distance) { m_platform_edge = Distance; }
|
|
double signal_offset() const { return m_signal_offset; }
|
|
void signal_offset(double Distance) { m_signal_offset = Distance; }
|
|
// look of the plates drawn for the signals: 0 plain, 1 toned, 2 aged
|
|
int signal_plate_look() const { return m_signal_plate_look; }
|
|
void signal_plate_look(int Look) { m_signal_plate_look = Look; }
|
|
|
|
// node bank: cards with the previews of the models or a list, and the size of the cards in pixels
|
|
bool nodebank_previews() const { return m_nodebank_previews; }
|
|
void nodebank_previews(bool Previews) { m_nodebank_previews = Previews; }
|
|
int nodebank_card() const { return m_nodebank_card; }
|
|
void nodebank_card(int Size) { m_nodebank_card = Size; }
|
|
|
|
// colours of the editor: 0 green, as the rest of the simulator; 1 amber
|
|
int palette() const { return m_palette; }
|
|
void palette(int Palette) { m_palette = Palette; }
|
|
|
|
// the tutorial (Help > Tutorial) opens by itself when an editor session starts
|
|
bool first_steps() const { return m_first_steps; }
|
|
void first_steps(bool Show) { m_first_steps = Show; }
|
|
// a scenery begun with no terrain is offered the terrain model as the first track is laid
|
|
bool terrain_offer() const { return m_terrain_offer; }
|
|
void terrain_offer(bool Offer) { m_terrain_offer = Offer; }
|
|
// a track laid and hidden in the ground is told of, with the way to fit the ground to it
|
|
bool terrain_buried_ask() const { return m_terrain_buried_ask; }
|
|
void terrain_buried_ask(bool Ask) { m_terrain_buried_ask = Ask; }
|
|
// the terrain of the terrain model made under the tracks as they're laid, around the cursor from the first point placed
|
|
bool terrain_while_laying() const { return m_terrain_while_laying; }
|
|
void terrain_while_laying(bool const Make) { m_terrain_while_laying = Make; }
|
|
// the terrain model in the terrain panel: the band along the tracks it's loaded in, m; the chunks along a side of the square
|
|
// made around the camera; the formation and the slopes made along the tracks; the terrain following the tracks edited; the
|
|
// terrain made from the model around the camera within the download area, in the background
|
|
struct terrain_model_settings
|
|
{
|
|
double band{300.0};
|
|
int around{4};
|
|
bool shape{true};
|
|
bool follow{true};
|
|
bool area{true};
|
|
};
|
|
terrain_model_settings &terrain_model() { return m_terrain_model; }
|
|
// the height offset of the terrain model to the tracks of the scenery, and whether it was fitted to them; false when none was stored
|
|
bool terrain_model_offset(std::string const &Scenery, double &Offset, bool &Fitted) const;
|
|
void terrain_model_offset(std::string const &Scenery, double Offset, bool Fitted);
|
|
bool track_tools_more() const { return m_track_tools_more; }
|
|
void track_tools_more(bool Show) { m_track_tools_more = Show; }
|
|
// the card of the track tool in use folded to its title row, for all the tools
|
|
bool track_card_folded() const { return m_track_card_folded; }
|
|
void track_card_folded(bool const Folded) { m_track_card_folded = Folded; }
|
|
// the ballast of the railway drawn in the top view
|
|
int top_tracks() const { return m_top_tracks; }
|
|
void top_tracks(int const Tracks) { m_top_tracks = Tracks; }
|
|
std::uint32_t top_rails() const { return m_top_rails; }
|
|
void top_rails(std::uint32_t const Colour) { m_top_rails = Colour; }
|
|
// the heights of the tracks laid on the ground: fitted to it as the tracks go onto the terrain, the points clicked on it with
|
|
// even grades between them, level
|
|
enum class lay_heights
|
|
{
|
|
fitted,
|
|
points,
|
|
level
|
|
};
|
|
lay_heights heights() const { return m_heights; }
|
|
void heights(lay_heights Heights) { m_heights = Heights; }
|
|
// the free camera: its speed, how many times faster Ctrl makes it, and in the top view as fast as the view is zoomed
|
|
struct camera_settings
|
|
{
|
|
double speed{1.0};
|
|
double fast{30.0};
|
|
bool zoomed{false}; // off as the editor was before: "As it was" means it
|
|
};
|
|
camera_settings &camera() { return m_camera; }
|
|
|
|
private:
|
|
movement_scheme m_movement{movement_scheme::wsad};
|
|
orthophoto_settings m_orthophoto;
|
|
camera_settings m_camera;
|
|
std::map<std::string, std::pair<double, double>> m_orthophoto_origins;
|
|
std::vector<wms_layer> m_wms_layers;
|
|
double m_platform_edge{1.725};
|
|
double m_signal_offset{2.25};
|
|
int m_signal_plate_look{1};
|
|
bool m_nodebank_previews{true};
|
|
int m_nodebank_card{96};
|
|
int m_palette{0};
|
|
bool m_first_steps{true};
|
|
bool m_terrain_offer{true};
|
|
bool m_terrain_buried_ask{true};
|
|
bool m_track_tools_more{false};
|
|
bool m_track_card_folded{false};
|
|
bool m_terrain_while_laying{true};
|
|
terrain_model_settings m_terrain_model;
|
|
std::map<std::string, std::pair<double, bool>> m_terrain_model_offsets;
|
|
int m_top_tracks{0}; // the railway in the top view: whole, without the ballast, the rails alone
|
|
std::uint32_t m_top_rails{0xffff6e28}; // colour of the rails alone, as ImGui keeps it: ABGR
|
|
lay_heights m_heights{lay_heights::points};
|
|
};
|
|
|
|
// global editor settings instance
|
|
extern editorSettings EditorSettings;
|