Implemented Short Description of Wraps & cleanup/simplify

This commit is contained in:
MaikyM 2019-08-20 01:06:33 -06:00
parent 86160a8be0
commit 6a810bb940
3 changed files with 53 additions and 110 deletions

View File

@ -288,76 +288,59 @@ namespace FModel
string all = "Complete ALL CHALLENGES to earn the reward item"; string all = "Complete ALL CHALLENGES to earn the reward item";
string any = "Complete ANY " + count + " 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": all = SearchResource.getTextByKey("CompletionRewardFormat_All", "Complete ALL CHALLENGES to earn the reward item", "AthenaChallengeDetailsEntry");
case "German": any = SearchResource.getTextByKey("CompletionRewardFormat", "Complete ANY " + count + " CHALLENGES to earn the reward item", "AthenaChallengeDetailsEntry");
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");
//because HtmlAgilityPack fail to detect the end of the tag when it's </> //because HtmlAgilityPack fail to detect the end of the tag when it's </>
if (all.Contains("</>")) { all = all.Replace("</>", "</text>"); } if (all.Contains("</>")) { all = all.Replace("</>", "</text>"); }
if (any.Contains("</>")) { any = any.Replace("</>", "</text>"); } if (any.Contains("</>")) { any = any.Replace("</>", "</text>"); }
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(all); doc.LoadHtml(all);
if (doc.DocumentNode.InnerText.Contains(" {0}")) //avoid white space if (doc.DocumentNode.InnerText.Contains(" {0}")) //avoid white space
{
if (all.Contains("</text>"))
{ {
if (all.Contains("</text>")) all = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
{ all = all.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); }
} }
else else { all = doc.DocumentNode.InnerText.Replace(" {0}", string.Empty); }
}
else
{
if (all.Contains("</text>"))
{ {
if (all.Contains("</text>")) all = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
{ all = all.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); }
} }
else { all = doc.DocumentNode.InnerText.Replace("{0}", string.Empty); }
}
doc = new HtmlAgilityPack.HtmlDocument(); doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(any); doc.LoadHtml(any);
if (doc.DocumentNode.InnerText.Contains("{QuestNumber}")) //russian if (doc.DocumentNode.InnerText.Contains("{QuestNumber}")) //russian
{
if (any.Contains("</text>"))
{ {
if (any.Contains("</text>")) any = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
{ any = any.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 { any = doc.DocumentNode.InnerText.Replace("{QuestNumber}", count); }
} }
else else { any = doc.DocumentNode.InnerText.Replace("{QuestNumber}", count); }
}
else
{
if (any.Contains("</text>"))
{ {
if (any.Contains("</text>")) any = doc.DocumentNode.InnerText.Replace(doc.DocumentNode.SelectSingleNode("text").InnerText, doc.DocumentNode.SelectSingleNode("text").InnerText.ToUpper());
{ any = string.Format(any, 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); }
} }
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 (all.Contains(" ")) { all = all.Replace(" ", " "); } //double space in Spanish (LA) i.e. with QuestBundle_PirateParty
if (any.Contains(" ")) { any = any.Replace(" ", " "); } if (any.Contains(" ")) { any = any.Replace(" ", " "); }
break;
default:
break;
} }
drawQuestBackground(myBitmap, false); drawQuestBackground(myBitmap, false);

View File

@ -107,37 +107,12 @@ namespace FModel
{ {
JToken key = shortDescription["key"]; JToken key = shortDescription["key"];
JToken sourceString = shortDescription["source_string"]; JToken sourceString = shortDescription["source_string"];
ShortDescription = SearchResource.getTextByKey(key != null ? key.Value<string>() : "", sourceString != null ? sourceString.Value<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<string>(), sourceString.Value<string>());
}
break;
default:
if (sourceString != null)
{
ShortDescription = sourceString.Value<string>();
}
break;
}
} }
if (theItem["export_type"] != null && theItem["export_type"].Value<string>().Equals("AthenaItemWrapDefinition"))
ShortDescription = SearchResource.getTextByKey("ItemWrapShortDescription", "Wrap", "Fort.Cosmetics");
JToken gameplayTags = theItem["GameplayTags"]; JToken gameplayTags = theItem["GameplayTags"];
if (gameplayTags != null) if (gameplayTags != null)
{ {
@ -500,32 +475,14 @@ namespace FModel
JToken setToken = cosmeticsSetsArray[0][setName]; JToken setToken = cosmeticsSetsArray[0][setName];
if (setToken != null) if (setToken != null)
{ {
string toReturn = string.Empty; if (!Settings.Default.IconLanguage.Equals("English"))
switch (Settings.Default.IconLanguage)
{ {
case "French": string translatedName = SearchResource.getTextByKey(setToken["DisplayName"]["key"].Value<string>(), setToken["DisplayName"]["source_string"].Value<string>(), setToken["DisplayName"]["namespace"].Value<string>());
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<string>(), setToken["DisplayName"]["source_string"].Value<string>(), setToken["DisplayName"]["namespace"].Value<string>());
toReturn = string.Format(SearchResource.getTextByKey("CosmeticItemDescription_SetMembership_NotRich", setToken["DisplayName"]["source_string"].Value<string>(), "Fort.Cosmetics"), translatedName); return string.Format(SearchResource.getTextByKey("CosmeticItemDescription_SetMembership_NotRich", setToken["DisplayName"]["source_string"].Value<string>(), "Fort.Cosmetics"), translatedName);
break;
default:
toReturn = string.Format("\nPart of the {0} set.", setToken["DisplayName"]["source_string"].Value<string>());
break;
} }
return toReturn; else
return string.Format("\nPart of the {0} set.", setToken["DisplayName"]["source_string"].Value<string>());
} }
else { return ""; } else { return ""; }
} }

View File

@ -33,8 +33,11 @@ namespace FModel
public static string getTextByKey(string key, string defaultText, string namespac = null) public static string getTextByKey(string key, string defaultText, string namespac = null)
{ {
if (Properties.Settings.Default.IconLanguage.Equals("English"))
return defaultText;
string text = defaultText; string text = defaultText;
if (LocResSerializer.LocResDict != null && Properties.Settings.Default.IconLanguage != "English") if (LocResSerializer.LocResDict != null)
{ {
text = getTranslatedText(namespac == null ? "LocResText" : namespac, key); text = getTranslatedText(namespac == null ? "LocResText" : namespac, key);
if (string.IsNullOrEmpty(text)) if (string.IsNullOrEmpty(text))