Relocated RPF binary search to BinarySearchForm. Added undo operations for audio placements. Removed RPF Browser tools menu entry (it's now obsolete). Renamed MainForm to MenuForm.

This commit is contained in:
dexyfex 2017-12-24 22:49:04 +11:00
parent 2a72aec735
commit ad46bc816c
14 changed files with 1608 additions and 178 deletions

View File

@ -29,126 +29,549 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BinarySearchForm));
this.TextRadio = new System.Windows.Forms.RadioButton();
this.HexRadio = new System.Windows.Forms.RadioButton();
this.SearchAbortButton = new System.Windows.Forms.Button();
this.SearchResultsTextBox = new System.Windows.Forms.TextBox();
this.BinSearchTextBox = new System.Windows.Forms.TextBox();
this.BinSearchFolderBrowseButton = new System.Windows.Forms.Button();
this.BinSearchButton = new System.Windows.Forms.Button();
this.FileSearchTextRadio = new System.Windows.Forms.RadioButton();
this.FileSearchHexRadio = new System.Windows.Forms.RadioButton();
this.FileSearchAbortButton = new System.Windows.Forms.Button();
this.FileSearchResultsTextBox = new System.Windows.Forms.TextBox();
this.FileSearchTextBox = new System.Windows.Forms.TextBox();
this.FileSearchFolderBrowseButton = new System.Windows.Forms.Button();
this.FileSearchButton = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.BinSearchFolderTextBox = new System.Windows.Forms.TextBox();
this.FileSearchFolderTextBox = new System.Windows.Forms.TextBox();
this.FolderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
this.MainTabControl = new System.Windows.Forms.TabControl();
this.SearchRPFTabPage = new System.Windows.Forms.TabPage();
this.SearchFileSystemTab = new System.Windows.Forms.TabPage();
this.MainStatusStrip = new System.Windows.Forms.StatusStrip();
this.StatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.FileSearchPanel = new System.Windows.Forms.Panel();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.RpfSearchSaveResultsButton = new System.Windows.Forms.Button();
this.RpfSearchIgnoreTextBox = new System.Windows.Forms.TextBox();
this.RpfSearchIgnoreCheckBox = new System.Windows.Forms.CheckBox();
this.RpfSearchBothDirectionsCheckBox = new System.Windows.Forms.CheckBox();
this.RpfSearchCaseSensitiveCheckBox = new System.Windows.Forms.CheckBox();
this.RpfSearchHexRadioButton = new System.Windows.Forms.RadioButton();
this.RpfSearchTextRadioButton = new System.Windows.Forms.RadioButton();
this.RpfSearchResultsListView = new System.Windows.Forms.ListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.RpfSearchAbortButton = new System.Windows.Forms.Button();
this.RpfSearchButton = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.RpfSearchTextBox = new System.Windows.Forms.TextBox();
this.RpfSearchOnlyTextBox = new System.Windows.Forms.TextBox();
this.RpfSearchOnlyCheckBox = new System.Windows.Forms.CheckBox();
this.ShowLargeFileContentsCheckBox = new System.Windows.Forms.CheckBox();
this.DataHexLineCombo = new System.Windows.Forms.ComboBox();
this.DataTextRadio = new System.Windows.Forms.RadioButton();
this.DataHexRadio = new System.Windows.Forms.RadioButton();
this.DataTextBox = new System.Windows.Forms.TextBox();
this.FileInfoLabel = new System.Windows.Forms.Label();
this.SaveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.ExportCompressCheckBox = new System.Windows.Forms.CheckBox();
this.ExportButton = new System.Windows.Forms.Button();
this.MainTabControl.SuspendLayout();
this.SearchRPFTabPage.SuspendLayout();
this.SearchFileSystemTab.SuspendLayout();
this.MainStatusStrip.SuspendLayout();
this.FileSearchPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// TextRadio
// FileSearchTextRadio
//
this.TextRadio.AutoSize = true;
this.TextRadio.Location = new System.Drawing.Point(169, 39);
this.TextRadio.Name = "TextRadio";
this.TextRadio.Size = new System.Drawing.Size(46, 17);
this.TextRadio.TabIndex = 45;
this.TextRadio.Text = "Text";
this.TextRadio.UseVisualStyleBackColor = true;
this.FileSearchTextRadio.AutoSize = true;
this.FileSearchTextRadio.Location = new System.Drawing.Point(162, 30);
this.FileSearchTextRadio.Name = "FileSearchTextRadio";
this.FileSearchTextRadio.Size = new System.Drawing.Size(46, 17);
this.FileSearchTextRadio.TabIndex = 45;
this.FileSearchTextRadio.Text = "Text";
this.FileSearchTextRadio.UseVisualStyleBackColor = true;
//
// HexRadio
// FileSearchHexRadio
//
this.HexRadio.AutoSize = true;
this.HexRadio.Checked = true;
this.HexRadio.Location = new System.Drawing.Point(119, 39);
this.HexRadio.Name = "HexRadio";
this.HexRadio.Size = new System.Drawing.Size(44, 17);
this.HexRadio.TabIndex = 44;
this.HexRadio.TabStop = true;
this.HexRadio.Text = "Hex";
this.HexRadio.UseVisualStyleBackColor = true;
this.FileSearchHexRadio.AutoSize = true;
this.FileSearchHexRadio.Checked = true;
this.FileSearchHexRadio.Location = new System.Drawing.Point(112, 30);
this.FileSearchHexRadio.Name = "FileSearchHexRadio";
this.FileSearchHexRadio.Size = new System.Drawing.Size(44, 17);
this.FileSearchHexRadio.TabIndex = 44;
this.FileSearchHexRadio.TabStop = true;
this.FileSearchHexRadio.Text = "Hex";
this.FileSearchHexRadio.UseVisualStyleBackColor = true;
//
// SearchAbortButton
// FileSearchAbortButton
//
this.SearchAbortButton.Location = new System.Drawing.Point(427, 36);
this.SearchAbortButton.Name = "SearchAbortButton";
this.SearchAbortButton.Size = new System.Drawing.Size(75, 23);
this.SearchAbortButton.TabIndex = 43;
this.SearchAbortButton.Text = "Abort";
this.SearchAbortButton.UseVisualStyleBackColor = true;
this.SearchAbortButton.Click += new System.EventHandler(this.SearchAbortButton_Click);
this.FileSearchAbortButton.Location = new System.Drawing.Point(420, 27);
this.FileSearchAbortButton.Name = "FileSearchAbortButton";
this.FileSearchAbortButton.Size = new System.Drawing.Size(75, 23);
this.FileSearchAbortButton.TabIndex = 43;
this.FileSearchAbortButton.Text = "Abort";
this.FileSearchAbortButton.UseVisualStyleBackColor = true;
this.FileSearchAbortButton.Click += new System.EventHandler(this.FileSearchAbortButton_Click);
//
// SearchResultsTextBox
// FileSearchResultsTextBox
//
this.SearchResultsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.FileSearchResultsTextBox.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.SearchResultsTextBox.Location = new System.Drawing.Point(14, 64);
this.SearchResultsTextBox.Multiline = true;
this.SearchResultsTextBox.Name = "SearchResultsTextBox";
this.SearchResultsTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.SearchResultsTextBox.Size = new System.Drawing.Size(487, 247);
this.SearchResultsTextBox.TabIndex = 42;
this.SearchResultsTextBox.WordWrap = false;
this.FileSearchResultsTextBox.Location = new System.Drawing.Point(85, 78);
this.FileSearchResultsTextBox.Multiline = true;
this.FileSearchResultsTextBox.Name = "FileSearchResultsTextBox";
this.FileSearchResultsTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.FileSearchResultsTextBox.Size = new System.Drawing.Size(685, 403);
this.FileSearchResultsTextBox.TabIndex = 42;
this.FileSearchResultsTextBox.WordWrap = false;
//
// BinSearchTextBox
// FileSearchTextBox
//
this.BinSearchTextBox.Location = new System.Drawing.Point(221, 38);
this.BinSearchTextBox.Name = "BinSearchTextBox";
this.BinSearchTextBox.Size = new System.Drawing.Size(119, 20);
this.BinSearchTextBox.TabIndex = 41;
this.BinSearchTextBox.Text = "4a03746e";
this.FileSearchTextBox.Location = new System.Drawing.Point(214, 29);
this.FileSearchTextBox.Name = "FileSearchTextBox";
this.FileSearchTextBox.Size = new System.Drawing.Size(119, 20);
this.FileSearchTextBox.TabIndex = 41;
this.FileSearchTextBox.Text = "4a03746e";
//
// BinSearchFolderBrowseButton
// FileSearchFolderBrowseButton
//
this.BinSearchFolderBrowseButton.Location = new System.Drawing.Point(346, 10);
this.BinSearchFolderBrowseButton.Name = "BinSearchFolderBrowseButton";
this.BinSearchFolderBrowseButton.Size = new System.Drawing.Size(27, 23);
this.BinSearchFolderBrowseButton.TabIndex = 40;
this.BinSearchFolderBrowseButton.Text = "...";
this.BinSearchFolderBrowseButton.UseVisualStyleBackColor = true;
this.BinSearchFolderBrowseButton.Click += new System.EventHandler(this.BinSearchFolderBrowseButton_Click);
this.FileSearchFolderBrowseButton.Location = new System.Drawing.Point(339, 1);
this.FileSearchFolderBrowseButton.Name = "FileSearchFolderBrowseButton";
this.FileSearchFolderBrowseButton.Size = new System.Drawing.Size(27, 23);
this.FileSearchFolderBrowseButton.TabIndex = 40;
this.FileSearchFolderBrowseButton.Text = "...";
this.FileSearchFolderBrowseButton.UseVisualStyleBackColor = true;
this.FileSearchFolderBrowseButton.Click += new System.EventHandler(this.FileSearchFolderBrowseButton_Click);
//
// BinSearchButton
// FileSearchButton
//
this.BinSearchButton.Location = new System.Drawing.Point(346, 36);
this.BinSearchButton.Name = "BinSearchButton";
this.BinSearchButton.Size = new System.Drawing.Size(75, 23);
this.BinSearchButton.TabIndex = 39;
this.BinSearchButton.Text = "Search";
this.BinSearchButton.UseVisualStyleBackColor = true;
this.BinSearchButton.Click += new System.EventHandler(this.BinSearchButton_Click);
this.FileSearchButton.Location = new System.Drawing.Point(339, 27);
this.FileSearchButton.Name = "FileSearchButton";
this.FileSearchButton.Size = new System.Drawing.Size(75, 23);
this.FileSearchButton.TabIndex = 39;
this.FileSearchButton.Text = "Search";
this.FileSearchButton.UseVisualStyleBackColor = true;
this.FileSearchButton.Click += new System.EventHandler(this.FileSearchButton_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(11, 15);
this.label2.Location = new System.Drawing.Point(3, 6);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(76, 13);
this.label2.Size = new System.Drawing.Size(73, 13);
this.label2.TabIndex = 38;
this.label2.Text = "Binary Search:";
this.label2.Text = "Search folder:";
//
// BinSearchFolderTextBox
// FileSearchFolderTextBox
//
this.BinSearchFolderTextBox.Location = new System.Drawing.Point(89, 12);
this.BinSearchFolderTextBox.Name = "BinSearchFolderTextBox";
this.BinSearchFolderTextBox.Size = new System.Drawing.Size(251, 20);
this.BinSearchFolderTextBox.TabIndex = 37;
this.BinSearchFolderTextBox.Text = "Compiled944";
this.FileSearchFolderTextBox.Location = new System.Drawing.Point(82, 3);
this.FileSearchFolderTextBox.Name = "FileSearchFolderTextBox";
this.FileSearchFolderTextBox.Size = new System.Drawing.Size(251, 20);
this.FileSearchFolderTextBox.TabIndex = 37;
this.FileSearchFolderTextBox.Text = "Compiled944";
//
// 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.SearchRPFTabPage);
this.MainTabControl.Controls.Add(this.SearchFileSystemTab);
this.MainTabControl.Location = new System.Drawing.Point(3, 5);
this.MainTabControl.Name = "MainTabControl";
this.MainTabControl.SelectedIndex = 0;
this.MainTabControl.Size = new System.Drawing.Size(846, 525);
this.MainTabControl.TabIndex = 46;
//
// SearchRPFTabPage
//
this.SearchRPFTabPage.Controls.Add(this.splitContainer1);
this.SearchRPFTabPage.Location = new System.Drawing.Point(4, 22);
this.SearchRPFTabPage.Name = "SearchRPFTabPage";
this.SearchRPFTabPage.Padding = new System.Windows.Forms.Padding(3);
this.SearchRPFTabPage.Size = new System.Drawing.Size(838, 499);
this.SearchRPFTabPage.TabIndex = 0;
this.SearchRPFTabPage.Text = "Search RPF contents";
this.SearchRPFTabPage.UseVisualStyleBackColor = true;
//
// SearchFileSystemTab
//
this.SearchFileSystemTab.Controls.Add(this.FileSearchPanel);
this.SearchFileSystemTab.Controls.Add(this.FileSearchResultsTextBox);
this.SearchFileSystemTab.Location = new System.Drawing.Point(4, 22);
this.SearchFileSystemTab.Name = "SearchFileSystemTab";
this.SearchFileSystemTab.Padding = new System.Windows.Forms.Padding(3);
this.SearchFileSystemTab.Size = new System.Drawing.Size(849, 499);
this.SearchFileSystemTab.TabIndex = 1;
this.SearchFileSystemTab.Text = "Search file system";
this.SearchFileSystemTab.UseVisualStyleBackColor = true;
//
// MainStatusStrip
//
this.MainStatusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.StatusLabel});
this.MainStatusStrip.Location = new System.Drawing.Point(0, 533);
this.MainStatusStrip.Name = "MainStatusStrip";
this.MainStatusStrip.Size = new System.Drawing.Size(852, 22);
this.MainStatusStrip.TabIndex = 47;
this.MainStatusStrip.Text = "statusStrip1";
//
// StatusLabel
//
this.StatusLabel.Name = "StatusLabel";
this.StatusLabel.Size = new System.Drawing.Size(837, 17);
this.StatusLabel.Spring = true;
this.StatusLabel.Text = "Initialising...";
this.StatusLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// FileSearchPanel
//
this.FileSearchPanel.Controls.Add(this.FileSearchFolderTextBox);
this.FileSearchPanel.Controls.Add(this.FileSearchFolderBrowseButton);
this.FileSearchPanel.Controls.Add(this.FileSearchTextRadio);
this.FileSearchPanel.Controls.Add(this.FileSearchTextBox);
this.FileSearchPanel.Controls.Add(this.FileSearchButton);
this.FileSearchPanel.Controls.Add(this.FileSearchHexRadio);
this.FileSearchPanel.Controls.Add(this.FileSearchAbortButton);
this.FileSearchPanel.Controls.Add(this.label2);
this.FileSearchPanel.Location = new System.Drawing.Point(3, 6);
this.FileSearchPanel.Name = "FileSearchPanel";
this.FileSearchPanel.Size = new System.Drawing.Size(536, 66);
this.FileSearchPanel.TabIndex = 46;
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(3, 3);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchOnlyTextBox);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchOnlyCheckBox);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchSaveResultsButton);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchIgnoreTextBox);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchIgnoreCheckBox);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchBothDirectionsCheckBox);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchCaseSensitiveCheckBox);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchHexRadioButton);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchTextRadioButton);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchResultsListView);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchAbortButton);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchButton);
this.splitContainer1.Panel1.Controls.Add(this.label3);
this.splitContainer1.Panel1.Controls.Add(this.RpfSearchTextBox);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.ExportCompressCheckBox);
this.splitContainer1.Panel2.Controls.Add(this.ExportButton);
this.splitContainer1.Panel2.Controls.Add(this.FileInfoLabel);
this.splitContainer1.Panel2.Controls.Add(this.ShowLargeFileContentsCheckBox);
this.splitContainer1.Panel2.Controls.Add(this.DataHexLineCombo);
this.splitContainer1.Panel2.Controls.Add(this.DataTextRadio);
this.splitContainer1.Panel2.Controls.Add(this.DataHexRadio);
this.splitContainer1.Panel2.Controls.Add(this.DataTextBox);
this.splitContainer1.Size = new System.Drawing.Size(832, 493);
this.splitContainer1.SplitterDistance = 270;
this.splitContainer1.TabIndex = 1;
//
// RpfSearchSaveResultsButton
//
this.RpfSearchSaveResultsButton.Enabled = false;
this.RpfSearchSaveResultsButton.Location = new System.Drawing.Point(181, 118);
this.RpfSearchSaveResultsButton.Name = "RpfSearchSaveResultsButton";
this.RpfSearchSaveResultsButton.Size = new System.Drawing.Size(86, 22);
this.RpfSearchSaveResultsButton.TabIndex = 62;
this.RpfSearchSaveResultsButton.Text = "Save results...";
this.RpfSearchSaveResultsButton.UseVisualStyleBackColor = true;
this.RpfSearchSaveResultsButton.Click += new System.EventHandler(this.RpfSearchSaveResultsButton_Click);
//
// RpfSearchIgnoreTextBox
//
this.RpfSearchIgnoreTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.RpfSearchIgnoreTextBox.Location = new System.Drawing.Point(68, 68);
this.RpfSearchIgnoreTextBox.Name = "RpfSearchIgnoreTextBox";
this.RpfSearchIgnoreTextBox.Size = new System.Drawing.Size(198, 20);
this.RpfSearchIgnoreTextBox.TabIndex = 59;
this.RpfSearchIgnoreTextBox.Text = ".ydr, .ydd, .ytd, .yft, .ybn, .ycd, .awc, .bik";
//
// RpfSearchIgnoreCheckBox
//
this.RpfSearchIgnoreCheckBox.AutoSize = true;
this.RpfSearchIgnoreCheckBox.Checked = true;
this.RpfSearchIgnoreCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.RpfSearchIgnoreCheckBox.Location = new System.Drawing.Point(9, 70);
this.RpfSearchIgnoreCheckBox.Name = "RpfSearchIgnoreCheckBox";
this.RpfSearchIgnoreCheckBox.Size = new System.Drawing.Size(59, 17);
this.RpfSearchIgnoreCheckBox.TabIndex = 58;
this.RpfSearchIgnoreCheckBox.Text = "Ignore:";
this.RpfSearchIgnoreCheckBox.UseVisualStyleBackColor = true;
this.RpfSearchIgnoreCheckBox.CheckedChanged += new System.EventHandler(this.RpfSearchIgnoreCheckBox_CheckedChanged);
//
// RpfSearchBothDirectionsCheckBox
//
this.RpfSearchBothDirectionsCheckBox.AutoSize = true;
this.RpfSearchBothDirectionsCheckBox.Checked = true;
this.RpfSearchBothDirectionsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.RpfSearchBothDirectionsCheckBox.Location = new System.Drawing.Point(109, 48);
this.RpfSearchBothDirectionsCheckBox.Name = "RpfSearchBothDirectionsCheckBox";
this.RpfSearchBothDirectionsCheckBox.Size = new System.Drawing.Size(96, 17);
this.RpfSearchBothDirectionsCheckBox.TabIndex = 57;
this.RpfSearchBothDirectionsCheckBox.Text = "Both directions";
this.RpfSearchBothDirectionsCheckBox.UseVisualStyleBackColor = true;
//
// RpfSearchCaseSensitiveCheckBox
//
this.RpfSearchCaseSensitiveCheckBox.AutoSize = true;
this.RpfSearchCaseSensitiveCheckBox.Location = new System.Drawing.Point(9, 48);
this.RpfSearchCaseSensitiveCheckBox.Name = "RpfSearchCaseSensitiveCheckBox";
this.RpfSearchCaseSensitiveCheckBox.Size = new System.Drawing.Size(94, 17);
this.RpfSearchCaseSensitiveCheckBox.TabIndex = 56;
this.RpfSearchCaseSensitiveCheckBox.Text = "Case-sensitive";
this.RpfSearchCaseSensitiveCheckBox.UseVisualStyleBackColor = true;
//
// RpfSearchHexRadioButton
//
this.RpfSearchHexRadioButton.AutoSize = true;
this.RpfSearchHexRadioButton.Location = new System.Drawing.Point(158, 5);
this.RpfSearchHexRadioButton.Name = "RpfSearchHexRadioButton";
this.RpfSearchHexRadioButton.Size = new System.Drawing.Size(44, 17);
this.RpfSearchHexRadioButton.TabIndex = 55;
this.RpfSearchHexRadioButton.Text = "Hex";
this.RpfSearchHexRadioButton.UseVisualStyleBackColor = true;
//
// RpfSearchTextRadioButton
//
this.RpfSearchTextRadioButton.AutoSize = true;
this.RpfSearchTextRadioButton.Checked = true;
this.RpfSearchTextRadioButton.Location = new System.Drawing.Point(106, 5);
this.RpfSearchTextRadioButton.Name = "RpfSearchTextRadioButton";
this.RpfSearchTextRadioButton.Size = new System.Drawing.Size(46, 17);
this.RpfSearchTextRadioButton.TabIndex = 54;
this.RpfSearchTextRadioButton.TabStop = true;
this.RpfSearchTextRadioButton.Text = "Text";
this.RpfSearchTextRadioButton.UseVisualStyleBackColor = true;
this.RpfSearchTextRadioButton.CheckedChanged += new System.EventHandler(this.RpfSearchTextRadioButton_CheckedChanged);
//
// RpfSearchResultsListView
//
this.RpfSearchResultsListView.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.RpfSearchResultsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.RpfSearchResultsListView.FullRowSelect = true;
this.RpfSearchResultsListView.HideSelection = false;
this.RpfSearchResultsListView.Location = new System.Drawing.Point(3, 146);
this.RpfSearchResultsListView.MultiSelect = false;
this.RpfSearchResultsListView.Name = "RpfSearchResultsListView";
this.RpfSearchResultsListView.Size = new System.Drawing.Size(263, 347);
this.RpfSearchResultsListView.TabIndex = 63;
this.RpfSearchResultsListView.UseCompatibleStateImageBehavior = false;
this.RpfSearchResultsListView.View = System.Windows.Forms.View.Details;
this.RpfSearchResultsListView.VirtualMode = true;
this.RpfSearchResultsListView.RetrieveVirtualItem += new System.Windows.Forms.RetrieveVirtualItemEventHandler(this.RpfSearchResultsListView_RetrieveVirtualItem);
this.RpfSearchResultsListView.SelectedIndexChanged += new System.EventHandler(this.RpfSearchResultsListView_SelectedIndexChanged);
//
// columnHeader1
//
this.columnHeader1.Text = "File";
this.columnHeader1.Width = 176;
//
// columnHeader2
//
this.columnHeader2.Text = "Offset";
//
// RpfSearchAbortButton
//
this.RpfSearchAbortButton.Location = new System.Drawing.Point(90, 118);
this.RpfSearchAbortButton.Name = "RpfSearchAbortButton";
this.RpfSearchAbortButton.Size = new System.Drawing.Size(75, 22);
this.RpfSearchAbortButton.TabIndex = 61;
this.RpfSearchAbortButton.Text = "Abort";
this.RpfSearchAbortButton.UseVisualStyleBackColor = true;
this.RpfSearchAbortButton.Click += new System.EventHandler(this.RpfSearchAbortButton_Click);
//
// RpfSearchButton
//
this.RpfSearchButton.Location = new System.Drawing.Point(9, 119);
this.RpfSearchButton.Name = "RpfSearchButton";
this.RpfSearchButton.Size = new System.Drawing.Size(75, 22);
this.RpfSearchButton.TabIndex = 60;
this.RpfSearchButton.Text = "Search";
this.RpfSearchButton.UseVisualStyleBackColor = true;
this.RpfSearchButton.Click += new System.EventHandler(this.RpfSearchButton_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(7, 7);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(91, 13);
this.label3.TabIndex = 64;
this.label3.Text = "Search in files for:";
//
// RpfSearchTextBox
//
this.RpfSearchTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.RpfSearchTextBox.Location = new System.Drawing.Point(3, 23);
this.RpfSearchTextBox.Name = "RpfSearchTextBox";
this.RpfSearchTextBox.Size = new System.Drawing.Size(263, 20);
this.RpfSearchTextBox.TabIndex = 53;
//
// RpfSearchOnlyTextBox
//
this.RpfSearchOnlyTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.RpfSearchOnlyTextBox.Enabled = false;
this.RpfSearchOnlyTextBox.Location = new System.Drawing.Point(68, 92);
this.RpfSearchOnlyTextBox.Name = "RpfSearchOnlyTextBox";
this.RpfSearchOnlyTextBox.Size = new System.Drawing.Size(198, 20);
this.RpfSearchOnlyTextBox.TabIndex = 66;
this.RpfSearchOnlyTextBox.Text = ".ysc, .rel";
//
// RpfSearchOnlyCheckBox
//
this.RpfSearchOnlyCheckBox.AutoSize = true;
this.RpfSearchOnlyCheckBox.Location = new System.Drawing.Point(9, 94);
this.RpfSearchOnlyCheckBox.Name = "RpfSearchOnlyCheckBox";
this.RpfSearchOnlyCheckBox.Size = new System.Drawing.Size(50, 17);
this.RpfSearchOnlyCheckBox.TabIndex = 65;
this.RpfSearchOnlyCheckBox.Text = "Only:";
this.RpfSearchOnlyCheckBox.UseVisualStyleBackColor = true;
this.RpfSearchOnlyCheckBox.CheckedChanged += new System.EventHandler(this.RpfSearchOnlyCheckBox_CheckedChanged);
//
// ShowLargeFileContentsCheckBox
//
this.ShowLargeFileContentsCheckBox.AutoSize = true;
this.ShowLargeFileContentsCheckBox.Location = new System.Drawing.Point(392, 62);
this.ShowLargeFileContentsCheckBox.Name = "ShowLargeFileContentsCheckBox";
this.ShowLargeFileContentsCheckBox.Size = new System.Drawing.Size(139, 17);
this.ShowLargeFileContentsCheckBox.TabIndex = 109;
this.ShowLargeFileContentsCheckBox.Text = "Show large file contents";
this.ShowLargeFileContentsCheckBox.UseVisualStyleBackColor = true;
this.ShowLargeFileContentsCheckBox.CheckedChanged += new System.EventHandler(this.ShowLargeFileContentsCheckBox_CheckedChanged);
//
// DataHexLineCombo
//
this.DataHexLineCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.DataHexLineCombo.FormattingEnabled = true;
this.DataHexLineCombo.Items.AddRange(new object[] {
"8",
"16",
"32"});
this.DataHexLineCombo.Location = new System.Drawing.Point(56, 60);
this.DataHexLineCombo.Name = "DataHexLineCombo";
this.DataHexLineCombo.Size = new System.Drawing.Size(49, 21);
this.DataHexLineCombo.TabIndex = 106;
this.DataHexLineCombo.SelectedIndexChanged += new System.EventHandler(this.DataHexLineCombo_SelectedIndexChanged);
//
// DataTextRadio
//
this.DataTextRadio.AutoSize = true;
this.DataTextRadio.Location = new System.Drawing.Point(135, 61);
this.DataTextRadio.Name = "DataTextRadio";
this.DataTextRadio.Size = new System.Drawing.Size(46, 17);
this.DataTextRadio.TabIndex = 107;
this.DataTextRadio.Text = "Text";
this.DataTextRadio.UseVisualStyleBackColor = true;
//
// DataHexRadio
//
this.DataHexRadio.AutoSize = true;
this.DataHexRadio.Checked = true;
this.DataHexRadio.Location = new System.Drawing.Point(6, 61);
this.DataHexRadio.Name = "DataHexRadio";
this.DataHexRadio.Size = new System.Drawing.Size(44, 17);
this.DataHexRadio.TabIndex = 105;
this.DataHexRadio.TabStop = true;
this.DataHexRadio.Text = "Hex";
this.DataHexRadio.UseVisualStyleBackColor = true;
this.DataHexRadio.CheckedChanged += new System.EventHandler(this.DataHexRadio_CheckedChanged);
//
// DataTextBox
//
this.DataTextBox.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.DataTextBox.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.DataTextBox.HideSelection = false;
this.DataTextBox.Location = new System.Drawing.Point(4, 92);
this.DataTextBox.Multiline = true;
this.DataTextBox.Name = "DataTextBox";
this.DataTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.DataTextBox.Size = new System.Drawing.Size(552, 401);
this.DataTextBox.TabIndex = 108;
this.DataTextBox.Text = "[Please select a search result]";
this.DataTextBox.WordWrap = false;
//
// FileInfoLabel
//
this.FileInfoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.FileInfoLabel.AutoEllipsis = true;
this.FileInfoLabel.Location = new System.Drawing.Point(3, 7);
this.FileInfoLabel.Name = "FileInfoLabel";
this.FileInfoLabel.Size = new System.Drawing.Size(549, 16);
this.FileInfoLabel.TabIndex = 110;
this.FileInfoLabel.Text = "[Nothing selected]";
//
// SaveFileDialog
//
this.SaveFileDialog.AddExtension = false;
//
// ExportCompressCheckBox
//
this.ExportCompressCheckBox.AutoSize = true;
this.ExportCompressCheckBox.Location = new System.Drawing.Point(87, 35);
this.ExportCompressCheckBox.Name = "ExportCompressCheckBox";
this.ExportCompressCheckBox.Size = new System.Drawing.Size(104, 17);
this.ExportCompressCheckBox.TabIndex = 112;
this.ExportCompressCheckBox.Text = "Compress export";
this.ExportCompressCheckBox.UseVisualStyleBackColor = true;
//
// ExportButton
//
this.ExportButton.Location = new System.Drawing.Point(6, 31);
this.ExportButton.Name = "ExportButton";
this.ExportButton.Size = new System.Drawing.Size(75, 23);
this.ExportButton.TabIndex = 111;
this.ExportButton.Text = "Export...";
this.ExportButton.UseVisualStyleBackColor = true;
this.ExportButton.Click += new System.EventHandler(this.ExportButton_Click);
//
// BinarySearchForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(513, 323);
this.Controls.Add(this.TextRadio);
this.Controls.Add(this.HexRadio);
this.Controls.Add(this.SearchAbortButton);
this.Controls.Add(this.SearchResultsTextBox);
this.Controls.Add(this.BinSearchTextBox);
this.Controls.Add(this.BinSearchFolderBrowseButton);
this.Controls.Add(this.BinSearchButton);
this.Controls.Add(this.label2);
this.Controls.Add(this.BinSearchFolderTextBox);
this.ClientSize = new System.Drawing.Size(852, 555);
this.Controls.Add(this.MainStatusStrip);
this.Controls.Add(this.MainTabControl);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "BinarySearchForm";
this.Text = "Binary Search - CodeWalker by dexyfex";
this.Load += new System.EventHandler(this.SearchForm_Load);
this.Load += new System.EventHandler(this.BinarySearchForm_Load);
this.MainTabControl.ResumeLayout(false);
this.SearchRPFTabPage.ResumeLayout(false);
this.SearchFileSystemTab.ResumeLayout(false);
this.SearchFileSystemTab.PerformLayout();
this.MainStatusStrip.ResumeLayout(false);
this.MainStatusStrip.PerformLayout();
this.FileSearchPanel.ResumeLayout(false);
this.FileSearchPanel.PerformLayout();
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -156,15 +579,47 @@
#endregion
private System.Windows.Forms.RadioButton TextRadio;
private System.Windows.Forms.RadioButton HexRadio;
private System.Windows.Forms.Button SearchAbortButton;
private System.Windows.Forms.TextBox SearchResultsTextBox;
private System.Windows.Forms.TextBox BinSearchTextBox;
private System.Windows.Forms.Button BinSearchFolderBrowseButton;
private System.Windows.Forms.Button BinSearchButton;
private System.Windows.Forms.RadioButton FileSearchTextRadio;
private System.Windows.Forms.RadioButton FileSearchHexRadio;
private System.Windows.Forms.Button FileSearchAbortButton;
private System.Windows.Forms.TextBox FileSearchResultsTextBox;
private System.Windows.Forms.TextBox FileSearchTextBox;
private System.Windows.Forms.Button FileSearchFolderBrowseButton;
private System.Windows.Forms.Button FileSearchButton;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox BinSearchFolderTextBox;
private System.Windows.Forms.TextBox FileSearchFolderTextBox;
private System.Windows.Forms.FolderBrowserDialog FolderBrowserDialog;
private System.Windows.Forms.TabControl MainTabControl;
private System.Windows.Forms.TabPage SearchRPFTabPage;
private System.Windows.Forms.TabPage SearchFileSystemTab;
private System.Windows.Forms.StatusStrip MainStatusStrip;
private System.Windows.Forms.ToolStripStatusLabel StatusLabel;
private System.Windows.Forms.Panel FileSearchPanel;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Button RpfSearchSaveResultsButton;
private System.Windows.Forms.TextBox RpfSearchIgnoreTextBox;
private System.Windows.Forms.CheckBox RpfSearchIgnoreCheckBox;
private System.Windows.Forms.CheckBox RpfSearchBothDirectionsCheckBox;
private System.Windows.Forms.CheckBox RpfSearchCaseSensitiveCheckBox;
private System.Windows.Forms.RadioButton RpfSearchHexRadioButton;
private System.Windows.Forms.RadioButton RpfSearchTextRadioButton;
private System.Windows.Forms.ListView RpfSearchResultsListView;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.Button RpfSearchAbortButton;
private System.Windows.Forms.Button RpfSearchButton;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox RpfSearchTextBox;
private System.Windows.Forms.TextBox RpfSearchOnlyTextBox;
private System.Windows.Forms.CheckBox RpfSearchOnlyCheckBox;
private System.Windows.Forms.CheckBox ShowLargeFileContentsCheckBox;
private System.Windows.Forms.ComboBox DataHexLineCombo;
private System.Windows.Forms.RadioButton DataTextRadio;
private System.Windows.Forms.RadioButton DataHexRadio;
private System.Windows.Forms.TextBox DataTextBox;
private System.Windows.Forms.Label FileInfoLabel;
private System.Windows.Forms.SaveFileDialog SaveFileDialog;
private System.Windows.Forms.CheckBox ExportCompressCheckBox;
private System.Windows.Forms.Button ExportButton;
}
}

