PoE2-MxFilterGen2/MxFilterGen2/Program.cs

104 lines
4.6 KiB
C#
Raw Permalink Normal View History

2024-12-23 18:42:50 -05:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
2024-12-23 18:42:50 -05:00
using System.Threading.Tasks;
namespace MxFilterGen2
{
internal class Program
{
public static string version = "1.1.2";
2024-12-27 17:05:41 -05:00
public static string docpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
2024-12-23 18:42:50 -05:00
static void Main(string[] args)
{
Message.Splash("MxFilterGen2", "mikx");
IO.Cleaner.CleanOut();
IO.Creator.CreateBaseDir();
string fname = JSON.Settings.GetName();
foreach (string s in JSON.Settings.GetStructure())
2024-12-23 18:42:50 -05:00
{
2024-12-27 17:05:41 -05:00
if (s != "GEN")
{
Message.CMW($"Section: {s}", true, 2);
foreach (string f in JSON.Settings.GetType())
2024-12-27 17:05:41 -05:00
{
Compiler.section.Compile(s, f);
}
}
}
Generator.Body.Gen();
Generator.Boots.Gen();
Generator.Bows.Gen();
Generator.Claws.Gen();
Generator.Daggers.Gen();
Generator.Focus.Gen();
Generator.Gloves.Gen();
Generator.Helmets.Gen();
Generator.OneHander.Gen();
Generator.Shields.Gen();
Generator.Staves.Gen();
Generator.TwoHander.Gen();
Generator.Wands.Gen();
var gens = Directory.GetFiles("out/Gen");
string genstring = "";
foreach (var g in gens)
{
foreach (string f in JSON.Settings.GetType())
2024-12-23 18:42:50 -05:00
{
2024-12-27 17:05:41 -05:00
File.AppendAllText($"out/{f}/GEN.filter",File.ReadAllText(g));
2024-12-23 18:42:50 -05:00
}
}
foreach (string f in JSON.Settings.GetType())
2024-12-23 18:42:50 -05:00
{
Message.CMW($"Creating the {f} filter...", true, 2);
string outp = "out/" + fname + "_" + f + ".filter";
////////// Splash //////////
File.AppendAllText(outp, $"#### Filson - PoE2 Item Filter JSON Parsing - MxFilterGen2 v{Program.version}{Environment.NewLine}");
File.AppendAllText(outp, $"#### Filson and MxFilterGen2 are developped by mikx.{Environment.NewLine}");
File.AppendAllText(outp, $"#### MxGit: https://mxgit.ovh/mikx/PoE2-MxFilterGen2{Environment.NewLine}");
2024-12-23 18:42:50 -05:00
File.AppendAllText(outp, $"#### MxPoE: https://mxpoe.ovh/{Environment.NewLine}");
File.AppendAllText(outp, $"#### Contact: mikx@mxpoe.ovh / http://discord.mxg.ovh{Environment.NewLine}");
File.AppendAllText(outp, $"{Environment.NewLine}");
File.AppendAllText(outp, $"#### SECTIONS{Environment.NewLine}");
foreach (var sspl in JSON.Settings.GetStructure())
2024-12-23 18:42:50 -05:00
{
File.AppendAllText(outp, $"# {sspl}{Environment.NewLine}");
}
2024-12-27 17:05:41 -05:00
File.AppendAllText(outp, $"{Environment.NewLine}");
foreach (var structure in JSON.Settings.GetStructure())
2024-12-27 17:05:41 -05:00
{
2024-12-23 18:42:50 -05:00
File.AppendAllText("out/" + fname + "_" + f + ".filter", string.Format("#### SECTION: {0}", (object)structure) + Environment.NewLine);
File.AppendAllText("out/" + fname + "_" + f + ".filter", File.ReadAllText(string.Format("out/" + f + "/" + structure + ".filter")));
File.AppendAllText("out/" + fname + "_" + f + ".filter", Environment.NewLine ?? "");
}
}
2024-12-27 17:05:41 -05:00
if (JSON.Settings.GetInstall())
2024-12-27 17:05:41 -05:00
{
Message.CMW($"Install is \"True\". Installing to the game directory...", true, 1);
foreach (string f in JSON.Settings.GetType())
2024-12-27 17:05:41 -05:00
{
File.Copy($"out/{JSON.Settings.GetName()}_{f}.filter", $@"{docpath}\My Games\Path of Exile 2\{JSON.Settings.GetName()}_{f}.filter", true);
2024-12-27 17:05:41 -05:00
}
foreach (var s in Directory.EnumerateFiles("sound"))
{
string sf = Path.GetFileName(s);
File.Copy($"{s}", $@"{docpath}\My Games\Path of Exile 2\{sf}", true);
}
} else
{
int fc = JSON.Settings.GetType().Count;
2024-12-27 17:05:41 -05:00
Message.CMW($"Install is \"False\". Use the {fc} Filter(s) from the \"out\" directory.", true, 1);
}
Message.CMW($"Waiting 5 seconds before exiting...", true, 1);
Thread.Sleep(5000);
2024-12-23 18:42:50 -05:00
}
}
}