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

@@ -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();
}
}