Exemplo n.º 1
0
 public void Stop()
 {
     if (IsActive)
     {
         AmeisenCore.LuaDoString($"abFrame:UnregisterAllEvents();");
         AmeisenCore.LuaDoString("abFrame:SetScript(\"OnEvent\", nil)");
         IsActive = false;
         EventReader.Join();
     }
 }
Exemplo n.º 2
0
        public void Init()
        {
            //StringBuilder luaStuff = new StringBuilder();
            AmeisenCore.LuaDoString($"{LUA_FRAME} = CreateFrame('Frame','{LUA_FRAME}');{LUA_FRAME}:SetScript('OnEvent',{LUA_EVENTRECEIVED});{LUA_TABLE}={"{}"};");
            AmeisenCore.LuaDoString($"function {LUA_REGISTER}(e){LUA_FRAME}:RegisterEvent(e);end");
            AmeisenCore.LuaDoString($"function {LUA_UNREGISTER}(e){LUA_FRAME}:UnregisterEvent(e);end");
            AmeisenCore.LuaDoString($"function {LUA_INFO}(e,d)table.insert({LUA_TABLE}, {"{e,time(),d}"});end");
            AmeisenCore.LuaDoString($"function {LUA_EVENTRECEIVED}(s,e,...){LUA_INFO}(e,{"{...}"});end");
            AmeisenCore.LuaDoString($"function {LUA_EVENTCOUNT}()return {LUA_TABLE}.count;end");
            AmeisenCore.LuaDoString($"function {LUA_EVENTREMOVE}()table.wipe({LUA_TABLE});end");
            AmeisenCore.LuaDoString($"function {LUA_EVENTNAME}(i)local ret;ret={LUA_TABLE}[i];{LUA_TABLE}.remove(i);return ret;end");
            //AmeisenCore.LuaDoString(luaStuff.ToString());

            IsActive = true;
            EventReader.Start();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Start to receive events to our event table
        /// and start the event reader that will fire
        /// events if they apper in our event table.
        ///
        /// Events will get read every 1000 ms by now.
        /// </summary>
        public void Init()
        {
            StringBuilder luaStuff = new StringBuilder();

            luaStuff.Append("abFrame = CreateFrame(\"FRAME\", \"AbotEventFrame\") ");
            luaStuff.Append("abEventTable = {} ");
            luaStuff.Append("function abEventHandler(self, event, ...) ");
            luaStuff.Append("table.insert(abEventTable, {time(), event, {...}}) end ");
            luaStuff.Append("if abFrame:GetScript(\"OnEvent\") == nil then ");
            luaStuff.Append("abFrame:SetScript(\"OnEvent\", abEventHandler) end");
            AmeisenCore.LuaDoString(luaStuff.ToString());

            IsActive = true;

            EventReader.Start();
            // if we equip an item confirm the dialog
            AmeisenCore.EnableAutoBoPConfirm();
        }
Exemplo n.º 4
0
 public void Unsubscribe(string eventName)
 {
     AmeisenCore.LuaDoString($"{LUA_UNREGISTER}('{eventName}')");
 }
Exemplo n.º 5
0
 /// <summary>
 /// Unsubscribe from an event
 /// </summary>
 /// <param name="eventName">event name</param>
 public void Unsubscribe(string eventName)
 {
     AmeisenCore.LuaDoString($"abFrame:UnregisterEvent(\"{eventName}\");");
     EventDictionary.Remove(eventName);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Subscribe to an event
 /// </summary>
 /// <param name="eventName">event name</param>
 /// <param name="onEventFired">method to fire when the event appered in WoW</param>
 public void Subscribe(string eventName, OnEventFired onEventFired)
 {
     AmeisenCore.LuaDoString($"abFrame:RegisterEvent(\"{eventName}\");");
     EventDictionary.Add(eventName, onEventFired);
 }