Skip to content

Commit

Permalink
feat: finish up switch generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Notexe committed Mar 10, 2023
1 parent 7a6a8c3 commit 45ed9c5
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 61 deletions.
61 changes: 0 additions & 61 deletions G2WwiseDataTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,67 +23,6 @@ static void Main(string[] args)
else
{
SoundbanksInfoParser.ReadSoundbankInfo(options.inputPath, Path.TrimEndingDirectorySeparator(options.outputPath) + "\\", options.outputToFolderStructure, options.saveEventAndSoundBankPaths, options.verbose);

/*
// Audio Switch Group Tests
// 00E0FF34FC69B603.WSGB
AudioSwitchWriter.SwitchGroup switchGroup = new AudioSwitchWriter.SwitchGroup();
switchGroup.name = "Gameplay_MenuDifficulty";
switchGroup.outputPath = Path.TrimEndingDirectorySeparator(options.outputPath) + "\\00E0FF34FC69B603.WSGB";
switchGroup.switches.Add("None");
switchGroup.switches.Add("Normal");
switchGroup.switches.Add("Pro1");
AudioSwitchWriter.WriteAudioSwitch(ref switchGroup);
// 00BFC6D2506A6FF7.WSGB
AudioSwitchWriter.SwitchGroup switchGroup2 = new AudioSwitchWriter.SwitchGroup();
switchGroup2.name = "StateGroup_Gecko_DX_Grey_Processed";
switchGroup2.outputPath = Path.TrimEndingDirectorySeparator(options.outputPath) + "\\00BFC6D2506A6FF7.WSGB";
switchGroup2.switches.Add("None");
switchGroup2.switches.Add("State_Gecko_DX_Grey_Processed");
switchGroup2.switches.Add("State_Gecko_DX_Grey_Unprocessed");
AudioSwitchWriter.WriteAudioSwitch(ref switchGroup2);
// 0051BE5D114AC863.WSGB
AudioSwitchWriter.SwitchGroup switchGroup3 = new AudioSwitchWriter.SwitchGroup();
switchGroup3.name = "Gameplay_Missionspecific_Mix";
switchGroup3.outputPath = Path.TrimEndingDirectorySeparator(options.outputPath) + "\\0051BE5D114AC863.WSGB";
switchGroup3.switches.Add("Bull");
switchGroup3.switches.Add("Bulldog");
switchGroup3.switches.Add("Copperhead");
switchGroup3.switches.Add("Cornflower");
switchGroup3.switches.Add("Falcon");
switchGroup3.switches.Add("Flamingo");
switchGroup3.switches.Add("Fox");
switchGroup3.switches.Add("Fox_Intro");
switchGroup3.switches.Add("Gecko");
switchGroup3.switches.Add("Hawk");
switchGroup3.switches.Add("Hippo");
switchGroup3.switches.Add("Llama");
switchGroup3.switches.Add("Magpie");
switchGroup3.switches.Add("Mamba");
switchGroup3.switches.Add("Mongoose");
switchGroup3.switches.Add("None");
switchGroup3.switches.Add("Octopus");
switchGroup3.switches.Add("Peacock");
switchGroup3.switches.Add("PolarBear");
switchGroup3.switches.Add("PolarBear_VR");
switchGroup3.switches.Add("PolerBear_Arrival");
switchGroup3.switches.Add("Python");
switchGroup3.switches.Add("Raccoon");
switchGroup3.switches.Add("Rat");
switchGroup3.switches.Add("Rocky_Dugong");
switchGroup3.switches.Add("Safehouse");
switchGroup3.switches.Add("Sheep");
switchGroup3.switches.Add("Skunk");
switchGroup3.switches.Add("SmoothSnake");
switchGroup3.switches.Add("SnowCrane");
switchGroup3.switches.Add("Spider");
switchGroup3.switches.Add("Stingray");
switchGroup3.switches.Add("Tiger");
switchGroup3.switches.Add("Wolverine");
AudioSwitchWriter.WriteAudioSwitch(ref switchGroup3);*/
}
}

Expand Down
102 changes: 102 additions & 0 deletions G2WwiseDataTool/SoundbanksInfoParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static void ReadSoundbankInfo(string inputPath, string outputPath, bool o

HashSet<string> logEventPaths = new HashSet<string>();
HashSet<string> logSoundBankPaths = new HashSet<string>();
HashSet<string> logSwitchPaths = new HashSet<string>();
HashSet<string> logUnsupportedEvents = new HashSet<string>();

try
Expand Down Expand Up @@ -219,6 +220,97 @@ public static void ReadSoundbankInfo(string inputPath, string outputPath, bool o
}
}

