mirror of
https://github.com/4sval/FModel.git
synced 2026-09-25 02:29:21 -05:00
keys from last session are stored for the aes manager
This commit is contained in:
56
FModel/Methods/AESManager/AESManager.cs
Normal file
56
FModel/Methods/AESManager/AESManager.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
{
|
||||
switch (selectedLanguage)
|
||||
{
|
||||
case "English":
|
||||
myLocRes = getMyLocRes("en");
|
||||
break;
|
||||
case "French":
|
||||
myLocRes = getMyLocRes("fr");
|
||||
break;
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user