mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 22:09:19 +02:00
second controller animation improvement, minor bug fixes
This commit is contained in:
110
Train.cpp
110
Train.cpp
@@ -1103,24 +1103,28 @@ void TTrain::OnCommand_secondcontrollerincrease( TTrain *Train, command_data con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// regular mode
|
||||||
|
// push or pushtoggle control type
|
||||||
if( Train->ggScndCtrl.is_push() ) {
|
if( Train->ggScndCtrl.is_push() ) {
|
||||||
// two-state control, active while the button is down
|
|
||||||
if( Command.action == GLFW_PRESS ) {
|
if( Command.action == GLFW_PRESS ) {
|
||||||
// activate on press
|
// activate on press
|
||||||
Train->mvControlled->IncScndCtrl( 1 );
|
Train->mvControlled->IncScndCtrl( 1 );
|
||||||
}
|
}
|
||||||
else if( Command.action == GLFW_RELEASE ) {
|
|
||||||
// zero on release
|
|
||||||
Train->mvControlled->DecScndCtrl( 2 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// toggle control type
|
||||||
else {
|
else {
|
||||||
// multi-state control
|
|
||||||
if( Command.action != GLFW_RELEASE ) {
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
// on press or hold
|
|
||||||
Train->mvControlled->IncScndCtrl( 1 );
|
Train->mvControlled->IncScndCtrl( 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// HACK: potentially animate push or pushtoggle control
|
||||||
|
if( Train->ggScndCtrl.is_push() ) {
|
||||||
|
auto const activeposition { Train->ggScndCtrl.is_toggle() ? 1.f : 1.f };
|
||||||
|
auto const neutralposition { Train->ggScndCtrl.is_toggle() ? 0.5f : 0.f };
|
||||||
|
Train->ggScndCtrl.UpdateValue(
|
||||||
|
( ( Command.action == GLFW_RELEASE ) ? neutralposition : activeposition ),
|
||||||
|
Train->dsbSwitch );
|
||||||
|
}
|
||||||
// potentially animate tempomat button
|
// potentially animate tempomat button
|
||||||
if( ( Train->ggScndCtrlButton.is_push() )
|
if( ( Train->ggScndCtrlButton.is_push() )
|
||||||
&& ( Train->mvControlled->ScndCtrlPos <= 1 ) ) {
|
&& ( Train->mvControlled->ScndCtrlPos <= 1 ) ) {
|
||||||
@@ -1250,30 +1254,53 @@ void TTrain::OnCommand_mucurrentindicatorothersourceactivate( TTrain *Train, com
|
|||||||
|
|
||||||
void TTrain::OnCommand_secondcontrollerdecrease( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_secondcontrollerdecrease( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
if( Command.action != GLFW_RELEASE ) {
|
if( ( Train->mvControlled->EngineType == TEngineType::DieselElectric )
|
||||||
// on press or hold
|
&& ( true == Train->mvControlled->ShuntMode ) ) {
|
||||||
if( ( Train->mvControlled->EngineType == TEngineType::DieselElectric )
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
&& ( true == Train->mvControlled->ShuntMode ) ) {
|
|
||||||
Train->mvControlled->AnPos = clamp(
|
Train->mvControlled->AnPos = clamp(
|
||||||
Train->mvControlled->AnPos - 0.025,
|
Train->mvControlled->AnPos - 0.025,
|
||||||
0.0, 1.0 );
|
0.0, 1.0 );
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
Train->mvControlled->DecScndCtrl( 1 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// potentially animate tempomat button
|
else {
|
||||||
if( ( Train->ggScndCtrlButton.is_push() )
|
// regular mode
|
||||||
&& ( Train->mvControlled->ScndCtrlPos <= 1 ) ) {
|
// push or pushtoggle control type
|
||||||
if( Train->m_controlmapper.contains( "tempomatoff_sw:" ) ) {
|
if( Train->ggScndCtrl.is_push() ) {
|
||||||
Train->ggScndCtrlOffButton.UpdateValue(
|
// basic push control can't decrease state, but pushtoggle can
|
||||||
( ( Command.action == GLFW_RELEASE ) ? 0.f : 1.f ),
|
if( true == Train->ggScndCtrl.is_toggle() ) {
|
||||||
|
if( Command.action == GLFW_PRESS ) {
|
||||||
|
// activate on press
|
||||||
|
Train->mvControlled->DecScndCtrl( 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// toggle control type
|
||||||
|
else {
|
||||||
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
|
Train->mvControlled->DecScndCtrl( 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// HACK: potentially animate push or pushtoggle control
|
||||||
|
if( Train->ggScndCtrl.is_push() ) {
|
||||||
|
auto const activeposition { Train->ggScndCtrl.is_toggle() ? 0.f : 1.f };
|
||||||
|
auto const neutralposition { Train->ggScndCtrl.is_toggle() ? 0.5f : 0.f };
|
||||||
|
Train->ggScndCtrl.UpdateValue(
|
||||||
|
( ( Command.action == GLFW_RELEASE ) ? neutralposition : activeposition ),
|
||||||
Train->dsbSwitch );
|
Train->dsbSwitch );
|
||||||
}
|
}
|
||||||
else {
|
// potentially animate tempomat button
|
||||||
Train->ggScndCtrlButton.UpdateValue(
|
if( ( Train->ggScndCtrlButton.is_push() )
|
||||||
( ( Command.action == GLFW_RELEASE ) ? 0.f : 1.f ),
|
&& ( Train->mvControlled->ScndCtrlPos <= 1 ) ) {
|
||||||
Train->dsbSwitch );
|
if( Train->m_controlmapper.contains( "tempomatoff_sw:" ) ) {
|
||||||
|
Train->ggScndCtrlOffButton.UpdateValue(
|
||||||
|
( ( Command.action == GLFW_RELEASE ) ? 0.f : 1.f ),
|
||||||
|
Train->dsbSwitch );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Train->ggScndCtrlButton.UpdateValue(
|
||||||
|
( ( Command.action == GLFW_RELEASE ) ? 0.f : 1.f ),
|
||||||
|
Train->dsbSwitch );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1294,9 +1321,23 @@ void TTrain::OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data
|
|||||||
|
|
||||||
void TTrain::OnCommand_secondcontrollerset( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_secondcontrollerset( TTrain *Train, command_data const &Command ) {
|
||||||
|
|
||||||
|
auto const targetposition{ std::min<int>( Command.param1, Train->mvControlled->ScndCtrlPosNo ) };
|
||||||
|
// HACK: potentially animate push or pushtoggle control
|
||||||
|
if( Train->ggScndCtrl.is_push() ) {
|
||||||
|
auto const activeposition {
|
||||||
|
Train->ggScndCtrl.is_toggle() ?
|
||||||
|
( targetposition < Train->mvControlled->ScndCtrlPos ? 0.f :
|
||||||
|
targetposition > Train->mvControlled->ScndCtrlPos ? 1.f :
|
||||||
|
Train->ggScndCtrl.GetDesiredValue() ) : // leave the control in its current position if it hits the limit
|
||||||
|
( targetposition == 0 ? 0.f : 1.f ) };
|
||||||
|
auto const neutralposition { Train->ggScndCtrl.is_toggle() ? 0.5f : 0.f };
|
||||||
|
Train->ggScndCtrl.UpdateValue(
|
||||||
|
( ( Command.action == GLFW_RELEASE ) ? neutralposition : activeposition ),
|
||||||
|
Train->dsbSwitch );
|
||||||
|
}
|
||||||
|
// update control value
|
||||||
if( Command.action != GLFW_RELEASE ) {
|
if( Command.action != GLFW_RELEASE ) {
|
||||||
// on press or hold
|
// on press or hold
|
||||||
auto const targetposition{ std::min<int>( Command.param1, Train->mvControlled->ScndCtrlPosNo ) };
|
|
||||||
while( ( targetposition < Train->mvControlled->ScndCtrlPos )
|
while( ( targetposition < Train->mvControlled->ScndCtrlPos )
|
||||||
&& ( true == Train->mvControlled->DecScndCtrl( 1 ) ) ) {
|
&& ( true == Train->mvControlled->DecScndCtrl( 1 ) ) ) {
|
||||||
// all work is done in the header
|
// all work is done in the header
|
||||||
@@ -7121,10 +7162,12 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
}
|
}
|
||||||
if (ggScndCtrl.SubModel != nullptr ) {
|
if (ggScndCtrl.SubModel != nullptr ) {
|
||||||
// Ra: od byte odejmowane boolean i konwertowane potem na double?
|
// Ra: od byte odejmowane boolean i konwertowane potem na double?
|
||||||
ggScndCtrl.UpdateValue(
|
if( false == ggScndCtrl.is_push() ) {
|
||||||
double( mvControlled->ScndCtrlPos
|
ggScndCtrl.UpdateValue(
|
||||||
- ( ( mvControlled->TrainType == dt_ET42 ) && mvControlled->DynamicBrakeFlag ) ),
|
double( mvControlled->ScndCtrlPos
|
||||||
dsbNastawnikBocz );
|
- ( ( mvControlled->TrainType == dt_ET42 ) && mvControlled->DynamicBrakeFlag ) ),
|
||||||
|
dsbNastawnikBocz );
|
||||||
|
}
|
||||||
ggScndCtrl.Update();
|
ggScndCtrl.Update();
|
||||||
}
|
}
|
||||||
if( ggScndCtrlButton.SubModel != nullptr ) {
|
if( ggScndCtrlButton.SubModel != nullptr ) {
|
||||||
@@ -8784,7 +8827,7 @@ void TTrain::set_cab_controls( int const Cab ) {
|
|||||||
// battery
|
// battery
|
||||||
ggBatteryButton.PutValue(
|
ggBatteryButton.PutValue(
|
||||||
( ggBatteryButton.type() == TGaugeType::push ? 0.5f :
|
( ggBatteryButton.type() == TGaugeType::push ? 0.5f :
|
||||||
mvOccupied->Battery ? 1.f :
|
mvOccupied->Power24vIsAvailable ? 1.f :
|
||||||
0.f ) );
|
0.f ) );
|
||||||
// line breaker
|
// line breaker
|
||||||
if( ggMainButton.SubModel != nullptr ) { // instead of single main button there can be on/off pair
|
if( ggMainButton.SubModel != nullptr ) { // instead of single main button there can be on/off pair
|
||||||
@@ -9073,6 +9116,13 @@ void TTrain::set_cab_controls( int const Cab ) {
|
|||||||
1.f :
|
1.f :
|
||||||
0.f );
|
0.f );
|
||||||
}
|
}
|
||||||
|
// second controller
|
||||||
|
if( ggScndCtrl.is_push() ) {
|
||||||
|
ggScndCtrl.PutValue(
|
||||||
|
ggScndCtrl.is_toggle() ?
|
||||||
|
0.5f : // pushtoggle is two-way control with neutral position in the middle
|
||||||
|
0.f ); // push is on/off control, active while held down, due to legacy use
|
||||||
|
}
|
||||||
// tempomat
|
// tempomat
|
||||||
if( false == ggScndCtrlButton.is_push() ) {
|
if( false == ggScndCtrlButton.is_push() ) {
|
||||||
ggScndCtrlButton.PutValue(
|
ggScndCtrlButton.PutValue(
|
||||||
|
|||||||
@@ -593,7 +593,7 @@ TController::cue_action( locale::string const Action, float const Actionparamete
|
|||||||
Action,
|
Action,
|
||||||
[this](float const Parameter) -> bool {
|
[this](float const Parameter) -> bool {
|
||||||
auto const &device { mvControlling->WaterPump };
|
auto const &device { mvControlling->WaterPump };
|
||||||
return ( ( device.start_type != start_t::manual ) || ( ( device.is_enabled == true ) && ( device.is_disabled == false ) ) ); } );
|
return ( ( device.start_type != start_t::manual ) || ( ( device.is_enabled == true ) && ( device.is_disabled == false ) ) || ( device.is_active == true ) ); } );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case locale::string::driver_hint_waterpumpoff: {
|
case locale::string::driver_hint_waterpumpoff: {
|
||||||
@@ -1128,7 +1128,7 @@ TController::cue_action( locale::string const Action, float const Actionparamete
|
|||||||
Action,
|
Action,
|
||||||
[this](float const Parameter) -> bool {
|
[this](float const Parameter) -> bool {
|
||||||
auto const &device { mvOccupied->CompartmentLights };
|
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 ) ) ); } );
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case locale::string::driver_hint_consistlightsoff: {
|
case locale::string::driver_hint_consistlightsoff: {
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ init() {
|
|||||||
"Zalaczyc wentylatory tylnych silnikow trakcyjnych",
|
"Zalaczyc wentylatory tylnych silnikow trakcyjnych",
|
||||||
"Wylaczyc wentylatory tylnych silnikow trakcyjnych",
|
"Wylaczyc wentylatory tylnych silnikow trakcyjnych",
|
||||||
"Zalaczyc hamulec sprezynowy",
|
"Zalaczyc hamulec sprezynowy",
|
||||||
"Zwolnic hamules sprezynowy",
|
"Zwolnic hamulec sprezynowy",
|
||||||
"Zalaczyc hamulec reczny",
|
"Zalaczyc hamulec reczny",
|
||||||
"Zwolnic hamulec reczny",
|
"Zwolnic hamulec reczny",
|
||||||
"Ustawic nastawnik jazdy na pozycje biegu jalowego",
|
"Ustawic nastawnik jazdy na pozycje biegu jalowego",
|
||||||
|
|||||||
Reference in New Issue
Block a user