mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
move vehicle param window to vehicle list, add radiostop button
This commit is contained in:
@@ -129,7 +129,6 @@ set(SOURCES
|
||||
"widgets/popup.cpp"
|
||||
"widgets/time.cpp"
|
||||
"widgets/vehicleparams.cpp"
|
||||
"widgets/trainingcontrol.cpp"
|
||||
|
||||
"ref/glad/src/glad.c"
|
||||
|
||||
|
||||
6
DynObj.h
6
DynObj.h
@@ -479,10 +479,8 @@ private:
|
||||
int GetPneumatic(bool front, bool red);
|
||||
void SetPneumatic(bool front, bool red);
|
||||
std::string asName;
|
||||
std::string name() const {
|
||||
return this ?
|
||||
asName :
|
||||
std::string(); };
|
||||
const std::string &name() const {
|
||||
return asName; }
|
||||
std::string asBaseDir;
|
||||
|
||||
// std::ofstream PneuLogFile; //zapis parametrow pneumatycznych
|
||||
|
||||
@@ -5013,7 +5013,7 @@ void TTrain::vehiclemove(float distance) {
|
||||
while( d ) {
|
||||
d->Move( distance * d->DirectionGet() );
|
||||
d = d->Next(); // pozostałe też
|
||||
}
|
||||
}
|
||||
d = DynamicObject->Prev();
|
||||
while( d ) {
|
||||
d->Move( distance * d->DirectionGet() );
|
||||
|
||||
@@ -229,6 +229,7 @@ commanddescription_sequence Commands_descriptions = {
|
||||
{ "motorblowersdisableall", command_target::vehicle, command_mode::oneoff },
|
||||
{ "coolingfanstoggle", command_target::vehicle, command_mode::oneoff },
|
||||
{ "tempomattoggle", command_target::vehicle, command_mode::oneoff },
|
||||
{ "globalradiostop", command_target::simulation, command_mode::oneoff },
|
||||
{ "timejump", command_target::simulation, command_mode::oneoff },
|
||||
{ "timejumplarge", command_target::simulation, command_mode::oneoff },
|
||||
{ "timejumpsmall", command_target::simulation, command_mode::oneoff },
|
||||
@@ -243,6 +244,7 @@ commanddescription_sequence Commands_descriptions = {
|
||||
{ "focuspauseset", command_target::simulation, command_mode::oneoff },
|
||||
{ "pausetoggle", command_target::simulation, command_mode::oneoff },
|
||||
{ "entervehicle", command_target::simulation, command_mode::oneoff },
|
||||
{ "resettrainset", command_target::simulation, command_mode::oneoff },
|
||||
{ "queueevent", command_target::simulation, command_mode::oneoff },
|
||||
{ "setlight", command_target::simulation, command_mode::oneoff },
|
||||
{ "insertmodel", command_target::simulation, command_mode::oneoff },
|
||||
|
||||
@@ -223,6 +223,7 @@ enum class user_command {
|
||||
coolingfanstoggle,
|
||||
tempomattoggle,
|
||||
|
||||
radiostop,
|
||||
timejump,
|
||||
timejumplarge,
|
||||
timejumpsmall,
|
||||
@@ -237,6 +238,7 @@ enum class user_command {
|
||||
focuspauseset,
|
||||
pausetoggle,
|
||||
entervehicle,
|
||||
resettrainset,
|
||||
queueevent,
|
||||
setlight,
|
||||
insertmodel,
|
||||
|
||||
@@ -22,17 +22,16 @@ driver_ui::driver_ui() {
|
||||
|
||||
clear_panels();
|
||||
// bind the panels with ui object. maybe not the best place for this but, eh
|
||||
push_back( &m_aidpanel );
|
||||
push_back( &m_scenariopanel );
|
||||
push_back( &m_timetablepanel );
|
||||
push_back( &m_debugpanel );
|
||||
push_back( &m_transcriptspanel );
|
||||
add_external_panel( &m_aidpanel );
|
||||
add_external_panel( &m_scenariopanel );
|
||||
add_external_panel( &m_timetablepanel );
|
||||
add_external_panel( &m_debugpanel );
|
||||
add_external_panel( &m_transcriptspanel );
|
||||
|
||||
//push_back( &m_vehiclelist );
|
||||
push_back( &m_vehicleparams );
|
||||
push_back( &m_timepanel );
|
||||
push_back( &m_mappanel );
|
||||
push_back( &m_logpanel );
|
||||
add_external_panel( &m_vehiclelist );
|
||||
add_external_panel( &m_timepanel );
|
||||
add_external_panel( &m_mappanel );
|
||||
add_external_panel( &m_logpanel );
|
||||
m_logpanel.is_open = false;
|
||||
|
||||
m_aidpanel.title = locale::strings[ locale::string::driver_aid_header ];
|
||||
@@ -57,14 +56,13 @@ void driver_ui::render_menu_contents() {
|
||||
{
|
||||
ImGui::MenuItem(m_aidpanel.title.c_str(), "F1", &m_aidpanel.is_open);
|
||||
ImGui::MenuItem(locale::strings[locale::string::driver_timetable_name].c_str(), "F2", &m_timetablepanel.is_open);
|
||||
ImGui::MenuItem(m_debugpanel.get_name().c_str(), "F12", &m_debugpanel.is_open);
|
||||
ImGui::MenuItem(m_mappanel.get_name().c_str(), "Tab", &m_mappanel.is_open);
|
||||
ImGui::MenuItem(m_debugpanel.name().c_str(), "F12", &m_debugpanel.is_open);
|
||||
ImGui::MenuItem(m_mappanel.name().c_str(), "Tab", &m_mappanel.is_open);
|
||||
ImGui::MenuItem(m_vehiclelist.name().c_str(), nullptr, &m_vehiclelist.is_open);
|
||||
|
||||
if (ImGui::MenuItem(m_timepanel.get_name().c_str()))
|
||||
if (ImGui::MenuItem(m_timepanel.name().c_str()))
|
||||
m_timepanel.open();
|
||||
|
||||
ImGui::MenuItem(m_vehicleparams.get_name().c_str(), nullptr, &m_vehicleparams.is_open);
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,7 @@ private:
|
||||
bool m_pause_modal_opened { false };
|
||||
|
||||
command_relay m_relay;
|
||||
ui::vehiclelist_panel m_vehiclelist;
|
||||
ui::vehicleparams_panel m_vehicleparams;
|
||||
ui::vehiclelist_panel m_vehiclelist { ui::vehiclelist_panel(*this) };
|
||||
ui::map_panel m_mappanel;
|
||||
ui::time_panel m_timepanel;
|
||||
};
|
||||
|
||||
@@ -195,9 +195,9 @@ scenario_panel::render() {
|
||||
}
|
||||
auto const panelname { (
|
||||
title.empty() ?
|
||||
name :
|
||||
m_name :
|
||||
title )
|
||||
+ "###" + name };
|
||||
+ "###" + m_name };
|
||||
if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
// potential assignment section
|
||||
auto const *owner { (
|
||||
@@ -442,9 +442,9 @@ debug_panel::render() {
|
||||
}
|
||||
auto const panelname { (
|
||||
title.empty() ?
|
||||
name :
|
||||
m_name :
|
||||
title )
|
||||
+ "###" + name };
|
||||
+ "###" + m_name };
|
||||
if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
// header section
|
||||
for( auto const &line : text_lines ) {
|
||||
@@ -1028,9 +1028,9 @@ transcripts_panel::render() {
|
||||
}
|
||||
auto const panelname { (
|
||||
title.empty() ?
|
||||
name :
|
||||
m_name :
|
||||
title )
|
||||
+ "###" + name };
|
||||
+ "###" + m_name };
|
||||
if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
// header section
|
||||
for( auto const &line : text_lines ) {
|
||||
|
||||
@@ -17,8 +17,8 @@ editor_ui::editor_ui() {
|
||||
|
||||
clear_panels();
|
||||
// bind the panels with ui object. maybe not the best place for this but, eh
|
||||
push_back( &m_itempropertiespanel );
|
||||
push_back( &m_nodebankpanel );
|
||||
add_external_panel( &m_itempropertiespanel );
|
||||
add_external_panel( &m_nodebankpanel );
|
||||
}
|
||||
|
||||
// potentially processes provided input key. returns: true if key was processed, false otherwise
|
||||
|
||||
@@ -253,9 +253,9 @@ itemproperties_panel::render() {
|
||||
}
|
||||
auto const panelname { (
|
||||
title.empty() ?
|
||||
name :
|
||||
m_name :
|
||||
title )
|
||||
+ "###" + name };
|
||||
+ "###" + m_name };
|
||||
if( true == ImGui::Begin( panelname.c_str(), nullptr, flags ) ) {
|
||||
// header section
|
||||
for( auto const &line : text_lines ) {
|
||||
|
||||
@@ -177,6 +177,32 @@ void state_manager::process_commands() {
|
||||
simulation::State.delete_model(simulation::Instances.find(commanddata.payload));
|
||||
}
|
||||
|
||||
if (commanddata.command == user_command::radiostop) {
|
||||
simulation::Region->RadioStop( commanddata.location );
|
||||
}
|
||||
|
||||
if (commanddata.command == user_command::resettrainset) {
|
||||
TDynamicObject *found_vehicle = simulation::Vehicles.find(commanddata.payload);
|
||||
TDynamicObject *vehicle = found_vehicle;
|
||||
|
||||
while (vehicle) {
|
||||
vehicle->MoverParameters->DamageFlag = 0;
|
||||
vehicle->MoverParameters->EngDmgFlag = 0;
|
||||
vehicle->MoverParameters->V = 0.0;
|
||||
vehicle->MoverParameters->DistCounter = 0.0;
|
||||
vehicle = vehicle->Next();
|
||||
}
|
||||
|
||||
vehicle = found_vehicle;
|
||||
while (vehicle) {
|
||||
vehicle->MoverParameters->DamageFlag = 0;
|
||||
vehicle->MoverParameters->EngDmgFlag = 0;
|
||||
vehicle->MoverParameters->V = 0.0;
|
||||
vehicle->MoverParameters->DistCounter = 0.0;
|
||||
vehicle = vehicle->Prev();
|
||||
}
|
||||
}
|
||||
|
||||
if (DebugModeFlag) {
|
||||
if (commanddata.command == user_command::timejump) {
|
||||
Time.update(commanddata.param1);
|
||||
|
||||
@@ -110,7 +110,11 @@ init() {
|
||||
"Insert obstacle:",
|
||||
"Delete obstacle",
|
||||
|
||||
"Vehicle list",
|
||||
|
||||
"Vehicle parameters",
|
||||
"Radiostop",
|
||||
"Reset trainset",
|
||||
|
||||
"master controller",
|
||||
"master controller",
|
||||
@@ -307,7 +311,11 @@ init() {
|
||||
u8"Wstaw przeszkodę:",
|
||||
u8"Usuń przeszkodę",
|
||||
|
||||
u8"Lista pojazdów",
|
||||
|
||||
u8"Parametry pojazdu",
|
||||
u8"Radiostop",
|
||||
u8"Zresetuj skład",
|
||||
|
||||
u8"nastawnik jazdy",
|
||||
u8"nastawnik jazdy",
|
||||
|
||||
@@ -99,7 +99,11 @@ enum string {
|
||||
map_obstacle_insert,
|
||||
map_obstacle_remove,
|
||||
|
||||
vehiclelist_window,
|
||||
|
||||
vehicleparams_window,
|
||||
vehicleparams_radiostop,
|
||||
vehicleparams_reset,
|
||||
|
||||
cab_mainctrl,
|
||||
cab_jointctrl,
|
||||
|
||||
31
uilayer.cpp
31
uilayer.cpp
@@ -29,7 +29,7 @@ GLFWwindow *ui_layer::m_window{nullptr};
|
||||
ImGuiIO *ui_layer::m_imguiio{nullptr};
|
||||
bool ui_layer::m_cursorvisible;
|
||||
|
||||
ui_panel::ui_panel(std::string const &Identifier, bool const Isopen) : name(Identifier), is_open(Isopen) {}
|
||||
ui_panel::ui_panel(std::string const &Identifier, bool const Isopen) : m_name(Identifier), is_open(Isopen) {}
|
||||
|
||||
void ui_panel::render()
|
||||
{
|
||||
@@ -49,7 +49,7 @@ void ui_panel::render()
|
||||
if (size_min.x > 0)
|
||||
ImGui::SetNextWindowSizeConstraints(ImVec2(size_min.x, size_min.y), ImVec2(size_max.x, size_max.y));
|
||||
|
||||
auto const panelname{(title.empty() ? name : title) + "###" + name};
|
||||
auto const panelname{(title.empty() ? m_name : title) + "###" + m_name};
|
||||
if (ImGui::Begin(panelname.c_str(), &is_open, flags)) {
|
||||
render_contents();
|
||||
|
||||
@@ -118,7 +118,7 @@ bool ui_layer::mouse_button_callback(int button, int action, int mods)
|
||||
ui_layer::ui_layer()
|
||||
{
|
||||
if (Global.loading_log)
|
||||
push_back(&m_logpanel);
|
||||
add_external_panel(&m_logpanel);
|
||||
m_logpanel.size = { 700, 400 };
|
||||
}
|
||||
|
||||
@@ -221,9 +221,13 @@ bool ui_layer::on_mouse_button(int const Button, int const Action)
|
||||
void ui_layer::update()
|
||||
{
|
||||
for (auto *panel : m_panels)
|
||||
{
|
||||
panel->update();
|
||||
}
|
||||
|
||||
for (auto it = m_ownedpanels.rbegin(); it != m_ownedpanels.rend(); it++) {
|
||||
(*it)->update();
|
||||
if (!(*it)->is_open)
|
||||
m_ownedpanels.erase(std::next(it).base());
|
||||
}
|
||||
}
|
||||
|
||||
void ui_layer::render()
|
||||
@@ -301,6 +305,19 @@ void ui_layer::set_background(std::string const &Filename)
|
||||
void ui_layer::clear_panels()
|
||||
{
|
||||
m_panels.clear();
|
||||
m_ownedpanels.clear();
|
||||
}
|
||||
|
||||
void ui_layer::add_owned_panel(ui_panel *Panel)
|
||||
{
|
||||
for (auto &panel : m_ownedpanels)
|
||||
if (panel->name() == Panel->name()) {
|
||||
delete Panel;
|
||||
return;
|
||||
}
|
||||
|
||||
Panel->is_open = true;
|
||||
m_ownedpanels.emplace_back( Panel );
|
||||
}
|
||||
|
||||
void ui_layer::render_progress()
|
||||
@@ -322,9 +339,9 @@ void ui_layer::render_progress()
|
||||
void ui_layer::render_panels()
|
||||
{
|
||||
for (auto *panel : m_panels)
|
||||
{
|
||||
panel->render();
|
||||
}
|
||||
for (auto &panel : m_ownedpanels)
|
||||
panel->render();
|
||||
}
|
||||
|
||||
void ui_layer::render_tooltip()
|
||||
|
||||
@@ -48,12 +48,12 @@ public:
|
||||
std::deque<text_line> text_lines;
|
||||
int window_flags = -1;
|
||||
|
||||
const std::string& get_name() { return name; }
|
||||
const std::string& name() { return m_name; }
|
||||
void register_popup(std::unique_ptr<ui::popup> &&popup);
|
||||
|
||||
protected:
|
||||
// members
|
||||
std::string name;
|
||||
std::string m_name;
|
||||
std::list<std::unique_ptr<ui::popup>> popups;
|
||||
};
|
||||
|
||||
@@ -128,7 +128,9 @@ public:
|
||||
void
|
||||
clear_panels();
|
||||
void
|
||||
push_back( ui_panel *Panel ) { m_panels.emplace_back( Panel ); }
|
||||
add_external_panel( ui_panel *Panel ) { m_panels.emplace_back( Panel ); }
|
||||
void
|
||||
add_owned_panel( ui_panel *Panel );
|
||||
|
||||
// callback functions for imgui input
|
||||
// returns true if input is consumed
|
||||
@@ -180,6 +182,7 @@ private:
|
||||
|
||||
texture_handle m_background { null_handle }; // path to texture used as the background. size depends on mAspect.
|
||||
std::vector<ui_panel *> m_panels;
|
||||
std::vector<std::unique_ptr<ui_panel>> m_ownedpanels;
|
||||
std::string m_tooltip;
|
||||
bool m_quit_active = false;
|
||||
};
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#include "widgets/trainingcontrol.h"
|
||||
|
||||
void ui::trainingcontrol_panel::render_contents() {
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#include "uilayer.h"
|
||||
|
||||
namespace ui
|
||||
{
|
||||
class trainingcontrol_panel : public ui_panel
|
||||
{
|
||||
public:
|
||||
void render_contents() override;
|
||||
};
|
||||
} // namespace ui
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user