Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nifyr committed Aug 1, 2022
1 parent 9b0567c commit 5b94a5e
Show file tree
Hide file tree
Showing 5 changed files with 4,665 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# CS8765: Nullability of type of parameter doesn't match overridden member (possibly because of nullability attributes).
dotnet_diagnostic.CS8765.severity = silent
66 changes: 66 additions & 0 deletions Wwise Bank Converter/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Newtonsoft.Json;

namespace WwiseBankConverter
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{

OpenFileDialog ofd = new()
{
Filter = "Wwise Bank(*.bnk;*.json)|*.bnk;*.json",
RestoreDirectory = true
};

if (ofd.ShowDialog() != DialogResult.OK) return;

string outputDir = Environment.CurrentDirectory + "\\Output";

if (Path.GetExtension(ofd.FileName) == ".bnk")
{
try
{
string destFileName = outputDir + "\\" + Path.GetFileNameWithoutExtension(ofd.FileName) + ".json";
Wwise.WwiseData wd = new(File.ReadAllBytes(ofd.FileName));
string json = JsonConvert.SerializeObject(wd.banks[0], Formatting.Indented);
Directory.CreateDirectory(outputDir);
File.WriteAllText(destFileName, json);
MessageBox.Show("Json placed in Output folder.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else if (Path.GetExtension(ofd.FileName) == ".json")
{
try
{
string destFileName = outputDir + "\\" + Path.GetFileNameWithoutExtension(ofd.FileName) + ".bnk";
string json = File.ReadAllText(ofd.FileName);
Wwise.WwiseData wd = new()
{
banks = new()
};
Wwise.Bank? b = JsonConvert.DeserializeObject<Wwise.Bank>(json);
if (b == null)
throw new ArgumentException();
wd.banks.Add(b);
Directory.CreateDirectory(outputDir);
FileStream fs = File.OpenWrite(destFileName);
fs.Write(wd.GetBytes());
MessageBox.Show("Wwise bank placed in Output folder.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}
Loading

0 comments on commit 5b94a5e

Please sign in to comment.