Beispiel #1
0
        public MatchPlayerBase(IInternalService internalService, IWebsiteService website, ReplayMatchPlayer player)
        {
            Database    = internalService.Database;
            HeroesIcons = internalService.HeroesIcons;
            UserProfile = internalService.UserProfile;
            Website     = website;
            Player      = player;

            SilenceIcon = HeroesIcons.GetOtherIcon(OtherIcon.Silence);
            TalentBorderScoreScreenIcon = HeroesIcons.GetOtherIcon(OtherIcon.TalentAvailable);
        }
        public void GetOtherIconTests()
        {
            List <string> assertMessages = new List <string>();

            foreach (OtherIcon icon in Enum.GetValues(typeof(OtherIcon)))
            {
                if (HeroesIcons.GetOtherIcon(icon) == null)
                {
                    assertMessages.Add($"Other icon {icon} is null");
                }
            }

            AssertFailMessage(assertMessages);
        }
        public MatchSummaryViewModel(IInternalService internalService, IWebsiteService website, ILoadingOverlayWindowService loadingOverlayWindow)
            : base(internalService)
        {
            Website = website;
            LoadingOverlayWindow = loadingOverlayWindow;

            IsFlyoutLoadingOverlayVisible = false;
            IsLeftChangeButtonVisible     = true;
            IsRightChangeButtonVisible    = true;
            IsLeftChangeButtonEnabled     = false;
            IsRightChangeButtonEnabled    = false;

            ScoreKillIcon   = HeroesIcons.GetOtherIcon(OtherIcon.Kills);
            ScoreAssistIcon = HeroesIcons.GetOtherIcon(OtherIcon.Assist);
            ScoreDeathIcon  = HeroesIcons.GetOtherIcon(OtherIcon.Death);
            BlueKillsIcons  = HeroesIcons.GetOtherIcon(OtherIcon.KillsBlue);
            RedKillsIcons   = HeroesIcons.GetOtherIcon(OtherIcon.KillsRed);

            LeftArrowDisabledIcon  = HeroesIcons.GetOtherIcon(OtherIcon.LongarrowLeftDisabled);
            LeftArrowDownIcon      = HeroesIcons.GetOtherIcon(OtherIcon.LongarrowLeftDown);
            LeftArrowHoverIcon     = HeroesIcons.GetOtherIcon(OtherIcon.LongarrowLeftHover);
            LeftArrowNormalIcon    = HeroesIcons.GetOtherIcon(OtherIcon.LongarrowLeftNormal);
            RightArrowDisabledIcon = HeroesIcons.GetOtherIcon(OtherIcon.LongarrowRightDisabled);
            RightArrowDownIcon     = HeroesIcons.GetOtherIcon(OtherIcon.LongarrowRightDown);
            RightArrowHoverIcon    = HeroesIcons.GetOtherIcon(OtherIcon.LongarrowRightHover);
            RightArrowNormalIcon   = HeroesIcons.GetOtherIcon(OtherIcon.LongarrowRightNormal);

            HasBans      = false;
            HasObservers = false;
            HasChat      = false;

            TeamLevelTimeGraph  = new TeamLevelTimeGraph();
            TeamExperienceGraph = new TeamExperienceGraph(Database);
            StatGraphs          = new StatGraphs(Database);

            Messenger.Default.Register <NotificationMessage>(this, (message) => ReceivedMessage(message));

            SimpleIoc.Default.Register <IMatchSummaryReplayService>(() => this);
        }
        // if this algorithm is changed then TalentTooltipStripNonText method in HeroIconsTest.cs needs to be changed as well
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string text = value as string;

            if (string.IsNullOrEmpty(text))
            {
                return(text);
            }

            var span = new Span();

            while (text.Length > 0)
            {
                int startIndex = text.IndexOf("<");

                if (startIndex > -1)
                {
                    int endIndex = text.IndexOf(">", startIndex) + 1;

                    // example <c val="#TooltipNumbers">
                    string startTag = text.Substring(startIndex, endIndex - startIndex);

                    if (startTag == "<n/>" || startTag == "</n>")
                    {
                        span.Inlines.Add(new Run(text.Substring(0, startIndex)));
                        span.Inlines.Add(new Run("\n"));

                        // remove, this part of the string is not needed anymore
                        text = text.Remove(0, endIndex);

                        continue;
                    }
                    else if (startTag.ToLower().StartsWith("<c val="))
                    {
                        string colorValue = startTag.Substring(8, startTag.Length - 10);

                        int offset           = 4;
                        int closingCTagIndex = text.ToLower().IndexOf("</c>", endIndex);

                        // check if an ending tag exists
                        if (closingCTagIndex > 0)
                        {
                            span.Inlines.Add(new Run(text.Substring(0, startIndex)));
                            span.Inlines.Add(new Run(text.Substring(endIndex, closingCTagIndex - endIndex))
                            {
                                Foreground = SetTooltipColors(colorValue), FontSize = 15, FontWeight = FontWeights.SemiBold
                            });

                            // remove, this part of the string is not needed anymore
                            text = text.Remove(0, closingCTagIndex + offset);
                        }
                        else
                        {
                            span.Inlines.Add(new Run(text.Substring(0, startIndex)));

                            // add the rest of the text
                            span.Inlines.Add(new Run(text.Substring(endIndex, text.Length - endIndex))
                            {
                                Foreground = SetTooltipColors(colorValue), FontSize = 15, FontWeight = FontWeights.SemiBold
                            });

                            // none left
                            text = string.Empty;
                        }
                    }
                    else if (startTag.ToLower().StartsWith("<s val="))
                    {
                        string colorValue = startTag.Substring(8, startTag.Length - 10);

                        int offset           = 4;
                        int closingCTagIndex = text.ToLower().IndexOf("</s>", endIndex);

                        // check if an ending tag exists
                        if (closingCTagIndex > 0)
                        {
                            span.Inlines.Add(new Run(text.Substring(0, startIndex)));
                            span.Inlines.Add(new Run(text.Substring(endIndex, closingCTagIndex - endIndex))
                            {
                                Foreground = SetTooltipColors(colorValue), FontSize = 15, FontWeight = FontWeights.SemiBold
                            });

                            // remove, this part of the string is not needed anymore
                            text = text.Remove(0, closingCTagIndex + offset);
                        }
                        else
                        {
                            span.Inlines.Add(new Run(text.Substring(0, startIndex)));

                            // add the rest of the text
                            span.Inlines.Add(new Run(text.Substring(endIndex, text.Length - endIndex))
                            {
                                Foreground = SetTooltipColors(colorValue), FontSize = 15, FontWeight = FontWeights.SemiBold
                            });

                            // none left
                            text = string.Empty;
                        }
                    }
                    else if (startTag.StartsWith("<img path=\"@UI/StormTalentInTextQuestIcon\"") || startTag.StartsWith("<img  path=\"@UI/StormTalentInTextQuestIcon\""))
                    {
                        int closingTag = text.IndexOf("/>");

                        span.Inlines.Add(new Run(text.Substring(0, startIndex)));

                        Image image = new Image()
                        {
                            Source            = CreateImage(HeroesIcons.GetOtherIcon(OtherIcon.Quest)),
                            Height            = 22,
                            Width             = 20,
                            Margin            = new Thickness(0, 0, 4, -2),
                            VerticalAlignment = VerticalAlignment.Center,
                        };

                        InlineUIContainer container = new InlineUIContainer(image);

                        span.Inlines.Add(container);

                        // remove, this part of the string is not needed anymore
                        text = text.Remove(0, closingTag + 2);
                    }
                    else if (startTag.StartsWith("<img path=\"@UI/StormTalentInTextArmorIcon\" alignment=\"uppermiddle\""))
                    {
                        int closingTag = text.IndexOf("/>");

                        span.Inlines.Add(new Run(text.Substring(0, startIndex)));

                        BitmapImage bitmapImage = null;

                        if (startTag.Contains("color=\"e12bfc\""))
                        {
                            bitmapImage = CreateImage(HeroesIcons.GetOtherIcon(OtherIcon.StatusResistShieldSpell));
                        }
                        else if (startTag.Contains("color=\"ff6600\""))
                        {
                            bitmapImage = CreateImage(HeroesIcons.GetOtherIcon(OtherIcon.StatusResistShieldPhysical));
                        }
                        else // if (startTag.Contains("color=\"BBBBBB\""))
                        {
                            bitmapImage = CreateImage(HeroesIcons.GetOtherIcon(OtherIcon.StatusResistShieldDefault));
                        }

                        bitmapImage.Freeze();

                        Image image = new Image()
                        {
                            Source            = bitmapImage,
                            Height            = 20,
                            Width             = 18,
                            Margin            = new Thickness(0, 0, 4, -2),
                            VerticalAlignment = VerticalAlignment.Center,
                        };

                        InlineUIContainer container = new InlineUIContainer(image);

                        span.Inlines.Add(container);

                        // remove, this part of the string is not needed anymore
                        text = text.Remove(0, closingTag + 2);
                    }
                    else
                    {
                        span.Inlines.Add(new Run(text));
                        text = string.Empty;

                        WarningLog.Log(LogLevel.Warn, $"[{nameof(TalentTooltipTextConverter)}] Unknown tag: {startTag} - FullText: {value.ToString()}");
                    }
                }
                else
                {
                    // add the rest
                    if (text.Length > 0)
                    {
                        span.Inlines.Add(new Run(text));
                    }

                    text = string.Empty;
                }
            }

            return(span);
        }