mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-20 19:44:58 +01:00
Merge pull request #286 from MaSzyna-EU07/fix/dimmer-position-bounds
fix(lights): keep the headlight dimmer position within the DimmerList
This commit is contained in:
@@ -7431,9 +7431,7 @@ void TDynamicObject::RaLightsSet(int head, int rear)
|
||||
bool tRight = MoverParameters->iLights[vehicleend] & (light::auxiliary_right | light::headlight_right); // a tu z prawej
|
||||
if (Controller == Humandriver) {
|
||||
|
||||
int ¤tDimPos = MoverParameters->modernDimmerPosition;
|
||||
auto &dimmerPositions = MoverParameters->dimPositions;
|
||||
TMoverParameters::dimPosition dps = dimmerPositions[currentDimPos];
|
||||
auto const dps{MoverParameters->currentDimPosition()};
|
||||
|
||||
// domyślnie
|
||||
HighBeamLights = false;
|
||||
@@ -7495,9 +7493,7 @@ void TDynamicObject::SetLightDimmings()
|
||||
if (Controller == Humandriver)
|
||||
{
|
||||
|
||||
int ¤tDimPos = MoverParameters->modernDimmerPosition;
|
||||
auto &dimmerPositions = MoverParameters->dimPositions;
|
||||
TMoverParameters::dimPosition dps = dimmerPositions[currentDimPos];
|
||||
auto const dps{MoverParameters->currentDimPosition()};
|
||||
|
||||
// domyślnie
|
||||
HighBeamLights = false;
|
||||
|
||||
@@ -723,7 +723,7 @@ std::shared_ptr<dictionary_source> TTrain::GetTrainState(dictionary_source const
|
||||
dict->insert("pant_compressor", mvPantographUnit->PantCompFlag);
|
||||
dict->insert("lights_front", mvOccupied->iLights[end::front]);
|
||||
dict->insert("lights_rear", mvOccupied->iLights[end::rear]);
|
||||
dict->insert("off_from_dimmer", mvOccupied->dimPositions[mvOccupied->modernDimmerPosition].isOff);
|
||||
dict->insert("off_from_dimmer", mvOccupied->currentDimPosition().isOff);
|
||||
dict->insert("lights_compartments", mvOccupied->CompartmentLights.is_active || mvOccupied->CompartmentLights.is_disabled);
|
||||
if (Dynamic()->Mechanik)
|
||||
{
|
||||
@@ -6068,14 +6068,9 @@ void TTrain::OnCommand_modernlightdimmerincrease(TTrain *Train, command_data con
|
||||
if (Command.action == GLFW_PRESS)
|
||||
{
|
||||
// update modern dimmer state
|
||||
|
||||
auto &dimPos = Train->mvOccupied->modernDimmerPosition;
|
||||
if (auto dimCount = Train->mvOccupied->dimPositions.size(); dimPos + 1 < dimCount)
|
||||
dimPos++;
|
||||
else if (Train->mvOccupied->modernDimmerCanCycle)
|
||||
dimPos = 0; // return to 0
|
||||
else
|
||||
return; // już na minimum i nie można cyklicznie
|
||||
if (false == Train->mvOccupied->stepDimmerPosition(1))
|
||||
return; // już na maksimum i nie można cyklicznie
|
||||
auto const dimPos = Train->mvOccupied->modernDimmerPosition;
|
||||
// update lightning
|
||||
// Train->Dynamic()->SetLights();
|
||||
Train->Dynamic()->SetLightDimmings();
|
||||
@@ -6092,18 +6087,9 @@ void TTrain::OnCommand_modernlightdimmerdecrease(TTrain *Train, command_data con
|
||||
|
||||
if (Command.action == GLFW_PRESS)
|
||||
{
|
||||
auto &dimPos = Train->mvOccupied->modernDimmerPosition;
|
||||
auto dimCount = Train->mvOccupied->dimPositions.size();
|
||||
|
||||
if (dimCount == 0)
|
||||
return;
|
||||
|
||||
if (dimPos > 0)
|
||||
dimPos--;
|
||||
else if (Train->mvOccupied->modernDimmerCanCycle)
|
||||
dimPos = static_cast<int>(dimCount - 1); // ostatnia pozycja
|
||||
else
|
||||
if (false == Train->mvOccupied->stepDimmerPosition(-1))
|
||||
return; // już na minimum i nie można cyklicznie
|
||||
auto const dimPos = Train->mvOccupied->modernDimmerPosition;
|
||||
|
||||
// Train->Dynamic()->SetLights();
|
||||
Train->Dynamic()->SetLightDimmings();
|
||||
@@ -6344,7 +6330,7 @@ void TTrain::OnCommand_headlightsdimenable(TTrain *Train, command_data const &Co
|
||||
|
||||
Train->DynamicObject->DimHeadlights = true;
|
||||
*/
|
||||
Train->DynamicObject->MoverParameters->modernDimmerPosition = 1; // ustawiamy modern dimmer na flage przyciemnienia
|
||||
Train->DynamicObject->MoverParameters->modernDimmerPosition = Train->DynamicObject->MoverParameters->clampDimmerPosition(1); // ustawiamy modern dimmer na flage przyciemnienia
|
||||
Train->DynamicObject->SetLightDimmings();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user