From d7ce52581cdc36f3a613bf9ca0201dc8c50ffc83 Mon Sep 17 00:00:00 2001 From: MaxHwoy Date: Thu, 20 Aug 2020 23:22:40 -0700 Subject: [PATCH 01/10] Version upgrade 2.1.2 --- Binary/Binary.csproj | 2 +- Binary/Editor.cs | 4 +- Binary/IntroUI.cs | 10 +++-- Binary/Prompt/Input.cs | 11 ++++-- Binary/UI/TextureEditor.cs | 3 +- Binary/UI/VectorDisplay.Designer.cs | 57 +++++++++++++++++++++++++++ Binary/UI/VectorDisplay.cs | 18 +++++++++ Binary/UI/VectorDisplay.resx | 60 +++++++++++++++++++++++++++++ Binary/UI/VectorEditor.cs | 4 +- 9 files changed, 156 insertions(+), 13 deletions(-) create mode 100644 Binary/UI/VectorDisplay.Designer.cs create mode 100644 Binary/UI/VectorDisplay.cs create mode 100644 Binary/UI/VectorDisplay.resx diff --git a/Binary/Binary.csproj b/Binary/Binary.csproj index 6baddec..a5d2a7a 100644 --- a/Binary/Binary.csproj +++ b/Binary/Binary.csproj @@ -5,7 +5,7 @@ netcoreapp3.1 true binary.ico - 2.1.0 + 2.1.2 MaxHwoy Tool for editing Need for Speed binary files (.BIN, .BUN, .LZC). Copyright © 2020 MaxHwoy diff --git a/Binary/Editor.cs b/Binary/Editor.cs index 924a5be..dae1162 100644 --- a/Binary/Editor.cs +++ b/Binary/Editor.cs @@ -856,12 +856,12 @@ private void EMSWindowsNew_Click(object sender, EventArgs e) private void EMSHelpAbout_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.1.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.1.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void EMSHelpTutorials_Click(object sender, EventArgs e) { - MessageBox.Show("Coming soon TM", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + MessageBox.Show("Join Discord server at the start page to get help and full tool documentation!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } #endregion diff --git a/Binary/IntroUI.cs b/Binary/IntroUI.cs index 63bce11..a4b9104 100644 --- a/Binary/IntroUI.cs +++ b/Binary/IntroUI.cs @@ -87,19 +87,21 @@ private void IntroPictureUser_Click(object sender, EventArgs e) private void IntroPictureModder_Click(object sender, EventArgs e) { - // If password check was not done yet + // If password check was not done yet (deprecated) + /* if (!Configurations.Default.PassPassed) { using var form = new ModderPass(); if (form.ShowDialog() != DialogResult.OK) { - + return; - + } } + */ this.ModderInteract(); ForcedX.GCCollect(); @@ -368,7 +370,7 @@ private void PictureBoxSoon_Click(object sender, EventArgs e) private void LabelBinary_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.1.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.1.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } diff --git a/Binary/Prompt/Input.cs b/Binary/Prompt/Input.cs index 15da0b1..e9d6e1c 100644 --- a/Binary/Prompt/Input.cs +++ b/Binary/Prompt/Input.cs @@ -13,19 +13,22 @@ public partial class Input : Form private readonly string _error_message; public string Value { get; private set; } = String.Empty; - public Input() : this(input, null, invalid) { } + public Input() : this(input, null, invalid, null) { } - public Input(string text) : this(text, null, invalid) { } + public Input(string text) : this(text, null, invalid, null) { } - public Input(string text, Predicate inputcheck) : this(text, inputcheck, invalid) { } + public Input(string text, Predicate inputcheck) : this(text, inputcheck, invalid, null) { } - public Input(string text, Predicate inputcheck, string error) + public Input(string text, Predicate inputcheck, string error) : this(text, inputcheck, invalid, error) { } + + public Input(string text, Predicate inputcheck, string error, string initial) { this.InitializeComponent(); this.ToggleTheme(); this.InputLabel.Text = text; this._input_check = inputcheck; this._error_message = error; + this.InputTextBox.Text = initial ?? String.Empty; } private void ToggleTheme() diff --git a/Binary/UI/TextureEditor.cs b/Binary/UI/TextureEditor.cs index 27932d5..b016654 100644 --- a/Binary/UI/TextureEditor.cs +++ b/Binary/UI/TextureEditor.cs @@ -205,7 +205,8 @@ private void TexEditorAddTextureItem_Click(object sender, EventArgs e) if (this.AddTextureDialog.ShowDialog() == DialogResult.OK) { - using var input = new Input("Enter name of the new texture"); + var initial = Path.GetFileNameWithoutExtension(this.AddTextureDialog.FileName); + using var input = new Input("Enter name of the new texture", null, null, initial); while (true) // use loop instead of recursion to prevent stack overflow { diff --git a/Binary/UI/VectorDisplay.Designer.cs b/Binary/UI/VectorDisplay.Designer.cs new file mode 100644 index 0000000..060bfea --- /dev/null +++ b/Binary/UI/VectorDisplay.Designer.cs @@ -0,0 +1,57 @@ +namespace Binary.UI +{ + partial class VectorDisplay + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.VinylBrowser = new System.Windows.Forms.WebBrowser(); + this.SuspendLayout(); + // + // VinylBrowser + // + this.VinylBrowser.Location = new System.Drawing.Point(233, 149); + this.VinylBrowser.Name = "VinylBrowser"; + this.VinylBrowser.Size = new System.Drawing.Size(344, 186); + this.VinylBrowser.TabIndex = 0; + // + // VectorDisplay + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.VinylBrowser); + this.Name = "VectorDisplay"; + this.Text = "VectorDisplay"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.WebBrowser VinylBrowser; + } +} \ No newline at end of file diff --git a/Binary/UI/VectorDisplay.cs b/Binary/UI/VectorDisplay.cs new file mode 100644 index 0000000..ef471c6 --- /dev/null +++ b/Binary/UI/VectorDisplay.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace Binary.UI +{ + public partial class VectorDisplay : Form + { + public VectorDisplay() + { + InitializeComponent(); + } + } +} diff --git a/Binary/UI/VectorDisplay.resx b/Binary/UI/VectorDisplay.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Binary/UI/VectorDisplay.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Binary/UI/VectorEditor.cs b/Binary/UI/VectorEditor.cs index 743a1c0..249144e 100644 --- a/Binary/UI/VectorEditor.cs +++ b/Binary/UI/VectorEditor.cs @@ -270,7 +270,9 @@ private void ExportSVGToolStripMenuItem_Click(object sender, EventArgs e) private void PreviewToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("Not implemented yet", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); + var svg = this.Vector.GetSVGString(1024); + File.WriteAllText("vectordev.html", svg); + Utils.OpenBrowser("vectordev.html"); } private void AddPathSetToolStripMenuItem_Click(object sender, EventArgs e) From f96f9306ded00501b724cdde05b95203c026ea69 Mon Sep 17 00:00:00 2001 From: MaxHwoy Date: Sun, 30 Aug 2020 14:03:08 -0700 Subject: [PATCH 02/10] Last fixes and improvements to editors --- Binary/Binary.csproj | 2 +- Binary/Editor.cs | 8 +-- Binary/IntroUI.cs | 6 +- Binary/UI/CarPartsEditor.cs | 2 + Binary/UI/StringEditor.cs | 135 ++++++++++++++++++++++++++++++------ Binary/UI/VectorEditor.cs | 10 ++- Binary/Utils.cs | 2 +- 7 files changed, 132 insertions(+), 33 deletions(-) diff --git a/Binary/Binary.csproj b/Binary/Binary.csproj index a5d2a7a..688a46d 100644 --- a/Binary/Binary.csproj +++ b/Binary/Binary.csproj @@ -5,7 +5,7 @@ netcoreapp3.1 true binary.ico - 2.1.2 + 2.2.0 MaxHwoy Tool for editing Need for Speed binary files (.BIN, .BUN, .LZC). Copyright © 2020 MaxHwoy diff --git a/Binary/Editor.cs b/Binary/Editor.cs index dae1162..f104b24 100644 --- a/Binary/Editor.cs +++ b/Binary/Editor.cs @@ -856,7 +856,7 @@ private void EMSWindowsNew_Click(object sender, EventArgs e) private void EMSHelpAbout_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.1.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.2.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void EMSHelpTutorials_Click(object sender, EventArgs e) @@ -1369,9 +1369,9 @@ private void LoadProfile(string filename, bool showerrors) this.EditorPropertyGrid.SelectedObject = null; this.Profile = BaseProfile.NewProfile(launch.GameID, launch.Directory); + this.EditorStatusLabel.Text = "Loading... Please wait..."; var watch = new Stopwatch(); - this.EditorStatusLabel.Text = "Loading... Please wait..."; watch.Start(); this.Profile.Load(launch); @@ -1459,8 +1459,8 @@ private void SaveProfile() { #endif - var watch = new Stopwatch(); this.EditorStatusLabel.Text = "Saving... Please wait..."; + var watch = new Stopwatch(); watch.Start(); this.Profile.Save(); @@ -1521,7 +1521,7 @@ private void EditorTreeView_AfterSelect(object sender, TreeViewEventArgs e) this.ManageButtonScriptNode(e.Node); this.EditorPropertyGrid.SelectedObject = selected; - this.EditorNodeInfo.Text = $"| {e.Node.Nodes.Count} subnodes"; + this.EditorNodeInfo.Text = $"| Index: {e.Node.Index} | {e.Node.Nodes.Count} subnodes"; } private void EditorTreeView_DoubleClick(object sender, EventArgs e) diff --git a/Binary/IntroUI.cs b/Binary/IntroUI.cs index a4b9104..bf45b8a 100644 --- a/Binary/IntroUI.cs +++ b/Binary/IntroUI.cs @@ -327,12 +327,12 @@ private void AskForGameRun(BaseProfile profile) private void PictureBoxDiscord_Click(object sender, EventArgs e) { - Utils.OpenBrowser("https://discord.gg/jzksXXn"); + Utils.OpenBrowser("https://discord.gg/xy5TjTa"); } private void PictureBoxUpdates_Click(object sender, EventArgs e) { - MessageBox.Show("No updates yet, follow discord server for news", "Updates"); + Utils.OpenBrowser("https://github.com/SpeedReflect/Binary/tags"); } private void PictureBoxAutoBackups_Click(object sender, EventArgs e) @@ -370,7 +370,7 @@ private void PictureBoxSoon_Click(object sender, EventArgs e) private void LabelBinary_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.1.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.2.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } diff --git a/Binary/UI/CarPartsEditor.cs b/Binary/UI/CarPartsEditor.cs index 097d2a7..f86d092 100644 --- a/Binary/UI/CarPartsEditor.cs +++ b/Binary/UI/CarPartsEditor.cs @@ -551,7 +551,9 @@ private void RemoveAttributeToolStripMenuItem_Click(object sender, EventArgs e) var realpart = this.Model.GetRealPart(node.Parent.Index); realpart.Attributes.RemoveAt(node.Index); this.CarPartsTreeView.SelectedNode = node.Parent; + node.Parent.Text = realpart.PartName; node.Parent.Nodes.RemoveAt(node.Index); + this.CarPartsPropertyGrid.Refresh(); } private void MoveUpAttributesToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/Binary/UI/StringEditor.cs b/Binary/UI/StringEditor.cs index e36c5f2..8eabcd4 100644 --- a/Binary/UI/StringEditor.cs +++ b/Binary/UI/StringEditor.cs @@ -22,9 +22,12 @@ public partial class StringEditor : Form private const string TText = "Text"; private STRBlock STR { get; } private readonly List
_openforms; + private readonly HashSet _modified; public List Commands { get; } private readonly string _strpath; + private static readonly Color _modified_light = Color.FromArgb(60, 60, 255); + private static readonly Color _modified_dark = Color.FromArgb(160, 140, 0); private static readonly Color _highlight_light = Color.FromArgb(60, 255, 60); private static readonly Color _highlight_dark = Color.FromArgb(160, 20, 30); @@ -35,6 +38,7 @@ public StringEditor(STRBlock str, string path) this.STR = str; this._strpath = path; this._openforms = new List(); + this._modified = new HashSet(); this.Commands = new List(); this.Text = $"{this.STR.CollectionName} Editor"; this.StrEditorListView.Columns[^1].Width = -2; @@ -116,6 +120,14 @@ private void LoadListView(int index = -1) item.SubItems.Add($"0x{record.Key:X8}"); item.SubItems.Add(record.Label); item.SubItems.Add(Utils.UTF8toISO(record.Text)); + + if (this._modified.Contains(item.SubItems[1].Text)) + { + + item.BackColor = Configurations.Default.DarkTheme ? _modified_dark : _modified_light; + + } + this.StrEditorListView.Items.Add(item); } @@ -219,6 +231,7 @@ private void AddStringToolStripMenuItem_Click(object sender, EventArgs e) var text = Utils.ISOtoUTF8(creator.Value); this.STR.AddRecord(creator.Key, creator.Label, text); this.GenerateAddStringCommand(creator.Key, creator.Label, text); + this._modified.Add(creator.Key); this.LoadListView(); var index = this.FastFindIndex(Convert.ToUInt32(creator.Key, 16)); this.FastItemSelection(index); @@ -298,12 +311,14 @@ private void EditStringToolStripMenuItem_Click(object sender, EventArgs e) this.GenerateUpdateStringCommand(prev, TText, text); this.GenerateUpdateStringCommand(prev, Label, creator.Label); this.GenerateUpdateStringCommand(prev, Key, creator.Key); + this._modified.Add(creator.Key); var item = this.StrEditorListView.SelectedItems[0]; item.SubItems[1].Text = creator.Key; item.SubItems[2].Text = creator.Label; item.SubItems[3].Text = creator.Value; this.StringEditorTextBox.Text = creator.Value; + item.BackColor = Configurations.Default.DarkTheme ? _modified_dark : _modified_light; this.GenericFindSelection(); break; @@ -359,6 +374,15 @@ private void ReplaceStringToolStripMenuItem_Click(object sender, EventArgs e) record.Text = Regex.Replace(record.Text, input.Value, with.Value, options); this.GenerateUpdateStringCommand(key, TText, record.Text); + + if (record.Text != item.SubItems[3].Text) + { + + this._modified.Add(item.SubItems[1].Text); + item.BackColor = Configurations.Default.DarkTheme ? _modified_dark : _modified_light; + + } + item.SubItems[3].Text = Utils.UTF8toISO(record.Text); } @@ -380,10 +404,12 @@ private void FindPreviousToolStripMenuItem_Click(object sender, EventArgs e) var index = this.StrEditorListView.SelectedIndices.Count == 0 ? this.StrEditorListView.Items.Count - 1 : this.StrEditorListView.SelectedIndices[0] - 1; + var match = Configurations.Default.DarkTheme ? _highlight_dark : _highlight_light; + for (int i = index; i >= 0; --i) { - if (this.StrEditorListView.Items[i].BackColor != this.StrEditorListView.BackColor) + if (this.StrEditorListView.Items[i].BackColor == match) { this.FastItemSelection(i); @@ -396,7 +422,7 @@ private void FindPreviousToolStripMenuItem_Click(object sender, EventArgs e) for (int i = this.StrEditorListView.Items.Count - 1; i > index; --i) { - if (this.StrEditorListView.Items[i].BackColor != this.StrEditorListView.BackColor) + if (this.StrEditorListView.Items[i].BackColor == match) { this.FastItemSelection(i); @@ -415,10 +441,12 @@ private void FindNextToolStripMenuItem_Click(object sender, EventArgs e) var index = this.StrEditorListView.SelectedIndices.Count == 0 ? 0 : this.StrEditorListView.SelectedIndices[0] + 1; + var match = Configurations.Default.DarkTheme ? _highlight_dark : _highlight_light; + for (int i = index; i < this.StrEditorListView.Items.Count; ++i) { - if (this.StrEditorListView.Items[i].BackColor != this.StrEditorListView.BackColor) + if (this.StrEditorListView.Items[i].BackColor == match) { this.FastItemSelection(i); @@ -431,7 +459,7 @@ private void FindNextToolStripMenuItem_Click(object sender, EventArgs e) for (int i = 0; i < index; ++i) { - if (this.StrEditorListView.Items[i].BackColor != this.StrEditorListView.BackColor) + if (this.StrEditorListView.Items[i].BackColor == match) { this.FastItemSelection(i); @@ -560,6 +588,13 @@ private void TextBoxKey_TextChanged(object sender, EventArgs e) { item.BackColor = this.StrEditorListView.BackColor; + + if (this._modified.Contains(item.SubItems[1].Text)) + { + + item.BackColor = Configurations.Default.DarkTheme ? _modified_dark : _modified_light; + + } } @@ -577,12 +612,21 @@ private void TextBoxKey_TextChanged(object sender, EventArgs e) foreach (ListViewItem item in this.StrEditorListView.Items) { - var value = item.SubItems[1].Text.ToUpperInvariant(); - item.BackColor = !value.Contains(find) - ? this.StrEditorListView.BackColor - : Configurations.Default.DarkTheme - ? _highlight_dark - : _highlight_light; + item.BackColor = this.StrEditorListView.BackColor; + + if (this._modified.Contains(item.SubItems[1].Text)) + { + + item.BackColor = Configurations.Default.DarkTheme ? _modified_dark : _modified_light; + + } + + if (item.SubItems[1].Text.ToUpperInvariant().Contains(find)) + { + + item.BackColor = Configurations.Default.DarkTheme ? _highlight_dark : _highlight_light; + + } } @@ -607,6 +651,13 @@ private void TextBoxLabel_TextChanged(object sender, EventArgs e) { item.BackColor = this.StrEditorListView.BackColor; + + if (this._modified.Contains(item.SubItems[1].Text)) + { + + item.BackColor = Configurations.Default.DarkTheme ? _modified_dark : _modified_light; + + } } @@ -624,12 +675,21 @@ private void TextBoxLabel_TextChanged(object sender, EventArgs e) foreach (ListViewItem item in this.StrEditorListView.Items) { - var value = item.SubItems[2].Text.ToUpperInvariant(); - item.BackColor = !value.Contains(find) - ? this.StrEditorListView.BackColor - : Configurations.Default.DarkTheme - ? _highlight_dark - : _highlight_light; + item.BackColor = this.StrEditorListView.BackColor; + + if (this._modified.Contains(item.SubItems[1].Text)) + { + + item.BackColor = Configurations.Default.DarkTheme ? _modified_dark : _modified_light; + + } + + if (item.SubItems[2].Text.ToUpperInvariant().Contains(find)) + { + + item.BackColor = Configurations.Default.DarkTheme ? _highlight_dark : _highlight_light; + + } } @@ -654,6 +714,13 @@ private void TextBoxText_TextChanged(object sender, EventArgs e) { item.BackColor = this.StrEditorListView.BackColor; + + if (this._modified.Contains(item.SubItems[1].Text)) + { + + item.BackColor = Configurations.Default.DarkTheme ? _modified_dark : _modified_light; + + } } @@ -671,12 +738,21 @@ private void TextBoxText_TextChanged(object sender, EventArgs e) foreach (ListViewItem item in this.StrEditorListView.Items) { - var value = item.SubItems[3].Text.ToUpperInvariant(); - item.BackColor = !value.Contains(find) - ? this.StrEditorListView.BackColor - : Configurations.Default.DarkTheme - ? _highlight_dark - : _highlight_light; + item.BackColor = this.StrEditorListView.BackColor; + + if (this._modified.Contains(item.SubItems[1].Text)) + { + + item.BackColor = Configurations.Default.DarkTheme ? _modified_dark : _modified_light; + + } + + if (item.SubItems[3].Text.ToUpperInvariant().Contains(find)) + { + + item.BackColor = Configurations.Default.DarkTheme ? _highlight_dark : _highlight_light; + + } } @@ -702,6 +778,15 @@ private void StringEditorTextBox_TextChanged(object sender, EventArgs e) if (record == null) return; var selected = this.StrEditorListView.SelectedItems[0]; + + if (selected.SubItems[3].Text != this.StringEditorTextBox.Text) + { + + this._modified.Add(selected.SubItems[1].Text); + selected.BackColor = Configurations.Default.DarkTheme ? _modified_dark : _modified_light; + + } + selected.SubItems[3].Text = this.StringEditorTextBox.Text ?? String.Empty; record.Text = Utils.ISOtoUTF8(selected.SubItems[3].Text); @@ -772,9 +857,15 @@ private void StringEditorTextBox_Validated(object sender, EventArgs e) var record = this.STR.GetRecord(key); if (record == null) return; + if (this.StrEditorListView.SelectedItems.Count == 0) return; var selected = this.StrEditorListView.SelectedItems[0]; + + if (selected.SubItems[3].Text == this.StringEditorTextBox.Text) return; + this.GenerateUpdateStringCommand(selected.SubItems[1].Text, TText, record.Text); + selected.BackColor = Configurations.Default.DarkTheme ? _modified_dark : _modified_light; + this._modified.Add(selected.SubItems[1].Text); } } } diff --git a/Binary/UI/VectorEditor.cs b/Binary/UI/VectorEditor.cs index 249144e..eb948dd 100644 --- a/Binary/UI/VectorEditor.cs +++ b/Binary/UI/VectorEditor.cs @@ -1,6 +1,7 @@ using System; using System.IO; using System.Drawing; +using System.Diagnostics; using System.Windows.Forms; using Binary.Properties; using Nikki.Support.Shared.Class; @@ -214,6 +215,7 @@ private void ImportSVGToolStripMenuItem_Click(object sender, EventArgs e) #endif this.Vector.ReadFromFile(browser.FileName); + this.VectorPropertyGrid.SelectedObject = null; this.LoadTreeView(); MessageBox.Show($"File {browser.FileName} has been successfully imported.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); @@ -271,8 +273,12 @@ private void ExportSVGToolStripMenuItem_Click(object sender, EventArgs e) private void PreviewToolStripMenuItem_Click(object sender, EventArgs e) { var svg = this.Vector.GetSVGString(1024); - File.WriteAllText("vectordev.html", svg); - Utils.OpenBrowser("vectordev.html"); + var dir = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); + var file = Path.Combine(dir, "vectordev.html"); + File.WriteAllText(file, svg); + + try { Process.Start(new ProcessStartInfo($"\"{file}\"") { UseShellExecute = true }); } + catch (Exception ex) { MessageBox.Show(ex.GetLowestMessage(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void AddPathSetToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/Binary/Utils.cs b/Binary/Utils.cs index 8821424..e9750fc 100644 --- a/Binary/Utils.cs +++ b/Binary/Utils.cs @@ -65,7 +65,7 @@ public static void OpenBrowser(string url) { url = url.Replace("&", "^&"); - Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true }); + Process.Start(new ProcessStartInfo("cmd.exe ", $"/c start {url}") { CreateNoWindow = true }); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) From 10935096f327638e99d7cbb5cc05bf7dd871c168 Mon Sep 17 00:00:00 2001 From: MaxHwoy Date: Wed, 11 Nov 2020 16:16:53 -0800 Subject: [PATCH 03/10] Underground1 support added. --- Binary/Interact/AttribCreator.cs | 14 +++++++++++--- Binary/Program.cs | 32 ++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Binary/Interact/AttribCreator.cs b/Binary/Interact/AttribCreator.cs index 4988506..46467f6 100644 --- a/Binary/Interact/AttribCreator.cs +++ b/Binary/Interact/AttribCreator.cs @@ -99,31 +99,39 @@ private void PopulateAttribTypesBasedOnGame(GameINT game) this.AttribTypeComboBox.SelectedIndex = 0; break; + case GameINT.Underground1: case GameINT.Underground2: case GameINT.MostWanted: this.AttribTypeComboBox.Items.AddRange(new string[] { Boolean, /// + /// + /// Floating, /// + /// + /// Integer, /// + /// + /// Key, /// + /// + /// String, /// + /// + /// }); this.AttribTypeComboBox.SelectedIndex = 0; break; - case GameINT.Underground1: - break; - default: break; } diff --git a/Binary/Program.cs b/Binary/Program.cs index 26a550a..32fed16 100644 --- a/Binary/Program.cs +++ b/Binary/Program.cs @@ -76,14 +76,30 @@ static void Main() private static void SetDependencyPaths(string thispath) { - CarbonProfile.MainHashList = Path.Combine(thispath, @"mainkeys\carbon.txt"); - CarbonProfile.CustomHashList = Path.Combine(thispath, @"userkeys\carbon.txt"); - MostWantedProfile.MainHashList = Path.Combine(thispath, @"mainkeys\mostwanted.txt"); - MostWantedProfile.CustomHashList = Path.Combine(thispath, @"userkeys\mostwanted.txt"); - Underground2Profile.MainHashList = Path.Combine(thispath, @"mainkeys\underground2.txt"); - Underground2Profile.CustomHashList = Path.Combine(thispath, @"userkeys\underground2.txt"); - ProstreetProfile.MainHashList = Path.Combine(thispath, @"mainkeys\prostreet.txt"); - ProstreetProfile.CustomHashList = Path.Combine(thispath, @"userkeys\prostreet.txt"); + var userdir = Path.Combine(thispath, "userkeys"); + var mainc = Path.Combine(thispath, @"mainkeys\carbon.txt"); + var userc = Path.Combine(thispath, @"userkeys\carbon.txt"); + var mainmw = Path.Combine(thispath, @"mainkeys\mostwanted.txt"); + var usermw = Path.Combine(thispath, @"userkeys\mostwanted.txt"); + var mainug2 = Path.Combine(thispath, @"mainkeys\underground2.txt"); + var userug2 = Path.Combine(thispath, @"userkeys\underground2.txt"); + var mainps = Path.Combine(thispath, @"mainkeys\prostreet.txt"); + var userps = Path.Combine(thispath, @"userkeys\prostreet.txt"); + + CarbonProfile.MainHashList = mainc; + CarbonProfile.CustomHashList = userc; + MostWantedProfile.MainHashList = mainmw; + MostWantedProfile.CustomHashList = usermw; + Underground2Profile.MainHashList = mainug2; + Underground2Profile.CustomHashList = userug2; + ProstreetProfile.MainHashList = mainps; + ProstreetProfile.CustomHashList = userps; + + if (!Directory.Exists(userdir)) Directory.CreateDirectory(userdir); + if (!File.Exists(userc)) { using var _ = File.Create(userc); } + if (!File.Exists(usermw)) { using var _ = File.Create(usermw); } + if (!File.Exists(userug2)) { using var _ = File.Create(userug2); } + if (!File.Exists(userps)) { using var _ = File.Create(userps); } } public static void ThreadExceptionHandler(object sender, ThreadExceptionEventArgs e) From e11711c2942e18571da2015914091be235ff9644 Mon Sep 17 00:00:00 2001 From: MaxHwoy Date: Wed, 18 Nov 2020 16:01:15 -0800 Subject: [PATCH 04/10] Added option to load new launcher; Find and Replace in CarPartsEditor now works for UG1 as well. --- Binary/Binary.csproj | 2 +- Binary/Editor.cs | 18 +++++++++++++++++- Binary/Interact/LanMaker.cs | 5 +++++ Binary/IntroUI.cs | 2 +- Binary/Program.cs | 19 ++++++++++++------- Binary/Tools/Raider.cs | 25 +++++++++++++++++-------- Binary/UI/CarPartsEditor.cs | 14 +++++++++----- Binary/UI/CareerEditor.cs | 1 + 8 files changed, 63 insertions(+), 23 deletions(-) diff --git a/Binary/Binary.csproj b/Binary/Binary.csproj index 688a46d..6ce1ec1 100644 --- a/Binary/Binary.csproj +++ b/Binary/Binary.csproj @@ -5,7 +5,7 @@ netcoreapp3.1 true binary.ico - 2.2.0 + 2.3.2 MaxHwoy Tool for editing Need for Speed binary files (.BIN, .BUN, .LZC). Copyright © 2020 MaxHwoy diff --git a/Binary/Editor.cs b/Binary/Editor.cs index f104b24..659cdf9 100644 --- a/Binary/Editor.cs +++ b/Binary/Editor.cs @@ -386,6 +386,22 @@ private void EMSMainNewLauncher_Click(object sender, EventArgs e) { using var form = new LanMaker(); form.ShowDialog(); + + if (form.WasCreated) + { + + var result = MessageBox.Show("New launcher was created. Would you like to load it?", "Prompt", + MessageBoxButtons.YesNo, MessageBoxIcon.Question); + + if (result == DialogResult.Yes) + { + + this.LoadProfile(form.NewLanPath, true); + + } + + } + } private void EMSMainLoadFiles_Click(object sender, EventArgs e) @@ -856,7 +872,7 @@ private void EMSWindowsNew_Click(object sender, EventArgs e) private void EMSHelpAbout_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.2.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.3.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void EMSHelpTutorials_Click(object sender, EventArgs e) diff --git a/Binary/Interact/LanMaker.cs b/Binary/Interact/LanMaker.cs index 61e86a1..46866c2 100644 --- a/Binary/Interact/LanMaker.cs +++ b/Binary/Interact/LanMaker.cs @@ -10,6 +10,8 @@ namespace Binary.Interact public partial class LanMaker : Form { private bool IsValidDirectoryChosen => Directory.Exists(this.LanMakerTextBoxDir.Text); + public bool WasCreated { get; private set; } + public string NewLanPath { get; private set; } public LanMaker() { @@ -90,6 +92,9 @@ private void LanMakerButtonSave_Click(object sender, EventArgs e) MessageBox.Show($"File {dialog.FileName} has been saved.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); + this.WasCreated = true; + this.NewLanPath = dialog.FileName; + } } diff --git a/Binary/IntroUI.cs b/Binary/IntroUI.cs index bf45b8a..4a319db 100644 --- a/Binary/IntroUI.cs +++ b/Binary/IntroUI.cs @@ -370,7 +370,7 @@ private void PictureBoxSoon_Click(object sender, EventArgs e) private void LabelBinary_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.2.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.3.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } diff --git a/Binary/Program.cs b/Binary/Program.cs index 32fed16..06c858b 100644 --- a/Binary/Program.cs +++ b/Binary/Program.cs @@ -81,25 +81,30 @@ private static void SetDependencyPaths(string thispath) var userc = Path.Combine(thispath, @"userkeys\carbon.txt"); var mainmw = Path.Combine(thispath, @"mainkeys\mostwanted.txt"); var usermw = Path.Combine(thispath, @"userkeys\mostwanted.txt"); - var mainug2 = Path.Combine(thispath, @"mainkeys\underground2.txt"); - var userug2 = Path.Combine(thispath, @"userkeys\underground2.txt"); var mainps = Path.Combine(thispath, @"mainkeys\prostreet.txt"); var userps = Path.Combine(thispath, @"userkeys\prostreet.txt"); + var mainug1 = Path.Combine(thispath, @"mainkeys\underground1.txt"); + var userug1 = Path.Combine(thispath, @"userkeys\underground1.txt"); + var mainug2 = Path.Combine(thispath, @"mainkeys\underground2.txt"); + var userug2 = Path.Combine(thispath, @"userkeys\underground2.txt"); CarbonProfile.MainHashList = mainc; CarbonProfile.CustomHashList = userc; MostWantedProfile.MainHashList = mainmw; MostWantedProfile.CustomHashList = usermw; - Underground2Profile.MainHashList = mainug2; - Underground2Profile.CustomHashList = userug2; ProstreetProfile.MainHashList = mainps; ProstreetProfile.CustomHashList = userps; + Underground1Profile.MainHashList = mainug1; + Underground1Profile.CustomHashList = userug1; + Underground2Profile.MainHashList = mainug2; + Underground2Profile.CustomHashList = userug2; if (!Directory.Exists(userdir)) Directory.CreateDirectory(userdir); if (!File.Exists(userc)) { using var _ = File.Create(userc); } if (!File.Exists(usermw)) { using var _ = File.Create(usermw); } - if (!File.Exists(userug2)) { using var _ = File.Create(userug2); } if (!File.Exists(userps)) { using var _ = File.Create(userps); } + if (!File.Exists(userug1)) { using var _ = File.Create(userug1); } + if (!File.Exists(userug2)) { using var _ = File.Create(userug2); } } public static void ThreadExceptionHandler(object sender, ThreadExceptionEventArgs e) @@ -128,8 +133,8 @@ public static void ThreadExceptionHandler(object sender, ThreadExceptionEventArg if (form is Editor editor) { - editor.EmergencySaveDatabase(); - MessageBox.Show("Database backup up.", "Done"); + //editor.EmergencySaveDatabase(); + //MessageBox.Show("Database backup up.", "Done"); } diff --git a/Binary/Tools/Raider.cs b/Binary/Tools/Raider.cs index 516be9b..be48188 100644 --- a/Binary/Tools/Raider.cs +++ b/Binary/Tools/Raider.cs @@ -59,15 +59,20 @@ private void ChooseSearchMode_SelectedIndexChanged(object sender, EventArgs e) private void BinHashInput_TextChanged(object sender, EventArgs e) { - if (!this.BinHashInput.ReadOnly && this.BinHashInput.Text.IsHexString()) + var value = this.BinHashInput.Text.StartsWith("0x") + ? this.BinHashInput.Text + : $"0x{this.BinHashInput.Text}"; + + if (!this.BinHashInput.ReadOnly && value.IsHexString()) { - if (this.BinHashInput.Text.Length > 10) return; + + if (value.Length > 10) { this.StringGuessed.Text = "N/A"; return; } var key = Convert.ToUInt32(this.BinHashInput.Text, 16); this.BinFileInput.Text = $"0x{key.Reverse():X8}"; - this.StringGuessed.Text = Map.BinKeys.TryGetValue(key, out var value) - ? value + this.StringGuessed.Text = Map.BinKeys.TryGetValue(key, out var result) + ? result : "N/A"; } @@ -75,17 +80,21 @@ private void BinHashInput_TextChanged(object sender, EventArgs e) private void BinFileInput_TextChanged(object sender, EventArgs e) { - if (!this.BinFileInput.ReadOnly && this.BinFileInput.Text.IsHexString()) + var value = this.BinHashInput.Text.StartsWith("0x") + ? this.BinHashInput.Text + : $"0x{this.BinHashInput.Text}"; + + if (!this.BinFileInput.ReadOnly && value.IsHexString()) { - if (this.BinHashInput.Text.Length > 10) return; + if (value.Length > 10) { this.StringGuessed.Text = "N/A"; return; } var key = Convert.ToUInt32(this.BinFileInput.Text, 16); key = key.Reverse(); this.BinHashInput.Text = $"0x{key:X8}"; - this.StringGuessed.Text = Map.BinKeys.TryGetValue(key, out var value) - ? value + this.StringGuessed.Text = Map.BinKeys.TryGetValue(key, out var result) + ? result : "N/A"; } } diff --git a/Binary/UI/CarPartsEditor.cs b/Binary/UI/CarPartsEditor.cs index f86d092..143baa8 100644 --- a/Binary/UI/CarPartsEditor.cs +++ b/Binary/UI/CarPartsEditor.cs @@ -30,12 +30,16 @@ public CarPartsEditor(DBModelPart model) this.LoadTreeView(); this.ToggleMenuStripControls(null); - if (this.Model.GameINT != GameINT.MostWanted && this.Model.GameINT != GameINT.Underground2) + this.FindAndReplaceToolStripMenuItem.Enabled = this.Model.GameINT switch { - - this.FindAndReplaceToolStripMenuItem.Enabled = false; - - } + GameINT.Underground1 => true, + GameINT.Underground2 => true, + GameINT.MostWanted => true, + GameINT.Carbon => false, + GameINT.Prostreet => false, + GameINT.Undercover => false, + _ => false, + }; } #region Theme diff --git a/Binary/UI/CareerEditor.cs b/Binary/UI/CareerEditor.cs index 20e2765..b266b71 100644 --- a/Binary/UI/CareerEditor.cs +++ b/Binary/UI/CareerEditor.cs @@ -473,6 +473,7 @@ private void GenerateUpdateInCareerCommand(string nodepath, string property, str string command = String.Empty; if (property.Contains(' ')) property = $"\"{property}\""; if (value.Contains(' ')) property = $"\"{value}\""; + if (String.IsNullOrEmpty(value)) value = "\"\""; if (splits.Length == 2) { From e0062030610b66cd1a6d7e0f427d0184afd1954c Mon Sep 17 00:00:00 2001 From: MaxHwoy Date: Sat, 21 Nov 2020 00:38:33 -0800 Subject: [PATCH 05/10] Custom attributor creating added to CarPartsEditor --- Binary/Prompt/Input.cs | 2 +- Binary/UI/CarPartsEditor.Designer.cs | 12 +++++++++++- Binary/UI/CarPartsEditor.cs | 26 ++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Binary/Prompt/Input.cs b/Binary/Prompt/Input.cs index e9d6e1c..de0d06c 100644 --- a/Binary/Prompt/Input.cs +++ b/Binary/Prompt/Input.cs @@ -19,7 +19,7 @@ public Input(string text) : this(text, null, invalid, null) { } public Input(string text, Predicate inputcheck) : this(text, inputcheck, invalid, null) { } - public Input(string text, Predicate inputcheck, string error) : this(text, inputcheck, invalid, error) { } + public Input(string text, Predicate inputcheck, string error) : this(text, inputcheck, error, null) { } public Input(string text, Predicate inputcheck, string error, string initial) { diff --git a/Binary/UI/CarPartsEditor.Designer.cs b/Binary/UI/CarPartsEditor.Designer.cs index da87402..f7637a7 100644 --- a/Binary/UI/CarPartsEditor.Designer.cs +++ b/Binary/UI/CarPartsEditor.Designer.cs @@ -51,6 +51,7 @@ private void InitializeComponent() this.MoveDownAttributesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ReverseAttributesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SortAttributesByKeyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.AddCustomAttributeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ToolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.HasherToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.RaiderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -227,7 +228,8 @@ private void InitializeComponent() this.MoveUpAttributesToolStripMenuItem, this.MoveDownAttributesToolStripMenuItem, this.ReverseAttributesToolStripMenuItem, - this.SortAttributesByKeyToolStripMenuItem}); + this.SortAttributesByKeyToolStripMenuItem, + this.AddCustomAttributeToolStripMenuItem}); this.AttributesToolStripMenuItem.Name = "AttributesToolStripMenuItem"; this.AttributesToolStripMenuItem.Size = new System.Drawing.Size(71, 20); this.AttributesToolStripMenuItem.Text = "Attributes"; @@ -278,6 +280,13 @@ private void InitializeComponent() this.SortAttributesByKeyToolStripMenuItem.Text = "Sort Attributes By Key"; this.SortAttributesByKeyToolStripMenuItem.Click += new System.EventHandler(this.SortAttributesByKeyToolStripMenuItem_Click); // + // AddCustomAttributeToolStripMenuItem + // + this.AddCustomAttributeToolStripMenuItem.Name = "AddCustomAttributeToolStripMenuItem"; + this.AddCustomAttributeToolStripMenuItem.Size = new System.Drawing.Size(225, 22); + this.AddCustomAttributeToolStripMenuItem.Text = "Add Custom Attribute"; + this.AddCustomAttributeToolStripMenuItem.Click += new System.EventHandler(this.AddCustomAttributeToolStripMenuItem_Click); + // // ToolsToolStripMenuItem // this.ToolsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -346,6 +355,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem MoveUpAttributesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem ReverseAttributesToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem SortAttributesByKeyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem AddCustomAttributeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem ToolsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem HasherToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem RaiderToolStripMenuItem; diff --git a/Binary/UI/CarPartsEditor.cs b/Binary/UI/CarPartsEditor.cs index 143baa8..0e5b85e 100644 --- a/Binary/UI/CarPartsEditor.cs +++ b/Binary/UI/CarPartsEditor.cs @@ -109,6 +109,8 @@ private void ToggleTheme() this.ReverseAttributesToolStripMenuItem.ForeColor = Theme.MenuItemForeColor; this.SortAttributesByKeyToolStripMenuItem.BackColor = Theme.MenuItemBackColor; this.SortAttributesByKeyToolStripMenuItem.ForeColor = Theme.MenuItemForeColor; + this.AddCustomAttributeToolStripMenuItem.BackColor = Theme.MenuItemBackColor; + this.AddCustomAttributeToolStripMenuItem.ForeColor = Theme.MenuItemForeColor; this.HasherToolStripMenuItem.BackColor = Theme.MenuItemBackColor; this.HasherToolStripMenuItem.ForeColor = Theme.MenuItemForeColor; this.RaiderToolStripMenuItem.BackColor = Theme.MenuItemBackColor; @@ -238,6 +240,7 @@ private void ToggleMenuStripControls(TreeNode node) this.MoveDownAttributesToolStripMenuItem.Enabled = false; this.ReverseAttributesToolStripMenuItem.Enabled = false; this.SortAttributesByKeyToolStripMenuItem.Enabled = false; + this.AddCustomAttributeToolStripMenuItem.Enabled = false; } else @@ -258,6 +261,7 @@ private void ToggleMenuStripControls(TreeNode node) this.MoveDownAttributesToolStripMenuItem.Enabled = node.Level == 1; this.ReverseAttributesToolStripMenuItem.Enabled = node.Level == 0; this.SortAttributesByKeyToolStripMenuItem.Enabled = node.Level == 0; + this.AddCustomAttributeToolStripMenuItem.Enabled = node.Level == 0; } } @@ -633,6 +637,28 @@ private void SortAttributesByKeyToolStripMenuItem_Click(object sender, EventArgs this.LoadTreeView(this.CarPartsTreeView.SelectedNode.FullPath); } + private void AddCustomAttributeToolStripMenuItem_Click(object sender, EventArgs e) + { + using var creator = new Input + ( + "Input name of new custom attribute", + new Predicate(_ => !String.IsNullOrEmpty(_)), + "Name of an attribute cannot be empty" + ); + + if (creator.ShowDialog() == DialogResult.OK) + { + + var node = this.CarPartsTreeView.SelectedNode; + var realpart = this.Model.GetRealPart(node.Index); + realpart.AddCustomAttribute(creator.Value); + var attribute = realpart.Attributes[^1]; + node.Nodes.Add(attribute.ToString()); + this.CarPartsPropertyGrid.Refresh(); + + } + } + private void HasherToolStripMenuItem_Click(object sender, EventArgs e) { var hasher = new Hasher() { StartPosition = FormStartPosition.CenterScreen }; From 1f3d6ac59b7ba005a7295bd81be1dac9ebdc44c2 Mon Sep 17 00:00:00 2001 From: MaxHwoy Date: Fri, 27 Nov 2020 02:12:05 -0800 Subject: [PATCH 06/10] Version bump, some fixes, extensions, more --- Binary/Binary.csproj | 2 +- Binary/Editor.cs | 2 +- Binary/IntroUI.cs | 2 +- Binary/Prompt/Check.cs | 7 +++++- Binary/Tools/Raider.cs | 6 ++--- Binary/UI/CarPartsEditor.cs | 46 +++++++++++++++++++++---------------- 6 files changed, 38 insertions(+), 27 deletions(-) diff --git a/Binary/Binary.csproj b/Binary/Binary.csproj index 6ce1ec1..bb16e8b 100644 --- a/Binary/Binary.csproj +++ b/Binary/Binary.csproj @@ -5,7 +5,7 @@ netcoreapp3.1 true binary.ico - 2.3.2 + 2.3.3 MaxHwoy Tool for editing Need for Speed binary files (.BIN, .BUN, .LZC). Copyright © 2020 MaxHwoy diff --git a/Binary/Editor.cs b/Binary/Editor.cs index 659cdf9..2684d35 100644 --- a/Binary/Editor.cs +++ b/Binary/Editor.cs @@ -872,7 +872,7 @@ private void EMSWindowsNew_Click(object sender, EventArgs e) private void EMSHelpAbout_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.3.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.3.3", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void EMSHelpTutorials_Click(object sender, EventArgs e) diff --git a/Binary/IntroUI.cs b/Binary/IntroUI.cs index 4a319db..cee5bb8 100644 --- a/Binary/IntroUI.cs +++ b/Binary/IntroUI.cs @@ -370,7 +370,7 @@ private void PictureBoxSoon_Click(object sender, EventArgs e) private void LabelBinary_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.3.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.3.3", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } diff --git a/Binary/Prompt/Check.cs b/Binary/Prompt/Check.cs index 6bd908a..452a252 100644 --- a/Binary/Prompt/Check.cs +++ b/Binary/Prompt/Check.cs @@ -15,11 +15,16 @@ public Check() this.ToggleTheme(); } - public Check(string desc, bool prompt) : this() + public Check(string desc, bool prompt) : this(desc, prompt, false) + { + } + + public Check(string desc, bool prompt, bool initiallyChecked) : this() { this.CheckButtonCancel.Enabled = !prompt; this.ControlBox = !prompt; this.CheckBoxSelection.Text = desc ?? String.Empty; + this.CheckBoxSelection.Checked = initiallyChecked; } private void ToggleTheme() diff --git a/Binary/Tools/Raider.cs b/Binary/Tools/Raider.cs index be48188..40da797 100644 --- a/Binary/Tools/Raider.cs +++ b/Binary/Tools/Raider.cs @@ -80,9 +80,9 @@ private void BinHashInput_TextChanged(object sender, EventArgs e) private void BinFileInput_TextChanged(object sender, EventArgs e) { - var value = this.BinHashInput.Text.StartsWith("0x") - ? this.BinHashInput.Text - : $"0x{this.BinHashInput.Text}"; + var value = this.BinFileInput.Text.StartsWith("0x") + ? this.BinFileInput.Text + : $"0x{this.BinFileInput.Text}"; if (!this.BinFileInput.ReadOnly && value.IsHexString()) { diff --git a/Binary/UI/CarPartsEditor.cs b/Binary/UI/CarPartsEditor.cs index 0e5b85e..c50665e 100644 --- a/Binary/UI/CarPartsEditor.cs +++ b/Binary/UI/CarPartsEditor.cs @@ -30,16 +30,7 @@ public CarPartsEditor(DBModelPart model) this.LoadTreeView(); this.ToggleMenuStripControls(null); - this.FindAndReplaceToolStripMenuItem.Enabled = this.Model.GameINT switch - { - GameINT.Underground1 => true, - GameINT.Underground2 => true, - GameINT.MostWanted => true, - GameINT.Carbon => false, - GameINT.Prostreet => false, - GameINT.Undercover => false, - _ => false, - }; + this.FindAndReplaceToolStripMenuItem.Enabled = true; } #region Theme @@ -491,6 +482,14 @@ private void FindAndReplaceToolStripMenuItem_Click(object sende, EventArgs e) { if (this.CarPartsTreeView.Nodes.Count == 0) return; + // 4 windows: + // 1. String to replace with + // 2. String to replace itself + // 3. Do case sensitive search + // 4. Replace only PartLabel or absolutely everything + + + // 1 & 2 using var with = new Input("Enter string to replace with"); using var input = new Input("Enter string to search for", new Predicate(_ => !String.IsNullOrEmpty(_)), @@ -499,30 +498,37 @@ private void FindAndReplaceToolStripMenuItem_Click(object sende, EventArgs e) if (input.ShowDialog() == DialogResult.OK && with.ShowDialog() == DialogResult.OK) { + // 3 using var check = new Check("Make case-sensitive replace?", false); if (check.ShowDialog() == DialogResult.OK) { + // Make regex options based on result of 3 var options = check.Value ? RegexOptions.Multiline | RegexOptions.CultureInvariant : RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase; - this.CarPartsTreeView.BeginUpdate(); + // 4 + using var all = new Check("Make replacement only in PartLabel?", false, true); - for (int i = 0; i < this.Model.CarPartsCount; ++i) + if (all.ShowDialog() == DialogResult.OK) { - // Very quick and dirty way to replace node's and part's name - var part = this.Model.GetRealPart(i); - var value = part.GetValue("PartLabel"); - value = Regex.Replace(value, input.Value, with.Value, options); - part.SetValue("PartLabel", value); - this.CarPartsTreeView.Nodes[i].Text = value; + this.CarPartsTreeView.BeginUpdate(); - } + for (int i = 0; i < this.Model.CarPartsCount; ++i) + { - this.CarPartsTreeView.EndUpdate(); + var part = this.Model.GetRealPart(i); + part.MakeReplace(all.Value, input.Value, with.Value, options); + this.CarPartsTreeView.Nodes[i].Text = part.PartName; + + } + + this.CarPartsTreeView.EndUpdate(); + + } } From 6a566828afb119592b62b27fa5ab846494bb05f5 Mon Sep 17 00:00:00 2001 From: MaxHwoy Date: Tue, 1 Dec 2020 22:27:27 -0800 Subject: [PATCH 07/10] New push with a bit improved IntroUI and some fixes. --- Binary/Binary.csproj | 2 +- Binary/Editor.cs | 2 +- Binary/IntroUI.Designer.cs | 44 +++++++++++++++++++++++++++++++------ Binary/IntroUI.cs | 2 +- Binary/UI/CarPartsEditor.cs | 1 + 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Binary/Binary.csproj b/Binary/Binary.csproj index bb16e8b..b5fc274 100644 --- a/Binary/Binary.csproj +++ b/Binary/Binary.csproj @@ -5,7 +5,7 @@ netcoreapp3.1 true binary.ico - 2.3.3 + 2.4.0 MaxHwoy Tool for editing Need for Speed binary files (.BIN, .BUN, .LZC). Copyright © 2020 MaxHwoy diff --git a/Binary/Editor.cs b/Binary/Editor.cs index 2684d35..3c22c91 100644 --- a/Binary/Editor.cs +++ b/Binary/Editor.cs @@ -872,7 +872,7 @@ private void EMSWindowsNew_Click(object sender, EventArgs e) private void EMSHelpAbout_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.3.3", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.4.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void EMSHelpTutorials_Click(object sender, EventArgs e) diff --git a/Binary/IntroUI.Designer.cs b/Binary/IntroUI.Designer.cs index 7f717c7..4eff935 100644 --- a/Binary/IntroUI.Designer.cs +++ b/Binary/IntroUI.Designer.cs @@ -31,8 +31,10 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(IntroUI)); this.IntroPanelModder = new System.Windows.Forms.Panel(); + this.label1 = new System.Windows.Forms.Label(); this.IntroPictureModder = new System.Windows.Forms.PictureBox(); this.IntroPanelUser = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); this.IntroPictureUser = new System.Windows.Forms.PictureBox(); this.IntroToolTip = new System.Windows.Forms.ToolTip(this.components); this.LabelBinary = new System.Windows.Forms.Label(); @@ -56,12 +58,24 @@ private void InitializeComponent() // // IntroPanelModder // + this.IntroPanelModder.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.IntroPanelModder.Controls.Add(this.label1); this.IntroPanelModder.Controls.Add(this.IntroPictureModder); this.IntroPanelModder.Location = new System.Drawing.Point(322, 77); this.IntroPanelModder.Name = "IntroPanelModder"; this.IntroPanelModder.Size = new System.Drawing.Size(300, 300); this.IntroPanelModder.TabIndex = 0; // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label1.Location = new System.Drawing.Point(96, 3); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(118, 21); + this.label1.TabIndex = 1; + this.label1.Text = "Modder Mode"; + // // IntroPictureModder // this.IntroPictureModder.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -69,9 +83,9 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.IntroPictureModder.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.IntroPictureModder.Cursor = System.Windows.Forms.Cursors.Hand; - this.IntroPictureModder.Location = new System.Drawing.Point(0, 0); + this.IntroPictureModder.Location = new System.Drawing.Point(0, 30); this.IntroPictureModder.Name = "IntroPictureModder"; - this.IntroPictureModder.Size = new System.Drawing.Size(300, 300); + this.IntroPictureModder.Size = new System.Drawing.Size(298, 268); this.IntroPictureModder.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.IntroPictureModder.TabIndex = 0; this.IntroPictureModder.TabStop = false; @@ -79,12 +93,24 @@ private void InitializeComponent() // // IntroPanelUser // + this.IntroPanelUser.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.IntroPanelUser.Controls.Add(this.label2); this.IntroPanelUser.Controls.Add(this.IntroPictureUser); this.IntroPanelUser.Location = new System.Drawing.Point(16, 77); this.IntroPanelUser.Name = "IntroPanelUser"; this.IntroPanelUser.Size = new System.Drawing.Size(300, 300); this.IntroPanelUser.TabIndex = 1; // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.label2.Location = new System.Drawing.Point(103, 3); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(92, 21); + this.label2.TabIndex = 1; + this.label2.Text = "User Mode"; + // // IntroPictureUser // this.IntroPictureUser.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -92,9 +118,9 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.IntroPictureUser.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.IntroPictureUser.Cursor = System.Windows.Forms.Cursors.Hand; - this.IntroPictureUser.Location = new System.Drawing.Point(0, 0); + this.IntroPictureUser.Location = new System.Drawing.Point(0, 30); this.IntroPictureUser.Name = "IntroPictureUser"; - this.IntroPictureUser.Size = new System.Drawing.Size(300, 300); + this.IntroPictureUser.Size = new System.Drawing.Size(298, 268); this.IntroPictureUser.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.IntroPictureUser.TabIndex = 0; this.IntroPictureUser.TabStop = false; @@ -104,10 +130,10 @@ private void InitializeComponent() // this.LabelBinary.AutoSize = true; this.LabelBinary.Cursor = System.Windows.Forms.Cursors.Hand; - this.LabelBinary.Font = new System.Drawing.Font("Fugaz One", 30F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); - this.LabelBinary.Location = new System.Drawing.Point(238, 9); + this.LabelBinary.Font = new System.Drawing.Font("Microsoft Sans Serif", 30F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); + this.LabelBinary.Location = new System.Drawing.Point(250, 18); this.LabelBinary.Name = "LabelBinary"; - this.LabelBinary.Size = new System.Drawing.Size(162, 59); + this.LabelBinary.Size = new System.Drawing.Size(139, 46); this.LabelBinary.TabIndex = 2; this.LabelBinary.Text = "Binary"; this.LabelBinary.Click += new System.EventHandler(this.LabelBinary_Click); @@ -200,8 +226,10 @@ private void InitializeComponent() this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Binary by MaxHwoy"; this.IntroPanelModder.ResumeLayout(false); + this.IntroPanelModder.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.IntroPictureModder)).EndInit(); this.IntroPanelUser.ResumeLayout(false); + this.IntroPanelUser.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.IntroPictureUser)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PictureBoxUpdates)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.PictureBoxMaximized)).EndInit(); @@ -228,5 +256,7 @@ private void InitializeComponent() private System.Windows.Forms.PictureBox PictureBoxAutoBackups; private System.Windows.Forms.PictureBox PictureBoxSoon; private System.Windows.Forms.PictureBox PictureBoxTheme; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; } } \ No newline at end of file diff --git a/Binary/IntroUI.cs b/Binary/IntroUI.cs index cee5bb8..67cd655 100644 --- a/Binary/IntroUI.cs +++ b/Binary/IntroUI.cs @@ -370,7 +370,7 @@ private void PictureBoxSoon_Click(object sender, EventArgs e) private void LabelBinary_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.3.3", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.4.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } diff --git a/Binary/UI/CarPartsEditor.cs b/Binary/UI/CarPartsEditor.cs index c50665e..85b04da 100644 --- a/Binary/UI/CarPartsEditor.cs +++ b/Binary/UI/CarPartsEditor.cs @@ -527,6 +527,7 @@ private void FindAndReplaceToolStripMenuItem_Click(object sende, EventArgs e) } this.CarPartsTreeView.EndUpdate(); + this.CarPartsPropertyGrid.Refresh(); } From 077d3d03ee1ae0611ff78c59de10a5064f98f727 Mon Sep 17 00:00:00 2001 From: MaxHwoy Date: Fri, 11 Dec 2020 20:59:28 -0800 Subject: [PATCH 08/10] Version bump with updated CoreExtensions lib linked. --- Binary.sln | 6 ++++++ Binary/Binary.csproj | 8 +------- Binary/Editor.cs | 2 +- Binary/IntroUI.cs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Binary.sln b/Binary.sln index 8213460..617813b 100644 --- a/Binary.sln +++ b/Binary.sln @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILWrapper", "..\ILWrapper\I EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Endscript", "..\Endscript\Endscript\Endscript.csproj", "{ACC9EEB0-18B8-4EBA-B9D0-739E9C4501A1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CoreExtensions", "..\CoreExtensions\CoreExtensions\CoreExtensions.csproj", "{4C6FAA97-A899-4EFC-94B0-9E0DA55FB99B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +35,10 @@ Global {ACC9EEB0-18B8-4EBA-B9D0-739E9C4501A1}.Debug|Any CPU.Build.0 = Debug|Any CPU {ACC9EEB0-18B8-4EBA-B9D0-739E9C4501A1}.Release|Any CPU.ActiveCfg = Release|Any CPU {ACC9EEB0-18B8-4EBA-B9D0-739E9C4501A1}.Release|Any CPU.Build.0 = Release|Any CPU + {4C6FAA97-A899-4EFC-94B0-9E0DA55FB99B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4C6FAA97-A899-4EFC-94B0-9E0DA55FB99B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4C6FAA97-A899-4EFC-94B0-9E0DA55FB99B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4C6FAA97-A899-4EFC-94B0-9E0DA55FB99B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Binary/Binary.csproj b/Binary/Binary.csproj index b5fc274..c12975e 100644 --- a/Binary/Binary.csproj +++ b/Binary/Binary.csproj @@ -5,7 +5,7 @@ netcoreapp3.1 true binary.ico - 2.4.0 + 2.5.0 MaxHwoy Tool for editing Need for Speed binary files (.BIN, .BUN, .LZC). Copyright © 2020 MaxHwoy @@ -26,12 +26,6 @@ - - - ..\..\Nikki\Nikki\CoreExtensions.dll - - - Form diff --git a/Binary/Editor.cs b/Binary/Editor.cs index 3c22c91..6769606 100644 --- a/Binary/Editor.cs +++ b/Binary/Editor.cs @@ -872,7 +872,7 @@ private void EMSWindowsNew_Click(object sender, EventArgs e) private void EMSHelpAbout_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.4.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.5.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void EMSHelpTutorials_Click(object sender, EventArgs e) diff --git a/Binary/IntroUI.cs b/Binary/IntroUI.cs index 67cd655..1407328 100644 --- a/Binary/IntroUI.cs +++ b/Binary/IntroUI.cs @@ -370,7 +370,7 @@ private void PictureBoxSoon_Click(object sender, EventArgs e) private void LabelBinary_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.4.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.5.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } From aae4f35d3c446866da027f25be09c3a9d8b1f399 Mon Sep 17 00:00:00 2001 From: MaxHwoy Date: Tue, 15 Dec 2020 23:19:22 -0800 Subject: [PATCH 09/10] Version bump with stream support --- Binary/Binary.csproj | 2 +- Binary/Editor.cs | 2 +- Binary/IntroUI.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Binary/Binary.csproj b/Binary/Binary.csproj index c12975e..ce86997 100644 --- a/Binary/Binary.csproj +++ b/Binary/Binary.csproj @@ -5,7 +5,7 @@ netcoreapp3.1 true binary.ico - 2.5.0 + 2.5.2 MaxHwoy Tool for editing Need for Speed binary files (.BIN, .BUN, .LZC). Copyright © 2020 MaxHwoy diff --git a/Binary/Editor.cs b/Binary/Editor.cs index 6769606..1287ef2 100644 --- a/Binary/Editor.cs +++ b/Binary/Editor.cs @@ -872,7 +872,7 @@ private void EMSWindowsNew_Click(object sender, EventArgs e) private void EMSHelpAbout_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.5.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.5.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void EMSHelpTutorials_Click(object sender, EventArgs e) diff --git a/Binary/IntroUI.cs b/Binary/IntroUI.cs index 1407328..eba1bbf 100644 --- a/Binary/IntroUI.cs +++ b/Binary/IntroUI.cs @@ -370,7 +370,7 @@ private void PictureBoxSoon_Click(object sender, EventArgs e) private void LabelBinary_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.5.0", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.5.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } From c66274ebc9ceedadfa7b3f657c8498adcd828d4b Mon Sep 17 00:00:00 2001 From: MaxHwoy Date: Mon, 28 Dec 2020 17:22:51 -0800 Subject: [PATCH 10/10] Version bump after dependency updates --- Binary/Binary.csproj | 2 +- Binary/Editor.cs | 2 +- Binary/IntroUI.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Binary/Binary.csproj b/Binary/Binary.csproj index ce86997..fa16f91 100644 --- a/Binary/Binary.csproj +++ b/Binary/Binary.csproj @@ -5,7 +5,7 @@ netcoreapp3.1 true binary.ico - 2.5.2 + 2.5.5 MaxHwoy Tool for editing Need for Speed binary files (.BIN, .BUN, .LZC). Copyright © 2020 MaxHwoy diff --git a/Binary/Editor.cs b/Binary/Editor.cs index 1287ef2..12eb08f 100644 --- a/Binary/Editor.cs +++ b/Binary/Editor.cs @@ -872,7 +872,7 @@ private void EMSWindowsNew_Click(object sender, EventArgs e) private void EMSHelpAbout_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.5.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.5.5", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void EMSHelpTutorials_Click(object sender, EventArgs e) diff --git a/Binary/IntroUI.cs b/Binary/IntroUI.cs index eba1bbf..ed18554 100644 --- a/Binary/IntroUI.cs +++ b/Binary/IntroUI.cs @@ -370,7 +370,7 @@ private void PictureBoxSoon_Click(object sender, EventArgs e) private void LabelBinary_Click(object sender, EventArgs e) { - MessageBox.Show("Binary by MaxHwoy v2.5.2", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show("Binary by MaxHwoy v2.5.5", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }