17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 08:39:19 +02:00

feat(editor): Signals mode of the Tracks window (H): semaphores, block, warning, shunting, stop, substitute signals and repeaters placed by the track from the templates of the scenery, described by //$e signal: (kind, mount, lamps, lean, the event the train reads them by) which tools/editor/signal_headers.py writes into them; a click by a track puts the signal on that side 2.25 m from the axis at the rail heads, facing the trains which have it on their right, a drag along turns it to the trains going the way of the drag; its (p1)_sem_info goes to event1 or event2 of the path, warning signals and repeaters, which the train doesn't read, get none; a head leaning away from the track swapped for its counterpart; the plate named like the signal; signals dragged along the track with their event, removed with it, renamed in the node properties with it, each a single step of the undo history; Polish translation

This commit is contained in:
maj00r
2026-10-08 03:12:16 +02:00
parent 4a7d839e5d
commit b02fe0ac2b
14 changed files with 1828 additions and 13 deletions

View File

@@ -29,6 +29,7 @@ http://mozilla.org/MPL/2.0/.
#include "world/Sweep.h"
#include <array>
#include <map>
#include <chrono>
#include <functional>
#include <memory>
@@ -814,7 +815,7 @@ class editor_mode : public application_mode, private editor_track::observer
void update_build_tools();
void draw_build_overlay() const;
// modes of the track editor, one at a time: path is the plain selection
enum class track_tab { straights, route, path, turnout, profile, speed, joints, infra, lay, lineside, turntable };
enum class track_tab { straights, route, path, turnout, profile, speed, joints, infra, lay, lineside, turntable, signals };
struct track_mode
{
char const *label;
@@ -822,7 +823,7 @@ class editor_mode : public application_mode, private editor_track::observer
track_tab tab;
char const *tooltip;
};
static std::array<track_mode, 11> const &track_modes();
static std::array<track_mode, 12> const &track_modes();
// the objects along the track: a tab for each tool
int m_lineside_tab{0};
void render_lineside_ui();
@@ -878,7 +879,7 @@ class editor_mode : public application_mode, private editor_track::observer
void draw_track_hover() const;
struct track_intent
{
enum class kind { none, gizmo, select, point, box, straight_set, straight_break, detour, straight_tool, straight_handle, route_vertex, route_grip, switch_at, lay, lay_end, sweep, turntable_place, turntable_exit, turntable_fit, spread, extend_end };
enum class kind { none, gizmo, select, point, box, straight_set, straight_break, detour, straight_tool, straight_handle, route_vertex, route_grip, switch_at, lay, lay_end, sweep, turntable_place, turntable_exit, turntable_fit, spread, extend_end, signal_place, signal_move };
kind what{kind::none};
TTrack *track{nullptr};
int path{0};
@@ -1043,6 +1044,7 @@ class editor_mode : public application_mode, private editor_track::observer
bool described{false};
std::string track;
glm::dvec2 tilt{0.0}; // rot.x and rot.z of a described template, degrees
std::map<std::string, std::string> values;
};
struct standing_template
{
@@ -1192,6 +1194,93 @@ class editor_mode : public application_mode, private editor_track::observer
void render_vehicle_ui();
void draw_vehicle_marker() const;
struct signal_template
{
std::string file;
std::string name;
std::string description;
std::string kind;
std::string mount;
std::string lamps;
std::string lean;
std::string read;
int parameters{0};
bool plate{false};
bool linked{false};
};
struct signal_spot
{
TTrack *track{nullptr};
int path{0};
glm::dvec3 axis{0.0};
glm::dvec2 travel{0.0, 1.0};
int side{1};
int list{2};
double offset{0.0};
glm::dvec3 position{0.0};
double yaw{0.0};
};
struct signal_standing
{
standing_template include;
int kind{-1};
std::string name;
std::string read;
TTrack *track{nullptr};
int list{0};
signal_spot spot;
bool on_track{false};
};
struct signal_tool
{
std::vector<signal_template> templates;
int revision{-1};
int kind{0};
std::array<int, 7> chosen{-1, -1, -1, -1, -1, -1, -1};
char filter[64]{};
char name[64]{"A"};
char plate[64]{};
char linked[64]{"none"};
float height{0.0f};
bool placing{false};
signal_spot press;
glm::vec2 pressed{0.f};
int facing{0};
std::vector<signal_standing> standing;
std::size_t standing_history{static_cast<std::size_t>(-1)};
std::size_t standing_redo{static_cast<std::size_t>(-1)};
double standing_time{-1.0};
int hover{-1};
scene::instance_handle selected{0};
bool moving{false};
signal_spot moved;
bool moved_valid{false};
std::string status;
};
signal_tool m_signal;
void signal_scan();
signal_template const *signal_armed() const;
signal_template const *signal_template_of(std::string const &File) const;
bool signal_spot_at(TTrack &Track, int const Path, glm::dvec3 const &Point, glm::dvec3 const &Cursor, int const Facing, int const Side, signal_template const &Template, signal_spot &Spot) const;
void signal_refresh(bool const Force = false);
int signal_hit() const;
void signal_press(track_intent const &Intent);
void signal_release();
bool signal_place(signal_spot const &Spot, signal_template const &Template);
void signal_move_update();
void signal_move_finish();
bool signal_delete(scene::instance_handle const Instance);
void signal_detach_events(std::string const &Read, std::vector<std::pair<TTrack *, editor_track::state>> &States);
void signal_renamed(std::string const &Before, std::string const &After, EditorSnapshot &Snapshot);
void signal_select(scene::instance_handle const Instance);
std::string signal_next_name(std::string const &Name) const;
void render_signal_ui();
void render_signal_palette();
void render_signal_selected();
void draw_signal_overlay() const;
std::string signal_intent_label(signal_template const &Template, signal_spot const &Spot) const;
std::string signal_variant(signal_template const &Template, signal_spot const &Spot) const;
// a model laid along the track: bent to follow it, or repeated along it
struct sweep_tool
{