mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 09:59:18 +02:00
event condition fixes, cab light control enhancement, manual brake control enhancement
This commit is contained in:
@@ -193,7 +193,7 @@ basic_event::event_conditions::deserialize( cParser &Input ) {
|
||||
flags |= flags::text;
|
||||
}
|
||||
Input.getTokens();
|
||||
if( Input.peek() != "*" ) //"*" - nie brac val1 pod uwage
|
||||
if( Input.peek() != "*" ) //"*" - nie brac pod uwage
|
||||
{ // two tokens, operator followed by comparison value
|
||||
std::string operatorstring;
|
||||
Input >> operatorstring;
|
||||
@@ -203,13 +203,14 @@ basic_event::event_conditions::deserialize( cParser &Input ) {
|
||||
flags |= flags::value1;
|
||||
}
|
||||
Input.getTokens();
|
||||
if( Input.peek() != "*" ) //"*" - nie brac pod uwage
|
||||
{ // two tokens, operator followed by comparison value
|
||||
std::string operatorstring;
|
||||
Input >> operatorstring;
|
||||
memcompare_value2_operator = comparison_operator_from_string( operatorstring );
|
||||
Input.getTokens();
|
||||
Input >> memcompare_value2;
|
||||
flags |= flags::value1;
|
||||
flags |= flags::value2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,12 +157,12 @@ bool TMemCell::Compare( std::string const &szTestText, double const fTestValue1,
|
||||
checkfailed |= ( !result );
|
||||
}
|
||||
if( TestFlag( CheckMask, basic_event::flags::value1 ) ) {
|
||||
auto const result { compare( fValue1, fTestValue1, TextOperator ) };
|
||||
auto const result { compare( fValue1, fTestValue1, Value1Operator ) };
|
||||
checkpassed |= result;
|
||||
checkfailed |= ( !result );
|
||||
}
|
||||
if( TestFlag( CheckMask, basic_event::flags::value2 ) ) {
|
||||
auto const result { compare( fValue2, fTestValue2, TextOperator ) };
|
||||
auto const result { compare( fValue2, fTestValue2, Value2Operator ) };
|
||||
checkpassed |= result;
|
||||
checkfailed |= ( !result );
|
||||
}
|
||||
|
||||
44
Train.cpp
44
Train.cpp
@@ -4271,14 +4271,11 @@ void TTrain::OnCommand_interiorlightenable( TTrain *Train, command_data const &C
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||
if( Train->ggCabLightButton.SubModel == nullptr ) {
|
||||
if( false == Train->m_controlmapper.contains( "cablight_sw:" ) ) {
|
||||
// TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels
|
||||
WriteLog( "Interior Light switch is missing, or wasn't defined" );
|
||||
return;
|
||||
}
|
||||
// visual feedback
|
||||
Train->ggCabLightButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||
Train->btCabLight.Turn( true );
|
||||
// store lighting switch states
|
||||
if( false == Train->DynamicObject->JointCabs ) {
|
||||
// vehicles with separate cabs get separate lighting switch states
|
||||
@@ -4297,14 +4294,11 @@ void TTrain::OnCommand_interiorlightdisable( TTrain *Train, command_data const &
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// only reacting to press, so the switch doesn't flip back and forth if key is held down
|
||||
if( Train->ggCabLightButton.SubModel == nullptr ) {
|
||||
if( false == Train->m_controlmapper.contains( "cablight_sw:" ) ) {
|
||||
// TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels
|
||||
WriteLog( "Interior Light switch is missing, or wasn't defined" );
|
||||
return;
|
||||
}
|
||||
// visual feedback
|
||||
Train->ggCabLightButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||
Train->btCabLight.Turn( false );
|
||||
// store lighting switch states
|
||||
if( false == Train->DynamicObject->JointCabs ) {
|
||||
// vehicles with separate cabs get separate lighting switch states
|
||||
@@ -6800,10 +6794,6 @@ bool TTrain::Update( double const Deltatime )
|
||||
}
|
||||
ggLocalBrake.Update();
|
||||
}
|
||||
if (ggManualBrake.SubModel != nullptr) {
|
||||
ggManualBrake.UpdateValue(double(mvOccupied->ManualBrakePos));
|
||||
ggManualBrake.Update();
|
||||
}
|
||||
ggAlarmChain.Update();
|
||||
ggBrakeProfileCtrl.Update();
|
||||
ggBrakeProfileG.Update();
|
||||
@@ -6940,7 +6930,6 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggInstrumentLightButton.Update();
|
||||
ggDashboardLightButton.Update();
|
||||
ggTimetableLightButton.Update();
|
||||
ggCabLightButton.Update();
|
||||
ggCabLightDimButton.Update();
|
||||
ggCompartmentLightsButton.Update();
|
||||
ggCompartmentLightsOnButton.Update();
|
||||
@@ -7617,6 +7606,8 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName)
|
||||
cabindex = 0;
|
||||
break;
|
||||
}
|
||||
iCabn = cabindex;
|
||||
|
||||
std::string cabstr("cab" + std::to_string(cabindex) + "definition:");
|
||||
|
||||
cParser parser(asFileName, cParser::buffer_FILE);
|
||||
@@ -8212,7 +8203,6 @@ void TTrain::clear_cab_controls()
|
||||
ggDirKey.Clear();
|
||||
ggBrakeCtrl.Clear();
|
||||
ggLocalBrake.Clear();
|
||||
ggManualBrake.Clear();
|
||||
ggAlarmChain.Clear();
|
||||
ggBrakeProfileCtrl.Clear();
|
||||
ggBrakeProfileG.Clear();
|
||||
@@ -8253,7 +8243,6 @@ void TTrain::clear_cab_controls()
|
||||
ggDashboardLightButton.Clear();
|
||||
ggTimetableLightButton.Clear();
|
||||
// hunter-091012
|
||||
ggCabLightButton.Clear();
|
||||
ggCabLightDimButton.Clear();
|
||||
ggCompartmentLightsButton.Clear();
|
||||
ggCompartmentLightsOnButton.Clear();
|
||||
@@ -8403,7 +8392,6 @@ void TTrain::clear_cab_controls()
|
||||
btLampkaRearRightLight.Clear();
|
||||
btLampkaRearLeftEndLight.Clear();
|
||||
btLampkaRearRightEndLight.Clear();
|
||||
btCabLight.Clear(); // hunter-171012
|
||||
// others
|
||||
btLampkaMalfunction.Clear();
|
||||
btLampkaMalfunctionB.Clear();
|
||||
@@ -8579,9 +8567,6 @@ void TTrain::set_cab_controls( int const Cab ) {
|
||||
ggDimHeadlightsButton.PutValue( 1.f );
|
||||
}
|
||||
// cab lights
|
||||
if( true == Cabine[Cab].bLight ) {
|
||||
ggCabLightButton.PutValue( 1.f );
|
||||
}
|
||||
if( true == Cabine[Cab].bLightDim ) {
|
||||
ggCabLightDimButton.PutValue( 1.f );
|
||||
}
|
||||
@@ -8833,7 +8818,6 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
|
||||
{ "i-rearrightend:", btLampkaRearRightEndLight },
|
||||
{ "i-dashboardlight:", btDashboardLight },
|
||||
{ "i-timetablelight:", btTimetableLight },
|
||||
{ "i-cablight:", btCabLight },
|
||||
{ "i-universal0:", btUniversals[ 0 ] },
|
||||
{ "i-universal1:", btUniversals[ 1 ] },
|
||||
{ "i-universal2:", btUniversals[ 2 ] },
|
||||
@@ -8859,7 +8843,8 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
|
||||
{ "i-doorpermit_right:", &mvOccupied->Doors.instances[ ( cab_to_end() == end::front ? side::right : side::left ) ].open_permit },
|
||||
{ "i-doorstep:", &mvOccupied->Doors.step_enabled },
|
||||
{ "i-mainpipelock:", &mvOccupied->LockPipe },
|
||||
{ "i-battery:", &mvOccupied->Battery }
|
||||
{ "i-battery:", &mvOccupied->Battery },
|
||||
{ "i-cablight:", &Cabine[ iCabn ].bLight },
|
||||
};
|
||||
{
|
||||
auto lookup = autolights.find( Label );
|
||||
@@ -8918,7 +8903,6 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
{ "dirkey:" , ggDirKey },
|
||||
{ "brakectrl:", ggBrakeCtrl },
|
||||
{ "localbrake:", ggLocalBrake },
|
||||
{ "manualbrake:", ggManualBrake },
|
||||
{ "alarmchain:", ggAlarmChain },
|
||||
{ "brakeprofile_sw:", ggBrakeProfileCtrl },
|
||||
{ "brakeprofileg_sw:", ggBrakeProfileG },
|
||||
@@ -9015,7 +8999,6 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
{ "instrumentlight_sw:", ggInstrumentLightButton },
|
||||
{ "dashboardlight_sw:", ggDashboardLightButton },
|
||||
{ "timetablelight_sw:", ggTimetableLightButton },
|
||||
{ "cablight_sw:", ggCabLightButton },
|
||||
{ "cablightdim_sw:", ggCabLightDimButton },
|
||||
{ "compartmentlights_sw:", ggCompartmentLightsButton },
|
||||
{ "compartmentlightson_sw:", ggCompartmentLightsOnButton },
|
||||
@@ -9084,6 +9067,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
{ "pantfrontoff_sw:", &mvControlled->Pantographs[end::front].valve.is_disabled },
|
||||
{ "pantrearoff_sw:", &mvControlled->Pantographs[end::rear].valve.is_disabled },
|
||||
{ "radio_sw:", &mvOccupied->Radio },
|
||||
{ "cablight_sw:", &Cabine[ iCabn ].bLight },
|
||||
};
|
||||
{
|
||||
auto lookup = autoboolgauges.find( Label );
|
||||
@@ -9095,6 +9079,20 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// TODO: move viable dedicated gauges to the automatic array
|
||||
std::unordered_map<std::string, int *> const autointgauges = {
|
||||
{ "manualbrake:", &mvOccupied->ManualBrakePos },
|
||||
};
|
||||
{
|
||||
auto lookup = autointgauges.find( Label );
|
||||
if( lookup != autointgauges.end() ) {
|
||||
auto &gauge = Cabine[ Cabindex ].Gauge( -1 ); // pierwsza wolna lampka
|
||||
gauge.Load( Parser, DynamicObject );
|
||||
gauge.AssignInt( lookup->second );
|
||||
m_controlmapper.insert( gauge, lookup->first );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// ABu 090305: uniwersalne przyciski lub inne rzeczy
|
||||
if( Label == "mainctrlact:" ) {
|
||||
|
||||
5
Train.h
5
Train.h
@@ -459,7 +459,6 @@ public: // reszta może by?publiczna
|
||||
TGauge ggDirKey;
|
||||
TGauge ggBrakeCtrl;
|
||||
TGauge ggLocalBrake;
|
||||
TGauge ggManualBrake;
|
||||
TGauge ggAlarmChain;
|
||||
TGauge ggBrakeProfileCtrl; // nastawiacz GPR - przelacznik obrotowy
|
||||
TGauge ggBrakeProfileG; // nastawiacz GP - hebelek towarowy
|
||||
@@ -539,7 +538,7 @@ public: // reszta może by?publiczna
|
||||
TGauge ggInstrumentLightButton;
|
||||
TGauge ggDashboardLightButton;
|
||||
TGauge ggTimetableLightButton;
|
||||
TGauge ggCabLightButton; // hunter-091012: przelacznik oswietlania kabiny
|
||||
// TGauge ggCabLightButton; // hunter-091012: przelacznik oswietlania kabiny
|
||||
TGauge ggCabLightDimButton; // hunter-091012: przelacznik przyciemnienia
|
||||
// oswietlenia kabiny
|
||||
TGauge ggCompartmentLightsButton;
|
||||
@@ -691,7 +690,7 @@ public: // reszta może by?publiczna
|
||||
TButton btLampkaTempomat;
|
||||
TButton btLampkaDistanceCounter;
|
||||
|
||||
TButton btCabLight; // hunter-171012: lampa oswietlajaca kabine
|
||||
// TButton btCabLight; // hunter-171012: lampa oswietlajaca kabine
|
||||
// Ra 2013-12: wirtualne "lampki" do odbijania na haslerze w PoKeys
|
||||
TButton btHaslerBrakes; // ciśnienie w cylindrach
|
||||
TButton btHaslerCurrent; // prąd na silnikach
|
||||
|
||||
Reference in New Issue
Block a user