View File

@ -1,4 +1,5 @@
using CodeWalker.Properties;
using CodeWalker.GameFiles;
using CodeWalker.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -17,31 +18,97 @@ namespace CodeWalker
private volatile bool InProgress = false;
private volatile bool AbortOperation = false;
public BinarySearchForm()
private GameFileCache FileCache = null;
private RpfManager RpfMan = null;
public BinarySearchForm(GameFileCache cache = null)
{
FileCache = cache;
RpfMan = cache?.RpfMan;
InitializeComponent();
}
private void SearchForm_Load(object sender, EventArgs e)
private void BinarySearchForm_Load(object sender, EventArgs e)
{
BinSearchFolderTextBox.Text = Settings.Default.CompiledScriptFolder;
}
FileSearchFolderTextBox.Text = Settings.Default.CompiledScriptFolder;
DataHexLineCombo.Text = "16";
DataTextBox.SetTabStopWidth(3);
private void BinSearchFolderBrowseButton_Click(object sender, EventArgs e)
{
FolderBrowserDialog.SelectedPath = BinSearchFolderTextBox.Text;
DialogResult res = FolderBrowserDialog.ShowDialog();
if (res == DialogResult.OK)
if (RpfMan == null)
{
BinSearchFolderTextBox.Text = FolderBrowserDialog.SelectedPath;
Task.Run(() =>
{
GTA5Keys.LoadFromPath(Settings.Default.GTAFolder);
RpfMan = new RpfManager();
RpfMan.Init(Settings.Default.GTAFolder, UpdateStatus, UpdateStatus, false, false);
RPFScanComplete();
});
}
else
{
RPFScanComplete();
}
}
private void BinSearchButton_Click(object sender, EventArgs e)
private void UpdateStatus(string text)
{
string searchtxt = BinSearchTextBox.Text;
string searchfolder = BinSearchFolderTextBox.Text;
try
{
if (InvokeRequired)
{
Invoke(new Action(() => { UpdateStatus(text); }));
}
else
{
StatusLabel.Text = text;
}
}
catch { }
}
private void RPFScanComplete()
{
try
{
if (InvokeRequired)
{
Invoke(new Action(() => { RPFScanComplete(); }));
}
else
{
StatusLabel.Text = "Ready";
//RpfSearchPanel.Enabled = true;
}
}
catch { }
}
private void FileSearchFolderBrowseButton_Click(object sender, EventArgs e)
{
FolderBrowserDialog.SelectedPath = FileSearchFolderTextBox.Text;
DialogResult res = FolderBrowserDialog.ShowDialog();
if (res == DialogResult.OK)
{
FileSearchFolderTextBox.Text = FolderBrowserDialog.SelectedPath;
}
}
private void FileSearchButton_Click(object sender, EventArgs e)
{
string searchtxt = FileSearchTextBox.Text;
string searchfolder = FileSearchFolderTextBox.Text;
AbortOperation = false;
if (InProgress) return;
@ -56,13 +123,13 @@ namespace CodeWalker
return;
}
SearchResultsTextBox.Clear();
FileSearchResultsTextBox.Clear();
byte[] searchbytes1;
byte[] searchbytes2;
int bytelen;
if (HexRadio.Checked)
if (FileSearchHexRadio.Checked)
{
try
{
@ -93,12 +160,14 @@ namespace CodeWalker
}
}
FileSearchPanel.Enabled = false;
InProgress = true;
Task.Run(() =>
{
AddSearchResult("Searching " + searchfolder + "...");
FileSearchAddResult("Searching " + searchfolder + "...");
string[] filenames = Directory.GetFiles(searchfolder);
@ -125,21 +194,22 @@ namespace CodeWalker
if (hitlen1 == bytelen)
{
AddSearchResult(finf.Name + ":" + (i - bytelen));
FileSearchAddResult(finf.Name + ":" + (i - bytelen));
matchcount++;
hitlen1 = 0;
}
if (hitlen2 == bytelen)
{
AddSearchResult(finf.Name + ":" + (i - bytelen));
FileSearchAddResult(finf.Name + ":" + (i - bytelen));
matchcount++;
hitlen2 = 0;
}
if (AbortOperation)
{
FileSearchAddResult("Search aborted.");
FileSearchComplete();
InProgress = false;
AddSearchResult("Search aborted.");
return;
}
@ -147,31 +217,766 @@ namespace CodeWalker
}
AddSearchResult(string.Format("Search complete. {0} results found.", matchcount));
FileSearchAddResult(string.Format("Search complete. {0} results found.", matchcount));
FileSearchComplete();
InProgress = false;
});
}
private void AddSearchResult(string result)
private void FileSearchAddResult(string result)
{
try
{
if (InvokeRequired)
{
Invoke(new Action(() => { AddSearchResult(result); }));
Invoke(new Action(() => { FileSearchAddResult(result); }));
}
else
{
SearchResultsTextBox.AppendText(result + "\r\n");
FileSearchResultsTextBox.AppendText(result + "\r\n");
}
}
catch { }
}
private void SearchAbortButton_Click(object sender, EventArgs e)
private void FileSearchComplete()
{
try
{
if (InvokeRequired)
{
Invoke(new Action(() => { FileSearchComplete(); }));
}
else
{
FileSearchPanel.Enabled = true;
}
}
catch { }
}
private void FileSearchAbortButton_Click(object sender, EventArgs e)
{
AbortOperation = true;
}
private List<RpfSearchResult> RpfSearchResults = new List<RpfSearchResult>();
private RpfEntry RpfSelectedEntry = null;
private int RpfSelectedOffset = -1;
private int RpfSelectedLength = 0;
private class RpfSearchResult
{
public RpfFileEntry FileEntry { get; set; }
public int Offset { get; set; }
public int Length { get; set; }
public RpfSearchResult(RpfFileEntry entry, int offset, int length)
{
FileEntry = entry;
Offset = offset;
Length = length;
}
}
private byte LowerCaseByte(byte b)
{
if ((b >= 65) && (b <= 90)) //upper case alphabet...
{
b += 32;
}
return b;
}
private void RpfSearchAddResult(RpfSearchResult result)
{
try
{
if (InvokeRequired)
{
Invoke(new Action(() => { RpfSearchAddResult(result); }));
}
else
{
RpfSearchResults.Add(result);
RpfSearchResultsListView.VirtualListSize = RpfSearchResults.Count;
}
}
catch { }
}
private void RpfSearch()
{
if (InProgress) return;
if (!(RpfMan?.IsInited ?? false))
{
MessageBox.Show("Please wait for the scan to complete.");
return;
}
if (RpfSearchTextBox.Text.Length == 0)
{
MessageBox.Show("Please enter a search term.");
return;
}
string searchtxt = RpfSearchTextBox.Text;
bool hex = RpfSearchHexRadioButton.Checked;
bool casesen = RpfSearchCaseSensitiveCheckBox.Checked || hex;
bool bothdirs = RpfSearchBothDirectionsCheckBox.Checked;
string[] ignoreexts = null;
string[] onlyexts = null;
byte[] searchbytes1;
byte[] searchbytes2;
int bytelen;
if (!casesen) searchtxt = searchtxt.ToLowerInvariant(); //case sensitive search in lower case.
if (RpfSearchIgnoreCheckBox.Checked)
{
ignoreexts = RpfSearchIgnoreTextBox.Text.Split(',');
for (int i = 0; i < ignoreexts.Length; i++)
{
ignoreexts[i] = ignoreexts[i].Trim();
}
}
if (RpfSearchOnlyCheckBox.Checked)
{
onlyexts = RpfSearchOnlyTextBox.Text.Split(',');
for (int i = 0; i < onlyexts.Length; i++)
{
onlyexts[i] = onlyexts[i].Trim();
}
}
if (hex)
{
if (searchtxt.Length < 2)
{
MessageBox.Show("Please enter at least one byte of hex (2 characters).");
return;
}
try
{
bytelen = searchtxt.Length / 2;
searchbytes1 = new byte[bytelen];
searchbytes2 = new byte[bytelen];
for (int i = 0; i < bytelen; i++)
{
searchbytes1[i] = Convert.ToByte(searchtxt.Substring(i * 2, 2), 16);
searchbytes2[bytelen - i - 1] = searchbytes1[i];
}
}
catch
{
MessageBox.Show("Please enter a valid hex string.");
return;
}
}
else
{
bytelen = searchtxt.Length;
searchbytes1 = new byte[bytelen];
searchbytes2 = new byte[bytelen]; //reversed text...
for (int i = 0; i < bytelen; i++)
{
searchbytes1[i] = (byte)searchtxt[i];
searchbytes2[bytelen - i - 1] = searchbytes1[i];
}
}
RpfSearchTextBox.Enabled = false;
RpfSearchHexRadioButton.Enabled = false;
RpfSearchTextRadioButton.Enabled = false;
RpfSearchCaseSensitiveCheckBox.Enabled = false;
RpfSearchBothDirectionsCheckBox.Enabled = false;
RpfSearchIgnoreCheckBox.Enabled = false;
RpfSearchIgnoreTextBox.Enabled = false;
RpfSearchButton.Enabled = false;
RpfSearchSaveResultsButton.Enabled = false;
InProgress = true;
AbortOperation = false;
RpfSearchResultsListView.VirtualListSize = 0;
RpfSearchResults.Clear();
uint totfiles = 0;
uint curfile = 0;
var scannedFiles = RpfMan.AllRpfs;
Task.Run(() =>
{
DateTime starttime = DateTime.Now;
int resultcount = 0;
for (int f = 0; f < scannedFiles.Count; f++)
{
var rpffile = scannedFiles[f];
totfiles += rpffile.GrandTotalFileCount;
}
for (int f = 0; f < scannedFiles.Count; f++)
{
var rpffile = scannedFiles[f];
foreach (var entry in rpffile.AllEntries)
{
var duration = DateTime.Now - starttime;
if (AbortOperation)
{
UpdateStatus(duration.ToString(@"hh\:mm\:ss") + " - Search aborted.");
InProgress = false;
RpfSearchComplete();
return;
}
RpfFileEntry fentry = entry as RpfFileEntry;
if (fentry == null) continue;
curfile++;
if (fentry.NameLower.EndsWith(".rpf"))
{ continue; }
if (onlyexts != null)
{
bool ignore = true;
for (int i = 0; i < onlyexts.Length; i++)
{
if (fentry.NameLower.EndsWith(onlyexts[i]))
{
ignore = false;
break;
}
}
if (ignore)
{ continue; }
}
if (ignoreexts != null)
{
bool ignore = false;
for (int i = 0; i < ignoreexts.Length; i++)
{
if (fentry.NameLower.EndsWith(ignoreexts[i]))
{
ignore = true;
break;
}
}
if (ignore)
{ continue; }
}
UpdateStatus(string.Format("{0} - Searching {1}/{2} : {3}", duration.ToString(@"hh\:mm\:ss"), curfile, totfiles, fentry.Path));
byte[] filebytes = fentry.File.ExtractFile(fentry);
if (filebytes == null) continue;
int hitlen1 = 0;
int hitlen2 = 0;
for (int i = 0; i < filebytes.Length; i++)
{
byte b = casesen ? filebytes[i] : LowerCaseByte(filebytes[i]);
byte b1 = searchbytes1[hitlen1]; //current test byte 1
byte b2 = searchbytes2[hitlen2];
if (b == b1) hitlen1++; else hitlen1 = 0;
if (b == b2) hitlen2++; else hitlen2 = 0;
if (hitlen1 == bytelen)
{
RpfSearchAddResult(new RpfSearchResult(fentry, (i - bytelen), bytelen));
resultcount++;
hitlen1 = 0;
}
if (hitlen2 == bytelen)
{
RpfSearchAddResult(new RpfSearchResult(fentry, (i - bytelen), bytelen));
resultcount++;
hitlen2 = 0;
}
}
}
}
var totdur = DateTime.Now - starttime;
UpdateStatus(totdur.ToString(@"hh\:mm\:ss") + " - Search complete. " + resultcount.ToString() + " results found.");
InProgress = false;
RpfSearchComplete();
});
}
private void RpfSearchComplete()
{
try
{
if (InvokeRequired)
{
Invoke(new Action(() => { RpfSearchComplete(); }));
}
else
{
RpfSearchTextBox.Enabled = true;
RpfSearchHexRadioButton.Enabled = true;
RpfSearchTextRadioButton.Enabled = true;
RpfSearchCaseSensitiveCheckBox.Enabled = RpfSearchTextRadioButton.Checked;
RpfSearchBothDirectionsCheckBox.Enabled = true;
RpfSearchIgnoreCheckBox.Enabled = true;
RpfSearchIgnoreTextBox.Enabled = RpfSearchIgnoreCheckBox.Checked;
RpfSearchButton.Enabled = true;
RpfSearchSaveResultsButton.Enabled = true;
}
}
catch { }
}
private void RpfSearchButton_Click(object sender, EventArgs e)
{
RpfSearch();
}
private void RpfSearchAbortButton_Click(object sender, EventArgs e)
{
AbortOperation = true;
}
private void RpfSearchSaveResultsButton_Click(object sender, EventArgs e)
{
SaveFileDialog.FileName = "SearchResults.txt";
if (SaveFileDialog.ShowDialog() == DialogResult.OK)
{
string fpath = SaveFileDialog.FileName;
StringBuilder sb = new StringBuilder();
sb.AppendLine("CodeWalker Search Results for \"" + RpfSearchTextBox.Text + "\"");
sb.AppendLine("[File path], [Byte offset]");
if (RpfSearchResults != null)
{
foreach (var r in RpfSearchResults)
{
sb.AppendLine(r.FileEntry.Path + ", " + r.Offset.ToString());
}
}
File.WriteAllText(fpath, sb.ToString());
}
}
private void RpfSearchIgnoreCheckBox_CheckedChanged(object sender, EventArgs e)
{
RpfSearchIgnoreTextBox.Enabled = RpfSearchIgnoreCheckBox.Checked;
if (RpfSearchIgnoreCheckBox.Checked)
{
RpfSearchOnlyCheckBox.Checked = false;
}
}
private void RpfSearchOnlyCheckBox_CheckedChanged(object sender, EventArgs e)
{
RpfSearchOnlyTextBox.Enabled = RpfSearchOnlyCheckBox.Checked;
if (RpfSearchOnlyCheckBox.Checked)
{
RpfSearchIgnoreCheckBox.Checked = false;
}
}
private void RpfSearchTextRadioButton_CheckedChanged(object sender, EventArgs e)
{
RpfSearchCaseSensitiveCheckBox.Enabled = RpfSearchTextRadioButton.Checked;
}
private void RpfSearchResultsListView_SelectedIndexChanged(object sender, EventArgs e)
{
if (RpfSearchResultsListView.SelectedIndices.Count == 1)
{
var i = RpfSearchResultsListView.SelectedIndices[0];
if ((i >= 0) && (i < RpfSearchResults.Count))
{
var r = RpfSearchResults[i];
SelectFile(r.FileEntry, r.Offset + 1, r.Length);
}
else
{
SelectFile(null, -1, 0);
}
}
else
{
SelectFile(null, -1, 0);
}
}
private void RpfSearchResultsListView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
{
var item = new ListViewItem();
if (e.ItemIndex < RpfSearchResults.Count)
{
RpfSearchResult r = RpfSearchResults[e.ItemIndex];
item.Text = r.FileEntry.Name;
item.SubItems.Add(r.Offset.ToString());
item.Tag = r;
}
e.Item = item;
}
private void SelectFile()
{
SelectFile(RpfSelectedEntry, RpfSelectedOffset, RpfSelectedLength);
}
private void SelectFile(RpfEntry entry, int offset, int length)
{
RpfSelectedEntry = entry;
RpfSelectedOffset = offset;
RpfSelectedLength = length;
RpfFileEntry rfe = entry as RpfFileEntry;
if (rfe == null)
{
RpfDirectoryEntry rde = entry as RpfDirectoryEntry;
if (rde != null)
{
FileInfoLabel.Text = rde.Path + " (Directory)";
DataTextBox.Text = "[Please select a data file]";
}
else
{
FileInfoLabel.Text = "[Nothing selected]";
DataTextBox.Text = "[Please select a search result]";
}
return;
}
Cursor = Cursors.WaitCursor;
string typestr = "Resource";
if (rfe is RpfBinaryFileEntry)
{
typestr = "Binary";
}
byte[] data = rfe.File.ExtractFile(rfe);
int datalen = (data != null) ? data.Length : 0;
FileInfoLabel.Text = rfe.Path + " (" + typestr + " file) - " + TextUtil.GetBytesReadable(datalen);
if (ShowLargeFileContentsCheckBox.Checked || (datalen < 524287)) //512K
{
DisplayFileContentsText(rfe, data, length, offset);
}
else
{
DataTextBox.Text = "[Filesize >512KB. Select the Show large files option to view its contents]";
}
//bool istexdict = false;
//if (rfe.NameLower.EndsWith(".ymap"))
//{
// YmapFile ymap = new YmapFile(rfe);
// ymap.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = ymap;
//}
//else if (rfe.NameLower.EndsWith(".ytyp"))
//{
// YtypFile ytyp = new YtypFile();
// ytyp.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = ytyp;
//}
//else if (rfe.NameLower.EndsWith(".ymf"))
//{
// YmfFile ymf = new YmfFile();
// ymf.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = ymf;
//}
//else if (rfe.NameLower.EndsWith(".ymt"))
//{
// YmtFile ymt = new YmtFile();
// ymt.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = ymt;
//}
//else if (rfe.NameLower.EndsWith(".ybn"))
//{
// YbnFile ybn = new YbnFile();
// ybn.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = ybn;
//}
//else if (rfe.NameLower.EndsWith(".fxc"))
//{
// FxcFile fxc = new FxcFile();
// fxc.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = fxc;
//}
//else if (rfe.NameLower.EndsWith(".yft"))
//{
// YftFile yft = new YftFile();
// yft.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = yft;
// if ((yft.Fragment != null) && (yft.Fragment.Drawable != null) && (yft.Fragment.Drawable.ShaderGroup != null) && (yft.Fragment.Drawable.ShaderGroup.TextureDictionary != null))
// {
// ShowTextures(yft.Fragment.Drawable.ShaderGroup.TextureDictionary);
// istexdict = true;
// }
//}
//else if (rfe.NameLower.EndsWith(".ydr"))
//{
// YdrFile ydr = new YdrFile();
// ydr.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = ydr;
// if ((ydr.Drawable != null) && (ydr.Drawable.ShaderGroup != null) && (ydr.Drawable.ShaderGroup.TextureDictionary != null))
// {
// ShowTextures(ydr.Drawable.ShaderGroup.TextureDictionary);
// istexdict = true;
// }
//}
//else if (rfe.NameLower.EndsWith(".ydd"))
//{
// YddFile ydd = new YddFile();
// ydd.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = ydd;
// //todo: show embedded texdicts in ydd's? is this possible?
//}
//else if (rfe.NameLower.EndsWith(".ytd"))
//{
// YtdFile ytd = new YtdFile();
// ytd.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = ytd;
// ShowTextures(ytd.TextureDict);
// istexdict = true;
//}
//else if (rfe.NameLower.EndsWith(".ycd"))
//{
// YcdFile ycd = new YcdFile();
// ycd.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = ycd;
//}
//else if (rfe.NameLower.EndsWith(".ynd"))
//{
// YndFile ynd = new YndFile();
// ynd.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = ynd;
//}
//else if (rfe.NameLower.EndsWith(".ynv"))
//{
// YnvFile ynv = new YnvFile();
// ynv.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = ynv;
//}
//else if (rfe.NameLower.EndsWith("_cache_y.dat"))
//{
// CacheDatFile cdf = new CacheDatFile();
// cdf.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = cdf;
//}
//else if (rfe.NameLower.EndsWith(".rel"))
//{
// RelFile rel = new RelFile(rfe);
// rel.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = rel;
//}
//else if (rfe.NameLower.EndsWith(".gxt2"))
//{
// Gxt2File gxt2 = new Gxt2File();
// gxt2.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = gxt2;
//}
//else if (rfe.NameLower.EndsWith(".pso"))
//{
// JPsoFile pso = new JPsoFile();
// pso.Load(data, rfe);
// DetailsPropertyGrid.SelectedObject = pso;
//}
//else
//{
// DetailsPropertyGrid.SelectedObject = null;
//}
//if (!istexdict)
//{
// ShowTextures(null);
//}
Cursor = Cursors.Default;
}
private void DisplayFileContentsText(RpfFileEntry rfe, byte[] data, int length, int offset)
{
if (data == null)
{
Cursor = Cursors.Default;
DataTextBox.Text = "[Error extracting file! " + rfe.File.LastError + "]";
return;
}
int selline = -1;
int selstartc = -1;
int selendc = -1;
if (DataHexRadio.Checked)
{
int charsperln = int.Parse(DataHexLineCombo.Text);
int lines = (data.Length / charsperln) + (((data.Length % charsperln) > 0) ? 1 : 0);
StringBuilder hexb = new StringBuilder();
StringBuilder texb = new StringBuilder();
StringBuilder finb = new StringBuilder();
if (offset > 0)
{
selline = offset / charsperln;
}
for (int i = 0; i < lines; i++)
{
int pos = i * charsperln;
int poslim = pos + charsperln;
hexb.Clear();
texb.Clear();
hexb.AppendFormat("{0:X4}: ", pos);
for (int c = pos; c < poslim; c++)
{
if (c < data.Length)
{
byte b = data[c];
hexb.AppendFormat("{0:X2} ", b);
if (char.IsControl((char)b))
{
texb.Append(".");
}
else
{
texb.Append(Encoding.ASCII.GetString(data, c, 1));
}
}
else
{
hexb.Append(" ");
texb.Append(" ");
}
}
if (i == selline) selstartc = finb.Length;
finb.AppendLine(hexb.ToString() + "| " + texb.ToString());
if (i == selline) selendc = finb.Length - 1;
}
DataTextBox.Text = finb.ToString();
}
else
{
string text = Encoding.UTF8.GetString(data);
DataTextBox.Text = text;
if (offset > 0)
{
selstartc = offset;
selendc = offset + length;
}
}
if ((selstartc > 0) && (selendc > 0))
{
DataTextBox.SelectionStart = selstartc;
DataTextBox.SelectionLength = selendc - selstartc;
DataTextBox.ScrollToCaret();
}
}
private void ExportButton_Click(object sender, EventArgs e)
{
if (InProgress) return;
if (!(RpfMan?.IsInited ?? false))
{
MessageBox.Show("Please wait for the scan to complete.");
return;
}
RpfFileEntry rfe = RpfSelectedEntry as RpfFileEntry;
if (rfe == null)
{
MessageBox.Show("Please select a file to export.");
return;
}
SaveFileDialog.FileName = rfe.Name;
if (SaveFileDialog.ShowDialog() == DialogResult.OK)
{
string fpath = SaveFileDialog.FileName;
byte[] data = rfe.File.ExtractFile(rfe);
if (ExportCompressCheckBox.Checked)
{
data = ResourceBuilder.Compress(data);
}
RpfResourceFileEntry rrfe = rfe as RpfResourceFileEntry;
if (rrfe != null) //add resource header if this is a resource file.
{
data = ResourceBuilder.AddResourceHeader(rrfe, data);
}
if (data == null)
{
MessageBox.Show("Error extracting file! " + rfe.File.LastError);
return;
}
try
{
File.WriteAllBytes(fpath, data);
}
catch (Exception ex)
{
MessageBox.Show("Error saving file! " + ex.ToString());
}
}
}
private void DataHexRadio_CheckedChanged(object sender, EventArgs e)
{
SelectFile();
}
private void DataHexLineCombo_SelectedIndexChanged(object sender, EventArgs e)
{
SelectFile();
}
private void ShowLargeFileContentsCheckBox_CheckedChanged(object sender, EventArgs e)
{
SelectFile();
}
}
}

