2015-09-30 02:56:11 +02:00
|
|
|
#ifndef _ENTITY_TEXTDRAW_HPP_
|
|
|
|
#define _ENTITY_TEXTDRAW_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
#include "Base/Shared.hpp"
|
2015-09-30 02:56:11 +02:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Manages a single textdraw entity.
|
2015-09-30 02:56:11 +02:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
class CTextdraw
|
2015-09-30 02:56:11 +02:00
|
|
|
{
|
2016-02-20 23:25:00 +01:00
|
|
|
// --------------------------------------------------------------------------------------------
|
|
|
|
friend class Core;
|
2015-10-29 22:14:17 +01:00
|
|
|
|
2016-02-20 23:25:00 +01:00
|
|
|
private:
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Identifier of the managed entity.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 m_ID;
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* User tag associated with this instance.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
String m_Tag;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* User data associated with this instance.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Object m_Data;
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Base constructor.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
CTextdraw(Int32 id);
|
2015-10-29 21:55:36 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
public:
|
|
|
|
|
2015-10-29 21:55:36 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Maximum possible number that could represent an identifier for this entity type.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
static const Int32 Max;
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Copy constructor. (disabled)
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
CTextdraw(const CTextdraw &) = delete;
|
2015-10-29 21:55:36 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move constructor. (disabled)
|
|
|
|
*/
|
|
|
|
CTextdraw(CTextdraw &&) = delete;
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Destructor.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
~CTextdraw();
|
2015-10-29 21:55:36 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Copy assignment operator. (disabled)
|
|
|
|
*/
|
|
|
|
CTextdraw & operator = (const CTextdraw &) = delete;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move assignment operator. (disabled)
|
|
|
|
*/
|
|
|
|
CTextdraw & operator = (CTextdraw &&) = delete;
|
|
|
|
|
2015-10-29 21:55:36 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* See whether this instance manages a valid entity.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
void Validate() const
|
2016-02-20 23:25:00 +01:00
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
if (INVALID_ENTITY(m_ID))
|
2016-03-12 21:51:44 +01:00
|
|
|
{
|
2016-03-21 21:37:58 +01:00
|
|
|
STHROWF("Invalid textdraw reference [%s]", m_Tag.c_str());
|
2016-03-12 21:51:44 +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
|
|
|
* Used by the script engine to compare two instances of this type.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Int32 Cmp(const CTextdraw & o) const;
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Used by the script engine to convert an instance of this type to a string.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
const String & ToString() const;
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Used by the script engine to retrieve the name from instances of this type.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
static SQInteger Typename(HSQUIRRELVM vm);
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-03-10 04:57:13 +01:00
|
|
|
* Retrieve the identifier of the entity managed by this instance.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
Int32 GetID() const
|
|
|
|
{
|
|
|
|
return m_ID;
|
|
|
|
}
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Check whether this instance manages a valid entity.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
bool IsActive() const
|
|
|
|
{
|
|
|
|
return VALID_ENTITY(m_ID);
|
|
|
|
}
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the associated user tag.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-03-10 04:57:13 +01:00
|
|
|
const String & GetTag() const;
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Modify the associated user tag.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetTag(CSStr tag);
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Retrieve the associated user data.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
Object & GetData();
|
2015-10-29 21:55:36 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-02-20 23:25:00 +01:00
|
|
|
* Modify the associated user data.
|
2015-10-29 21:55:36 +01:00
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetData(Object & data);
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destroy the managed textdraw entity.
|
|
|
|
*/
|
|
|
|
bool Destroy()
|
|
|
|
{
|
|
|
|
return Destroy(0, NullObject());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destroy the managed textdraw entity.
|
|
|
|
*/
|
|
|
|
bool Destroy(Int32 header)
|
|
|
|
{
|
|
|
|
return Destroy(header, NullObject());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destroy the managed textdraw entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
bool Destroy(Int32 header, Object & payload);
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Bind to an event supported by this entity type.
|
|
|
|
*/
|
|
|
|
void BindEvent(Int32 evid, Object & env, Function & func) const;
|
2016-02-20 23:25:00 +01:00
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Show the managed textdraw entity to all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void ShowAll() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Show the managed textdraw entity to the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void ShowFor(CPlayer & player) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Show the managed textdraw entity to all players in the specified range.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void ShowRange(Int32 first, Int32 last) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Hide the managed textdraw entity from all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void HideAll() const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Hide the managed textdraw entity from the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void HideFor(CPlayer & player) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Hide the managed textdraw entity from all players in the specified range.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void HideRange(Int32 first, Int32 last) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the position of the managed textdraw entity for all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionAll(const Vector2i & pos) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the position of the managed textdraw entity for all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionAllEx(Int32 x, Int32 y) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the position of the managed textdraw entity for the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionFor(CPlayer & player, const Vector2i & pos) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the position of the managed textdraw entity for the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionForEx(CPlayer & player, Int32 x, Int32 y) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the position of the managed textdraw entity for all players in the specified range.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetPositionRange(Int32 first, Int32 last, const Vector2i & pos) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the center of the managed textdraw entity for all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetColorAll(const Color4 & col) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the color of the managed textdraw entity for all players on the server.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetColorAllEx(Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the color of the managed textdraw entity for the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetColorFor(CPlayer & player, const Color4 & col) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the color of the managed textdraw entity for the specified player entity.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetColorForEx(CPlayer & player, Uint8 r, Uint8 g, Uint8 b, Uint8 a) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the color of the managed textdraw entity for all players in the specified range.
|
|
|
|
*/
|
2016-02-20 23:25:00 +01:00
|
|
|
void SetColorRange(Int32 first, Int32 last, const Color4 & col) const;
|
2016-03-10 04:57:13 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the text string used by the managed textdraw entity.
|
|
|
|
*/
|
|
|
|
const String & GetText() const;
|
2015-09-30 02:56:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
|
|
|
#endif // _ENTITY_TEXTDRAW_HPP_
|