private void saveCurrentTagToolStripMenuItem_Click(object sender, EventArgs e) { if (CurrentTag == null || !CurrentTags.ContainsKey(CurrentTag.Index)) { return; } var tagName = SaveTagChanges(CurrentTag, CurrentTags[CurrentTag.Index]); MessageBox.Show($"Saved changes to {tagName} successfully.", "Save Tag Changes", MessageBoxButtons.OK); }
private void closeCurrentTagToolStripMenuItem_Click(object sender, EventArgs e) { if (CurrentTag == null) { return; } tagEditorPanel.Controls.Clear(); if (currentTagsComboBox.Items.Count > 0) { currentTagsComboBox.Items.RemoveAt(currentTagsComboBox.SelectedIndex); } if (!CurrentTags.ContainsKey(CurrentTag.Index)) { return; } CurrentTags.Remove(CurrentTag.Index); }
public void LoadTagEditor(CachedTag tag) { if (tag == null || (CurrentTag != null && CurrentTag.Index == tag.Index)) { return; } LoadingTag = true; object definition = null; if (CurrentTags.ContainsKey(tag.Index)) { definition = CurrentTags[tag.Index]; } tagTreeView.Enabled = false; tagEditorPanel.Controls.Clear(); var tagName = tag.Name ?? $"0x{tag.Index:X4}"; var groupName = Cache.StringTable.GetString(tag.Group.Name); statusLabel.Text = $"Loading {tagName}.{ groupName}..."; progressBar.Style = ProgressBarStyle.Marquee; progressBar.MarqueeAnimationSpeed = 30; if (definition == null) { using (var stream = Cache.OpenCacheRead()) definition = Cache.Deserialize(stream, tag); } if (tagName.Contains("\\")) { var index = tagName.LastIndexOf('\\') + 1; tagName = tagName.Substring(index, tagName.Length - index); } statusLabel.Text = $"Generating {groupName} interface..."; Application.DoEvents(); var point = new Point(); if (tag.IsInGroup("matg") || tag.IsInGroup("mulg") || tag.IsInGroup("scnr") || tag.IsInGroup("sbsp")) { var control = new StructMultiControl(this, Cache, tag, definition) { Dock = DockStyle.Fill }; control.GetFieldValue(null, definition, definition); tagEditorPanel.Controls.Add(control); } // todo: fixup/clean model rendering code // todo: finish bitm editing (save/import dds, add size scaling to image) else if (tag.IsInGroup("bitm") || tag.IsInGroup("obje")) { var splitContainer = new SplitContainer { Dock = DockStyle.Fill, Orientation = Orientation.Horizontal }; splitContainer.FixedPanel = FixedPanel.Panel1; tagEditorPanel.Controls.Add(splitContainer); splitContainer.BringToFront(); /*if (tag.IsInGroup("bitm")) * splitContainer.SplitterDistance = 384;//Math.Min((short)512, Math.Max((short)16, ((TagTool.Tags.Definitions.Bitmap)definition).Images[0].Height)); * else if (tag.IsInGroup("obje")) * splitContainer.SplitterDistance = 384;*/ if (tag.IsInGroup("bitm")) { var bitmDefinition = (TagTool.Tags.Definitions.Bitmap)definition; if (Cache.ResourceCache.GetBitmapTextureInteropResource(bitmDefinition.Resources[0]) != null) { splitContainer.SplitterDistance = 384; var bitmapControl = new BitmapControl(Cache, bitmDefinition) { Dock = DockStyle.Fill }; splitContainer.Panel1.Controls.Add(bitmapControl); bitmapControl.BringToFront(); } } /*else if (tag.IsInGroup("obje")) * { * var modelControl = new ObjectControl(Cache, (GameObject)definition) * { * Dock = DockStyle.Fill * }; * * splitContainer.Panel1.Controls.Add(modelControl); * modelControl.BringToFront(); * }*/ var control = tag.IsInGroup("obje") ? (Control) new StructMultiControl(this, Cache, tag, definition) { Dock = DockStyle.Fill } : new StructControl(this, Cache, definition.GetType(), null); ((IFieldControl)control).GetFieldValue(null, definition, definition); control.Location = point; splitContainer.Panel2.Controls.Add(control); splitContainer.Panel2.AutoScroll = true; } else { if (tag.IsInGroup("snd!")) { var soundControl = new SoundControl(Cache, tag, (Sound)definition) { Dock = DockStyle.Top }; tagEditorPanel.Controls.Add(soundControl); soundControl.BringToFront(); point.Y = soundControl.Bottom; } var control = new StructControl(this, Cache, definition.GetType(), null); control.GetFieldValue(null, definition, definition); control.Location = point; tagEditorPanel.Controls.Add(control); } statusLabel.Text = ""; progressBar.Style = ProgressBarStyle.Continuous; progressBar.MarqueeAnimationSpeed = 0; tagTreeView.Enabled = true; CurrentTag = tag; if (!CurrentTags.ContainsKey(tag.Index)) { CurrentTags[tag.Index] = definition; var item = new TagInstanceItem { Cache = Cache, Tag = tag }; currentTagsComboBox.Items.Add(item); currentTagsComboBox.SelectedItem = item; } else { for (var i = 0; i < currentTagsComboBox.Items.Count; i++) { var item = (TagInstanceItem)currentTagsComboBox.Items[i]; if (item.Tag.Index == tag.Index) { currentTagsComboBox.SelectedIndex = i; break; } } } LoadingTag = false; }