Example #1
0
        private void CallDebuger(string request)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var data = new Dictionary <string, object>();

            data["request"]     = request;
            data["stopOnEntry"] = false;
            data["program"]     = "remote debug";

            string path = dte.Solution.FileName;

            while (true)
            {
                int index = path.LastIndexOf('\\');
                if (index < 0)
                {
                    break;
                }
                path = path.Substring(0, index);
                if (Directory.Exists(path + @"\res\lua"))
                {
                    data["resDir"] = path + @"\res";
                    break;
                }
            }

            string tempFile = Path.GetTempFileName();

            File.WriteAllText(tempFile, CJsonHelper.Save(data));
            string parameters = string.Format(@"/LaunchJson:""{0}"" /EngineGuid:""94eb6cd0-3439-4af2-971c-0327a9daea68""", tempFile);

            dte.Commands.Raise("0ddba113-7ac1-4c6e-a2ef-dcac3f9e731e", 0x0101, parameters, IntPtr.Zero);
            File.Delete(tempFile);
        }
 private Dictionary <string, object> RecvUdp(ref IPEndPoint addr)
 {
     byte[] buf = udp.Receive(ref addr);
     if (buf.Length < 2)
     {
         return(null);
     }
     return(CJsonHelper.Load(Encoding.UTF8.GetString(buf)) as Dictionary <string, object>);
 }
Example #3
0
        static void FillGameDir(Dictionary <string, object> args)
        {
            string resDir = args.GetStr("resDir");

            if (resDir == null)
            {
                return;
            }

            string path = resDir + "/gameconfig.json";

            if (!File.Exists(path))
            {
                return;
            }

            var cfg = CJsonHelper.Load(File.ReadAllText(path)) as Dictionary <string, object>;

            string gameDir  = cfg.GetStr("dataDir", "game").Replace("/", @"\");
            string gameType = cfg.GetStr("gtype", "sample");

            if (gameDir.StartsWith(@".\"))
            {
                gameDir = gameDir.Substring(2);
            }
            if (gameDir == "game" && !Directory.Exists(resDir + @"\game\" + gameType))
            {
                gameDir = "game_res";
            }
            if (gameDir.Length < 2 || (gameDir[1] != ':' && gameDir[0] != '\\'))
            {
                gameDir = Path.Combine(resDir, gameDir);
            }
            if (Directory.Exists(Path.Combine(gameDir, gameType)))
            {
                args["gameDir"] = gameDir + @"\{gameName}";
            }
        }
Example #4
0
        static bool ProcessStdin()
        {
            byte[] buf = recvBuf.GetBuffer();
            recvBuf.Position += stdin.Read(buf, (int)recvBuf.Position, buf.Length - (int)recvBuf.Position);
            int index;

            for (int i = 0; ; i++)
            {
                if (i + 4 > recvBuf.Position)
                {
                    return(true);
                }
                if (buf[i] == '\r' && buf[i + 1] == '\n' & buf[i + 2] == '\r' & buf[i + 3] == '\n')
                {
                    index = i;
                    break;
                }
            }

            string line = Encoding.UTF8.GetString(buf, 0, index);

            string[] ary = line.Split(':');
            Trace.Assert(ary.Length == 2);
            Trace.Assert(ary[0] == "Content-Length");
            int len = int.Parse(ary[1]);

            index += 4;
            if (index + len > recvBuf.Position)
            {
                return(true);
            }

            var data = CJsonHelper.Load(Encoding.UTF8.GetString(buf, index, len)) as Dictionary <string, object>;

            index += len;
            for (int i = 0; i + index < recvBuf.Position; i++)
            {
                buf[i] = buf[i + index];
            }
            recvBuf.Position -= index;

            string cmd = data["command"] as string;

            if (cmd == "initialize")
            {
                var res = new Dictionary <string, object>();
                res["type"]        = "response";
                res["command"]     = data["command"];
                res["success"]     = true;
                res["request_seq"] = data["seq"];
                var body = new Dictionary <string, object>();
                res["body"] = body;
                res["seq"]  = 1;
                body["supportsConfigurationDoneRequest"] = true;
                body["supportsEvaluateForHovers"]        = true;
                body["supportsSetVariable"]             = true;
                body["supportsExceptionInfoRequest"]    = true;
                body["supportsExceptionOptions"]        = true;
                body["supportsExceptionDetailsRequest"] = true;
                var excs = new Dictionary <string, object> [3];
                body["exceptionBreakpointFilters"] = excs;
                excs[0]            = new Dictionary <string, object>();
                excs[0]["filter"]  = "perror";
                excs[0]["label"]   = "SCRIPT_EXCEPTION output";
                excs[0]["default"] = false;
                excs[1]            = new Dictionary <string, object>();
                excs[1]["filter"]  = "xpcall";
                excs[1]["label"]   = "exception in xpcall";
                excs[1]["default"] = true;
                excs[2]            = new Dictionary <string, object>();
                excs[2]["filter"]  = "endless";
                excs[2]["label"]   = "break when endless";
                excs[2]["default"] = false;
                buf = Encoding.UTF8.GetBytes(Msg2Txt(res));
                stdout.Write(buf, 0, buf.Length);
                stdout.Flush();
                return(true);
            }
            else if (cmd == "attach")
            {
                DoAttach(data);
                return(false);
            }
            else if (cmd == "launch")
            {
                DoLaunch(data);
                return(false);
            }
            return(true);
        }
Example #5
0
        static string Msg2Txt(Dictionary <string, object> res)
        {
            string json = CJsonHelper.Save(res);

            return("Content-Length: " + Encoding.UTF8.GetByteCount(json).ToString() + "\r\n\r\n" + json);
        }