Пример #1
0
        private void GenerateTooltip(ChampionSpellStatic champSpell, UltraToolTipInfo thisToolTipInfo)
        {
            try
            {
                //Prepare Desc//
                string sDescPrep = champSpell.Tooltip;


                //Replace Var.Ceoff markers in tooltip
                if (champSpell.Vars != null)
                {
                    foreach (SpellVarsStatic spellVars in champSpell.Vars)
                    {
                        string sTarget      = "{{ " + spellVars.Key + " }}";
                        string sReplacement = "";
                        string ofAdAp       = "";
                        string dynText      = spellVars.Dyn != null ? spellVars.Dyn : "";
                        if (spellVars.Coeff != null)
                        {
                            var  varsCoeff = (Newtonsoft.Json.Linq.JArray)spellVars.Coeff;
                            int  index     = 0;
                            int  icount    = varsCoeff.Count;
                            bool isPercent = false;
                            foreach (string sVar in varsCoeff)
                            {
                                string sVarNew = sVar;
                                try
                                {
                                    double dVar = Convert.ToDouble(sVarNew);
                                    if (dVar < 3)
                                    {
                                        sVarNew   = (dVar * 100).ToString();
                                        isPercent = true;
                                    }
                                }
                                catch
                                {
                                    //do nothing
                                }

                                sReplacement += sVarNew;
                                if ((index + 1) != icount)
                                {
                                    sReplacement += "/";
                                }
                                index++;
                            }
                            if (isPercent)
                            {
                                sReplacement += "%";
                            }
                        }

                        if (spellVars.Link.Contains("bonusarmor"))
                        {
                            ofAdAp = " of bonus armor";
                        }
                        else if (spellVars.Link.Contains("bonusattackdamage"))
                        {
                            ofAdAp = " of bonus attack damage";
                        }
                        else if (spellVars.Link.Contains("bonushealth"))
                        {
                            ofAdAp = " of bonus health";
                        }
                        else if (spellVars.Link.Contains("maxhealth"))                         //This one was made up by for ChampionDataCorrections
                        {
                            ofAdAp = " of max health";
                        }
                        else if (spellVars.Link.Contains("bonusspellblock"))
                        {
                            ofAdAp = " of bonus magic resist";
                        }

                        else if (spellVars.Link.Contains("armor"))
                        {
                            ofAdAp = " of total armor";
                        }
                        else if (spellVars.Link.Contains("attackdamage"))
                        {
                            ofAdAp = " of attack damage";
                        }
                        else if (spellVars.Link.Contains("health"))
                        {
                            ofAdAp = " of health";
                        }
                        else if (spellVars.Link.Contains("spelldamage"))
                        {
                            ofAdAp = " of ability power";
                        }
                        else if (spellVars.Link.Contains("mana"))
                        {
                            ofAdAp = " of mana";
                        }

                        else if (spellVars.Link.Contains("@text"))
                        {
                        }
                        else if (spellVars.Link.Contains("@cooldownchampion"))
                        {
                        }
                        else if (spellVars.Link.Contains("@dynamic.abilitypower"))
                        {
                            ofAdAp = " of ability power";
                        }
                        else if (spellVars.Link.Contains("@dynamic.attackdamage") && champSpell.Name == "Savagery")                         //Rengar
                        {
                            sReplacement = "";
                        }
                        else if (spellVars.Link.Contains("@dynamic.attackdamage"))
                        {
                            ofAdAp = " per attack damage";
                        }
                        else if (spellVars.Link.Contains("@stacks"))
                        {
                            ofAdAp = " of stacks";
                        }
                        else if (spellVars.Link.Contains("@special.BraumWArmor"))
                        {
                            //TODO
                        }
                        else if (spellVars.Link.Contains("@special.BraumWMR"))
                        {
                            //TODO
                        }
                        else if (spellVars.Link.Contains("@special.dariusr3"))
                        {
                            //TODO
                        }
                        else if (spellVars.Link.Contains("@special.jaycew"))
                        {
                            //TODO
                        }
                        else if (spellVars.Link.Contains("@special.jaxrarmor"))
                        {
                            sReplacement = "bonus";
                        }
                        else if (spellVars.Link.Contains("@special.jaxrmr"))
                        {
                            sReplacement = "bonus";
                        }
                        else if (spellVars.Link.Contains("@special.nautilusq"))
                        {
                            //TODO
                        }
                        else if (spellVars.Link.Contains("@special.viw"))
                        {
                            dynText = "1% per ";
                            ofAdAp  = " bonus AD";
                        }
                        else if (spellVars.Link.Contains("@custom.MagicDamage"))                         //This one was made up by for ChampionDataCorrections
                        {
                            ofAdAp = "";
                        }
                        else if (spellVars.Link.Contains("@custom.percentOfAttack"))                         //This one was made up by for ChampionDataCorrections
                        {
                            ofAdAp = "% of attack damage";
                        }
                        else if (spellVars.Link.Contains("@custom.percentOfMana"))                         //This one was made up by for ChampionDataCorrections
                        {
                            ofAdAp = "% of mana";
                        }
                        else if (spellVars.Link.Contains("@custom.percentOfAP"))                         //This one was made up by for ChampionDataCorrections
                        {
                            ofAdAp = "% of AP";
                        }
                        else if (spellVars.Link.Contains("@custom.percent"))                         //This one was made up by for ChampionDataCorrections
                        {
                            ofAdAp = "%";
                        }



                        sDescPrep = sDescPrep.Replace(sTarget, dynText + sReplacement + ofAdAp);
                    }
                }

                //Replace effect markers in tooltip
                if (champSpell.EffectBurns != null)
                {
                    int i = 0;
                    foreach (string sReplacement in champSpell.EffectBurns)
                    {
                        if (sReplacement != "")
                        {
                            string newReplace = sReplacement;
                            string sTarget    = "{{ e" + i + " }}";
                            sDescPrep = sDescPrep.Replace(sTarget, newReplace);
                        }
                        i++;
                    }
                }


                //Replace cost marker in tooltip
                if (sDescPrep.Contains("{{ cost }}"))
                {
                    string sTarget = "{{ cost }}";
                    sDescPrep = sDescPrep.Replace(sTarget, champSpell.CostBurn);
                }


                //replace tags in Resource
                string resourceCost = champSpell.Resource != null?champSpell.Resource.Replace("{{ cost }}", champSpell.CostBurn) : "Passive";

                if (champSpell.EffectBurns != null)
                {
                    int i = 0;
                    foreach (string sReplacement in champSpell.EffectBurns)
                    {
                        if (sReplacement != "")
                        {
                            string newReplace = sReplacement;
                            string sTarget    = "{{ e" + i + " }}";
                            resourceCost = resourceCost.Replace(sTarget, newReplace);
                        }
                        i++;
                    }
                }



                //Fix color tags
                sDescPrep = sDescPrep.Replace("class=\"color", "style=\"color:#");


                //Artificial Word-wrap
                sDescPrep = StringExtensions.BrWrapper(sDescPrep);



                //Prep Image for tooltip
                string version = getChampionsFromServer.version;
                string file    = string.Format(@"{0}\Data\Champions\Images\{1}\{2}", PublicStaticVariables.thisAppDataDir, version, champSpell.Image.Sprite);
                string dir     = string.Format(@"{0}\Data\Champions\Images", PublicStaticVariables.thisAppDataDir);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                Image imageTemp = Image.FromFile(file);
                imageTemp = CommonMethods.cropImage(imageTemp, new Rectangle(champSpell.Image.X, champSpell.Image.Y, champSpell.Image.Width, champSpell.Image.Height));
                string image = FormattedLinkEditor.EncodeImage(imageTemp);


                //Compile Description
                string tipDesc = string.Format(@"
				<div style='color:White; font-family:Tahoma; font-size:10pt; text-smoothing-mode:AntiAlias; border-style:solid; border-width:2px; width:400px'>
				  <img style='padding: 4 4 0 4;' data='{5}' width='48' height='48'/>
				  <div>
					<br/>
					<b>{0}</b><br/>
					<span style='font-size:8pt'>
					  {1}<br/>
					  {2}<br/>
					  {3}
					</span>
				  </div>
				<hr style='border-style:solid; margin: 0 0 0 0;'/>
				{4}
				</div>"                , champSpell.Name,
                                               "Cooldown: " + (champSpell.Resource != null ? champSpell.CooldownBurn : "Passive"),
                                               "Cost: " + resourceCost,
                                               "Range: " + champSpell.RangeBurn,
                                               sDescPrep,
                                               image);

                tipDesc = tipDesc.Replace("<br>", "<br/>");
                tipDesc = tipDesc.Replace("\"", "'");
                //tipDesc = tipDesc.Replace("\r", "");
                //tipDesc = tipDesc.Replace("\n", "");
                //tipDesc = tipDesc.Replace("\t", "");



                //TODO: add \r for troubleshooting
                tipDesc = tipDesc.Replace("<br/>", "<br/>\r\n");


                //These tags needed to be closed for UltraToolTipInfo to accept it as well-formed html because by default HtmlAgilityPack removes the /> at the end
                HtmlNode.ElementsFlags["img"] = HtmlElementFlag.Closed;
                HtmlNode.ElementsFlags["hr"]  = HtmlElementFlag.Closed;
                HtmlNode.ElementsFlags["br"]  = HtmlElementFlag.Closed;
                //Fixes Riots malformed html
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(tipDesc);
                MemoryStream memoryStream = new MemoryStream();
                doc.Save(memoryStream);
                memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
                StreamReader streamReader = new StreamReader(memoryStream);
                tipDesc = streamReader.ReadToEnd();


                thisToolTipInfo.ToolTipTextFormatted = tipDesc;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #2
0
        private void GenerateTooltip(PassiveStatic passiveStatic, UltraToolTipInfo thisToolTipInfo)
        {
            try
            {
                string sDescPrep = passiveStatic.Description;

                //Fix color tags
                sDescPrep = sDescPrep.Replace("class=\"color", "style=\"color:#");


                //Artificial Word-wrap
                sDescPrep = StringExtensions.BrWrapper(sDescPrep);



                //Prep Image for tooltip
                string version = getChampionsFromServer.version;
                string file    = string.Format(@"{0}\Data\Champions\Images\{1}\{2}", PublicStaticVariables.thisAppDataDir, version, passiveStatic.Image.Sprite);
                string dir     = string.Format(@"{0}\Data\Champions\Images", PublicStaticVariables.thisAppDataDir);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                Image imageTemp = Image.FromFile(file);
                imageTemp = CommonMethods.cropImage(imageTemp, new Rectangle(passiveStatic.Image.X, passiveStatic.Image.Y, passiveStatic.Image.Width, passiveStatic.Image.Height));
                string image = FormattedLinkEditor.EncodeImage(imageTemp);


                //Compile Description
                string tipDesc = string.Format(@"
				<div style='color:White; font-family:Tahoma; font-size:10pt; text-smoothing-mode:AntiAlias; border-style:solid; border-width:2px; width:400px'>
				  <img style='padding: 4 4 0 4;' data='{2}' width='48' height='48'/>
				  <div>
					<br/>
					<b>{0}</b>
				  </div>
				<hr style='border-style:solid; margin: 0 0 0 0;'/>
				{1}
				</div>"                , passiveStatic.Name,
                                               sDescPrep,
                                               image);

                tipDesc = tipDesc.Replace("<br>", "<br/>");
                tipDesc = tipDesc.Replace("\"", "'");
                //tipDesc = tipDesc.Replace("\r", "");
                //tipDesc = tipDesc.Replace("\n", "");
                //tipDesc = tipDesc.Replace("\t", "");



                //TODO: add \r for troubleshooting
                tipDesc = tipDesc.Replace("<br/>", "<br/>\r\n");


                //These tags needed to be closed for UltraToolTipInfo to accept it as well-formed html because by default HtmlAgilityPack removes the /> at the end
                HtmlNode.ElementsFlags["img"] = HtmlElementFlag.Closed;
                HtmlNode.ElementsFlags["hr"]  = HtmlElementFlag.Closed;
                HtmlNode.ElementsFlags["br"]  = HtmlElementFlag.Closed;
                //Fixes Riots malformed html
                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.LoadHtml(tipDesc);
                MemoryStream memoryStream = new MemoryStream();
                doc.Save(memoryStream);
                memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
                StreamReader streamReader = new StreamReader(memoryStream);
                tipDesc = streamReader.ReadToEnd();


                thisToolTipInfo.ToolTipTextFormatted = tipDesc;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }