Skip to content

Commit

Permalink
added ui for wwise project generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurHeitmann committed Aug 25, 2024
1 parent 09b00eb commit 461efd7
Show file tree
Hide file tree
Showing 17 changed files with 417 additions and 52 deletions.
4 changes: 2 additions & 2 deletions lib/stateManagement/hierarchy/types/BnkHierarchyEntry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import '../../../fileTypeUtils/audio/removePrefetchWems.dart';
import '../../../fileTypeUtils/audio/wemIdsToNames.dart';
import '../../../fileTypeUtils/audio/wwiseObjectPath.dart';
import '../../../utils/utils.dart';
import '../../../utils/wwiseProjectGenerator/wwiseProjectGenerator.dart';
import '../../../widgets/misc/wwiseProjectGeneratorPopup.dart';
import '../../Property.dart';
import '../../openFiles/types/WemFileData.dart';
import '../../undoable.dart';
Expand Down Expand Up @@ -511,7 +511,7 @@ class BnkHierarchyEntry extends GenericFileHierarchyEntry {
return [
HierarchyEntryAction(
name: "Create Wwise project",
action: () => WwiseProjectGenerator.generateFromBnk(path, r"D:\delete\wwise project gen"),
action: () => showWwiseProjectGeneratorPopup(path),
),
...super.getActions()
];
Expand Down
2 changes: 2 additions & 0 deletions lib/stateManagement/preferencesData.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class PreferencesData extends OpenFileData {
SavableProp<String>? wwise2012CliPath;
SavableProp<String>? lastCpkExtractDir;
SavableProp<String>? lastSearchDir;
SavableProp<String>? lastWwiseProjectDir;

PreferencesData._()
: prefsFuture = SharedPreferences.getInstance(),
Expand Down Expand Up @@ -134,6 +135,7 @@ class PreferencesData extends OpenFileData {
wwise2012CliPath = SavableProp<String>("wwise2012CliPath", _prefs!, "");
lastCpkExtractDir = SavableProp<String>("lastCpkExtractDir", _prefs!, "");
lastSearchDir = SavableProp<String>("lastSearchDir", _prefs!, "");
lastWwiseProjectDir = SavableProp<String>("lastWwiseProjectDir", _prefs!, "");

await super.load();
_loadingState = LoadingState.loaded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class WwiseHierarchyElement<T extends BnkHircChunkWithBaseParamsGetter> extends
pannerProps.add(WwiseProperty(prop.name, prop.type, value: value.number.toString()));
}
else {
project.log(WwiseLogSeverity.error, "Unknown property id $propId on ${chunk.uid}");
project.log(WwiseLogSeverity.warning, "Unknown property id $propId on ${chunk.uid}");
}
continue;
}
Expand All @@ -164,7 +164,7 @@ class WwiseHierarchyElement<T extends BnkHircChunkWithBaseParamsGetter> extends
for (var (propId, value) in rangedProps) {
var prop = _propIdToConfig[propId];
if (prop == null) {
project.log(WwiseLogSeverity.error, "Unknown ranged property id $propId on ${chunk.uid}");
project.log(WwiseLogSeverity.warning, "Unknown ranged property id $propId on ${chunk.uid}");
continue;
}
properties.add(WwiseProperty(
Expand All @@ -177,7 +177,7 @@ class WwiseHierarchyElement<T extends BnkHircChunkWithBaseParamsGetter> extends
for (var rtpc in baseParams.rtpc.rtpc) {
var prop = _rtpcPropIdToName[rtpc.paramID];
if (prop == null) {
project.log(WwiseLogSeverity.error, "Unknown rtpc id ${rtpc.paramID} on ${chunk.uid}");
project.log(WwiseLogSeverity.warning, "Unknown rtpc id ${rtpc.paramID} on ${chunk.uid}");
continue;
}
properties.add(WwiseProperty(prop.name, prop.type, project: project, rtpcs: [rtpc]));
Expand All @@ -194,7 +194,7 @@ class WwiseHierarchyElement<T extends BnkHircChunkWithBaseParamsGetter> extends
continue;
var effectRef = project.lookupElement(idFnv: effect.fxID) as WwiseEffect?;
if (effectRef == null) {
project.log(WwiseLogSeverity.error, "Could not locate effect id ${effect.fxID}");
project.log(WwiseLogSeverity.warning, "Could not locate effect id ${effect.fxID}");
continue;
}
if (effect.bIsShareSet != 0)
Expand Down Expand Up @@ -274,7 +274,7 @@ Future<void> saveHierarchyBaseElements(WwiseProjectGenerator project) async {
element = WwiseMusicSwitch(project: project, wuId: imhWu.id, chunk: chunk);
}
else {
project.log(WwiseLogSeverity.error, "Unknown chunk type ${chunk.runtimeType}");
project.log(WwiseLogSeverity.warning, "Unknown chunk type ${chunk.runtimeType}");
}

if (element != null) {
Expand All @@ -294,7 +294,7 @@ Future<void> saveHierarchyBaseElements(WwiseProjectGenerator project) async {
for (var (id, parentId, element) in elements.values) {
var parent = elements[parentId];
if (parent == null && parentId != 0) {
project.log(WwiseLogSeverity.error, "Could not find parent $parentId for $id");
project.log(WwiseLogSeverity.warning, "Could not find parent $parentId for $id");
continue;
}
if (parent != null)
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/wwiseProjectGenerator/elements/wwiseAction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class WwiseAction extends WwiseElement {
? project.buses[action.initialParams.idExt]
: project.lookupElement(idFnv: action.initialParams.idExt);
if (action.initialParams.idExt != 0 && lookup == null)
project.log(WwiseLogSeverity.error, "Unknown action target ${action.initialParams.idExt}");
project.log(WwiseLogSeverity.warning, "Unknown action target ${action.initialParams.idExt}");
elements.add(lookup);
}
// exceptions
Expand All @@ -129,7 +129,7 @@ class WwiseAction extends WwiseElement {
? project.buses[id]
: project.lookupElement(idFnv: id);
if (lookup == null && id != 0)
project.log(WwiseLogSeverity.error, "Unknown action exception $id");
project.log(WwiseLogSeverity.warning, "Unknown action exception $id");
elements.add(lookup);
}
}
Expand Down Expand Up @@ -172,15 +172,15 @@ class WwiseAction extends WwiseElement {
for (var (prop: prop, value: value) in valueProps) {
var propInfo = _bnkPropToName[prop];
if (propInfo == null) {
project.log(WwiseLogSeverity.error, "Unknown value property 0x${prop.toRadixString(16)}");
project.log(WwiseLogSeverity.warning, "Unknown value property 0x${prop.toRadixString(16)}");
continue;
}
properties.add(WwiseProperty(propInfo.name, propInfo.type, value: (value.number / propInfo.div).toString()));
}
for (var (prop: prop, value: (min, max)) in rangedProps) {
var propInfo = _bnkPropToName[prop];
if (propInfo == null) {
project.log(WwiseLogSeverity.error, "Unknown ranged property 0x${prop.toRadixString(16)}");
project.log(WwiseLogSeverity.warning, "Unknown ranged property 0x${prop.toRadixString(16)}");
continue;
}
properties.add(WwiseProperty(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class WwiseAttenuation extends WwiseElement {
for (var rtpc in attenuation.rtpcs) {
var config = _rtpcPropConfig[rtpc.paramID];
if (config == null) {
project.log(WwiseLogSeverity.error, "Unknown rtpc curve id ${rtpc.paramID}");
project.log(WwiseLogSeverity.warning, "Unknown rtpc curve id ${rtpc.paramID}");
continue;
}
properties.add(WwiseProperty(config.name, config.type, project: project, rtpcs: [rtpc]));
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/wwiseProjectGenerator/elements/wwiseEffect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class WwiseEffect extends WwiseElement {
for (var rtpc in effect.rtpc.rtpc) {
var propConfig = config.rtpcProps[rtpc.paramID];
if (propConfig == null) {
project.log(WwiseLogSeverity.error, "Unknown rtpc curve id ${rtpc.paramID} for effect plugin ${config.name}");
project.log(WwiseLogSeverity.warning, "Unknown rtpc curve id ${rtpc.paramID} for effect plugin ${config.name}");
continue;
}
properties.add(WwiseProperty(propConfig.name, propConfig.type, project: project, rtpcs: [rtpc]));
Expand All @@ -48,12 +48,12 @@ class WwiseEffect extends WwiseElement {
static WwiseEffect? fromId({required String wuId, required WwiseProjectGenerator project, required int id}) {
var effect = project.hircChunkById<BnkFxCustom>(id);
if (effect == null) {
project.log(WwiseLogSeverity.error, "Could not locate effect id $id");
project.log(WwiseLogSeverity.warning, "Could not locate effect id $id");
return null;
}
var config = _pluginConfigs[effect.fxId];
if (config == null) {
project.log(WwiseLogSeverity.error, "Unknown effect id ${effect.fxId}");
project.log(WwiseLogSeverity.warning, "Unknown effect id ${effect.fxId}");
return null;
}
return WwiseEffect(wuId: wuId, project: project, effect: effect, config: config);
Expand Down Expand Up @@ -228,7 +228,7 @@ Future<void> saveEffectsIntoWu(WwiseProjectGenerator project) async {
continue;
var config = _pluginConfigs[effect.fxId];
if (config == null) {
project.log(WwiseLogSeverity.error, "Unknown effect id ${effect.fxId}");
project.log(WwiseLogSeverity.warning, "Unknown effect id ${effect.fxId}");
continue;
}
var effectElement = WwiseEffect(wuId: project.effectsWu.id, project: project, effect: effect, config: config);
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/wwiseProjectGenerator/elements/wwiseEvents.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Future<void> saveEventsHierarchy(WwiseProjectGenerator project) async {
shortIdHint: event.uid,
children: [
for (var actionId in event.ids)
if (actionsMap.containsKey(actionId))
if (project.options.actions && actionsMap.containsKey(actionId))
WwiseAction(wuId: project.eventsWu.id, project: project, action: actionsMap[actionId]!)
]
), event.uid);
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/wwiseProjectGenerator/elements/wwiseMusicTrack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class WwiseMusicTrack extends WwiseHierarchyElement<BnkMusicTrack> {
name: "${wemIdsToNames[chunk.sources.first.sourceID] ?? wemIdsToNames[chunk.sources.first.fileID] ?? chunk.uid.toString()} Music Track",
shortId: chunk.uid,
properties: [
if ((chunk.sources.firstOrNull?.streamType ?? 0) >= 1)
if (project.options.streaming && (chunk.sources.firstOrNull?.streamType ?? 0) >= 1)
WwiseProperty("IsStreamingEnabled", "bool", values: ["True"]),
if ((chunk.sources.firstOrNull?.streamType ?? 0) == 2)
if (project.options.streaming && (chunk.sources.firstOrNull?.streamType ?? 0) == 2)
WwiseProperty("IsZeroLantency", "bool", values: ["True"]),
if (chunk.iLookAheadTime != 100)
WwiseProperty("LookAheadTime", "int16", value: chunk.iLookAheadTime.toString()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ XmlElement? makeWwisePositioningInfo(WwiseProjectGenerator project, WwiseElement
if ((positioning.attenuationID ?? 0) != 0) {
var attenuation = project.lookupElement(idFnv: positioning.attenuationID!) as WwiseAttenuation?;
if (attenuation == null) {
project.log(WwiseLogSeverity.error, "Attenuation with ID ${positioning.attenuationID} not found");
project.log(WwiseLogSeverity.warning, "Attenuation with ID ${positioning.attenuationID} not found");
} else {
children.add(makeXmlElement(name: "AttenuationInfo", children: [
makeXmlElement(
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/wwiseProjectGenerator/elements/wwiseSound.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class WwiseSound extends WwiseHierarchyElement<BnkSound> {
shortId: chunk.uid,
additionalAttributes: { "Type": chunk.bankData.mediaInformation.uSourceBits & 1 == 0 ? "SoundFX" : "Voice"},
properties: [
if (chunk.bankData.streamType >= 1)
if (project.options.streaming && chunk.bankData.streamType >= 1)
WwiseProperty("IsStreamingEnabled", "bool", values: ["True"]),
if (chunk.bankData.streamType == 2)
if (project.options.streaming && chunk.bankData.streamType == 2)
WwiseProperty("IsZeroLantency", "bool", values: ["True"]),
],
children: [
Expand Down
4 changes: 2 additions & 2 deletions lib/utils/wwiseProjectGenerator/elements/wwiseStateInfo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ XmlElement? makeWwiseStatInfo(WwiseProjectGenerator project, List<BnkStateChunkG
.map((id) {
var group = project.stateGroups[id];
if (group == null)
project.log(WwiseLogSeverity.error, "State group $id is not found");
project.log(WwiseLogSeverity.warning, "State group $id is not found");
return group;
})
.whereType<WwiseSwitchOrStateGroup>()
Expand Down Expand Up @@ -52,7 +52,7 @@ XmlElement? makeWwiseStatInfo(WwiseProjectGenerator project, List<BnkStateChunkG
.map((prop) {
var propInfo = _propIdToName[prop.$1];
if (propInfo == null) {
project.log(WwiseLogSeverity.error, "Unknown property ${prop.$1}");
project.log(WwiseLogSeverity.warning, "Unknown property ${prop.$1}");
return null;
}
return makeXmlElement(name: "Property", attributes: {"Name": propInfo.name, "Type": propInfo.type, "Value": prop.$2.toString()});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ XmlElement makeWwiseTransitionList(WwiseProjectGenerator project, String wuId, L
var destPlItem = project.lookupElement(idFnv: transition.dstRule.uJumpToID) as WwiseElement?;
var transSegment = project.lookupElement(idFnv: transition.musicTransition.segmentID) as WwiseElement?;
if (transition.srcID > 0 && src == null) {
project.log(WwiseLogSeverity.error, "Transition source not found: ${wwiseIdToStr(transition.srcID)}");
project.log(WwiseLogSeverity.warning, "Transition source not found: ${wwiseIdToStr(transition.srcID)}");
return null;
}
if (transition.dstID > 0 && dest == null) {
project.log(WwiseLogSeverity.error, "Transition destination not found: ${wwiseIdToStr(transition.dstID)}");
project.log(WwiseLogSeverity.warning, "Transition destination not found: ${wwiseIdToStr(transition.dstID)}");
return null;
}
if (transition.dstRule.uJumpToID > 0 && destPlItem == null) {
project.log(WwiseLogSeverity.error, "Transition destination playlist item not found: ${wwiseIdToStr(transition.dstRule.uJumpToID)}");
project.log(WwiseLogSeverity.warning, "Transition destination playlist item not found: ${wwiseIdToStr(transition.dstRule.uJumpToID)}");
return null;
}
String? srcCustomCueName = transition.srcRule.uMarkerID != 0 ? (project.lookupElement(idFnv: transition.srcRule.uMarkerID) as WwiseElement?)?.name : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ XmlElement? makeStingerList(WwiseProjectGenerator project, String wuId, List<Bnk
if (stinger.segmentID != 0) {
segment = project.lookupElement(idFnv: stinger.segmentID) as WwiseElement?;
if (segment == null)
project.log(WwiseLogSeverity.error, "Stinger segment not found: ${stinger.segmentID}");
project.log(WwiseLogSeverity.warning, "Stinger segment not found: ${stinger.segmentID}");
}
stingerElements.add(WwiseElement(
project: project,
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/wwiseProjectGenerator/wwiseAudioFilesPrepare.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ Future<Map<int, WwiseAudioFile>> prepareWwiseAudioFiles(WwiseProjectGenerator pr
await Directory(sfxDir).create(recursive: true);
await Directory(langDir).create(recursive: true);
Future<Directory>? tmpDirLazy;
int processed = 0;
try {
await futuresWaitBatched(usedWemIds.map((id) async {
project.status.currentMsg.value = "Processing WEM files: $processed / ${usedWemIds.length}";
processed++;
var srcId = id;
var fileId = srcToFileIds[srcId];
var trueId = srcId;
Expand All @@ -83,7 +86,7 @@ Future<Map<int, WwiseAudioFile>> prepareWwiseAudioFiles(WwiseProjectGenerator pr
if (wemPath == null) {
var file = internalWemFiles[srcId];
if (file == null) {
project.log(WwiseLogSeverity.error, "WEM file ${wwiseIdToStr(srcId, alwaysIncludeId: true)} is not indexed or found in BNK file");
project.log(WwiseLogSeverity.warning, "WEM file ${wwiseIdToStr(srcId, alwaysIncludeId: true)} is not indexed or found in BNK file");
return;
}
tmpDirLazy ??= Directory.systemTemp.createTemp("wwise_audio_files");
Expand Down
Loading

0 comments on commit 461efd7

Please sign in to comment.