1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 16:57:16 +01:00
SqMod/source/Entity/Keybind.cpp

97 lines
2.9 KiB
C++
Raw Normal View History

2015-09-30 02:56:11 +02:00
#include "Entity/Keybind.hpp"
#include "Register.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
// ------------------------------------------------------------------------------------------------
SQInt32 CKeybind::GetPrimary() const noexcept
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Primary;
}
else
{
LogWrn(_SC("[SOURCE: CKeybind::GetPrimary()] [INFO: Invalid reference] [DATA: (this::m_ID {0:d})]"), m_ID);
}
return SQMOD_UNKNOWN;
}
// ------------------------------------------------------------------------------------------------
SQInt32 CKeybind::GetSecondary() const noexcept
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Secondary;
}
else
{
LogWrn(_SC("[SOURCE: CKeybind::GetSecondary()] [INFO: Invalid reference] [DATA: (this::m_ID {0:d})]"), m_ID);
}
return SQMOD_UNKNOWN;
}
// ------------------------------------------------------------------------------------------------
SQInt32 CKeybind::GetAlternative() const noexcept
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Alternative;
}
else
{
LogWrn(_SC("[SOURCE: CKeybind::GetAlternative()] [INFO: Invalid reference] [DATA: (this::m_ID {0:d})]"), m_ID);
}
return SQMOD_UNKNOWN;
}
// ------------------------------------------------------------------------------------------------
bool CKeybind::IsRelease() const noexcept
{
if (VALID_ENTITY(m_ID))
{
RefType::Get(m_ID).Release;
}
else
{
LogWrn(_SC("[SOURCE: CKeybind::IsRelease()] [INFO: Invalid reference] [DATA: (this::m_ID {0:d})]"), m_ID);
}
return false;
}
// ================================================================================================
2015-09-30 02:56:11 +02:00
bool Register_CKeybind(HSQUIRRELVM vm)
{
// Attempt to register the base reference type before the actual implementation
2015-09-30 02:56:11 +02:00
if (!Register_Reference< CKeybind >(vm, _SC("BaseKeybind")))
{
LogFtl("Unable to register the base class <BaseKeybind> for <CKeybind> type");
// Registration failed
2015-09-30 02:56:11 +02:00
return false;
}
// Output debugging information
2015-09-30 02:56:11 +02:00
LogDbg("Beginning registration of <CKeybind> type");
// Attempt to register the actual reference that implements all of the entity functionality
2015-09-30 02:56:11 +02:00
Sqrat::RootTable(vm).Bind(_SC("CKeybind"), Sqrat::DerivedClass< CKeybind, Reference< CKeybind > >(vm, _SC("CKeybind"))
/* Constructors */
2015-09-30 02:56:11 +02:00
.Ctor()
.Ctor< SQInt32 >()
/* Properties */
.Prop(_SC("primary"), &CKeybind::GetPrimary)
.Prop(_SC("secondary"), &CKeybind::GetSecondary)
.Prop(_SC("alternative"), &CKeybind::GetAlternative)
.Prop(_SC("is_release"), &CKeybind::IsRelease)
2015-09-30 02:56:11 +02:00
);
// Output debugging information
2015-09-30 02:56:11 +02:00
LogDbg("Registration of <CKeybind> type was successful");
// Registration succeeded
2015-09-30 02:56:11 +02:00
return true;
}
} // Namespace:: SqMod