1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2026-07-09 01:57:09 +02:00

Implement a new event to receive notifications when an object alpha has changed.

This commit is contained in:
Sandu Liviu Catalin
2016-08-18 16:50:30 +03:00
parent 3bbff3f258
commit 9ce8a8a4f8
6 changed files with 39 additions and 10 deletions
+19 -7
View File
@@ -217,21 +217,33 @@ Int32 CObject::GetAlpha() const
}
// ------------------------------------------------------------------------------------------------
void CObject::SetAlpha(Int32 alpha) const
void CObject::SetAlpha(Int32 alpha)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
_Func->SetObjectAlpha(m_ID, alpha, 0);
SetAlphaEx(alpha, 0);
}
// ------------------------------------------------------------------------------------------------
void CObject::SetAlphaEx(Int32 alpha, Uint32 time) const
void CObject::SetAlphaEx(Int32 alpha, Uint32 time)
{
// Validate the managed identifier
Validate();
// Perform the requested operation
// Grab the current value for this property
const Int32 current = _Func->GetObjectAlpha(m_ID);
// Don't even bother if it's the same value
if (current == alpha)
{
return;
}
// Avoid property unwind from a recursive call
_Func->SetObjectAlpha(m_ID, alpha, time);
// Avoid infinite recursive event loops
if (!(m_CircularLocks & OBJECTCL_EMIT_OBJECT_ALPHA))
{
// Prevent this event from triggering while executed
BitGuardU32 bg(m_CircularLocks, OBJECTCL_EMIT_OBJECT_ALPHA);
// Now forward the event call
Core::Get().EmitObjectAlpha(m_ID, current, alpha, time);
}
}
// ------------------------------------------------------------------------------------------------