public void SaveMaps(ICLIFlags toolFlags) { string basePath; if (toolFlags is ExtractFlags flags) { basePath = flags.OutputPath; } else { throw new Exception("no output path"); } Dictionary <string, Dictionary <string, ParsedArg> > parsedTypes = ParseQuery(flags, QueryTypes, QueryNameOverrides); if (parsedTypes == null) { QueryHelp(QueryTypes); return; } foreach (ulong key in TrackedFiles[0x9F]) { STUMapHeader map = GetInstance <STUMapHeader>(key); if (map == null) { continue; } MapHeader mapInfo = ListMaps.GetMap(key); mapInfo.Name = mapInfo.Name ?? "Title Screen"; Dictionary <string, ParsedArg> config = GetQuery(parsedTypes, mapInfo.Name, mapInfo.VariantName, mapInfo.GetUniqueName(), mapInfo.GetName(), teResourceGUID.Index(map.m_map).ToString("X"), "*"); if (config.Count == 0) { continue; } Map.Save(flags, mapInfo, map, key, basePath); SaveScratchDatabase(); } }
public void SaveMaps(ICLIFlags toolFlags) { string basePath; if (toolFlags is ExtractFlags extractFlags) { basePath = extractFlags.OutputPath; } else { throw new Exception("no output path"); } basePath = Path.Combine(basePath, "Environments"); if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } var flags = extractFlags as ExtractMapEnvFlags ?? new ExtractMapEnvFlags(); if (!flags.SkipMapEnvironmentLUT && File.Exists(Path.Combine(basePath, "SPILUT", "config.ocio"))) { File.Delete(Path.Combine(basePath, "SPILUT", "config.ocio")); } HashSet <KeyValuePair <ulong, string> > done = new HashSet <KeyValuePair <ulong, string> >(); foreach (ulong metaKey in TrackedFiles[0x9F]) { STUMapHeader map = GetInstance <STUMapHeader>(metaKey); if (map == null) { continue; } MapHeader mapInfo = GetMap(metaKey); ulong dataKey = map.m_map; //if (teResourceGUID.Index(dataKey) != 0x7A4) continue; var mapName = GetValidFilename($"{mapInfo.GetName()}_{teResourceGUID.Index(mapInfo.MapGUID):X}"); string fname = $"ow_map_{mapName}"; var reflectionData = Map.GetPlaceableData(map, Enums.teMAP_PLACEABLE_TYPE.REFLECTIONPOINT); if (reflectionData != null) { foreach (var placeable in reflectionData.Placeables ?? Array.Empty <IMapPlaceable>()) { if (!(placeable is teMapPlaceableReflectionPoint reflectionPoint)) { continue; } if (done.Add(new KeyValuePair <ulong, string>(reflectionPoint.Header.Texture1, mapInfo.Name + "cube"))) { SaveTex(extractFlags, basePath, Path.Combine("Cubemap", fname), reflectionPoint.Header.Texture1.ToString(), reflectionPoint.Header.Texture1); } if (done.Add(new KeyValuePair <ulong, string>(reflectionPoint.Header.Texture2, mapInfo.Name + "cube"))) { SaveTex(extractFlags, basePath, Path.Combine("Cubemap", fname), reflectionPoint.Header.Texture2.ToString(), reflectionPoint.Header.Texture2); } } } using (Stream data = OpenFile(dataKey)) { if (data != null) { using (BinaryReader dataReader = new BinaryReader(data)) { teMap env = dataReader.Read <teMap>(); // using (Stream lightingStream = OpenFile(env.BakedLighting)) { // teLightingManifest lightingManifest = new teLightingManifest(lightingStream); //} if (!flags.SkipMapEnvironmentSound && done.Add(new KeyValuePair <ulong, string>(env.MapEnvironmentSound, mapInfo.Name))) { SaveSound(extractFlags, basePath, Path.Combine("Sound", mapName), env.MapEnvironmentSound); } if (!flags.SkipMapEnvironmentLUT && done.Add(new KeyValuePair <ulong, string>(env.LUT, mapInfo.Name))) { SaveTex(extractFlags, basePath, "LUT", fname + env.LUT, env.LUT); SaveLUT(extractFlags, basePath, "SPILUT", fname + env.LUT, env.LUT, Path.Combine(basePath, "SPILUT", "config.ocio"), mapInfo); } if (!flags.SkipMapEnvironmentBlendCubemap && done.Add(new KeyValuePair <ulong, string>(env.BlendEnvironmentCubemap, mapInfo.Name))) { SaveTex(extractFlags, basePath, "BlendCubemap", fname + env.BlendEnvironmentCubemap, env.BlendEnvironmentCubemap); } if (!flags.SkipMapEnvironmentGroundCubemap && done.Add(new KeyValuePair <ulong, string>(env.GroundEnvironmentCubemap, mapInfo.Name))) { SaveTex(extractFlags, basePath, "GroundCubemap", fname + env.GroundEnvironmentCubemap, env.GroundEnvironmentCubemap); } if (!flags.SkipMapEnvironmentSkyCubemap && done.Add(new KeyValuePair <ulong, string>(env.SkyEnvironmentCubemap, mapInfo.Name))) { SaveTex(extractFlags, basePath, "SkyCubemap", fname + env.SkyEnvironmentCubemap, env.SkyEnvironmentCubemap); } if (!flags.SkipMapEnvironmentSkybox && done.Add(new KeyValuePair <ulong, string>(env.SkyboxModel + env.SkyboxModelLook, mapInfo.Name))) { SaveMdl(extractFlags, basePath, Path.Combine("Skybox", mapName), env.SkyboxModel, env.SkyboxModelLook); } if (!flags.SkipMapEnvironmentEntity && done.Add(new KeyValuePair <ulong, string>(env.EntityDefinition, mapInfo.Name))) { SaveEntity(extractFlags, basePath, Path.Combine("Entity", mapName), env.EntityDefinition); } } } } InfoLog("Saved Environment data for {0}", mapInfo.GetUniqueName()); } }
public void SaveMaps(ICLIFlags toolFlags) { string basePath; if (toolFlags is ExtractMapEnvFlags flags) { basePath = flags.OutputPath; } else { throw new Exception("no output path"); } basePath = Path.Combine(basePath, "Environments"); if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } if (!flags.SkipMapEnvironmentLUT && File.Exists(Path.Combine(basePath, "SPILUT", "config.ocio"))) { File.Delete(Path.Combine(basePath, "SPILUT", "config.ocio")); } HashSet <KeyValuePair <ulong, string> > done = new HashSet <KeyValuePair <ulong, string> >(); foreach (ulong metaKey in TrackedFiles[0x9F]) { STUMapHeader map = GetInstance <STUMapHeader>(metaKey); if (map == null) { continue; } MapHeader mapInfo = GetMap(metaKey); ulong dataKey = map.m_map; //if (teResourceGUID.Index(dataKey) != 0x7A4) continue; using (Stream data = OpenFile(dataKey)) { if (data == null) { continue; } using (BinaryReader dataReader = new BinaryReader(data)) { teMap env = dataReader.Read <teMap>(); var mapName = GetValidFilename($"{mapInfo.GetName()}_{teResourceGUID.Index(mapInfo.MapGUID):X}"); string fname = $"ow_map_{mapName}"; //using (Stream lightingStream = OpenFile(env.BakedLighting)) { // teLightingManifest lightingManifest = new teLightingManifest(lightingStream); //} if (!flags.SkipMapEnvironmentSound && done.Add(new KeyValuePair <ulong, string>(env.MapEnvironmentSound, mapInfo.Name))) { SaveSound(flags, basePath, Path.Combine("Sound", mapName), env.MapEnvironmentSound); } if (!flags.SkipMapEnvironmentLUT && done.Add(new KeyValuePair <ulong, string>(env.LUT, mapInfo.Name))) { SaveTex(flags, basePath, "LUT", fname, env.LUT); SaveLUT(flags, basePath, "SPILUT", fname, env.LUT, Path.Combine(basePath, "SPILUT", "config.ocio"), mapInfo); } if (!flags.SkipMapEnvironmentBlendCubemap && done.Add(new KeyValuePair <ulong, string>(env.BlendEnvironmentCubemap, mapInfo.Name))) { SaveTex(flags, basePath, "BlendCubemap", fname, env.BlendEnvironmentCubemap); } if (!flags.SkipMapEnvironmentGroundCubemap && done.Add(new KeyValuePair <ulong, string>(env.GroundEnvironmentCubemap, mapInfo.Name))) { SaveTex(flags, basePath, "GroundCubemap", fname, env.GroundEnvironmentCubemap); } if (!flags.SkipMapEnvironmentSkyCubemap && done.Add(new KeyValuePair <ulong, string>(env.SkyEnvironmentCubemap, mapInfo.Name))) { SaveTex(flags, basePath, "SkyCubemap", fname, env.SkyEnvironmentCubemap); } if (!flags.SkipMapEnvironmentSkybox && done.Add(new KeyValuePair <ulong, string>(env.SkyboxModel ^ env.SkyboxModelLook, mapInfo.Name))) { SaveMdl(flags, basePath, Path.Combine("Skybox", mapName), env.SkyboxModel, env.SkyboxModelLook); } if (!flags.SkipMapEnvironmentEntity && done.Add(new KeyValuePair <ulong, string>(env.EntityDefinition, mapInfo.Name))) { SaveEntity(flags, basePath, Path.Combine("Entity", mapName), env.EntityDefinition); } InfoLog("Saved Environment data for {0}", mapInfo.GetUniqueName()); } } } }