View File

@ -120,6 +120,12 @@
<metadata name="FolderBrowserDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="MainStatusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>182, 17</value>
</metadata>
<metadata name="SaveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>317, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>

View File

@ -331,11 +331,11 @@
<Compile Include="KeyBindForm.Designer.cs">
<DependentUpon>KeyBindForm.cs</DependentUpon>
</Compile>
<Compile Include="MainForm.cs">
<Compile Include="MenuForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
<Compile Include="MenuForm.Designer.cs">
<DependentUpon>MenuForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Project\MenyooXml.cs" />
@ -517,8 +517,8 @@
<EmbeddedResource Include="KeyBindForm.resx">
<DependentUpon>KeyBindForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
<EmbeddedResource Include="MenuForm.resx">
<DependentUpon>MenuForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>

View File

@ -2206,7 +2206,7 @@ namespace CodeWalker.GameFiles
Vehicle = 3,
VehicleEngine = 4,
VehicleEntity = 5, //not sure about this
RadioStation = 6,//possibly, audio "stream"
RadioStream = 6,//possibly, generic audio stream
Helicopter = 8, //maybe

View File

@ -31,7 +31,7 @@ namespace CodeWalker.GameFiles
public volatile bool IsInited = false;
public void Init(string folder, Action<string> updateStatus, Action<string> errorLog, bool rootOnly = false)
public void Init(string folder, Action<string> updateStatus, Action<string> errorLog, bool rootOnly = false, bool buildIndex = true)
{
UpdateStatus = updateStatus;
ErrorLog = errorLog;
@ -81,8 +81,12 @@ namespace CodeWalker.GameFiles
}
}
updateStatus("Building jenkindex...");
BuildBaseJenkIndex();
if (buildIndex)
{
updateStatus("Building jenkindex...");
BuildBaseJenkIndex();
}
updateStatus("Scan complete");
IsInited = true;

