2016-02-20 23:25:00 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2015-09-30 02:56:11 +02:00
|
|
|
#include "Entity/Textdraw.hpp"
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Entity/Player.hpp"
|
2015-10-29 21:55:36 +01:00
|
|
|
#include "Base/Vector2i.hpp"
|
2015-11-01 00:33:04 +01:00
|
|
|
#include "Core.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
2015-11-01 00:33:04 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
const Int32 CTextdraw::Max = SQMOD_TEXTDRAW_POOL;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
SQInteger CTextdraw::Typename(HSQUIRRELVM vm)
|
|
|
|
{
|
|
|
|
static SQChar name[] = _SC("SqTextdraw");
|
|
|
|
sq_pushstring(vm, name, sizeof(name));
|
|
|
|
return 1;
|
|
|
|
}
|
2016-02-20 23:25:00 +01:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
CTextdraw::CTextdraw(Int32 id)
|
|
|
|
: m_ID(VALID_ENTITYGETEX(id, SQMOD_TEXTDRAW_POOL))
|
2016-03-10 04:57:13 +01:00
|
|
|
, m_Tag(ToStrF("%d", id))
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
|
|
|
/* ... */
|
|
|
|
}
|
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
CTextdraw::~CTextdraw()
|
2015-10-29 21:55:36 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
/* ... */
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 CTextdraw::Cmp(const CTextdraw & o) const
|
|
|
|
{
|
|
|
|
if (m_ID == o.m_ID)
|
|
|
|
return 0;
|
|
|
|
else if (m_ID > o.m_ID)
|
|
|
|
return 1;
|
2015-10-29 21:55:36 +01:00
|
|
|
else
|
2016-02-20 23:25:00 +01:00
|
|
|
return -1;
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const String & CTextdraw::ToString() const
|
2015-10-29 21:55:36 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
const String & CTextdraw::GetTag() const
|
2015-10-29 21:55:36 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
return m_Tag;
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetTag(CSStr tag)
|
|
|
|
{
|
|
|
|
m_Tag.assign(tag);
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
Object & CTextdraw::GetData()
|
2015-10-29 21:55:36 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return m_Data;
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetData(Object & data)
|
2015-10-29 21:55:36 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Apply the specified value
|
|
|
|
m_Data = data;
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
bool CTextdraw::Destroy(Int32 header, Object & payload)
|
2015-10-29 21:55:36 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-02-20 23:25:00 +01:00
|
|
|
return _Core->DelTextdraw(m_ID, header, payload);
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
void CTextdraw::BindEvent(Int32 evid, Object & env, Function & func) const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Obtain the function instance called for this event
|
2016-02-20 23:25:00 +01:00
|
|
|
Function & event = _Core->GetTextdrawEvent(m_ID, evid);
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified callback function null?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (func.IsNull())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
event.Release(); // Then release the current callback
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Assign the specified environment and function
|
2015-10-29 21:55:36 +01:00
|
|
|
else
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
event = Function(env.GetVM(), env, func.GetFunc());
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::ShowAll() const
|
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->ShowTextdraw(m_ID, -1);
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::ShowFor(CPlayer & player) const
|
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified player even valid?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (!player.IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player argument: null");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->ShowTextdraw(m_ID, player.GetID());
|
2016-02-20 23:25:00 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::ShowRange(Int32 first, Int32 last) const
|
2015-10-29 21:55:36 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the specified range
|
2016-02-20 23:25:00 +01:00
|
|
|
if (first > last)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player range: %d > %d", first, last);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
for (; first <= last; ++first)
|
|
|
|
{
|
|
|
|
// Is the currently processed player even connected?
|
|
|
|
if (_Func->IsPlayerConnected(first))
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Then show this textdraw on his client
|
|
|
|
_Func->ShowTextdraw(m_ID, first);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::HideAll() const
|
2015-10-29 21:55:36 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->HideTextdraw(m_ID, -1);
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::HideFor(CPlayer & player) const
|
2015-10-29 21:55:36 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified player even valid?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (!player.IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player argument: null");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
2016-03-12 21:51:44 +01:00
|
|
|
_Func->HideTextdraw(m_ID, player.GetID());
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::HideRange(Int32 first, Int32 last) const
|
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the specified range
|
2016-02-20 23:25:00 +01:00
|
|
|
if (first > last)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player range: %d > %d", first, last);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
for (; first <= last; ++first)
|
|
|
|
{
|
|
|
|
// Is the currently processed player even connected?
|
|
|
|
if (_Func->IsPlayerConnected(first))
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Then hide this textdraw on his client
|
|
|
|
_Func->HideTextdraw(m_ID, first);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetPositionAll(const Vector2i & pos) const
|
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->MoveTextdraw(m_ID, -1, pos.x, pos.y);
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetPositionAllEx(Int32 x, Int32 y) const
|
2015-10-29 21:55:36 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->MoveTextdraw(m_ID, -1, x, y);
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetPositionFor(CPlayer & player, const Vector2i & pos) const
|
2015-10-29 21:55:36 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified player even valid?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (!player.IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player argument: null");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->MoveTextdraw(m_ID, player.GetID(), pos.x, pos.y);
|
2015-10-29 21:55:36 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified player even valid?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (!player.IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player argument: null");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->MoveTextdraw(m_ID, player.GetID(), x, y);
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) const
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the specified range
|
2016-02-20 23:25:00 +01:00
|
|
|
if (first > last)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player range: %d > %d", first, last);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
for (; first <= last; ++first)
|
|
|
|
{
|
|
|
|
// Is the currently processed player even connected?
|
|
|
|
if (_Func->IsPlayerConnected(first))
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Then move this textdraw on his client
|
|
|
|
_Func->MoveTextdraw(m_ID, first, pos.x, pos.y);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetColorAll(const Color4 & col) const
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetTextdrawColour(m_ID, -1, col.GetRGBA());
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetColorAllEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetTextdrawColour(m_ID, -1, SQMOD_PACK_RGBA(r, g, b, a));
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetColorFor(CPlayer & player, const Color4 & col) const
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified player even valid?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (!player.IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player argument: null");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetTextdrawColour(m_ID, player.GetID(), col.GetRGBA());
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetColorForEx(CPlayer & player, Uint8 r, Uint8 g, Uint8 b, Uint8 a) const
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Is the specified player even valid?
|
2016-02-20 23:25:00 +01:00
|
|
|
if (!player.IsActive())
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player argument: null");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
_Func->SetTextdrawColour(m_ID, player.GetID(), SQMOD_PACK_RGBA(r, g, b, a));
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
void CTextdraw::SetColorRange(Int32 first, Int32 last, const Color4 & col) const
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the specified range
|
2016-02-20 23:25:00 +01:00
|
|
|
if (first > last)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid player range: %d > %d", first, last);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Perform the requested operation
|
|
|
|
for (const Uint32 color = col.GetRGBA(); first <= last; ++first)
|
|
|
|
{
|
|
|
|
// Is the currently processed player even connected?
|
|
|
|
if (_Func->IsPlayerConnected(first))
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Then colorize this textdraw on his client
|
|
|
|
_Func->SetTextdrawColour(m_ID, first, color);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
const String & CTextdraw::GetText() const
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
// Validate the managed identifier
|
|
|
|
Validate();
|
|
|
|
// Return the requested information
|
|
|
|
return _Core->GetTextdraw(m_ID).mText;
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Textdraw_CreateEx(CSStr text, Int32 xp, Int32 yp,
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint8 r, Uint8 g, Uint8 b, Uint8 a, bool rel)
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, xp, yp, SQMOD_PACK_ARGB(a, r, g, b), rel,
|
|
|
|
SQMOD_CREATE_DEFAULT, NullObject());
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static Object & Textdraw_CreateEx(CSStr text, Int32 xp, Int32 yp,
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint8 r, Uint8 g, Uint8 b, Uint8 a, bool rel,
|
|
|
|
Int32 header, Object & payload)
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, xp, yp, SQMOD_PACK_ARGB(a, r, g, b), rel,
|
2015-11-01 00:33:04 +01:00
|
|
|
header, payload);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Textdraw_CreateEx(Int32 index, CSStr text, Int32 xp, Int32 yp,
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint8 r, Uint8 g, Uint8 b, Uint8 a, bool rel)
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return _Core->NewTextdraw(index,text, xp, yp, SQMOD_PACK_ARGB(a, r, g, b), rel,
|
|
|
|
SQMOD_CREATE_DEFAULT, NullObject());
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static Object & Textdraw_CreateEx(Int32 index, CSStr text, Int32 xp, Int32 yp,
|
2016-02-20 23:25:00 +01:00
|
|
|
Uint8 r, Uint8 g, Uint8 b, Uint8 a, bool rel,
|
|
|
|
Int32 header, Object & payload)
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return _Core->NewTextdraw(index, text, xp, yp, SQMOD_PACK_ARGB(a, r, g, b), rel,
|
2015-11-01 00:33:04 +01:00
|
|
|
header, payload);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Textdraw_Create(CSStr text, const Vector2i & pos, const Color4 & color, bool rel)
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
|
|
|
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, pos.x, pos.y, color.GetARGB(), rel,
|
2016-02-20 23:25:00 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullObject());
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static Object & Textdraw_Create(CSStr text, const Vector2i & pos, const Color4 & color, bool rel,
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 header, Object & payload)
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
|
|
|
return _Core->NewTextdraw(SQMOD_UNKNOWN, text, pos.x, pos.y, color.GetARGB(), rel,
|
|
|
|
header, payload);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
static Object & Textdraw_Create(Int32 index, CSStr text, const Vector2i & pos, const Color4 & color,
|
2016-02-20 23:25:00 +01:00
|
|
|
bool rel)
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
|
|
|
return _Core->NewTextdraw(index, text, pos.x, pos.y, color.GetARGB(), rel,
|
2016-02-20 23:25:00 +01:00
|
|
|
SQMOD_CREATE_DEFAULT, NullObject());
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static Object & Textdraw_Create(Int32 index, CSStr text, const Vector2i & pos, const Color4 & color,
|
2016-02-20 23:25:00 +01:00
|
|
|
bool rel, Int32 header, Object & payload)
|
2015-11-01 00:33:04 +01:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
return _Core->NewTextdraw(index, text, pos.x, pos.y, color.GetARGB(), rel, header, payload);
|
2015-11-01 00:33:04 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 05:18:39 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static const Object & Textdraw_FindByID(Int32 id)
|
|
|
|
{
|
|
|
|
// Perform a range check on the specified identifier
|
|
|
|
if (INVALID_ENTITYEX(id, SQMOD_TEXTDRAW_POOL))
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("The specified textdraw identifier is invalid: %d", id);
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 05:18:39 +01:00
|
|
|
// Obtain the ends of the entity pool
|
|
|
|
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
|
|
|
|
Core::Textdraws::const_iterator end = _Core->GetTextdraws().cend();
|
|
|
|
// Process each entity in the pool
|
|
|
|
for (; itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Does the identifier match the specified one?
|
|
|
|
if (itr->mID == id)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 05:18:39 +01:00
|
|
|
return itr->mObj; // Stop searching and return this entity
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 05:18:39 +01:00
|
|
|
}
|
|
|
|
// Unable to locate a textdraw matching the specified identifier
|
|
|
|
return NullObject();
|
|
|
|
}
|
|
|
|
|
2016-03-26 17:17:31 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-03-10 05:18:39 +01:00
|
|
|
static const Object & Textdraw_FindByTag(CSStr tag)
|
|
|
|
{
|
|
|
|
// Perform a validity check on the specified tag
|
2016-03-12 21:51:44 +01:00
|
|
|
if (!tag || *tag == '\0')
|
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("The specified textdraw tag is invalid: null/empty");
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 05:18:39 +01:00
|
|
|
// Obtain the ends of the entity pool
|
|
|
|
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
|
|
|
|
Core::Textdraws::const_iterator end = _Core->GetTextdraws().cend();
|
|
|
|
// Process each entity in the pool
|
|
|
|
for (; itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Does this entity even exist and does the tag match the specified one?
|
|
|
|
if (itr->mInst != nullptr && itr->mInst->GetTag().compare(tag) == 0)
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-10 05:18:39 +01:00
|
|
|
return itr->mObj; // Stop searching and return this entity
|
2016-03-12 21:51:44 +01:00
|
|
|
}
|
2016-03-10 05:18:39 +01:00
|
|
|
}
|
|
|
|
// Unable to locate a textdraw matching the specified tag
|
|
|
|
return NullObject();
|
|
|
|
}
|
|
|
|
|
2016-03-26 17:17:31 +01:00
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
static Array Textdraw_FindActive()
|
|
|
|
{
|
|
|
|
// Remember the initial stack size
|
|
|
|
StackGuard sg;
|
|
|
|
// Obtain the ends of the entity pool
|
|
|
|
Core::Textdraws::const_iterator itr = _Core->GetTextdraws().cbegin();
|
|
|
|
Core::Textdraws::const_iterator end = _Core->GetTextdraws().cend();
|
|
|
|
// Allocate an empty array on the stack
|
|
|
|
sq_newarray(DefaultVM::Get(), 0);
|
|
|
|
// Process each entity in the pool
|
|
|
|
for (; itr != end; ++itr)
|
|
|
|
{
|
|
|
|
// Is this entity instance active?
|
|
|
|
if (VALID_ENTITY(itr->mID))
|
|
|
|
{
|
|
|
|
// Push the script object on the stack
|
|
|
|
sq_pushobject(DefaultVM::Get(), (HSQOBJECT &)((*itr).mObj));
|
|
|
|
// Append the object at the back of the array
|
|
|
|
if (SQ_FAILED(sq_arrayappend(DefaultVM::Get(), -1)))
|
|
|
|
{
|
|
|
|
STHROWF("Unable to append entity instance to the list");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Return the array at the top of the stack
|
|
|
|
return Var< Array >(DefaultVM::Get(), -1).value;
|
|
|
|
}
|
|
|
|
|
2015-10-29 21:55:36 +01:00
|
|
|
// ================================================================================================
|
2016-02-20 23:25:00 +01:00
|
|
|
void Register_CTextdraw(HSQUIRRELVM vm)
|
|
|
|
{
|
|
|
|
RootTable(vm).Bind(_SC("SqTextdraw"),
|
|
|
|
Class< CTextdraw, NoConstructor< CTextdraw > >(vm, _SC("SqTextdraw"))
|
2016-03-10 04:57:13 +01:00
|
|
|
// Metamethods
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("_cmp"), &CTextdraw::Cmp)
|
2016-03-10 04:57:13 +01:00
|
|
|
.SquirrelFunc(_SC("_typename"), &CTextdraw::Typename)
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("_tostring"), &CTextdraw::ToString)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Static Values
|
2016-03-10 04:57:13 +01:00
|
|
|
.SetStaticValue(_SC("MaxID"), CTextdraw::Max)
|
|
|
|
// Core Properties
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("ID"), &CTextdraw::GetID)
|
|
|
|
.Prop(_SC("Tag"), &CTextdraw::GetTag, &CTextdraw::SetTag)
|
|
|
|
.Prop(_SC("Data"), &CTextdraw::GetData, &CTextdraw::SetData)
|
|
|
|
.Prop(_SC("Active"), &CTextdraw::IsActive)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Core Methods
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("Bind"), &CTextdraw::BindEvent)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Core Overloads
|
2016-02-20 23:25:00 +01:00
|
|
|
.Overload< bool (CTextdraw::*)(void) >(_SC("Destroy"), &CTextdraw::Destroy)
|
|
|
|
.Overload< bool (CTextdraw::*)(Int32) >(_SC("Destroy"), &CTextdraw::Destroy)
|
|
|
|
.Overload< bool (CTextdraw::*)(Int32, Object &) >(_SC("Destroy"), &CTextdraw::Destroy)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Properties
|
2016-02-20 23:25:00 +01:00
|
|
|
.Prop(_SC("Text"), &CTextdraw::GetText)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Member Methods
|
2016-02-20 23:25:00 +01:00
|
|
|
.Func(_SC("ShowAll"), &CTextdraw::ShowAll)
|
|
|
|
.Func(_SC("ShowTo"), &CTextdraw::ShowFor)
|
|
|
|
.Func(_SC("ShowFor"), &CTextdraw::ShowFor)
|
|
|
|
.Func(_SC("ShowRange"), &CTextdraw::ShowRange)
|
|
|
|
.Func(_SC("HideAll"), &CTextdraw::HideAll)
|
|
|
|
.Func(_SC("HideFor"), &CTextdraw::HideFor)
|
|
|
|
.Func(_SC("HideFrom"), &CTextdraw::HideFor)
|
|
|
|
.Func(_SC("HideRange"), &CTextdraw::HideRange)
|
|
|
|
.Func(_SC("SetPositionRange"), &CTextdraw::SetPositionRange)
|
|
|
|
.Func(_SC("SetColorRange"), &CTextdraw::SetColorRange)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Member Overloads
|
2015-10-29 21:55:36 +01:00
|
|
|
.Overload< void (CTextdraw::*)(const Vector2i &) const >
|
2016-02-20 23:25:00 +01:00
|
|
|
(_SC("SetPositionAll"), &CTextdraw::SetPositionAll)
|
|
|
|
.Overload< void (CTextdraw::*)(Int32, Int32) const >
|
|
|
|
(_SC("SetPositionAll"), &CTextdraw::SetPositionAllEx)
|
|
|
|
.Overload< void (CTextdraw::*)(CPlayer &, const Vector2i &) const >
|
|
|
|
(_SC("SetPositionFor"), &CTextdraw::SetPositionFor)
|
|
|
|
.Overload< void (CTextdraw::*)(CPlayer &, Int32, Int32) const >
|
|
|
|
(_SC("SetPositionFor"), &CTextdraw::SetPositionForEx)
|
2015-10-29 21:55:36 +01:00
|
|
|
.Overload< void (CTextdraw::*)(const Color4 &) const >
|
2016-02-20 23:25:00 +01:00
|
|
|
(_SC("SetColorAll"), &CTextdraw::SetColorAll)
|
2015-10-29 21:55:36 +01:00
|
|
|
.Overload< void (CTextdraw::*)(Uint8, Uint8, Uint8, Uint8) const >
|
2016-02-20 23:25:00 +01:00
|
|
|
(_SC("SetColorAll"), &CTextdraw::SetColorAllEx)
|
|
|
|
.Overload< void (CTextdraw::*)(CPlayer &, const Color4 &) const >
|
|
|
|
(_SC("SetColorFor"), &CTextdraw::SetColorFor)
|
|
|
|
.Overload< void (CTextdraw::*)(CPlayer &, Uint8, Uint8, Uint8, Uint8) const >
|
|
|
|
(_SC("SetColorFor"), &CTextdraw::SetColorForEx)
|
2016-03-10 05:18:39 +01:00
|
|
|
// Static Functions
|
|
|
|
.StaticFunc(_SC("FindByID"), &Textdraw_FindByID)
|
|
|
|
.StaticFunc(_SC("FindByTag"), &Textdraw_FindByTag)
|
2016-03-26 17:17:31 +01:00
|
|
|
.StaticFunc(_SC("FindActive"), &Textdraw_FindActive)
|
2016-03-10 04:57:13 +01:00
|
|
|
// Static Overloads
|
|
|
|
.StaticOverload< Object & (*)(CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool) >
|
|
|
|
(_SC("CreateEx"), &Textdraw_CreateEx)
|
|
|
|
.StaticOverload< Object & (*)(CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool, Int32, Object &) >
|
|
|
|
(_SC("CreateEx"), &Textdraw_CreateEx)
|
|
|
|
.StaticOverload< Object & (*)(Int32, CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool) >
|
|
|
|
(_SC("CreateEx"), &Textdraw_CreateEx)
|
|
|
|
.StaticOverload< Object & (*)(Int32, CSStr, Int32, Int32, Uint8, Uint8, Uint8, Uint8, bool, Int32, Object &) >
|
|
|
|
(_SC("CreateEx"), &Textdraw_CreateEx)
|
|
|
|
.StaticOverload< Object & (*)(CSStr, const Vector2i &, const Color4 &, bool) >
|
|
|
|
(_SC("Create"), &Textdraw_Create)
|
|
|
|
.StaticOverload< Object & (*)(CSStr, const Vector2i &, const Color4 &, bool, Int32, Object &) >
|
|
|
|
(_SC("Create"), &Textdraw_Create)
|
|
|
|
.StaticOverload< Object & (*)(Int32, CSStr, const Vector2i &, const Color4 &, bool) >
|
|
|
|
(_SC("Create"), &Textdraw_Create)
|
|
|
|
.StaticOverload< Object & (*)(Int32, CSStr, const Vector2i &, const Color4 &, bool, Int32, Object &) >
|
|
|
|
(_SC("Create"), &Textdraw_Create)
|
2015-09-30 02:56:11 +02:00
|
|
|
);
|
2016-03-10 04:57:13 +01:00
|
|
|
}
|
2015-09-30 02:56:11 +02:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
} // Namespace:: SqMod
|