diff --git a/Traction.cpp b/Traction.cpp index 70a4f55f..d0169b95 100644 --- a/Traction.cpp +++ b/Traction.cpp @@ -528,7 +528,7 @@ glm::vec3 TTraction::wire_color() const { glm::vec3 color; - if( false == DebugModeFlag ) { + if( false == DebugTractionFlag ) { switch( Material ) { // Ra: kolory podzieliłem przez 2, bo po zmianie ambient za jasne były // trzeba uwzględnić kierunek świecenia Słońca - tylko ze Słońcem widać kolor case 1: { diff --git a/TractionPower.h b/TractionPower.h index f19a087f..171f2879 100644 --- a/TractionPower.h +++ b/TractionPower.h @@ -15,6 +15,8 @@ http://mozilla.org/MPL/2.0/. class TTractionPowerSource : public scene::basic_node { + friend class debug_panel; + public: // constructor TTractionPowerSource( scene::node_data const &Nodedata ); diff --git a/driveruipanels.cpp b/driveruipanels.cpp index a748ec80..ecec98d7 100644 --- a/driveruipanels.cpp +++ b/driveruipanels.cpp @@ -16,6 +16,7 @@ http://mozilla.org/MPL/2.0/. #include "simulationtime.h" #include "Timer.h" #include "Event.h" +#include "TractionPower.h" #include "Camera.h" #include "mtable.h" #include "Train.h" @@ -476,6 +477,7 @@ debug_panel::update() { m_scantablelines.clear(); m_scenariolines.clear(); m_eventqueuelines.clear(); + m_powergridlines.clear(); m_cameralines.clear(); m_rendererlines.clear(); @@ -485,6 +487,7 @@ debug_panel::update() { update_section_scantable( m_scantablelines ); update_section_scenario( m_scenariolines ); update_section_eventqueue( m_eventqueuelines ); + update_section_powergrid( m_powergridlines ); update_section_camera( m_cameralines ); update_section_renderer( m_rendererlines ); } @@ -526,6 +529,10 @@ debug_panel::render() { // event queue filter ImGui::Checkbox( "By This Vehicle Only", &m_eventqueueactivevehicleonly ); } + if( true == render_section( "Power Grid", m_powergridlines ) ) { + // traction state debug + ImGui::Checkbox( "Debug Traction", &DebugTractionFlag ); + } render_section( "Camera", m_cameralines ); render_section( "Gfx Renderer", m_rendererlines ); // toggles @@ -984,6 +991,46 @@ debug_panel::update_section_eventqueue( std::vector &Output ) { } } +void +debug_panel::update_section_powergrid( std::vector &Output ) { + + auto const lowpowercolor { glm::vec4( 164.0f / 255.0f, 132.0f / 255.0f, 84.0f / 255.0f, 1.f ) }; + auto const nopowercolor { glm::vec4( 164.0f / 255.0f, 84.0f / 255.0f, 84.0f / 255.0f, 1.f ) }; + + Output.emplace_back( "Name: Output: Timeout:", Global.UITextColor ); + + std::string textline; + + for( auto const *powerstation : simulation::Powergrid.sequence() ) { + + if( true == powerstation->bSection ) { continue; } + + auto const name { ( + powerstation->m_name.empty() ? + "(unnamed)" : + powerstation->m_name ) + + " " }; + + textline = + name.substr( 0, 20 ) + + " " + to_string( powerstation->OutputVoltage, 0, 5 ) + + " " + to_string( powerstation->FuseTimer, 1, 12 ) + + ( powerstation->FuseCounter == 0 ? + "" : + " (x" + to_string( powerstation->FuseCounter ) + ")" ); + + Output.emplace_back( + textline, + ( ( powerstation->FastFuse || powerstation->SlowFuse ) ? nopowercolor : + powerstation->OutputVoltage < ( 0.8 * powerstation->NominalVoltage ) ? lowpowercolor : + Global.UITextColor ) ); + } + + if( Output.size() == 1 ) { + Output.front().data = "(no power stations)"; + } +} + void debug_panel::update_section_camera( std::vector &Output ) { diff --git a/driveruipanels.h b/driveruipanels.h index 7c075562..ddd4eff2 100644 --- a/driveruipanels.h +++ b/driveruipanels.h @@ -87,6 +87,7 @@ private: void update_section_scantable( std::vector &Output ); void update_section_scenario( std::vector &Output ); void update_section_eventqueue( std::vector &Output ); + void update_section_powergrid( std::vector &Output ); void update_section_camera( std::vector &Output ); void update_section_renderer( std::vector &Output ); // section update helpers @@ -105,6 +106,7 @@ private: m_cameralines, m_scenariolines, m_eventqueuelines, + m_powergridlines, m_rendererlines; int tprev { 0 }; // poprzedni czas double VelPrev { 0.0 }; // poprzednia prędkość diff --git a/utilities.cpp b/utilities.cpp index 4c9953b1..5393d28e 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -31,6 +31,7 @@ bool DebugModeFlag = false; bool FreeFlyModeFlag = false; bool EditorModeFlag = false; bool DebugCameraFlag = false; +bool DebugTractionFlag = false; double Max0R(double x1, double x2) { diff --git a/utilities.h b/utilities.h index 1c930f7a..85734f37 100644 --- a/utilities.h +++ b/utilities.h @@ -38,6 +38,7 @@ extern bool DebugModeFlag; extern bool FreeFlyModeFlag; extern bool EditorModeFlag; extern bool DebugCameraFlag; +extern bool DebugTractionFlag; /*funkcje matematyczne*/ double Max0R(double x1, double x2);