View File

@ -1,6 +1,6 @@
namespace CodeWalker
{
partial class MainForm
partial class MenuForm
{
/// <summary>
/// Required designer variable.
@ -28,7 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MenuForm));
this.FolderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
this.OpenFileDialog = new System.Windows.Forms.OpenFileDialog();
this.ExtractScriptsButton = new System.Windows.Forms.Button();
@ -44,6 +44,7 @@
this.ExtractKeysButton = new System.Windows.Forms.Button();
this.ProjectButton = new System.Windows.Forms.Button();
this.JenkIndButton = new System.Windows.Forms.Button();
this.RPFExplorerButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// ExtractScriptsButton
@ -68,10 +69,10 @@
//
// RPFBrowserButton
//
this.RPFBrowserButton.Location = new System.Drawing.Point(188, 12);
this.RPFBrowserButton.Location = new System.Drawing.Point(188, 41);
this.RPFBrowserButton.Name = "RPFBrowserButton";
this.RPFBrowserButton.Size = new System.Drawing.Size(108, 23);
this.RPFBrowserButton.TabIndex = 0;
this.RPFBrowserButton.TabIndex = 13;
this.RPFBrowserButton.Text = "RPF Browser...";
this.RPFBrowserButton.UseVisualStyleBackColor = true;
this.RPFBrowserButton.Click += new System.EventHandler(this.RPFBrowserButton_Click);
@ -98,7 +99,7 @@
//
// GCCollectButton
//
this.GCCollectButton.Location = new System.Drawing.Point(188, 157);
this.GCCollectButton.Location = new System.Drawing.Point(188, 186);
this.GCCollectButton.Name = "GCCollectButton";
this.GCCollectButton.Size = new System.Drawing.Size(108, 23);
this.GCCollectButton.TabIndex = 10;
@ -138,7 +139,7 @@
//
// JenkGenButton
//
this.JenkGenButton.Location = new System.Drawing.Point(188, 70);
this.JenkGenButton.Location = new System.Drawing.Point(188, 99);
this.JenkGenButton.Name = "JenkGenButton";
this.JenkGenButton.Size = new System.Drawing.Size(108, 23);
this.JenkGenButton.TabIndex = 12;
@ -168,7 +169,7 @@
//
// JenkIndButton
//
this.JenkIndButton.Location = new System.Drawing.Point(188, 99);
this.JenkIndButton.Location = new System.Drawing.Point(188, 128);
this.JenkIndButton.Name = "JenkIndButton";
this.JenkIndButton.Size = new System.Drawing.Size(108, 23);
this.JenkIndButton.TabIndex = 11;
@ -176,11 +177,22 @@
this.JenkIndButton.UseVisualStyleBackColor = true;
this.JenkIndButton.Click += new System.EventHandler(this.JenkIndButton_Click);
//
// RPFExplorerButton
//
this.RPFExplorerButton.Location = new System.Drawing.Point(188, 12);
this.RPFExplorerButton.Name = "RPFExplorerButton";
this.RPFExplorerButton.Size = new System.Drawing.Size(108, 23);
this.RPFExplorerButton.TabIndex = 0;
this.RPFExplorerButton.Text = "RPF Explorer...";
this.RPFExplorerButton.UseVisualStyleBackColor = true;
this.RPFExplorerButton.Click += new System.EventHandler(this.RPFExplorerButton_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(308, 250);
this.Controls.Add(this.RPFExplorerButton);
this.Controls.Add(this.JenkIndButton);
this.Controls.Add(this.ProjectButton);
this.Controls.Add(this.ExtractKeysButton);
@ -219,6 +231,7 @@
private System.Windows.Forms.Button ExtractKeysButton;
private System.Windows.Forms.Button ProjectButton;
private System.Windows.Forms.Button JenkIndButton;
private System.Windows.Forms.Button RPFExplorerButton;
}
}

