added Hotfixed strings support + DC Rarity

This commit is contained in:
Asval 2019-09-18 23:24:37 +02:00
parent a655a07ff9
commit 8cce7701d6
9 changed files with 144 additions and 18 deletions

View File

@ -91,9 +91,6 @@
<Reference Include="Cyotek.Windows.Forms.ColorPicker, Version=1.0.0.0, Culture=neutral, PublicKeyToken=58daa28b0b2de221, processorArchitecture=MSIL">
<HintPath>..\packages\Cyotek.Windows.Forms.ColorPicker.1.7.2\lib\net35\Cyotek.Windows.Forms.ColorPicker.dll</HintPath>
</Reference>
<Reference Include="Hammock.ClientProfile, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c148cfba29ed1a4d, processorArchitecture=MSIL">
<HintPath>..\packages\TweetMoaSharp.6.0.0\lib\4.5\Hammock.ClientProfile.dll</HintPath>
</Reference>
<Reference Include="HtmlAgilityPack, Version=1.11.12.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
<HintPath>..\packages\HtmlAgilityPack.1.11.12\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
@ -124,9 +121,6 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="TweetSharp, Version=6.0.0.0, Culture=neutral, PublicKeyToken=c148cfba29ed1a4d, processorArchitecture=MSIL">
<HintPath>..\packages\TweetMoaSharp.6.0.0\lib\4.5\TweetSharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Forms\MergeImages.cs">
@ -162,6 +156,7 @@
<Compile Include="Methods\PakHelper\CreateBackup.cs" />
<Compile Include="Methods\PakHelper\PakHelper.cs" />
<Compile Include="Methods\Serializer\AssetReader.cs" />
<Compile Include="Methods\Serializer\LocRes\HotfixedStrings.cs" />
<Compile Include="Methods\Serializer\LocRes\LocResSerializer.cs" />
<Compile Include="Methods\Scintilla\MyScintilla.cs" />
<Compile Include="Methods\UpdateMode\RegisterSettings.cs" />

View File

@ -192,6 +192,7 @@ namespace FModel
AddBackupFiles();
Utilities.SetFolderPermission(App.DefaultOutputPath);
Utilities.CreateDefaultFolders();
Methods.Serializer.LocRes.HotfixedStrings.setHotfixedStrings();
});
MyScintilla.SetScintillaStyle(scintilla1);

View File

@ -80,6 +80,21 @@ namespace FModel
toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 512, 512), new Point(5, 5));
}
}
else if (theSeries.Equals("DCUSeries"))
{
DrawBackground(toDrawOn, Color.FromArgb(255, 45, 68, 93), Color.FromArgb(255, 16, 25, 40), Color.FromArgb(255, 62, 94, 122));
string cubeBG = JohnWick.AssetToTexture2D("T-BlackMonday-Background");
if (!string.IsNullOrEmpty(cubeBG))
{
Image itemIcon;
using (var bmpTemp = new Bitmap(cubeBG))
{
itemIcon = new Bitmap(bmpTemp);
}
Image opacityImage = ImageUtilities.SetImageOpacity(itemIcon, (float)0.6);
toDrawOn.DrawImage(ImageUtilities.ResizeImage(opacityImage, 512, 512), new Point(5, 5));
}
}
else
{
DrawRarityBackground(theItem, toDrawOn);

View File

@ -1,3 +1,5 @@
using FModel.Methods.Serializer.LocRes;
using FModel.Properties;
using System.Collections.Generic;
namespace FModel
@ -8,13 +10,20 @@ namespace FModel
{
try
{
if (string.IsNullOrEmpty(theNamespace))
if (HotfixedStrings.HotfixedStringsDict != null && HotfixedStrings.HotfixedStringsDict.ContainsKey(theKey))
{
return LocResSerializer.LocResDict[theKey];
return HotfixedStrings.HotfixedStringsDict[theKey][GetLanguageCode()];
}
else
{
return LocResSerializer.LocResDict[theNamespace][theKey];
if (string.IsNullOrEmpty(theNamespace))
{
return LocResSerializer.LocResDict[theKey];
}
else
{
return LocResSerializer.LocResDict[theNamespace][theKey];
}
}
}
catch (KeyNotFoundException)
@ -26,7 +35,16 @@ namespace FModel
public static string getTextByKey(string key, string defaultText, string namespac = null)
{
if (Properties.Settings.Default.IconLanguage.Equals("English"))
return defaultText;
{
if (HotfixedStrings.HotfixedStringsDict != null && HotfixedStrings.HotfixedStringsDict.ContainsKey(key))
{
return HotfixedStrings.HotfixedStringsDict[key][GetLanguageCode()];
}
else
{
return defaultText;
}
}
string text = defaultText;
if (LocResSerializer.LocResDict != null)
@ -38,5 +56,42 @@ namespace FModel
return text;
}
private static string GetLanguageCode()
{
switch (Settings.Default.IconLanguage)
{
case "French":
return "fr";
case "German":
return "de";
case "Italian":
return "it";
case "Spanish":
return "es";
case "Spanish (LA)":
return "es-419";
case "Arabic":
return "ar";
case "Japanese":
return "ja";
case "Korean":
return "ko";
case "Polish":
return "pl";
case "Portuguese (Brazil)":
return "pt-BR";
case "Russian":
return "ru";
case "Turkish":
return "tr";
case "Chinese (S)":
return "zh-CN";
case "Traditional Chinese":
return "zh-Hant";
default:
return "en";
}
}
}
}

