Exemple #1
0
        private void ListBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ReplayNameListBox.SelectedItem != null)
            {
                ConfirmButton.IsEnabled = true;
                string[] words = (ReplayNameListBox.SelectedItem as ReplayListItem).Title.Split(' ');
                GUISelection.fileName = words[words.Length - 1];

                List <string> heroNameList = ParserHandler.GetHeroNameList(Path.Combine("Parser", GUISelection.fileName + "/"));

                List <HeroListItem> heros = new List <HeroListItem>();
                foreach (string heroName in heroNameList)
                {
                    heros.Add(new HeroListItem()
                    {
                        ImagePath = Path.Combine(Environment.CurrentDirectory, "hero_icon_images/" + replayParse.heroID.ID_heroDictionary[heroName].ToString() + ".png"),
                        Title     = heroName
                    });
                }

                MainWindow.HeroList.ItemsSource = heros;
            }
            else
            {
                ConfirmButton.IsEnabled = false;
            }
        }
        public MainWindow()
        {
            if (Process.GetProcessesByName("GamingSupervisor").Length != 1)
            {
                MessageBox.Show(this, "Gaming Supervisor is already running. Close the other instance and try again.", "Error",
                                MessageBoxButton.OK,
                                MessageBoxImage.Information,
                                MessageBoxResult.OK,
                                MessageBoxOptions.DefaultDesktopOnly);

                Application.Current.Shutdown();
            }

            InitializeComponent();

            HideInstructions();
            DescriptionToggle.IsChecked = false;

            Description         = GUIDescription;
            HeroList            = HeroNameItemsControl;
            HeroList.Visibility = Visibility.Collapsed;

            ParserHandler.StartInfoParsing();

            DifficultySelection difficultySelection = new DifficultySelection();

            GUINavigation.Navigate(difficultySelection);
        }
        public ReplayHeroSelection()
        {
            InitializeComponent();

            MainWindow.Description.Text = "Select which hero to analyze.";

            List <string> heroNameList = ParserHandler.GetHeroNameList(GUISelection.replayDataFolderLocation);

            replayParse.heroID  heroId = new replayParse.heroID();
            List <HeroListItem> heros  = new List <HeroListItem>();

            foreach (string heroName in heroNameList)
            {
                heros.Add(new HeroListItem()
                {
                    ImagePath = Path.Combine(Environment.CurrentDirectory, "hero_icon_images/" + replayParse.heroID.ID_heroDictionary[heroName].ToString() + ".png"),
                    Title     = heroName
                });
            }

            HeroNameListBox.ItemsSource = heros;

            ConfirmButton.IsEnabled = false;

            MainWindow.HeroList.Visibility    = Visibility.Collapsed;
            MainWindow.Description.Visibility = Visibility.Visible;
        }
Exemple #4
0
        public void Start()
        {
            CreateAutoExecFile();

            switch (GUISelection.gameType)
            {
            case GUISelection.GameType.live:
                break;

            case GUISelection.GameType.replay:
                ParserHandler.StartFullParsing(GUISelection.fileName + ".dem");
                break;
            }

            bool isDotaAlreadyRunning = Process.GetProcessesByName("dota2").Length != 0;

            if (!isDotaAlreadyRunning)
            {
                StartDota();
            }

            switch (GUISelection.gameType)
            {
            case GUISelection.GameType.live:
                liveAnalyzer = new LiveAnalyzer();
                break;

            case GUISelection.GameType.replay:
                ParserHandler.WaitForFullParsing();
                replayAnalyzer = new ReplayAnalyzer();
                break;
            }

            if (!isDotaAlreadyRunning)
            {
                WaitForDotaToOpen();
            }

            switch (GUISelection.gameType)
            {
            case GUISelection.GameType.live:
                liveAnalyzer.Start();
                break;

            case GUISelection.GameType.replay:
                replayAnalyzer.Start();
                break;
            }
        }
Exemple #5
0
        private async Task WaitForParsingAsync()
        {
            ParserHandler.WaitForInfoParsing();

            if (replays != null)
            {
                return;
            }

            using (ApiHandler api = new ApiHandler("8BFC2C10E3D1E95B85DCF6AAD861782D"))
            {
                var leagues = await api.GetLeagueListings();

                replays = new List <ReplayListItem>();
                foreach (string replay in
                         Directory.EnumerateDirectories(Path.Combine(Environment.CurrentDirectory, "Parser")))
                {
                    if (!File.Exists(Path.Combine(replay, "info.txt")))
                    {
                        continue;
                    }

                    string info    = File.ReadAllText(Path.Combine(replay, "info.txt"));
                    var    matches = Regex.Matches(info, @"match_id: (?<MatchID>\d+)");
                    if (matches.Count == 0)
                    {
                        continue;
                    }
                    string replayID = matches[0].Groups["MatchID"].Value;
                    Console.WriteLine(replayID);
                    var matchResult = await api.GetDetailedMatch(replayID);

                    string winner = "";
                    switch (matchResult.WinningFaction)
                    {
                    case Dota2Api.Enums.Faction.Dire:
                        winner = "Dire";
                        break;

                    case Dota2Api.Enums.Faction.Radiant:
                        winner = "Radiant";
                        break;
                    }

                    TimeSpan time       = TimeSpan.FromSeconds(matchResult.Duration);
                    string   timeString = time.ToString(@"hh\:mm\:ss");

                    string leagueName = "";

                    /*if (leagues.Leagues.Count != 0)
                     * {
                     *  leagueName = (from league in leagues.Leagues
                     *                where league.LeagueId == matchResult.LeagueId
                     *                select league.Name).Single();
                     * }*/

                    leagueName = leagueName.Replace("#DOTA_Item", "");
                    leagueName = leagueName.Replace("_", " ");
                    leagueName = leagueName == "" ? "" : $"League: {leagueName}\n";

                    string entry = $"{leagueName}Duration: {timeString} Winner: {winner}\nGameID: {matchResult.MatchId}";

                    replays.Add(new ReplayListItem()
                    {
                        Title = entry
                    });
                }
            }
        }