View File

@ -13,12 +13,12 @@ using System.Windows.Forms;
namespace CodeWalker
{
public partial class MainForm : Form
public partial class MenuForm : Form
{
private volatile bool worldFormOpen = false;
private WorldForm worldForm = null;
public MainForm()
public MenuForm()
{
InitializeComponent();
}
@ -32,6 +32,12 @@ namespace CodeWalker
Settings.Default.Save();
}
private void RPFExplorerButton_Click(object sender, EventArgs e)
{
ExploreForm f = new ExploreForm();
f.Show(this);
}
private void RPFBrowserButton_Click(object sender, EventArgs e)
{
BrowseForm f = new BrowseForm();

View File

@ -42,7 +42,7 @@ namespace CodeWalker
#endif
if (menumode)
{
Application.Run(new MainForm());
Application.Run(new MenuForm());
}
else if (explorermode)
{

View File

@ -651,4 +651,83 @@ namespace CodeWalker.Project
}
}
public class AudioPositionUndoStep : UndoStep
{
public AudioPlacement Audio { get; set; }
public Vector3 StartPosition { get; set; }
public Vector3 EndPosition { get; set; }
public AudioPositionUndoStep(AudioPlacement audio, Vector3 startpos)
{
Audio = audio;
StartPosition = startpos;
EndPosition = audio?.Position ?? Vector3.Zero;
}
private void Update(WorldForm wf, ref MapSelection sel, Vector3 p)
{
Audio?.SetPosition(p);
if (Audio != sel.Audio) wf.SelectAudio(Audio);
wf.SetWidgetPosition(p);
}
public override void Undo(WorldForm wf, ref MapSelection sel)
{
Update(wf, ref sel, StartPosition);
}
public override void Redo(WorldForm wf, ref MapSelection sel)
{
Update(wf, ref sel, EndPosition);
}
public override string ToString()
{
return "Audio " + (Audio?.GetNameString() ?? "") + ": Position";
}
}
public class AudioRotationUndoStep : UndoStep
{
public AudioPlacement Audio { get; set; }
public Quaternion StartRotation { get; set; }
public Quaternion EndRotation { get; set; }
public AudioRotationUndoStep(AudioPlacement audio, Quaternion startrot)
{
Audio = audio;
StartRotation = startrot;
EndRotation = audio?.Orientation ?? Quaternion.Identity;
}
private void Update(WorldForm wf, ref MapSelection sel, Quaternion q)
{
Audio?.SetOrientation(q);
if (Audio != sel.Audio) wf.SelectAudio(Audio);
wf.SetWidgetRotation(q);
}
public override void Undo(WorldForm wf, ref MapSelection sel)
{
Update(wf, ref sel, StartRotation);
}
public override void Redo(WorldForm wf, ref MapSelection sel)
{
Update(wf, ref sel, EndRotation);
}
public override string ToString()
{
return "Audio " + (Audio?.GetNameString() ?? "") + ": Rotation";
}
}
}

