public void LoadModels(Dictionary <uint, Drawable> dict) { DrawableDict = dict; LightsTreeView.Nodes.Clear(); if (dict != null) { foreach (var kvp in dict) { MetaHash mhash = new MetaHash(kvp.Key); var drawable = kvp.Value; var dnode = LightsTreeView.Nodes.Add(mhash.ToString()); dnode.Tag = drawable; var lights = drawable.LightAttributes.data_items; if (lights != null) { AddLightsTreeNodes(lights, dnode); } dnode.Expand(); } } }
public void Init(string name, GameFileCache gfc, bool hidef = true) { Name = name; var modelnamel = name.ToLowerInvariant(); MetaHash modelhash = JenkHash.GenHash(modelnamel); MetaHash modelhashhi = JenkHash.GenHash(modelnamel + "_hi"); var ydrhash = hidef ? modelhashhi : modelhash; NameHash = modelhash; ModelHash = ydrhash; var useHash = ModelHash; Ydr = gfc.GetYdr(ModelHash); if (Ydr == null) { useHash = NameHash; Ydr = gfc.GetYdr(NameHash); } while ((Ydr != null) && (!Ydr.Loaded)) { Thread.Sleep(20);//kinda hacky Ydr = gfc.GetYdr(useHash); } if (Ydr != null) { Drawable = Ydr.Drawable?.ShallowCopy() as Drawable; } UpdateEntity(); }
public void LoadModels(Dictionary <uint, Drawable> dict) { DrawableDict = dict; ModelsTreeView.Nodes.Clear(); //ModelsTreeView.ShowRootLines = true; if (dict != null) { foreach (var kvp in dict) { MetaHash mhash = new MetaHash(kvp.Key); var drawable = kvp.Value; var dnode = ModelsTreeView.Nodes.Add(mhash.ToString()); dnode.Tag = drawable; AddDrawableModelsTreeNodes(drawable.DrawableModels?.High, "High Detail", dnode); AddDrawableModelsTreeNodes(drawable.DrawableModels?.Med, "Medium Detail", dnode); AddDrawableModelsTreeNodes(drawable.DrawableModels?.Low, "Low Detail", dnode); AddDrawableModelsTreeNodes(drawable.DrawableModels?.VLow, "Very Low Detail", dnode); dnode.Expand(); } } }
public void Init(string name, GameFileCache gfc, bool hidef = true) { Name = name; var modelnamel = name.ToLowerInvariant(); MetaHash modelhash = JenkHash.GenHash(modelnamel); MetaHash modelhashhi = JenkHash.GenHash(modelnamel + "_hi"); var yfthash = hidef ? modelhashhi : modelhash; VehicleInitData vid = null; if (gfc.VehiclesInitDict.TryGetValue(modelhash, out vid)) { bool vehiclechange = NameHash != modelhash; ConvRoofDict = null; ConvRoofClip = null; ModelHash = yfthash; NameHash = modelhash; InitData = vid; Yft = gfc.GetYft(ModelHash); while ((Yft != null) && (!Yft.Loaded)) { Thread.Sleep(20);//kinda hacky Yft = gfc.GetYft(ModelHash); } DisplayMake = GlobalText.TryGetString(JenkHash.GenHash(vid.vehicleMakeName.ToLowerInvariant())); DisplayName = GlobalText.TryGetString(JenkHash.GenHash(vid.gameName.ToLowerInvariant())); if (!string.IsNullOrEmpty(vid.animConvRoofDictName) && (vid.animConvRoofDictName.ToLowerInvariant() != "null")) { var ycdhash = JenkHash.GenHash(vid.animConvRoofDictName.ToLowerInvariant()); var cliphash = JenkHash.GenHash(vid.animConvRoofName?.ToLowerInvariant()); ConvRoofDict = gfc.GetYcd(ycdhash); while ((ConvRoofDict != null) && (!ConvRoofDict.Loaded)) { Thread.Sleep(20);//kinda hacky ConvRoofDict = gfc.GetYcd(ycdhash); } ClipMapEntry cme = null; ConvRoofDict?.ClipMap?.TryGetValue(cliphash, out cme); ConvRoofClip = cme; } } else { ModelHash = 0; NameHash = 0; InitData = null; Yft = null; DisplayMake = "-"; DisplayName = "-"; ConvRoofDict = null; ConvRoofClip = null; } UpdateEntity(); }
private void addButton_Click(object sender, EventArgs e) { float posX = (float)numericX.Value; float posY = (float)numericY.Value; float posZ = (float)numericZ.Value; float rotX = (float)numericRotX.Value; float rotY = (float)numericRotY.Value; float rotZ = (float)numericRotZ.Value; string model = modelTextBox.Text; if (string.IsNullOrEmpty(model)) { MessageBox.Show("Please provide a model name."); return; } bool deleteEntity = deleteCheckbox.Checked; string replaceModel = replaceModelTextBox.Text; if (!deleteEntity && string.IsNullOrEmpty(replaceModel)) { MessageBox.Show("You forgot to put a replacement model."); return; } if (deleteEntity) { listBoxFiles.Items.Add(model + " will be deleted."); MetaHash hashConv = GetMetaHash2(model); deleteList.Add(hashConv); } else { listBoxFiles.Items.Add(model + " will be replaced by " + replaceModel + ". XYZ: " + posX + " " + posY + " " + posZ + " | Rotation: " + rotX + " " + rotY + " " + rotZ); replaceList.Add(new ReplaceEntity(model, replaceModel, posX, posY, posZ, rotX, rotY, rotZ)); } deleteCheckbox.Checked = false; replaceModelTextBox.Text = ""; modelTextBox.Text = ""; numericRotX.Value = 0; numericRotY.Value = 0; numericRotZ.Value = 0; numericX.Value = 0; numericY.Value = 0; numericZ.Value = 0; }
private void AddDrawableTreeNode(DrawableBase drawable, uint hash, bool check) { MetaHash mhash = new MetaHash(hash); var dnode = ModelsTreeView.Nodes.Add(mhash.ToString()); dnode.Tag = drawable; dnode.Checked = check; AddDrawableModelsTreeNodes(drawable.DrawableModels?.High, "High Detail", true, dnode); AddDrawableModelsTreeNodes(drawable.DrawableModels?.Med, "Medium Detail", false, dnode); AddDrawableModelsTreeNodes(drawable.DrawableModels?.Low, "Low Detail", false, dnode); AddDrawableModelsTreeNodes(drawable.DrawableModels?.VLow, "Very Low Detail", false, dnode); //AddDrawableModelsTreeNodes(drawable.DrawableModels?.Extra, "X Detail", false, dnode); }
private void CarPopGroupTextBox_TextChanged(object sender, EventArgs e) { if (populatingui) { return; } if (CurrentCarGen == null) { return; } uint hash = 0; string name = CarPopGroupTextBox.Text; if (!uint.TryParse(name, out hash))//don't re-hash hashes { hash = JenkHash.GenHash(name); JenkIndex.Ensure(name); } CarPopGroupHashLabel.Text = "Hash: " + hash.ToString(); //var grp = GameFileCache.GetCarPopGroup(hash); //todo: something like this for popgroup info? //if (grp == null) //{ // CarPopGroupHashLabel.Text += " (not found)"; //} if (CurrentCarGen != null) { lock (ProjectForm.ProjectSyncRoot) { var pghash = new MetaHash(hash); if (CurrentCarGen._CCarGen.popGroup != pghash) { CurrentCarGen._CCarGen.popGroup = pghash; ProjectForm.SetYmapHasChanged(true); } } } ProjectForm.ProjectExplorer?.UpdateCarGenTreeNode(CurrentCarGen); }
public void LoadVehicle() { var modelname = VehicleModelComboBox.Text; var modelnamel = modelname.ToLowerInvariant(); MetaHash modelhash = JenkHash.GenHash(modelnamel); MetaHash modelhashhi = JenkHash.GenHash(modelnamel + "_hi"); bool hidet = VehicleHighDetailCheckBox.Checked; var yfthash = hidet ? modelhashhi : modelhash; VehicleInitData vid = null; if (GameFileCache.VehiclesInitDict.TryGetValue(modelhash, out vid)) { bool vehiclechange = SelectedVehicleHash != modelhash; SelectedModelHash = yfthash; SelectedVehicleHash = modelhash; SelectedVehicleInit = vid; SelectedVehicleYft = GameFileCache.GetYft(SelectedModelHash); while ((SelectedVehicleYft != null) && (!SelectedVehicleYft.Loaded)) { Thread.Sleep(20);//kinda hacky SelectedVehicleYft = GameFileCache.GetYft(SelectedModelHash); } LoadModel(SelectedVehicleYft, vehiclechange); VehicleMakeLabel.Text = GlobalText.TryGetString(JenkHash.GenHash(vid.vehicleMakeName.ToLower())); VehicleNameLabel.Text = GlobalText.TryGetString(JenkHash.GenHash(vid.gameName.ToLower())); } else { SelectedModelHash = 0; SelectedVehicleHash = 0; SelectedVehicleInit = null; SelectedVehicleYft = null; VehicleMakeLabel.Text = "-"; VehicleNameLabel.Text = "-"; } }
public void SetComponentDrawable(int index, string name, string tex, GameFileCache gfc) { if (string.IsNullOrEmpty(name)) { DrawableNames[index] = null; Drawables[index] = null; Textures[index] = null; Expressions[index] = null; return; } MetaHash namehash = JenkHash.GenHash(name.ToLowerInvariant()); Drawable d = null; if (Ydd?.Dict != null) { Ydd.Dict.TryGetValue(namehash, out d); } if ((d == null) && (DrawableFilesDict != null)) { RpfFileEntry file = null; if (DrawableFilesDict.TryGetValue(namehash, out file)) { var ydd = gfc.GetFileUncached <YddFile>(file); while ((ydd != null) && (!ydd.Loaded)) { Thread.Sleep(1);//kinda hacky gfc.TryLoadEnqueue(ydd); } if (ydd?.Drawables?.Length > 0) { d = ydd.Drawables[0];//should only be one in this dict } } } MetaHash texhash = JenkHash.GenHash(tex.ToLowerInvariant()); Texture t = null; if (Ytd?.TextureDict?.Dict != null) { Ytd.TextureDict.Dict.TryGetValue(texhash, out t); } if ((t == null) && (TextureFilesDict != null)) { RpfFileEntry file = null; if (TextureFilesDict.TryGetValue(texhash, out file)) { var ytd = gfc.GetFileUncached <YtdFile>(file); while ((ytd != null) && (!ytd.Loaded)) { Thread.Sleep(1);//kinda hacky gfc.TryLoadEnqueue(ytd); } if (ytd?.TextureDict?.Textures?.data_items.Length > 0) { t = ytd.TextureDict.Textures.data_items[0];//should only be one in this dict } } } CharacterCloth cc = null; if (Yld?.Dict != null) { Yld.Dict.TryGetValue(namehash, out cc); } if ((cc == null) && (ClothFilesDict != null)) { RpfFileEntry file = null; if (ClothFilesDict.TryGetValue(namehash, out file)) { var yld = gfc.GetFileUncached <YldFile>(file); while ((yld != null) && (!yld.Loaded)) { Thread.Sleep(1);//kinda hacky gfc.TryLoadEnqueue(yld); } if (yld?.ClothDictionary?.Clothes?.data_items?.Length > 0) { cc = yld.ClothDictionary.Clothes.data_items[0];//should only be one in this dict } } } ClothInstance c = null; if (cc != null) { c = new ClothInstance(); c.Init(cc, Skeleton); } Expression e = null; if (Yed?.ExprMap != null) { Yed.ExprMap.TryGetValue(namehash, out e); } if (d != null) { Drawables[index] = d.ShallowCopy() as Drawable; } if (t != null) { Textures[index] = t; } if (c != null) { Clothes[index] = c; } if (e != null) { Expressions[index] = e; } DrawableNames[index] = name; }
public void Init(MetaHash pedhash, GameFileCache gfc) { Name = string.Empty; NameHash = 0; InitData = null; Ydd = null; Ytd = null; Yld = null; Ycd = null; Yed = null; Yft = null; Ymt = null; AnimClip = null; for (int i = 0; i < 12; i++) { Drawables[i] = null; Textures[i] = null; Expressions[i] = null; } CPedModelInfo__InitData initdata = null; if (!gfc.PedsInitDict.TryGetValue(pedhash, out initdata)) { return; } var ycdhash = JenkHash.GenHash(initdata.ClipDictionaryName.ToLowerInvariant()); var yedhash = JenkHash.GenHash(initdata.ExpressionDictionaryName.ToLowerInvariant()); //bool pedchange = NameHash != pedhash; //Name = pedname; NameHash = pedhash; InitData = initdata; Ydd = gfc.GetYdd(pedhash); Ytd = gfc.GetYtd(pedhash); Ycd = gfc.GetYcd(ycdhash); Yed = gfc.GetYed(yedhash); Yft = gfc.GetYft(pedhash); PedFile pedFile = null; gfc.PedVariationsDict?.TryGetValue(pedhash, out pedFile); Ymt = pedFile; Dictionary <MetaHash, RpfFileEntry> peddict = null; gfc.PedDrawableDicts.TryGetValue(NameHash, out peddict); DrawableFilesDict = peddict; DrawableFiles = DrawableFilesDict?.Values.ToArray(); gfc.PedTextureDicts.TryGetValue(NameHash, out peddict); TextureFilesDict = peddict; TextureFiles = TextureFilesDict?.Values.ToArray(); gfc.PedClothDicts.TryGetValue(NameHash, out peddict); ClothFilesDict = peddict; ClothFiles = ClothFilesDict?.Values.ToArray(); RpfFileEntry clothFile = null; if (ClothFilesDict?.TryGetValue(pedhash, out clothFile) ?? false) { Yld = gfc.GetFileUncached <YldFile>(clothFile); while ((Yld != null) && (!Yld.Loaded)) { Thread.Sleep(1);//kinda hacky gfc.TryLoadEnqueue(Yld); } } while ((Ydd != null) && (!Ydd.Loaded)) { Thread.Sleep(1);//kinda hacky Ydd = gfc.GetYdd(pedhash); } while ((Ytd != null) && (!Ytd.Loaded)) { Thread.Sleep(1);//kinda hacky Ytd = gfc.GetYtd(pedhash); } while ((Ycd != null) && (!Ycd.Loaded)) { Thread.Sleep(1);//kinda hacky Ycd = gfc.GetYcd(ycdhash); } while ((Yed != null) && (!Yed.Loaded)) { Thread.Sleep(1);//kinda hacky Yed = gfc.GetYed(yedhash); } while ((Yft != null) && (!Yft.Loaded)) { Thread.Sleep(1);//kinda hacky Yft = gfc.GetYft(pedhash); } Skeleton = Yft?.Fragment?.Drawable?.Skeleton?.Clone(); MetaHash cliphash = JenkHash.GenHash("idle"); ClipMapEntry cme = null; Ycd?.ClipMap?.TryGetValue(cliphash, out cme); AnimClip = cme; var exprhash = JenkHash.GenHash(initdata.ExpressionName.ToLowerInvariant()); Expression expr = null; Yed?.ExprMap?.TryGetValue(exprhash, out expr); Expression = expr; UpdateEntity(); }
public void Init(GameFileCache gameFileCache, XmlNode node) { Name = Xml.GetChildInnerText(node, "Name"); NameHash = new MetaHash(JenkHash.GenHash(Name.ToLower())); Sun = Xml.GetChildFloatAttribute(node, "Sun", "value"); Cloud = Xml.GetChildFloatAttribute(node, "Cloud", "value"); WindMin = Xml.GetChildFloatAttribute(node, "WindMin", "value"); WindMax = Xml.GetChildFloatAttribute(node, "WindMax", "value"); Rain = Xml.GetChildFloatAttribute(node, "Rain", "value"); Snow = Xml.GetChildFloatAttribute(node, "Snow", "value"); SnowMist = Xml.GetChildFloatAttribute(node, "SnowMist", "value"); Fog = Xml.GetChildFloatAttribute(node, "Fog", "value"); RippleBumpiness = Xml.GetChildFloatAttribute(node, "RippleBumpiness", "value"); RippleMinBumpiness = Xml.GetChildFloatAttribute(node, "RippleMinBumpiness", "value"); RippleMaxBumpiness = Xml.GetChildFloatAttribute(node, "RippleMaxBumpiness", "value"); RippleBumpinessWindScale = Xml.GetChildFloatAttribute(node, "RippleBumpinessWindScale", "value"); RippleScale = Xml.GetChildFloatAttribute(node, "RippleScale", "value"); RippleSpeed = Xml.GetChildFloatAttribute(node, "RippleSpeed", "value"); RippleVelocityTransfer = Xml.GetChildFloatAttribute(node, "RippleVelocityTransfer", "value"); OceanBumpiness = Xml.GetChildFloatAttribute(node, "OceanBumpiness", "value"); DeepOceanScale = Xml.GetChildFloatAttribute(node, "DeepOceanScale", "value"); OceanNoiseMinAmplitude = Xml.GetChildFloatAttribute(node, "OceanNoiseMinAmplitude", "value"); OceanWaveAmplitude = Xml.GetChildFloatAttribute(node, "OceanWaveAmplitude", "value"); ShoreWaveAmplitude = Xml.GetChildFloatAttribute(node, "ShoreWaveAmplitude", "value"); OceanWaveWindScale = Xml.GetChildFloatAttribute(node, "OceanWaveWindScale", "value"); ShoreWaveWindScale = Xml.GetChildFloatAttribute(node, "ShoreWaveWindScale", "value"); OceanWaveMinAmplitude = Xml.GetChildFloatAttribute(node, "OceanWaveMinAmplitude", "value"); ShoreWaveMinAmplitude = Xml.GetChildFloatAttribute(node, "ShoreWaveMinAmplitude", "value"); OceanWaveMaxAmplitude = Xml.GetChildFloatAttribute(node, "OceanWaveMaxAmplitude", "value"); ShoreWaveMaxAmplitude = Xml.GetChildFloatAttribute(node, "ShoreWaveMaxAmplitude", "value"); OceanFoamIntensity = Xml.GetChildFloatAttribute(node, "OceanFoamIntensity", "value"); OceanFoamScale = Xml.GetChildFloatAttribute(node, "OceanFoamScale", "value"); RippleDisturb = Xml.GetChildFloatAttribute(node, "RippleDisturb", "value"); Lightning = Xml.GetChildFloatAttribute(node, "Lightning", "value"); Sandstorm = Xml.GetChildFloatAttribute(node, "Sandstorm", "value"); OldSettingName = Xml.GetChildInnerText(node, "OldSettingName"); DropSettingName = Xml.GetChildInnerText(node, "DropSettingName"); MistSettingName = Xml.GetChildInnerText(node, "MistSettingName"); GroundSettingName = Xml.GetChildInnerText(node, "GroundSettingName"); TimeCycleFilename = Xml.GetChildInnerText(node, "TimeCycleFilename"); CloudSettingsName = Xml.GetChildInnerText(node, "CloudSettingsName"); if (!string.IsNullOrEmpty(TimeCycleFilename)) { //TODO: RpfMan should be able to get the right version? or maybe let gameFileCache do it! string fname = TimeCycleFilename.ToLower(); bool useupd = gameFileCache.EnableDlc; if (useupd) { fname = fname.Replace("common:", "update/update.rpf/common"); } XmlDocument tcxml = gameFileCache.RpfMan.GetFileXml(fname); if (useupd && !tcxml.HasChildNodes) { fname = TimeCycleFilename.ToLower(); tcxml = gameFileCache.RpfMan.GetFileXml(fname); } foreach (XmlNode cycle in tcxml.DocumentElement.ChildNodes) { TimeCycleData = new WeatherCycleKeyframeData(); TimeCycleData.Init(cycle); } } }
public void BuildContent() { try { Assets assets = new Assets(SourceFile); string relativePath = SourceFile.Replace(Program.Arguments.WorkingDirectory, "").Trim('/', '\\'); string relativePathWithoutExtension = relativePath.Contains(".") ? relativePath.Remove(relativePath.LastIndexOf('.')) : relativePath; string relativeDirWithoutExtension = relativePath.Contains("/") || relativePath.Contains("\\") ? relativePath.Remove(relativePath.LastIndexOfAny(new char[] { '/', '\\' })) : ""; string tempImporter = null; string tempProcessor = null; Dictionary <string, string> tempProcessorParam = new Dictionary <string, string>(); if (!FirstBuild) { tempImporter = Importer; tempProcessor = Processor; tempProcessorParam.Union(ProcessorParam); ProcessorParam.Clear(); if (!File.Exists(SourceFile)) { DeleteFlag = true; } else if (!BuildTool.Equals(Program.Arguments.BuildTool.ToString(), StringComparison.OrdinalIgnoreCase)) { BuildTool = Program.Arguments.BuildTool.ToString(); RebuildFlag = true; } else { string newHash; using (FileStream fileStream = new FileStream(SourceFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) newHash = fileStream.ToMD5(); if (!MetaHash.Equals(newHash, StringComparison.OrdinalIgnoreCase)) { MetaHash = newHash; RebuildFlag = true; } else { List <string> fileToCheck = new List <string>(); if (DestinationFile != null) { fileToCheck.Add(DestinationFile.GetFullPath()); } fileToCheck = fileToCheck.Union(BuildOutput).Union(BuildAsset).ToList(); foreach (string file in fileToCheck) { if (!File.Exists(file)) { RebuildFlag = true; break; } } } } } else { using (FileStream fileStream = new FileStream(SourceFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) MetaHash = fileStream.ToMD5(); } #if MonoGame if (assets.IsEffectAssets()) { // Effect Importer - MonoGame string temp; using (StreamReader reader = new StreamReader(new FileStream(SourceFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8)) temp = reader.ReadToEnd(); temp = temp.Replace("vs_1_1", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "vs_2_0" : "vs_4_0"); temp = temp.Replace("vs_2_0", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "vs_2_0" : "vs_4_0"); temp = temp.Replace("vs_4_0", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "vs_2_0" : "vs_4_0"); temp = temp.Replace("ps_1_1", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "ps_2_0" : "ps_4_0"); temp = temp.Replace("ps_2_0", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "ps_2_0" : "ps_4_0"); temp = temp.Replace("ps_4_0", Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase) ? "ps_2_0" : "ps_4_0"); using (StreamWriter Writer = new StreamWriter(new FileStream(SourceFile, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite), Encoding.UTF8) { AutoFlush = true }) Writer.Write(temp); temp = null; Importer = "EffectImporter"; Processor = "EffectProcessor"; ProcessorParam.Add("DebugMode", "Auto"); } else if (assets.IsFbxModelAssets()) { // Fbx Importer - MonoGame Importer = "FbxImporter"; Processor = "ModelProcessor"; ProcessorParam.Add("ColorKeyColor", "0,0,0,0"); ProcessorParam.Add("ColorKeyEnabled", "True"); ProcessorParam.Add("DefaultEffect", "BasicEffect"); ProcessorParam.Add("GenerateMipmaps", "True"); ProcessorParam.Add("GenerateTangentFrames", "False"); ProcessorParam.Add("PremultiplyTextureAlpha", "True"); ProcessorParam.Add("PremultiplyVertexColors", "True"); ProcessorParam.Add("ResizeTexturesToPowerOfTwo", "False"); ProcessorParam.Add("RotationX", "0"); ProcessorParam.Add("RotationY", "0"); ProcessorParam.Add("RotationZ", "0"); ProcessorParam.Add("Scale", "1"); ProcessorParam.Add("SwapWindingOrder", "False"); ProcessorParam.Add("TextureFormat", "Color"); } else if (assets.IsXModelAssets()) { // X Importer - MonoGame Importer = "XImporter"; Processor = "ModelProcessor"; ProcessorParam.Add("ColorKeyColor", "0,0,0,0"); ProcessorParam.Add("ColorKeyEnabled", "True"); ProcessorParam.Add("DefaultEffect", "BasicEffect"); ProcessorParam.Add("GenerateMipmaps", "True"); ProcessorParam.Add("GenerateTangentFrames", "False"); ProcessorParam.Add("PremultiplyTextureAlpha", "True"); ProcessorParam.Add("PremultiplyVertexColors", "True"); ProcessorParam.Add("ResizeTexturesToPowerOfTwo", "False"); ProcessorParam.Add("RotationX", "0"); ProcessorParam.Add("RotationY", "0"); ProcessorParam.Add("RotationZ", "0"); ProcessorParam.Add("Scale", "1"); ProcessorParam.Add("SwapWindingOrder", "False"); ProcessorParam.Add("TextureFormat", "Color"); } else if (assets.IsOpenModelAssets()) { // Open Asset Import Library - MonoGame Importer = "OpenAssetImporter"; Processor = "ModelProcessor"; ProcessorParam.Add("ColorKeyColor", "0,0,0,0"); ProcessorParam.Add("ColorKeyEnabled", "True"); ProcessorParam.Add("DefaultEffect", "BasicEffect"); ProcessorParam.Add("GenerateMipmaps", "True"); ProcessorParam.Add("GenerateTangentFrames", "False"); ProcessorParam.Add("PremultiplyTextureAlpha", "True"); ProcessorParam.Add("PremultiplyVertexColors", "True"); ProcessorParam.Add("ResizeTexturesToPowerOfTwo", "False"); ProcessorParam.Add("RotationX", "0"); ProcessorParam.Add("RotationY", "0"); ProcessorParam.Add("RotationZ", "0"); ProcessorParam.Add("Scale", "1"); ProcessorParam.Add("SwapWindingOrder", "False"); ProcessorParam.Add("TextureFormat", "Color"); } else if (assets.IsSpriteFontAssets()) { // Sprite Font Importer - MonoGame Importer = "FontDescriptionImporter"; Processor = "FontDescriptionProcessor"; ProcessorParam.Add("TextureFormat", "Color"); } else if (assets.IsTextureAssets()) { // Texture Importer - MonoGame if (assets.IsFontAssets()) { Importer = "TextureImporter"; Processor = "FontTextureProcessor"; ProcessorParam.Add("FirstCharacter", " "); ProcessorParam.Add("PremultiplyAlpha", "True"); ProcessorParam.Add("TextureFormat", "Color"); } else { Importer = "TextureImporter"; Processor = "TextureProcessor"; ProcessorParam.Add("ColorKeyColor", "255,0,255,255"); ProcessorParam.Add("ColorKeyEnabled", "True"); ProcessorParam.Add("GenerateMipmaps", "False"); ProcessorParam.Add("PremultiplyAlpha", "True"); ProcessorParam.Add("ResizeToPowerOfTwo", "False"); ProcessorParam.Add("MakeSquare", "False"); ProcessorParam.Add("TextureFormat", "Color"); } } else if (assets.IsMp3Assets()) { // Mp3 Importer - MonoGame if (assets.IsMusicAssets()) { Importer = "Mp3Importer"; Processor = "SongProcessor"; ProcessorParam.Add("Quality", "Low"); } else if (assets.IsSoundAssets()) { Importer = "Mp3Importer"; Processor = "SoundEffectProcessor"; ProcessorParam.Add("Quality", "Low"); } } else if (assets.IsOggAssets()) { // Ogg Importer - MonoGame if (assets.IsMusicAssets()) { Importer = "OggImporter"; Processor = "SongProcessor"; ProcessorParam.Add("Quality", "Low"); } else if (assets.IsSoundAssets()) { Importer = "OggImporter"; Processor = "SoundEffectProcessor"; ProcessorParam.Add("Quality", "Low"); } } else if (assets.IsWavAssets()) { // Wav Importer - MonoGame if (assets.IsMusicAssets()) { Importer = "WavImporter"; Processor = "SongProcessor"; ProcessorParam.Add("Quality", "Low"); } else if (assets.IsSoundAssets()) { Importer = "WavImporter"; Processor = "SoundEffectProcessor"; ProcessorParam.Add("Quality", "Low"); } } else if (assets.IsWmaAssets()) { // Wma Importer - MonoGame if (assets.IsMusicAssets()) { Importer = "WmaImporter"; Processor = "SongProcessor"; ProcessorParam.Add("Quality", "Low"); } else if (assets.IsSoundAssets()) { Importer = "WmaImporter"; Processor = "SoundEffectProcessor"; ProcessorParam.Add("Quality", "Low"); } } else if (assets.IsMp4Assets()) { // H.264 Video - MonoGame Importer = "H264Importer"; Processor = "VideoProcessor"; } else if (assets.IsWmvAssets()) { // Wmv Importer - MonoGame Importer = "WmvImporter"; Processor = "VideoProcessor"; } else if (assets.IsXMLAssets()) { // Xml Importer - MonoGame Importer = "XmlImporter"; Processor = "PassThroughProcessor"; } if (!FirstBuild) { if (Importer != null && Processor != null) { if (!tempImporter.Equals(Importer, StringComparison.OrdinalIgnoreCase) || !tempProcessor.Equals(Processor, StringComparison.OrdinalIgnoreCase) || tempProcessorParam.Select(a => a.Key + "=" + a.Value).Join(";").Equals(ProcessorParam.Select(a => a.Key + "=" + a.Value).Join(";"), StringComparison.OrdinalIgnoreCase)) { RebuildFlag = true; } } tempImporter = null; tempProcessor = null; tempProcessorParam = null; } #endif if (RebuildFlag || DeleteFlag) { CleanFile(); } if (Importer.IsNullOrEmpty() || Processor.IsNullOrEmpty()) { DestinationFile = (Program.Arguments.OutputDirectory + "/" + relativePath).GetFullPath(); } else { DestinationFile = (Program.Arguments.OutputDirectory + "/" + relativePathWithoutExtension + ".xnb").GetFullPath(); } if (RebuildFlag || Program.Arguments.Rebuild) { if (Importer.IsNullOrEmpty() || Processor.IsNullOrEmpty()) { DirectoryHelper.CreateDirectoryIfNotExists((Program.Arguments.OutputDirectory + "/" + relativeDirWithoutExtension).GetFullPath()); if (!Program.Arguments.Quiet) { Console.WriteLine("Copying: " + relativePath); } using (FileStream fileStream = new FileStream(SourceFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (FileStream fileStream2 = new FileStream((Program.Arguments.OutputDirectory + "/" + relativePath).GetFullPath(), FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite)) fileStream.CopyTo(fileStream2); } BuildSuccess = true; } else { #if MonoGame PipelineManager manager = new PipelineManager(Program.Arguments.WorkingDirectory, Program.Arguments.OutputDirectory, Program.Arguments.IntermediateDirectory) { CompressContent = Program.Arguments.Compress }; if (Program.Arguments.Platform.Equals("DesktopGL", StringComparison.OrdinalIgnoreCase)) { manager.Platform = TargetPlatform.DesktopGL; } else if (Program.Arguments.Platform.Equals("Windows", StringComparison.OrdinalIgnoreCase)) { manager.Platform = TargetPlatform.Windows; } if (Program.Arguments.Profile.Equals("Reach", StringComparison.OrdinalIgnoreCase)) { manager.Profile = GraphicsProfile.Reach; } else if (Program.Arguments.Profile.Equals("HiDef", StringComparison.OrdinalIgnoreCase)) { manager.Profile = GraphicsProfile.HiDef; } OpaqueDataDictionary Param = new OpaqueDataDictionary(); foreach (KeyValuePair <string, string> item in ProcessorParam) { Param.Add(item.Key, item.Value); } try { if (!Program.Arguments.Quiet) { Console.WriteLine("Building: " + relativePath); } PipelineBuildEvent buildResult = manager.BuildContent(SourceFile, null, Importer, Processor, Param); BuildAsset = buildResult.BuildAsset; BuildOutput = buildResult.BuildOutput; BuildSuccess = true; } catch (Exception ex) { if (!Program.Arguments.Quiet) { Console.Error.WriteLine("Content Error (" + relativePath + "): " + ex.Message); } BuildSuccess = false; } #endif } } else if (DeleteFlag) { BuildSuccess = true; } else { if (!Program.Arguments.Quiet) { Console.WriteLine("Skip: " + relativePath); } BuildSuccess = true; } } catch (Exception ex) { Console.Error.WriteLine(ex.Message); Console.Error.WriteLine(); Console.Error.WriteLine(ex.StackTrace); } }
private void replaceButton_Click(object sender, EventArgs e) { if (replaceList.Count == 0) { return; } if (listBoxPath.Items.Count == 0) { MessageBox.Show("The path is not valid."); return; } fileList = new List <string>(); foreach (string path in listBoxPath.Items) { DirSearch(path); } int fileCount = fileList.Count; if (fileCount <= 0) { MessageBox.Show("This path is empty."); return; } progressBar1.Maximum = fileCount - 1; progressBar1.Minimum = 1; progressBar1.Step = 1; progressBar1.Value = 1; new Thread(() => { Thread.CurrentThread.IsBackground = true; foreach (string filePath in fileList) { bool modificationsMade = false; YmapFile ymap = new YmapFile(); byte[] ymapBytes = File.ReadAllBytes(filePath); ymap.Load(ymapBytes); ymap.Name = Path.GetFileNameWithoutExtension(filePath); YmapEntityDef[] entities = ymap.AllEntities; if (entities == null) { continue; } foreach (YmapEntityDef entity in entities) { MetaHash modelName = entity._CEntityDef.archetypeName; foreach (ReplaceEntity entityData in replaceList) { MetaHash hash = GetMetaHash2(entityData.model); if (hash == modelName) { MetaHash newHash = GetMetaHash2(entityData.newModel); entity._CEntityDef.archetypeName = new MetaHash(newHash); entity.SetPosition(entity.Position + new Vector3(0.0f + entityData.posX, 0.0f + entityData.posY, 0.0f + entityData.posZ)); if (entityData.rotX != 0.0 || entityData.rotY != 0.0 || entityData.rotZ != 0.0) { Quaternion angle = AngleToQuaternion(entityData.rotX, entityData.rotY, entityData.rotZ); Quaternion newRot = Quaternion.Multiply(entity.Orientation, angle); newRot.Normalize(); entity.SetOrientation(newRot); } listBoxLogs.Items.Add("Replaced " + modelName + " by " + entityData.newModel + " in " + ymap.Name + "."); if (!modificationsMade) { modificationsMade = true; } break; } } if (deleteList.Contains(modelName)) { ymap.RemoveEntity(entity); Console.WriteLine("Deleted " + modelName); listBoxLogs.Items.Add("Deleted " + modelName + " from: " + ymap.Name + "."); if (!modificationsMade) { modificationsMade = true; } } } if (modificationsMade) { byte[] newBytes = ymap.Save(); File.WriteAllBytes(filePath, newBytes); } progressBar1.PerformStep(); } MessageBox.Show("Success!"); }).Start(); }