mirror of
https://github.com/4sval/FModel.git
synced 2026-09-26 11:07:39 -05:00
todo: find translations faster, disabled for now
This commit is contained in:
37
FModel/Methods/IconGenerator/Translations/LoadLocRes.cs
Normal file
37
FModel/Methods/IconGenerator/Translations/LoadLocRes.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
namespace FModel
|
||||
{
|
||||
static class LoadLocRes
|
||||
{
|
||||
public static string myLocRes { get; set; }
|
||||
|
||||
public static void LoadMySelectedLocRes(string selectedLanguage)
|
||||
{
|
||||
switch (selectedLanguage)
|
||||
{
|
||||
case "English":
|
||||
myLocRes = getMyLocRes("en");
|
||||
break;
|
||||
case "French":
|
||||
myLocRes = getMyLocRes("fr");
|
||||
break;
|
||||
case "German":
|
||||
myLocRes = getMyLocRes("de");
|
||||
break;
|
||||
case "Italian":
|
||||
myLocRes = getMyLocRes("it");
|
||||
break;
|
||||
case "Spanish":
|
||||
myLocRes = getMyLocRes("es");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static string getMyLocRes(string selectedLanguage)
|
||||
{
|
||||
string locResPath = JohnWick.ExtractAsset(ThePak.AllpaksDictionary["Game_BR.locres"], "Game_BR.locres");
|
||||
return LocResSerializer.StringFinder(locResPath.Replace("zh-Hant", selectedLanguage));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace FModel
|
||||
{
|
||||
static class SearchNamespaces
|
||||
{
|
||||
public static List<string> myNamespacesList { get; set; }
|
||||
public static void searchNamespacesInUexp(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 == "Toy"
|
||||
|| str == "Music")
|
||||
{
|
||||
int index = listBeforeData.IndexOf(str);
|
||||
|
||||
myNamespacesList.Add(listBeforeData[index - 3]);
|
||||
myNamespacesList.Add(listBeforeData[index - 1]);
|
||||
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
FModel/Methods/IconGenerator/Translations/SearchResource.cs
Normal file
37
FModel/Methods/IconGenerator/Translations/SearchResource.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using FModel.Parser.LocResParser;
|
||||
|
||||
namespace FModel
|
||||
{
|
||||
static class SearchResource
|
||||
{
|
||||
private static string parsedJsonToCheck { get; set; }
|
||||
|
||||
public static string getTranslatedText(string theNamespace)
|
||||
{
|
||||
string toReturn = string.Empty;
|
||||
string myParsedJson = string.Empty;
|
||||
|
||||
if (myParsedJson != parsedJsonToCheck)
|
||||
{
|
||||
myParsedJson = JToken.Parse(LoadLocRes.myLocRes).ToString().TrimStart('[').TrimEnd(']');
|
||||
}
|
||||
JObject jo = JObject.Parse(myParsedJson);
|
||||
foreach (JToken token in jo.FindTokens(theNamespace))
|
||||
{
|
||||
LocResParser LocResParse = LocResParser.FromJson(token.ToString());
|
||||
if (LocResParse.LocResText != null)
|
||||
{
|
||||
toReturn = LocResParse.LocResText;
|
||||
}
|
||||
else if (LocResParse.WorkerSetBonusTraitPattern != null)
|
||||
{
|
||||
toReturn = LocResParse.WorkerSetBonusTraitPattern;
|
||||
}
|
||||
}
|
||||
|
||||
parsedJsonToCheck = myParsedJson;
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace FModel
|
||||
reader.BaseStream.Seek(reader.BaseStream.Length - 49 - 160, SeekOrigin.Begin);
|
||||
uint g4 = reader.ReadUInt32();
|
||||
|
||||
var guid = g1 + "-" + g2 + "-" + g3 + "-" + g4;
|
||||
string guid = g1 + "-" + g2 + "-" + g3 + "-" + g4;
|
||||
return guid;
|
||||
}
|
||||
}
|
||||
@@ -63,8 +63,6 @@ namespace FModel
|
||||
static class Checking
|
||||
{
|
||||
public static bool WasFeatured { get; set; }
|
||||
public static int YAfterLoop { get; set; }
|
||||
|
||||
public static bool UmWorking { get; set; }
|
||||
}
|
||||
public struct BundleInfoEntry: IEquatable<BundleInfoEntry>
|
||||
|
||||
Reference in New Issue
Block a user