View File

@ -145,15 +145,14 @@ namespace CodeWalker.World
public Vector3 OuterMax { get; set; }
public float OuterRad { get; set; }
public Quaternion OuterOri { get; set; }
public Vector3 HitboxPos { get; set; }
public Vector3 Position { get; set; }
public Vector3 HitboxMin { get; set; }
public Vector3 HitboxMax { get; set; }
public Quaternion HitboxOri { get; set; }
public Quaternion HitboxOriInv { get; set; }
public Quaternion Orientation { get; set; }
public Quaternion OrientationInv { get; set; }
public float HitSphereRad { get; set; }
public AudioPlacement(RelFile rel, Dat151AmbientZone zone)
{
RelFile = rel;
@ -196,15 +195,15 @@ namespace CodeWalker.World
bool useouter = ((InnerMax.X == 0) || (InnerMax.Y == 0) || (InnerMax.Z == 0));
if (useouter && (zone.Shape != Dat151ZoneShape.Sphere))
{ } //not sure what these are yet!
HitboxPos = useouter ? OuterPos : InnerPos;
Position = useouter ? OuterPos : InnerPos;
HitboxMax = useouter ? OuterMax : InnerMax;
HitboxMin = useouter ? OuterMin : InnerMin;
HitboxOri = useouter ? OuterOri : InnerOri;
HitboxOriInv = Quaternion.Invert(HitboxOri);
Orientation = useouter ? OuterOri : InnerOri;
OrientationInv = Quaternion.Invert(Orientation);
HitSphereRad = InnerRad;
if (zone.Shape == Dat151ZoneShape.Sphere)
{
HitboxPos = InnerPos;
Position = InnerPos;
}
}
public AudioPlacement(RelFile rel, Dat151AmbientEmitter emitter)
@ -217,8 +216,8 @@ namespace CodeWalker.World
Name = emitter.Name;
NameHash = emitter.NameHash;
HitboxOri = Quaternion.Identity;
HitboxOriInv = Quaternion.Identity;
Orientation = Quaternion.Identity;
OrientationInv = Quaternion.Identity;
InnerPos = emitter.Position;
OuterPos = InnerPos;
InnerRad = emitter.InnerRad;
@ -229,7 +228,7 @@ namespace CodeWalker.World
{
InnerRad = 1;
}
HitboxPos = InnerPos;
Position = InnerPos;
HitSphereRad = InnerRad;// useouter ? OuterRad : InnerRad;
}
@ -240,17 +239,17 @@ namespace CodeWalker.World
Vector3 delta = pos - InnerPos;
InnerPos = pos;
OuterPos += delta;
HitboxPos = useouter ? OuterPos : InnerPos;
Position = useouter ? OuterPos : InnerPos;
}
public void SetOrientation(Quaternion ori)
{
HitboxOri = ori;
HitboxOriInv = Quaternion.Invert(ori);
Orientation = ori;
OrientationInv = Quaternion.Invert(ori);
if (InnerOri == OuterOri)
{
InnerOri = HitboxOri;
OuterOri = HitboxOri;
InnerOri = Orientation;
OuterOri = Orientation;
}
else
{
@ -259,15 +258,21 @@ namespace CodeWalker.World
bool useouter = ((InnerMax.X == 0) || (InnerMax.Y == 0) || (InnerMax.Z == 0));
if (useouter)
{
OuterOri = HitboxOri;
OuterOri = Orientation;
}
else
{
InnerOri = HitboxOri;
InnerOri = Orientation;
}
}
}
public string GetNameString()
{
if (!string.IsNullOrEmpty(Name)) return Name;
return NameHash.ToString();
}
}

