16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 06:29:18 +02:00

event condition fixes, cab light control enhancement, manual brake control enhancement

This commit is contained in:
tmj-fstate
2020-03-12 22:29:33 +01:00
parent a8b47c3c97
commit e0c1f41474
4 changed files with 28 additions and 30 deletions

View File

@@ -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:" ) {