예제 #1
0
        //returns false if game was busy
        public bool RestoreLoadedFiles()
        {
            bool wasRunning = this.DebugEngine.CurrentState == DebugState.Running;

            if (wasRunning)
            {
                if (!GameLoopHook.PauseGame())
                {
                    return(false);
                }
            }

            BBLua.lua_getglobal(this.L, "_LuaDebugger_FileData");
            if (BBLua.lua_type(this.L, -1) != LuaType.Table)
            {
                if (wasRunning)
                {
                    GameLoopHook.ResumeGame();
                }
                return(true);
            }

            StringBuilder sb = new StringBuilder();

            for (int i = 1; ; i++)
            {
                BBLua.lua_rawgeti(this.L, -1, i);
                if (BBLua.lua_type(this.L, -1) != LuaType.String)
                {
                    BBLua.lua_settop(this.L, -2);
                    break;
                }
                sb.Append(BBLua.lua_tostring(this.L, -1));
                BBLua.lua_settop(this.L, -2);
            }

            if (wasRunning)
            {
                GameLoopHook.ResumeGame();
            }

            this.LoadedFiles.Clear();

            RestoreFromFileString(sb.ToString());

            return(true);
        }