From 4e23d23dfbc2fb5bc41ab7a696fe9ec3f1ba6613 Mon Sep 17 00:00:00 2001 From: Asval Date: Fri, 21 Jun 2019 03:17:35 +0200 Subject: [PATCH] custom challenges watermark + drawstring reward id + fixed language pack loading when it wasn't needed --- FModel/App.config | 6 ++ FModel/Forms/Settings.Designer.cs | 56 ++++++++++++- FModel/Forms/Settings.cs | 18 +++- FModel/MainWindow.cs | 84 ++++++++++--------- .../ChallengeGenerator/BundleDesign.cs | 18 +++- .../ChallengeGenerator/DrawingRewards.cs | 12 ++- FModel/Properties/Settings.Designer.cs | 24 ++++++ FModel/Properties/Settings.settings | 6 ++ README.md | 1 + 9 files changed, 177 insertions(+), 48 deletions(-) diff --git a/FModel/App.config b/FModel/App.config index a2f8ed90..805bdf3e 100644 --- a/FModel/App.config +++ b/FModel/App.config @@ -133,6 +133,12 @@ English + + False + + + + diff --git a/FModel/Forms/Settings.Designer.cs b/FModel/Forms/Settings.Designer.cs index b936e6eb..c4a419f5 100644 --- a/FModel/Forms/Settings.Designer.cs +++ b/FModel/Forms/Settings.Designer.cs @@ -61,6 +61,10 @@ namespace FModel.Forms this.label6 = new System.Windows.Forms.Label(); this.textBox4 = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); + this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.checkBox2 = new System.Windows.Forms.CheckBox(); + this.textBox6 = new System.Windows.Forms.TextBox(); + this.label12 = new System.Windows.Forms.Label(); this.groupBox3.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox4.SuspendLayout(); @@ -70,6 +74,7 @@ namespace FModel.Forms this.groupBox1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.imgsPerRow)).BeginInit(); this.groupBox5.SuspendLayout(); + this.groupBox6.SuspendLayout(); this.SuspendLayout(); // // groupBox3 @@ -132,7 +137,7 @@ namespace FModel.Forms // this.OKButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.OKButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.OKButton.Location = new System.Drawing.Point(475, 476); + this.OKButton.Location = new System.Drawing.Point(475, 527); this.OKButton.Name = "OKButton"; this.OKButton.Size = new System.Drawing.Size(97, 21); this.OKButton.TabIndex = 15; @@ -295,7 +300,7 @@ namespace FModel.Forms this.groupBox1.Controls.Add(this.label5); this.groupBox1.Controls.Add(this.textBox3); this.groupBox1.Controls.Add(this.label4); - this.groupBox1.Location = new System.Drawing.Point(12, 420); + this.groupBox1.Location = new System.Drawing.Point(12, 473); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(560, 46); this.groupBox1.TabIndex = 17; @@ -414,11 +419,50 @@ namespace FModel.Forms this.label2.TabIndex = 3; this.label2.Text = "EPIC Email:"; // + // groupBox6 + // + this.groupBox6.Controls.Add(this.checkBox2); + this.groupBox6.Controls.Add(this.textBox6); + this.groupBox6.Controls.Add(this.label12); + this.groupBox6.Location = new System.Drawing.Point(12, 421); + this.groupBox6.Name = "groupBox6"; + this.groupBox6.Size = new System.Drawing.Size(560, 46); + this.groupBox6.TabIndex = 19; + this.groupBox6.TabStop = false; + this.groupBox6.Text = "Challenges"; + // + // checkBox2 + // + this.checkBox2.AutoSize = true; + this.checkBox2.Location = new System.Drawing.Point(448, 21); + this.checkBox2.Name = "checkBox2"; + this.checkBox2.Size = new System.Drawing.Size(105, 17); + this.checkBox2.TabIndex = 27; + this.checkBox2.Text = "Draw Reward ID"; + this.checkBox2.UseVisualStyleBackColor = true; + // + // textBox6 + // + this.textBox6.Location = new System.Drawing.Point(74, 19); + this.textBox6.Name = "textBox6"; + this.textBox6.Size = new System.Drawing.Size(359, 20); + this.textBox6.TabIndex = 8; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(6, 22); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(62, 13); + this.label12.TabIndex = 9; + this.label12.Text = "Watermark:"; + // // Settings // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(584, 509); + this.ClientSize = new System.Drawing.Size(584, 560); + this.Controls.Add(this.groupBox6); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox4); @@ -446,6 +490,8 @@ namespace FModel.Forms ((System.ComponentModel.ISupportInitialize)(this.imgsPerRow)).EndInit(); this.groupBox5.ResumeLayout(false); this.groupBox5.PerformLayout(); + this.groupBox6.ResumeLayout(false); + this.groupBox6.PerformLayout(); this.ResumeLayout(false); } @@ -484,5 +530,9 @@ namespace FModel.Forms private System.Windows.Forms.CheckBox checkBox1; private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.Label label10; + private System.Windows.Forms.GroupBox groupBox6; + private System.Windows.Forms.CheckBox checkBox2; + private System.Windows.Forms.TextBox textBox6; + private System.Windows.Forms.Label label12; } } diff --git a/FModel/Forms/Settings.cs b/FModel/Forms/Settings.cs index 738889ea..a6caf718 100644 --- a/FModel/Forms/Settings.cs +++ b/FModel/Forms/Settings.cs @@ -10,6 +10,7 @@ namespace FModel.Forms { private static string _paKsPathBefore; private static string _outputPathBefore; + private static string _oldLanguage; public Settings() { @@ -21,6 +22,14 @@ namespace FModel.Forms textBox4.Text = Properties.Settings.Default.eEmail; textBox5.Text = Properties.Settings.Default.ePassword; + textBox6.Text = Properties.Settings.Default.challengesWatermark; + checkBox2.Checked = Properties.Settings.Default.challengesDebug; + if (string.IsNullOrWhiteSpace(textBox6.Text)) + { + textBox6.Text = "{Bundle_Name} Generated using FModel & JohnWickParse - {Date}"; + } + else { textBox6.Text = Properties.Settings.Default.challengesWatermark; } + //MERGER textBox3.Text = Properties.Settings.Default.mergerFileName; imgsPerRow.Value = Properties.Settings.Default.mergerImagesRow; @@ -68,6 +77,7 @@ namespace FModel.Forms } } + _oldLanguage = Properties.Settings.Default.IconLanguage; comboBox1.SelectedIndex = comboBox1.FindStringExact(Properties.Settings.Default.IconLanguage); _paKsPathBefore = Properties.Settings.Default.PAKsPath; @@ -97,6 +107,9 @@ namespace FModel.Forms Properties.Settings.Default.eEmail = textBox4.Text; Properties.Settings.Default.ePassword = textBox5.Text; + Properties.Settings.Default.challengesDebug = checkBox2.Checked; + Properties.Settings.Default.challengesWatermark = textBox6.Text; + //MERGER Properties.Settings.Default.mergerFileName = textBox3.Text; Properties.Settings.Default.mergerImagesRow = Decimal.ToInt32(imgsPerRow.Value); @@ -117,7 +130,10 @@ namespace FModel.Forms //LOCRES Properties.Settings.Default.IconLanguage = comboBox1.SelectedItem.ToString(); - LoadLocRes.LoadMySelectedLocRes(Properties.Settings.Default.IconLanguage); + if (comboBox1.SelectedItem.ToString() != _oldLanguage) + { + LoadLocRes.LoadMySelectedLocRes(Properties.Settings.Default.IconLanguage); + } Properties.Settings.Default.Save(); //SAVE Close(); diff --git a/FModel/MainWindow.cs b/FModel/MainWindow.cs index efaa2080..8c3bdb76 100644 --- a/FModel/MainWindow.cs +++ b/FModel/MainWindow.cs @@ -1279,48 +1279,50 @@ namespace FModel { UpdateConsole(ThePak.CurrentUsedItem + " is an Item Definition", Color.FromArgb(255, 66, 244, 66), "Success"); - Bitmap bmp = new Bitmap(522, 522); - Graphics g = Graphics.FromImage(bmp); - g.TextRenderingHint = TextRenderingHint.AntiAlias; - - Rarity.DrawRarity(theItem, g, specialMode); - - ItemIcon.ItemIconPath = string.Empty; - ItemIcon.GetItemIcon(theItem, Settings.Default.loadFeaturedImage); - if (File.Exists(ItemIcon.ItemIconPath)) + using (Bitmap bmp = new Bitmap(522, 522)) { - Image itemIcon; - using (var bmpTemp = new Bitmap(ItemIcon.ItemIconPath)) + Graphics g = Graphics.FromImage(bmp); + g.TextRenderingHint = TextRenderingHint.AntiAlias; + + Rarity.DrawRarity(theItem, g, specialMode); + + ItemIcon.ItemIconPath = string.Empty; + ItemIcon.GetItemIcon(theItem, Settings.Default.loadFeaturedImage); + if (File.Exists(ItemIcon.ItemIconPath)) { - itemIcon = new Bitmap(bmpTemp); + Image itemIcon; + using (var bmpTemp = new Bitmap(ItemIcon.ItemIconPath)) + { + itemIcon = new Bitmap(bmpTemp); + } + g.DrawImage(ImageUtilities.ResizeImage(itemIcon, 512, 512), new Point(5, 5)); } - g.DrawImage(ImageUtilities.ResizeImage(itemIcon, 512, 512), new Point(5, 5)); - } - else - { - Image itemIcon = Resources.unknown512; - g.DrawImage(itemIcon, new Point(0, 0)); - } - - ItemIcon.DrawWatermark(g); - - Image bg512 = Resources.BG512; - g.DrawImage(bg512, new Point(5, 383)); - - DrawText.DrawTexts(theItem, g, specialMode); - - if (autoSaveImagesToolStripMenuItem.Checked || updateModeToolStripMenuItem.Checked) - { - bmp.Save(App.DefaultOutputPath + "\\Icons\\" + ThePak.CurrentUsedItem + ".png", ImageFormat.Png); - - if (File.Exists(App.DefaultOutputPath + "\\Icons\\" + ThePak.CurrentUsedItem + ".png")) + else { - AppendText(ThePak.CurrentUsedItem, Color.DarkRed); - AppendText(" successfully saved", Color.Black, true); + Image itemIcon = Resources.unknown512; + g.DrawImage(itemIcon, new Point(0, 0)); } - } - return bmp; + ItemIcon.DrawWatermark(g); + + Image bg512 = Resources.BG512; + g.DrawImage(bg512, new Point(5, 383)); + + DrawText.DrawTexts(theItem, g, specialMode); + + if (autoSaveImagesToolStripMenuItem.Checked || updateModeToolStripMenuItem.Checked) + { + bmp.Save(App.DefaultOutputPath + "\\Icons\\" + ThePak.CurrentUsedItem + ".png", ImageFormat.Png); + + if (File.Exists(App.DefaultOutputPath + "\\Icons\\" + ThePak.CurrentUsedItem + ".png")) + { + AppendText(ThePak.CurrentUsedItem, Color.DarkRed); + AppendText(" successfully saved", Color.Black, true); + } + } + + return bmp; + } } @@ -1375,7 +1377,7 @@ namespace FModel //in case you wanna make some changes //BundleDesign.toDrawOn.DrawRectangle(new Pen(new SolidBrush(Color.Red)), new Rectangle(107, BundleDesign.theY + 7, 2000, 93)); //rectangle that resize the font -> used for "Font goodFont = " - //BundleDesign.toDrawOn.DrawRectangle(new Pen(new SolidBrush(Color.Green)), new Rectangle(107, BundleDesign.theY + 7, 2000, 75)); //rectangle the font needs to be fit with + //BundleDesign.toDrawOn.DrawRectangle(new Pen(new SolidBrush(Color.Blue)), new Rectangle(107, BundleDesign.theY + 7, 2000, 75)); //rectangle the font needs to be fit with //draw quest description Font goodFont = FontUtilities.FindFont(BundleDesign.toDrawOn, BundleInfos.BundleData[i].questDescr, new Rectangle(107, BundleDesign.theY + 7, 2000, 93).Size, new Font(FontUtilities.pfc.Families[1], 50)); //size in "new Font()" is never check @@ -1428,6 +1430,7 @@ namespace FModel AppendText(" successfully saved", Color.Black, true); } } + bmp.Dispose(); } /// @@ -1500,10 +1503,13 @@ namespace FModel else UpdateConsole("Couldn't convert " + ThePak.CurrentUsedItem, Color.FromArgb(255, 244, 66, 66), "Error"); } + + /// + /// todo: overwrite existing extracted font + /// + /// private void ConvertToTtf(string file) { - if (File.Exists(file)) { File.Delete(file); } - File.Move(file, Path.ChangeExtension(file, ".ttf") ?? throw new InvalidOperationException()); UpdateConsole(ThePak.CurrentUsedItem + " successfully converter to a font", Color.FromArgb(255, 66, 244, 66), "Success"); } diff --git a/FModel/Methods/ChallengeGenerator/BundleDesign.cs b/FModel/Methods/ChallengeGenerator/BundleDesign.cs index bde86947..c69fef45 100644 --- a/FModel/Methods/ChallengeGenerator/BundleDesign.cs +++ b/FModel/Methods/ChallengeGenerator/BundleDesign.cs @@ -207,9 +207,23 @@ namespace FModel /// public static void drawWatermark(Bitmap myBitmap) { - string text = SearchResource.getTextByKey(myItem.DisplayName.Key, myItem.DisplayName.SourceString); + string text = Settings.Default.challengesWatermark; + if (string.IsNullOrWhiteSpace(text)) + { + text = "{Bundle_Name} Generated using FModel & JohnWickParse - {Date}"; + } + + if (text.Contains("{Bundle_Name}")) + { + text = text.Replace("{Bundle_Name}", SearchResource.getTextByKey(myItem.DisplayName.Key, myItem.DisplayName.SourceString)); + } + if (text.Contains("{Date}")) + { + text = text.Replace("{Date}", DateTime.Now.ToString("dd/MM/yyyy")); + } + toDrawOn.FillRectangle(new SolidBrush(Color.FromArgb(100, 0, 0, 0)), new Rectangle(0, theY + 240, myBitmap.Width, 40)); - toDrawOn.DrawString(text + " Generated using FModel & JohnWickParse - " + DateTime.Now.ToString("dd/MM/yyyy"), new Font(FontUtilities.pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(myBitmap.Width / 2, theY + 250), FontUtilities.centeredString); + toDrawOn.DrawString(text, new Font(FontUtilities.pfc.Families[0], 20), new SolidBrush(Color.FromArgb(150, 255, 255, 255)), new Point(myBitmap.Width / 2, theY + 250), FontUtilities.centeredString); } private static void drawForbyteReward() diff --git a/FModel/Methods/ChallengeGenerator/DrawingRewards.cs b/FModel/Methods/ChallengeGenerator/DrawingRewards.cs index 0b9fd2f3..34db58cf 100644 --- a/FModel/Methods/ChallengeGenerator/DrawingRewards.cs +++ b/FModel/Methods/ChallengeGenerator/DrawingRewards.cs @@ -71,7 +71,7 @@ namespace FModel { ItemIcon.SearchAthIteDefIcon(itemId[i]); - drawIcon(); + drawIcon(item); } } } @@ -127,7 +127,7 @@ namespace FModel ItemIcon.ItemIconPath = JohnWick.AssetToTexture2D(textureFile); } - drawIcon(); + drawIcon(bannerName); } } } @@ -139,10 +139,16 @@ namespace FModel } } - private static void drawIcon() + private static void drawIcon(string itemId) { if (File.Exists(ItemIcon.ItemIconPath)) { + if (Settings.Default.challengesDebug) + { + //draw quest reward id + BundleDesign.toDrawOn.DrawString(itemId, new Font("Courier New", 12), new SolidBrush(Color.White), new RectangleF(2110, BundleDesign.theY + 30, 190, 60), FontUtilities.centeredStringLine); + } + Image itemIcon; using (var bmpTemp = new Bitmap(ItemIcon.ItemIconPath)) { diff --git a/FModel/Properties/Settings.Designer.cs b/FModel/Properties/Settings.Designer.cs index 5c154202..fd7e56d1 100644 --- a/FModel/Properties/Settings.Designer.cs +++ b/FModel/Properties/Settings.Designer.cs @@ -514,5 +514,29 @@ namespace FModel.Properties { this["IconLanguage"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool challengesDebug { + get { + return ((bool)(this["challengesDebug"])); + } + set { + this["challengesDebug"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string challengesWatermark { + get { + return ((string)(this["challengesWatermark"])); + } + set { + this["challengesWatermark"] = value; + } + } } } diff --git a/FModel/Properties/Settings.settings b/FModel/Properties/Settings.settings index 193755ad..78071891 100644 --- a/FModel/Properties/Settings.settings +++ b/FModel/Properties/Settings.settings @@ -125,5 +125,11 @@ English + + False + + + + \ No newline at end of file diff --git a/README.md b/README.md index de64b781..051f8069 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ This project is mainly based on what [UModel](https://github.com/gildor2/UModel) I'd highly suggest you to use [UModel](https://github.com/gildor2/UModel) instead if you wanna use something made professionnaly. ## TODO + - [ ] Take a look at memory usage - [ ] Code refactoring - [ ] 2FA support - [ ] Export Queue