mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 08:39:19 +02:00
A "Plan" panel, opened from Track layout in the editor's menu bar, draws a niweleta the way the web frontend did: click to lay chained straights, drag a corner to move it, and pick a fit for each gap between them. The geometry is entirely maj0sted's - the panel gathers the input, hands the document to solve_project and paints the rails that come back, coloured by whether they came from a straight, an arc or a clothoid. Scenery nodes are untouched. A fit the library cannot produce is simply absent from its answer, so the gap is labelled as not fitting rather than left looking as though its parameters took effect. Save/load go through the library's own document format, so a project written here opens in the same state. Also translates the comments added with -editor into English, matching the files they sit in.
109 lines
2.3 KiB
C++
109 lines
2.3 KiB
C++
/*
|
|
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/.
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
#include "application/editoruilayer.h"
|
|
|
|
#include "utilities/Globals.h"
|
|
#include "utilities/utilities.h"
|
|
#include "scene/scenenode.h"
|
|
#include "rendering/renderer.h"
|
|
|
|
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;
|
|
} |