public static void SaveSound(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, ulong sound) { FindLogic.Combo.SoundInfoNew soundInfo = info.Sounds[sound]; string soundDir = Path.Combine(path, soundInfo.GetName()); CreateDirectoryFromFile(soundDir + "\\harrypotter.png"); HashSet <ulong> done = new HashSet <ulong>(); if (soundInfo.Sounds != null) { foreach (KeyValuePair <uint, ulong> soundPair in soundInfo.Sounds) { if (done.Contains(soundPair.Value)) { continue; } SaveSoundFile(flags, soundDir, info, soundPair.Value, false); done.Add(soundPair.Value); } } if (soundInfo.OtherSounds != null) { foreach (ulong otherSound in soundInfo.OtherSounds) { if (done.Contains(otherSound)) { continue; } SaveSoundFile(flags, soundDir, info, otherSound, false); done.Add(otherSound); } } }
public static void Save(ICLIFlags flags, string directory, DataModels.Unlock unlock) { FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo(); FindLogic.Combo.Find(info, unlock.GUID); bool saveAllTextures = false; try { info.m_textures.First(x => x.Value.m_loose).Value.m_name = unlock.Name; directory = Path.GetFullPath(Path.Combine(directory, "..")); } catch { // animated spray - no main image saveAllTextures = true; } var context = new Combo.SaveContext(info); Combo.SaveLooseTextures(flags, directory, context); if (!saveAllTextures) { context.Wait(); return; } Combo.SaveAllMaterials(flags, directory, context); Combo.Save(flags, directory, context); context.Wait(); }
public static void Save(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info) { info.SaveRuntimeData = new FindLogic.Combo.ComboSaveRuntimeData(); foreach (FindLogic.Combo.EntityInfoNew entity in info.Entities.Values) { if (info.SaveRuntimeData.Threads) { info.SaveRuntimeData.Tasks.Add(Task.Run(() => { SaveEntity(flags, path, info, entity.GUID); })); } else { SaveEntity(flags, path, info, entity.GUID); } } foreach (FindLogic.Combo.EffectInfoCombo effectInfo in info.Effects.Values) { SaveEffect(flags, path, info, effectInfo.GUID); } foreach (FindLogic.Combo.ModelInfoNew model in info.Models.Values) { SaveModel(flags, path, info, model.GUID); } // rules for threads: // CASC IO MUST BE DONE IN MAIN THREAD. NO EXCEPTIONS Wait(info); }
private static void SetPreviewWeaponNames(FindLogic.Combo.ComboInfo info, Dictionary <ulong, ulong> weaponReplacements, STU_A0872511[] entities, int index) { if (entities == null) { return; } foreach (STU_A0872511 weaponEntity in entities) { FindLogic.Combo.Find(info, weaponEntity.m_entityDefinition, weaponReplacements); if (weaponEntity.m_loadout == 0) { continue; } Loadout loadout = Loadout.GetLoadout(weaponEntity.m_loadout); if (loadout == null) { continue; } info.SetEntityName(weaponEntity.m_entityDefinition, $"{loadout.Name}-{teResourceGUID.Index(weaponEntity.m_entityDefinition)}"); if ((weaponReplacements == null || index == 0) && info.m_entities.TryGetValue(weaponEntity.m_entityDefinition, out var entity) && info.m_models.TryGetValue(entity.m_modelGUID, out var model)) { foreach (var modellook in model.m_modelLooks) { info.SetModelLookName(modellook, $"{(STUWeaponType) index:G}-{teResourceGUID.Index(modellook):X}"); } } } }
public static void Save(ICLIFlags flags, string directory, DataModels.Unlock unlock) { STUUnlock_PortraitFrame portraitFrame = (STUUnlock_PortraitFrame)unlock.STU; string tier = portraitFrame.m_rank.ToString(); FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo(); if (portraitFrame.m_rankTexture != null) { FindLogic.Combo.Find(info, portraitFrame.m_rankTexture); info.SetTextureName(portraitFrame.m_rankTexture, $"Star - {portraitFrame.m_stars}"); } if (portraitFrame.m_949D9C2A != null) { FindLogic.Combo.Find(info, portraitFrame.m_949D9C2A); int borderNum = portraitFrame.m_level - portraitFrame.m_stars * 10 - (int)portraitFrame.m_rank * 10; if ((int)portraitFrame.m_rank > 1) { borderNum -= 50 * ((int)portraitFrame.m_rank - 1); } borderNum -= 1; info.SetTextureName(portraitFrame.m_949D9C2A, $"Border - {borderNum}"); } var context = new Combo.SaveContext(info); Combo.SaveLooseTextures(flags, Path.Combine(directory, tier), context); context.Wait(); }
public static void SaveSoundFile(ICLIFlags flags, string directory, FindLogic.Combo.ComboInfo info, ulong soundFile, bool voice, string name = null) { if (soundFile == 0) { return; } bool convertWem = true; if (flags is ExtractFlags extractFlags) { convertWem = !extractFlags.RawSound && !extractFlags.Raw; if (extractFlags.SkipSound) { return; } } FindLogic.Combo.SoundFileInfo soundFileInfo = voice ? info.VoiceSoundFiles[soundFile] : info.SoundFiles[soundFile]; using (Stream soundStream = OpenFile(soundFile)) { if (soundStream == null) { return; } if (!convertWem) { WriteFile(soundStream, Path.Combine(directory, $"{name ?? soundFileInfo.GetName()}.wem")); } else { ConvertSoundFile(soundStream, soundFileInfo, directory, name); } } }
public static void SaveSound(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, ulong sound) { FindLogic.Combo.SoundInfoNew soundInfo = info.Sounds[sound]; string soundDir = Path.Combine(path, soundInfo.GetName()); CreateDirectorySafe(soundDir); HashSet <ulong> done = new HashSet <ulong>(); if (soundInfo.SoundFiles != null) { foreach (KeyValuePair <uint, ulong> soundPair in soundInfo.SoundFiles) { if (done.Contains(soundPair.Value)) { continue; } SaveSoundFile(flags, soundDir, info, soundPair.Value, false); done.Add(soundPair.Value); } } if (soundInfo.SoundStreams != null) { foreach (KeyValuePair <uint, ulong> soundStream in soundInfo.SoundStreams) { if (done.Contains(soundStream.Value)) { continue; } SaveSoundFile(flags, soundDir, info, soundStream.Value, false); done.Add(soundStream.Value); } } }
public OverwatchEffect(FindLogic.Combo.ComboInfo info, FindLogic.Combo.EffectInfoCombo effectInfo, Dictionary <ulong, HashSet <FindLogic.Combo.VoiceLineInstanceInfo> > voiceStimuli) { Info = info; EffectInfo = effectInfo; VoiceStimuli = voiceStimuli; }
public static void SaveModelLook(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, ulong modelLook) { Model.OWMatWriter14 materialWriter = new Model.OWMatWriter14(); FindLogic.Combo.ModelLookInfo modelLookInfo = info.ModelLooks[modelLook]; if (info.SaveRuntimeData.Threads) { info.SaveRuntimeData.Tasks.Add(Task.Run(() => { SaveOWMaterialModelLookFile(path, modelLookInfo, materialWriter, info); })); } else { SaveOWMaterialModelLookFile(path, modelLookInfo, materialWriter, info); } if (modelLookInfo.Materials == null) { return; } foreach (ulong modelLookMaterial in modelLookInfo.Materials) { SaveMaterial(flags, path, info, modelLookMaterial); } }
public static void SaveMaterial(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, ulong material) { FindLogic.Combo.MaterialInfo materialInfo = info.Materials[material]; if (!info.MaterialDatas.ContainsKey(materialInfo.MaterialData)) { return; // heckin encryted content } FindLogic.Combo.MaterialDataInfo materialDataInfo = info.MaterialDatas[materialInfo.MaterialData]; Model.OWMatWriter14 materialWriter = new Model.OWMatWriter14(); string textureDirectory = Path.Combine(path, "Textures"); if (info.SaveRuntimeData.Threads) { info.SaveRuntimeData.Tasks.Add(Task.Run(() => { SaveOWMaterialFile(path, materialInfo, materialWriter, info); })); } else { SaveOWMaterialFile(path, materialInfo, materialWriter, info); } foreach (KeyValuePair <ulong, ImageDefinition.ImageType> texture in materialDataInfo.Textures) { if (!info.Textures.ContainsKey(texture.Key)) { continue; } SaveTexture(flags, textureDirectory, info, texture.Key); } }
public static void SaveAllModelLooks(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info) { foreach (ulong material in info.ModelLooks.Keys) { SaveModelLook(flags, path, info, material); } }
public static void SaveEntity(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, ulong entityGuid) { FindLogic.Combo.EntityInfoNew entityInfo = info.Entities[entityGuid]; Entity.OverwatchEntity entity = new Entity.OverwatchEntity(entityInfo, info); string entityDir = Path.Combine(path, "Entities", entityInfo.GetName()); string outputFile = Path.Combine(entityDir, entityInfo.GetName() + $".{entity.Extension}"); CreateDirectoryFromFile(outputFile); using (Stream entityOutputStream = File.OpenWrite(outputFile)) { entityOutputStream.SetLength(0); entity.Write(entityOutputStream); } if (!info.SaveConfig.SaveAnimationEffects) { return; } if (entityInfo.Model == 0) { return; } foreach (ulong animation in entityInfo.Animations) { SaveAnimationEffectReference(entityDir, info, animation, entityInfo.Model); } foreach (ulong effect in entityInfo.Effects) { SaveEffect(flags, entityDir, info, effect); } }
public static void Save(ICLIFlags flags, string directory, DataModels.Unlock unlock) { FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo(); FindLogic.Combo.Find(info, unlock.GUID); // hmm, resaving the default spray over and over again (ref'd by SSCE) is kinda bad. try { info.Textures.First(x => x.Value.Loose).Value.Name = unlock.Name; } catch { // what } ExtractFlags extractFlags = flags as ExtractFlags; if (extractFlags?.SprayOnlyImage == true) { directory = Path.GetFullPath(Path.Combine(directory, "..")); } Combo.SaveLooseTextures(flags, directory, info); if (extractFlags?.SprayOnlyImage == true) { return; } Combo.SaveAllMaterials(flags, directory, info); Combo.Save(flags, directory, info); }
public static void SaveAllVoiceSoundFiles(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info) { foreach (FindLogic.Combo.SoundFileInfo soundInfo in info.VoiceSoundFiles.Values) { SaveSoundFile(flags, path, info, soundInfo.GUID, true); } }
// helpers (NOT FOR INTERNAL USE) public static void SaveAllVoiceSets(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo soundInfo) { foreach (KeyValuePair <ulong, FindLogic.Combo.VoiceSetInfo> voiceSet in soundInfo.VoiceSets) { SaveVoiceSet(flags, path, soundInfo, voiceSet.Value); } }
public static void SaveVoiceStimuli(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, IEnumerable <FindLogic.Combo.VoiceLineInstanceInfo> voiceLineInstances, bool split) { info.SaveRuntimeData = new FindLogic.Combo.ComboSaveRuntimeData(); SaveVoiceStimuliInternal(flags, path, info, voiceLineInstances, split); Wait(info); }
public static void SaveVoiceStimulus(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, FindLogic.Combo.VoiceLineInstanceInfo voiceLineInstanceInfo) { foreach (ulong soundFile in voiceLineInstanceInfo.SoundFiles) { SaveSoundFile(flags, path, info, soundFile, true); } }
public static void SaveVoiceSet(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, FindLogic.Combo.VoiceSetInfo voiceSetInfo) { info.SaveRuntimeData = new FindLogic.Combo.ComboSaveRuntimeData(); SaveVoiceSetInternal(flags, path, info, voiceSetInfo.GUID); Wait(info); }
public static void SaveAllModelLooks(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info) { info.SaveRuntimeData = new FindLogic.Combo.ComboSaveRuntimeData(); foreach (ulong material in info.ModelLooks.Keys) { SaveModelLook(flags, path, info, material); } Wait(info); }
public static void SaveVoiceStimulus(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, FindLogic.Combo.VoiceLineInstanceInfo voiceLineInstanceInfo) { var saveSubtitles = true; if (flags is ExtractFlags extractFlags) { saveSubtitles = extractFlags.SubtitlesWithSounds; } var realPath = path; var soundSet = new HashSet <ulong>(voiceLineInstanceInfo.SoundFiles.Where(x => x != 0)); string overrideName = null; if (saveSubtitles) { IEnumerable <string> subtitle = new HashSet <string>(); if (info.Subtitles.TryGetValue(voiceLineInstanceInfo.Subtitle, out var subtitleInfo)) { subtitle = subtitle.Concat(subtitleInfo.Text); } if (info.Subtitles.TryGetValue(voiceLineInstanceInfo.SubtitleRuntime, out var subtitleRuntimeInfo)) { subtitle = subtitle.Concat(subtitleRuntimeInfo.Text); } var subtitleSet = new HashSet <string>(subtitle); if (subtitleSet.Any()) { if (soundSet.Count > 1) { realPath = Path.Combine(realPath, IO.GetValidFilename(subtitleSet.First().Trim().TrimEnd('.'))); WriteFile(string.Join("\n", subtitleSet), Path.Combine(realPath, $"{teResourceGUID.LongKey(voiceLineInstanceInfo.Subtitle):X8}-{teResourceGUID.LongKey(voiceLineInstanceInfo.SubtitleRuntime):X8}-subtitles.txt")); } else if (soundSet.Count == 1) { try { overrideName = GetValidFilename($"{teResourceGUID.AsString(soundSet.First())}-{subtitleSet.First().TrimEnd('.')}"); if (overrideName.Length > 128) { overrideName = overrideName.Substring(0, 100); } WriteFile(string.Join("\n", subtitleSet), Path.Combine(realPath, $"{overrideName}.txt")); } catch { overrideName = teResourceGUID.AsString(soundSet.First()); WriteFile(string.Join("\n", subtitleSet), Path.Combine(realPath, $"{overrideName}.txt")); } } } } foreach (ulong soundFile in soundSet) { SaveSoundFile(flags, realPath, info, soundFile, true, overrideName); } }
public OverwatchAnimationEffect(FindLogic.Combo.ComboInfo info, FindLogic.Combo.EffectInfoCombo animationEffect, Dictionary <ulong, HashSet <FindLogic.Combo.VoiceLineInstanceInfo> > voiceStimuli, FindLogic.Combo.AnimationAsset animation, ulong model) : base(info, animationEffect, voiceStimuli) { Animation = animation; Model = model; }
public void Write(Stream output, FindLogic.Combo.EntityInfoNew entity, FindLogic.Combo.ComboInfo info) { using (BinaryWriter writer = new BinaryWriter(output)) { writer.Write(new string(Identifier)); writer.Write(VersionMajor); writer.Write((ushort)1); // todo writer.Write(entity.GetNameIndex()); if (entity.Model != 0) { FindLogic.Combo.ModelInfoNew modelInfo = info.Models[entity.Model]; writer.Write(modelInfo.GetName()); } else { writer.Write("null"); } if (entity.Effect != 0) { FindLogic.Combo.EffectInfoCombo effectInfo = info.Effects[entity.Effect]; writer.Write(effectInfo.GetName()); } else { writer.Write("null"); } writer.Write(GUID.Index(entity.GUID)); writer.Write(GUID.Index(entity.Model)); writer.Write(GUID.Index(entity.Effect)); if (entity.Children == null) { writer.Write(0); return; } writer.Write(entity.Children.Count(x => x.GUID != 0)); foreach (FindLogic.Combo.ChildEntityReferenceNew childEntityReference in entity.Children.Where(x => x.GUID != 0)) { FindLogic.Combo.EntityInfoNew childEntityInfo = info.Entities[childEntityReference.GUID]; writer.Write(childEntityInfo.GetName()); writer.Write(childEntityReference.Hardpoint); writer.Write(childEntityReference.Variable); writer.Write(GUID.Index(childEntityReference.Hardpoint)); writer.Write(GUID.Index(childEntityReference.Variable)); if (childEntityReference.Hardpoint != 0) { writer.Write(Model.OWModelWriter14.IdToString("hardpoint", GUID.Index(childEntityReference.Hardpoint))); } else { writer.Write("null"); // erm, k } } } }
public static void Save(ICLIFlags flags, string directory, DataModels.Unlock unlock) { FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo(); FindLogic.Combo.Find(info, unlock.GUID); info.SaveConfig.SaveAnimationEffects = false; // todo: unsupported here due to relative paths used by OWEffect Combo.Save(flags, directory, info); Combo.SaveAllAnimations(flags, directory, info); }
public static void SaveLooseTextures(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info) { foreach (FindLogic.Combo.TextureInfoNew textureInfo in info.Textures.Values) { if (!textureInfo.Loose) { continue; } SaveTexture(flags, path, info, textureInfo.GUID); } }
private static void SaveVoiceSetInternal(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info, ulong voiceSet) { string thisPath = Path.Combine(path, GetFileName(voiceSet)); FindLogic.Combo.VoiceSetInfo voiceSetInfo = info.VoiceSets[voiceSet]; foreach (KeyValuePair <ulong, HashSet <FindLogic.Combo.VoiceLineInstanceInfo> > stimuliSet in voiceSetInfo.VoiceLineInstances) { SaveVoiceStimuliInternal(flags, thisPath, info, stimuliSet.Value, true); } }
public static void Save(ICLIFlags flags, string directory, DataModels.Unlock unlock) { FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo(); FindLogic.Combo.Find(info, unlock.GUID); // hmm, resaving the default spray over and over again (ref'd by SSCE) is kinda bad. Combo.SaveLooseTextures(flags, directory, info); Combo.SaveAllMaterials(flags, directory, info); Combo.Save(flags, directory, info); }
public static void SaveVoiceLines(ICLIFlags flags, HashSet <ulong> lines, VoiceSet voiceSet, string directory) { FindLogic.Combo.ComboInfo fakeComboInfo = new FindLogic.Combo.ComboInfo(); foreach (ulong line in lines) { VoiceLineInstance voiceLineInstance = voiceSet.VoiceLines[line]; SaveVoiceLine(flags, voiceLineInstance, directory, fakeComboInfo); } }
public static void SaveAllAnimations(ICLIFlags flags, string path, FindLogic.Combo.ComboInfo info) { bool beforeSaveAnimEffects = info.SaveConfig.SaveAnimationEffects; info.SaveConfig.SaveAnimationEffects = false; foreach (ulong material in info.Animations.Keys) { SaveAnimation(flags, path, info, material, 0); } info.SaveConfig.SaveAnimationEffects = beforeSaveAnimEffects; }
private void SaveSound(ExtractFlags flags, string basePath, string part, ulong key) { STU_F3EB00D4 stu = GetInstance <STU_F3EB00D4>(key); // todo: should be named if (stu == null || stu.m_B3685B0D == 0) { return; } FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo(); FindLogic.Combo.Find(info, stu.m_B3685B0D); SaveLogic.Combo.SaveSound(flags, Path.Combine(basePath, part), info, stu.m_B3685B0D); }
private void SaveTex(ExtractFlags flags, string basePath, string part, string filename, ulong key) { if (key == 0) { return; } FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo(); FindLogic.Combo.Find(info, key); info.SetTextureName(key, filename); SaveLogic.Combo.SaveTexture(flags, Path.Combine(basePath, part), info, key); }