i stg if this does not work i am throwing hands

This commit is contained in:
NicoAICP 2022-02-10 22:34:01 +01:00
parent 087b2c0b53
commit 320d0e9228
3 changed files with 27 additions and 11 deletions

View file

@ -23,7 +23,9 @@ using System.Xml;
using UWUVCI_AIO_WPF.Classes;
using UWUVCI_AIO_WPF.Properties;
using UWUVCI_AIO_WPF.UI.Windows;
using Newtonsoft.Json;
using MessageBox = System.Windows.MessageBox;
using Newtonsoft.Json.Linq;
namespace UWUVCI_AIO_WPF
{
@ -2164,32 +2166,42 @@ namespace UWUVCI_AIO_WPF
File.Delete(Directory.GetCurrentDirectory() + @"\mod_alldata.bin");
}
catch { }
var packer = new MArchivePacker(new ZlibCodec(), "MX8wgGEJ2+M47", 80);
AllDataPacker.UnpackFiles(allDataPath, "psbout", packer);
string json = "";
var lastModDirect = new DirectoryInfo("psbout").GetDirectories().OrderByDescending(d => d.LastWriteTimeUtc).LastOrDefault();
packer.DecompressFile(Directory.GetCurrentDirectory() + @"\psbout\" + lastModDirect + @"\config\title_prof.psb.m");
using (FileStream fs = File.OpenRead(Directory.GetCurrentDirectory() + @"\psbout\" + lastModDirect + @"\config\title_prof.psb"))
{
using (PsbReader psbReader = new PsbReader(fs))
{
json = psbReader.Root.ToString();
json = json.Replace("\"brightness\": 0.75,", "\"brightness\": 1,");
string json = psbReader.Root.ToString();
dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
jsonObj["root"]["m2epi"]["brightness"] = 1;
//string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented);
//File.WriteAllText("settings.json", output);
using (Stream fs2 = File.Create(Directory.GetCurrentDirectory() + @"\psbout\" + lastModDirect + @"\config\title_prof2.psb"))
{
PsbWriter psbWriter = new PsbWriter(jsonObj, null) { Version = 4 };
psbWriter.Write(fs2);
fs2.Close();
}
psbReader.Close();
}
fs.Close();
}
using (Stream fs = File.Create(Directory.GetCurrentDirectory() + @"\psbout\" + lastModDirect + @"\config\title_prof2.psb"))
{
var s = Newtonsoft.Json.JsonConvert.SerializeObject(json);
PsbWriter psbWriter = new PsbWriter(s, null) { Version = 4 };
psbWriter.Write(fs);
using (FileStream fs = File.OpenRead(Directory.GetCurrentDirectory() + @"\psbout\" + lastModDirect + @"\config\title_prof2.psb"))
{
using (PsbReader psbReader = new PsbReader(fs))
{
psbReader.Close();
}
fs.Close();
}
packer.CompressFile(Directory.GetCurrentDirectory() + @"\psbout\" + lastModDirect + @"\config\title_prof2.psb");
File.Move(Directory.GetCurrentDirectory() + @"\psbout\" + lastModDirect + @"\config\title_prof2.psb.m", Directory.GetCurrentDirectory() + @"\psbout\" + lastModDirect + @"\config\title_prof.psb.m");
var outputAllDataPath = Path.Combine(baseRomPath, "content", "alldata.psb.m");

View file

@ -82,6 +82,9 @@
<Reference Include="ICSharpCode.SharpZipLib, Version=1.2.0.246, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
<HintPath>..\packages\SharpZipLib.1.2.0\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
</Reference>
<Reference Include="Json.Net, Version=1.0.33.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Json.Net.1.0.33\lib\netstandard2.0\Json.Net.dll</HintPath>
</Reference>
<Reference Include="MaterialDesignColors, Version=1.2.7.1979, Culture=neutral, PublicKeyToken=df2a72020bd7962a, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignColors.1.2.7\lib\net45\MaterialDesignColors.dll</HintPath>
</Reference>

View file

@ -4,6 +4,7 @@
<package id="Costura.Fody" version="4.1.0" targetFramework="net46" />
<package id="Fody" version="6.3.0" targetFramework="net46" developmentDependency="true" />
<package id="GMWare.M2" version="1.1.2" targetFramework="net48" />
<package id="Json.Net" version="1.0.33" targetFramework="net472" />
<package id="MaterialDesignColors" version="1.2.7" targetFramework="net46" />
<package id="MaterialDesignThemes" version="2.6.0" targetFramework="net472" />
<package id="McMaster.Extensions.CommandLineUtils" version="2.4.2" targetFramework="net48" />