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 6baddec..fa16f91 100644 --- a/Binary/Binary.csproj +++ b/Binary/Binary.csproj @@ -5,7 +5,7 @@ netcoreapp3.1 true binary.ico - 2.1.0 + 2.5.5 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 924a5be..12eb08f 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,12 +872,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.5.5", "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 @@ -1369,9 +1385,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 +1475,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 +1537,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/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/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.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 63bce11..ed18554 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(); @@ -325,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) @@ -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.5.5", "About", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } diff --git a/Binary/Program.cs b/Binary/Program.cs index 26a550a..06c858b 100644 --- a/Binary/Program.cs +++ b/Binary/Program.cs @@ -76,14 +76,35 @@ 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 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; + 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(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) @@ -112,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/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/Prompt/Input.cs b/Binary/Prompt/Input.cs index 15da0b1..de0d06c 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, error, null) { } + + 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/Tools/Raider.cs b/Binary/Tools/Raider.cs index 516be9b..40da797 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.BinFileInput.Text.StartsWith("0x") + ? this.BinFileInput.Text + : $"0x{this.BinFileInput.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.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 097d2a7..85b04da 100644 --- a/Binary/UI/CarPartsEditor.cs +++ b/Binary/UI/CarPartsEditor.cs @@ -30,12 +30,7 @@ public CarPartsEditor(DBModelPart model) this.LoadTreeView(); this.ToggleMenuStripControls(null); - if (this.Model.GameINT != GameINT.MostWanted && this.Model.GameINT != GameINT.Underground2) - { - - this.FindAndReplaceToolStripMenuItem.Enabled = false; - - } + this.FindAndReplaceToolStripMenuItem.Enabled = true; } #region Theme @@ -105,6 +100,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; @@ -234,6 +231,7 @@ private void ToggleMenuStripControls(TreeNode node) this.MoveDownAttributesToolStripMenuItem.Enabled = false; this.ReverseAttributesToolStripMenuItem.Enabled = false; this.SortAttributesByKeyToolStripMenuItem.Enabled = false; + this.AddCustomAttributeToolStripMenuItem.Enabled = false; } else @@ -254,6 +252,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; } } @@ -483,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(_)), @@ -491,30 +498,38 @@ 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(); + this.CarPartsPropertyGrid.Refresh(); + + } } @@ -551,7 +566,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) @@ -627,6 +644,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 }; 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) { 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/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..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); @@ -270,7 +272,13 @@ 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); + 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))