mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 21:07:06 +01:00
a7a641944f
The first part of E4a (editor-tracks-domain.md §3, §9, §14): the domain model of E2 and the project file of E3 brought into the running editor, behind a setting, "Editing on the model (trial)" in the settings of the editor, off by default. Off, nothing of it runs and the editor is as it was. - editor/project/projectSession: the project of the map open in the editor, no scene. open() reads the project file of the map, or makes it of the //$ lines the first time (open_project of E3), and compares the tracks the generator wrote with the files as they are now: a track changed or gone outside the editor marks its line changed by hand. trial() tries a command on a copy of the network and tells the lines it lays anew or takes away (differences()), nothing changed; execute() carries it out, the lines of Overwrite no longer taken for changed by hand with it. A command kept is a step of the model's history with a token, which the editor's step of it takes back and brings again (undo(Token), redo(Token)): only the latest step kept, or taken back, can be, so the two histories can't go out of step; the marks of a change by hand go with the step. record_written() records the tracks of a line as the scenery save wrote them, save() writes the project with the network as it is, the records of the lines gone taken out. - The setting on, the project of the map (the file of the scenery opened, <map>.eu07proj next to it) is opened with the scenery and written with it. The scenery save asks for the text of each track it writes (scene::node_layers::path_writer): a track the generator made, as long as nothing else changed it, is written as the generator made it (the numbers in the shortest form which reads back to the same double, not the 15 digits of the export), and its checksum recorded; one changed by the other tools is written by its own export and its line marked changed by hand. The tracks of the lines of the project are found in the scene by their names, with the text the file has for each (scene::node_layers::source() tells the file and the placement of a node). Tests: U: a map opened gets its project file; a command refused, tried or carried out, changes nothing and isn't a step; a command tried changes nothing, carried out tells its lines (new, split, a curve changed, deleted); the steps taken back and brought again by their tokens in the order of the history, another token refused, a command after an undo dropping the step taken back, the identifiers not given again; the tracks of two lines written and recorded, a reopen finding nothing changed and the line the same to the bit as the model laid it, a speed edited in the file marking its line alone, deleting it writing over it too, the mark taken off by a command writing over it and back with its undo, the records of a line deleted gone with it at the save. Self-test: modelediting <0|1> (the setting for the run, not kept), expect modellines, expect projectfile <present|absent|lines n>. lang/editor_pl.po: the Polish of the new texts.
166 lines
7.0 KiB
C++
166 lines
7.0 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; }
|
|
// the tracks laid and edited through the model of the track geometry, its commands and the project file of the map (stage E4,
|
|
// a trial): off, the editor works as it did
|
|
bool model_editing() const { return m_model_editing; }
|
|
void model_editing(bool const On) { m_model_editing = On; }
|
|
// 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 tool in use folded to its title row, for all the tools of all the fields of work
|
|
bool tool_card_folded() const { return m_tool_card_folded; }
|
|
void tool_card_folded(bool const Folded) { m_tool_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_model_editing{false};
|
|
bool m_terrain_offer{true};
|
|
bool m_terrain_buried_ask{true};
|
|
bool m_track_tools_more{false};
|
|
bool m_tool_card_folded{true};
|
|
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;
|