From de293999872346271cdfb5dbecbad7f77362b83b Mon Sep 17 00:00:00 2001 From: faketruth Date: Fri, 27 Jan 2012 23:47:32 +0000 Subject: Converted entire Core plugin including WebAdmin interface to new plugin method/system/thingy and sexyfied it. Made some changes to WebAdmin to make the new plugins work Old plugins still work like they're supposed to Not all hooks have been programmed for the new plugins yet, this still needs to be done git-svn-id: http://mc-server.googlecode.com/svn/trunk@182 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/ManualBindings.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'source/ManualBindings.cpp') diff --git a/source/ManualBindings.cpp b/source/ManualBindings.cpp index 728320f11..a40bcb9d6 100644 --- a/source/ManualBindings.cpp +++ b/source/ManualBindings.cpp @@ -6,6 +6,7 @@ #include "cWorld.h" #include "cPlugin.h" #include "cPluginManager.h" +#include "cWebPlugin_Lua.h" #include "cLuaCommandBinder.h" #include "cPlayer.h" #include "md5/md5.h" @@ -191,6 +192,49 @@ static int tolua_cPlugin_BindCommand(lua_State* tolua_S) return 0; } +static int tolua_cWebPlugin_Lua_AddTab(lua_State* tolua_S) +{ + cWebPlugin_Lua* self = (cWebPlugin_Lua*) tolua_tousertype(tolua_S,1,0); + + tolua_Error tolua_err; + tolua_err.array = 0; + tolua_err.index = 0; + tolua_err.type = 0; + + std::string Title = ""; + int Reference = LUA_REFNIL; + + if( tolua_isstring( tolua_S, 2, 0, &tolua_err ) && + lua_isfunction( tolua_S, 3 ) ) + { + Reference = luaL_ref(tolua_S, LUA_REGISTRYINDEX); + Title = ((std::string) tolua_tocppstring(tolua_S,2,0)); + } + else + { + if( tolua_err.type == 0 ) + { + tolua_err.type = "function"; + } + tolua_error(tolua_S,"#ferror in function 'AddTab'.",&tolua_err); + return 0; + } + + if( Reference != LUA_REFNIL ) + { + if( !self->AddTab( Title.c_str(), tolua_S, Reference ) ) + { + luaL_unref( tolua_S, LUA_REGISTRYINDEX, Reference ); + } + } + else + { + LOGERROR("ERROR: cWebPlugin_Lua:AddTab invalid function reference in 2nd argument (Title: \"%s\")", Title.c_str() ); + } + + return 0; +} + static int tolua_md5(lua_State* tolua_S) { std::string SourceString = tolua_tostring(tolua_S, 1, 0); @@ -222,6 +266,9 @@ void ManualBindings::Bind( lua_State* tolua_S ) tolua_beginmodule(tolua_S,"cPlayer"); tolua_function(tolua_S,"GetGroups",tolua_cPlayer_GetGroups); tolua_endmodule(tolua_S); + tolua_beginmodule(tolua_S,"cWebPlugin_Lua"); + tolua_function(tolua_S,"AddTab",tolua_cWebPlugin_Lua_AddTab); + tolua_endmodule(tolua_S); tolua_function(tolua_S,"md5",tolua_md5); -- cgit v1.2.3