1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-16 07:07:13 +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

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);
}
}
// ------------------------------------------------------------------------------------------------

View File

@ -12,7 +12,8 @@ namespace SqMod {
*/
enum ObjectCircularLocks
{
OBJECTCL_EMIT_OBJECT_WORLD = (1 << 0)
OBJECTCL_EMIT_OBJECT_WORLD = (1 << 0),
OBJECTCL_EMIT_OBJECT_ALPHA = (2 << 0)
};
/* ------------------------------------------------------------------------------------------------
@ -235,12 +236,12 @@ public:
/* --------------------------------------------------------------------------------------------
* Modify the alpha of the managed object entity.
*/
void SetAlpha(Int32 alpha) const;
void SetAlpha(Int32 alpha);
/* --------------------------------------------------------------------------------------------
* Modify the alpha of the managed object entity over the specified time.
*/
void SetAlphaEx(Int32 alpha, Uint32 time) const;
void SetAlphaEx(Int32 alpha, Uint32 time);
/* --------------------------------------------------------------------------------------------
* Move the managed object entity to the specified position over the specified time.