-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
4,665 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.