22
WorldForm.Designer.cs generated
View File

@ -145,6 +145,7 @@ namespace CodeWalker
this.WaitForChildrenCheckBox = new System.Windows.Forms.CheckBox();
this.label14 = new System.Windows.Forms.Label();
this.tabPage9 = new System.Windows.Forms.TabPage();
this.AudioOuterBoundsCheckBox = new System.Windows.Forms.CheckBox();
this.PopZonesCheckBox = new System.Windows.Forms.CheckBox();
this.NavMeshesCheckBox = new System.Windows.Forms.CheckBox();
this.TrainPathsCheckBox = new System.Windows.Forms.CheckBox();
@ -1745,6 +1746,7 @@ namespace CodeWalker
//
// tabPage9
//
this.tabPage9.Controls.Add(this.AudioOuterBoundsCheckBox);
this.tabPage9.Controls.Add(this.PopZonesCheckBox);
this.tabPage9.Controls.Add(this.NavMeshesCheckBox);
this.tabPage9.Controls.Add(this.TrainPathsCheckBox);
@ -1772,6 +1774,19 @@ namespace CodeWalker
this.tabPage9.Text = "Helpers";
this.tabPage9.UseVisualStyleBackColor = true;
//
// AudioOuterBoundsCheckBox
//
this.AudioOuterBoundsCheckBox.AutoSize = true;
this.AudioOuterBoundsCheckBox.Checked = true;
this.AudioOuterBoundsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.AudioOuterBoundsCheckBox.Location = new System.Drawing.Point(10, 434);
this.AudioOuterBoundsCheckBox.Name = "AudioOuterBoundsCheckBox";
this.AudioOuterBoundsCheckBox.Size = new System.Drawing.Size(147, 17);
this.AudioOuterBoundsCheckBox.TabIndex = 54;
this.AudioOuterBoundsCheckBox.Text = "Show audio outer bounds";
this.AudioOuterBoundsCheckBox.UseVisualStyleBackColor = true;
this.AudioOuterBoundsCheckBox.CheckedChanged += new System.EventHandler(this.AudioOuterBoundsCheckBox_CheckedChanged);
//
// PopZonesCheckBox
//
this.PopZonesCheckBox.AutoSize = true;
@ -2474,13 +2489,14 @@ namespace CodeWalker
this.ToolsMenuExtractShaders,
this.ToolsMenuOptions});
this.ToolsMenu.Name = "ToolsMenu";
this.ToolsMenu.Size = new System.Drawing.Size(166, 290);
this.ToolsMenu.Size = new System.Drawing.Size(166, 312);
//
// ToolsMenuRPFBrowser
//
this.ToolsMenuRPFBrowser.Name = "ToolsMenuRPFBrowser";
this.ToolsMenuRPFBrowser.Size = new System.Drawing.Size(165, 22);
this.ToolsMenuRPFBrowser.Text = "RPF Browser...";
this.ToolsMenuRPFBrowser.Visible = false;
this.ToolsMenuRPFBrowser.Click += new System.EventHandler(this.ToolsMenuRPFBrowser_Click);
//
// ToolsMenuRPFExplorer
@ -2514,6 +2530,7 @@ namespace CodeWalker
//
// ToolsMenuBinarySearch
//
this.ToolsMenuBinarySearch.Enabled = false;
this.ToolsMenuBinarySearch.Name = "ToolsMenuBinarySearch";
this.ToolsMenuBinarySearch.Size = new System.Drawing.Size(165, 22);
this.ToolsMenuBinarySearch.Text = "Binary search...";
@ -2601,7 +2618,7 @@ namespace CodeWalker
this.ToolbarCameraModeButton});
this.Toolbar.Location = new System.Drawing.Point(1, 0);
this.Toolbar.Name = "Toolbar";
this.Toolbar.Size = new System.Drawing.Size(553, 25);
this.Toolbar.Size = new System.Drawing.Size(522, 25);
this.Toolbar.TabIndex = 6;
this.Toolbar.Text = "toolStrip1";
//
@ -3457,5 +3474,6 @@ namespace CodeWalker
private System.Windows.Forms.ToolStripMenuItem ToolbarOpenScenarioButton;
private System.Windows.Forms.CheckBox PopZonesCheckBox;
private System.Windows.Forms.ToolStripMenuItem ToolbarSelectAudioButton;
private System.Windows.Forms.CheckBox AudioOuterBoundsCheckBox;
}
}

