engine/include/ScriptManager/ScriptManager.h

121 lines
2.8 KiB
C
Raw Normal View History

2013-01-19 20:02:34 +00:00
#ifndef SCRIPT_MANAGER_H_INCLUDED
#define SCRIPT_MANAGER_H_INCLUDED
2017-01-10 04:10:36 +00:00
//#include "sqplus.h"
2013-01-19 20:02:34 +00:00
#include <iostream>
#include <string>
2017-01-10 04:10:36 +00:00
typedef char SQChar;
2013-01-19 20:02:34 +00:00
namespace SE
{
struct TScriptInfo
{
std::string LongName;
std::string ShortDescription;
std::string Description;
bool Registered;
TScriptInfo()
: Registered(false)
{
}
TScriptInfo(const std::string& longName, const std::string& shortDescription = "", const std::string& description = "")
: LongName(longName)
, ShortDescription(shortDescription)
, Description(description)
, Registered(false)
{
}
};
2017-01-10 04:10:36 +00:00
2013-01-19 20:02:34 +00:00
class TFunctionBinderInterface
{
public:
static std::vector<TFunctionBinderInterface*> BinderList;
TFunctionBinderInterface()
{
BinderList.push_back(this);
}
virtual void BindFunctions() = 0;
};
class TScriptManager : public TSerializeInterface
{
protected:
2017-01-10 04:10:36 +00:00
//HSQUIRRELVM virtualMachine;
//std::map<std::string, TScriptInfo> FuncInfoMap;
/*
2013-01-19 20:02:34 +00:00
template<typename T1,typename T2>
void RegisterFunc(T1& object, T2 method, const std::string& funcName)
{
SqPlus::RegisterGlobal(virtualMachine, object, method, _SC(funcName.c_str()));
}
template<typename T>
void RegisterFunc(T globalFunc, const std::string& funcName)
{
SqPlus::RegisterGlobal(virtualMachine, globalFunc, _SC(funcName.c_str()));
2017-01-10 04:10:36 +00:00
}*/
2013-01-19 20:02:34 +00:00
public:
TScriptManager();
~TScriptManager();
void AddFuncDescription(const std::string& shortName, TScriptInfo scriptInfo);
void RunScript(const std::string& scriptCode);
void BindBasicFunctions();
template<typename T1, typename T2>
void AddFunction(const std::string& shortName, TScriptInfo scriptInfo, T1& object, T2 method)
{
2017-01-10 04:10:36 +00:00
/*
2013-01-19 20:02:34 +00:00
AddFuncDescription(shortName, scriptInfo);
RegisterFunc(object, method, shortName);
RegisterFunc(object, method, scriptInfo.LongName);
2017-01-10 04:10:36 +00:00
FuncInfoMap[shortName].Registered = true;*/
2013-01-19 20:02:34 +00:00
}
template<typename T>
void AddFunction(const std::string& shortName, TScriptInfo scriptInfo, T globalFunc)
{
2017-01-10 04:10:36 +00:00
/*AddFuncDescription(shortName, scriptInfo);
2013-01-19 20:02:34 +00:00
RegisterFunc(globalFunc, shortName);
RegisterFunc(globalFunc, scriptInfo.LongName);
2017-01-10 04:10:36 +00:00
FuncInfoMap[shortName].Registered = true;*/
2013-01-19 20:02:34 +00:00
}
void BindFunctionsFromObject(TFunctionBinderInterface* binderObject);
void PrintRegisteredFunctionList();
void PrintFunctionInfo(const std::string& funcName);
virtual void Serialize(boost::property_tree::ptree& propertyTree);
};
2017-01-10 04:10:36 +00:00
//void SQ_Print(const SQChar *inString);
//void SQ_PrintWidgetList();
//void SQ_MoveWidget(const SQChar *widgetName, float x, float y);
2013-01-19 20:02:34 +00:00
//void SQ_PrintTextureList();
//void SQ_PrintAnimationList();
//void SQ_MoveWidgetTransformTaskTest(const SQChar *groupName, float x, float y, cardinal totalTime);
} //namespace SE
#endif