From 6a810bb940e02536862af2201d772d3331667ef4 Mon Sep 17 00:00:00 2001 From: MaikyM <51415805+MaikyM@users.noreply.github.com> Date: Tue, 20 Aug 2019 01:06:33 -0600 Subject: [PATCH] Implemented Short Description of Wraps & cleanup/simplify --- .../ChallengeGenerator/BundleDesign.cs | 97 ++++++++----------- .../IconGenerator/ItemGenerator/DrawText.cs | 61 ++---------- .../Translations/SearchResource.cs | 5 +- 3 files changed, 53 insertions(+), 110 deletions(-) diff --git a/FModel/Methods/IconGenerator/ChallengeGenerator/BundleDesign.cs b/FModel/Methods/IconGenerator/ChallengeGenerator/BundleDesign.cs index bc19512b..7ef7b6de 100644 --- a/FModel/Methods/IconGenerator/ChallengeGenerator/BundleDesign.cs +++ b/FModel/Methods/IconGenerator/ChallengeGenerator/BundleDesign.cs @@ -288,76 +288,59 @@ namespace FModel string all = "Complete ALL CHALLENGES to earn the reward item"; string any = "Complete ANY " + count + " CHALLENGES to earn the reward item"; - switch (Settings.Default.IconLanguage) + if (!Settings.Default.IconLanguage.Equals("English")) { - case "French": - case "German": - case "Italian": - case "Spanish": - case "Spanish (LA)": - case "Arabic": - case "Japanese": - case "Korean": - case "Polish": - case "Portuguese (Brazil)": - case "Russian": - case "Turkish": - case "Chinese (S)": - case "Traditional Chinese": - all = SearchResource.getTextByKey("CompletionRewardFormat_All", "Complete ALL CHALLENGES to earn the reward item", "AthenaChallengeDetailsEntry"); - any = SearchResource.getTextByKey("CompletionRewardFormat", "Complete ANY " + count + " CHALLENGES to earn the reward item", "AthenaChallengeDetailsEntry"); + all = SearchResource.getTextByKey("CompletionRewardFormat_All", "Complete ALL CHALLENGES to earn the reward item", "AthenaChallengeDetailsEntry"); + any = SearchResource.getTextByKey("CompletionRewardFormat", "Complete ANY " + count + " CHALLENGES to earn the reward item", "AthenaChallengeDetailsEntry"); - //because HtmlAgilityPack fail to detect the end of the tag when it's - if (all.Contains("")) { all = all.Replace("", ""); } - if (any.Contains("")) { any = any.Replace("", ""); } + //because HtmlAgilityPack fail to detect the end of the tag when it's + if (all.Contains("")) { all = all.Replace("", ""); } + if (any.Contains("")) { any = any.Replace("", ""); } - HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); - doc.LoadHtml(all); - if (doc.DocumentNode.InnerText.Contains(" {0}")) //avoid white space + HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); + doc.LoadHtml(all); + if (doc.DocumentNode.InnerText.Contains(" {0}")) //avoid white space + { + if (all.Contains("")) { - if (all.Contains("")) - { - all = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper()); - all = all.Replace(" {0}", string.Empty); - } - else { all = doc.DocumentNode.InnerText.Replace(" {0}", string.Empty); } + all = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper()); + all = all.Replace(" {0}", string.Empty); } - else + else { all = doc.DocumentNode.InnerText.Replace(" {0}", string.Empty); } + } + else + { + if (all.Contains("")) { - if (all.Contains("")) - { - all = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper()); - all = all.Replace("{0}", string.Empty); - } - else { all = doc.DocumentNode.InnerText.Replace("{0}", string.Empty); } + all = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper()); + all = all.Replace("{0}", string.Empty); } + else { all = doc.DocumentNode.InnerText.Replace("{0}", string.Empty); } + } - doc = new HtmlAgilityPack.HtmlDocument(); - doc.LoadHtml(any); - if (doc.DocumentNode.InnerText.Contains("{QuestNumber}")) //russian + doc = new HtmlAgilityPack.HtmlDocument(); + doc.LoadHtml(any); + if (doc.DocumentNode.InnerText.Contains("{QuestNumber}")) //russian + { + if (any.Contains("")) { - if (any.Contains("")) - { - any = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper()); - any = any.Replace("{QuestNumber}", count); - } - else { any = doc.DocumentNode.InnerText.Replace("{QuestNumber}", count); } + any = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper()); + any = any.Replace("{QuestNumber}", count); } - else + else { any = doc.DocumentNode.InnerText.Replace("{QuestNumber}", count); } + } + else + { + if (any.Contains("")) { - if (any.Contains("")) - { - any = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper()); - any = string.Format(any, count); - } - else { any = string.Format(doc.DocumentNode.InnerText, count); } + any = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper()); + any = string.Format(any, count); } + else { any = string.Format(doc.DocumentNode.InnerText, count); } + } - if (all.Contains(" ")) { all = all.Replace(" ", " "); } //double space in Spanish (LA) i.e. with QuestBundle_PirateParty - if (any.Contains(" ")) { any = any.Replace(" ", " "); } - break; - default: - break; + if (all.Contains(" ")) { all = all.Replace(" ", " "); } //double space in Spanish (LA) i.e. with QuestBundle_PirateParty + if (any.Contains(" ")) { any = any.Replace(" ", " "); } } drawQuestBackground(myBitmap, false); diff --git a/FModel/Methods/IconGenerator/ItemGenerator/DrawText.cs b/FModel/Methods/IconGenerator/ItemGenerator/DrawText.cs index c2d31bfd..f4264430 100644 --- a/FModel/Methods/IconGenerator/ItemGenerator/DrawText.cs +++ b/FModel/Methods/IconGenerator/ItemGenerator/DrawText.cs @@ -107,37 +107,12 @@ namespace FModel { JToken key = shortDescription["key"]; JToken sourceString = shortDescription["source_string"]; - - switch (Settings.Default.IconLanguage) - { - case "French": - case "German": - case "Italian": - case "Spanish": - case "Spanish (LA)": - case "Arabic": - case "Japanese": - case "Korean": - case "Polish": - case "Portuguese (Brazil)": - case "Russian": - case "Turkish": - case "Chinese (S)": - case "Traditional Chinese": - if (key != null && sourceString != null) - { - ShortDescription = SearchResource.getTextByKey(key.Value(), sourceString.Value()); - } - break; - default: - if (sourceString != null) - { - ShortDescription = sourceString.Value(); - } - break; - } + ShortDescription = SearchResource.getTextByKey(key != null ? key.Value() : "", sourceString != null ? sourceString.Value() : ""); } + if (theItem["export_type"] != null && theItem["export_type"].Value().Equals("AthenaItemWrapDefinition")) + ShortDescription = SearchResource.getTextByKey("ItemWrapShortDescription", "Wrap", "Fort.Cosmetics"); + JToken gameplayTags = theItem["GameplayTags"]; if (gameplayTags != null) { @@ -500,32 +475,14 @@ namespace FModel JToken setToken = cosmeticsSetsArray[0][setName]; if (setToken != null) { - string toReturn = string.Empty; - switch (Settings.Default.IconLanguage) + if (!Settings.Default.IconLanguage.Equals("English")) { - case "French": - case "German": - case "Italian": - case "Spanish": - case "Spanish (LA)": - case "Arabic": - case "Japanese": - case "Korean": - case "Polish": - case "Portuguese (Brazil)": - case "Russian": - case "Turkish": - case "Chinese (S)": - case "Traditional Chinese": - string translatedName = SearchResource.getTextByKey(setToken["DisplayName"]["key"].Value(), setToken["DisplayName"]["source_string"].Value(), setToken["DisplayName"]["namespace"].Value()); + string translatedName = SearchResource.getTextByKey(setToken["DisplayName"]["key"].Value(), setToken["DisplayName"]["source_string"].Value(), setToken["DisplayName"]["namespace"].Value()); - toReturn = string.Format(SearchResource.getTextByKey("CosmeticItemDescription_SetMembership_NotRich", setToken["DisplayName"]["source_string"].Value(), "Fort.Cosmetics"), translatedName); - break; - default: - toReturn = string.Format("\nPart of the {0} set.", setToken["DisplayName"]["source_string"].Value()); - break; + return string.Format(SearchResource.getTextByKey("CosmeticItemDescription_SetMembership_NotRich", setToken["DisplayName"]["source_string"].Value(), "Fort.Cosmetics"), translatedName); } - return toReturn; + else + return string.Format("\nPart of the {0} set.", setToken["DisplayName"]["source_string"].Value()); } else { return ""; } } diff --git a/FModel/Methods/IconGenerator/Translations/SearchResource.cs b/FModel/Methods/IconGenerator/Translations/SearchResource.cs index 39895d65..75ad27b8 100644 --- a/FModel/Methods/IconGenerator/Translations/SearchResource.cs +++ b/FModel/Methods/IconGenerator/Translations/SearchResource.cs @@ -33,8 +33,11 @@ namespace FModel public static string getTextByKey(string key, string defaultText, string namespac = null) { + if (Properties.Settings.Default.IconLanguage.Equals("English")) + return defaultText; + string text = defaultText; - if (LocResSerializer.LocResDict != null && Properties.Settings.Default.IconLanguage != "English") + if (LocResSerializer.LocResDict != null) { text = getTranslatedText(namespac == null ? "LocResText" : namespac, key); if (string.IsNullOrEmpty(text))