Make SMXPanelAnimation stop temporarily if lights are set in another way.

This is a simple way of making it so things like the "light panels" button don't fight
with animations.
master
Glenn Maynard 5 years ago
parent 81eaae1f51
commit 36b006028a
  1. 3
      sdk/Windows/SMX.cpp
  2. 16
      sdk/Windows/SMXPanelAnimation.cpp
  3. 7
      sdk/Windows/SMXPanelAnimation.h

@ -95,6 +95,9 @@ SMX_API void SMX_SetLights2(const char *lightData, int lightDataSize)
}
SMXManager::g_pSMX->SetLights(lights);
// If we're running auto animations, stop them when we get an API call to set lights.
SMXAutoPanelAnimations::TemporaryStopAnimating();
}
// This is internal for SMXConfig. These lights aren't meant to be animated.

@ -383,6 +383,18 @@ bool SMX_LightsAnimation_Load(const char *gif, int size, int pad, SMX_LightsType
return true;
}
namespace
{
double g_fStopAnimatingUntil = -1;
}
void SMXAutoPanelAnimations::TemporaryStopAnimating()
{
// Stop animating for 100ms.
double fStopForSeconds = 1/10.0f;
g_fStopAnimatingUntil = SMX::GetMonotonicTime() + fStopForSeconds;
}
// A thread to handle setting light animations. We do this in a separate
// thread rather than in the SMXManager thread so this can be treated as
// if it's external application thread, and it's making normal threaded
@ -407,7 +419,11 @@ private:
while(!m_bShutdown)
{
// Check if we've temporarily stopped updating lights.
bool bSkipUpdate = g_fStopAnimatingUntil > SMX::GetMonotonicTime();
// Run a single panel lights update.
if(!bSkipUpdate)
UpdateLights();
// Wait up to 30 FPS, or until we're signalled. We can only be signalled

@ -28,6 +28,13 @@ public:
std::vector<float> m_iFrameDurations;
};
namespace SMXAutoPanelAnimations
{
// If SMX_LightsAnimation_SetAuto is active, stop sending animations briefly. This is
// called when lights are set directly, so they don't compete with the animation.
void TemporaryStopAnimating();
}
// For SMX_API:
#include "../SMX.h"

Loading…
Cancel
Save