Audio Explorer

This commit is contained in:
dexy
2022-01-13 05:07:07 +11:00
Unverified
parent e76e854ead
commit df79715e6b
11 changed files with 1303 additions and 266 deletions
+148 -6
View File
@@ -89,6 +89,19 @@ namespace CodeWalker.GameFiles
public Dictionary<MetaHash, Dictionary<MetaHash, RpfFileEntry>> PedTextureDicts { get; set; }
public Dictionary<MetaHash, Dictionary<MetaHash, RpfFileEntry>> PedClothDicts { get; set; }
public List<RelFile> AudioDatRelFiles = new List<RelFile>();
public Dictionary<MetaHash, RelData> AudioConfigDict = new Dictionary<MetaHash, RelData>();
public Dictionary<MetaHash, RelData> AudioSpeechDict = new Dictionary<MetaHash, RelData>();
public Dictionary<MetaHash, RelData> AudioSynthsDict = new Dictionary<MetaHash, RelData>();
public Dictionary<MetaHash, RelData> AudioMixersDict = new Dictionary<MetaHash, RelData>();
public Dictionary<MetaHash, RelData> AudioCurvesDict = new Dictionary<MetaHash, RelData>();
public Dictionary<MetaHash, RelData> AudioCategsDict = new Dictionary<MetaHash, RelData>();
public Dictionary<MetaHash, RelData> AudioSoundsDict = new Dictionary<MetaHash, RelData>();
public Dictionary<MetaHash, RelData> AudioGameDict = new Dictionary<MetaHash, RelData>();
public List<RpfFile> BaseRpfs { get; private set; }
public List<RpfFile> AllRpfs { get; private set; }
public List<RpfFile> DlcRpfs { get; private set; }
@@ -98,6 +111,7 @@ namespace CodeWalker.GameFiles
public bool LoadArchetypes = true;
public bool LoadVehicles = true;
public bool LoadPeds = true;
public bool LoadAudio = true;
private bool PreloadedMode = false;
private string GTAFolder;
@@ -250,6 +264,9 @@ namespace CodeWalker.GameFiles
UpdateStatus("Loading strings...");
InitStringDicts();
UpdateStatus("Loading audio...");
InitAudio();
IsInited = true;
}
@@ -296,6 +313,9 @@ namespace CodeWalker.GameFiles
UpdateStatus("Loading peds...");
InitPeds();
UpdateStatus("Loading audio...");
InitAudio();
}
private void InitDlcList()
@@ -944,32 +964,26 @@ namespace CodeWalker.GameFiles
RpfFileEntry fentry = entry as RpfFileEntry;
if (entry.NameLower.EndsWith(".ydr"))
{
YdrDict[entry.NameHash] = fentry; //replaces any existing entries...
YdrDict[entry.ShortNameHash] = fentry;
}
else if (entry.NameLower.EndsWith(".ydd"))
{
YddDict[entry.NameHash] = fentry; //replaces any existing entries...
YddDict[entry.ShortNameHash] = fentry;
}
else if (entry.NameLower.EndsWith(".ytd"))
{
YtdDict[entry.NameHash] = fentry; //replaces any existing entries...
YtdDict[entry.ShortNameHash] = fentry;
}
else if (entry.NameLower.EndsWith(".yft"))
{
YftDict[entry.NameHash] = fentry;
YftDict[entry.ShortNameHash] = fentry;
}
else if (entry.NameLower.EndsWith(".ycd"))
{
YcdDict[entry.NameHash] = fentry;
YcdDict[entry.ShortNameHash] = fentry;
}
else if (entry.NameLower.EndsWith(".yed"))
{
YedDict[entry.NameHash] = fentry;
YedDict[entry.ShortNameHash] = fentry;
}
}
@@ -1826,6 +1840,134 @@ namespace CodeWalker.GameFiles
}
public void InitAudio()
{
if (!LoadAudio) return;
Dictionary<uint, RpfFileEntry> datrelentries = new Dictionary<uint, RpfFileEntry>();
void addRpfDatRelEntries(RpfFile rpffile)
{
if (rpffile.AllEntries == null) return;
foreach (var entry in rpffile.AllEntries)
{
if (entry is RpfFileEntry)
{
RpfFileEntry fentry = entry as RpfFileEntry;
if (entry.NameLower.EndsWith(".rel"))
{
datrelentries[entry.NameHash] = fentry;
}
}
}
}
var audrpf = RpfMan.FindRpfFile("x64\\audio\\audio_rel.rpf");
if (audrpf != null)
{
addRpfDatRelEntries(audrpf);
}
if (EnableDlc)
{
var updrpf = RpfMan.FindRpfFile("update\\update.rpf");
if (updrpf != null)
{
addRpfDatRelEntries(updrpf);
}
foreach (var dlcrpf in DlcActiveRpfs) //load from current dlc rpfs
{
addRpfDatRelEntries(dlcrpf);
}
if (DlcActiveRpfs.Count == 0) //when activated from RPF explorer... DLCs aren't initialised fully
{
foreach (var rpf in AllRpfs) //this is a bit of a hack - DLC orders won't be correct so likely will select wrong versions of things
{
if (rpf.NameLower.StartsWith("dlc"))
{
addRpfDatRelEntries(rpf);
}
}
}
}
var audioDatRelFiles = new List<RelFile>();
var audioConfigDict = new Dictionary<MetaHash, RelData>();
var audioSpeechDict = new Dictionary<MetaHash, RelData>();
var audioSynthsDict = new Dictionary<MetaHash, RelData>();
var audioMixersDict = new Dictionary<MetaHash, RelData>();
var audioCurvesDict = new Dictionary<MetaHash, RelData>();
var audioCategsDict = new Dictionary<MetaHash, RelData>();
var audioSoundsDict = new Dictionary<MetaHash, RelData>();
var audioGameDict = new Dictionary<MetaHash, RelData>();
foreach (var datrelentry in datrelentries.Values)
{
var relfile = RpfMan.GetFile<RelFile>(datrelentry);
if (relfile == null) continue;
audioDatRelFiles.Add(relfile);
var d = audioGameDict;
var t = relfile.RelType;
switch (t)
{
case RelDatFileType.Dat4:
d = relfile.IsAudioConfig ? audioConfigDict : audioSpeechDict;
break;
case RelDatFileType.Dat10ModularSynth:
d = audioSynthsDict;
break;
case RelDatFileType.Dat15DynamicMixer:
d = audioMixersDict;
break;
case RelDatFileType.Dat16Curves:
d = audioCurvesDict;
break;
case RelDatFileType.Dat22Categories:
d = audioCategsDict;
break;
case RelDatFileType.Dat54DataEntries:
d = audioSoundsDict;
break;
case RelDatFileType.Dat149:
case RelDatFileType.Dat150:
case RelDatFileType.Dat151:
default:
d = audioGameDict;
break;
}
foreach (var reldata in relfile.RelDatas)
{
if (reldata.NameHash == 0) continue;
//if (d.TryGetValue(reldata.NameHash, out var exdata) && (exdata.TypeID != reldata.TypeID))
//{ }//sanity check
d[reldata.NameHash] = reldata;
}
}
AudioDatRelFiles = audioDatRelFiles;
AudioConfigDict = audioConfigDict;
AudioSpeechDict = audioSpeechDict;
AudioSynthsDict = audioSynthsDict;
AudioMixersDict = audioMixersDict;
AudioCurvesDict = audioCurvesDict;
AudioCategsDict = audioCategsDict;
AudioSoundsDict = audioSoundsDict;
AudioGameDict = audioGameDict;
}
public bool SetDlcLevel(string dlc, bool enable)
{