Exemple #1
0
 internal void BuffIcon_UpdateIcon(On.RoR2.UI.BuffIcon.orig_UpdateIcon orig, RoR2.UI.BuffIcon self)
 {
     orig(self);
     if (self.buffDef && self.transform.parent.name == "BuffDisplayRoot")
     {
         if (mod.config.BuffTooltips.Value)
         {
             RoR2.UI.TooltipProvider tooltipProvider = self.GetComponent <RoR2.UI.TooltipProvider>();
             tooltipProvider.overrideTitleText = self.buffDef.name;
             tooltipProvider.titleColor        = self.buffDef.buffColor;
         }
         if (mod.config.BuffTimers.Value)
         {
             Transform timerText = self.transform.Find("TimerText");
             if (timerText != null)
             {
                 if (mod.HUD != null)
                 {
                     CharacterBody characterBody = mod.HUD.targetBodyObject ? mod.HUD.targetBodyObject.GetComponent <CharacterBody>() : null;
                     if (characterBody != null && characterBody.timedBuffs.Count > 0)
                     {
                         timedBuffs = characterBody.timedBuffs.Where(b => b.buffIndex == self.buffDef.buffIndex);
                         if (timedBuffs.Any())
                         {
                             thisBuff = timedBuffs.OrderByDescending(b => b.timer).First();
                             timerText.GetComponent <RoR2.UI.HGTextMeshProUGUI>().text = thisBuff.timer < 10 && mod.config.BuffTimersDecimal.Value ? thisBuff.timer.ToString("N1") : thisBuff.timer.ToString("N0");
                             return;
                         }
                     }
                 }
                 timerText.GetComponent <RoR2.UI.HGTextMeshProUGUI>().text = "";
             }
         }
     }
 }
Exemple #2
0
 private static void BuffIcon_UpdateIcon(On.RoR2.UI.BuffIcon.orig_UpdateIcon orig, RoR2.UI.BuffIcon self)
 {
     if (!self.buffDef)
     {
         self.iconImage.sprite = null;
         return;
     }
     if (self.buffDef == maxHPDown || self.buffDef == maxHPDownStage)
     {
         self.iconImage.sprite = self.buffDef.iconSprite;
         self.iconImage.color  = self.buffDef.buffColor;
         if (self.buffDef.canStack)
         {
             BuffIcon.sharedStringBuilder.Clear();
             BuffIcon.sharedStringBuilder.AppendInt(self.buffCount, 1U, uint.MaxValue);
             BuffIcon.sharedStringBuilder.Append("%");
             self.stackCount.enabled = true;
             self.stackCount.SetText(BuffIcon.sharedStringBuilder);
             return;
         }
         self.stackCount.enabled = false;
     }
     else
     {
         orig(self);
     }
 }
        private void BuffIcon_UpdateIcon(On.RoR2.UI.BuffIcon.orig_UpdateIcon orig, BuffIcon self)
        {
            orig(self);
            var tooltipProvider = self.GetComponent <TooltipProvider>();

            if (tooltipProvider != null)
            {
                BuffInfo buffInfo = BuffInfoProvider.GetBuffInfoFromIndex(self.buffIndex);
                string   title;
                string   body;
                Color    titleColor = Color.black;
                Color    bodyColor  = new Color(0.6f, 0.6f, 0.6f, 1f);

                if (buffInfo != null)
                {
                    title      = buffInfo.Name;
                    body       = buffInfo.Description;
                    titleColor = buffInfo.Color;
                }
                else
                {
                    title = BuffCatalog.GetBuffDef(self.buffIndex)?.name;
                    body  = "";
                }

                TooltipContent ttContent = new TooltipContent
                {
                    titleToken = title,
                    bodyToken  = body,
                    titleColor = titleColor,
                    bodyColor  = bodyColor
                };

                tooltipProvider.SetContent(ttContent);
            }
        }