16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 04:39:18 +02:00

air temperature readout for python scripts, scenarion inspector ui mode

This commit is contained in:
tmj-fstate
2018-05-11 14:54:06 +02:00
parent b5f334a1fa
commit 32feae8ff6
4 changed files with 91 additions and 35 deletions

View File

@@ -132,6 +132,10 @@ public:
bool bool
insert( TEventLauncher *Launcher ) { insert( TEventLauncher *Launcher ) {
return m_launchers.insert( Launcher ); } return m_launchers.insert( Launcher ); }
// returns first event in the queue
TEvent *
begin() {
return QueryRootEvent; }
// legacy method, returns pointer to specified event, or null // legacy method, returns pointer to specified event, or null
TEvent * TEvent *
FindEvent( std::string const &Name ); FindEvent( std::string const &Name );

View File

@@ -322,7 +322,9 @@ global_settings::ConfigParse(cParser &Parser) {
// selected device for audio renderer // selected device for audio renderer
Parser.getTokens(); Parser.getTokens();
Parser >> AirTemperature; Parser >> AirTemperature;
AirTemperature = clamp( AirTemperature, -15.f, 45.f ); if( false == DebugModeFlag ) {
AirTemperature = clamp( AirTemperature, -15.f, 45.f );
}
} }
else if( token == "scalespeculars" ) { else if( token == "scalespeculars" ) {
// whether strength of specular highlights should be adjusted (generally needed for legacy 3d models) // whether strength of specular highlights should be adjusted (generally needed for legacy 3d models)

View File

@@ -535,6 +535,7 @@ PyObject *TTrain::GetTrainState() {
PyDict_SetItemString( dict, "hours", PyGetInt( simulation::Time.data().wHour ) ); PyDict_SetItemString( dict, "hours", PyGetInt( simulation::Time.data().wHour ) );
PyDict_SetItemString( dict, "minutes", PyGetInt( simulation::Time.data().wMinute ) ); PyDict_SetItemString( dict, "minutes", PyGetInt( simulation::Time.data().wMinute ) );
PyDict_SetItemString( dict, "seconds", PyGetInt( simulation::Time.second() ) ); PyDict_SetItemString( dict, "seconds", PyGetInt( simulation::Time.second() ) );
PyDict_SetItemString( dict, "air_temperature", PyGetInt( Global.AirTemperature ) );
return dict; return dict;
} }
@@ -6396,44 +6397,60 @@ void TTrain::set_cab_controls() {
ggRadioChannelSelector.PutValue( iRadioChannel - 1 ); ggRadioChannelSelector.PutValue( iRadioChannel - 1 );
// pantographs // pantographs
if( mvOccupied->PantSwitchType != "impulse" ) { if( mvOccupied->PantSwitchType != "impulse" ) {
ggPantFrontButton.PutValue( if( ggPantFrontButton.SubModel ) {
( mvControlled->PantFrontUp ? ggPantFrontButton.PutValue(
1.0 : ( mvControlled->PantFrontUp ?
0.0 ) ); 1.0 :
ggPantFrontButtonOff.PutValue( 0.0 ) );
( mvControlled->PantFrontUp ? }
0.0 : if( ggPantFrontButtonOff.SubModel ) {
1.0 ) ); ggPantFrontButtonOff.PutValue(
( mvControlled->PantFrontUp ?
0.0 :
1.0 ) );
}
// NOTE: currently we animate the selectable pantograph control for both pantographs // NOTE: currently we animate the selectable pantograph control for both pantographs
// TODO: implement actual selection control, and refactor handling this control setup in a separate method // TODO: implement actual selection control, and refactor handling this control setup in a separate method
ggPantSelectedButton.PutValue( if( ggPantSelectedButton.SubModel ) {
( mvControlled->PantFrontUp ? ggPantSelectedButton.PutValue(
1.0 : ( mvControlled->PantFrontUp ?
0.0 ) ); 1.0 :
ggPantSelectedDownButton.PutValue( 0.0 ) );
( mvControlled->PantFrontUp ? }
0.0 : if( ggPantSelectedDownButton.SubModel ) {
1.0 ) ); ggPantSelectedDownButton.PutValue(
( mvControlled->PantFrontUp ?
0.0 :
1.0 ) );
}
} }
if( mvOccupied->PantSwitchType != "impulse" ) { if( mvOccupied->PantSwitchType != "impulse" ) {
ggPantRearButton.PutValue( if( ggPantRearButton.SubModel ) {
( mvControlled->PantRearUp ? ggPantRearButton.PutValue(
1.0 : ( mvControlled->PantRearUp ?
0.0 ) ); 1.0 :
ggPantRearButtonOff.PutValue( 0.0 ) );
( mvControlled->PantRearUp ? }
0.0 : if( ggPantRearButtonOff.SubModel ) {
1.0 ) ); ggPantRearButtonOff.PutValue(
( mvControlled->PantRearUp ?
0.0 :
1.0 ) );
}
// NOTE: currently we animate the selectable pantograph control for both pantographs // NOTE: currently we animate the selectable pantograph control for both pantographs
// TODO: implement actual selection control, and refactor handling this control setup in a separate method // TODO: implement actual selection control, and refactor handling this control setup in a separate method
ggPantSelectedButton.PutValue( if( ggPantSelectedButton.SubModel ) {
( mvControlled->PantRearUp ? ggPantSelectedButton.PutValue(
1.0 : ( mvControlled->PantRearUp ?
0.0 ) ); 1.0 :
ggPantSelectedDownButton.PutValue( 0.0 ) );
( mvControlled->PantRearUp ? }
0.0 : if( ggPantSelectedDownButton.SubModel ) {
1.0 ) ); ggPantSelectedDownButton.PutValue(
( mvControlled->PantRearUp ?
0.0 :
1.0 ) );
}
} }
// auxiliary compressor // auxiliary compressor
ggPantCompressorValve.PutValue( ggPantCompressorValve.PutValue(
@@ -6750,7 +6767,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
{ "horn_bt:", ggHornButton }, { "horn_bt:", ggHornButton },
{ "hornlow_bt:", ggHornLowButton }, { "hornlow_bt:", ggHornLowButton },
{ "hornhigh_bt:", ggHornHighButton }, { "hornhigh_bt:", ggHornHighButton },
{ "whistle_bt:", ggHornHighButton }, { "whistle_bt:", ggWhistleButton },
{ "fuse_bt:", ggFuseButton }, { "fuse_bt:", ggFuseButton },
{ "converterfuse_bt:", ggConverterFuseButton }, { "converterfuse_bt:", ggConverterFuseButton },
{ "stlinoff_bt:", ggStLinOffButton }, { "stlinoff_bt:", ggStLinOffButton },

View File

@@ -184,6 +184,12 @@ ui_layer::on_key( int const Key, int const Action ) {
return true; return true;
} }
case GLFW_KEY_F11: {
// scenario inspector
Global.iTextMode = Key;
return true;
}
case GLFW_KEY_F12: { case GLFW_KEY_F12: {
// coś tam jeszcze // coś tam jeszcze
Global.iTextMode = Key; Global.iTextMode = Key;
@@ -641,7 +647,34 @@ ui_layer::update() {
case( GLFW_KEY_F10 ) : { case( GLFW_KEY_F10 ) : {
uitextline1 = ( "Press [Y] key to quit / Aby zakonczyc program, przycisnij klawisz [Y]." ); uitextline1 = "Press [Y] key to quit / Aby zakonczyc program, przycisnij klawisz [Y].";
break;
}
case( GLFW_KEY_F11 ): {
// scenario inspector
auto const time { Timer::GetTime() };
auto const *event { simulation::Events.begin() };
auto eventtableindex{ 0 };
while( ( event != nullptr )
&& ( eventtableindex < 30 ) ) {
if( ( false == event->m_ignored )
&& ( true == event->bEnabled ) ) {
auto const delay { " " + to_string( std::max( 0.0, event->fStartTime - time ), 1 ) };
auto const eventline =
"Delay: " + delay.substr( delay.length() - 6 )
+ ", Event: " + event->asName
+ ( event->Activator ? " (by: " + event->Activator->asName + ")" : "" )
+ ( event->evJoined ? " (joint event)" : "" );
UITable->text_lines.emplace_back( eventline, Global.UITextColor );
++eventtableindex;
}
event = event->evNext;
}
break; break;
} }