1.1.2 - Renamed JSON.settings to JSON.Settings + Minor tweaks

This commit is contained in:
mikx 2024-12-29 12:45:09 -05:00
parent 8038d18d23
commit 807fb8d06c
5 changed files with 21 additions and 17 deletions

View File

@ -14,7 +14,7 @@ namespace MxFilterGen2.DB
MySqlConnection conn;
string myConnectionString;
myConnectionString = $"server={JSON.settings.GetdbHost()};port={JSON.settings.GetdbPort()};uid={JSON.settings.GetdbUser()};pwd={JSON.settings.GetdbPass()};database={JSON.settings.GetdbName()};";
myConnectionString = $"server={JSON.Settings.GetdbHost()};port={JSON.Settings.GetdbPort()};uid={JSON.Settings.GetdbUser()};pwd={JSON.Settings.GetdbPass()};database={JSON.Settings.GetdbName()};";
conn = new MySqlConnection();
conn.ConnectionString = myConnectionString;
return conn;

View File

@ -11,14 +11,14 @@ namespace MxFilterGen2.IO
{
public static void CleanOut()
{
foreach (string f in JSON.settings.GetType())
foreach (string f in JSON.Settings.GetType())
{
String[] files = Directory.GetFiles($"out/{f}", "*.*");
foreach (String file in files)
{
File.Delete(file);
}
File.Delete($"out/{JSON.settings.GetName()}_{f}.filter");
File.Delete($"out/{JSON.Settings.GetName()}_{f}.filter");
}
var gens = Directory.GetFiles("out/Gen");
foreach (var g in gens)

View File

@ -14,7 +14,8 @@ namespace MxFilterGen2.IO
Message.CMW($"Checking and creating the base directories...", true, 2);
if (!Directory.Exists($"filson")) { Directory.CreateDirectory($"filson"); }
if (!Directory.Exists($"out")) { Directory.CreateDirectory($"out"); }
foreach (string f in JSON.settings.GetType())
if (!Directory.Exists($"out/Gen")) { Directory.CreateDirectory($"out/Gen"); }
foreach (string f in JSON.Settings.GetType())
{
if (!Directory.Exists($"out/{f}")) { Directory.CreateDirectory($"out/{f}"); }
}

View File

@ -23,7 +23,7 @@ namespace MxFilterGen2.JSON
}
class settings
class Settings
{
public static string GetdbHost() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("settings.json")).dbHost;
public static string GetdbPort() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("settings.json")).dbPort;

View File

@ -3,26 +3,27 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace MxFilterGen2
{
internal class Program
{
public static string version = "1.1.1";
public static string version = "1.1.2";
public static string docpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
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())
string fname = JSON.Settings.GetName();
foreach (string s in JSON.Settings.GetStructure())
{
if (s != "GEN")
{
Message.CMW($"Section: {s}", true, 2);
foreach (string f in JSON.settings.GetType())
foreach (string f in JSON.Settings.GetType())
{
Compiler.section.Compile(s, f);
}
@ -47,13 +48,13 @@ namespace MxFilterGen2
string genstring = "";
foreach (var g in gens)
{
foreach (string f in JSON.settings.GetType())
foreach (string f in JSON.Settings.GetType())
{
File.AppendAllText($"out/{f}/GEN.filter",File.ReadAllText(g));
}
}
foreach (string f in JSON.settings.GetType())
foreach (string f in JSON.Settings.GetType())
{
Message.CMW($"Creating the {f} filter...", true, 2);
string outp = "out/" + fname + "_" + f + ".filter";
@ -65,12 +66,12 @@ namespace MxFilterGen2
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())
foreach (var sspl in JSON.Settings.GetStructure())
{
File.AppendAllText(outp, $"# {sspl}{Environment.NewLine}");
}
File.AppendAllText(outp, $"{Environment.NewLine}");
foreach (var structure in JSON.settings.GetStructure())
foreach (var structure in JSON.Settings.GetStructure())
{
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")));
@ -78,12 +79,12 @@ namespace MxFilterGen2
}
}
if (JSON.settings.GetInstall())
if (JSON.Settings.GetInstall())
{
Message.CMW($"Install is \"True\". Installing to the game directory...", true, 1);
foreach (string f in JSON.settings.GetType())
foreach (string f in JSON.Settings.GetType())
{
File.Copy($"out/{JSON.settings.GetName()}_{f}.filter", $@"{docpath}\My Games\Path of Exile 2\{JSON.settings.GetName()}_{f}.filter", true);
File.Copy($"out/{JSON.Settings.GetName()}_{f}.filter", $@"{docpath}\My Games\Path of Exile 2\{JSON.Settings.GetName()}_{f}.filter", true);
}
foreach (var s in Directory.EnumerateFiles("sound"))
{
@ -92,9 +93,11 @@ namespace MxFilterGen2
}
} else
{
int fc = JSON.settings.GetType().Count;
int fc = JSON.Settings.GetType().Count;
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);
}
}
}