Пример #1
0
 private static byte[] DefaultLoader(string path)
 {
     path = path.Replace("/", ".");
     char[] separator = new char[] { '.' };
     if (path.Split(separator).Length > 1)
     {
         char[] chArray2 = new char[] { '.' };
         char[] chArray3 = new char[] { '.' };
         path = path.Split(chArray2)[path.Split(chArray3).Length - 1];
     }
     return(LuaHelper.GetResManager().luaFiles[path].bytes);
 }
Пример #2
0
 public static void Close()
 {
     com.tencent.pandora.Logger.d("call close");
     try
     {
         isPannelOpen = false;
         LuaHelper.GetPanelManager().CloseAllPanel();
     }
     catch (Exception exception)
     {
         com.tencent.pandora.Logger.d("CloseError:" + exception.Message);
     }
 }
Пример #3
0
        public LuaFunction LoadFile(string fileName)
        {
            int oldTop = LuaDLL.lua_gettop(this.L);

            byte[] buff = null;
            buff = LuaHelper.GetResManager().luaFiles[fileName].bytes;
            if (LuaDLL.luaL_loadbuffer(this.L, buff, buff.Length, fileName) != 0)
            {
                this.ThrowExceptionFromError(oldTop);
            }
            LuaFunction function = this.translator.getFunction(this.L, -1);

            this.translator.popValues(this.L, oldTop);
            return(function);
        }
Пример #4
0
 public void RefreshLuaLoadStatus()
 {
     try
     {
         if (this.isNeedLoadLua && this.blIsInitFinish)
         {
             for (int i = 0; i < this.aryRes.Count; i++)
             {
                 CRes res = this.aryRes[i] as CRes;
                 if (((res.iLuaState != this.iLuaInited) && this.CheckIsDown(res.iLoadState)) && ((res.iLuaState != this.iLuaIniting) && this.CheckIsDown(res.iLoadState)))
                 {
                     bool flag  = false;
                     bool flag2 = true;
                     for (int k = 0; k < res.aryFileState.Count; k++)
                     {
                         CFileState state       = res.aryFileState[k] as CFileState;
                         string     strFileName = state.strFileName;
                         if (state.isLua)
                         {
                             flag = true;
                             if (this.isLuaFile(strFileName) && (!this.CheckIsDown(state.iDownState) || (state.iLuaState == -1)))
                             {
                                 flag2 = false;
                             }
                         }
                     }
                     if (!flag)
                     {
                         Logger.d("res:" + res.strResName + " no lua");
                         res.iLuaState = this.iLuaInited;
                     }
                     if (flag2)
                     {
                         res.iLuaState = this.iLuaWaitInit;
                     }
                     if (res.iLuaState == this.iLuaWaitInit)
                     {
                         res.iLuaState = this.iLuaIniting;
                         for (int m = 0; m < res.aryFileState.Count; m++)
                         {
                             CFileState state2 = res.aryFileState[m] as CFileState;
                             string     key    = state2.strFileName;
                             if (state2.isLua && !this.dicInitLua.ContainsKey(key))
                             {
                                 this.dicInitLua.Add(key, true);
                                 Logger.d("开始加载-》" + key);
                                 string luaName = this.GetLuaName(key);
                                 LuaHelper.GetResManager().LuaInitToVm(luaName);
                             }
                         }
                         res.iLuaState = this.iLuaInited;
                     }
                 }
             }
             bool flag3 = true;
             for (int j = 0; j < this.aryRes.Count; j++)
             {
                 CRes res2 = this.aryRes[j] as CRes;
                 if (res2.iLuaState != this.iLuaInited)
                 {
                     flag3 = false;
                     break;
                 }
             }
             if (flag3)
             {
                 Logger.d("init lua finish");
                 this.isNeedLoadLua = false;
             }
         }
     }
     catch (Exception exception)
     {
         Logger.LogNetError(Configer.iCodeCSException, exception.Message + exception.StackTrace.ToString());
     }
 }