mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 03:59:19 +02:00
Fix/sonar maintainability rebased (#209)
* refactor(sonar): use override instead of redundant virtual (cpp:S3471) * refactor(sonar): remove empty statements, one declaration per statement (cpp:S1116, cpp:S1659) * refactor(sonar): drop redundant lambda return types (cpp:S3574) * refactor(sonar): prefer using over typedef (cpp:S5416) * refactor(sonar): use =default for trivial special members (cpp:S3490) * refactor(sonar): use nullptr literal (cpp:S4962) * refactor(sonar): remove redundant access specifiers (cpp:S3539) * refactor(sonar): remove redundant casts (cpp:S1905) * refactor(sonar): use std::scoped_lock instead of std::lock_guard (cpp:S5997) * refactor(sonar): construct elements in place with emplace_back (cpp:S6003) * refactor(sonar): make narrowing conversions explicit (cpp:S5276) * refactor(sonar): mark unused parameters (cpp:S1172) Unused names are commented out; parameters used only on some platforms are marked [[maybe_unused]]. * refactor(sonar): declare non-mutating member functions const (cpp:S5817) Virtual functions are left untouched so overrides keep matching. * refactor(sonar): merge collapsible nested if statements (cpp:S1066) Comments that preceded the inner if are kept above the merged statement. * refactor(sonar): scope single-use variables in if init-statements (cpp:S6004) * fix(sonar): give polymorphic base classes virtual destructors (cpp:S1235) * refactor(sonar): use try_emplace for map insertion (cpp:S6030) * refactor(sonar): use auto where the type is spelled out on the right (cpp:S5827) * refactor(sonar): remove redundant parentheses (cpp:S1110) * refactor(sonar): document intentionally empty functions (cpp:S1186) * refactor(sonar): remove dead stores (cpp:S1854) Side effects (e.g. LISTLINE++) are kept. * refactor(sonar): remove unused variables, captures and private fields (cpp:S1481, cpp:S1068) * refactor(sonar): use structured bindings for pair access (cpp:S6005) * refactor(sonar): use range-based loops and ranges algorithms (cpp:S5566) * refactor(sonar): split chained assignments (cpp:S1121) * refactor(sonar): add default cases to switch statements (cpp:S3562) * refactor(sonar): use std::size for array lengths (cpp:S7127) * refactor(sonar): use std::ranges algorithms and std::erase(_if) (cpp:S6197) * refactor(sonar): access static members through the class (cpp:S2209) * refactor(sonar): add braces around nested if-else (cpp:S5261) * refactor(sonar): avoid side effects inside typeid operands (cpp:S5279) * refactor(sonar): drop top-level const from by-value return types (cpp:S5951) * refactor(sonar): declare variables separately from their type definitions (cpp:S3646) * refactor(sonar): declare loop counters in the for statement (cpp:S5955) * refactor(sonar): rely on class template argument deduction (cpp:S6012) * refactor(sonar): inherit base constructors instead of forwarding them (cpp:S5952) * refactor(sonar): rename locals that shadow outer declarations (cpp:S1117) Only local variables and definition parameters are renamed; shadowing struct fields and enumerators in headers are left for a separate change. * refactor(sonar): reduce enum qualification with using enum (cpp:S6177) Applied only where no unqualified name in the block could be captured by the introduced enumerators. * refactor(sonar): mark converting constructors explicit (cpp:S1709) sound_source and the gl::object conversion operators stay implicit; they are relied upon by copy-list-initialisation and GL calls. * refactor(sonar): initialise members in initialiser lists or declarations (cpp:S3230) * refactor(sonar): make read-only local references and pointers const (cpp:S5350) * refactor(sonar): take read-only pointer and reference parameters as const (cpp:S995) TTrain command handlers keep their signature, it is fixed by the handler table. * refactor(sonar): pass expensive-to-copy parameters by const reference (cpp:S1238) Signatures declared in files touched by PR 206 (Driver.h, EU07.cpp) and virtual overrides are left unchanged. * refactor(sonar): use transparent comparators for string-keyed maps (cpp:S6045) std::unordered_map instances and map types exposed in headers used by other modules are left as they are. * fix(sonar): do not use UI text as a printf format string (cpp:S5281) Text lines containing '%' would otherwise be interpreted as format specifiers by ImGui::TextColored. * refactor(sonar): use std::bind_front for callbacks (cpp:S5995) * refactor(sonar): drop const_cast on string literals passed to the Python C API (cpp:S859) * refactor(sonar): take read-only string parameters as std::string_view (cpp:S6009) The Windows messaging helpers keep std::string, they need c_str(). * refactor(sonar): make read-only global tables const (cpp:S5421) Mutable global state (flags, timers, singletons) is left as is. * refactor(sonar): replace single-case switch statements with if (cpp:S1301) * refactor(sonar): format UUIDs and log timestamps with std::format (cpp:S6494, cpp:S5945) * refactor(sonar): use std::array for local fixed-size arrays (cpp:S5945) Arrays that are class members or part of headers are left unchanged. * fix(sonar): test the bearing damage bit, not bit 0 (cpp:S872) 'DamageFlag & dtrain_bearing > 0' parsed as 'DamageFlag & (dtrain_bearing > 0)', i.e. DamageFlag & 1, so bearing friction reacted to the wrong damage flag. * refactor(sonar): assorted small fixes - empty() instead of size() comparisons (cpp:S1155) - member initialisers in declaration order (cpp:S3229) - no redundant c_str() when a std::string is accepted (cpp:S7121) - contains() on associative containers (cpp:S6171) - const reference instead of a copying range-for (cpp:S6032) - starts_with() for prefix checks (cpp:S6178) - no std::move on temporaries (cpp:S5274) - has_value() on std::optional (cpp:S7172) - bool literals for bool members (cpp:S5820) - inline only on the definition (cpp:S3548) - explicit base access specifier (cpp:S5965) - explicit element access instead of dereferencing an array (cpp:S7116) - rely on the C++20 rewritten operator!= (cpp:S6186) * refactor(sonar): more small fixes - std::format instead of iostream manipulators in to_string/to_hex_str (cpp:S6495); output verified identical, negative hex values keep the unsigned form - remove an empty compound statement (cpp:S108) - drop an always-false unsigned < 0 branch (cpp:S1768) - explicit lambda capture (cpp:S3608) - std::make_unique (cpp:S5950) * chore: strip stray carriage returns left in TTrain constructor comments * fix: keep quantize() in its own value type The S5276 change cast the result of the generic quantize<Type_>() to unsigned int, which truncated float/double callers (shadow angle slider, editor rotation snapping, AI speed control steps) and broke negative values. * fix(sonar): use integer loop counters in segment sampling (cpp:S2193) * refactor(sonar): clean up issues reported on PR 209 - remove locals left unused after the dead-store cleanup (cpp:S1481, cpp:S1854) - unnamed unused parameter (cpp:S1172) - single-use declarations moved into if init-statements (cpp:S6004) - auto for casted initialisers (cpp:S5827) - const references and pointers where nothing is modified (cpp:S5350) - rename structured bindings shadowed by inner declarations (cpp:S1117)
This commit is contained in:
@@ -25,19 +25,19 @@ public:
|
||||
virtual bool update() = 0;
|
||||
// draws mode-specific user interface
|
||||
inline
|
||||
void render_ui() {
|
||||
void render_ui() const {
|
||||
if( m_userinterface != nullptr ) {
|
||||
m_userinterface->render(); } }
|
||||
inline
|
||||
void begin_ui_frame() {
|
||||
void begin_ui_frame() const {
|
||||
if( m_userinterface != nullptr ) {
|
||||
m_userinterface->begin_ui_frame(); } }
|
||||
inline
|
||||
void set_progress( float const Progress = 0.f, float const Subtaskprogress = 0.f ) {
|
||||
void set_progress( float const Progress = 0.f, float const Subtaskprogress = 0.f ) const {
|
||||
if( m_userinterface != nullptr ) {
|
||||
m_userinterface->set_progress( Progress, Subtaskprogress ); } }
|
||||
inline
|
||||
void set_tooltip( std::string const &Tooltip ) {
|
||||
void set_tooltip( std::string const &Tooltip ) const {
|
||||
if( m_userinterface != nullptr ) {
|
||||
m_userinterface->set_tooltip( Tooltip ); } }
|
||||
// maintenance method, called when the mode is activated
|
||||
|
||||
@@ -38,7 +38,7 @@ void
|
||||
TController::remove_hint( driver_hint const Value ) {
|
||||
|
||||
m_hints.remove_if(
|
||||
[=]( auto const &Hint ) {
|
||||
[Value]( auto const &Hint ) {
|
||||
return std::get<driver_hint>(Hint) == Value; } );
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::batteryoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->BatteryStart != start_t::manual || mvOccupied->Power24vIsAvailable == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::batteryon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->BatteryStart != start_t::manual || mvOccupied->Power24vIsAvailable == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::cabdeactivation );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->AutomaticCabActivation || mvOccupied->IsCabMaster(); } );
|
||||
break;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::cabactivation );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->AutomaticCabActivation || (mvOccupied->CabMaster == false && mvOccupied->CabActive == 0); } );
|
||||
break;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::radiooff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->Radio == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -144,7 +144,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
}
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const Parameter) {
|
||||
return iRadioChannel == static_cast<int>(Parameter); },
|
||||
Actionparameter );
|
||||
break;
|
||||
@@ -156,7 +156,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::radioon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->Radio == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::oilpumpoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvOccupied->OilPump };
|
||||
return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true || mvOccupied->Mains; } );
|
||||
break;
|
||||
@@ -180,7 +180,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::oilpumpon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvOccupied->OilPump };
|
||||
return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
|
||||
break;
|
||||
@@ -193,7 +193,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::fuelpumpoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvOccupied->FuelPump };
|
||||
return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true; } );
|
||||
break;
|
||||
@@ -205,7 +205,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::fuelpumpon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvOccupied->FuelPump };
|
||||
return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
|
||||
break;
|
||||
@@ -218,7 +218,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::pantographairsourcesetauxiliary );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvPantographUnit->bPantKurek3 == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::pantographcompressoron );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvPantographUnit->bPantKurek3 == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::pantographcompressoroff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvPantographUnit->PantCompFlag == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -251,7 +251,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::pantographcompressoron );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvPantographUnit->PantCompFlag == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::pantographsvalveoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvPantographUnit->PantsValve.is_active == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -273,7 +273,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::frontpantographvalveoff );
|
||||
hint(
|
||||
Action,
|
||||
[ this ]( float const Parameter ) -> bool {
|
||||
[ this ]( float const Parameter ) {
|
||||
return mvPantographUnit->Pantographs[end::front].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); },
|
||||
Actionparameter );
|
||||
break;
|
||||
@@ -285,7 +285,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::frontpantographvalveon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvPantographUnit->Pantographs[end::front].valve.is_active == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::rearpantographvalveoff );
|
||||
hint(
|
||||
Action,
|
||||
[ this ]( float const Parameter ) -> bool {
|
||||
[ this ]( float const Parameter ) {
|
||||
return mvPantographUnit->Pantographs[end::rear].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); },
|
||||
Actionparameter );
|
||||
break;
|
||||
@@ -308,7 +308,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::rearpantographvalveon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvPantographUnit->Pantographs[end::rear].valve.is_active == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -320,7 +320,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::converteroff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyConverterEnabled == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -331,7 +331,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::converteron );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyConverterExplicitlyEnabled == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -342,7 +342,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
}
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->ConverterOverloadRelayStart != start_t::manual || mvOccupied->ConvOvldFlag == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -352,7 +352,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
}
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->GroundRelayStart != start_t::manual || mvOccupied->GroundRelay == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
}
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->FuseFlag == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -374,7 +374,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::linebreakeropen );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyLineBreakerOpen == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -385,7 +385,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::linebreakerclose );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
// TBD, TODO: replace with consist-wide flag set true if any line breaker is closed?
|
||||
return mvControlling->Mains == false; } );
|
||||
break;
|
||||
@@ -398,7 +398,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::compressoroff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyCompressorEnabled == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -409,7 +409,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::compressoron );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyCompressorExplicitlyEnabled == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -421,7 +421,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::frontmotorblowersoff );
|
||||
hint(
|
||||
Action,
|
||||
[this]( float const Parameter ) -> bool {
|
||||
[this]( float const /*Parameter*/ ) {
|
||||
auto const &device { mvOccupied->MotorBlowers[ end::front ] };
|
||||
return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } );
|
||||
break;
|
||||
@@ -434,7 +434,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::rearmotorblowersoff );
|
||||
hint(
|
||||
Action,
|
||||
[this]( float const Parameter ) -> bool {
|
||||
[this]( float const /*Parameter*/ ) {
|
||||
auto const &device { mvOccupied->MotorBlowers[ end::rear ] };
|
||||
return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } );
|
||||
break;
|
||||
@@ -447,7 +447,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::springbrakeoff );
|
||||
hint(
|
||||
Action,
|
||||
[this]( float const Parameter ) -> bool {
|
||||
[this]( float const /*Parameter*/ ) {
|
||||
return mvOccupied->SpringBrake.Activate == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -458,7 +458,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::springbrakeon );
|
||||
hint(
|
||||
Action,
|
||||
[this]( float const Parameter ) -> bool {
|
||||
[this]( float const /*Parameter*/ ) {
|
||||
return mvOccupied->SpringBrake.Activate == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -470,7 +470,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::manualbrakoff );
|
||||
hint(
|
||||
Action,
|
||||
[this]( float const Parameter ) -> bool {
|
||||
[this]( float const /*Parameter*/ ) {
|
||||
return mvOccupied->LocalBrake != TLocalBrake::ManualBrake || mvOccupied->MBrake == false || mvOccupied->ManualBrakePos == ManualBrakePosNo; } );
|
||||
break;
|
||||
}
|
||||
@@ -481,7 +481,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::manualbrakon );
|
||||
hint(
|
||||
Action,
|
||||
[this]( float const Parameter ) -> bool {
|
||||
[this]( float const /*Parameter*/ ) {
|
||||
return mvOccupied->LocalBrake != TLocalBrake::ManualBrake || mvOccupied->MBrake == false || mvOccupied->ManualBrakePos == 0; } );
|
||||
break;
|
||||
}
|
||||
@@ -490,33 +490,31 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
if( AIControllFlag ) {
|
||||
while( mvControlling->RList[mvControlling->MainCtrlPos].Mn == 0
|
||||
&& mvControlling->IncMainCtrl(1) ) {
|
||||
;
|
||||
// all work is done in the loop header
|
||||
}
|
||||
}
|
||||
remove_master_controller_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this]( float const Parameter ) -> bool {
|
||||
[this]( float const /*Parameter*/ ) {
|
||||
return mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0; } );
|
||||
break;
|
||||
}
|
||||
case driver_hint::mastercontrollersetseriesmode: {
|
||||
if( AIControllFlag ) {
|
||||
if( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 ) {
|
||||
// limit yourself to series mode
|
||||
if( mvControlling->ScndCtrlPos ) {
|
||||
mvControlling->DecScndCtrl( 2 );
|
||||
}
|
||||
while( mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1
|
||||
&& mvControlling->DecMainCtrl(1) ) {
|
||||
; // all work is performed in the header
|
||||
}
|
||||
if (AIControllFlag && mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1) {
|
||||
// limit yourself to series mode
|
||||
if( mvControlling->ScndCtrlPos ) {
|
||||
mvControlling->DecScndCtrl( 2 );
|
||||
}
|
||||
while( mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1
|
||||
&& mvControlling->DecMainCtrl(1) ) {
|
||||
// all work is performed in the header
|
||||
}
|
||||
}
|
||||
remove_master_controller_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this]( float const Parameter ) -> bool {
|
||||
[this]( float const /*Parameter*/ ) {
|
||||
return mvControlling->RList[mvControlling->MainCtrlPos].Bn < 2; } );
|
||||
break;
|
||||
}
|
||||
@@ -527,7 +525,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_master_controller_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvControlling->IsMainCtrlNoPowerPos() && mvControlling->IsScndCtrlNoPowerPos(); } );
|
||||
break;
|
||||
}
|
||||
@@ -535,15 +533,15 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
if( AIControllFlag ) {
|
||||
while( false == mvControlling->EIMDirectionChangeAllow()
|
||||
&& mvControlling->DecMainCtrl(1) ) {
|
||||
;
|
||||
// all work is done in the loop header
|
||||
}
|
||||
}
|
||||
remove_master_controller_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvControlling->EIMDirectionChangeAllow(); },
|
||||
mvControlling->MainCtrlMaxDirChangePos );
|
||||
static_cast<float>(mvControlling->MainCtrlMaxDirChangePos) );
|
||||
break;
|
||||
}
|
||||
case driver_hint::tractiveforcedecrease: {
|
||||
@@ -553,13 +551,13 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_master_controller_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const Parameter) {
|
||||
return std::abs(mvControlling->Ft) <= Parameter; },
|
||||
std::min(
|
||||
static_cast<float>(std::min(
|
||||
0.0,
|
||||
std::max(
|
||||
std::abs( mvControlling->Ft ) * 0.95,
|
||||
std::abs( mvControlling->Ft ) - 5.0 ) ) );
|
||||
std::abs( mvControlling->Ft ) - 5.0 ) )) );
|
||||
break;
|
||||
}
|
||||
case driver_hint::tractiveforceincrease: {
|
||||
@@ -575,21 +573,19 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
}
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return AccDesired <= EU07_AI_NOACCELERATION || (false == Ready && false == mvOccupied->ShuntMode) || AccDesired - AbsAccS <= 0.05 ||
|
||||
(mvOccupied->EIMCtrlType > 0 ? mvControlling->eimic_real >= 1.0 : mvControlling->IsScndCtrlMaxPowerPos() && mvControlling->IsMainCtrlMaxPowerPos()); } );
|
||||
break;
|
||||
}
|
||||
case driver_hint::bufferscompress: {
|
||||
if( AIControllFlag ) {
|
||||
if( std::abs( mvControlling->Ft ) < 50000.0 ) {
|
||||
IncSpeed();
|
||||
}
|
||||
if (AIControllFlag && std::abs( mvControlling->Ft ) < 50000.0) {
|
||||
IncSpeed();
|
||||
}
|
||||
remove_master_controller_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return std::abs(mvControlling->Ft) > 30.0 || (OrderCurrentGet() & Disconnect) == 0; } );
|
||||
break;
|
||||
}
|
||||
@@ -601,7 +597,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_master_controller_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvControlling->IsScndCtrlNoPowerPos(); } );
|
||||
break;
|
||||
}
|
||||
@@ -613,7 +609,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::waterpumpoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvControlling->WaterPump };
|
||||
return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false) || device.is_active == true; } );
|
||||
break;
|
||||
@@ -625,7 +621,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::waterpumpon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvControlling->WaterPump };
|
||||
return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
|
||||
break;
|
||||
@@ -637,7 +633,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::waterpumpbreakeroff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvControlling->WaterPump };
|
||||
return device.breaker == true; } );
|
||||
break;
|
||||
@@ -649,7 +645,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::waterpumpbreakeron );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvControlling->WaterPump };
|
||||
return device.breaker == false; } );
|
||||
break;
|
||||
@@ -661,7 +657,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::waterheateroff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvControlling->WaterHeater };
|
||||
return device.is_enabled == true; } );
|
||||
break;
|
||||
@@ -673,7 +669,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::waterheateron );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvControlling->WaterHeater };
|
||||
return device.is_enabled == false; } );
|
||||
break;
|
||||
@@ -685,7 +681,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::waterheaterbreakeroff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvControlling->WaterHeater };
|
||||
return device.breaker == true; } );
|
||||
break;
|
||||
@@ -697,7 +693,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::waterheaterbreakeron );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvControlling->WaterHeater };
|
||||
return device.breaker == false; } );
|
||||
break;
|
||||
@@ -709,7 +705,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::watercircuitslinkoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvControlling->dizel_heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -720,7 +716,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::watercircuitslinkon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvControlling->dizel_heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -728,7 +724,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
// NOTE: this action doesn't have AI component
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return false == IsHeatingTemperatureTooLow; } );
|
||||
break;
|
||||
}
|
||||
@@ -736,7 +732,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
// NOTE: this action doesn't have AI component
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvControlling->ScndPipePress > 4.5 || mvControlling->VeselVolume == 0.0; } );
|
||||
break;
|
||||
}
|
||||
@@ -744,7 +740,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
// NOTE: this action doesn't have AI component
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvPantographUnit->PantPress >= (is_emu() ? (mvPantographUnit->PantPressLockActive ? 4.6 : 2.6) : 4.2); } );
|
||||
break;
|
||||
}
|
||||
@@ -752,7 +748,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
// NOTE: this action doesn't have AI component
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return ExchangeTime <= 0; } );
|
||||
break;
|
||||
}
|
||||
@@ -760,7 +756,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
// NOTE: this action doesn't have AI component
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAtPassengerStop == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -773,19 +769,16 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
// driver_hint_brakingforcesetzero
|
||||
// driver_hint_brakingforcelap
|
||||
case driver_hint::trainbrakesetpipeunlock: {
|
||||
if( AIControllFlag ) {
|
||||
if( mvOccupied->HandleUnlock != -3 ) {
|
||||
while( BrakeCtrlPosition >= mvOccupied->HandleUnlock
|
||||
&& BrakeLevelAdd(-1) ) {
|
||||
// all work is done in the header
|
||||
;
|
||||
}
|
||||
if (AIControllFlag && mvOccupied->HandleUnlock != -3) {
|
||||
while( BrakeCtrlPosition >= mvOccupied->HandleUnlock
|
||||
&& BrakeLevelAdd(-1) ) {
|
||||
// all work is done in the header
|
||||
}
|
||||
}
|
||||
remove_train_brake_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->HandleUnlock == -3 || BrakeCtrlPosition == mvOccupied->HandleUnlock; } );
|
||||
break;
|
||||
}
|
||||
@@ -797,7 +790,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_train_brake_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2) || (mvOccupied->Handle->Time && mvOccupied->Handle->GetCP() > mvOccupied->HighPipePress - 0.05); } );
|
||||
// return ( BrakeCtrlPosition == gbh_RP ); } );
|
||||
break;
|
||||
@@ -815,7 +808,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_train_brake_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsConsistBraked /*|| ( ( OrderCurrentGet() & Disconnect ) == 0 ) */; } );
|
||||
break;
|
||||
}
|
||||
@@ -830,9 +823,9 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_train_brake_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const Parameter) {
|
||||
return std::abs(mvControlling->Fb) <= Parameter; },
|
||||
std::min( 0.0, 0.95 * std::abs( mvControlling->Fb ) ) ); // keep hint until 5% decrease
|
||||
static_cast<float>(std::min( 0.0, 0.95 * std::abs( mvControlling->Fb ) )) ); // keep hint until 5% decrease
|
||||
break;
|
||||
}
|
||||
case driver_hint::brakingforceincrease: {
|
||||
@@ -846,23 +839,25 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_train_brake_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const Parameter) {
|
||||
return std::abs(mvControlling->Fb) > Parameter || is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_EB), 0.2); },
|
||||
std::max(
|
||||
static_cast<float>(std::max(
|
||||
0.0,
|
||||
std::max(
|
||||
std::abs( mvControlling->Fb ) * 1.05,
|
||||
std::abs( mvControlling->Fb ) + 5.0 ) ) );
|
||||
std::abs( mvControlling->Fb ) + 5.0 ) )) );
|
||||
break;
|
||||
}
|
||||
case driver_hint::brakingforcesetzero: { // releases both train and independent brake
|
||||
if( AIControllFlag ) {
|
||||
while( true == DecBrake() ) { ; }
|
||||
while( true == DecBrake() ) {
|
||||
// all work is done in the loop condition
|
||||
}
|
||||
}
|
||||
remove_train_brake_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return Ready && fReady < 0.4 && is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2); } );
|
||||
break;
|
||||
}
|
||||
@@ -877,18 +872,16 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
}
|
||||
// independent brake
|
||||
case driver_hint::independentbrakeapply: {
|
||||
if( AIControllFlag ) {
|
||||
if( mvOccupied->LocalBrakePosA < 1.0 ) {
|
||||
mvOccupied->IncLocalBrakeLevel( LocalBrakePosNo );
|
||||
if (mvOccupied->EIMCtrlEmergency) {
|
||||
mvOccupied->DecLocalBrakeLevel(1);
|
||||
if (AIControllFlag && mvOccupied->LocalBrakePosA < 1.0) {
|
||||
mvOccupied->IncLocalBrakeLevel( LocalBrakePosNo );
|
||||
if (mvOccupied->EIMCtrlEmergency) {
|
||||
mvOccupied->DecLocalBrakeLevel(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
remove_hint( driver_hint::independentbrakerelease );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const Parameter) {
|
||||
return mvOccupied->LocalBrakePosA >= Parameter; },
|
||||
( LocalBrakePosNo - ( mvOccupied->EIMCtrlEmergency ? 1 : 0 ) ) / LocalBrakePosNo );
|
||||
break;
|
||||
@@ -900,7 +893,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::independentbrakeapply );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->LocalBrakePosA < 0.05; } );
|
||||
break;
|
||||
}
|
||||
@@ -912,7 +905,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_reverser_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->DirActive * mvOccupied->CabActive > 0; } );
|
||||
break;
|
||||
}
|
||||
@@ -923,7 +916,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_reverser_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->DirActive * mvOccupied->CabActive < 0; } );
|
||||
break;
|
||||
}
|
||||
@@ -936,7 +929,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_reverser_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return iDirection == iDirectionOrder; } );
|
||||
break;
|
||||
}
|
||||
@@ -947,7 +940,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_reverser_hints();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->DirActive == 0; } );
|
||||
break;
|
||||
}
|
||||
@@ -959,7 +952,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::sandingoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvControlling->Sand == 0 || mvControlling->SandDose == true || mvControlling->SlippingWheels == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -970,7 +963,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::sandingon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvControlling->Sand == 0 || mvControlling->SandDose == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -980,7 +973,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
}
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvControlling->ASBType != 1 || (mvControlling->Hamulec->GetBrakeStatus() & b_asb) != 0 || mvControlling->SlippingWheels == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -992,7 +985,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::hornoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
// NOTE: we provide slightly larger horn activation window for human driver
|
||||
return fWarningDuration + 5.0 < 0.05 || mvOccupied->WarningSignal != 0; } );
|
||||
break;
|
||||
@@ -1019,7 +1012,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
// TODO: remove other door lock hints
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->Doors.has_lock == false || mvOccupied->Doors.lock_enabled == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -1031,7 +1024,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::departuresignaloff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->Doors.has_warning == false || mvOccupied->Doors.has_autowarning == true || mvOccupied->DepartureSignal == true || mvOccupied->Vel > 5.0; } );
|
||||
break;
|
||||
}
|
||||
@@ -1042,7 +1035,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::departuresignalon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->Doors.has_warning == false || mvOccupied->Doors.has_autowarning == true || mvOccupied->DepartureSignal == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -1055,7 +1048,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::doorrightclose );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyDoorOpen[side::right] == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -1067,7 +1060,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::doorrightopen );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyDoorOpen[side::right] == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -1079,7 +1072,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::doorleftclose );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyDoorOpen[side::left] == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -1091,7 +1084,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::doorleftopen );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyDoorOpen[side::left] == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -1102,7 +1095,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::doorrightpermitoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyDoorPermitActive[side::right] == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -1113,7 +1106,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::doorrightpermiton );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyDoorPermitActive[side::right] == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -1124,7 +1117,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::doorleftpermitoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyDoorPermitActive[side::left] == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -1135,7 +1128,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::doorleftpermiton );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return IsAnyDoorPermitActive[side::left] == false; } );
|
||||
break;
|
||||
}
|
||||
@@ -1148,7 +1141,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::consistlightsoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvOccupied->CompartmentLights };
|
||||
return Global.fLuminance * ConsistShade > 0.40 || device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false) || device.is_active == true; } );
|
||||
break;
|
||||
@@ -1161,7 +1154,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::consistlightson );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const &device { mvOccupied->CompartmentLights };
|
||||
return Global.fLuminance * ConsistShade < 0.35 || device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
|
||||
break;
|
||||
@@ -1174,7 +1167,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::consistheatingoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->HeatingAllow == true; } );
|
||||
break;
|
||||
}
|
||||
@@ -1185,52 +1178,48 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::consistheatingon );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return mvOccupied->HeatingAllow == false; } );
|
||||
break;
|
||||
}
|
||||
|
||||
case driver_hint::securitysystemreset: {
|
||||
if( AIControllFlag ) {
|
||||
if (mvOccupied->SecuritySystem.is_blinking())
|
||||
mvOccupied->SecuritySystemReset();
|
||||
}
|
||||
if (AIControllFlag && mvOccupied->SecuritySystem.is_blinking())
|
||||
mvOccupied->SecuritySystemReset();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return !mvOccupied->SecuritySystem.is_vigilance_blinking(); } );
|
||||
break;
|
||||
}
|
||||
case driver_hint::shpsystemreset: {
|
||||
if( AIControllFlag ) {
|
||||
if (mvOccupied->SecuritySystem.is_cabsignal_blinking())
|
||||
mvOccupied->SecuritySystem.cabsignal_reset();
|
||||
}
|
||||
if (AIControllFlag && mvOccupied->SecuritySystem.is_cabsignal_blinking())
|
||||
mvOccupied->SecuritySystem.cabsignal_reset();
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return !mvOccupied->SecuritySystem.is_cabsignal_blinking(); } );
|
||||
break;
|
||||
}
|
||||
case driver_hint::couplingadapterattach: {
|
||||
// TODO: run also for potential settings-based virtual assistant
|
||||
if( AIControllFlag ) {
|
||||
pVehicles[ end::front ]->attach_coupler_adapter( Actionparameter );
|
||||
pVehicles[ end::front ]->attach_coupler_adapter( static_cast<int>(Actionparameter) );
|
||||
}
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const Parameter) {
|
||||
auto const &device { pVehicles[ end::front ]->MoverParameters->Couplers[ static_cast<int>( Parameter ) ] };
|
||||
return device.type() == TCouplerType::Automatic; } );
|
||||
break;
|
||||
}
|
||||
case driver_hint::couplingadapterremove: {
|
||||
if( AIControllFlag || Global.AITrainman ) {
|
||||
pVehicles[ end::front ]->remove_coupler_adapter( Actionparameter );
|
||||
pVehicles[ end::front ]->remove_coupler_adapter( static_cast<int>(Actionparameter) );
|
||||
}
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const Parameter) {
|
||||
auto const &device { pVehicles[ end::front ]->MoverParameters->Couplers[ static_cast<int>( Parameter ) ] };
|
||||
return false == device.has_adapter(); } );
|
||||
break;
|
||||
@@ -1245,7 +1234,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::lightsoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return pVehicles[end::front]->has_signal_pc1_on(); } );
|
||||
break;
|
||||
}
|
||||
@@ -1258,7 +1247,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::lightsoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return pVehicles[end::front]->has_signal_pc2_on(); } );
|
||||
break;
|
||||
}
|
||||
@@ -1275,7 +1264,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::lightsoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const activeend { mvOccupied->CabActive >= 0 ? end::front : end::rear };
|
||||
auto const consistfront { mvOccupied->DirActive >= 0 ? end::front : end::rear };
|
||||
return pVehicles[consistfront]->has_signal_on(activeend, light::headlight_right) && pVehicles[1 - consistfront]->has_signal_on(1 - activeend, light::headlight_left); } );
|
||||
@@ -1290,7 +1279,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::lightsoff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return pVehicles[end::rear]->has_signal_pc5_on(); } );
|
||||
break;
|
||||
}
|
||||
@@ -1304,7 +1293,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::headcodetb1 );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
auto const activeend { mvOccupied->CabActive >= 0 ? end::front : end::rear };
|
||||
auto const consistfront { mvOccupied->DirActive >= 0 ? end::front : end::rear };
|
||||
return pVehicles[consistfront]->has_signal_on(activeend, 0) && pVehicles[1 - consistfront]->has_signal_on(1 - activeend, 0); } );
|
||||
@@ -1318,7 +1307,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::releaseroff );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return true == mvOccupied->Hamulec->Releaser(); } );
|
||||
break;
|
||||
}
|
||||
@@ -1329,7 +1318,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
remove_hint( driver_hint::releaseron );
|
||||
hint(
|
||||
Action,
|
||||
[this](float const Parameter) -> bool {
|
||||
[this](float const /*Parameter*/) {
|
||||
return false == mvOccupied->Hamulec->Releaser(); } );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ enum class driver_hint {
|
||||
#ifdef DRIVER_HINT_CONTENT
|
||||
#define DRIVER_HINT_DEF(a, b) b,
|
||||
|
||||
const char *driver_hints_texts[] =
|
||||
const char *const driver_hints_texts[] =
|
||||
{
|
||||
#include "application/driverhints_def.h"
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ drivingaid_panel::update() {
|
||||
|| controlled->Mechanik == nullptr ) { return; }
|
||||
|
||||
auto const *mover = controlled->MoverParameters;
|
||||
auto const *driver = controlled->Mechanik;
|
||||
auto const *vehicledriver = controlled->Mechanik;
|
||||
auto const *owner = controlled->ctOwner != nullptr ? controlled->ctOwner : controlled->Mechanik;
|
||||
|
||||
{ // throttle, velocity, speed limits and grade
|
||||
@@ -61,8 +61,7 @@ drivingaid_panel::update() {
|
||||
// grade
|
||||
std::string gradetext;
|
||||
auto const reverser { ( mover->DirActive > 0 ? 1 : -1 ) };
|
||||
auto const grade { controlled->VectorFront().y * 100 * ( controlled->DirectionGet() == reverser ? 1 : -1 ) * reverser };
|
||||
if( std::abs( grade ) >= 0.25 ) {
|
||||
if( auto const grade { controlled->VectorFront().y * 100 * ( controlled->DirectionGet() == reverser ? 1 : -1 ) * reverser }; std::abs( grade ) >= 0.25 ) {
|
||||
std::snprintf(
|
||||
m_buffer.data(), m_buffer.size(),
|
||||
STR_C(" Grade: %.1f%%%%"),
|
||||
@@ -87,8 +86,7 @@ drivingaid_panel::update() {
|
||||
// then take into account speed change ahead, compare it with speed after potentially clearing last limit
|
||||
// lower of these two takes priority; otherwise limit lasts at least until potential last limit is cleared
|
||||
auto const noactivespeedlimit { owner->VelLimitLastDist.second < 0 };
|
||||
auto const speedatproximitydistance { min_speed( schedulespeedlimit, static_cast<int>( owner->VelNext ) ) };
|
||||
if( speedatproximitydistance == nextspeedlimit ) {
|
||||
if( auto const speedatproximitydistance { min_speed( schedulespeedlimit, static_cast<int>( owner->VelNext ) ) }; speedatproximitydistance == nextspeedlimit ) {
|
||||
if( noactivespeedlimit ) {
|
||||
nextspeedlimit = speedatproximitydistance;
|
||||
nextspeedlimitdistance = owner->ActualProximityDist;
|
||||
@@ -142,8 +140,8 @@ drivingaid_panel::update() {
|
||||
std::snprintf(
|
||||
m_buffer.data(), m_buffer.size(),
|
||||
STR_C("Throttle: %3d+%d %c%s"),
|
||||
mover->EIMCtrlType > 0 ? std::max(0, static_cast<int>(100.4 * mover->eimic_real)) : driver->Controlling()->MainCtrlPos,
|
||||
mover->EIMCtrlType > 0 ? driver->Controlling()->MainCtrlPos : driver->Controlling()->ScndCtrlPos,
|
||||
mover->EIMCtrlType > 0 ? std::max(0, static_cast<int>(100.4 * mover->eimic_real)) : vehicledriver->Controlling()->MainCtrlPos,
|
||||
mover->EIMCtrlType > 0 ? vehicledriver->Controlling()->MainCtrlPos : vehicledriver->Controlling()->ScndCtrlPos,
|
||||
mover->SpeedCtrlUnit.IsActive ? 'T' :
|
||||
mover->DirActive > 0 ? 'D' :
|
||||
mover->DirActive < 0 ? 'R' :
|
||||
@@ -253,12 +251,7 @@ scenario_panel::render() {
|
||||
if( size_min.x > 0 ) {
|
||||
ImGui::SetNextWindowSizeConstraints( ImVec2S( size_min.x, size_min.y ), ImVec2S( size_max.x, size_max.y ) );
|
||||
}
|
||||
auto const panelname { (
|
||||
title.empty() ?
|
||||
m_name :
|
||||
title )
|
||||
+ "###" + m_name };
|
||||
if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
if( auto const panelname { ( title.empty() ? m_name : title ) + "###" + m_name }; true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
// potential assignment section
|
||||
auto const *owner { (
|
||||
m_nearest->Mechanik != nullptr && m_nearest->Mechanik->primary() ?
|
||||
@@ -274,21 +267,19 @@ scenario_panel::render() {
|
||||
}
|
||||
// current task
|
||||
for( auto const &line : text_lines ) {
|
||||
ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() );
|
||||
ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), "%s", line.data.c_str() );
|
||||
}
|
||||
// hints
|
||||
if( owner != nullptr ) {
|
||||
if( true == ImGui::CollapsingHeader( STR_C("Hints"), ImGuiTreeNodeFlags_DefaultOpen ) ) {
|
||||
for( auto const &hint : owner->m_hints ) {
|
||||
auto const isdone { std::get<TController::hintpredicate>( hint )( std::get<float>( hint ) ) };
|
||||
auto const hintcolor{ (
|
||||
isdone ?
|
||||
colors::uitextgreen :
|
||||
Global.UITextColor ) };
|
||||
ImGui::PushStyleColor( ImGuiCol_Text, { hintcolor.r, hintcolor.g, hintcolor.b, hintcolor.a } );
|
||||
ImGui::TextWrapped( Translations.lookup_c(driver_hints_texts[(size_t)std::get<driver_hint>( hint )], true), std::get<float>( hint ) );
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
if (owner != nullptr && true == ImGui::CollapsingHeader( STR_C("Hints"), ImGuiTreeNodeFlags_DefaultOpen )) {
|
||||
for( auto const &hint : owner->m_hints ) {
|
||||
auto const isdone { std::get<TController::hintpredicate>( hint )( std::get<float>( hint ) ) };
|
||||
auto const hintcolor{ (
|
||||
isdone ?
|
||||
colors::uitextgreen :
|
||||
Global.UITextColor ) };
|
||||
ImGui::PushStyleColor( ImGuiCol_Text, { hintcolor.r, hintcolor.g, hintcolor.b, hintcolor.a } );
|
||||
ImGui::TextWrapped( Translations.lookup_c(driver_hints_texts[(size_t)std::get<driver_hint>( hint )], true), std::get<float>( hint ) );
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,8 +355,7 @@ timetable_panel::update() {
|
||||
//odejmij lokomotywy czynne, a przynajmniej aktualną
|
||||
consistmass -= owner->pVehicle->MoverParameters->TotalMass;
|
||||
// subtract potential other half of a two-part vehicle
|
||||
auto const *previous { owner->pVehicle->Prev( coupling::permanent ) };
|
||||
if( previous != nullptr ) { consistmass -= previous->MoverParameters->TotalMass; }
|
||||
if( auto const *previous { owner->pVehicle->Prev( coupling::permanent ) }; previous != nullptr ) { consistmass -= previous->MoverParameters->TotalMass; }
|
||||
auto const *next { owner->pVehicle->Next( coupling::permanent ) };
|
||||
if( next != nullptr ) { consistmass -= next->MoverParameters->TotalMass; }
|
||||
}
|
||||
@@ -428,13 +418,13 @@ timetable_panel::update() {
|
||||
&& i < table.StationIndex
|
||||
&& ( tableline->Ah < 0 // pass-through, always valid
|
||||
|| tableline->is_maintenance // maintenance stop, always valid
|
||||
|| time.wHour * 60 + time.wMinute + time.wSecond * 0.0167 >= tableline->Dh * 60 + tableline->Dm ) ) };
|
||||
|| time.wHour * 60 + time.wMinute + time.wSecond * 0.0167 >= static_cast<float>(tableline->Dh * 60) + tableline->Dm ) ) };
|
||||
auto const loadchangeinprogress { ( static_cast<int>(std::ceil(-1.0 * owner->fStopTime)) > 0 ) };
|
||||
auto const isatpassengerstop { true == owner->IsAtPassengerStop && vehicle->MoverParameters->Vel < 1.0 };
|
||||
auto const traveltime { (
|
||||
i < 2 ? " " :
|
||||
tableline->Ah >= 0 ? to_minutes_str( CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Ah, tableline->Am ), false, 3 ) :
|
||||
to_minutes_str( std::max( 0.0, CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Dh, tableline->Dm ) - 0.5 ), false, 3 ) ) };
|
||||
tableline->Ah >= 0 ? to_minutes_str( static_cast<float>(CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Ah, tableline->Am )), false, 3 ) :
|
||||
to_minutes_str( static_cast<float>(std::max( 0.0, CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Dh, tableline->Dm ) - 0.5 )), false, 3 ) ) };
|
||||
auto const linecolor { (
|
||||
i != table.StationStart ? Global.UITextColor :
|
||||
loadchangeinprogress ? colors::uitextred :
|
||||
@@ -486,19 +476,14 @@ timetable_panel::render() {
|
||||
if( size_min.x > 0 ) {
|
||||
ImGui::SetNextWindowSizeConstraints( ImVec2S( size_min.x * horizontalScale, size_min.y ), ImVec2S( size_max.x * horizontalScale, size_max.y ) );
|
||||
}
|
||||
auto const panelname { (
|
||||
title.empty() ?
|
||||
m_name :
|
||||
title )
|
||||
+ "###" + m_name };
|
||||
if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
if( auto const panelname { ( title.empty() ? m_name : title ) + "###" + m_name }; true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
for( auto const &line : text_lines ) {
|
||||
ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() );
|
||||
ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), "%s", line.data.c_str() );
|
||||
}
|
||||
if( is_expanded ) {
|
||||
ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, ImVec2( 1, 0 ) );
|
||||
for( auto const &line : m_tablelines ) {
|
||||
ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() );
|
||||
ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), "%s", line.data.c_str() );
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
@@ -576,25 +561,16 @@ debug_panel::render() {
|
||||
if( size_min.x > 0 ) {
|
||||
ImGui::SetNextWindowSizeConstraints( ImVec2S( size_min.x, size_min.y ), ImVec2S( size_max.x, size_max.y ) );
|
||||
}
|
||||
auto const panelname { (
|
||||
title.empty() ?
|
||||
m_name :
|
||||
title )
|
||||
+ "###" + m_name };
|
||||
if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
if( auto const panelname { ( title.empty() ? m_name : title ) + "###" + m_name }; true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
// header section
|
||||
for( auto const &line : text_lines ) {
|
||||
ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() );
|
||||
ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), "%s", line.data.c_str() );
|
||||
}
|
||||
// sections
|
||||
ImGui::Separator();
|
||||
if( true == render_section( "Vehicle", m_vehiclelines ) ) {
|
||||
if( DebugModeFlag && m_input.mover && m_input.mover->DamageFlag != 0 ) {
|
||||
if( true == ImGui::Button( "Stop and repair consist" ) ) {
|
||||
command_relay relay;
|
||||
relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name());
|
||||
}
|
||||
}
|
||||
if (true == render_section( "Vehicle", m_vehiclelines ) && DebugModeFlag && m_input.mover && m_input.mover->DamageFlag != 0 && true == ImGui::Button( "Stop and repair consist" )) {
|
||||
command_relay commandrelay;
|
||||
commandrelay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name());
|
||||
}
|
||||
render_section( "Vehicle Engine", m_enginelines );
|
||||
render_section( "Vehicle AI", m_ailines );
|
||||
@@ -611,13 +587,13 @@ debug_panel::render() {
|
||||
render_section_developer(); // Developer tools
|
||||
#ifdef WITH_UART
|
||||
if(true == render_section( "UART", m_uartlines)) {
|
||||
int ports_num = UartStatus.available_ports.size();
|
||||
char **avlports = new char*[ports_num];
|
||||
auto ports_num = static_cast<int>(UartStatus.available_ports.size());
|
||||
auto avlports = new char*[ports_num];
|
||||
for (int i=0; i < ports_num; i++) {
|
||||
avlports[i] = (char *) UartStatus.available_ports[i].c_str();
|
||||
}
|
||||
ImGui::Combo("Port", &UartStatus.selected_port_index, avlports, ports_num);
|
||||
ImGui::Combo("Baud", &UartStatus.selected_baud_index, uart_baudrates_list, uart_baudrates_list_num);
|
||||
ImGui::Combo("Baud", &UartStatus.selected_baud_index, uart_baudrates_list, static_cast<int>(uart_baudrates_list_num));
|
||||
ImGui::Checkbox("Enabled", &UartStatus.enabled);
|
||||
}
|
||||
#endif
|
||||
@@ -625,8 +601,8 @@ debug_panel::render() {
|
||||
ImGui::Separator();
|
||||
bool flag = DebugModeFlag;
|
||||
if (ImGui::Checkbox("Debug Mode", &flag)) {
|
||||
command_relay relay;
|
||||
relay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
|
||||
command_relay commandrelay;
|
||||
commandrelay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -647,8 +623,8 @@ debug_panel::render_section_scenario() {
|
||||
auto fogrange = std::log( Global.fFogEnd );
|
||||
if( ImGui::SliderFloat(
|
||||
( to_string( std::exp( fogrange ), 0, 5 ) + " m###fogend" ).c_str(), &fogrange, std::log( 10.0f ), std::log( 50000.0f ), "Fog distance" ) ) {
|
||||
command_relay relay;
|
||||
relay.post(
|
||||
command_relay commandrelay;
|
||||
commandrelay.post(
|
||||
user_command::setweather,
|
||||
std::clamp( std::exp( fogrange ), 10.0f, 50000.0f ),
|
||||
Global.Overcast,
|
||||
@@ -661,8 +637,8 @@ debug_panel::render_section_scenario() {
|
||||
(to_string(Airtemperature, 1) + " deg C###Airtemperature").c_str(),
|
||||
&Airtemperature, -35.0f, 40.0f, "Air Temperature"))
|
||||
{
|
||||
command_relay relay;
|
||||
relay.post(
|
||||
command_relay commandrelay;
|
||||
commandrelay.post(
|
||||
user_command::settemperature,
|
||||
std::clamp(Airtemperature, -35.0f, 40.0f),
|
||||
Global.Overcast,
|
||||
@@ -673,8 +649,8 @@ debug_panel::render_section_scenario() {
|
||||
{
|
||||
if( ImGui::SliderFloat(
|
||||
( to_string( Global.Overcast, 2, 5 ) + " (" + Global.Weather + ")###overcast" ).c_str(), &Global.Overcast, 0.0f, 2.0f, "Cloud cover" ) ) {
|
||||
command_relay relay;
|
||||
relay.post(
|
||||
command_relay commandrelay;
|
||||
commandrelay.post(
|
||||
user_command::setweather,
|
||||
Global.fFogEnd,
|
||||
std::clamp( Global.Overcast, 0.0f, 2.0f ),
|
||||
@@ -685,8 +661,8 @@ debug_panel::render_section_scenario() {
|
||||
{
|
||||
if( ImGui::SliderFloat(
|
||||
( to_string( Global.fMoveLight, 0, 5 ) + " (" + Global.Season + ")###movelight" ).c_str(), &Global.fMoveLight, 0.0f, 364.0f, "Day of year" ) ) {
|
||||
command_relay relay;
|
||||
relay.post(
|
||||
command_relay commandrelay;
|
||||
commandrelay.post(
|
||||
user_command::setdatetime,
|
||||
std::clamp( Global.fMoveLight, 0.0f, 365.0f ),
|
||||
simulation::Time.data().wHour * 60 + simulation::Time.data().wMinute,
|
||||
@@ -695,10 +671,8 @@ debug_panel::render_section_scenario() {
|
||||
}
|
||||
// dynamic material update checkbox
|
||||
ImGui::Checkbox( "Update Item Materials", &Global.UpdateMaterials );
|
||||
if( DebugModeFlag ) {
|
||||
if( ImGui::Checkbox( "Force Daylight", &Global.FakeLight ) ) {
|
||||
simulation::Environment.on_daylight_change();
|
||||
}
|
||||
if (DebugModeFlag && ImGui::Checkbox( "Force Daylight", &Global.FakeLight )) {
|
||||
simulation::Environment.on_daylight_change();
|
||||
}
|
||||
// advanced options, only visible in debug mode
|
||||
if( DebugModeFlag ) {
|
||||
@@ -713,8 +687,8 @@ debug_panel::render_section_scenario() {
|
||||
+ ":"
|
||||
+ std::string( std::to_string( int( 100 + simulation::Time.data().wMinute ) ).substr( 1, 2 ) ) ) };
|
||||
if( ImGui::SliderInt( ( timestring + " (" + Global.Period + ")###simulationtime" ).c_str(), &time, 0, 1439, "Time of day" ) ) {
|
||||
command_relay relay;
|
||||
relay.post(
|
||||
command_relay commandrelay;
|
||||
commandrelay.post(
|
||||
user_command::setdatetime,
|
||||
Global.fMoveLight,
|
||||
std::clamp( time, 0, 1439 ),
|
||||
@@ -903,7 +877,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
|
||||
mover.LoadFlag,
|
||||
mover.LocalBrakePosA,
|
||||
mover.LocalBrakePosAEIM,
|
||||
mover.ManualBrakePos / static_cast<float>(ManualBrakePosNo),
|
||||
static_cast<float>(mover.ManualBrakePos) / static_cast<float>(ManualBrakePosNo),
|
||||
mover.SpringBrake.Activate ? 1.f : 0.f,
|
||||
// cylinders
|
||||
mover.BrakePress,
|
||||
@@ -981,11 +955,11 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
|
||||
|
||||
if (!std::isnan(last_time)) {
|
||||
double dt = Timer::GetTime() - last_time;
|
||||
AccN_jerk_graph.update((mover.AccN - last_AccN) / dt);
|
||||
AccN_acc_graph.update(mover.AccN);
|
||||
AccN_jerk_graph.update(static_cast<float>((mover.AccN - last_AccN) / dt));
|
||||
AccN_acc_graph.update(static_cast<float>(mover.AccN));
|
||||
}
|
||||
|
||||
last_AccN = mover.AccN;
|
||||
last_AccN = static_cast<float>(mover.AccN);
|
||||
last_time = Timer::GetTime();
|
||||
}
|
||||
|
||||
@@ -1002,7 +976,7 @@ void debug_panel::graph_data::update(float val) {
|
||||
void debug_panel::graph_data::render() {
|
||||
ImGui::PushID(this);
|
||||
ImGui::SliderFloat(STR_C("##Range"), &range, 0.5f, 60.0f, "%.1f");
|
||||
ImGui::PlotLines("##plot", data.data(), data.size(), pos, nullptr, 0.0f, range, ImVec2(0, 100));
|
||||
ImGui::PlotLines("##plot", data.data(), static_cast<int>(data.size()), static_cast<int>(pos), nullptr, 0.0f, range, ImVec2(0, 100));
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
@@ -1047,9 +1021,9 @@ debug_panel::update_vehicle_brake() const {
|
||||
{ bdelay_R, "R" },
|
||||
{ bdelay_M, "+Mg" } };
|
||||
|
||||
for( auto const &delay : delays ) {
|
||||
if( ( mover.BrakeDelayFlag & delay.first ) == delay.first ) {
|
||||
brakedelay += delay.second;
|
||||
for( auto const &[delayflag, delayname] : delays ) {
|
||||
if( ( mover.BrakeDelayFlag & delayflag ) == delayflag ) {
|
||||
brakedelay += delayname;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1057,7 +1031,7 @@ debug_panel::update_vehicle_brake() const {
|
||||
}
|
||||
|
||||
void
|
||||
debug_panel::update_section_engine( std::vector<text_line> &Output ) {
|
||||
debug_panel::update_section_engine( std::vector<text_line> &Output ) const {
|
||||
|
||||
if( m_input.vehicle == nullptr ) { return; }
|
||||
if( m_input.mover == nullptr ) { return; }
|
||||
@@ -1072,9 +1046,9 @@ debug_panel::update_section_engine( std::vector<text_line> &Output ) {
|
||||
for( int i = 0; i <= 20; ++i ) {
|
||||
|
||||
std::string parameters =
|
||||
mover.eimc_labels[ i ] + to_string( mover.eimc[ i ], 2, 9 )
|
||||
TMoverParameters::eimc_labels[ i ] + to_string( mover.eimc[ i ], 2, 9 )
|
||||
+ " | "
|
||||
+ mover.eimv_labels[ i ] + to_string( mover.eimv[ i ], 2, 9 );
|
||||
+ TMoverParameters::eimv_labels[ i ] + to_string( mover.eimv[ i ], 2, 9 );
|
||||
|
||||
if( i < 10 ) {
|
||||
parameters +=
|
||||
@@ -1084,7 +1058,7 @@ debug_panel::update_section_engine( std::vector<text_line> &Output ) {
|
||||
parameters += " med:";
|
||||
}
|
||||
else if( i >= 13 ) {
|
||||
parameters += " | " + vehicle.MED_labels[ i - 13 ] + to_string( vehicle.MED[ 0 ][ i - 13 ], 2, 9 );
|
||||
parameters += " | " + TDynamicObject::MED_labels[ i - 13 ] + to_string( vehicle.MED[ 0 ][ i - 13 ], 2, 9 );
|
||||
}
|
||||
|
||||
Output.emplace_back( parameters, Global.UITextColor );
|
||||
@@ -1112,8 +1086,8 @@ debug_panel::update_section_engine( std::vector<text_line> &Output ) {
|
||||
{ "cdesi: ", mover.dizel_engagestate },
|
||||
{ "cdelt: ", mover.dizel_engagedeltaomega },
|
||||
{ "gears: ", mover.dizel_automaticgearstatus} };
|
||||
for( auto const ¶meter : paramvalues ) {
|
||||
parameterstext += "\n" + parameter.first + to_string( parameter.second, 2, 9 );
|
||||
for( auto const &[parametername, parametervalue] : paramvalues ) {
|
||||
parameterstext += "\n" + parametername + to_string( parametervalue, 2, 9 );
|
||||
}
|
||||
Output.emplace_back( parameterstext, Global.UITextColor );
|
||||
|
||||
@@ -1130,15 +1104,15 @@ debug_panel::update_section_engine( std::vector<text_line> &Output ) {
|
||||
{ "hRtTq: ", mover.hydro_R_Torque }
|
||||
|
||||
};
|
||||
for( auto const ¶meter : hydrovalues ) {
|
||||
parameterstext += "\n" + parameter.first + to_string( parameter.second, 2, 9 );
|
||||
for( auto const &[parametername, parametervalue] : hydrovalues ) {
|
||||
parameterstext += "\n" + parametername + to_string( parametervalue, 2, 9 );
|
||||
}
|
||||
Output.emplace_back( parameterstext, Global.UITextColor );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
debug_panel::update_section_ai( std::vector<text_line> &Output ) {
|
||||
debug_panel::update_section_ai( std::vector<text_line> &Output ) const {
|
||||
|
||||
if( m_input.mover == nullptr ) { return; }
|
||||
if( m_input.mechanik == nullptr ) { return; }
|
||||
@@ -1202,14 +1176,14 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) {
|
||||
{ mover.RunningTrack.Velmax, "track" } };
|
||||
|
||||
std::string restrictionstext;
|
||||
for( auto const &restriction : restrictions ) {
|
||||
if( restriction.first < 0.0 ) { continue; }
|
||||
for( auto const &[restrictionspeed, restrictionsource] : restrictions ) {
|
||||
if( restrictionspeed < 0.0 ) { continue; }
|
||||
if( false == restrictionstext.empty() ) {
|
||||
restrictionstext += ", ";
|
||||
}
|
||||
restrictionstext +=
|
||||
to_string( restriction.first, 0 )
|
||||
+ " (" + restriction.second + ")";
|
||||
to_string( restrictionspeed, 0 )
|
||||
+ " (" + restrictionsource + ")";
|
||||
}
|
||||
|
||||
if( false == restrictionstext.empty() ) {
|
||||
@@ -1262,7 +1236,7 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) {
|
||||
}
|
||||
|
||||
void
|
||||
debug_panel::update_section_scantable( std::vector<text_line> &Output ) {
|
||||
debug_panel::update_section_scantable( std::vector<text_line> &Output ) const {
|
||||
|
||||
if( m_input.mechanik == nullptr ) { return; }
|
||||
|
||||
@@ -1284,8 +1258,8 @@ debug_panel::update_section_scantable( std::vector<text_line> &Output ) {
|
||||
|
||||
#ifdef WITH_UART
|
||||
void
|
||||
debug_panel::update_section_uart( std::vector<text_line> &Output ) {
|
||||
uart_status *status = &UartStatus;
|
||||
debug_panel::update_section_uart( std::vector<text_line> &Output ) const {
|
||||
uart_status const *status = &UartStatus;
|
||||
|
||||
Output.emplace_back(
|
||||
("Port: " + status->port_name).c_str(),
|
||||
@@ -1312,7 +1286,7 @@ debug_panel::update_section_uart( std::vector<text_line> &Output ) {
|
||||
#endif
|
||||
|
||||
void
|
||||
debug_panel::update_section_scenario( std::vector<text_line> &Output ) {
|
||||
debug_panel::update_section_scenario( std::vector<text_line> &Output ) const {
|
||||
|
||||
auto textline =
|
||||
"vehicles: " + to_string( Timer::subsystem.sim_dynamics.average(), 2 ) + " msec"
|
||||
@@ -1326,7 +1300,7 @@ debug_panel::update_section_scenario( std::vector<text_line> &Output ) {
|
||||
+ to_string( simulation::Environment.wind_azimuth(), 0 ) // ma być azymut, czyli 0 na północy i rośnie na wschód
|
||||
+ " "
|
||||
+ std::string( "N NEE SES SWW NW" )
|
||||
.substr( 0 + 2 * std::floor( std::fmod( 8 + ( glm::radians( simulation::Environment.wind_azimuth() ) + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ), 2 )
|
||||
.substr( static_cast<std::size_t>( 2 * std::floor( std::fmod( 8 + ( glm::radians( simulation::Environment.wind_azimuth() ) + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ) ), 2 )
|
||||
+ ", " + to_string( glm::length( simulation::Environment.wind() ), 1 ) + " m/s";
|
||||
textline += "\nAir temperature: " + to_string( Global.AirTemperature, 1 ) + " deg C";
|
||||
|
||||
@@ -1340,36 +1314,36 @@ debug_panel::update_section_eventqueue( std::vector<text_line> &Output ) {
|
||||
|
||||
// current event queue
|
||||
auto const time { Timer::GetTime() };
|
||||
auto const *event { simulation::Events.begin() };
|
||||
auto const *queuedevent { simulation::Events.begin() };
|
||||
auto const searchfilter { std::string( m_eventsearch.data() ) };
|
||||
|
||||
Output.emplace_back( "Delay: Event:", Global.UITextColor );
|
||||
|
||||
while( event != nullptr
|
||||
while( queuedevent != nullptr
|
||||
&& Output.size() < 30 ) {
|
||||
|
||||
if( false == event->m_ignored
|
||||
&& false == event->m_passive
|
||||
if( false == queuedevent->m_ignored
|
||||
&& false == queuedevent->m_passive
|
||||
&& ( false == m_eventqueueactivevehicleonly
|
||||
|| event->m_activator == m_input.vehicle ) ) {
|
||||
|| queuedevent->m_activator == m_input.vehicle ) ) {
|
||||
|
||||
auto const label { event->m_name + ( event->m_activator ? " (by: " + event->m_activator->asName + ")" : "" ) };
|
||||
auto const label { queuedevent->m_name + ( queuedevent->m_activator ? " (by: " + queuedevent->m_activator->asName + ")" : "" ) };
|
||||
|
||||
if( false == searchfilter.empty()
|
||||
&& false == contains(label, searchfilter) ) {
|
||||
event = event->m_next;
|
||||
queuedevent = queuedevent->m_next;
|
||||
continue;
|
||||
}
|
||||
|
||||
auto const delay { " " + to_string( std::max( 0.0, event->m_launchtime - time ), 1 ) };
|
||||
auto const delay { " " + to_string( std::max( 0.0, queuedevent->m_launchtime - time ), 1 ) };
|
||||
textline =
|
||||
delay.substr( delay.length() - 6 )
|
||||
+ " "
|
||||
+ label + ( event->m_sibling ? " (joint event)" : "" );
|
||||
+ label + ( queuedevent->m_sibling ? " (joint event)" : "" );
|
||||
|
||||
Output.emplace_back( textline, Global.UITextColor );
|
||||
}
|
||||
event = event->m_next;
|
||||
queuedevent = queuedevent->m_next;
|
||||
}
|
||||
if( Output.size() == 1 ) {
|
||||
// event queue can be empty either because no event got through active filters, or because it is genuinely empty
|
||||
@@ -1378,7 +1352,7 @@ debug_panel::update_section_eventqueue( std::vector<text_line> &Output ) {
|
||||
}
|
||||
|
||||
void
|
||||
debug_panel::update_section_powergrid( std::vector<text_line> &Output ) {
|
||||
debug_panel::update_section_powergrid( std::vector<text_line> &Output ) const {
|
||||
|
||||
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 ) };
|
||||
@@ -1420,7 +1394,7 @@ debug_panel::update_section_powergrid( std::vector<text_line> &Output ) {
|
||||
}
|
||||
|
||||
void
|
||||
debug_panel::update_section_camera( std::vector<text_line> &Output ) {
|
||||
debug_panel::update_section_camera( std::vector<text_line> &Output ) const {
|
||||
|
||||
if( m_input.camera == nullptr ) { return; }
|
||||
|
||||
@@ -1440,13 +1414,13 @@ debug_panel::update_section_camera( std::vector<text_line> &Output ) {
|
||||
+ to_string( 180.0 - glm::degrees( camera.Angle.y ), 0 ) // ma być azymut, czyli 0 na północy i rośnie na wschód
|
||||
+ " "
|
||||
+ std::string( "S SEE NEN NWW SW" )
|
||||
.substr( 0 + 2 * floor( fmod( 8 + ( camera.Angle.y + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ), 2 );
|
||||
.substr( static_cast<std::size_t>( 2 * floor( fmod( 8 + ( camera.Angle.y + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ) ), 2 );
|
||||
|
||||
Output.emplace_back( textline, Global.UITextColor );
|
||||
}
|
||||
|
||||
void
|
||||
debug_panel::update_section_renderer( std::vector<text_line> &Output ) {
|
||||
debug_panel::update_section_renderer( std::vector<text_line> &Output ) const {
|
||||
|
||||
// gfx renderer data
|
||||
auto textline =
|
||||
@@ -1526,7 +1500,7 @@ debug_panel::render_section( std::string const &Header, std::vector<text_line> c
|
||||
}
|
||||
|
||||
bool
|
||||
debug_panel::render_section( std::vector<text_line> const &Lines ) {
|
||||
debug_panel::render_section( std::vector<text_line> const &Lines ) const {
|
||||
|
||||
for( auto const &line : Lines ) {
|
||||
ImGui::PushStyleColor( ImGuiCol_Text, { line.color.r, line.color.g, line.color.b, line.color.a } );
|
||||
@@ -1537,7 +1511,7 @@ debug_panel::render_section( std::vector<text_line> const &Lines ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool debug_panel::render_section_developer()
|
||||
bool debug_panel::render_section_developer() const
|
||||
{
|
||||
if (false == ImGui::CollapsingHeader("Developer tools"))
|
||||
return false;
|
||||
@@ -1553,7 +1527,7 @@ bool debug_panel::render_section_developer()
|
||||
}
|
||||
|
||||
bool
|
||||
debug_panel::render_section_settings() {
|
||||
debug_panel::render_section_settings() const {
|
||||
|
||||
if( false == ImGui::CollapsingHeader( "Settings" ) ) { return false; }
|
||||
|
||||
@@ -1563,9 +1537,9 @@ debug_panel::render_section_settings() {
|
||||
// reflection fidelity
|
||||
ImGui::SliderInt( ( std::to_string( Global.reflectiontune.fidelity ) + "###reflectionfidelity" ).c_str(), &Global.reflectiontune.fidelity, 0, 2, "Reflection fidelity" );
|
||||
ImGui::SliderInt( ( std::to_string( Global.gfx_shadow_rank_cutoff ) + "###shadowrankcutoff" ).c_str(), &Global.gfx_shadow_rank_cutoff, 1, 3, "Shadow ranks" );
|
||||
if( ImGui::SliderFloat( ( to_string( std::abs( Global.gfx_shadow_angle_min ), 2 ) + "###shadowanglecutoff" ).c_str(), &Global.gfx_shadow_angle_min, -1.0, -0.2, "Shadow angle cutoff" ) ) {
|
||||
if( ImGui::SliderFloat( ( to_string( std::abs( Global.gfx_shadow_angle_min ), 2 ) + "###shadowanglecutoff" ).c_str(), &Global.gfx_shadow_angle_min, -1.0, -0.2f, "Shadow angle cutoff" ) ) {
|
||||
Global.gfx_shadow_angle_min = quantize( Global.gfx_shadow_angle_min, 0.05f );
|
||||
};
|
||||
}
|
||||
if( DebugModeFlag ) {
|
||||
// sky sliders
|
||||
{
|
||||
@@ -1595,8 +1569,8 @@ debug_panel::render_section_settings() {
|
||||
if (simulation::Train) {
|
||||
float val = simulation::Train->get_radiovolume();
|
||||
if( ImGui::SliderFloat( ( std::to_string( static_cast<int>( val * 100 ) ) + "%###volumeradio" ).c_str(), &val, 0.0f, 1.0f, "Vehicle radio volume" ) ) {
|
||||
command_relay relay;
|
||||
relay.post(user_command::radiovolumeset, val, 0.0, GLFW_PRESS, 0);
|
||||
command_relay commandrelay;
|
||||
commandrelay.post(user_command::radiovolumeset, val, 0.0, GLFW_PRESS, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1635,12 +1609,7 @@ transcripts_panel::render() {
|
||||
if( size_min.x > 0 ) {
|
||||
ImGui::SetNextWindowSizeConstraints( ImVec2S( size_min.x, size_min.y ), ImVec2S( size_max.x, size_max.y ) );
|
||||
}
|
||||
auto const panelname { (
|
||||
title.empty() ?
|
||||
m_name :
|
||||
title )
|
||||
+ "###" + m_name };
|
||||
if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
if( auto const panelname { ( title.empty() ? m_name : title ) + "###" + m_name }; true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
// header section
|
||||
for( auto const &line : text_lines ) {
|
||||
ImGui::TextWrapped( "%s", line.data.c_str() );
|
||||
|
||||
@@ -54,7 +54,6 @@ public:
|
||||
|
||||
private:
|
||||
// members
|
||||
std::array<char, 256> m_buffer;
|
||||
TDynamicObject const *m_nearest { nullptr };
|
||||
};
|
||||
|
||||
@@ -81,42 +80,41 @@ private:
|
||||
// methods
|
||||
// generate and send section data to provided output
|
||||
void update_section_vehicle( std::vector<text_line> &Output );
|
||||
void update_section_engine( std::vector<text_line> &Output );
|
||||
void update_section_ai( std::vector<text_line> &Output );
|
||||
void update_section_scantable( std::vector<text_line> &Output );
|
||||
void update_section_scenario( std::vector<text_line> &Output );
|
||||
void update_section_engine( std::vector<text_line> &Output ) const;
|
||||
void update_section_ai( std::vector<text_line> &Output ) const;
|
||||
void update_section_scantable( std::vector<text_line> &Output ) const;
|
||||
void update_section_scenario( std::vector<text_line> &Output ) const;
|
||||
void update_section_eventqueue( std::vector<text_line> &Output );
|
||||
void update_section_powergrid( std::vector<text_line> &Output );
|
||||
void update_section_camera( std::vector<text_line> &Output );
|
||||
void update_section_renderer( std::vector<text_line> &Output );
|
||||
void update_section_powergrid( std::vector<text_line> &Output ) const;
|
||||
void update_section_camera( std::vector<text_line> &Output ) const;
|
||||
void update_section_renderer( std::vector<text_line> &Output ) const;
|
||||
#ifdef WITH_UART
|
||||
void update_section_uart( std::vector<text_line> &Output );
|
||||
void update_section_uart( std::vector<text_line> &Output ) const;
|
||||
#endif
|
||||
// section update helpers
|
||||
std::string update_vehicle_coupler( int const Side );
|
||||
std::string update_vehicle_brake() const;
|
||||
// renders provided lines, under specified collapsing header
|
||||
bool render_section( std::string const &Header, std::vector<text_line> const &Lines );
|
||||
bool render_section( std::vector<text_line> const &Lines );
|
||||
bool render_section( std::vector<text_line> const &Lines ) const;
|
||||
bool render_section_scenario();
|
||||
bool render_section_eventqueue();
|
||||
bool render_section_settings();
|
||||
bool render_section_developer();
|
||||
bool render_section_settings() const;
|
||||
bool render_section_developer() const;
|
||||
// members
|
||||
std::array<char, 1024> m_buffer;
|
||||
std::array<char, 128> m_eventsearch;
|
||||
input_data m_input;
|
||||
std::vector<text_line>
|
||||
m_vehiclelines,
|
||||
m_enginelines,
|
||||
m_ailines,
|
||||
m_scantablelines,
|
||||
m_cameralines,
|
||||
m_scenariolines,
|
||||
m_eventqueuelines,
|
||||
m_powergridlines,
|
||||
m_rendererlines,
|
||||
m_uartlines;
|
||||
std::vector<text_line> m_vehiclelines;
|
||||
std::vector<text_line> m_enginelines;
|
||||
std::vector<text_line> m_ailines;
|
||||
std::vector<text_line> m_scantablelines;
|
||||
std::vector<text_line> m_cameralines;
|
||||
std::vector<text_line> m_scenariolines;
|
||||
std::vector<text_line> m_eventqueuelines;
|
||||
std::vector<text_line> m_powergridlines;
|
||||
std::vector<text_line> m_rendererlines;
|
||||
std::vector<text_line> m_uartlines;
|
||||
|
||||
double last_time = std::numeric_limits<double>::quiet_NaN();
|
||||
|
||||
@@ -134,8 +132,6 @@ private:
|
||||
graph_data AccN_acc_graph;
|
||||
float last_AccN;
|
||||
|
||||
std::array<char, 128> queue_event_buf = { 0 };
|
||||
std::array<char, 128> queue_event_activator_buf = { 0 };
|
||||
|
||||
bool m_eventqueueactivevehicleonly { false };
|
||||
};
|
||||
|
||||
@@ -11,13 +11,13 @@ TTranscripts Transcripts;
|
||||
|
||||
// dodanie linii do tabeli, (show) i (hide) w [s] od aktualnego czasu
|
||||
void
|
||||
TTranscripts::AddLine( std::string const &txt, float show, float hide, bool it ) {
|
||||
TTranscripts::AddLine( std::string_view txt, float show, float hide, bool it ) {
|
||||
|
||||
if( show == hide ) { return; } // komentarz jest ignorowany
|
||||
|
||||
// TODO: replace the timeangledeg mess with regular time points math
|
||||
show = Global.fTimeAngleDeg + show / 240.0; // jeśli doba to 360, to 1s będzie równe 1/240
|
||||
hide = Global.fTimeAngleDeg + hide / 240.0;
|
||||
show = static_cast<float>(Global.fTimeAngleDeg + show / 240.0); // jeśli doba to 360, to 1s będzie równe 1/240
|
||||
hide = static_cast<float>(Global.fTimeAngleDeg + hide / 240.0);
|
||||
|
||||
TTranscript transcript;
|
||||
transcript.asText = txt;
|
||||
@@ -34,7 +34,7 @@ TTranscripts::AddLine( std::string const &txt, float show, float hide, bool it )
|
||||
|
||||
// dodanie tekstów, długość dźwięku, czy istotne
|
||||
void
|
||||
TTranscripts::Add( std::string const &txt, bool backgorund ) {
|
||||
TTranscripts::Add( std::string const &txt, bool /*backgorund*/ ) {
|
||||
|
||||
if( true == txt.empty() ) { return; }
|
||||
|
||||
@@ -42,20 +42,21 @@ TTranscripts::Add( std::string const &txt, bool backgorund ) {
|
||||
cParser parser( asciitext );
|
||||
while( true == parser.getTokens( 3, false, "[]\n" ) ) {
|
||||
|
||||
float begin{ 0.f }, end{ 0.f };
|
||||
float begin{ 0.f };
|
||||
float end{ 0.f };
|
||||
std::string transcript;
|
||||
parser
|
||||
>> begin
|
||||
>> end
|
||||
>> transcript;
|
||||
AddLine( transcript, 0.10 * begin, 0.12 * end, false );
|
||||
AddLine( transcript, static_cast<float>(0.10 * begin), static_cast<float>(0.12 * end), false );
|
||||
}
|
||||
// try to handle malformed(?) cases with no show/hide times
|
||||
std::string transcript; parser >> transcript;
|
||||
while( false == transcript.empty() ) {
|
||||
|
||||
// WriteLog( "Transcript text with no display/hide times: \"" + transcript + "\"" );
|
||||
AddLine( transcript, 0.0, 0.12 * transcript.size(), false );
|
||||
AddLine( transcript, 0.0, static_cast<float>(0.12 * static_cast<double>(transcript.size())), false );
|
||||
transcript = ""; parser >> transcript;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
// constructors
|
||||
TTranscripts() = default;
|
||||
// methods
|
||||
void AddLine( std::string const &txt, float show, float hide, bool it );
|
||||
void AddLine( std::string_view txt, float show, float hide, bool it );
|
||||
// dodanie tekstów, długość dźwięku, czy istotne
|
||||
void Add( std::string const &txt, bool background = false );
|
||||
// usuwanie niepotrzebnych (ok. 10 razy na sekundę)
|
||||
|
||||
Reference in New Issue
Block a user