diff --git a/CodeWalker.Core/GameFiles/MetaTypes/MetaXml.cs b/CodeWalker.Core/GameFiles/MetaTypes/MetaXml.cs index 6ccbb68..07e42a7 100644 --- a/CodeWalker.Core/GameFiles/MetaTypes/MetaXml.cs +++ b/CodeWalker.Core/GameFiles/MetaTypes/MetaXml.cs @@ -1837,6 +1837,7 @@ namespace CodeWalker.GameFiles PSO = 2, RBF = 3, CacheFile = 4, + AudioRel = 5, } } diff --git a/ExploreForm.cs b/ExploreForm.cs index 7d14932..afe8792 100644 --- a/ExploreForm.cs +++ b/ExploreForm.cs @@ -1580,7 +1580,7 @@ namespace CodeWalker private void ViewRel(string name, string path, byte[] data, RpfFileEntry e) { var rel = RpfFile.GetFile(e, data); - RelForm f = new RelForm(); + RelForm f = new RelForm(this); f.Show(); f.LoadRel(rel); } diff --git a/Forms/MetaForm.cs b/Forms/MetaForm.cs index ed3c1d4..e7d9e10 100644 --- a/Forms/MetaForm.cs +++ b/Forms/MetaForm.cs @@ -400,6 +400,8 @@ namespace CodeWalker.Forms modified = false; + StatusLabel.Text = metaFormat.ToString() + " file saved successfully at " + DateTime.Now.ToString(); + return true; //victory! } catch (Exception ex) diff --git a/Forms/RelForm.Designer.cs b/Forms/RelForm.Designer.cs index 90da09d..74d18d6 100644 --- a/Forms/RelForm.Designer.cs +++ b/Forms/RelForm.Designer.cs @@ -32,6 +32,8 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RelForm)); this.RelPropertyGrid = new CodeWalker.WinForms.PropertyGridFix(); this.MainTabControl = new System.Windows.Forms.TabControl(); + this.XmlTabPage = new System.Windows.Forms.TabPage(); + this.XmlTextBox = new FastColoredTextBoxNS.FastColoredTextBox(); this.DetailsTabPage = new System.Windows.Forms.TabPage(); this.NameTableTabPage = new System.Windows.Forms.TabPage(); this.MainTextBox = new CodeWalker.WinForms.TextBoxFix(); @@ -42,15 +44,35 @@ this.SearchTextBox = new System.Windows.Forms.TextBox(); this.SearchButton = new System.Windows.Forms.Button(); this.SearchResultsGrid = new CodeWalker.WinForms.PropertyGridFix(); - this.CloseButton = new System.Windows.Forms.Button(); - this.XmlTabPage = new System.Windows.Forms.TabPage(); - this.XmlTextBox = new FastColoredTextBoxNS.FastColoredTextBox(); + this.MainToolbar = new System.Windows.Forms.ToolStrip(); + this.NewButton = new System.Windows.Forms.ToolStripSplitButton(); + this.OpenButton = new System.Windows.Forms.ToolStripSplitButton(); + this.SaveButton = new System.Windows.Forms.ToolStripSplitButton(); + this.MainStatusStrip = new System.Windows.Forms.StatusStrip(); + this.StatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this.MainMenu = new System.Windows.Forms.MenuStrip(); + this.FileMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.FileNewMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.FileOpenMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.FileSaveMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.FileSaveAsMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.FileCloseMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.EditMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.wIPToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ViewMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.wIPToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.OpenFileDialog = new System.Windows.Forms.OpenFileDialog(); + this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog(); this.MainTabControl.SuspendLayout(); + this.XmlTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.XmlTextBox)).BeginInit(); this.DetailsTabPage.SuspendLayout(); this.NameTableTabPage.SuspendLayout(); this.SearchTabPage.SuspendLayout(); - this.XmlTabPage.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.XmlTextBox)).BeginInit(); + this.MainToolbar.SuspendLayout(); + this.MainStatusStrip.SuspendLayout(); + this.MainMenu.SuspendLayout(); this.SuspendLayout(); // // RelPropertyGrid @@ -61,159 +83,30 @@ this.RelPropertyGrid.HelpVisible = false; this.RelPropertyGrid.Location = new System.Drawing.Point(6, 6); this.RelPropertyGrid.Name = "RelPropertyGrid"; - this.RelPropertyGrid.Size = new System.Drawing.Size(644, 356); + this.RelPropertyGrid.Size = new System.Drawing.Size(819, 448); this.RelPropertyGrid.TabIndex = 0; // // MainTabControl // - this.MainTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.MainTabControl.Controls.Add(this.XmlTabPage); this.MainTabControl.Controls.Add(this.DetailsTabPage); this.MainTabControl.Controls.Add(this.NameTableTabPage); this.MainTabControl.Controls.Add(this.SearchTabPage); - this.MainTabControl.Location = new System.Drawing.Point(5, 5); + this.MainTabControl.Dock = System.Windows.Forms.DockStyle.Fill; + this.MainTabControl.Location = new System.Drawing.Point(0, 49); this.MainTabControl.Margin = new System.Windows.Forms.Padding(0); this.MainTabControl.Name = "MainTabControl"; this.MainTabControl.SelectedIndex = 0; - this.MainTabControl.Size = new System.Drawing.Size(664, 394); + this.MainTabControl.Size = new System.Drawing.Size(839, 486); this.MainTabControl.TabIndex = 1; // - // DetailsTabPage - // - this.DetailsTabPage.Controls.Add(this.RelPropertyGrid); - this.DetailsTabPage.Location = new System.Drawing.Point(4, 22); - this.DetailsTabPage.Name = "DetailsTabPage"; - this.DetailsTabPage.Padding = new System.Windows.Forms.Padding(3); - this.DetailsTabPage.Size = new System.Drawing.Size(656, 368); - this.DetailsTabPage.TabIndex = 1; - this.DetailsTabPage.Text = "Details"; - this.DetailsTabPage.UseVisualStyleBackColor = true; - // - // NameTableTabPage - // - this.NameTableTabPage.Controls.Add(this.MainTextBox); - this.NameTableTabPage.Location = new System.Drawing.Point(4, 22); - this.NameTableTabPage.Name = "NameTableTabPage"; - this.NameTableTabPage.Padding = new System.Windows.Forms.Padding(3); - this.NameTableTabPage.Size = new System.Drawing.Size(656, 368); - this.NameTableTabPage.TabIndex = 0; - this.NameTableTabPage.Text = "Names"; - this.NameTableTabPage.UseVisualStyleBackColor = true; - // - // MainTextBox - // - this.MainTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.MainTextBox.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.MainTextBox.HideSelection = false; - this.MainTextBox.Location = new System.Drawing.Point(6, 6); - this.MainTextBox.Multiline = true; - this.MainTextBox.Name = "MainTextBox"; - this.MainTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; - this.MainTextBox.Size = new System.Drawing.Size(644, 356); - this.MainTextBox.TabIndex = 1; - this.MainTextBox.WordWrap = false; - // - // SearchTabPage - // - this.SearchTabPage.Controls.Add(this.SearchTextRadio); - this.SearchTabPage.Controls.Add(this.SearchHashRadio); - this.SearchTabPage.Controls.Add(this.label12); - this.SearchTabPage.Controls.Add(this.SearchTextBox); - this.SearchTabPage.Controls.Add(this.SearchButton); - this.SearchTabPage.Controls.Add(this.SearchResultsGrid); - this.SearchTabPage.Location = new System.Drawing.Point(4, 22); - this.SearchTabPage.Name = "SearchTabPage"; - this.SearchTabPage.Size = new System.Drawing.Size(656, 368); - this.SearchTabPage.TabIndex = 2; - this.SearchTabPage.Text = "Search"; - this.SearchTabPage.UseVisualStyleBackColor = true; - // - // SearchTextRadio - // - this.SearchTextRadio.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.SearchTextRadio.AutoSize = true; - this.SearchTextRadio.Location = new System.Drawing.Point(343, 4); - this.SearchTextRadio.Name = "SearchTextRadio"; - this.SearchTextRadio.Size = new System.Drawing.Size(46, 17); - this.SearchTextRadio.TabIndex = 36; - this.SearchTextRadio.Text = "Text"; - this.SearchTextRadio.UseVisualStyleBackColor = true; - // - // SearchHashRadio - // - this.SearchHashRadio.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.SearchHashRadio.AutoSize = true; - this.SearchHashRadio.Checked = true; - this.SearchHashRadio.Location = new System.Drawing.Point(287, 4); - this.SearchHashRadio.Name = "SearchHashRadio"; - this.SearchHashRadio.Size = new System.Drawing.Size(50, 17); - this.SearchHashRadio.TabIndex = 35; - this.SearchHashRadio.TabStop = true; - this.SearchHashRadio.Text = "Hash"; - this.SearchHashRadio.UseVisualStyleBackColor = true; - // - // label12 - // - this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(8, 6); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(30, 13); - this.label12.TabIndex = 32; - this.label12.Text = "Find:"; - // - // SearchTextBox - // - this.SearchTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.SearchTextBox.Location = new System.Drawing.Point(44, 3); - this.SearchTextBox.Name = "SearchTextBox"; - this.SearchTextBox.Size = new System.Drawing.Size(237, 20); - this.SearchTextBox.TabIndex = 33; - this.SearchTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SearchTextBox_KeyDown); - // - // SearchButton - // - this.SearchButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.SearchButton.Location = new System.Drawing.Point(395, 2); - this.SearchButton.Name = "SearchButton"; - this.SearchButton.Size = new System.Drawing.Size(68, 23); - this.SearchButton.TabIndex = 34; - this.SearchButton.Text = "Search"; - this.SearchButton.UseVisualStyleBackColor = true; - this.SearchButton.Click += new System.EventHandler(this.SearchButton_Click); - // - // SearchResultsGrid - // - this.SearchResultsGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.SearchResultsGrid.HelpVisible = false; - this.SearchResultsGrid.Location = new System.Drawing.Point(3, 31); - this.SearchResultsGrid.Name = "SearchResultsGrid"; - this.SearchResultsGrid.Size = new System.Drawing.Size(647, 331); - this.SearchResultsGrid.TabIndex = 1; - // - // CloseButton - // - this.CloseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.CloseButton.Location = new System.Drawing.Point(584, 409); - this.CloseButton.Name = "CloseButton"; - this.CloseButton.Size = new System.Drawing.Size(75, 23); - this.CloseButton.TabIndex = 2; - this.CloseButton.Text = "Close"; - this.CloseButton.UseVisualStyleBackColor = true; - this.CloseButton.Click += new System.EventHandler(this.CloseButton_Click); - // // XmlTabPage // this.XmlTabPage.Controls.Add(this.XmlTextBox); this.XmlTabPage.Location = new System.Drawing.Point(4, 22); this.XmlTabPage.Name = "XmlTabPage"; - this.XmlTabPage.Size = new System.Drawing.Size(656, 368); + this.XmlTabPage.Padding = new System.Windows.Forms.Padding(3); + this.XmlTabPage.Size = new System.Drawing.Size(831, 460); this.XmlTabPage.TabIndex = 3; this.XmlTabPage.Text = "XML"; this.XmlTabPage.UseVisualStyleBackColor = true; @@ -247,36 +140,327 @@ this.XmlTextBox.Language = FastColoredTextBoxNS.Language.XML; this.XmlTextBox.LeftBracket = '<'; this.XmlTextBox.LeftBracket2 = '('; - this.XmlTextBox.Location = new System.Drawing.Point(0, 0); + this.XmlTextBox.Location = new System.Drawing.Point(3, 3); this.XmlTextBox.Name = "XmlTextBox"; this.XmlTextBox.Paddings = new System.Windows.Forms.Padding(0); this.XmlTextBox.RightBracket = '>'; this.XmlTextBox.RightBracket2 = ')'; this.XmlTextBox.SelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(255))))); this.XmlTextBox.ServiceColors = ((FastColoredTextBoxNS.ServiceColors)(resources.GetObject("XmlTextBox.ServiceColors"))); - this.XmlTextBox.Size = new System.Drawing.Size(656, 368); + this.XmlTextBox.Size = new System.Drawing.Size(825, 454); this.XmlTextBox.TabIndex = 2; this.XmlTextBox.Zoom = 100; + this.XmlTextBox.TextChanged += new System.EventHandler(this.XmlTextBox_TextChanged); + this.XmlTextBox.VisibleRangeChangedDelayed += new System.EventHandler(this.XmlTextBox_VisibleRangeChangedDelayed); + // + // DetailsTabPage + // + this.DetailsTabPage.Controls.Add(this.RelPropertyGrid); + this.DetailsTabPage.Location = new System.Drawing.Point(4, 22); + this.DetailsTabPage.Name = "DetailsTabPage"; + this.DetailsTabPage.Padding = new System.Windows.Forms.Padding(3); + this.DetailsTabPage.Size = new System.Drawing.Size(831, 460); + this.DetailsTabPage.TabIndex = 1; + this.DetailsTabPage.Text = "Details"; + this.DetailsTabPage.UseVisualStyleBackColor = true; + // + // NameTableTabPage + // + this.NameTableTabPage.Controls.Add(this.MainTextBox); + this.NameTableTabPage.Location = new System.Drawing.Point(4, 22); + this.NameTableTabPage.Name = "NameTableTabPage"; + this.NameTableTabPage.Padding = new System.Windows.Forms.Padding(3); + this.NameTableTabPage.Size = new System.Drawing.Size(831, 460); + this.NameTableTabPage.TabIndex = 0; + this.NameTableTabPage.Text = "Names"; + this.NameTableTabPage.UseVisualStyleBackColor = true; + // + // MainTextBox + // + this.MainTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.MainTextBox.Font = new System.Drawing.Font("Courier New", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.MainTextBox.HideSelection = false; + this.MainTextBox.Location = new System.Drawing.Point(6, 6); + this.MainTextBox.Multiline = true; + this.MainTextBox.Name = "MainTextBox"; + this.MainTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.MainTextBox.Size = new System.Drawing.Size(819, 448); + this.MainTextBox.TabIndex = 1; + this.MainTextBox.WordWrap = false; + // + // SearchTabPage + // + this.SearchTabPage.Controls.Add(this.SearchTextRadio); + this.SearchTabPage.Controls.Add(this.SearchHashRadio); + this.SearchTabPage.Controls.Add(this.label12); + this.SearchTabPage.Controls.Add(this.SearchTextBox); + this.SearchTabPage.Controls.Add(this.SearchButton); + this.SearchTabPage.Controls.Add(this.SearchResultsGrid); + this.SearchTabPage.Location = new System.Drawing.Point(4, 22); + this.SearchTabPage.Name = "SearchTabPage"; + this.SearchTabPage.Size = new System.Drawing.Size(831, 460); + this.SearchTabPage.TabIndex = 2; + this.SearchTabPage.Text = "Search"; + this.SearchTabPage.UseVisualStyleBackColor = true; + // + // SearchTextRadio + // + this.SearchTextRadio.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.SearchTextRadio.AutoSize = true; + this.SearchTextRadio.Location = new System.Drawing.Point(518, 4); + this.SearchTextRadio.Name = "SearchTextRadio"; + this.SearchTextRadio.Size = new System.Drawing.Size(46, 17); + this.SearchTextRadio.TabIndex = 36; + this.SearchTextRadio.Text = "Text"; + this.SearchTextRadio.UseVisualStyleBackColor = true; + // + // SearchHashRadio + // + this.SearchHashRadio.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.SearchHashRadio.AutoSize = true; + this.SearchHashRadio.Checked = true; + this.SearchHashRadio.Location = new System.Drawing.Point(462, 4); + this.SearchHashRadio.Name = "SearchHashRadio"; + this.SearchHashRadio.Size = new System.Drawing.Size(50, 17); + this.SearchHashRadio.TabIndex = 35; + this.SearchHashRadio.TabStop = true; + this.SearchHashRadio.Text = "Hash"; + this.SearchHashRadio.UseVisualStyleBackColor = true; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(8, 6); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(30, 13); + this.label12.TabIndex = 32; + this.label12.Text = "Find:"; + // + // SearchTextBox + // + this.SearchTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SearchTextBox.Location = new System.Drawing.Point(44, 3); + this.SearchTextBox.Name = "SearchTextBox"; + this.SearchTextBox.Size = new System.Drawing.Size(412, 20); + this.SearchTextBox.TabIndex = 33; + this.SearchTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SearchTextBox_KeyDown); + // + // SearchButton + // + this.SearchButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.SearchButton.Location = new System.Drawing.Point(570, 2); + this.SearchButton.Name = "SearchButton"; + this.SearchButton.Size = new System.Drawing.Size(68, 23); + this.SearchButton.TabIndex = 34; + this.SearchButton.Text = "Search"; + this.SearchButton.UseVisualStyleBackColor = true; + this.SearchButton.Click += new System.EventHandler(this.SearchButton_Click); + // + // SearchResultsGrid + // + this.SearchResultsGrid.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.SearchResultsGrid.HelpVisible = false; + this.SearchResultsGrid.Location = new System.Drawing.Point(3, 31); + this.SearchResultsGrid.Name = "SearchResultsGrid"; + this.SearchResultsGrid.Size = new System.Drawing.Size(822, 423); + this.SearchResultsGrid.TabIndex = 1; + // + // MainToolbar + // + this.MainToolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.NewButton, + this.OpenButton, + this.SaveButton}); + this.MainToolbar.Location = new System.Drawing.Point(0, 24); + this.MainToolbar.Name = "MainToolbar"; + this.MainToolbar.Size = new System.Drawing.Size(839, 25); + this.MainToolbar.TabIndex = 9; + this.MainToolbar.Text = "Main Toolbar"; + // + // NewButton + // + this.NewButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.NewButton.Image = ((System.Drawing.Image)(resources.GetObject("NewButton.Image"))); + this.NewButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.NewButton.Name = "NewButton"; + this.NewButton.Size = new System.Drawing.Size(32, 22); + this.NewButton.Text = "New..."; + this.NewButton.ButtonClick += new System.EventHandler(this.NewButton_ButtonClick); + // + // OpenButton + // + this.OpenButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.OpenButton.Image = ((System.Drawing.Image)(resources.GetObject("OpenButton.Image"))); + this.OpenButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.OpenButton.Name = "OpenButton"; + this.OpenButton.Size = new System.Drawing.Size(32, 22); + this.OpenButton.Text = "Open..."; + this.OpenButton.ButtonClick += new System.EventHandler(this.OpenButton_ButtonClick); + // + // SaveButton + // + this.SaveButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.SaveButton.Image = ((System.Drawing.Image)(resources.GetObject("SaveButton.Image"))); + this.SaveButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.SaveButton.Name = "SaveButton"; + this.SaveButton.Size = new System.Drawing.Size(32, 22); + this.SaveButton.Text = "Save"; + this.SaveButton.ButtonClick += new System.EventHandler(this.SaveButton_ButtonClick); + // + // MainStatusStrip + // + this.MainStatusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.StatusLabel}); + this.MainStatusStrip.Location = new System.Drawing.Point(0, 535); + this.MainStatusStrip.Name = "MainStatusStrip"; + this.MainStatusStrip.Size = new System.Drawing.Size(839, 22); + this.MainStatusStrip.TabIndex = 7; + this.MainStatusStrip.Text = "Main Status Strip"; + // + // StatusLabel + // + this.StatusLabel.Name = "StatusLabel"; + this.StatusLabel.Size = new System.Drawing.Size(824, 17); + this.StatusLabel.Spring = true; + this.StatusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // MainMenu + // + this.MainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.FileMenu, + this.EditMenu, + this.ViewMenu}); + this.MainMenu.Location = new System.Drawing.Point(0, 0); + this.MainMenu.Name = "MainMenu"; + this.MainMenu.Size = new System.Drawing.Size(839, 24); + this.MainMenu.TabIndex = 8; + this.MainMenu.Text = "Main Menu"; + // + // FileMenu + // + this.FileMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.FileNewMenu, + this.FileOpenMenu, + this.FileSaveMenu, + this.FileSaveAsMenu, + this.toolStripSeparator1, + this.FileCloseMenu}); + this.FileMenu.Name = "FileMenu"; + this.FileMenu.Size = new System.Drawing.Size(37, 20); + this.FileMenu.Text = "File"; + // + // FileNewMenu + // + this.FileNewMenu.Name = "FileNewMenu"; + this.FileNewMenu.Size = new System.Drawing.Size(145, 22); + this.FileNewMenu.Text = "New"; + this.FileNewMenu.Click += new System.EventHandler(this.FileNewMenu_Click); + // + // FileOpenMenu + // + this.FileOpenMenu.Name = "FileOpenMenu"; + this.FileOpenMenu.Size = new System.Drawing.Size(145, 22); + this.FileOpenMenu.Text = "Open..."; + this.FileOpenMenu.Click += new System.EventHandler(this.FileOpenMenu_Click); + // + // FileSaveMenu + // + this.FileSaveMenu.Name = "FileSaveMenu"; + this.FileSaveMenu.Size = new System.Drawing.Size(145, 22); + this.FileSaveMenu.Text = "Save"; + this.FileSaveMenu.Click += new System.EventHandler(this.FileSaveMenu_Click); + // + // FileSaveAsMenu + // + this.FileSaveAsMenu.Name = "FileSaveAsMenu"; + this.FileSaveAsMenu.Size = new System.Drawing.Size(145, 22); + this.FileSaveAsMenu.Text = "Save As..."; + this.FileSaveAsMenu.Click += new System.EventHandler(this.FileSaveAsMenu_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(142, 6); + // + // FileCloseMenu + // + this.FileCloseMenu.Name = "FileCloseMenu"; + this.FileCloseMenu.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4))); + this.FileCloseMenu.Size = new System.Drawing.Size(145, 22); + this.FileCloseMenu.Text = "Close"; + this.FileCloseMenu.Click += new System.EventHandler(this.FileCloseMenu_Click); + // + // EditMenu + // + this.EditMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.wIPToolStripMenuItem}); + this.EditMenu.Enabled = false; + this.EditMenu.Name = "EditMenu"; + this.EditMenu.Size = new System.Drawing.Size(39, 20); + this.EditMenu.Text = "Edit"; + // + // wIPToolStripMenuItem + // + this.wIPToolStripMenuItem.Name = "wIPToolStripMenuItem"; + this.wIPToolStripMenuItem.Size = new System.Drawing.Size(106, 22); + this.wIPToolStripMenuItem.Text = "[WIP!]"; + // + // ViewMenu + // + this.ViewMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.wIPToolStripMenuItem1}); + this.ViewMenu.Enabled = false; + this.ViewMenu.Name = "ViewMenu"; + this.ViewMenu.Size = new System.Drawing.Size(44, 20); + this.ViewMenu.Text = "View"; + // + // wIPToolStripMenuItem1 + // + this.wIPToolStripMenuItem1.Name = "wIPToolStripMenuItem1"; + this.wIPToolStripMenuItem1.Size = new System.Drawing.Size(106, 22); + this.wIPToolStripMenuItem1.Text = "[WIP!]"; + // + // OpenFileDialog + // + this.OpenFileDialog.Filter = "XML files|*.xml|All files|*.*"; + // + // SaveFileDialog + // + this.SaveFileDialog.Filter = "XML files|*.xml|All files|*.*"; // // RelForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(671, 441); - this.Controls.Add(this.CloseButton); + this.ClientSize = new System.Drawing.Size(839, 557); this.Controls.Add(this.MainTabControl); + this.Controls.Add(this.MainToolbar); + this.Controls.Add(this.MainStatusStrip); + this.Controls.Add(this.MainMenu); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "RelForm"; - this.Text = "REL Viewer - CodeWalker by dexyfex"; + this.Text = "Audio dat.rel Editor - CodeWalker by dexyfex"; this.MainTabControl.ResumeLayout(false); + this.XmlTabPage.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.XmlTextBox)).EndInit(); this.DetailsTabPage.ResumeLayout(false); this.NameTableTabPage.ResumeLayout(false); this.NameTableTabPage.PerformLayout(); this.SearchTabPage.ResumeLayout(false); this.SearchTabPage.PerformLayout(); - this.XmlTabPage.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.XmlTextBox)).EndInit(); + this.MainToolbar.ResumeLayout(false); + this.MainToolbar.PerformLayout(); + this.MainStatusStrip.ResumeLayout(false); + this.MainStatusStrip.PerformLayout(); + this.MainMenu.ResumeLayout(false); + this.MainMenu.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -287,7 +471,6 @@ private System.Windows.Forms.TabPage NameTableTabPage; private System.Windows.Forms.TabPage DetailsTabPage; private WinForms.TextBoxFix MainTextBox; - private System.Windows.Forms.Button CloseButton; private System.Windows.Forms.TabPage SearchTabPage; private WinForms.PropertyGridFix SearchResultsGrid; private System.Windows.Forms.RadioButton SearchTextRadio; @@ -297,5 +480,25 @@ private System.Windows.Forms.Button SearchButton; private System.Windows.Forms.TabPage XmlTabPage; private FastColoredTextBoxNS.FastColoredTextBox XmlTextBox; + private System.Windows.Forms.ToolStrip MainToolbar; + private System.Windows.Forms.ToolStripSplitButton NewButton; + private System.Windows.Forms.ToolStripSplitButton OpenButton; + private System.Windows.Forms.ToolStripSplitButton SaveButton; + private System.Windows.Forms.StatusStrip MainStatusStrip; + private System.Windows.Forms.ToolStripStatusLabel StatusLabel; + private System.Windows.Forms.MenuStrip MainMenu; + private System.Windows.Forms.ToolStripMenuItem FileMenu; + private System.Windows.Forms.ToolStripMenuItem FileNewMenu; + private System.Windows.Forms.ToolStripMenuItem FileOpenMenu; + private System.Windows.Forms.ToolStripMenuItem FileSaveMenu; + private System.Windows.Forms.ToolStripMenuItem FileSaveAsMenu; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem FileCloseMenu; + private System.Windows.Forms.ToolStripMenuItem EditMenu; + private System.Windows.Forms.ToolStripMenuItem wIPToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem ViewMenu; + private System.Windows.Forms.ToolStripMenuItem wIPToolStripMenuItem1; + private System.Windows.Forms.OpenFileDialog OpenFileDialog; + private System.Windows.Forms.SaveFileDialog SaveFileDialog; } } \ No newline at end of file diff --git a/Forms/RelForm.cs b/Forms/RelForm.cs index 585b0e5..ca544a3 100644 --- a/Forms/RelForm.cs +++ b/Forms/RelForm.cs @@ -1,18 +1,31 @@ using CodeWalker.GameFiles; +using FastColoredTextBoxNS; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.Xml; namespace CodeWalker.Forms { public partial class RelForm : Form { + private string xml; + public string Xml + { + get { return xml; } + set + { + xml = value; + UpdateTextBoxFromData(); + } + } private string fileName; @@ -30,9 +43,19 @@ namespace CodeWalker.Forms private RelFile CurrentFile { get; set; } + private bool modified = false; + private bool LoadingXml = false; + private bool DelayHighlight = false; - public RelForm() + private ExploreForm exploreForm = null; + public RpfFileEntry rpfFileEntry { get; private set; } = null; + private MetaFormat metaFormat = MetaFormat.XML; + + + public RelForm(ExploreForm owner) { + exploreForm = owner; + InitializeComponent(); } @@ -40,7 +63,49 @@ namespace CodeWalker.Forms private void UpdateFormTitle() { - Text = fileName + " - REL Viewer - CodeWalker by dexyfex"; + Text = fileName + " - Audio dat.rel Editor - CodeWalker by dexyfex"; + } + + private void UpdateTextBoxFromData() + { + LoadingXml = true; + XmlTextBox.Text = ""; + XmlTextBox.Language = Language.XML; + DelayHighlight = false; + + if (string.IsNullOrEmpty(xml)) + { + LoadingXml = false; + return; + } + //if (xml.Length > (1048576 * 5)) + //{ + // XmlTextBox.Language = Language.Custom; + // XmlTextBox.Text = "[XML size > 10MB - Not shown due to performance limitations - Please use an external viewer for this file.]"; + // return; + //} + //else + if (xml.Length > (1024 * 512)) + { + XmlTextBox.Language = Language.Custom; + DelayHighlight = true; + } + //else + //{ + // XmlTextBox.Language = Language.XML; + //} + + + Cursor = Cursors.WaitCursor; + + + + XmlTextBox.Text = xml; + //XmlTextBox.IsChanged = false; + XmlTextBox.ClearUndo(); + + Cursor = Cursors.Default; + LoadingXml = false; } @@ -59,7 +124,11 @@ namespace CodeWalker.Forms CurrentFile = rel; - XmlTextBox.Text = RelXml.GetXml(rel); + rpfFileEntry = rel?.RpfFileEntry; + + Xml = RelXml.GetXml(rel); + + metaFormat = MetaFormat.AudioRel; StringBuilder sb = new StringBuilder(); if (rel != null) @@ -106,6 +175,216 @@ namespace CodeWalker.Forms } + + + private bool SaveRel(XmlDocument doc) + { + + if (!(exploreForm?.EditMode ?? false)) return false; + if (rpfFileEntry?.Parent == null) return false; + + byte[] data = null; + +#if !DEBUG + try +#endif + { + switch (metaFormat) + { + default: + case MetaFormat.XML: + return false;//what are we even doing here? + case MetaFormat.AudioRel: + var rel = XmlRel.GetRel(doc); + if ((rel?.RelDatasSorted == null) || (rel.RelDatasSorted.Length == 0)) + { + MessageBox.Show("Schema not supported.", "Cannot import REL XML"); + return false; + } + data = rel.Save(); + break; + } + } +#if !DEBUG + catch (Exception ex) + { + MessageBox.Show("Exception encountered!\r\n" + ex.ToString(), "Cannot convert XML"); + return false; + } +#endif + if (data == null) + { + MessageBox.Show("Schema not supported. (Unspecified error - data was null!)", "Cannot convert XML"); + return false; + } + + if (!rpfFileEntry.Path.ToLowerInvariant().StartsWith("mods")) + { + if (MessageBox.Show("This file is NOT located in the mods folder - Are you SURE you want to save this file?\r\nWARNING: This could cause permanent damage to your game!!!", "WARNING: Are you sure about this?", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return false;//that was a close one + } + } + + try + { + if (!(exploreForm?.EnsureRpfValidEncryption(rpfFileEntry.File) ?? false)) return false; + + var newentry = RpfFile.CreateFile(rpfFileEntry.Parent, rpfFileEntry.Name, data); + if (newentry != rpfFileEntry) + { } + rpfFileEntry = newentry; + + exploreForm?.RefreshMainListViewInvoke(); //update the file details in explorer... + + modified = false; + + StatusLabel.Text = metaFormat.ToString() + " file saved successfully at " + DateTime.Now.ToString(); + + return true; //victory! + } + catch (Exception ex) + { + MessageBox.Show("Error saving file to RPF! The RPF archive may be corrupted...\r\n" + ex.ToString(), "Really Bad Error"); + } + + return false; + } + + + + + private bool CloseDocument() + { + if (modified) + { + var res = MessageBox.Show("Do you want to save the current document before closing it?", "Save before closing", MessageBoxButtons.YesNoCancel); + switch (res) + { + case DialogResult.Yes: + SaveDocument(); + break; + case DialogResult.Cancel: + return false; + } + } + + FilePath = ""; + FileName = ""; + Xml = ""; + RelPropertyGrid.SelectedObject = null; + MainTextBox.Text = ""; + modified = false; + rpfFileEntry = null; + + return true; + } + private void NewDocument() + { + if (!CloseDocument()) return; + + FileName = "New.xml"; + rpfFileEntry = null; + + //TODO: decide XML/REL format..? + } + private void OpenDocument() + { + if (OpenFileDialog.ShowDialog() != DialogResult.OK) return; + + if (!CloseDocument()) return; + + var fn = OpenFileDialog.FileName; + + if (!File.Exists(fn)) return; //couldn't find file? + + Xml = File.ReadAllText(fn); + + modified = false; + FilePath = fn; + FileName = new FileInfo(fn).Name; + RelPropertyGrid.SelectedObject = null; + MainTextBox.Text = ""; + rpfFileEntry = null; + + //TODO: open raw REL..? + } + private void SaveDocument(bool saveAs = false) + { + if ((metaFormat != MetaFormat.XML) && (saveAs == false)) + { + var doc = new XmlDocument(); + try + { + doc.LoadXml(xml); + } + catch (Exception ex) + { + MessageBox.Show("There's something wrong with your XML document:\r\n" + ex.Message, "Unable to parse XML"); + return; + } + if (SaveRel(doc)) + { + return; + } + //if REL saving failed for whatever reason, fallback to saving the XML in the filesystem. + saveAs = true; + } + + if (string.IsNullOrEmpty(FileName)) saveAs = true; + if (string.IsNullOrEmpty(FilePath)) saveAs = true; + else if ((FilePath.ToLowerInvariant().StartsWith(GTAFolder.CurrentGTAFolder.ToLowerInvariant()))) saveAs = true; + if (!File.Exists(FilePath)) saveAs = true; + + var fn = FilePath; + if (saveAs) + { + if (!string.IsNullOrEmpty(fn)) + { + var dir = new FileInfo(fn).DirectoryName; + if (!Directory.Exists(dir)) dir = ""; + SaveFileDialog.InitialDirectory = dir; + } + SaveFileDialog.FileName = FileName; + if (SaveFileDialog.ShowDialog() != DialogResult.OK) return; + fn = SaveFileDialog.FileName; + } + + File.WriteAllText(fn, xml); + + modified = false; + FilePath = fn; + FileName = new FileInfo(fn).Name; + metaFormat = MetaFormat.XML; + } + + + + + + + Style BlueStyle = new TextStyle(Brushes.Blue, null, FontStyle.Regular); + Style RedStyle = new TextStyle(Brushes.Red, null, FontStyle.Regular); + Style MaroonStyle = new TextStyle(Brushes.Maroon, null, FontStyle.Regular); + + private void HTMLSyntaxHighlight(Range range) + { + //clear style of changed range + range.ClearStyle(BlueStyle, MaroonStyle, RedStyle); + //tag brackets highlighting + range.SetStyle(BlueStyle, @"<|/>|"); + //tag name + range.SetStyle(MaroonStyle, @"<(?[!\w]+)"); + //end of tag + range.SetStyle(MaroonStyle, @"\w+)>"); + //attributes + range.SetStyle(RedStyle, @"(?\S+?)='[^']*'|(?\S+)=""[^""]*""|(?\S+)=\S+"); + //attribute values + range.SetStyle(BlueStyle, @"\S+?=(?'[^']*')|\S+=(?""[^""]*"")|\S+=(?\S+)"); + } + + + private void Search() { SearchResultsGrid.SelectedObject = null; @@ -167,12 +446,6 @@ namespace CodeWalker.Forms } - - private void CloseButton_Click(object sender, EventArgs e) - { - Close(); - } - private void SearchButton_Click(object sender, EventArgs e) { Search(); @@ -185,5 +458,65 @@ namespace CodeWalker.Forms Search(); } } + + private void FileNewMenu_Click(object sender, EventArgs e) + { + NewDocument(); + } + + private void FileOpenMenu_Click(object sender, EventArgs e) + { + OpenDocument(); + } + + private void FileSaveMenu_Click(object sender, EventArgs e) + { + SaveDocument(); + } + + private void FileSaveAsMenu_Click(object sender, EventArgs e) + { + SaveDocument(true); + } + + private void FileCloseMenu_Click(object sender, EventArgs e) + { + Close(); + } + + private void NewButton_ButtonClick(object sender, EventArgs e) + { + NewDocument(); + } + + private void OpenButton_ButtonClick(object sender, EventArgs e) + { + OpenDocument(); + } + + private void SaveButton_ButtonClick(object sender, EventArgs e) + { + SaveDocument(); + } + + private void XmlTextBox_TextChanged(object sender, TextChangedEventArgs e) + { + if (!LoadingXml) + { + xml = XmlTextBox.Text; + modified = true; + } + } + + private void XmlTextBox_VisibleRangeChangedDelayed(object sender, EventArgs e) + { + //this approach is much faster to load, but no outlining is available + + //highlight only visible area of text + if (DelayHighlight) + { + HTMLSyntaxHighlight(XmlTextBox.VisibleRange); + } + } } } diff --git a/Forms/RelForm.resx b/Forms/RelForm.resx index 4d27add..0ddade0 100644 --- a/Forms/RelForm.resx +++ b/Forms/RelForm.resx @@ -135,7 +135,51 @@ CgAAAAAAAAAATgABAAH4/////P///woAAAAAAAAAAKQAAQAB9/////z///8KAAAAAAAAAACWAAEACw== + + 22, 15 + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADESURBVDhPzZI7DgIhGIQ5grUnsPQMnMgLWMo1bDyJiYUV + h7CxEo1Aiw7+E9ldWF+Nk0w2wMy3/z5UqRDCwjk3iTEmGmvsS6Ste2gtJYvrdjklJK9xLtGhcAeEdqtZ + Ouw3uUgA1tgXSH0SGdsyfD0dcwHXAmqRk0pXCNMsN+y893OpPYVDjFw8d9JaD2yMqUNYgjkBCmd36bgJ + 6b+DMUAJkXr9K9QANM6QkfpD/f/gYwCESfgnfgWg/gcw5peAdyzxX6TUDfMCML1omZa9AAAAAElFTkSu + QmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEcSURBVDhPlZKxqsIwFIb7Bvc+idxHuPQVXFpQcOhe8Amc + OqqzCBdU6HQfQIfunVwKoi7FQQeF9GrajufmhDYkTaMY+EjPyf//TZtY9aCUfhVFQRggQbBfSV4PFJ8v + GekMf8HqzqE3jXhIhRwsqKyWxYpJ3bzcMpBD4jgG27Y1RACaZ+sEPvoLbmqCa/f7AzLyJ2gGcDO+bXe6 + ajugDypMiBJQluU3f2DiZ+YmT3eANWIyIyKgFsv/AOs2k4wSgIXneRBFEaRpyhew10ZbwNb3fU1oYrPe + qAF5no/CMNSEJsbjiRqAty9JEk1ownEcNaA6BeK6riY2cdgf+SwC2Gf8BEGgCU2slis+iwB2mQZ4Ak3h + K0QAIeQTi/cp4B9tCZE2c6oRhQAAAABJRU5ErkJggg== + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABWSURBVDhPY6AK+Pbt238S8PsvX74YQLVCAEjCyckJjj+8 + /wjHyGIguq2tDdMQUgwAYZghUO2kGwDCID1Q7fgNQMbIamhrADF41IBBaQA5GKqdEsDAAADtDPd9n5qK + lQAAAABJRU5ErkJggg== + + + + 143, 15 + + + 281, 15 + + + 391, 15 + + + 526, 15 + AAABAAMAICAAAAAAGACoDAAANgAAABAQAAAAABgAaAMAAN4MAABAQAAAAAAYACgyAABGEAAAKAAAACAA