5.0.0 - Custom Sounds

This commit is contained in:
mikx 2018-12-22 23:04:30 -05:00
parent 5fb7a3436a
commit 55fe83c714
7 changed files with 157 additions and 112 deletions

Binary file not shown.

View File

@ -12,7 +12,6 @@ namespace PoE_MxFilterGen.json
{
public string git { get; set; }
public string api { get; set; }
public string league { get; set; }
public int confidence { get; set; }
public int minimumValue { get; set; }
public int chancingMinValue { get; set; }
@ -35,12 +34,6 @@ namespace PoE_MxFilterGen.json
return j.api;
}
public static string GetLeague()
{
SETTINGS j = JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("settings.json"));
return j.league;
}
public static int GetConfidence()
{
SETTINGS j = JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("settings.json"));
@ -84,7 +77,6 @@ namespace PoE_MxFilterGen.json
{
git = js.git,
api = js.api,
league = js.league,
confidence = js.confidence,
minimumValue = js.minimumValue,
chancingMinValue = js.chancingMinValue,

View File

@ -1,6 +1,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
@ -8,6 +9,7 @@ using System.Security.Cryptography;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using static System.Net.Mime.MediaTypeNames;
namespace PoE_MxFilterGen
{
@ -15,13 +17,25 @@ namespace PoE_MxFilterGen
{
private static DateTime dt = DateTime.Now;
public static string version = "4.3.0";
public static string version = "5.0.0";
public static string fDate = string.Format("{0}-{1}-{2}", dt.Day, dt.Month, dt.Year);
public static string section = "";
public static string league = "";
public static string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
private static string giturl = json.settings.GetGIT();
public class REMVAR
{
public string league { get; set; }
}
public class REMSND
{
public List<string> sound { get; set; }
}
public class STRUCTURE
{
public string section { get; set; }
@ -39,129 +53,158 @@ namespace PoE_MxFilterGen
static void Main(string[] args)
{
msg.Splash();
// Get current league from MxD
var ls = web.ReadString("https://data.mxnet.xyz/poe/json/mxfiltergen_var.json");
REMVAR lj = JsonConvert.DeserializeObject<REMVAR>(ls);
league = lj.league;
msg.CMW(league, true, 1);
msg.CMW(string.Format("GIT: {0}", json.settings.GetGIT()), true, 1);
msg.CMW(string.Format("API: {0}", json.settings.GetAPI()), true, 1);
msg.CMW(string.Format("League: {0}", json.settings.GetLeague()), true, 1);
msg.CMW(string.Format("League: {0}", league), true, 1);
msg.CMW(string.Format("Confidence: {0}", json.settings.GetConfidence().ToString()), true, 1);
msg.CMW(string.Format("Minimum Value: {0}c", json.settings.GetMinimumValue().ToString()), true, 1);
msg.CMW(string.Format("Chancing Min. Value: {0}c", json.settings.GetChancingMinValue().ToString()), true, 1);
msg.CMW(string.Format("Verbose: {0}", json.settings.GetVerbose().ToString()), true, 1);
msg.CMW(string.Format("Strict: {0}", json.settings.GetStrict().ToString()), true, 1);
// Check if all the required dir exists
if (!Directory.Exists(@"data\"))
// Check for updates
string remote_version = web.ReadString(@"https://data.mxnet.xyz/poe/txt/mxfiltergen_version.txt");
if (version != remote_version)
{
Process.Start("PoE-MxFilterGen-Updater.exe");
//Process.GetCurrentProcess().Kill();
} else
{
Directory.CreateDirectory(@"data\");
}
if (!Directory.Exists(@"gen\"))
{
Directory.CreateDirectory(@"gen\");
}
if (!Directory.Exists(@"filter\"))
{
Directory.CreateDirectory(@"filter\");
}
if (!Directory.Exists(@"structure\"))
{
Directory.CreateDirectory(@"structure\");
}
// Clean all generated data
DirectoryInfo dataDir = new DirectoryInfo(@"data\");
DirectoryInfo genDir = new DirectoryInfo(@"gen\");
DirectoryInfo filterDir = new DirectoryInfo(@"filter\");
DirectoryInfo strucDir = new DirectoryInfo(@"structure\");
foreach (FileInfo file in dataDir.GetFiles())
{
file.Delete();
}
foreach (FileInfo file in genDir.GetFiles())
{
file.Delete();
}
foreach (FileInfo file in filterDir.GetFiles())
{
file.Delete();
}
foreach (FileInfo file in strucDir.GetFiles())
{
file.Delete();
}
// Get latest poe.ninja api
web.SaveString(json.settings.GetAPI() + "GetUniqueArmourOverview?league=" + json.settings.GetLeague(), "data/ninja.armour.json");
web.SaveString(json.settings.GetAPI() + "GetUniqueWeaponOverview?league=" + json.settings.GetLeague(), "data/ninja.weapon.json");
web.SaveString(json.settings.GetAPI() + "GetUniqueAccessoryOverview?league=" + json.settings.GetLeague(), "data/ninja.accessory.json");
web.SaveString(json.settings.GetAPI() + "GetUniqueMapOverview?league=" + json.settings.GetLeague(), "data/ninja.map.json");
web.SaveString(json.settings.GetAPI() + "GetDivinationCardsOverview?league=" + json.settings.GetLeague(), "data/ninja.card.json");
// Setup basic variable
string structure_name = $"{json.settings.GetLeague()}";
string filter_name = "MxFilter";
// Get the structure list
var js = web.ReadString($@"{giturl}/PoE-MxFilter-Structure/master/{structure_name}.json");
RootStructure j = JsonConvert.DeserializeObject<RootStructure>(js);
// Read the structure one by one to process gen
// Generator (dlls) are downloaded from the web and executed in a separate AppDomain before the AD is unloaded to execute a new generator.
// As we CAN'T unload an assembly, using AppDomains is the only way we can load/unload multiple assembly in a row.
foreach (var sec in j.structures)
{
if (sec.gen == true)
// Check if all the required dir exists
msg.CMW($"Checking for required dirs...",true,1);
if (!Directory.Exists(@"data\"))
{
msg.CMW(string.Format("REMOTE_GEN {0}", sec.section), true, 1);
web.DownloadFile($@"{giturl}/PoE-MxFilter-Structure/master/{structure_name}/{sec.section}.dll", $@"structure\{sec.section}.dll");
json.settings.WriteSection(sec.section);
var bytes = GenerateAssemblyAndGetRawBytes(sec.section);
Directory.CreateDirectory(@"data\");
}
if (!Directory.Exists(@"gen\"))
{
Directory.CreateDirectory(@"gen\");
}
if (!Directory.Exists(@"structure\"))
{
Directory.CreateDirectory(@"structure\");
}
var appDomain = AppDomain.CreateDomain(sec.section, null, new AppDomainSetup
// Clean all generated data
msg.CMW($"Cleaning the base dirs...", true, 1);
DirectoryInfo dataDir = new DirectoryInfo(@"data\");
DirectoryInfo genDir = new DirectoryInfo(@"gen\");
DirectoryInfo strucDir = new DirectoryInfo(@"structure\");
foreach (FileInfo file in dataDir.GetFiles())
{
file.Delete();
}
foreach (FileInfo file in genDir.GetFiles())
{
file.Delete();
}
foreach (FileInfo file in strucDir.GetFiles())
{
file.Delete();
}
// Clean the latest generated filter from settings path
msg.CMW($"Cleaning the last filter from path...", true, 1);
File.Delete($@"{path}\My Games\Path of Exile\MxFilter.filter");
// Get latest poe.ninja api
msg.CMW($"Downloading the latest API data from poe.ninja...", true, 1);
web.SaveString(json.settings.GetAPI() + "GetUniqueArmourOverview?league=" + league, "data/ninja.armour.json");
web.SaveString(json.settings.GetAPI() + "GetUniqueWeaponOverview?league=" + league, "data/ninja.weapon.json");
web.SaveString(json.settings.GetAPI() + "GetUniqueAccessoryOverview?league=" + league, "data/ninja.accessory.json");
web.SaveString(json.settings.GetAPI() + "GetUniqueMapOverview?league=" + league, "data/ninja.map.json");
web.SaveString(json.settings.GetAPI() + "GetDivinationCardsOverview?league=" + league, "data/ninja.card.json");
// Setup basic variable
string structure_name = $"{league}";
string filter_name = "MxFilter";
// Get the structure list
var js = web.ReadString($@"{giturl}/PoE-MxFilter-Structure/master/{structure_name}.json");
RootStructure j = JsonConvert.DeserializeObject<RootStructure>(js);
// Get Theme File(s)
web.DownloadFile($@"{giturl}/PoE-MxFilter-Structure/master/{structure_name}/Chancing.json", @"structure\Chancing.json");
// Read the structure one by one to process gen
// Generator (dlls) are downloaded from the web and executed in a separate AppDomain before the AD is unloaded to execute a new generator.
// As we CAN'T unload an assembly, using AppDomains is the only way we can load/unload multiple assembly in a row.
msg.CMW($@"Generating the filter using {j.structures.Count} data...", true, 1);
foreach (var sec in j.structures)
{
if (sec.gen == true)
{
ShadowCopyFiles = "true",
LoaderOptimization = LoaderOptimization.MultiDomainHost
});
//msg.CMW(string.Format("REMOTE_GEN {0}", sec.section), true, 1);
web.DownloadFile($@"{giturl}/PoE-MxFilter-Structure/master/{structure_name}/{sec.section}.dll", $@"structure\{sec.section}.dll");
json.settings.WriteSection(sec.section);
var bytes = GenerateAssemblyAndGetRawBytes(sec.section);
var assmblyLoaderType = typeof(AssmeblyLoader);
var assemblyLoader = (IAssemblyLoader)appDomain.CreateInstanceFromAndUnwrap(assmblyLoaderType.Assembly.Location, assmblyLoaderType.FullName);
assemblyLoader.Load(bytes);
var appDomain = AppDomain.CreateDomain(sec.section, null, new AppDomainSetup
{
ShadowCopyFiles = "true",
LoaderOptimization = LoaderOptimization.MultiDomainHost
});
AppDomain.Unload(appDomain);
var assmblyLoaderType = typeof(AssmeblyLoader);
var assemblyLoader = (IAssemblyLoader)appDomain.CreateInstanceFromAndUnwrap(assmblyLoaderType.Assembly.Location, assmblyLoaderType.FullName);
assemblyLoader.Load(bytes);
AppDomain.Unload(appDomain);
}
else
{
//msg.CMW($@"REMOTE_GET {sec.section}", true, 1);
web.SaveString($@"{giturl}/PoE-MxFilter-Structure/master/{structure_name}/{sec.section}.filter", $"structure/{sec.section}.filter");
}
}
else
// Create the final filter.
msg.CMW($@"Creating the final filter...", true, 1);
foreach (var sec in j.structures)
{
msg.CMW($@"REMOTE_GET {sec.section}", true, 1);
web.SaveString($@"{giturl}/PoE-MxFilter-Structure/master/{structure_name}/{sec.section}.filter", $"structure/{sec.section}.filter");
if (sec.gen == true)
{
File.AppendAllText($@"{path}\My Games\Path of Exile\{filter_name}.filter", File.ReadAllText(string.Format("gen\\{0}.filter", sec.section)));
File.AppendAllText($@"{path}\My Games\Path of Exile\{filter_name}.filter", "" + Environment.NewLine);
File.AppendAllText($@"{path}\My Games\Path of Exile\{filter_name}.filter", "" + Environment.NewLine);
}
else
{
File.AppendAllText($@"{path}\My Games\Path of Exile\{filter_name}.filter", string.Format("# Section: {0}", sec.section) + Environment.NewLine);
File.AppendAllText($@"{path}\My Games\Path of Exile\{filter_name}.filter", "" + Environment.NewLine);
File.AppendAllText($@"{path}\My Games\Path of Exile\{filter_name}.filter", File.ReadAllText(string.Format("structure\\{0}.filter", sec.section)));
File.AppendAllText($@"{path}\My Games\Path of Exile\{filter_name}.filter", "" + Environment.NewLine);
File.AppendAllText($@"{path}\My Games\Path of Exile\{filter_name}.filter", "" + Environment.NewLine);
}
}
}
// Create the final filter.
foreach (var sec in j.structures)
{
if (sec.gen == true)
// Download the sounds from the remote list
msg.CMW($@"Downloading the latest sound...", true, 1);
var sl = web.ReadString("https://data.mxnet.xyz/poe/json/mxfiltergen_sound.json");
REMSND slj = JsonConvert.DeserializeObject<REMSND>(sl);
foreach (string s in slj.sound)
{
File.AppendAllText($@"filter\{filter_name}.filter", File.ReadAllText(string.Format("gen\\{0}.filter", sec.section)));
File.AppendAllText($@"filter\{filter_name}.filter", "" + Environment.NewLine);
File.AppendAllText($@"filter\{filter_name}.filter", "" + Environment.NewLine);
if (File.Exists($@"{path}\My Games\Path of Exile\{s}")) { File.Delete($@"{path}\My Games\Path of Exile\{s}"); }
web.DownloadFile($"https://data.mxnet.xyz/poe/mp3/{s}",$@"{path}\My Games\Path of Exile\{s}");
}
else
{
File.AppendAllText($@"filter\{filter_name}.filter", string.Format("# Section: {0}", sec.section) + Environment.NewLine);
File.AppendAllText($@"filter\{filter_name}.filter", "" + Environment.NewLine);
File.AppendAllText($@"filter\{filter_name}.filter", File.ReadAllText(string.Format("structure\\{0}.filter", sec.section)));
File.AppendAllText($@"filter\{filter_name}.filter", "" + Environment.NewLine);
File.AppendAllText($@"filter\{filter_name}.filter", "" + Environment.NewLine);
}
}
// Clean all generated data
foreach (FileInfo file in genDir.GetFiles())
{
file.Delete();
}
foreach (FileInfo file in strucDir.GetFiles())
{
file.Delete();
}
// Clean all generated data
foreach (FileInfo file in genDir.GetFiles())
{
file.Delete();
}
foreach (FileInfo file in strucDir.GetFiles())
{
file.Delete();
}
}
}
private static byte[] GenerateAssemblyAndGetRawBytes(string dll)
@ -186,7 +229,7 @@ namespace PoE_MxFilterGen
Type type = AppDomain.CurrentDomain.GetAssemblies().SelectMany(t => t.GetTypes()).Where(t => String.Equals(t.Name, "Generator", StringComparison.Ordinal)).First();
object o = Activator.CreateInstance(type);
MethodInfo mi = o.GetType().GetMethod("Gen");
Object[] ob = { json.settings.GetSection(), json.settings.GetAPI(), json.settings.GetLeague(), json.settings.GetMinimumValue(), json.settings.GetChancingMinValue(), json.settings.GetConfidence() };
Object[] ob = { json.settings.GetSection(), json.settings.GetAPI(), main.league, json.settings.GetMinimumValue(), json.settings.GetChancingMinValue(), json.settings.GetConfidence() };
mi.Invoke(o, ob);
}
}

View File

@ -24,3 +24,13 @@ E:\_MxGit\PoE\PoE-MxFilterGen\PoE-MxFilterGen\obj\Debug\PoE-MxFilterGen.csproj.C
E:\_MxGit\PoE\PoE-MxFilterGen\PoE-MxFilterGen\obj\Debug\PoE-MxFilterGen.csproj.CopyComplete
E:\_MxGit\PoE\PoE-MxFilterGen\PoE-MxFilterGen\obj\Debug\mxfiltergen.exe
E:\_MxGit\PoE\PoE-MxFilterGen\PoE-MxFilterGen\obj\Debug\mxfiltergen.pdb
E:\_MxGitHub\PoE-MxFilterGen\PoE-MxFilterGen\bin\Debug\mxfiltergen.exe.config
E:\_MxGitHub\PoE-MxFilterGen\PoE-MxFilterGen\bin\Debug\mxfiltergen.exe
E:\_MxGitHub\PoE-MxFilterGen\PoE-MxFilterGen\bin\Debug\mxfiltergen.pdb
E:\_MxGitHub\PoE-MxFilterGen\PoE-MxFilterGen\bin\Debug\Newtonsoft.Json.dll
E:\_MxGitHub\PoE-MxFilterGen\PoE-MxFilterGen\bin\Debug\Newtonsoft.Json.xml
E:\_MxGitHub\PoE-MxFilterGen\PoE-MxFilterGen\obj\Debug\PoE-MxFilterGen.csproj.CoreCompileInputs.cache
E:\_MxGitHub\PoE-MxFilterGen\PoE-MxFilterGen\obj\Debug\PoE-MxFilterGen.csproj.CopyComplete
E:\_MxGitHub\PoE-MxFilterGen\PoE-MxFilterGen\obj\Debug\mxfiltergen.exe
E:\_MxGitHub\PoE-MxFilterGen\PoE-MxFilterGen\obj\Debug\mxfiltergen.pdb
E:\_MxGitHub\PoE-MxFilterGen\PoE-MxFilterGen\obj\Debug\PoE-MxFilterGen.csprojAssemblyReference.cache