mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
General lights overhaul
Add modern light switcher Available fiz variables with defualt parameters Headlights: LampRed=255 LampGreen=255 LampBlue=255 DimmedMultiplier=0.6 NormalMultiplier=1.0 HighbeamDimmedMultiplier=2.5 HighBeamMultiplier=2.8 Switches: ModernDimmer=No ModernDimmerOffPosition=Yes
This commit is contained in:
81
Train.cpp
81
Train.cpp
@@ -377,6 +377,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
|
||||
{ user_command::headlighttogglerearupper, &TTrain::OnCommand_headlighttogglerearupper },
|
||||
{ user_command::headlightenablerearupper, &TTrain::OnCommand_headlightenablerearupper },
|
||||
{ user_command::headlightdisablerearupper, &TTrain::OnCommand_headlightdisablerearupper },
|
||||
{user_command::modernlightdimmerdecrease, &TTrain::OnCommand_modernlightdimmerdecrease},
|
||||
{user_command::modernlightdimmerincrease, &TTrain::OnCommand_modernlightdimmerincrease},
|
||||
{ user_command::redmarkertogglerearleft, &TTrain::OnCommand_redmarkertogglerearleft },
|
||||
{ user_command::redmarkerenablerearleft, &TTrain::OnCommand_redmarkerenablerearleft },
|
||||
{ user_command::redmarkerdisablerearleft, &TTrain::OnCommand_redmarkerdisablerearleft },
|
||||
@@ -4699,6 +4701,44 @@ void TTrain::OnCommand_headlightdisablerearupper( TTrain *Train, command_data co
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_modernlightdimmerincrease(TTrain* Train, command_data const& Command)
|
||||
{
|
||||
if (!Train->mvOccupied->enableModernDimmer)
|
||||
return; // if modern dimmer is disabled, skip entire command
|
||||
if (Command.action == GLFW_PRESS)
|
||||
{
|
||||
// update modern dimmer state
|
||||
if (Train->mvOccupied->modernDimmerState < 4)
|
||||
Train->mvOccupied->modernDimmerState++;
|
||||
Train->Dynamic()->SetLights();
|
||||
// visual feedback
|
||||
if (Train->ggModernLightDimSw.SubModel != nullptr)
|
||||
if (Train->mvOccupied->modernContainOffPos)
|
||||
Train->ggModernLightDimSw.UpdateValue(Train->mvOccupied->modernDimmerState, Train->dsbSwitch);
|
||||
else
|
||||
Train->ggModernLightDimSw.UpdateValue(Train->mvOccupied->modernDimmerState - 1, Train->dsbSwitch);
|
||||
}
|
||||
}
|
||||
void TTrain::OnCommand_modernlightdimmerdecrease(TTrain *Train, command_data const &Command)
|
||||
{
|
||||
if (!Train->mvOccupied->enableModernDimmer)
|
||||
return; // if modern dimmer is disabled, skip entire command
|
||||
if (Command.action == GLFW_PRESS)
|
||||
{
|
||||
byte minPos = (Train->mvOccupied->modernContainOffPos) ? 0 : 1; // prevent switching to 0 if its not enabled
|
||||
// update modern dimmer state
|
||||
if (Train->mvOccupied->modernDimmerState > minPos)
|
||||
Train->mvOccupied->modernDimmerState--;
|
||||
Train->Dynamic()->SetLights();
|
||||
// visual feedback
|
||||
if (Train->ggModernLightDimSw.SubModel != nullptr)
|
||||
if (Train->mvOccupied->modernContainOffPos)
|
||||
Train->ggModernLightDimSw.UpdateValue(Train->mvOccupied->modernDimmerState, Train->dsbSwitch);
|
||||
else
|
||||
Train->ggModernLightDimSw.UpdateValue(Train->mvOccupied->modernDimmerState - 1, Train->dsbSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_redmarkertogglerearleft( TTrain *Train, command_data const &Command ) {
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// NOTE: we toggle the light on opposite side, as 'rear right' is 'front left' on the rear end etc
|
||||
@@ -4896,17 +4936,22 @@ void TTrain::OnCommand_headlightsdimenable( 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->ggDimHeadlightsButton.SubModel == nullptr ) {
|
||||
if( Train->ggDimHeadlightsButton.SubModel != nullptr ) {
|
||||
// TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels
|
||||
WriteLog( "Dim Headlights switch is missing, or wasn't defined" );
|
||||
return;
|
||||
// visual feedback
|
||||
Train->ggDimHeadlightsButton.UpdateValue(1.0, Train->dsbSwitch);
|
||||
}
|
||||
// visual feedback
|
||||
Train->ggDimHeadlightsButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||
|
||||
if( true == Train->DynamicObject->DimHeadlights ) { return; } // already enabled
|
||||
/* // to jest stara logika
|
||||
if (true == Train->DynamicObject->DimHeadlights)
|
||||
{
|
||||
return;
|
||||
} // already enabled
|
||||
|
||||
Train->DynamicObject->DimHeadlights = true;
|
||||
*/
|
||||
|
||||
Train->mvOccupied->modernDimmerState = 1; // ustawiamy modern dimmer na flage przyciemnienia
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4914,17 +4959,20 @@ void TTrain::OnCommand_headlightsdimdisable( 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->ggDimHeadlightsButton.SubModel == nullptr ) {
|
||||
if( Train->ggDimHeadlightsButton.SubModel != nullptr ) {
|
||||
// TODO: proper control deviced definition for the interiors, that doesn't hinge of presence of 3d submodels
|
||||
WriteLog( "Dim Headlights switch is missing, or wasn't defined" );
|
||||
return;
|
||||
// visual feedback
|
||||
Train->ggDimHeadlightsButton.UpdateValue(0.0, Train->dsbSwitch);
|
||||
}
|
||||
// visual feedback
|
||||
Train->ggDimHeadlightsButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||
|
||||
|
||||
/* // stara logika przyciemniania
|
||||
if( false == Train->DynamicObject->DimHeadlights ) { return; } // already enabled
|
||||
|
||||
Train->DynamicObject->DimHeadlights = false;
|
||||
|
||||
*/
|
||||
Train->mvOccupied->modernDimmerState = 2; // ustawiamy modern dimmer na flage rozjasnienia
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8004,6 +8052,7 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggRightLightButton.Update();
|
||||
ggLeftEndLightButton.Update();
|
||||
ggRightEndLightButton.Update();
|
||||
ggModernLightDimSw.Update();
|
||||
// hunter-230112
|
||||
ggRearUpperLightButton.Update();
|
||||
ggRearLeftLightButton.Update();
|
||||
@@ -8011,6 +8060,7 @@ bool TTrain::Update( double const Deltatime )
|
||||
ggRearLeftEndLightButton.Update();
|
||||
ggRearRightEndLightButton.Update();
|
||||
ggDimHeadlightsButton.Update();
|
||||
ggDimHeadlightsButton.Update();
|
||||
//------------
|
||||
ggConverterButton.Update();
|
||||
ggConverterLocalButton.Update();
|
||||
@@ -9600,6 +9650,7 @@ void TTrain::clear_cab_controls()
|
||||
ggRightLightButton.Clear();
|
||||
ggUpperLightButton.Clear();
|
||||
ggDimHeadlightsButton.Clear();
|
||||
ggModernLightDimSw.Clear();
|
||||
ggLeftEndLightButton.Clear();
|
||||
ggRightEndLightButton.Clear();
|
||||
ggLightsButton.Clear();
|
||||
@@ -9631,6 +9682,13 @@ void TTrain::set_cab_controls( int const Cab ) {
|
||||
m_linebreakerstate > 0 ? 1.f :
|
||||
0.f ) );
|
||||
}
|
||||
|
||||
if (ggModernLightDimSw.SubModel != nullptr) {
|
||||
ggModernLightDimSw.PutValue(
|
||||
mvOccupied->modernDimmerState
|
||||
);
|
||||
}
|
||||
|
||||
// motor connectors
|
||||
ggStLinOffButton.PutValue(
|
||||
( mvControlled->StLinSwitchOff ?
|
||||
@@ -10190,6 +10248,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
{ "leftend_sw:", ggLeftEndLightButton },
|
||||
{ "rightend_sw:", ggRightEndLightButton },
|
||||
{ "lights_sw:", ggLightsButton },
|
||||
{ "moderndimmer_sw:", ggModernLightDimSw },
|
||||
{ "rearupperlight_sw:", ggRearUpperLightButton },
|
||||
{ "rearleftlight_sw:", ggRearLeftLightButton },
|
||||
{ "rearrightlight_sw:", ggRearRightLightButton },
|
||||
|
||||
Reference in New Issue
Block a user