2013-01-19 20:02:34 +00:00
|
|
|
#ifndef SCRIPT_MANAGER_H_INCLUDED
|
|
|
|
#define SCRIPT_MANAGER_H_INCLUDED
|
|
|
|
|
2024-06-05 18:19:20 +00:00
|
|
|
//#include "sqplus.h"
|
2013-01-19 20:02:34 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TFunctionBinderInterface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static std::vector<TFunctionBinderInterface*> BinderList;
|
|
|
|
|
|
|
|
TFunctionBinderInterface()
|
|
|
|
{
|
|
|
|
BinderList.push_back(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void BindFunctions() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-06-05 18:19:20 +00:00
|
|
|
|
2013-01-19 20:02:34 +00:00
|
|
|
class TScriptManager : public TSerializeInterface
|
|
|
|
{
|
|
|
|
protected:
|
2024-06-05 18:19:20 +00:00
|
|
|
//HSQUIRRELVM virtualMachine;
|
2013-01-19 20:02:34 +00:00
|
|
|
std::map<std::string, TScriptInfo> FuncInfoMap;
|
|
|
|
|
|
|
|
template<typename T1,typename T2>
|
|
|
|
void RegisterFunc(T1& object, T2 method, const std::string& funcName)
|
|
|
|
{
|
2024-06-05 18:19:20 +00:00
|
|
|
//SqPlus::RegisterGlobal(virtualMachine, object, method, _SC(funcName.c_str()));
|
2013-01-19 20:02:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void RegisterFunc(T globalFunc, const std::string& funcName)
|
|
|
|
{
|
2024-06-05 18:19:20 +00:00
|
|
|
//SqPlus::RegisterGlobal(virtualMachine, globalFunc, _SC(funcName.c_str()));
|
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)
|
|
|
|
{
|
|
|
|
AddFuncDescription(shortName, scriptInfo);
|
|
|
|
RegisterFunc(object, method, shortName);
|
|
|
|
RegisterFunc(object, method, scriptInfo.LongName);
|
|
|
|
FuncInfoMap[shortName].Registered = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
void AddFunction(const std::string& shortName, TScriptInfo scriptInfo, T globalFunc)
|
|
|
|
{
|
|
|
|
AddFuncDescription(shortName, scriptInfo);
|
|
|
|
RegisterFunc(globalFunc, shortName);
|
|
|
|
RegisterFunc(globalFunc, scriptInfo.LongName);
|
|
|
|
FuncInfoMap[shortName].Registered = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BindFunctionsFromObject(TFunctionBinderInterface* binderObject);
|
|
|
|
|
|
|
|
void PrintRegisteredFunctionList();
|
|
|
|
|
|
|
|
void PrintFunctionInfo(const std::string& funcName);
|
|
|
|
|
|
|
|
virtual void Serialize(boost::property_tree::ptree& propertyTree);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-06-05 18:19:20 +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
|