View File

@ -191,6 +191,7 @@ namespace CodeWalker
bool renderpopzones = false;
bool renderaudiozones = false;
bool renderaudioouterbounds = true;
float timeofday = 12.0f;
@ -2135,17 +2136,20 @@ namespace CodeWalker
mb.Scale = Vector3.One;
HilightBoxes.Add(mb);
mb.CamRelPos = placement.OuterPos - camera.Position;
mb.BBMin = placement.OuterMin;
mb.BBMax = placement.OuterMax;
mb.Orientation = placement.OuterOri;
mb.Scale = Vector3.One;
BoundingBoxes.Add(mb);
if (renderaudioouterbounds)
{
mb.CamRelPos = placement.OuterPos - camera.Position;
mb.BBMin = placement.OuterMin;
mb.BBMax = placement.OuterMax;
mb.Orientation = placement.OuterOri;
mb.Scale = Vector3.One;
BoundingBoxes.Add(mb);
}
Vector3 hbcamrel = (placement.HitboxPos - camera.Position);
Vector3 hbcamrel = (placement.Position - camera.Position);
Ray mraytrn = new Ray();
mraytrn.Position = placement.HitboxOriInv.Multiply(camera.MouseRay.Position - hbcamrel);
mraytrn.Direction = placement.HitboxOriInv.Multiply(mray.Direction);
mraytrn.Position = placement.OrientationInv.Multiply(camera.MouseRay.Position - hbcamrel);
mraytrn.Direction = placement.OrientationInv.Multiply(mray.Direction);
bbox.Minimum = placement.HitboxMin;
bbox.Maximum = placement.HitboxMax;
if (mraytrn.Intersects(ref bbox, out hitdist) && (hitdist < CurMouseHit.HitDist) && (hitdist > 0))
@ -2165,17 +2169,20 @@ namespace CodeWalker
ms.Radius = placement.InnerRad;
HilightSpheres.Add(ms);
ms.CamRelPos = placement.OuterPos - camera.Position;
ms.Radius = placement.OuterRad;
BoundingSpheres.Add(ms);
if (renderaudioouterbounds)
{
ms.CamRelPos = placement.OuterPos - camera.Position;
ms.Radius = placement.OuterRad;
BoundingSpheres.Add(ms);
}
bsph.Center = placement.HitboxPos;
bsph.Center = placement.Position;
bsph.Radius = placement.HitSphereRad;
if (mray.Intersects(ref bsph, out hitdist) && (hitdist < CurMouseHit.HitDist) && (hitdist > 0))
{
CurMouseHit.Audio = placement;
CurMouseHit.HitDist = hitdist;
CurMouseHit.CamRel = placement.HitboxPos - camera.Position;
CurMouseHit.CamRel = placement.Position - camera.Position;
CurMouseHit.AABB = new BoundingBox(); //no box here
CurMouseHit.BSphere = bsph;
lastHitOuterSphere = ms; //highlight the outer sphere
@ -3207,7 +3214,7 @@ namespace CodeWalker
}
if (CurMouseHit.Audio != null)
{
ori = CurMouseHit.Audio.HitboxOri;
ori = CurMouseHit.Audio.Orientation;
if (CurMouseHit.Audio.Shape == Dat151ZoneShape.Sphere)
{
mode = BoundsShaderMode.Sphere;
@ -3412,8 +3419,8 @@ namespace CodeWalker
if (selectionItem.Audio != null)
{
var au = selectionItem.Audio;
camrel = au.HitboxPos - camera.Position;
ori = au.HitboxOri;
camrel = au.Position - camera.Position;
ori = au.Orientation;
bbmin = au.HitboxMin;
bbmax = au.HitboxMax;
@ -5609,6 +5616,21 @@ namespace CodeWalker
SelectItem(ms);
}
}
public void SelectAudio(AudioPlacement audio)
{
if (audio == null)
{
SelectItem(null);
}
else
{
MapSelection ms = new MapSelection();
ms.Audio = audio;
ms.AABB = new BoundingBox(audio.HitboxMin, audio.HitboxMax);
ms.BSphere = new BoundingSphere(audio.Position, audio.HitSphereRad);
SelectItem(ms);
}
}
private void SelectMousedItem()
{
//when clicked, select the currently moused item and update the selection info UI
@ -6637,6 +6659,7 @@ namespace CodeWalker
//if (SelectedItem.NavPoly != null) hasval = true;
if (SelectedItem.TrainTrackNode != null) canundo = true;
if (SelectedItem.ScenarioNode != null) canundo = true;
if (SelectedItem.Audio != null) canundo = true;
if (!canundo) return;
if (Widget is TransformWidget)
{
@ -6655,12 +6678,14 @@ namespace CodeWalker
//if (SelectedItem.NavPoly != null) hasval = true;
if (SelectedItem.TrainTrackNode != null) canundo = true;
if (SelectedItem.ScenarioNode != null) canundo = true;
if (SelectedItem.Audio != null) canundo = true;
if (!canundo) return;
var ent = SelectedItem.EntityDef;
var cargen = SelectedItem.CarGenerator;
var pathnode = SelectedItem.PathNode;
var trainnode = SelectedItem.TrainTrackNode;
var scenarionode = SelectedItem.ScenarioNode;
var audio = SelectedItem.Audio;
TransformWidget tw = Widget as TransformWidget;
UndoStep s = null;
if (tw != null)
@ -6723,6 +6748,14 @@ namespace CodeWalker
case WidgetMode.Rotation: s = new ScenarioNodeRotationUndoStep(scenarionode, UndoStartRotation, this); break;
}
}
else if (audio != null)
{
switch (tw.Mode)
{
case WidgetMode.Position: s = new AudioPositionUndoStep(audio, UndoStartPosition); break;
case WidgetMode.Rotation: s = new AudioRotationUndoStep(audio, UndoStartRotation); break;
}
}
}
if (s != null)
{
@ -6803,6 +6836,7 @@ namespace CodeWalker
ToolbarOpenButton.Enabled = true;
ToolbarProjectWindowButton.Enabled = true;
ToolsMenuProjectWindow.Enabled = true;
ToolsMenuBinarySearch.Enabled = true;
ToolsMenuJenkInd.Enabled = true;
}
}
@ -8431,6 +8465,11 @@ namespace CodeWalker
renderpopzones = PopZonesCheckBox.Checked;
}
private void AudioOuterBoundsCheckBox_CheckedChanged(object sender, EventArgs e)
{
renderaudioouterbounds = AudioOuterBoundsCheckBox.Checked;
}
private void ToolsPanelExpandButton_Click(object sender, EventArgs e)
{
toolspanelexpanded = !toolspanelexpanded;
@ -8549,7 +8588,7 @@ namespace CodeWalker
private void ToolsMenuBinarySearch_Click(object sender, EventArgs e)
{
BinarySearchForm f = new BinarySearchForm();
BinarySearchForm f = new BinarySearchForm(gameFileCache);
f.Show(this);
}
@ -9724,7 +9763,7 @@ namespace CodeWalker
}
if (Audio != null)
{
name = Audio.ShortTypeName + " " + FloatUtil.GetVector3String(Audio.InnerPos);
name = Audio.ShortTypeName + " " + Audio.GetNameString();// FloatUtil.GetVector3String(Audio.InnerPos);
}
return name;
}
@ -9790,7 +9829,7 @@ namespace CodeWalker
}
if (Audio != null)
{
name = Audio.ShortTypeName + " " + FloatUtil.GetVector3String(Audio.InnerPos);
name = Audio.ShortTypeName + " " + Audio.GetNameString();// + FloatUtil.GetVector3String(Audio.InnerPos);
}
return name;
}
@ -9911,7 +9950,7 @@ namespace CodeWalker
}
else if (Audio != null)
{
return Audio.HitboxOri;
return Audio.Orientation;
}
return Quaternion.Identity;
}