View File

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
namespace FModel.Methods.Serializer.LocRes
{
class HotfixedStrings
{
public static Dictionary<string, dynamic> HotfixedStringsDict { get; set; }
public static void setHotfixedStrings()
{
string pdd = Path.GetFullPath(Path.Combine(Properties.Settings.Default.PAKsPath, @"..\..\PersistentDownloadDir\EMS\"));
if (File.Exists(pdd + "a22d837b6a2b46349421259c0a5411bf"))
{
HotfixedStringsDict = new Dictionary<string, dynamic>();
using (StreamReader sr = new StreamReader(File.Open(pdd + "a22d837b6a2b46349421259c0a5411bf", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
{
while (!sr.EndOfStream)
{
string line = sr.ReadLine();
if (line.StartsWith("+TextReplacements=(Category=Game,"))
{
string txtNamespace = GetValueFromParam(line, "Namespace=\"", "\",");
string txtKey = GetValueFromParam(line, "Key=\"", "\",");
int trIndex = line.IndexOf("LocalizedStrings=(") + "LocalizedStrings=(".Length;
string translations = GetValueFromParam(line, "LocalizedStrings=(", "))");
if (!translations.EndsWith(")")) { translations = translations + ")"; }
HotfixedStringsDict[txtKey] = new Dictionary<string, string>();
HotfixedStringsDict[txtKey]["namespace"] = txtNamespace;
Regex regex = new Regex(@"(?<=\().+?(?=\))");
foreach (Match match in regex.Matches(translations))
{
try
{
string[] langParts = match.Value.Substring(1, match.Value.Length - 2).Split(new string[] { "\",\"" }, StringSplitOptions.None);
HotfixedStringsDict[txtKey][langParts[0]] = langParts[1];
}
catch (IndexOutOfRangeException)
{
string[] langParts = match.Value.Substring(1, match.Value.Length - 2).Split(new string[] { "\", \"" }, StringSplitOptions.None);
HotfixedStringsDict[txtKey][langParts[0]] = langParts[1];
}
}
}
}
}
}
}
private static string GetValueFromParam(string fullLine, string startWith, string endWith)
{
int startIndex = fullLine.IndexOf(startWith) + startWith.Length;
int endIndex = fullLine.Substring(startIndex).IndexOf(endWith);
return fullLine.Substring(startIndex, endIndex);
}
}
}

View File

@ -1,6 +1,4 @@
using Newtonsoft.Json;
using System;
using System.Collections;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

View File

@ -33,7 +33,7 @@ using System.Runtime.InteropServices;
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
// en utilisant '*', comme indiqué ci-dessous :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.4.5.1")]
[assembly: AssemblyFileVersion("2.4.5.1")]
[assembly: AssemblyVersion("2.4.5.2")]
[assembly: AssemblyFileVersion("2.4.5.2")]
[assembly: NeutralResourcesLanguage("en")]

View File

@ -6,5 +6,4 @@
<package id="jacobslusser.ScintillaNET" version="3.6.3" targetFramework="net471" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net471" />
<package id="RestSharp" version="106.6.10" targetFramework="net471" />
<package id="TweetMoaSharp" version="6.0.0" targetFramework="net471" />
</packages>

View File

@ -1,7 +1,7 @@
# FModel
[![](https://img.shields.io/github/downloads/iAmAsval/FModel/total.svg?color=green&label=Total%20Downloads&logo=buzzfeed&logoColor=white)](https://github.com/iAmAsval/FModel/releases)
[![](https://img.shields.io/github/downloads/iAmAsval/FModel/latest/total.svg?label=2.4.5.1&logo=buzzfeed&logoColor=white)](https://github.com/iAmAsval/FModel//releases/latest)
[![](https://img.shields.io/github/downloads/iAmAsval/FModel/latest/total.svg?label=2.4.5.2&logo=buzzfeed&logoColor=white)](https://github.com/iAmAsval/FModel//releases/latest)
[![](https://img.shields.io/badge/License-GPL-blue.svg?logo=gnu)](https://github.com/iAmAsval/FModel/blob/master/LICENSE)
[![](https://img.shields.io/badge/Twitter-@AsvalFN-1da1f2.svg?logo=twitter)](https://twitter.com/AsvalFN)
[![](https://img.shields.io/badge/Discord-Need%20Help%3F-7289da.svg?logo=discord)](https://discord.gg/JmWvXKb)
@ -12,7 +12,7 @@
### Prerequisites
[.NET Framework 4.7.1](https://dotnet.microsoft.com/download/dotnet-framework/net471)
### Download
[![](https://img.shields.io/badge/Release-2.4.5.1-orange.svg?logo=github)](https://github.com/iAmAsval/FModel/releases/latest)
[![](https://img.shields.io/badge/Release-2.4.5.2-orange.svg?logo=github)](https://github.com/iAmAsval/FModel/releases/latest)
### How To Use
><p align="center"><a href="https://www.youtube.com/watch?v=rWlux5vg9Xs">Video Tutorial by FireMonkey</a></p>