public DotaConsoleParser()
        {
            consoleLogPath    = Path.Combine(SteamAppsLocation.Get(), "console.log");
            consoleFileStream = File.Open(consoleLogPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

            heroesSelected = new string[] { "null", "null", "null", "null", "null", "null", "null", "null", "null", "null" };
            heroes         = new Player[10];
            for (int i = 0; i < 10; i++)
            {
                heroes[i].Level      = 0;
                heroes[i].HeroName   = "";
                heroes[i].PlayerName = "";
                heroes[i].Kills      = 0;
                heroes[i].Deaths     = 0;
                heroes[i].Assists    = 0;
                heroes[i].LastHits   = 0;
                heroes[i].Denies     = 0;
                heroes[i].Gold       = 0;
                heroes[i].Health     = 0;
                heroes[i].MaxHealth  = 0;
                heroes[i].Mana       = 0;
                heroes[i].MaxMana    = 0;
            }

            heroCount = 0;

            stopHeroSelection = false;
            stopHeroData      = false;
        }
示例#2
0
        public Overlay()
        {
#if DEBUG
            if (SteamAppsLocation.Get() == "./../../debug")
            {
                dotaProcessHandle = Process.GetProcessesByName("notepad")[0].MainWindowHandle;
                overlayManager    = new OverlayManager(dotaProcessHandle, out window, out renderer);
                renderer.SetupHintSlots();
                return;
            }
#endif
            while (Process.GetProcessesByName("dota2").Length == 0)
            {
                Console.WriteLine("Waiting for dota to start...");
                Thread.Sleep(500);
            }

            while (Process.GetProcessesByName("dota2")[0].MainWindowHandle == IntPtr.Zero)
            {
                Console.WriteLine("Waiting for dota window handle to appear...");
                Thread.Sleep(500);
            }

            dotaProcessHandle = Process.GetProcessesByName("dota2")[0].MainWindowHandle;
            overlayManager    = new OverlayManager(dotaProcessHandle, out window, out renderer);
            renderer.SetupHintSlots();
            Console.WriteLine("Overlay running!");
        }
示例#3
0
        private void StartDota()
        {
#if DEBUG
            if (SteamAppsLocation.Get() == "./../../debug")
            {
                return;
            }
#endif
            Console.WriteLine("Starting dota...");
            Process p = new Process();

            RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam");
            if (regKey != null)
            {
                p.StartInfo.FileName = regKey.GetValue("SteamPath") + "/Steam.exe";
            }
            else
            {
                throw new Exception("Could not start DotA 2. Is Steam installed?");
            }
            p.StartInfo.Arguments = "-applaunch 570 -console -condebug +exec autoexec";
            try
            {
                p.Start();
                Console.WriteLine("Dota running!");
            }
            catch (Win32Exception ex)
            {
                Console.WriteLine("Starting dota failed! " + ex.Message);
            }
        }
示例#4
0
        private void WaitForDotaToOpen()
        {
#if DEBUG
            if (SteamAppsLocation.Get() == "./../../debug")
            {
                return;
            }
#endif
            string consoleLog = Path.Combine(SteamAppsLocation.Get(), "console.log");
            using (FileStream fileStream = File.Open(consoleLog, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                fileStream.Seek(0, SeekOrigin.End);
                using (StreamReader streamReader = new StreamReader(fileStream))
                {
                    while (true)
                    {
                        Thread.Sleep(500);
                        if (streamReader.ReadToEnd().Contains("ChangeGameUIState: DOTA_GAME_UI_STATE_LOADING_SCREEN -> DOTA_GAME_UI_STATE_DASHBOARD"))
                        {
                            break;
                        }
                    }
                }
            }
        }
        private static void CreateGameStateIntegrationFile()
        {
            string gsifolder = Path.Combine(SteamAppsLocation.Get(), "cfg/gamestate_integration");

            Directory.CreateDirectory(gsifolder);
            string gsifile = Path.Combine(gsifolder, "gamestate_integration_testGSI.cfg");

            if (File.Exists(gsifile))
            {
                return;
            }

            string[] contentofgsifile =
            {
                "\"Dota 2 Integration Configuration\"",
                "{",
                "    \"uri\"           \"http://localhost:3000\"",
                "    \"timeout\"       \"5.0\"",
                "    \"buffer\"        \"0.1\"",
                "    \"throttle\"      \"0.1\"",
                "    \"heartbeat\"     \"30.0\"",
                "    \"data\"",
                "    {",
                "        \"provider\"      \"1\"",
                "        \"map\"           \"1\"",
                "        \"player\"        \"1\"",
                "        \"hero\"          \"1\"",
                "        \"abilities\"     \"1\"",
                "        \"items\"         \"1\"",
                "    }",
                "}",
            };

            File.WriteAllLines(gsifile, contentofgsifile);
        }
        public GameStateIntegration()
        {
#if DEBUG
            if (SteamAppsLocation.Get() == "./../../debug")
            {
                return;
            }
#endif
            CreateGameStateIntegrationFile();

            while (true)
            {
                Process[] processName = Process.GetProcessesByName("Dota2");
                if (processName.Length != 0)
                {
                    break;
                }
                Thread.Sleep(1000);
            }

            if (gameStateListener == null)
            {
                gameStateListener = new GameStateListener(3000);
                gameStateListener.NewGameState += OnNewGameState;
            }
        }
示例#7
0
        protected bool IsDotaRunning()
        {
#if DEBUG
            if (SteamAppsLocation.Get() == "./../../debug")
            {
                return(true);
            }
#endif
            return(Process.GetProcessesByName("dota2").Length != 0);
        }
示例#8
0
        private void CreateAutoExecFile()
        {
            string lineToWrite = "bind \"HOME\" \"dota_player_status\"";

            string autoExecPath = Path.Combine(SteamAppsLocation.Get(), "cfg/autoexec.cfg");

            if (File.Exists(autoExecPath))
            {
                if (File.ReadAllText(autoExecPath).Contains(lineToWrite))
                {
                    return;
                }
            }

            File.AppendAllText(autoExecPath, "\r\n" + lineToWrite + "\r\n");
        }
示例#9
0
        private static void ParseInfoReplayFiles()
        {
            string replayDirectory = Path.Combine(SteamAppsLocation.Get(), "replays");

            string[] fileEntries = Directory.GetFiles(replayDirectory);

            foreach (string file in fileEntries)
            {
                if (Path.GetExtension(file) != ".dem")
                {
                    continue;
                }

                ParseReplay(Path.Combine(replayDirectory, file), "info");
            }
        }
示例#10
0
        public bool isReplayStarted()
        {
#if DEBUG
            if (SteamAppsLocation.Get() == "./../../debug")
            {
                return(false);
            }
#endif
            if (!listenerStarted)
            {
                gameStateIntegration.StartListener();
                listenerStarted = true;
            }
            return(
                gameStateIntegration.GameState != "Undefined" &&
                gameStateIntegration.GameState != null &&
                gameStateIntegration.GameState != "");
        }
示例#11
0
        private static void ParseFullReplayFile(string fileName)
        {
            string replayDirectory = Path.Combine(SteamAppsLocation.Get(), "replays");

            ParseReplay(Path.Combine(replayDirectory, fileName), "full");
        }