mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 00:49:19 +02:00
work
This commit is contained in:
31
widgets/vehiclelist.cpp
Normal file
31
widgets/vehiclelist.cpp
Normal 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
10
widgets/vehiclelist.h
Normal 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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user