XmlNodeList switchGroups = soundBankNode.SelectNodes("SwitchGroups/SwitchGroup");
foreach (XmlNode switchGroupNode in switchGroups)
{
string switchGroupName = switchGroupNode.Attributes["Name"].Value;
string switchGroupObjectPath = switchGroupNode.Attributes["ObjectPath"].Value;
string switchGroupAssemblyPath = "[assembly:/sound/wwise/exportedwwisedata" + switchGroupObjectPath + ".wwiseswitchgroup].pc_entityblueprint";
string switchGroupAssemblyHash = MD5.ConvertStringtoMD5(switchGroupAssemblyPath);

string switchGroupTypeAssemblyPath = "[assembly:/sound/wwise/exportedwwisedata" + switchGroupObjectPath + ".wwiseswitchgroup].pc_entitytype";
string switchGroupTypeAssemblyHash = MD5.ConvertStringtoMD5(switchGroupTypeAssemblyPath);

logSwitchPaths.Add(switchGroupTypeAssemblyPath.Replace("\\", "/"));
logSwitchPaths.Add(switchGroupAssemblyPath.Replace("\\", "/"));

AudioSwitchWriter.SwitchGroup switchData = new AudioSwitchWriter.SwitchGroup();

switchData.name = switchGroupName;

foreach (XmlNode switches in switchGroupNode.SelectNodes("Switches/Switch"))
{
string switchName = switches.Attributes["Name"].Value;

switchData.switches.Add(switchName);
}

MetaFiles.MetaData switchTypeMetaData = new MetaFiles.MetaData();

switchTypeMetaData.hashValue = switchGroupTypeAssemblyHash;
switchTypeMetaData.hashOffset = 73362489;
switchTypeMetaData.hashSize = 2147483648;
switchTypeMetaData.hashResourceType = "WSWT";
switchTypeMetaData.hashReferenceTableSize = 22;
switchTypeMetaData.hashReferenceTableDummy = 0;
switchTypeMetaData.hashSizeFinal = 0;
switchTypeMetaData.hashSizeInMemory = 4294967295;
switchTypeMetaData.hashSizeInVideoMemory = 4294967295;
switchTypeMetaData.hashReferenceData.Add(new
{
hash = "[modules:/zaudioswitchentity.class].pc_entitytype",
flag = "1F"
});
switchTypeMetaData.hashReferenceData.Add(new
{
hash = switchGroupAssemblyPath.ToLower().Replace("\\", "/"),
flag = "1F"
});

MetaFiles.MetaData switchBlueprintMetaData = new MetaFiles.MetaData();

switchBlueprintMetaData.hashValue = switchGroupAssemblyHash;
switchBlueprintMetaData.hashOffset = 44115007;
switchBlueprintMetaData.hashSize = 2147483843;
switchBlueprintMetaData.hashResourceType = "WSWB";
switchBlueprintMetaData.hashReferenceTableSize = 13;
switchBlueprintMetaData.hashReferenceTableDummy = 0;
switchBlueprintMetaData.hashSizeFinal = 265;
switchBlueprintMetaData.hashSizeInMemory = 201;
switchBlueprintMetaData.hashSizeInVideoMemory = 4294967295;
switchBlueprintMetaData.hashReferenceData.Add(new
{
hash = "[modules:/zaudioswitchentity.class].pc_entityblueprint",
flag = "1F"
});

if (outputToFolderStructure == true)
{
string finalOutputPath = Path.Combine(outputPath, switchGroupObjectPath.TrimStart('\\'));
if (!Directory.Exists(outputPath))
{
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
}

switchData.outputPath = finalOutputPath + ".wwiseswitchgroup";
AudioSwitchWriter.WriteAudioSwitch(ref switchData);

MetaFiles.GenerateMeta(ref switchBlueprintMetaData, finalOutputPath + ".wwiseswitchgroup.meta.json");
}
else
{
switchData.outputPath = outputPath + switchGroupAssemblyHash + ".WSWB";
AudioSwitchWriter.WriteAudioSwitch(ref switchData);

MetaFiles.GenerateMeta(ref switchTypeMetaData, outputPath + switchGroupTypeAssemblyHash + ".WSWT.meta.json");
MetaFiles.GenerateMeta(ref switchBlueprintMetaData, outputPath + switchGroupAssemblyHash + ".WSWB.meta.json");

// Create blank WSWT file
File.Create(outputPath + switchGroupTypeAssemblyHash + ".WSWT");
}

}

if (soundBankName == "Init") // Ignore Init soundbank because the game already has one
{
continue;
Expand Down Expand Up @@ -278,10 +370,20 @@ public static void ReadSoundbankInfo(string inputPath, string outputPath, bool o
}
}

if (logSwitchPaths.Count > 0)
{
Console.WriteLine("Switch Paths:");
foreach (string logSwitchPath in logSwitchPaths)
{
Console.WriteLine(logSwitchPath);
}
}

if (saveEventAndSoundBankPaths)
{
File.WriteAllLines(Path.Combine(outputPath + "events.txt"), logEventPaths);
File.WriteAllLines(Path.Combine(outputPath + "soundbanks.txt"), logSoundBankPaths);
File.WriteAllLines(Path.Combine(outputPath + "switches.txt"), logSwitchPaths);
}

if (logUnsupportedEvents.Count > 0)
Expand Down

0 comments on commit 45ed9c5

Please sign in to comment.