16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00

move vehicle param window to vehicle list, add radiostop button

This commit is contained in:
milek7
2019-03-16 20:51:51 +01:00
parent 20652829b1
commit 16570f8d23
21 changed files with 130 additions and 81 deletions

View File

@@ -1,5 +0,0 @@
#include "widgets/trainingcontrol.h"
void ui::trainingcontrol_panel::render_contents() {
}

View File

@@ -1,10 +0,0 @@
#include "uilayer.h"
namespace ui
{
class trainingcontrol_panel : public ui_panel
{
public:
void render_contents() override;
};
} // namespace ui

View File

@@ -2,12 +2,19 @@
#include "widgets/vehiclelist.h"
#include "simulation.h"
#include "Driver.h"
#include "widgets/vehicleparams.h"
ui::vehiclelist_panel::vehiclelist_panel(ui_layer &parent)
: ui_panel(LOC_STR(vehiclelist_window), false), m_parent(parent)
{
}
void ui::vehiclelist_panel::render_contents()
{
for (TDynamicObject *vehicle : simulation::Vehicles.sequence())
{
if (vehicle->Prev())
if (!vehicle->Mechanik)
continue;
std::string name = vehicle->name();
@@ -16,20 +23,13 @@ void ui::vehiclelist_panel::render_contents()
if (vehicle->Mechanik)
timetable = vehicle->Mechanik->TrainName() + ", ";
std::string label = std::string(name + ", " + timetable + std::to_string(speed) + " km/h");
if (!vehicle->Next())
ImGui::TextUnformatted(label.c_str());
else if (ImGui::TreeNode(vehicle, label.c_str()))
{
vehicle = vehicle->Next();
while (vehicle)
{
ImGui::TextUnformatted(vehicle->name().c_str());
vehicle = vehicle->Next();
}
ImGui::TreePop();
}
}
std::string label = std::string(name + ", " + timetable + std::to_string(speed) + " km/h###");
// ImGui::ShowDemoWindow();
ImGui::PushID(vehicle);
if (ImGui::Button(label.c_str())) {
ui_panel *panel = new vehicleparams_panel(vehicle->name());
m_parent.add_owned_panel(panel);
}
ImGui::PopID();
}
}

View File

@@ -4,8 +4,10 @@ namespace ui
{
class vehiclelist_panel : public ui_panel
{
ui_layer &m_parent;
public:
vehiclelist_panel() : ui_panel("Vehicle list", true) {}
vehiclelist_panel(ui_layer &parent);
void render_contents() override;
};

View File

@@ -5,17 +5,14 @@
#include "Driver.h"
#include "Train.h"
ui::vehicleparams_panel::vehicleparams_panel()
: ui_panel(LOC_STR(vehicleparams_window), false)
ui::vehicleparams_panel::vehicleparams_panel(const std::string &vehicle)
: ui_panel(std::string(LOC_STR(vehicleparams_window)) + ": " + vehicle, false), m_vehicle_name(vehicle)
{
}
void ui::vehicleparams_panel::render_contents()
{
if (m_vehicle_name.empty())
m_vehicle_name = simulation::Vehicles.sequence()[0]->name();
TDynamicObject *vehicle_ptr = simulation::Vehicles.find(m_vehicle_name);
if (!vehicle_ptr) {
is_open = false;
@@ -186,4 +183,12 @@ void ui::vehicleparams_panel::render_contents()
vehicle.GetPosition().z );
ImGui::TextUnformatted(buffer.data());
if (ImGui::Button(LOC_STR(vehicleparams_radiostop)))
m_relay.post(user_command::radiostop, 0.0, 0.0, GLFW_PRESS, 0, vehicle_ptr->GetPosition());
ImGui::SameLine();
if (ImGui::Button(LOC_STR(vehicleparams_reset)))
m_relay.post(user_command::resettrainset, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &vehicle_ptr->name());
}

View File

@@ -7,9 +7,10 @@ namespace ui
class vehicleparams_panel : public ui_panel
{
std::string m_vehicle_name;
command_relay m_relay;
public:
vehicleparams_panel();
vehicleparams_panel(const std::string &vehicle);
void render_contents() override;
};