1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
4 // This file is part of Scorched3D.
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #if !defined(__INCLUDE_LUAScriptHook_INCLUDE__)
22 #define __INCLUDE_LUAScriptHook_INCLUDE__
24 #include <lua/LUAScriptFactory.h>
25 #include <lang/LangString.h>
42 Param(fixed innumber
) :
43 number(innumber
), type(eNumber
) {};
44 Param(const char *instr
) :
45 str(instr
), type(eString
) {};
46 Param(const std::string
&instr
) :
47 str(instr
), type(eString
) {};
48 Param(const LangString
&instr
) :
49 str(LangStringUtil::convertFromLang(instr
)), type(eString
) {};
51 boolean(b
), type(eBoolean
) {};
59 LUAScriptHook(LUAScriptFactory
*factory
,
60 const std::string
&hooksName
,
61 const std::string
&directoryName
);
64 void addHookProvider(const std::string
&hookName
);
66 void callHook(const std::string
&hookName
);
67 void callHook(const std::string
&hookName
, const Param
¶m1
);
68 void callHook(const std::string
&hookName
, const Param
¶m1
, const Param
¶m2
);
69 void callHook(const std::string
&hookName
, const Param
¶m1
, const Param
¶m2
, const Param
¶m3
);
79 std::string entryPoint
;
82 std::string directoryName_
, hooksName_
;
83 LUAScriptFactory
*factory_
;
84 std::map
<std::string
, std::vector
<HookEntry
> > hookNames_
;
85 bool loadHook(const std::string
&directoryName
, const std::string
&fileName
);
86 void reloadHooks() { loadHooks(); }
88 void callHookInternal(const std::string
&hookName
, const std::vector
<Param
> ¶ms
);
91 #endif // __INCLUDE_LUAScriptHook_INCLUDE__