private void UpdateControls() { if (CurrentControl != null) { CurrentControl.Hide(); CurrentControl.RemoveFromMainForm(MainForm); } string truncatedType = SelectedChunk.ChunkType.Remove(SelectedChunk.ChunkType.Length - 1); CurrentControl = Controls.Find(x => x.ChunkID.Contains(truncatedType)); CurrentControl.FillGeneral(SelectedChunk); CurrentControl.AddToMainForm(MainForm); CurrentControl.Show(); }
private List<ControlObject> LoadControls() { List<ControlObject> controlList = new List<ControlObject>(); string lastChunkType = "NULL"; foreach (Chunk chunk in Chunks) { if (chunk.ChunkType != lastChunkType) { ControlObject obj = new ControlObject(); obj.Load(chunk); controlList.Add(obj); lastChunkType = chunk.ChunkType; } } return controlList; }
void Read(EndianBinaryReader reader) { if (CurrentControl != null) { CurrentControl.Hide(); CurrentControl.RemoveFromMainForm(MainForm); CurrentControl = null; } Cam = new Camera(); ChunkTemplates = LoadTemplates(); Chunks.Clear(); int numChunkHeaders = reader.ReadInt32(); int readerOffsetStorage = 4; for (int i = 0; i < numChunkHeaders; i++) { string chunkName = reader.ReadStringUntil('\0'); reader.BaseStream.Position -= 1; int numChunks = reader.ReadInt32(); int chunksOffset = reader.ReadInt32(); readerOffsetStorage = (int)reader.BaseStream.Position; reader.BaseStream.Position = chunksOffset; if (chunkName == "RTBL") { //Skip offset bank, which is a table of integers reader.BaseStream.Position += 4 * numChunks; } for (int j = 0; j < numChunks; j++) { Chunk newChunk = new Chunk(); newChunk.Read(reader, chunkName, ChunkTemplates); Chunks.Add(newChunk); } reader.BaseStream.Position = readerOffsetStorage; } foreach (Chunk chunk in Chunks) { string chunkSearchString = chunk.ChunkType.Remove(chunk.ChunkType.Length - 1); EntityTemplate template = ChunkTemplates.Find(x => x.ChunkID.Contains(chunkSearchString)); template.ReadSpecialProcess(chunk.Fields, Chunks); } UpdateTreeView(); MainForm.ElementView.SelectedNode = MainForm.ElementView.Nodes[0]; SelectedChunk = Chunks[0]; Controls = LoadControls(); IsListLoaded = true; }
public void AddChunk(string chunkType) { var query = GroupChunksByFourCc(); foreach (var group in query) { if (group.Key == chunkType) { MessageBox.Show("The chunk type you selected already exists.", "Chunk Type Already Exists"); return; } } Chunk newChunk = new Chunk(); string searchString = chunkType.Remove(chunkType.Length - 1); newChunk.MakeEmptyChunkFromTemplate(ChunkTemplates.Find(x => x.ChunkID.Contains(searchString))); newChunk.ChunkType = chunkType; Chunks.Add(newChunk); ControlObject newControl = new ControlObject(); newControl.Load(newChunk); Controls.Add(newControl); UpdateTreeView(); }