private void menuCarmageddonReincarnationClick(object sender, EventArgs e) { ToolStripMenuItem mi = (ToolStripMenuItem)sender; SceneManager.Current.SetCoordinateSystem(SceneManager.CoordinateSystem.LeftHanded); switch (mi.Text) { case "Accessory": ofdBrowse.Filter = "Carmageddon ReinCARnation Accessory files (accessory.cnt)|accessory.cnt"; if (ofdBrowse.ShowDialog() == DialogResult.OK && File.Exists(ofdBrowse.FileName)) { SceneManager.Current.Reset(); var accessory = SceneManager.Current.Add(SceneManager.Current.Content.Load <Model, CNTImporter>(Path.GetFileName(ofdBrowse.FileName), Path.GetDirectoryName(ofdBrowse.FileName))); string accessorytxt = ofdBrowse.FileName.Replace(".cnt", ".txt", StringComparison.OrdinalIgnoreCase); if (File.Exists(accessorytxt)) { accessory.SupportingDocuments["Accessory"] = ToxicRagers.CarmageddonReincarnation.Formats.Accessory.Load(accessorytxt); } SceneManager.Current.SetContext(ContextGame.Carmageddon_Reincarnation, ContextMode.Accessory); } break; case "Environment": openContent("Carmageddon ReinCARnation Environment files (level.cnt)|level.cnt"); break; case "Pedestrian": openContent("Carmageddon ReinCARnation Pedestrians (bodyform.cnt)|bodyform.cnt"); break; case "Vehicle": ofdBrowse.Filter = "Carmageddon ReinCARnation Vehicles (car.cnt)|car.cnt"; if (ofdBrowse.ShowDialog() == DialogResult.OK && File.Exists(ofdBrowse.FileName)) { SceneManager.Current.Reset(); string assetFolder = Path.GetDirectoryName(ofdBrowse.FileName) + "\\"; var vehicle = (Model)SceneManager.Current.Add(SceneManager.Current.Content.Load <Model, CNTImporter>(Path.GetFileName(ofdBrowse.FileName), assetFolder)); // Load supporting documents if (File.Exists(assetFolder + "setup.lol")) { vehicle.SupportingDocuments["Setup"] = ToxicRagers.CarmageddonReincarnation.Formats.Setup.Load(assetFolder + "setup.lol"); } if (File.Exists(assetFolder + "Structure.xml")) { vehicle.SupportingDocuments["Structure"] = ToxicRagers.CarmageddonReincarnation.Formats.Structure.Load(assetFolder + "Structure.xml"); } if (File.Exists(assetFolder + "SystemsDamage.xml")) { vehicle.SupportingDocuments["SystemsDamage"] = ToxicRagers.CarmageddonReincarnation.Formats.SystemsDamage.Load(assetFolder + "SystemsDamage.xml"); } if (File.Exists(assetFolder + "vehicle_setup.cfg")) { vehicle.SupportingDocuments["VehicleSetupConfig"] = ToxicRagers.CarmageddonReincarnation.Formats.VehicleSetupConfig.Load(assetFolder + "vehicle_setup.cfg"); } foreach (var bone in vehicle.Bones) { string boneName = bone.Name.ToLower(); if (boneName.StartsWith("wheel_") || boneName.StartsWith("vfx_") || boneName.StartsWith("driver")) { var entity = new Entity { Name = bone.Name, EntityType = (boneName.StartsWith("driver") ? EntityType.Driver : (boneName.StartsWith("wheel_") ? EntityType.Wheel : EntityType.VFX)), AssetType = AssetType.Sprite }; entity.LinkWith(bone); SceneManager.Current.Entities.Add(entity); } } SceneManager.Current.SetContext(ContextGame.Carmageddon_Reincarnation, ContextMode.Car); } break; case "CNT files": case "MDL files": case "MT2 files": case "TDX files": case "LIGHT files": case "Accessory.txt files": case "Routes.txt files": case "vehicle_setup.cfg files": case "Structure.xml files": case "SystemsDamage.xml files": case "Setup.lol files": case "ZAD files": processAll(mi.Text); break; case "Wheel Preview": var preview = new frmReincarnationWheelPreview(); var result = preview.ShowDialog(); switch (result) { case DialogResult.OK: case DialogResult.Abort: foreach (var entity in SceneManager.Current.Entities) { if (entity.EntityType == EntityType.Wheel) { entity.Asset = (result == DialogResult.OK ? preview.Wheel : null); entity.AssetType = (result == DialogResult.OK ? AssetType.Model : AssetType.Sprite); } } break; } break; case "Bulk UnZAD": if (MessageBox.Show(string.Format("Are you entirely sure? This will extra ALL ZAD files in and under\r\n{0}\r\nThis will require at least 30gb of free space", Properties.Settings.Default.PathCarmageddonReincarnation), "Totes sure?", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (Directory.Exists(Properties.Settings.Default.PathCarmageddonReincarnation)) { int success = 0; int fail = 0; ToxicRagers.Helpers.IO.LoopDirectoriesIn(Properties.Settings.Default.PathCarmageddonReincarnation, (d) => { foreach (FileInfo fi in d.GetFiles("*.zad")) { var zad = ToxicRagers.Stainless.Formats.ZAD.Load(fi.FullName); int i = 0; if (zad != null) { if (!zad.IsVT) { foreach (var entry in zad.Contents) { i++; zad.Extract(entry, Properties.Settings.Default.PathCarmageddonReincarnation); if (i % 25 == 0) { tsslProgress.Text = string.Format("[{0}/{1}] {2} -> {3}", success, fail, fi.Name, entry.Name); Application.DoEvents(); } } success++; } } else { fail++; } tsslProgress.Text = string.Format("[{0}/{1}] {2}", success, fail, fi.FullName.Replace(Properties.Settings.Default.PathCarmageddonReincarnation, "")); Application.DoEvents(); } } ); tsslProgress.Text = string.Format("unZADing complete. {0} success {1} fail", success, fail); } } break; } }
private void menuCarmageddonReincarnationClick(object sender, EventArgs e) { ToolStripMenuItem mi = (ToolStripMenuItem)sender; SceneManager.Current.SetCoordinateSystem(SceneManager.CoordinateSystem.LeftHanded); switch (mi.Text) { case "Accessory": ofdBrowse.Filter = "Carmageddon ReinCARnation Accessory files (accessory.cnt)|accessory.cnt"; if (ofdBrowse.ShowDialog() == DialogResult.OK && File.Exists(ofdBrowse.FileName)) { SceneManager.Current.Reset(); var accessory = SceneManager.Current.Add(SceneManager.Current.Content.Load<Model, CNTImporter>(Path.GetFileName(ofdBrowse.FileName), Path.GetDirectoryName(ofdBrowse.FileName))); string accessorytxt = ofdBrowse.FileName.Replace(".cnt", ".txt", StringComparison.OrdinalIgnoreCase); if (File.Exists(accessorytxt)) { accessory.SupportingDocuments["Accessory"] = ToxicRagers.CarmageddonReincarnation.Formats.Accessory.Load(accessorytxt); } SceneManager.Current.SetContext(ContextGame.Carmageddon_Reincarnation, ContextMode.Accessory); } break; case "Environment": openContent("Carmageddon ReinCARnation Environment files (level.cnt)|level.cnt"); break; case "Pedestrian": openContent("Carmageddon ReinCARnation Pedestrians (bodyform.cnt)|bodyform.cnt"); break; case "Vehicle": ofdBrowse.Filter = "Carmageddon ReinCARnation Vehicles (car.cnt)|car.cnt"; if (ofdBrowse.ShowDialog() == DialogResult.OK && File.Exists(ofdBrowse.FileName)) { SceneManager.Current.Reset(); string assetFolder = Path.GetDirectoryName(ofdBrowse.FileName) + "\\"; var vehicle = (Model)SceneManager.Current.Add(SceneManager.Current.Content.Load<Model, CNTImporter>(Path.GetFileName(ofdBrowse.FileName), assetFolder)); // Load supporting documents if (File.Exists(assetFolder + "setup.lol")) { vehicle.SupportingDocuments["Setup"] = ToxicRagers.CarmageddonReincarnation.Formats.Setup.Load(assetFolder + "setup.lol"); } if (File.Exists(assetFolder + "Structure.xml")) { vehicle.SupportingDocuments["Structure"] = ToxicRagers.CarmageddonReincarnation.Formats.Structure.Load(assetFolder + "Structure.xml"); } if (File.Exists(assetFolder + "SystemsDamage.xml")) { vehicle.SupportingDocuments["SystemsDamage"] = ToxicRagers.CarmageddonReincarnation.Formats.SystemsDamage.Load(assetFolder + "SystemsDamage.xml"); } if (File.Exists(assetFolder + "vehicle_setup.cfg")) { vehicle.SupportingDocuments["VehicleSetupConfig"] = ToxicRagers.CarmageddonReincarnation.Formats.VehicleSetupConfig.Load(assetFolder + "vehicle_setup.cfg"); } foreach (var bone in vehicle.Bones) { string boneName = bone.Name.ToLower(); if (boneName.StartsWith("wheel_") || boneName.StartsWith("vfx_") || boneName.StartsWith("driver")) { var entity = new Entity { Name = bone.Name, EntityType = (boneName.StartsWith("driver") ? EntityType.Driver : (boneName.StartsWith("wheel_") ? EntityType.Wheel : EntityType.VFX)), AssetType = AssetType.Sprite }; entity.LinkWith(bone); SceneManager.Current.Entities.Add(entity); } } SceneManager.Current.SetContext(ContextGame.Carmageddon_Reincarnation, ContextMode.Car); } break; case "CNT files": case "MDL files": case "MT2 files": case "TDX files": case "LIGHT files": case "Accessory.txt files": case "Routes.txt files": case "vehicle_setup.cfg files": case "Structure.xml files": case "SystemsDamage.xml files": case "Setup.lol files": case "ZAD files": processAll(mi.Text); break; case "Wheel Preview": var preview = new frmReincarnationWheelPreview(); var result = preview.ShowDialog(); switch (result) { case DialogResult.OK: case DialogResult.Abort: foreach (var entity in SceneManager.Current.Entities) { if (entity.EntityType == EntityType.Wheel) { entity.Asset = (result == DialogResult.OK ? preview.Wheel : null); entity.AssetType = (result == DialogResult.OK ? AssetType.Model : AssetType.Sprite); } } break; } break; case "Bulk UnZAD": if (MessageBox.Show(string.Format("Are you entirely sure? This will extra ALL ZAD files in and under\r\n{0}\r\nThis will require at least 30gb of free space", Properties.Settings.Default.PathCarmageddonReincarnation), "Totes sure?", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (Directory.Exists(Properties.Settings.Default.PathCarmageddonReincarnation)) { int success = 0; int fail = 0; ToxicRagers.Helpers.IO.LoopDirectoriesIn(Properties.Settings.Default.PathCarmageddonReincarnation, (d) => { foreach (FileInfo fi in d.GetFiles("*.zad")) { var zad = ToxicRagers.Stainless.Formats.ZAD.Load(fi.FullName); int i = 0; if (zad != null) { if (!zad.IsVT) { foreach (var entry in zad.Contents) { i++; zad.Extract(entry, Properties.Settings.Default.PathCarmageddonReincarnation); if (i % 25 == 0) { tsslProgress.Text = string.Format("[{0}/{1}] {2} -> {3}", success, fail, fi.Name, entry.Name); Application.DoEvents(); } } success++; } } else { fail++; } tsslProgress.Text = string.Format("[{0}/{1}] {2}", success, fail, fi.FullName.Replace(Properties.Settings.Default.PathCarmageddonReincarnation, "")); Application.DoEvents(); } } ); tsslProgress.Text = string.Format("unZADing complete. {0} success {1} fail", success, fail); } } break; } }