Dat151 progress

This commit is contained in:
dexy
2018-12-27 00:20:39 +11:00
Unverified
parent 05d302a4e1
commit 77d9c4e4c8
16 changed files with 2177 additions and 247 deletions
+112 -14
View File
@@ -31,13 +31,21 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RelForm));
this.RelPropertyGrid = new CodeWalker.WinForms.PropertyGridFix();
this.MainTabControl = new System.Windows.Forms.TabControl();
this.DetailsTabPage = new System.Windows.Forms.TabPage();
this.NameTableTabPage = new System.Windows.Forms.TabPage();
this.MainTextBox = new CodeWalker.WinForms.TextBoxFix();
this.DetailsTabPage = new System.Windows.Forms.TabPage();
this.CloseButton = new System.Windows.Forms.Button();
this.SearchTabPage = new System.Windows.Forms.TabPage();
this.SearchResultsGrid = new CodeWalker.WinForms.PropertyGridFix();
this.label12 = new System.Windows.Forms.Label();
this.SearchTextBox = new System.Windows.Forms.TextBox();
this.SearchButton = new System.Windows.Forms.Button();
this.SearchHashRadio = new System.Windows.Forms.RadioButton();
this.SearchTextRadio = new System.Windows.Forms.RadioButton();
this.MainTabControl.SuspendLayout();
this.NameTableTabPage.SuspendLayout();
this.DetailsTabPage.SuspendLayout();
this.NameTableTabPage.SuspendLayout();
this.SearchTabPage.SuspendLayout();
this.SuspendLayout();
//
// RelPropertyGrid
@@ -58,6 +66,7 @@
| System.Windows.Forms.AnchorStyles.Right)));
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.Margin = new System.Windows.Forms.Padding(0);
this.MainTabControl.Name = "MainTabControl";
@@ -65,6 +74,17 @@
this.MainTabControl.Size = new System.Drawing.Size(664, 394);
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);
@@ -91,17 +111,6 @@
this.MainTextBox.TabIndex = 1;
this.MainTextBox.WordWrap = false;
//
// 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;
//
// CloseButton
//
this.CloseButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@@ -113,6 +122,86 @@
this.CloseButton.UseVisualStyleBackColor = true;
this.CloseButton.Click += new System.EventHandler(this.CloseButton_Click);
//
// 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;
//
// 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;
//
// 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);
//
// 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;
//
// 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;
//
// RelForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -124,9 +213,11 @@
this.Name = "RelForm";
this.Text = "REL Viewer - CodeWalker by dexyfex";
this.MainTabControl.ResumeLayout(false);
this.DetailsTabPage.ResumeLayout(false);
this.NameTableTabPage.ResumeLayout(false);
this.NameTableTabPage.PerformLayout();
this.DetailsTabPage.ResumeLayout(false);
this.SearchTabPage.ResumeLayout(false);
this.SearchTabPage.PerformLayout();
this.ResumeLayout(false);
}
@@ -139,5 +230,12 @@
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;
private System.Windows.Forms.RadioButton SearchHashRadio;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.TextBox SearchTextBox;
private System.Windows.Forms.Button SearchButton;
}
}
+80
View File
@@ -27,6 +27,8 @@ namespace CodeWalker.Forms
}
public string FilePath { get; set; }
private RelFile CurrentFile { get; set; }
public RelForm()
@@ -55,6 +57,8 @@ namespace CodeWalker.Forms
RelPropertyGrid.SelectedObject = rel;
CurrentFile = rel;
StringBuilder sb = new StringBuilder();
if (rel != null)
@@ -100,9 +104,85 @@ namespace CodeWalker.Forms
}
private void Search()
{
SearchResultsGrid.SelectedObject = null;
if (CurrentFile?.RelDatasSorted == null) return;
bool textsearch = SearchTextRadio.Checked;
var text = SearchTextBox.Text;
var textl = text.ToLowerInvariant();
uint hash = 0;
uint hashl = 0;
if (!uint.TryParse(text, out hash))//don't re-hash hashes
{
hash = JenkHash.GenHash(text);
JenkIndex.Ensure(text);
hashl = JenkHash.GenHash(textl);
JenkIndex.Ensure(textl);
}
else
{
hashl = hash;
}
var results = new List<RelData>();
foreach (var rd in CurrentFile.RelDatasSorted)
{
if (textsearch)
{
if (((rd.Name?.ToLowerInvariant().Contains(textl))??false) || (rd.NameHash == hash) || (rd.NameHash == hashl) ||
(rd.NameHash.ToString().ToLowerInvariant().Contains(textl)))
{
results.Add(rd);
}
}
else
{
if ((rd.NameHash == hash)||(rd.NameHash == hashl))
{
SearchResultsGrid.SelectedObject = rd;
return;
}
}
}
if (textsearch && (results.Count > 0))
{
SearchResultsGrid.SelectedObject = results.ToArray();
}
else
{
SearchResultsGrid.SelectedObject = null;
}
}
private void CloseButton_Click(object sender, EventArgs e)
{
Close();
}
private void SearchButton_Click(object sender, EventArgs e)
{
Search();
}
private void SearchTextBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
Search();
}
}
}
}