mirror of
https://github.com/4sval/FModel.git
synced 2026-03-22 01:34:37 -05:00
Supported Save to World Localization
This commit is contained in:
parent
5255b797b5
commit
61820cf2e7
|
|
@ -29,12 +29,14 @@ namespace FModel
|
|||
|
||||
public static void DrawTexts(ItemsIdParser theItem, Graphics myGraphic, string mode)
|
||||
{
|
||||
bool isSTW = (mode == "stwHeroes" || mode == "stwDefenders");
|
||||
|
||||
using (myGraphic)
|
||||
{
|
||||
SetTexts(theItem);
|
||||
SetTexts(theItem, isSTW);
|
||||
|
||||
DrawDisplayName(theItem, myGraphic);
|
||||
DrawDescription(theItem, myGraphic);
|
||||
DrawDisplayName(theItem, myGraphic, isSTW);
|
||||
DrawDescription(theItem, myGraphic, isSTW);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
|
|
@ -81,7 +83,7 @@ namespace FModel
|
|||
/// todo: find a better way to handle errors
|
||||
/// </summary>
|
||||
/// <param name="theItem"></param>
|
||||
private static void SetTexts(ItemsIdParser theItem)
|
||||
private static void SetTexts(ItemsIdParser theItem, bool isSTW = false)
|
||||
{
|
||||
CosmeticSource = "";
|
||||
CosmeticSet = "";
|
||||
|
|
@ -113,7 +115,7 @@ namespace FModel
|
|||
case "Turkish":
|
||||
case "Chinese (S)":
|
||||
case "Traditional Chinese":
|
||||
ShortDescription = theItem.ShortDescription != null ? SearchResource.getTextByKey(theItem.ShortDescription.Key, theItem.ShortDescription.SourceString) : "";
|
||||
ShortDescription = theItem.ShortDescription != null ? SearchResource.getTextByKey(theItem.ShortDescription.Key, theItem.ShortDescription.SourceString, isSTW) : "";
|
||||
break;
|
||||
default:
|
||||
ShortDescription = theItem.ShortDescription != null ? theItem.ShortDescription.SourceString : "";
|
||||
|
|
@ -248,13 +250,13 @@ namespace FModel
|
|||
/// </summary>
|
||||
/// <param name="theItem"></param>
|
||||
/// <param name="myGraphic"></param>
|
||||
private static void DrawDisplayName(ItemsIdParser theItem, Graphics myGraphic)
|
||||
private static void DrawDisplayName(ItemsIdParser theItem, Graphics myGraphic, bool isSTW = false)
|
||||
{
|
||||
if (theItem.DisplayName != null)
|
||||
{
|
||||
//myGraphic.DrawRectangle(new Pen(new SolidBrush(Color.Red)), new Rectangle(5, 405, 512, 55));
|
||||
|
||||
string text = SearchResource.getTextByKey(theItem.DisplayName.Key, theItem.DisplayName.SourceString);
|
||||
string text = SearchResource.getTextByKey(theItem.DisplayName.Key, theItem.DisplayName.SourceString, isSTW);
|
||||
|
||||
Font goodFont = FontUtilities.FindFont(
|
||||
myGraphic,
|
||||
|
|
@ -278,13 +280,13 @@ namespace FModel
|
|||
/// </summary>
|
||||
/// <param name="theItem"></param>
|
||||
/// <param name="myGraphic"></param>
|
||||
private static void DrawDescription(ItemsIdParser theItem, Graphics myGraphic)
|
||||
private static void DrawDescription(ItemsIdParser theItem, Graphics myGraphic, bool isSTW = false)
|
||||
{
|
||||
if (theItem.Description != null)
|
||||
{
|
||||
//myGraphic.DrawRectangle(new Pen(new SolidBrush(Color.Pink)), new Rectangle(5, 455, 512, 42));
|
||||
|
||||
string text = SearchResource.getTextByKey(theItem.Description.Key, theItem.Description.SourceString);
|
||||
string text = SearchResource.getTextByKey(theItem.Description.Key, theItem.Description.SourceString, isSTW);
|
||||
if (!string.IsNullOrEmpty(CosmeticSet))
|
||||
{
|
||||
string theSet = DrawCosmeticSet(CosmeticSet);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace FModel
|
|||
static class LoadLocRes
|
||||
{
|
||||
public static string myLocRes { get; set; }
|
||||
public static string myLocResSTW { get; set; }
|
||||
|
||||
public static void LoadMySelectedLocRes(string selectedLanguage)
|
||||
{
|
||||
|
|
@ -12,45 +13,59 @@ namespace FModel
|
|||
{
|
||||
case "French":
|
||||
myLocRes = getMyLocRes("fr");
|
||||
myLocResSTW = getMyLocRes("fr", true);
|
||||
break;
|
||||
case "German":
|
||||
myLocRes = getMyLocRes("de");
|
||||
myLocResSTW = getMyLocRes("de", true);
|
||||
break;
|
||||
case "Italian":
|
||||
myLocRes = getMyLocRes("it");
|
||||
myLocResSTW = getMyLocRes("it", true);
|
||||
break;
|
||||
case "Spanish":
|
||||
myLocRes = getMyLocRes("es");
|
||||
myLocResSTW = getMyLocRes("es", true);
|
||||
break;
|
||||
case "Spanish (LA)":
|
||||
myLocRes = getMyLocRes("es-419");
|
||||
myLocResSTW = getMyLocRes("es-419", true);
|
||||
break;
|
||||
case "Arabic":
|
||||
myLocRes = getMyLocRes("ar");
|
||||
myLocResSTW = getMyLocRes("ar", true);
|
||||
break;
|
||||
case "Japanese":
|
||||
myLocRes = getMyLocRes("ja");
|
||||
myLocResSTW = getMyLocRes("ja", true);
|
||||
break;
|
||||
case "Korean":
|
||||
myLocRes = getMyLocRes("ko");
|
||||
myLocResSTW = getMyLocRes("ko", true);
|
||||
break;
|
||||
case "Polish":
|
||||
myLocRes = getMyLocRes("pl");
|
||||
myLocResSTW = getMyLocRes("pl", true);
|
||||
break;
|
||||
case "Portuguese (Brazil)":
|
||||
myLocRes = getMyLocRes("pt-BR");
|
||||
myLocResSTW = getMyLocRes("pt-BR", true);
|
||||
break;
|
||||
case "Russian":
|
||||
myLocRes = getMyLocRes("ru");
|
||||
myLocResSTW = getMyLocRes("ru", true);
|
||||
break;
|
||||
case "Turkish":
|
||||
myLocRes = getMyLocRes("tr");
|
||||
myLocResSTW = getMyLocRes("tr", true);
|
||||
break;
|
||||
case "Chinese (S)":
|
||||
myLocRes = getMyLocRes("zh-CN");
|
||||
myLocResSTW = getMyLocRes("zh-CN", true);
|
||||
break;
|
||||
case "Traditional Chinese":
|
||||
myLocRes = getMyLocRes("zh-Hant");
|
||||
myLocResSTW = getMyLocRes("zh-Hant", true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -62,19 +77,19 @@ namespace FModel
|
|||
/// </summary>
|
||||
/// <param name="selectedLanguage"></param>
|
||||
/// <returns></returns>
|
||||
private static string getMyLocRes(string selectedLanguage)
|
||||
private static string getMyLocRes(string selectedLanguage, bool isSTW = false)
|
||||
{
|
||||
if (ThePak.AllpaksDictionary != null)
|
||||
{
|
||||
if (ThePak.AllpaksDictionary.ContainsKey("Game_BR.locres"))
|
||||
if (ThePak.AllpaksDictionary.ContainsKey(isSTW ? "Game_StW.locres" : "Game_BR.locres"))
|
||||
{
|
||||
string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres");
|
||||
string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary[isSTW ? "Game_StW.locres" : "Game_BR.locres"], isSTW ? "Game_StW.locres" : "Game_BR.locres");
|
||||
|
||||
return LocResSerializer.StringFinder(locResPath.Replace("zh-Hant", selectedLanguage));
|
||||
}
|
||||
else
|
||||
{
|
||||
new UpdateMyConsole("[FModel] Localization File Not Found - Icon Language set to English", Color.DarkRed, true).AppendToConsole();
|
||||
new UpdateMyConsole("[FModel] "+ (isSTW ? "STW" : "BR") +" Localization File Not Found - Icon Language set to English", Color.DarkRed, true).AppendToConsole();
|
||||
new UpdateMyConsole("", Color.Black, true).AppendToConsole();
|
||||
|
||||
Properties.Settings.Default.IconLanguage = "English";
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ namespace FModel
|
|||
static class SearchResource
|
||||
{
|
||||
private static string parsedJsonToCheck { get; set; }
|
||||
private static string parsedSTWJsonToCheck { get; set; }
|
||||
public static JObject jo { get; set; }
|
||||
private static string oldLanguage = Properties.Settings.Default.IconLanguage;
|
||||
private static bool isSTWCheck { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// for most (if not all) of our translations there's no namespace so we just have to find the key in the string
|
||||
|
|
@ -16,15 +18,26 @@ namespace FModel
|
|||
/// </summary>
|
||||
/// <param name="theKey"></param>
|
||||
/// <returns></returns>
|
||||
public static string getTranslatedText(string theKey)
|
||||
public static string getTranslatedText(string theKey, bool isSTW)
|
||||
{
|
||||
string toReturn = string.Empty;
|
||||
string newLanguage = Properties.Settings.Default.IconLanguage;
|
||||
|
||||
if (parsedJsonToCheck == null || newLanguage != oldLanguage)
|
||||
if (isSTW)
|
||||
{
|
||||
parsedJsonToCheck = JToken.Parse(LoadLocRes.myLocRes).ToString().TrimStart('[').TrimEnd(']');
|
||||
jo = JObject.Parse(parsedJsonToCheck);
|
||||
if (parsedSTWJsonToCheck == null || newLanguage != oldLanguage || isSTWCheck != isSTW)
|
||||
{
|
||||
parsedSTWJsonToCheck = JToken.Parse(LoadLocRes.myLocResSTW).ToString().TrimStart('[').TrimEnd(']');
|
||||
jo = JObject.Parse(parsedSTWJsonToCheck);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parsedJsonToCheck == null || newLanguage != oldLanguage || isSTWCheck != isSTW)
|
||||
{
|
||||
parsedJsonToCheck = JToken.Parse(LoadLocRes.myLocRes).ToString().TrimStart('[').TrimEnd(']');
|
||||
jo = JObject.Parse(parsedJsonToCheck);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (JToken token in jo.FindTokens(theKey))
|
||||
|
|
@ -36,16 +49,17 @@ namespace FModel
|
|||
}
|
||||
}
|
||||
|
||||
isSTWCheck = isSTW;
|
||||
oldLanguage = newLanguage;
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static string getTextByKey(string key, string defaultText)
|
||||
public static string getTextByKey(string key, string defaultText, bool isSTW = false)
|
||||
{
|
||||
string text = defaultText;
|
||||
if (LoadLocRes.myLocRes != null && Properties.Settings.Default.IconLanguage != "English")
|
||||
{
|
||||
text = getTranslatedText(key);
|
||||
text = getTranslatedText(key, isSTW);
|
||||
if (string.IsNullOrEmpty(text))
|
||||
text = defaultText;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user