16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 00:49:19 +02:00
This commit is contained in:
milek7
2019-01-02 22:31:46 +01:00
parent 1cad7ad297
commit b1cb4ad1ea
24 changed files with 462 additions and 173 deletions

31
widgets/vehiclelist.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include "widgets/vehiclelist.h"
#include "simulation.h"
#include "imgui/imgui.h"
#include "Driver.h"
void ui::vehiclelist_panel::render_contents() {
for (const TDynamicObject* vehicle : simulation::Vehicles.sequence()) {
if (vehicle->Prev())
continue;
std::string name = vehicle->name();
double speed = vehicle->GetVelocity();
std::string timetable;
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();
}
}
ImGui::ShowDemoWindow();
}

10
widgets/vehiclelist.h Normal file
View File

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