diff --git a/FModel/PAKWindow.Designer.cs b/FModel/PAKWindow.Designer.cs index 25d47b0a..b61c474c 100644 --- a/FModel/PAKWindow.Designer.cs +++ b/FModel/PAKWindow.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PAKWindow)); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.PAKsLoad = new System.Windows.Forms.Button(); @@ -38,17 +39,22 @@ this.PAKTreeView = new System.Windows.Forms.TreeView(); this.ItemIconPictureBox = new System.Windows.Forms.PictureBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.SaveImageCheckBox = new System.Windows.Forms.CheckBox(); - this.SaveImageButton = new System.Windows.Forms.Button(); - this.LoadDataCheckBox = new System.Windows.Forms.CheckBox(); + this.SaveImageButton = new FModel.SplitButton(); + this.ImageContext = new System.Windows.Forms.ContextMenuStrip(this.components); + this.OpenImageTS = new System.Windows.Forms.ToolStripMenuItem(); + this.ExtractAssetButton = new FModel.SplitButton(); + this.ExtractAsset = new System.Windows.Forms.ContextMenuStrip(this.components); + this.LoadDataTS = new System.Windows.Forms.ToolStripMenuItem(); + this.SaveImageTS = new System.Windows.Forms.ToolStripMenuItem(); this.ConsoleRichTextBox = new System.Windows.Forms.RichTextBox(); - this.ExtractButton = new System.Windows.Forms.Button(); this.ItemRichTextBox = new System.Windows.Forms.RichTextBox(); this.FilterLabel = new System.Windows.Forms.Label(); this.FilterTextBox = new System.Windows.Forms.TextBox(); this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.ItemIconPictureBox)).BeginInit(); this.groupBox2.SuspendLayout(); + this.ImageContext.SuspendLayout(); + this.ExtractAsset.SuspendLayout(); this.SuspendLayout(); // // groupBox1 @@ -130,11 +136,9 @@ // // groupBox2 // - this.groupBox2.Controls.Add(this.SaveImageCheckBox); this.groupBox2.Controls.Add(this.SaveImageButton); - this.groupBox2.Controls.Add(this.LoadDataCheckBox); + this.groupBox2.Controls.Add(this.ExtractAssetButton); this.groupBox2.Controls.Add(this.ConsoleRichTextBox); - this.groupBox2.Controls.Add(this.ExtractButton); this.groupBox2.Controls.Add(this.ItemRichTextBox); this.groupBox2.Controls.Add(this.ItemIconPictureBox); this.groupBox2.Location = new System.Drawing.Point(426, 12); @@ -143,37 +147,71 @@ this.groupBox2.TabIndex = 4; this.groupBox2.TabStop = false; // - // SaveImageCheckBox - // - this.SaveImageCheckBox.AutoSize = true; - this.SaveImageCheckBox.Location = new System.Drawing.Point(703, 639); - this.SaveImageCheckBox.Name = "SaveImageCheckBox"; - this.SaveImageCheckBox.Size = new System.Drawing.Size(108, 17); - this.SaveImageCheckBox.TabIndex = 9; - this.SaveImageCheckBox.Text = "Auto Save Image"; - this.SaveImageCheckBox.UseVisualStyleBackColor = true; - this.SaveImageCheckBox.CheckedChanged += new System.EventHandler(this.SaveImageCheckBox_CheckedChanged); - // // SaveImageButton // - this.SaveImageButton.Location = new System.Drawing.Point(816, 635); + this.SaveImageButton.Location = new System.Drawing.Point(810, 635); + this.SaveImageButton.Menu = this.ImageContext; this.SaveImageButton.Name = "SaveImageButton"; - this.SaveImageButton.Size = new System.Drawing.Size(106, 23); - this.SaveImageButton.TabIndex = 8; - this.SaveImageButton.Text = "Save Image"; + this.SaveImageButton.Size = new System.Drawing.Size(112, 23); + this.SaveImageButton.TabIndex = 11; + this.SaveImageButton.Text = " Save Image"; + this.SaveImageButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.SaveImageButton.UseVisualStyleBackColor = true; this.SaveImageButton.Click += new System.EventHandler(this.SaveImageButton_Click); // - // LoadDataCheckBox + // ImageContext // - this.LoadDataCheckBox.AutoSize = true; - this.LoadDataCheckBox.Location = new System.Drawing.Point(703, 668); - this.LoadDataCheckBox.Name = "LoadDataCheckBox"; - this.LoadDataCheckBox.Size = new System.Drawing.Size(101, 17); - this.LoadDataCheckBox.TabIndex = 7; - this.LoadDataCheckBox.Text = "Auto Load Data"; - this.LoadDataCheckBox.UseVisualStyleBackColor = true; - this.LoadDataCheckBox.CheckedChanged += new System.EventHandler(this.LoadImageCheckBox_CheckedChanged); + this.ImageContext.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.OpenImageTS}); + this.ImageContext.Name = "ImageContext"; + this.ImageContext.Size = new System.Drawing.Size(140, 26); + // + // OpenImageTS + // + this.OpenImageTS.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.OpenImageTS.Name = "OpenImageTS"; + this.OpenImageTS.Size = new System.Drawing.Size(139, 22); + this.OpenImageTS.Text = "Open Image"; + this.OpenImageTS.Click += new System.EventHandler(this.OpenImageTS_Click); + // + // ExtractAssetButton + // + this.ExtractAssetButton.Location = new System.Drawing.Point(810, 664); + this.ExtractAssetButton.Menu = this.ExtractAsset; + this.ExtractAssetButton.Name = "ExtractAssetButton"; + this.ExtractAssetButton.Size = new System.Drawing.Size(112, 23); + this.ExtractAssetButton.TabIndex = 10; + this.ExtractAssetButton.Text = " Extract Asset"; + this.ExtractAssetButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.ExtractAssetButton.UseVisualStyleBackColor = true; + this.ExtractAssetButton.Click += new System.EventHandler(this.ExtractAssetButton_Click); + // + // ExtractAsset + // + this.ExtractAsset.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.LoadDataTS, + this.SaveImageTS}); + this.ExtractAsset.Name = "ExtractAsset"; + this.ExtractAsset.Size = new System.Drawing.Size(223, 48); + // + // LoadDataTS + // + this.LoadDataTS.Checked = true; + this.LoadDataTS.CheckOnClick = true; + this.LoadDataTS.CheckState = System.Windows.Forms.CheckState.Checked; + this.LoadDataTS.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.LoadDataTS.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.LoadDataTS.Name = "LoadDataTS"; + this.LoadDataTS.Size = new System.Drawing.Size(222, 22); + this.LoadDataTS.Text = "Load Data After Serialization"; + // + // SaveImageTS + // + this.SaveImageTS.CheckOnClick = true; + this.SaveImageTS.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.SaveImageTS.Name = "SaveImageTS"; + this.SaveImageTS.Size = new System.Drawing.Size(222, 22); + this.SaveImageTS.Text = "Save Generated Image"; // // ConsoleRichTextBox // @@ -185,16 +223,6 @@ this.ConsoleRichTextBox.TabIndex = 6; this.ConsoleRichTextBox.Text = ""; // - // ExtractButton - // - this.ExtractButton.Location = new System.Drawing.Point(816, 664); - this.ExtractButton.Name = "ExtractButton"; - this.ExtractButton.Size = new System.Drawing.Size(106, 23); - this.ExtractButton.TabIndex = 5; - this.ExtractButton.Text = "Extract"; - this.ExtractButton.UseVisualStyleBackColor = true; - this.ExtractButton.Click += new System.EventHandler(this.ExtractButton_Click); - // // ItemRichTextBox // this.ItemRichTextBox.BackColor = System.Drawing.SystemColors.Window; @@ -246,7 +274,8 @@ this.groupBox1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.ItemIconPictureBox)).EndInit(); this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); + this.ImageContext.ResumeLayout(false); + this.ExtractAsset.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -263,14 +292,17 @@ private System.Windows.Forms.TreeView PAKTreeView; private System.Windows.Forms.PictureBox ItemIconPictureBox; private System.Windows.Forms.GroupBox groupBox2; - private System.Windows.Forms.Button ExtractButton; private System.Windows.Forms.RichTextBox ItemRichTextBox; private System.Windows.Forms.RichTextBox ConsoleRichTextBox; - private System.Windows.Forms.CheckBox LoadDataCheckBox; - private System.Windows.Forms.CheckBox SaveImageCheckBox; - private System.Windows.Forms.Button SaveImageButton; private System.Windows.Forms.Label FilterLabel; private System.Windows.Forms.TextBox FilterTextBox; + private SplitButton ExtractAssetButton; + private System.Windows.Forms.ContextMenuStrip ExtractAsset; + private System.Windows.Forms.ToolStripMenuItem LoadDataTS; + private System.Windows.Forms.ContextMenuStrip ImageContext; + private System.Windows.Forms.ToolStripMenuItem OpenImageTS; + private SplitButton SaveImageButton; + private System.Windows.Forms.ToolStripMenuItem SaveImageTS; } } diff --git a/FModel/PAKWindow.cs b/FModel/PAKWindow.cs index c5a1478d..7296607d 100644 --- a/FModel/PAKWindow.cs +++ b/FModel/PAKWindow.cs @@ -1,9 +1,11 @@ using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; +using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; +using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Drawing.Text; using System.IO; @@ -134,9 +136,8 @@ namespace FModel AppendText("updated successfully", Color.Black, true); } - ExtractButton.Enabled = false; + ExtractAssetButton.Enabled = false; SaveImageButton.Enabled = false; - SaveImageCheckBox.Enabled = false; fontLength = Properties.Resources.BurbankBigCondensed_Bold.Length; fontdata = Properties.Resources.BurbankBigCondensed_Bold; @@ -295,13 +296,13 @@ namespace FModel ItemsListBox.Items.Add(afterItems[i]); } - ExtractButton.Enabled = ItemsListBox.SelectedIndex >= 0; + ExtractAssetButton.Enabled = ItemsListBox.SelectedIndex >= 0; } private void ItemsListBox_SelectedIndexChanged(object sender, EventArgs e) { if (ItemsListBox.SelectedItem != null && SelectedArray == null) { - ExtractButton.Enabled = true; + ExtractAssetButton.Enabled = true; } } //NO EXTRACT BUTTON IF NOTHING SELECTED @@ -569,7 +570,25 @@ namespace FModel } } - private async void ExtractButton_Click(object sender, EventArgs e) + private void SaveImageButton_Click(object sender, EventArgs e) + { + SaveFileDialog saveTheDialog = new SaveFileDialog(); + saveTheDialog.Title = "Save Icon"; + saveTheDialog.Filter = "PNG Files (*.png)|*.png"; + saveTheDialog.InitialDirectory = docPath + "\\Generated Icons\\"; + saveTheDialog.FileName = ItemName; + if (saveTheDialog.ShowDialog() == DialogResult.OK) + { + ItemIconPictureBox.Image.Save(saveTheDialog.FileName, ImageFormat.Png); + AppendText("✔ ", Color.Green); + AppendText(ItemName, Color.DarkRed); + AppendText(" successfully saved to ", Color.Black); + AppendText(saveTheDialog.FileName, Color.SteelBlue, true); + } + } + + public static string currentItem; + private async void ExtractAssetButton_Click(object sender, EventArgs e) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); @@ -590,11 +609,11 @@ namespace FModel SelectedArray[i] = ItemsListBox.SelectedItems[i].ToString(); } - ExtractButton.Enabled = false; + ExtractAssetButton.Enabled = false; SaveImageButton.Enabled = false; for (int i = 0; i < SelectedArray.Length; i++) { - string currentItem = SelectedArray[i].ToString(); + currentItem = SelectedArray[i].ToString(); var files = Directory.GetFiles(docPath + "\\Extracted", currentItem + ".*", SearchOption.AllDirectories).Where(x => !x.EndsWith(".png")).FirstOrDefault(); if (!File.Exists(files)) @@ -634,7 +653,7 @@ namespace FModel var IDParser = ItemsIdParser.FromJson(json); - if (LoadDataCheckBox.Checked == true) + if (((ToolStripMenuItem)ExtractAsset.Items[0]).Checked == true) { AppendText("Auto loading data set to ", Color.Black); AppendText("True", Color.Green, true); @@ -654,6 +673,7 @@ namespace FModel ItemName = IDParser[iii].DisplayName; Bitmap bmp = new Bitmap(522, 522); Graphics g = Graphics.FromImage(bmp); + g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; getItemRarity(IDParser[iii], g); @@ -1093,7 +1113,7 @@ namespace FModel } //COSMETIC SOURCE ItemIconPictureBox.Image = bmp; - if (SaveImageCheckBox.Checked == true) + if (((ToolStripMenuItem)ExtractAsset.Items[1]).Checked == true) { AppendText("Auto saving icon set to ", Color.Black); AppendText("True", Color.Green, true); @@ -1171,7 +1191,7 @@ namespace FModel ItemIconPictureBox.Image = Properties.Resources.unknown512; } - if (SaveImageCheckBox.Checked == true) + if (((ToolStripMenuItem)ExtractAsset.Items[1]).Checked == true) { AppendText("Auto saving icon set to ", Color.Black); AppendText("True", Color.Green, true); @@ -1265,7 +1285,7 @@ namespace FModel AppendText(currentItem, Color.SteelBlue, true); } } - ExtractButton.Enabled = true; + ExtractAssetButton.Enabled = true; SaveImageButton.Enabled = true; SelectedArray = null; @@ -1275,45 +1295,79 @@ namespace FModel AppendText("\nDone\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tTime elapsed: " + elapsedTime, Color.Green, true); } - private void LoadImageCheckBox_CheckedChanged(object sender, EventArgs e) + private void OpenImageTS_Click(object sender, EventArgs e) { - if (LoadDataCheckBox.Checked == true) - { - SaveImageButton.Enabled = true; - SaveImageCheckBox.Enabled = true; - } - if (LoadDataCheckBox.Checked == false) - { - SaveImageButton.Enabled = false; - SaveImageCheckBox.Enabled = false; - } + var newForm = new Form(); + + PictureBox pb = new PictureBox(); + pb.Dock = DockStyle.Fill; + pb.Image = ItemIconPictureBox.Image; + pb.SizeMode = PictureBoxSizeMode.Zoom; + + newForm.Size = ItemIconPictureBox.Image.Size; + newForm.Icon = FModel.Properties.Resources.FNTools_Logo; + newForm.Text = currentItem; + newForm.StartPosition = FormStartPosition.CenterScreen; + newForm.Controls.Add(pb); + newForm.Show(); } - private void SaveImageCheckBox_CheckedChanged(object sender, EventArgs e) + } + + public class SplitButton : Button + { + [DefaultValue(null), Browsable(true), + DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] + public ContextMenuStrip Menu { get; set; } + + [DefaultValue(20), Browsable(true), + DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] + public int SplitWidth { get; set; } + + public SplitButton() { - if (SaveImageCheckBox.Checked == true) + SplitWidth = 20; + } + + protected override void OnMouseDown(MouseEventArgs mevent) + { + var splitRect = new Rectangle(this.Width - this.SplitWidth, 0, this.SplitWidth, this.Height); + + // Figure out if the button click was on the button itself or the menu split + if (Menu != null && + mevent.Button == MouseButtons.Left && + splitRect.Contains(mevent.Location)) { - SaveImageButton.Enabled = false; + Menu.Show(this, 0, this.Height); // Shows menu under button + //Menu.Show(this, mevent.Location); // Shows menu at click location } - if (SaveImageCheckBox.Checked == false) + else { - SaveImageButton.Enabled = true; + base.OnMouseDown(mevent); } } - private void SaveImageButton_Click(object sender, EventArgs e) + protected override void OnPaint(PaintEventArgs pevent) { - SaveFileDialog saveTheDialog = new SaveFileDialog(); - saveTheDialog.Title = "Save Icon"; - saveTheDialog.Filter = "PNG Files (*.png)|*.png"; - saveTheDialog.InitialDirectory = docPath + "\\Generated Icons\\"; - saveTheDialog.FileName = ItemName; - if (saveTheDialog.ShowDialog() == DialogResult.OK) + base.OnPaint(pevent); + + if (this.Menu != null && this.SplitWidth > 0) { - ItemIconPictureBox.Image.Save(saveTheDialog.FileName, ImageFormat.Png); - AppendText("✔ ", Color.Green); - AppendText(ItemName, Color.DarkRed); - AppendText(" successfully saved to ", Color.Black); - AppendText(saveTheDialog.FileName, Color.SteelBlue, true); + // Draw the arrow glyph on the right side of the button + int arrowX = ClientRectangle.Width - 14; + int arrowY = ClientRectangle.Height / 2 - 1; + + var arrowBrush = Enabled ? SystemBrushes.ControlText : SystemBrushes.ButtonShadow; + var arrows = new[] { new Point(arrowX, arrowY), new Point(arrowX + 7, arrowY), new Point(arrowX + 3, arrowY + 4) }; + pevent.Graphics.FillPolygon(arrowBrush, arrows); + + // Draw a dashed separator on the left of the arrow + int lineX = ClientRectangle.Width - this.SplitWidth; + int lineYFrom = arrowY - 4; + int lineYTo = arrowY + 8; + using (var separatorPen = new Pen(Brushes.DarkGray) { DashStyle = DashStyle.Dot }) + { + pevent.Graphics.DrawLine(separatorPen, lineX, lineYFrom, lineX, lineYTo); + } } } } diff --git a/FModel/PAKWindow.resx b/FModel/PAKWindow.resx index ac20f58a..ebea627a 100644 --- a/FModel/PAKWindow.resx +++ b/FModel/PAKWindow.resx @@ -120,6 +120,12 @@ True + + 134, 17 + + + 17, 17 + diff --git a/FModel/Properties/Resources.Designer.cs b/FModel/Properties/Resources.Designer.cs index cf32b541..c3ce3514 100644 --- a/FModel/Properties/Resources.Designer.cs +++ b/FModel/Properties/Resources.Designer.cs @@ -100,6 +100,16 @@ namespace FModel.Properties { } } + /// + /// Recherche une ressource localisée de type System.Drawing.Icon semblable à (Icône). + /// + internal static System.Drawing.Icon FNTools_Logo { + get { + object obj = ResourceManager.GetObject("FNTools_Logo", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// Recherche une ressource localisée de type System.Drawing.Bitmap. /// diff --git a/FModel/Properties/Resources.resx b/FModel/Properties/Resources.resx index f5420f0c..c78ac8ae 100644 --- a/FModel/Properties/Resources.resx +++ b/FModel/Properties/Resources.resx @@ -130,6 +130,9 @@ ..\Resources\E512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\FNTools_Logo.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\I512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/README.md b/README.md index 8de3d605..023fb1c6 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ **4.** Navigate through the tree to find the Asset you want -**5.** Clicking on **Extract** will extract the selected Asset to your `Documents` folder, try to serialize it and will display infos about it +**5.** Clicking on **Extract Asset** will extract the selected Asset to your `Documents` folder, try to serialize it and will display infos about it - Asset is an **_ID_**: - Try to create an [Icon](https://i.imgur.com/CkiU3p5.png) with **Name**, **Description**, **Rarity**, **Type** and the **Cosmetic Source** - Asset is a **_Texture_**: