public InternalAssetEditor(Asset asset, ArchiveEditorFunctions archive, bool hideHelp) { InitializeComponent(); TopMost = true; this.asset = asset; this.archive = archive; DynamicTypeDescriptor dt = new DynamicTypeDescriptor(asset.GetType()); asset.SetDynamicProperties(dt); propertyGridAsset.SelectedObject = dt.FromComponent(asset); labelAssetName.Text = $"[{asset.AHDR.assetType.ToString()}] {asset.ToString()}"; propertyGridAsset.HelpVisible = !hideHelp; if (asset is AssetCAM cam) { SetupForCam(cam); } else if (asset is AssetCSN csn) { SetupForCsn(csn); } else if (asset is AssetGRUP grup) { SetupForGrup(grup); } else if (asset is AssetRenderWareModel arwm) { SetupForModel(arwm); } else if (asset is AssetSHRP shrp) { SetupForShrp(shrp); } else if (asset is AssetWIRE wire) { SetupForWire(wire); } Button buttonHelp = new Button() { Dock = DockStyle.Fill, Text = "Open Wiki Page", AutoSize = true }; buttonHelp.Click += (object sender, EventArgs e) => System.Diagnostics.Process.Start(AboutBox.WikiLink + asset.AHDR.assetType.ToString()); tableLayoutPanel1.Controls.Add(buttonHelp, 0, tableLayoutPanel1.RowCount - 1); Button buttonFindCallers = new Button() { Dock = DockStyle.Fill, Text = "Find Who Targets Me", AutoSize = true }; buttonFindCallers.Click += (object sender, EventArgs e) => Program.MainForm.FindWhoTargets(GetAssetID()); tableLayoutPanel1.Controls.Add(buttonFindCallers, 1, tableLayoutPanel1.RowCount - 1); }
public AssetGRSM(Section_AHDR AHDR, Game game, Endianness endianness) : base(AHDR, game, endianness) { using (var reader = new EndianBinaryReader(AHDR.data, endianness)) { reader.BaseStream.Position = baseHeaderEndPosition; var numVertices = reader.ReadUInt32(); var numTriangles = reader.ReadUInt32(); MinX = reader.ReadSingle(); MinY = reader.ReadSingle(); MinZ = reader.ReadSingle(); MaxX = reader.ReadSingle(); MaxY = reader.ReadSingle(); MaxZ = reader.ReadSingle(); Vertices = new GrassMeshVertex[numVertices]; for (int i = 0; i < Vertices.Length; i++) { Vertices[i] = new GrassMeshVertex(reader); } Triangles = new DashTrackPortal[numTriangles]; for (int i = 0; i < Triangles.Length; i++) { Triangles[i] = new DashTrackPortal(reader); } CreateTransformMatrix(); ArchiveEditorFunctions.AddToRenderableAssets(this); } }
public AssetWIRE(Section_AHDR AHDR, Game game, Endianness endianness, SharpRenderer renderer) : base(AHDR, game, endianness) { using (var reader = new EndianBinaryReader(AHDR.data, endianness)) { reader.ReadInt32(); int vertexAmount = reader.ReadInt32(); int lineAmount = reader.ReadInt32(); hashID0 = reader.ReadUInt32(); hashID1 = reader.ReadUInt32(); Points = new WireVector[vertexAmount]; for (int i = 0; i < Points.Length; i++) { Points[i] = new WireVector(reader); } Lines = new Line[lineAmount]; for (int i = 0; i < Lines.Length; i++) { Lines[i] = new Line(reader); } Setup(renderer); ArchiveEditorFunctions.AddToRenderableAssets(this); } }
private void comboBoxAssetTypes_SelectedIndexChanged(object sender, EventArgs e) { assetType = (AssetType)comboBoxAssetTypes.SelectedItem; AHDRflags = ArchiveEditorFunctions.AHDRFlagsFromAssetType(assetType); label1.Visible = AHDRflags == 0; }
public InternalSoundEditor(AssetSound asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; this.archive = archive; Text = $"[{asset.assetType}] {asset}"; }
public InternalSoundEditor(Asset asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; this.archive = archive; labelAssetName.Text = $"[{asset.AHDR.assetType.ToString()}] {asset.ToString()}"; }
public Asset(string assetName, AssetType assetType) { game = Game.Unknown; endianness = Endianness.Unknown; this.assetType = assetType; this.assetName = assetName; assetID = new AssetID(assetName); assetFileName = ""; flags = ArchiveEditorFunctions.AHDRFlagsFromAssetType(assetType); }
public InternalTextureEditor(AssetRWTX asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; this.archive = archive; propertyGridAsset.SelectedObject = asset; labelAssetName.Text = $"[{asset.AHDR.assetType.ToString()}] {asset.ToString()}"; }
public InternalTextEditor(AssetTEXT asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; this.archive = archive; Text = $"[{this.asset.assetType}] {this.asset}"; richTextBoxAssetText.Text = this.asset.Text; }
public InternalFlyEditor(AssetFLY asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; this.archive = archive; Text = $"[{asset.assetType}] {asset}"; UpdateListbox(); }
public InternalTextEditor(AssetTEXT asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; this.archive = archive; labelAssetName.Text = $"[{this.asset.AHDR.assetType.ToString()}] {this.asset.ToString()}"; richTextBoxAssetText.Text = this.asset.Text; }
public static List <Section_AHDR> GetAssets(out bool success, out bool overwrite) { ImportTextures a = new ImportTextures(); if (a.ShowDialog() == DialogResult.OK) { ReadFileMethods.treatStuffAsByteArray = true; List <Section_AHDR> AHDRs = new List <Section_AHDR>(); for (int i = 0; i < a.filePaths.Count; i++) { if (Path.GetExtension(a.filePaths[i]).ToLower().Equals(".rwtex")) { byte[] data = ReadFileMethods.ExportRenderWareFile(new TextureDictionary_0016() { textureDictionaryStruct = new TextureDictionaryStruct_0001() { textureCount = 1, unknown = 0 }, textureNativeList = new List <TextureNative_0015>() { new TextureNative_0015().FromBytes(File.ReadAllBytes(a.filePaths[i])) }, textureDictionaryExtension = new Extension_0003() }, ArchiveEditorFunctions.currentTextureVersion); string assetName = Path.GetFileNameWithoutExtension(a.filePaths[i]) + (a.checkBoxRW3.Checked ? ".RW3" : ""); Section_ADBG ADBG = new Section_ADBG(0, assetName, "", 0); Section_AHDR AHDR = new Section_AHDR(Functions.BKDRHash(assetName), AssetType.RWTX, ArchiveEditorFunctions.AHDRFlagsFromAssetType(AssetType.RWTX), ADBG, data); AHDRs.Add(AHDR); } else { AHDRs.Add(ArchiveEditorFunctions.CreateRWTXFromBitmap(a.filePaths[i], a.checkBoxRW3.Checked, a.checkBoxFlipTextures.Checked, a.checkBoxMipmaps.Checked, a.checkBoxCompress.Checked)); } } ReadFileMethods.treatStuffAsByteArray = false; success = true; overwrite = a.checkBoxOverwrite.Checked; return(AHDRs); } else { success = false; overwrite = false; return(null); } }
public InternalTextureEditor(AssetRWTX asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; this.archive = archive; propertyGridAsset.SelectedObject = asset; Text = $"[{asset.assetType}] {asset}"; RefreshPropertyGrid(); }
private void comboBoxAssetTypes_SelectedIndexChanged(object sender, EventArgs e) { assetType = (AssetType)comboBoxAssetTypes.SelectedItem; AHDRFlags flags = ArchiveEditorFunctions.AHDRFlagsFromAssetType(assetType); checkSourceFile.Checked = (flags & AHDRFlags.SOURCE_FILE) != 0; checkSourceVirtual.Checked = (flags & AHDRFlags.SOURCE_VIRTUAL) != 0; checkReadT.Checked = (flags & AHDRFlags.READ_TRANSFORM) != 0; checkWriteT.Checked = (flags & AHDRFlags.WRITE_TRANSFORM) != 0; label1.Visible = flags == 0; }
public static void RemoveTexture(string textureName, ArchiveEditorFunctions sender, uint assetID) { foreach (var ae in Program.MainForm.archiveEditors) { if (ae.archive != sender && ae.archive.ContainsAsset(assetID)) { return; } } DisposeTexture(textureName); Textures.Remove(textureName); ReapplyTextures(); }
public InternalPlatEditor(AssetPLAT asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; this.archive = archive; propertyGridAsset.SelectedObject = asset; labelAssetName.Text = $"[{asset.AHDR.assetType.ToString()}] {asset.ToString()}"; asset.PlatSpecificChosen += UpdatePlatSpecifics; UpdatePlatSpecifics(); }
public InternalAssetEditor(Asset asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; this.archive = archive; propertyGridAsset.SelectedObject = asset; labelAssetName.Text = $"[{asset.AHDR.assetType.ToString()}] {asset.ToString()}"; if (asset is AssetMVPT) { propertyGridAsset.HelpVisible = true; } }
public InternalModelEditor(AssetRenderWareModel asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; this.archive = archive; if (asset.AHDR.assetType != HipHopFile.AssetType.MODL) { buttonImport.Enabled = false; } propertyGridAsset.SelectedObject = asset; labelAssetName.Text = $"[{asset.AHDR.assetType.ToString()}] {asset.ToString()}"; }
private void AddFolder(string folderPath) { foreach (string s in Directory.GetFiles(folderPath)) { if (Path.GetExtension(s).ToLower() == ".hip" || Path.GetExtension(s).ToLower() == ".hop") { ArchiveEditorFunctions archive = new ArchiveEditorFunctions(); archive.OpenFile(s); WriteWhatIFound(archive); archive.Dispose(); } } foreach (string s in Directory.GetDirectories(folderPath)) { AddFolder(s); } }
private void buttonExport_Click(object sender, System.EventArgs e) { SaveFileDialog a = new SaveFileDialog() { //Filter = "All supported formats|*.png;*.rwtex|PNG Files|*.png|RWTEX Files|*.rwtex", Filter = "RWTEX Files|*.rwtex", FileName = Path.ChangeExtension(asset.AHDR.ADBG.assetName, ".rwtex") }; if (a.ShowDialog() == DialogResult.OK) { //if (Path.GetExtension(a.FileName).ToLower() == ".rwtex") ArchiveEditorFunctions.ExportSingleTextureToRWTEX(asset.Data, a.FileName); //else // MessageBox.Show("Unsupported"); } }
private void buttonCopy_Click(object sender, EventArgs e) { if (listBoxTemplates.SelectedIndex < 0) { return; } // Generating Asset AHDR string assetName = listBoxTemplates.SelectedItem.ToString().Substring(listBoxTemplates.SelectedItem.ToString().IndexOf(']') + 2); string assetTypeName = listBoxTemplates.SelectedItem.ToString().Substring(listBoxTemplates.SelectedItem.ToString().IndexOf('[') + 1, listBoxTemplates.SelectedItem.ToString().IndexOf(']') - listBoxTemplates.SelectedItem.ToString().IndexOf('[') - 1); AssetType assetType = AssetType.Null; foreach (AssetType o in Enum.GetValues(typeof(AssetType))) { if (o.ToString() == assetTypeName.Trim().ToUpper()) { assetType = o; break; } } if (assetType == AssetType.Null) { throw new Exception("Unknown asset type: " + assetType); } Section_AHDR newAsset = new Section_AHDR { assetID = Functions.BKDRHash(assetName), assetType = assetType, flags = ArchiveEditorFunctions.AHDRFlagsFromAssetType(assetType), data = File.ReadAllBytes(Path.Combine(Program.MainForm.userTemplatesFolder, listBoxTemplates.SelectedItem.ToString())) }; newAsset.ADBG = new Section_ADBG(0, assetName, "", 0); // Asset AHDR is done Clipboard.SetText(JsonConvert.SerializeObject(new List <Section_AHDR> { newAsset })); }
private void AddFolder(string folderPath, ref Platform scoobyPlatform) { foreach (string s in Directory.GetFiles(folderPath)) { if (Path.GetExtension(s).ToLower() == ".hip" || Path.GetExtension(s).ToLower() == ".hop") { ArchiveEditorFunctions archive = new ArchiveEditorFunctions(); archive.OpenFile(s, false, scoobyPlatform, out _, true); if (scoobyPlatform == Platform.Unknown) { scoobyPlatform = archive.platform; } WriteWhatIFound(archive); archive.Dispose(false); } } foreach (string s in Directory.GetDirectories(folderPath)) { AddFolder(s, ref scoobyPlatform); } }
public AssetDTRK(Section_AHDR AHDR, Game game, Endianness endianness) : base(AHDR, game, endianness) { using (var reader = new EndianBinaryReader(AHDR.data, endianness)) { reader.BaseStream.Position = baseHeaderEndPosition; var numVertices = reader.ReadUInt32(); var numTriangles = reader.ReadUInt32(); LandableStart = reader.ReadUInt32(); LeavableStart = reader.ReadUInt32(); Unknown1 = reader.ReadUInt32(); Unknown2 = reader.ReadUInt32(); Unknown3 = reader.ReadUInt32(); Vertices = new WireVector[numVertices]; for (int i = 0; i < Vertices.Length; i++) { Vertices[i] = new WireVector(reader); } Triangles = new DashTrackTriangle[numTriangles]; for (int i = 0; i < Triangles.Length; i++) { Triangles[i] = new DashTrackTriangle(reader); } Portals = new DashTrackPortal[numTriangles]; for (int i = 0; i < Portals.Length; i++) { Portals[i] = new DashTrackPortal(reader); } LastTriangle = reader.ReadUInt32(); LastPositionX = reader.ReadSingle(); LastPositionY = reader.ReadSingle(); CreateTransformMatrix(); ArchiveEditorFunctions.AddToRenderableAssets(this); } }
public ArchiveEditor(string filePath) { InitializeComponent(); TopMost = true; archive = new ArchiveEditorFunctions(); defaultColor = textBoxFindAsset.BackColor; textBoxFindAsset.AutoCompleteSource = AutoCompleteSource.CustomSource; archive.SetTextboxForAutocomplete(textBoxFindAsset); if (!string.IsNullOrWhiteSpace(filePath)) { OpenFile(filePath); } ArchiveEditorFunctions.PopulateTemplateMenusAt(addTemplateToolStripMenuItem, TemplateToolStripMenuItem_Click); listViewAssets_SizeChanged(null, null); #if RELEASE shuffleToolStripMenuItem.Visible = false; #endif }
public InternalMultiAssetEditor(Asset[] assets, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; assetIDs = (from Asset a in assets select a.assetID).ToArray(); this.archive = archive; var typeDescriptors = new List <DynamicTypeDescriptor>(); labelAssetName.Text = ""; foreach (var asset in assets) { DynamicTypeDescriptor dt = new DynamicTypeDescriptor(asset.GetType()); asset.SetDynamicProperties(dt); typeDescriptors.Add(dt.FromComponent(asset)); } propertyGridAsset.SelectedObjects = typeDescriptors.ToArray(); labelAssetName.Text = string.Join(" | ", from Asset asset in assets select asset.assetName); }
public SharpRenderer(Control control) { try { device = new SharpDevice(control, false); } catch (Exception e) { MessageBox.Show("Error setting up DirectX11 renderer: " + e.Message); return; } LoadModels(); sharpFPS = new SharpFPS(); Camera.AspectRatio = (float)control.ClientSize.Width / control.ClientSize.Height; Camera.Reset(); ResetColors(); SetSharpShader(); LoadTexture(); ArchiveEditorFunctions.SetUpGizmos(); }
private void buttonPerform_Click(object sender, EventArgs e) { List <string> fileList = new List <string>(); AddFolder(rootDir, ref fileList); progressBar1.Minimum = 0; progressBar1.Maximum = fileList.Count; progressBar1.Value = 0; progressBar1.Step = 1; Dictionary <(DynaType, int, int), int> dynas = new Dictionary <(DynaType, int, int), int>(); foreach (string s in fileList) { progressBar1.PerformStep(); ArchiveEditorFunctions archive = new ArchiveEditorFunctions(); archive.OpenFile(s, false, Platform.Unknown, true); Check(archive, ref dynas); archive.Dispose(false); } List <string> output = new List <string>(); foreach (var v in dynas.Keys) { output.Add($"{v.Item1.ToString()} - v{v.Item2} - {v.Item3} bytes - {dynas[v]} inst\n"); } richTextBox1.Clear(); foreach (var s in output.OrderBy(f => f)) { richTextBox1.AppendText(s); } }
private void buttonImport_Click(object sender, System.EventArgs e) { OpenFileDialog a = new OpenFileDialog() { Filter = ImportTextures.filter }; if (a.ShowDialog() == DialogResult.OK) { archive.UnsavedChanges = true; string i = a.FileName; if (Path.GetExtension(i).ToLower().Equals(".rwtex")) { asset.Data = ReadFileMethods.ExportRenderWareFile(new TextureDictionary_0016() { textureDictionaryStruct = new TextureDictionaryStruct_0001() { textureCount = 1, unknown = 0 }, textureNativeList = new List <TextureNative_0015>() { new TextureNative_0015().FromBytes(File.ReadAllBytes(i)) }, textureDictionaryExtension = new Extension_0003() }, ArchiveEditorFunctions.currentTextureVersion); } else { asset.Data = ArchiveEditorFunctions.CreateRWTXFromBitmap(i, false, false, true, true).data; } archive.EnableTextureForDisplay(asset); } }
private void WriteWhatIFound(ArchiveEditorFunctions archive) { progressBar1.Minimum = 0; progressBar1.Maximum = archive.AssetCount; progressBar1.Step = 1; foreach (Asset asset in archive.GetAllAssets()) { progressBar1.PerformStep(); if (senderAssetType != AssetType.Null && asset.AHDR.assetType != senderAssetType) { continue; } if (asset is ObjectAsset objectAsset) { foreach (LinkBFBB assetEvent in objectAsset.LinksBFBB) { if (recieveEventType != EventBFBB.Unknown && assetEvent.EventReceiveID != recieveEventType) { continue; } if (targetEventType != EventBFBB.Unknown && assetEvent.EventSendID != targetEventType) { continue; } Asset targetAsset = null; if (archive.ContainsAsset(assetEvent.TargetAssetID)) { targetAsset = archive.GetFromAssetID(assetEvent.TargetAssetID); } if (recieverAssetType != AssetType.Null) { if (targetAsset != null && targetAsset.AHDR.assetType != recieverAssetType) { continue; } if (targetAsset == null) { continue; } } string eventName = $"{objectAsset.AHDR.ADBG.assetName} ({assetEvent.EventReceiveID.ToString()}) => {assetEvent.EventSendID.ToString()} => "; if (targetAsset == null) { eventName += $"0x{assetEvent.TargetAssetID.ToString("X8")}"; } else { eventName += $"{targetAsset.AHDR.ADBG.assetName}"; } eventName += $" [{assetEvent.Arguments_Float[0]}, {assetEvent.Arguments_Float[1]}, {assetEvent.Arguments_Float[2]}, {assetEvent.Arguments_Float[3]}"; if (assetEvent.ArgumentAssetID != 0) { if (archive.ContainsAsset(assetEvent.ArgumentAssetID)) { eventName += $", {archive.GetFromAssetID(assetEvent.ArgumentAssetID).AHDR.ADBG.assetName}"; } else { eventName += $", 0x{assetEvent.ArgumentAssetID.ToString("X8")}"; } } if (assetEvent.SourceCheckAssetID != 0) { if (archive.ContainsAsset(assetEvent.SourceCheckAssetID)) { eventName += $", {archive.GetFromAssetID(assetEvent.SourceCheckAssetID).AHDR.ADBG.assetName}"; } else { eventName += $", 0x{assetEvent.SourceCheckAssetID.ToString("X8")}"; } } eventName += "]"; richTextBox1.AppendText(eventName + "\n"); senders.Add(objectAsset.AHDR.assetType); if (targetAsset != null) { recievers.Add(targetAsset.AHDR.assetType); } recievedEvents.Add(assetEvent.EventReceiveID); sentEvents.Add(assetEvent.EventSendID); total++; } } } }
private void propertyGridAsset_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { archive.UnsavedChanges = true; ArchiveEditorFunctions.UpdateGizmoPosition(); UpdatePlatSpecifics(); }