17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 08:39:19 +02:00
Files
maszyna/application/editoruilayer.cpp
maj00r c15e200e37 Merge the track layout editor into cpp20-modules, ported to modules
The editor branch was written against headers and the PCH, both of which this
branch has done away with, so its own files were ported rather than merged: the
five headers it added are now interface units and their .cpp files module
implementation units.

- editor/{puwg1992,polandmap,turnouts,orthophoto} become eu07.editor.* modules,
  application/planpanel becomes eu07.application.planpanel. The plan tool keeps
  to its own module rather than joining the eu07.simcore partitions: it stands on
  the editor's libraries and eu07.application.uilayer, not on the simulation core,
  so :editoruilayer can export import it without a cycle.
- glm arrives by import eu07.glm, never by include, as the rest of the tree does.
  maj0sted is header-only and glm-free, so its headers stay includes in the global
  module fragment - every unit that names those types includes them itself, since
  a global fragment is not visible across units.
- the one textual conflict was :editoruilayer's include block against this
  branch's imports; resolved this branch's way plus the planpanel import.

Builds with clang 22 (-DWITH_BETTER_RENDERER=OFF) and starts into the editor on
empty ground with -editor alone.
2026-09-13 12:36:21 +02:00

125 lines
2.6 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();
}
}
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;
}