本文整理汇总了C#中LWF.Movie.AddEventHandler方法的典型用法代码示例。如果您正苦于以下问题:C# Movie.AddEventHandler方法的具体用法?C# Movie.AddEventHandler怎么用?C# Movie.AddEventHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LWF.Movie
的用法示例。
在下文中一共展示了Movie.AddEventHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddEventHandlerLua
public int AddEventHandlerLua(Movie movie = null, Button button = null)
{
if (luaState==null)
return 0;
Lua.lua_State l = (Lua.lua_State)luaState;
string ev;
int luaHandlerId;
int handlerId;
/* 1: LWF_LWF instance */
/* 2: string */
/* 3: function */
ev = Lua.lua_tostring(l, 2).ToString();
Lua.lua_getglobal(l, "LWF");
/* -1: LWF */
if (!Lua.lua_istable(l, -1)) {
Lua.lua_pop(l, 1);
/* 0 */
goto error;
}
Lua.lua_getfield(l, -1, "Instances");
/* -2: LWF */
/* -1: LWF.Instances */
Lua.lua_remove(l, -2);
/* -1: LWF.Instances */
if (!Lua.lua_istable(l, -1)) {
Lua.lua_pop(l, 1);
/* 0 */
goto error;
}
Lua.lua_getfield(l, -1, instanceIdString);
/* -2: LWF.Instances */
/* -1: LWF.Instances.<instanceId> */
Lua.lua_remove(l, -2);
/* -1: LWF.Instances.<instanceId> */
if (!Lua.lua_istable(l, -1)) {
Lua.lua_pop(l, 1);
/* 0 */
goto error;
}
Lua.lua_getfield(l, -1, "Handlers");
/* -2: LWF.Instances.<instanceId> */
/* -1: LWF.Instances.<instanceId>.Handlers */
Lua.lua_remove(l, -2);
/* -1: LWF.Instances.<instanceId>.Handlers */
if (!Lua.lua_istable(l, -1)) {
Lua.lua_pop(l, 1);
/* 0 */
goto error;
}
Lua.lua_pushvalue(l, 3);
/* -2: LWF.Instances.<instanceId>.Handlers */
/* -1: function */
luaHandlerId = GetEventOffset();
Lua.lua_setfield(l, -2, luaHandlerId.ToString());
/* LWF.Instances.<instanceId>.Handlers.<luaHandlerId> = function */
/* -1: LWF.Instances.<instanceId>.Handlers */
Lua.lua_pop(l, 1);
/* 0 */
if (movie != null) {
if (string.IsNullOrEmpty(ev) || MovieEvents.ContainsKey(ev)) {
/* Movie event */
handlerId = movie.AddEventHandler(ev, (Movie m) => {
Lua.lua_State _l = (Lua.lua_State)m.lwf.luaState;
if (!m.lwf.PushHandlerLua(luaHandlerId))
return;
/* -1: function */
Luna_LWF_Movie.push(_l, m, false);
/* -2: function */
/* -1: Movie */
if (Lua.lua_pcall(_l, 1, 0, 0)!=0)
Lua.lua_pop(_l, 1);
});
} else {
handlerId = movie.AddEventHandler(ev, () => {
Lua.lua_State _l = (Lua.lua_State)movie.lwf.luaState;
if (!movie.lwf.PushHandlerLua(luaHandlerId))
return;
/* -1: function */
/* User defined event */
Lua.lua_createtable(_l, 0, 2);
/* -2: function */
/* -1: table */
Lua.lua_pushstring(_l, ev);
/* -3: function */
/* -2: table */
/* -1: string(type) */
Lua.lua_setfield(_l, -2, "type");
/* -2: function */
/* -1: table */
if (Lua.lua_istable(_l, 2)) {
Lua.lua_getfield(_l, 2, "param");
/* -3: function */
/* -2: table */
/* -1: param */
//.........这里部分代码省略.........