2012-11-08 14:09:35 -05:00
|
|
|
|
2012-07-08 17:01:08 -04:00
|
|
|
#pragma once
|
2012-11-08 14:09:35 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef USE_SQUIRREL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-07-08 17:01:08 -04:00
|
|
|
#include "SquirrelBindings.h"
|
2012-09-23 18:09:57 -04:00
|
|
|
#include "../Plugin_Squirrel.h"
|
|
|
|
#include "../PluginManager.h"
|
|
|
|
#include "../Root.h"
|
|
|
|
#include "../SquirrelCommandBinder.h"
|
2012-07-08 17:01:08 -04:00
|
|
|
|
2012-11-08 14:09:35 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// The baseclass for squirrel plugins
|
2012-07-08 17:01:08 -04:00
|
|
|
class cSquirrelBaseClass
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cSquirrelBaseClass()
|
|
|
|
: m_Instance(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void setInstance(cPlugin_Squirrel *a_Instance)
|
|
|
|
{
|
|
|
|
m_Instance = a_Instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddHook(short a_Hook)
|
|
|
|
{
|
|
|
|
if(m_Instance)
|
|
|
|
cRoot::Get()->GetPluginManager()->AddHook(m_Instance, (cPluginManager::PluginHook) a_Hook);
|
|
|
|
}
|
|
|
|
|
2012-07-09 11:53:17 -04:00
|
|
|
void AddCommand( std::string a_Command, std::string a_Description, std::string a_Permission )
|
|
|
|
{
|
|
|
|
if(m_Instance) m_Instance->AddCommand(a_Command, a_Description, a_Permission);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BindCommand( const std::string a_Command, const std::string a_Permission, Sqrat::Function a_Callback)
|
|
|
|
{
|
|
|
|
if(!m_Instance) return false;
|
|
|
|
return cRoot::Get()->GetPluginManager()->GetSquirrelCommandBinder()->BindCommand(a_Command, a_Permission, m_Instance, a_Callback);
|
|
|
|
}
|
|
|
|
|
2012-07-08 17:01:08 -04:00
|
|
|
protected:
|
|
|
|
cPlugin_Squirrel *m_Instance;
|
2012-11-08 14:09:35 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif // USE_SQUIRREL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|