From 4274a2ba093fc6f6c64efcc4488c96ca8c4ca1d1 Mon Sep 17 00:00:00 2001 From: MaikyM <51415805+MaikyM@users.noreply.github.com> Date: Fri, 21 Jun 2019 21:29:09 -0600 Subject: [PATCH] simplify some functions --- FModel/Forms/Settings.cs | 3 +- .../ChallengeGenerator/BundleDesign.cs | 47 ++++++++----------- .../ChallengeGenerator/DrawingRewards.cs | 8 ++-- FModel/Methods/IconGenerator/DrawText.cs | 38 +++++++-------- 4 files changed, 45 insertions(+), 51 deletions(-) diff --git a/FModel/Forms/Settings.cs b/FModel/Forms/Settings.cs index a6caf718..57f3c7db 100644 --- a/FModel/Forms/Settings.cs +++ b/FModel/Forms/Settings.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Drawing; using System.IO; using System.Windows.Forms; @@ -167,6 +167,7 @@ namespace FModel.Forms wPictureBox.Image = bmp; } } + if (checkBox8.Checked) { if (!string.IsNullOrEmpty(Properties.Settings.Default.wFilename)) diff --git a/FModel/Methods/ChallengeGenerator/BundleDesign.cs b/FModel/Methods/ChallengeGenerator/BundleDesign.cs index f94833b1..ca747c93 100644 --- a/FModel/Methods/ChallengeGenerator/BundleDesign.cs +++ b/FModel/Methods/ChallengeGenerator/BundleDesign.cs @@ -154,78 +154,69 @@ namespace FModel } private static void drawCompletionText(string count) { - string all = string.Empty; - string any = string.Empty; + string all = "Complete ALL CHALLENGES to earn the reward item"; + string any = "Complete ANY " + count + " CHALLENGES to earn the reward item"; + switch (Settings.Default.IconLanguage) { - case "English": - all = "Complete ALL CHALLENGES to earn the reward item"; - any = "Complete ANY " + count + " CHALLENGES to earn the reward item"; - goto default; case "French": all = "Terminez CHACUN DES DÉFIS pour gagner la récompense"; any = "Terminez " + count + " DES DÉFIS pour gagner la récompense"; - goto default; + break; case "German": all = "Schließe ALLE HERAUSFORDERUNGEN ab, um die Belohnung zu verdienen"; any = "Schließe " + count + " HERAUSFORDERUNGEN ab, um die Belohnung zu verdienen"; - goto default; + break; case "Italian": all = "Completa TUTTE LE SFIDE per ottenere l'oggetto in ricompensa"; any = "Completa " + count + " SFIDE QUALSIASI per ottenere l'oggetto ricompensa"; - goto default; + break; case "Spanish": case "Spanish (LA)": - all = "Completa LOS DESAFÍOS para conseguir el objeto de recompensa"; + all = "Completa TODOS LOS DESAFÍOS para conseguir el objeto de recompensa"; any = "Completa " + count + " DE LOS DESAFÍOS para conseguir el objeto de recompensa"; - goto default; + break; case "Arabic": all = "أكمل جميع التحديات لتربح عنصر المكافأة"; any = "أكمل أيًا " + count + " من التحديات للحصول على عنصر المكافأة"; - goto default; + break; case "Japanese": all = "全個のチャレンジをクリアして報酬アイテムを獲得する"; any = "いずれか" + count + "個のチャレンジをクリアして、報酬アイテムを獲得する"; - goto default; + break; case "Korean": all = "개의 도전을 모두 완료하고 보상 아이템을 얻으세요."; any = count + "개의 도전 완료"; - goto default; + break; case "Polish": all = "Ukończ wszystkie wyzwań, by otrzymać tę nagrodę"; any = "Ukończ " + count + " dowolnych wyzwań, by otrzymać tę nagrodę"; - goto default; + break; case "Portuguese (Brazil)": all = "Conclua TODOS OS DESAFIOS para receber o item de recompensa"; any = "Conclua " + count + " DESAFIO(S) para receber o item de recompensa"; - goto default; + break; case "Russian": all = "Выполните все испытания, чтобы получить награду"; any = "Выполните не менее " + count + " любых испытаний для награды"; - goto default; + break; case "Turkish": all = "Ödülü kazanmak için GÖREVI DE tamamla."; any = "Ödülü kazanmak için herhangi " + count + " GÖREVI tamamla."; - goto default; + break; case "Chinese (S)": all = "完成所有个挑战以赢得奖励物品"; any = "完成任意" + count + "个挑战以赢得奖励物品"; - goto default; + break; case "Traditional Chinese": all = "完成所有個挑戰以贏得獎勵物品"; any = "完成任意" + count + "個挑戰以贏得獎勵物品"; - goto default; + break; default: - if (count == "-1") - { - toDrawOn.DrawString(all, new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22)); - } - else - { - toDrawOn.DrawString(any, new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22)); - } break; } + + toDrawOn.DrawString(count == "-1" ? all : any, new Font(FontUtilities.pfc.Families[1], 50), new SolidBrush(Color.White), new Point(100, theY + 22)); } /// diff --git a/FModel/Methods/ChallengeGenerator/DrawingRewards.cs b/FModel/Methods/ChallengeGenerator/DrawingRewards.cs index 34db58cf..9920954d 100644 --- a/FModel/Methods/ChallengeGenerator/DrawingRewards.cs +++ b/FModel/Methods/ChallengeGenerator/DrawingRewards.cs @@ -141,6 +141,7 @@ namespace FModel private static void drawIcon(string itemId) { + Image itemIcon = null; if (File.Exists(ItemIcon.ItemIconPath)) { if (Settings.Default.challengesDebug) @@ -149,17 +150,18 @@ namespace FModel 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)) { itemIcon = new Bitmap(bmpTemp); } - BundleDesign.toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, BundleDesign.theY + 6)); } else + itemIcon = Resources.unknown512; + + if (itemIcon != null) { - Image itemIcon = Resources.unknown512; BundleDesign.toDrawOn.DrawImage(ImageUtilities.ResizeImage(itemIcon, 110, 110), new Point(2300, BundleDesign.theY + 6)); + itemIcon.Dispose(); } } diff --git a/FModel/Methods/IconGenerator/DrawText.cs b/FModel/Methods/IconGenerator/DrawText.cs index 6b7b5311..ed288327 100644 --- a/FModel/Methods/IconGenerator/DrawText.cs +++ b/FModel/Methods/IconGenerator/DrawText.cs @@ -1,4 +1,4 @@ -using csharp_wick; +using csharp_wick; using FModel.Parser.Items; using FModel.Properties; using Newtonsoft.Json; @@ -204,39 +204,39 @@ namespace FModel /// private static void DrawCosmeticUff(ItemsIdParser theItem, Graphics myGraphic) { + Image imageLogo = null; + Point pointCoords = new Point(6, 6); + if (CosmeticUff != null) { if (CosmeticUff.Contains("Animated")) { - Image animatedLogo = Resources.T_Icon_Animated_64; - myGraphic.DrawImage(ImageUtilities.ResizeImage(animatedLogo, 32, 32), new Point(6, -2)); + pointCoords = new Point(6, -2); + imageLogo = Resources.T_Icon_Animated_64; } else if (CosmeticUff.Contains("HasUpgradeQuests") && theItem.ExportType != "AthenaPetCarrierItemDefinition") - { - Image questLogo = Resources.T_Icon_Quests_64; - myGraphic.DrawImage(ImageUtilities.ResizeImage(questLogo, 32, 32), new Point(6, 6)); - } + imageLogo = Resources.T_Icon_Quests_64; else if (CosmeticUff.Contains("HasUpgradeQuests") && theItem.ExportType == "AthenaPetCarrierItemDefinition") - { - Image petLogo = Resources.T_Icon_Pets_64; - myGraphic.DrawImage(ImageUtilities.ResizeImage(petLogo, 32, 32), new Point(6, 6)); - } + imageLogo = Resources.T_Icon_Pets_64; else if (CosmeticUff.Contains("HasVariants")) - { - Image variantsLogo = Resources.T_Icon_Variant_64; - myGraphic.DrawImage(ImageUtilities.ResizeImage(variantsLogo, 32, 32), new Point(6, 6)); - } + imageLogo = Resources.T_Icon_Variant_64; else if (CosmeticUff.Contains("Reactive")) { - Image reactiveLogo = Resources.T_Icon_Adaptive_64; - myGraphic.DrawImage(ImageUtilities.ResizeImage(reactiveLogo, 32, 32), new Point(7, 7)); + pointCoords = new Point(7, 7); + imageLogo = Resources.T_Icon_Adaptive_64; } else if (CosmeticUff.Contains("Traversal")) { - Image traversalLogo = Resources.T_Icon_Traversal_64; - myGraphic.DrawImage(ImageUtilities.ResizeImage(traversalLogo, 32, 32), new Point(6, 3)); + pointCoords = new Point(6, 3); + imageLogo = Resources.T_Icon_Traversal_64; } } + + if (imageLogo != null) + { + myGraphic.DrawImage(ImageUtilities.ResizeImage(imageLogo, 32, 32), pointCoords); + imageLogo.Dispose(); + } } ///