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:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user