mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 08:39:19 +02:00
What the plan tool was missing was not geometry but the ordinary business of editing: taking a mistake back, dividing what is drawn, and seeing what the next click will do before making it. Cofanie. The document is plain data, so a step is a copy of it. What counts as one step is decided by watching the document - a fingerprint over the tracks, turnouts and catalogue - rather than by dressing every edit with a call: a frame that changes anything opens a step, and the step closes when the drawing settles. That is what makes a drag, or a number typed digit by digit, one step and not thirty, and nothing can be forgotten on the way in. Ctrl+Z / Ctrl+Y; the scene editor listens for the same keys, so it hands them over while the plan has the keyboard. Złącze i wycięcie. `insert_joint` divides whichever element a station lands in and leaves one chain: the ground does not move, the curvature at the new joint is the one that was always there, and the fit reads the chain the same way afterwards. It is refused on a straight, because two straights end to end are one straight and the skeleton will not read that, and under a turnout, which is one piece of geometry on one element. `cut_track` takes a piece out and does leave two tracks - a gap is the ground between them, not a hole in a chain. Przejście rozjazdowe. A turnout may now stand against another one: where it stands is then worked out from that one's frog, not authored, so moving either carries the other with it and a trapez stays shut. The frog has to land on the line leaving the other frog - not on the track's axis, which is 1,469 m further on for a 1:9 - so the station is settled by laying the turnout and walking it along until it does. Drawing is a tool now, not what a click happens to do: until Rysuj is on, a click picks what is under it. With it on, the cursor at the growing end shows the corner and the straight the next click would lay, worked out by the same fit_corner the click itself uses. A chain only grows at a loose end, and the first element of a track is put down by two clicks instead of landing on the plan's zero. Also here: the curvature strip under the panel, pikietaż in the rows and at the cursor, how far the laid axis runs from the clicks it was drawn from, the file format saying which frame and which units it is in (v9), plans chosen from the directory instead of typed, and editor/samples/demo.m0s - two parallel tracks and a trapez - with the generator that wrote it and a test that opens it and demands it lays clean.
130 lines
2.7 KiB
C++
130 lines
2.7 KiB
C++
module;
|
|
#include <array>
|
|
#include <cstddef>
|
|
#include <deque>
|
|
#include <unordered_map>
|
|
#include <utility>
|
|
#include <vector>
|
|
#include <chrono>
|
|
#include <limits>
|
|
#include <mutex>
|
|
#include <ostream>
|
|
#include <sstream>
|
|
#include <type_traits>
|
|
#include <string>
|
|
#include "imgui/imgui.h"
|
|
#include "utilities/Globals_macros.h"
|
|
#include "utilities/utilities_macros.h"
|
|
|
|
module eu07.simcore;
|
|
import eu07.utilities.globals;
|
|
import eu07.utilities.utilities;
|
|
import eu07.rendering.renderer;
|
|
/*
|
|
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/.
|
|
*/
|
|
|
|
|
|
|
|
editor_ui::editor_ui()
|
|
{
|
|
|
|
clear_panels();
|
|
// bind the panels with ui object. maybe not the best place for this but, eh
|
|
|
|
add_external_panel(&m_itempropertiespanel);
|
|
add_external_panel(&m_nodebankpanel);
|
|
add_external_panel(&m_functionspanel);
|
|
add_external_panel(&m_brushobjects);
|
|
add_external_panel(&m_planpanel);
|
|
}
|
|
|
|
// updates state of UI elements
|
|
void editor_ui::update()
|
|
{
|
|
|
|
set_tooltip("");
|
|
|
|
if (Global.ControlPicking && DebugModeFlag)
|
|
{
|
|
const auto sceneryNode = GfxRenderer->Pick_Node();
|
|
const std::string content = sceneryNode ? sceneryNode->tooltip() : "";
|
|
set_tooltip(content);
|
|
}
|
|
|
|
ui_layer::update();
|
|
m_itempropertiespanel.update(m_node);
|
|
m_functionspanel.update(m_node);
|
|
|
|
auto ptr = get_active_node_template(true);
|
|
if (ptr)
|
|
m_brushobjects.update(*ptr);
|
|
}
|
|
|
|
void editor_ui::render_menu_contents()
|
|
{
|
|
ui_layer::render_menu_contents();
|
|
|
|
if (ImGui::BeginMenu("Track layout"))
|
|
{
|
|
ImGui::MenuItem(m_planpanel.name().c_str(), nullptr, &m_planpanel.is_open);
|
|
ImGui::EndMenu();
|
|
}
|
|
}
|
|
|
|
bool editor_ui::plan_takes_history() const
|
|
{
|
|
return m_planpanel.takes_history_shortcuts();
|
|
}
|
|
|
|
void editor_ui::toggleBrushSettings(bool isVisible)
|
|
{
|
|
if (m_brushobjects.is_open != isVisible)
|
|
m_brushobjects.is_open = isVisible;
|
|
}
|
|
|
|
void editor_ui::set_node(scene::basic_node *Node)
|
|
{
|
|
m_node = Node;
|
|
}
|
|
|
|
void editor_ui::add_node_template(const std::string &desc)
|
|
{
|
|
m_nodebankpanel.add_template(desc);
|
|
}
|
|
|
|
std::string const *editor_ui::get_active_node_template(bool bypassRandom)
|
|
{
|
|
if (!bypassRandom && m_brushobjects.is_open && m_brushobjects.useRandom && m_brushobjects.Objects.size() > 0)
|
|
{
|
|
return m_brushobjects.GetRandomObject();
|
|
}
|
|
return m_nodebankpanel.get_active_template();
|
|
}
|
|
|
|
nodebank_panel::edit_mode editor_ui::mode()
|
|
{
|
|
return m_nodebankpanel.mode;
|
|
}
|
|
float editor_ui::getSpacing()
|
|
{
|
|
return m_brushobjects.spacing;
|
|
}
|
|
|
|
functions_panel::rotation_mode editor_ui::rot_mode()
|
|
{
|
|
return m_functionspanel.rot_mode;
|
|
}
|
|
float editor_ui::rot_val()
|
|
{
|
|
return m_functionspanel.rot_value;
|
|
}
|
|
bool editor_ui::rot_from_last()
|
|
{
|
|
return m_functionspanel.rot_from_last;
|
|
} |