keys from last session are stored for the aes manager

This commit is contained in:
Asval
2019-06-12 01:37:03 +02:00
parent 77547e33d8
commit e171b3772a
10 changed files with 177 additions and 77 deletions

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Xml.Serialization;
namespace FModel
{
static class AESManager
{
public static List<AESEntry> AESEntries { get; set; }
private static XmlSerializer serializer = new XmlSerializer(typeof(List<AESEntry>));
public static void serialize(string data)
{
ConfigurationUserLevel level = ConfigurationUserLevel.PerUserRoamingAndLocal;
Configuration configuration = ConfigurationManager.OpenExeConfiguration(level);
string configurationFilePath = configuration.FilePath.Substring(0, configuration.FilePath.LastIndexOf("\\"));
AESEntries.Add(new AESEntry()
{
theKey = data
});
string path = configurationFilePath + "\\AESManager.xml";
Directory.CreateDirectory(Path.GetDirectoryName(path));
using (var fileStream = new FileStream(path, FileMode.Create))
{
serializer.Serialize(fileStream, AESEntries);
}
}
public static string[] deserialize()
{
ConfigurationUserLevel level = ConfigurationUserLevel.PerUserRoamingAndLocal;
Configuration configuration = ConfigurationManager.OpenExeConfiguration(level);
string configurationFilePath = configuration.FilePath.Substring(0, configuration.FilePath.LastIndexOf("\\"));
string path = configurationFilePath + "\\AESManager.xml";
List<AESEntry> outputList;
using (var fileStream = new FileStream(path, FileMode.Open))
{
outputList = (List<AESEntry>)serializer.Deserialize(fileStream);
}
string[] toReturn = new string[outputList.Count];
for (int i = 0; i < toReturn.Length; i++)
{
toReturn[i] = outputList[i].theKey;
}
return toReturn;
}
}
}

View File

@@ -4,6 +4,7 @@ using FModel.Parser.Items;
using FModel.Properties;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
@@ -21,7 +22,7 @@ namespace FModel
/// <param name="featured"></param>
public static void GetItemIcon(ItemsIdParser theItem, bool featured = false)
{
if (featured == false)
if (!featured)
{
Checking.WasFeatured = false;
SearchAthIteDefIcon(theItem);
@@ -207,11 +208,11 @@ namespace FModel
/// <param name="catName"></param>
private static void GetFeaturedItemIcon(ItemsIdParser theItem, string catName)
{
if (ThePak.AllpaksDictionary.ContainsKey(catName))
{
ThePak.CurrentUsedItem = catName;
ThePak.CurrentUsedItem = catName;
string catalogFilePath;
string catalogFilePath;
try
{
if (ThePak.CurrentUsedPakGuid != null && ThePak.CurrentUsedPakGuid != "0-0-0-0")
{
catalogFilePath = JohnWick.ExtractAsset(ThePak.CurrentUsedPak, catName);
@@ -263,7 +264,10 @@ namespace FModel
}
}
}
else { GetItemIcon(theItem); }
catch (KeyNotFoundException)
{
GetItemIcon(theItem);
}
}
/// <summary>

View File

@@ -8,9 +8,6 @@
{
switch (selectedLanguage)
{
case "English":
myLocRes = getMyLocRes("en");
break;
case "French":
myLocRes = getMyLocRes("fr");
break;

View File

@@ -22,7 +22,7 @@ namespace FModel
byte[] bytes = File.ReadAllBytes(filepath);
string pattern = @"^[a-zA-Z0-9 ]+$";
string pattern = @"^[a-zA-Z0-9()'\-.&!+, ]";
Regex regex = new Regex(pattern);
foreach (byte b in bytes) // Iterate throught all the bytes of the file
@@ -42,7 +42,7 @@ namespace FModel
bool found = false;
foreach (string str in weirdStrings)
{
if (str.Length > 2)
if (str.Length >= 2)
{
if (found) { myNamespacesList.Add(str); break; }
@@ -55,11 +55,14 @@ namespace FModel
|| str == "Glider"
|| str == "Contrail"
|| str == "Emote"
|| str == "Emoticon"
|| str == "Toy"
|| str == "Music")
{
int index = listBeforeData.IndexOf(str);
//Console.WriteLine("DName: " + listBeforeData[index - 3]);
myNamespacesList.Add(listBeforeData[index - 3]);
myNamespacesList.Add(listBeforeData[index - 1]);

View File

@@ -84,4 +84,18 @@ namespace FModel
throw new NotImplementedException();
}
}
public struct AESEntry : IEquatable<AESEntry>
{
internal AESEntry(string myKey)
{
theKey = myKey;
}
public string theKey { get; set; }
bool IEquatable<AESEntry>.Equals(AESEntry other)
{
throw new NotImplementedException();
}
}
}