FModel 2.4.0

This commit is contained in:
Asval
2019-06-18 00:13:16 +02:00
parent 7203caf3db
commit 19d86e8127
17 changed files with 194 additions and 161 deletions

View File

@@ -154,13 +154,49 @@ namespace FModel
}
private static void drawCompletionText(string count)
{
string all = string.Empty;
string any = string.Empty;
switch (Settings.Default.IconLanguage)
{
case "English":
all = "Complete ALL CHALLENGES to earn the reward item";
any = "Complete ANY " + count + " CHALLENGES to earn the reward item";
goto default;
case "French":
all = "Terminez CHACUN DES DÉFIS pour gagner la récompense";
any = "Terminez " + count + " DES DÉFIS pour gagner la récompense";
goto default;
case "German":
all = "Schließe ALLE HERAUSFORDERUNGEN ab, um die Belohnung zu verdienen";
any = "Schließe " + count + " HERAUSFORDERUNGEN ab, um die Belohnung zu verdienen";
goto default;
case "Italian":
all = "Completa TUTTE LE SFIDE per ottenere l'oggetto in ricompensa";
any = "Completa " + count + " SFIDE QUALSIASI per ottenere l'oggetto ricompensa";
goto default;
case "Spanish":
all = "Completa LOS DESAFÍOS para conseguir el objeto de recompensa";
any = "Completa " + count + " DE LOS DESAFÍOS para conseguir el objeto de recompensa";
goto default;
default:
if (count == "-1")
{
toDrawOn.DrawString(all, new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
}
else
{
toDrawOn.DrawString(any, new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
}
break;
}
if (count == "-1")
{
toDrawOn.DrawString("Complete ALL CHALLENGES to earn the reward item", new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
toDrawOn.DrawString(all, new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
}
else
{
toDrawOn.DrawString("Complete ANY " + count + " CHALLENGES to earn the reward item", new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
toDrawOn.DrawString(any, new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22));
}
}
@@ -170,8 +206,25 @@ namespace FModel
/// <param name="myBitmap"></param>
public static void drawWatermark(Bitmap myBitmap)
{
toDrawOn.FillRectangle(new SolidBrush(Color.FromArgb(100, 0, 0, 0)), new Rectangle(0, theY + 240, myBitmap.Width, 40));
toDrawOn.DrawString(myItem.DisplayName + " Generated using FModel & JohnWickParse - " + DateTime.Now.ToString("dd/MM/yyyy"), new Font(FontUtilities.pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(myBitmap.Width / 2, theY + 250), FontUtilities.centeredString);
if (LoadLocRes.myLocRes != null && Settings.Default.IconLanguage != "English")
{
string text = SearchResource.getTranslatedText(myItem.DisplayName.Key);
if (!string.IsNullOrEmpty(text))
{
toDrawOn.FillRectangle(new SolidBrush(Color.FromArgb(100, 0, 0, 0)), new Rectangle(0, theY + 240, myBitmap.Width, 40));
toDrawOn.DrawString(text + " Generated using FModel & JohnWickParse - " + DateTime.Now.ToString("dd/MM/yyyy"), new Font(FontUtilities.pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(myBitmap.Width / 2, theY + 250), FontUtilities.centeredString);
}
else
{
toDrawOn.FillRectangle(new SolidBrush(Color.FromArgb(100, 0, 0, 0)), new Rectangle(0, theY + 240, myBitmap.Width, 40));
toDrawOn.DrawString(myItem.DisplayName.SourceString + " Generated using FModel & JohnWickParse - " + DateTime.Now.ToString("dd/MM/yyyy"), new Font(FontUtilities.pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(myBitmap.Width / 2, theY + 250), FontUtilities.centeredString);
}
}
else
{
toDrawOn.FillRectangle(new SolidBrush(Color.FromArgb(100, 0, 0, 0)), new Rectangle(0, theY + 240, myBitmap.Width, 40));
toDrawOn.DrawString(myItem.DisplayName.SourceString + " Generated using FModel & JohnWickParse - " + DateTime.Now.ToString("dd/MM/yyyy"), new Font(FontUtilities.pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(myBitmap.Width / 2, theY + 250), FontUtilities.centeredString);
}
}
private static void drawForbyteReward()

View File

@@ -34,7 +34,16 @@ namespace FModel
}
public static string getBundleDisplayName(ItemsIdParser theItem)
{
return theItem.DisplayName.ToUpper();
if (LoadLocRes.myLocRes != null && Properties.Settings.Default.IconLanguage != "English")
{
string text = SearchResource.getTranslatedText(theItem.DisplayName.Key);
if (!string.IsNullOrEmpty(text))
{
return text.ToUpper();
}
else { return theItem.DisplayName.SourceString.ToUpper(); }
}
else { return theItem.DisplayName.SourceString.ToUpper(); }
}
public static string getLastFolder(string pathToExtractedBundle)
{
@@ -93,11 +102,18 @@ namespace FModel
long oldCount = 0;
for (int p = 0; p < questParser[x].Objectives.Length; p++)
{
string newQuest = questParser[x].Objectives[p].Description;
string newQuest;
if (LoadLocRes.myLocRes != null && Properties.Settings.Default.IconLanguage != "English")
{
newQuest = SearchResource.getTranslatedText(questParser[x].Objectives[p].Description.Key);
}
else { newQuest = questParser[x].Objectives[p].Description.SourceString; }
long newCount = questParser[x].Objectives[p].Count;
if (questParser[x].BAthenaMustCompleteInSingleMatch != false && questParser[x].ObjectiveCompletionCount > 0)
if (questParser[x].BAthenaMustCompleteInSingleMatch && questParser[x].ObjectiveCompletionCount > 0)
{
newCount = questParser[x].ObjectiveCompletionCount;
}
if (newQuest != oldQuest && newCount != oldCount)
{

View File

@@ -84,7 +84,19 @@ namespace FModel
try
{
ShortDescription = theItem.ShortDescription;
switch (Settings.Default.IconLanguage)
{
case "French":
case "German":
case "Italian":
case "Spanish":
ShortDescription = SearchResource.getTranslatedText(theItem.ShortDescription.Key);
if (string.IsNullOrEmpty(ShortDescription)) { ShortDescription = theItem.ShortDescription.SourceString; }
break;
default:
ShortDescription = theItem.ShortDescription.SourceString;
break;
}
}
catch (Exception)
{
@@ -219,7 +231,22 @@ namespace FModel
{
if (theItem.DisplayName != null)
{
myGraphic.DrawString(theItem.DisplayName, new Font(FontUtilities.pfc.Families[0], 35), new SolidBrush(Color.White), new Point(522 / 2, 395), FontUtilities.centeredString);
if (LoadLocRes.myLocRes != null && Settings.Default.IconLanguage != "English")
{
string text = SearchResource.getTranslatedText(theItem.DisplayName.Key);
if (!string.IsNullOrEmpty(text))
{
myGraphic.DrawString(text, new Font(FontUtilities.pfc.Families[0], 35), new SolidBrush(Color.White), new Point(522 / 2, 395), FontUtilities.centeredString);
}
else
{
myGraphic.DrawString(theItem.DisplayName.SourceString, new Font(FontUtilities.pfc.Families[0], 35), new SolidBrush(Color.White), new Point(522 / 2, 395), FontUtilities.centeredString);
}
}
else
{
myGraphic.DrawString(theItem.DisplayName.SourceString, new Font(FontUtilities.pfc.Families[0], 35), new SolidBrush(Color.White), new Point(522 / 2, 395), FontUtilities.centeredString);
}
}
}
@@ -232,7 +259,22 @@ namespace FModel
{
if (theItem.Description != null)
{
myGraphic.DrawString(theItem.Description, new Font("Arial", 10), new SolidBrush(Color.White), new RectangleF(5, 441, 512, 49), FontUtilities.centeredStringLine);
if (LoadLocRes.myLocRes != null && Settings.Default.IconLanguage != "English")
{
string text = SearchResource.getTranslatedText(theItem.Description.Key);
if (!string.IsNullOrEmpty(text))
{
myGraphic.DrawString(text, new Font("Arial", 10), new SolidBrush(Color.White), new RectangleF(5, 441, 512, 49), FontUtilities.centeredStringLine);
}
else
{
myGraphic.DrawString(theItem.Description.SourceString, new Font("Arial", 10), new SolidBrush(Color.White), new RectangleF(5, 441, 512, 49), FontUtilities.centeredStringLine);
}
}
else
{
myGraphic.DrawString(theItem.Description.SourceString, new Font("Arial", 10), new SolidBrush(Color.White), new RectangleF(5, 441, 512, 49), FontUtilities.centeredStringLine);
}
}
}

View File

@@ -1,109 +0,0 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace FModel
{
static class AssetNameMap
{
public static List<string> myNamespacesList { get; set; }
public static void searchStringsInUexp(string filepath)
{
myNamespacesList = new List<string>();
if (File.Exists(filepath))
{
List<string> weirdStrings = new List<string>();
List<string> listBeforeData = new List<string>();
bool previousByteWasValid = false;
byte[] bytes = File.ReadAllBytes(filepath);
string pattern = @"^[a-zA-Z0-9()'\-.&!+, ]";
Regex regex = new Regex(pattern);
foreach (byte b in bytes) // Iterate throught all the bytes of the file
{
string byteString = Encoding.UTF8.GetString(new[] { b }); // Generate string for single byte
bool valid = regex.IsMatch(byteString);
if (valid)
{
if (previousByteWasValid) weirdStrings[weirdStrings.Count - 1] += byteString;
else weirdStrings.Add(byteString);
}
previousByteWasValid = valid;
}
bool found = false;
foreach (string str in weirdStrings)
{
if (str.Length >= 2)
{
if (found) { myNamespacesList.Add(str); break; }
listBeforeData.Add(str);
if (str == "Outfit"
|| str == "Back Bling"
|| str == "Pet"
|| str == "Harvesting Tool"
|| str == "Glider"
|| str == "Contrail"
|| str == "Emote"
|| str == "Emoticon"
|| str == "Toy"
|| str == "Music")
{
int index = listBeforeData.IndexOf(str);
//Console.WriteLine("DName: " + listBeforeData[index - 3]);
//Console.WriteLine("Description: " + listBeforeData[index - 1]);
myNamespacesList.Add(listBeforeData[index - 3]);
myNamespacesList.Add(listBeforeData[index - 1]);
found = true;
}
}
}
}
}
public static void getNameMap(string filepath)
{
Console.Clear();
using (BinaryReader reader = new BinaryReader(File.Open(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.GetEncoding(1252)))
{
reader.ReadBytes(24);
int AssetLength = reader.ReadInt32();
//Console.WriteLine(AssetLength);
reader.ReadBytes(13);
int NamespaceCount = reader.ReadInt32();
long LocalizedStringArrayOffset = -1;
LocalizedStringArrayOffset = reader.ReadInt64();
if (LocalizedStringArrayOffset != -1)
{
long newOffset = LocalizedStringArrayOffset - 4;
reader.BaseStream.Seek(newOffset, SeekOrigin.Begin);
string[] LocalizedStringArray = new string[NamespaceCount];
for (int i = 0; i < LocalizedStringArray.Length; i++)
{
string tag = AssetReader.readCleanString(reader);
if (tag != "None") { LocalizedStringArray[i] = tag; Console.WriteLine(LocalizedStringArray[i]); }
}
}
}
}
}
}

View File

@@ -27,7 +27,11 @@
private static string getMyLocRes(string selectedLanguage)
{
string oldKey = JohnWick.MyKey;
JohnWick.MyKey = Properties.Settings.Default.AESKey;
string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres");
JohnWick.MyKey = oldKey;
return LocResSerializer.StringFinder(locResPath.Replace("zh-Hant", selectedLanguage));
}
}

View File

@@ -6,17 +6,19 @@ namespace FModel
static class SearchResource
{
private static string parsedJsonToCheck { get; set; }
private static JObject jo { get; set; }
private static string oldLanguage = Properties.Settings.Default.IconLanguage;
public static string getTranslatedText(string theNamespace)
{
string toReturn = string.Empty;
string myParsedJson = string.Empty;
string newLanguage = Properties.Settings.Default.IconLanguage;
if (myParsedJson != parsedJsonToCheck)
if (parsedJsonToCheck == null || newLanguage != oldLanguage)
{
myParsedJson = JToken.Parse(LoadLocRes.myLocRes).ToString().TrimStart('[').TrimEnd(']');
parsedJsonToCheck = JToken.Parse(LoadLocRes.myLocRes).ToString().TrimStart('[').TrimEnd(']');
jo = JObject.Parse(parsedJsonToCheck);
}
JObject jo = JObject.Parse(myParsedJson);
foreach (JToken token in jo.FindTokens(theNamespace))
{
LocResParser LocResParse = LocResParser.FromJson(token.ToString());
@@ -24,13 +26,9 @@ namespace FModel
{
toReturn = LocResParse.LocResText;
}
else if (LocResParse.WorkerSetBonusTraitPattern != null)
{
toReturn = LocResParse.WorkerSetBonusTraitPattern;
}
}
oldLanguage = newLanguage;
parsedJsonToCheck = myParsedJson;
return toReturn;
}
}

View File

@@ -99,18 +99,6 @@ namespace FModel
}
currentPakToCheck = currentPak;
/*if (AssetPath.Contains("Athena\\Items\\") && File.Exists(AssetPath.Substring(0, AssetPath.LastIndexOf(".")) + ".uexp")) //TEST
{
try
{
AssetNameMap.searchStringsInUexp(AssetPath.Substring(0, AssetPath.LastIndexOf(".")) + ".uexp");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}*/
return AssetPath;
}