From 17639beadf035b0b672c6ef254368b0562d02589 Mon Sep 17 00:00:00 2001 From: lastbattle <4586194+lastbattle@users.noreply.github.com> Date: Sun, 24 Nov 2024 19:24:35 +0800 Subject: [PATCH] [HaCreator] fix initialisation errors with MapleStoryU String,wz (TODO: Mintable item handling) --- HaCreator/GUI/Initialization.cs | 64 +++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/HaCreator/GUI/Initialization.cs b/HaCreator/GUI/Initialization.cs index a5bc67fa..248c0e7e 100644 --- a/HaCreator/GUI/Initialization.cs +++ b/HaCreator/GUI/Initialization.cs @@ -1089,7 +1089,7 @@ public void ExtractStringFile(bool bIsBetaMapleStory) { // In non-beta, process each item within the category eqpCategorySubProp.WzProperties - .Cast() + //.Cast() .ToList() .ForEach(itemProp => ExtractStringFile_ProcessEquipmentItem( itemProp, @@ -1104,22 +1104,28 @@ public void ExtractStringFile(bool bIsBetaMapleStory) else stringInsImg = ((WzImage)Program.WzManager.FindWzImageByName("string", "Ins.img")).WzProperties; - foreach (WzSubProperty insItemImg in stringInsImg) // String.wz/Ins.img/3010000 + foreach (WzImageProperty insItemImage in stringInsImg) // String.wz/Ins.img/3010000 { - string itemId = insItemImg.Name; - const string itemCategory = "Ins"; - string itemName = (insItemImg["name"] as WzStringProperty)?.Value ?? "NO NAME"; - string itemDesc = (insItemImg["desc"] as WzStringProperty)?.Value ?? "NO DESC"; + if (insItemImage is WzSubProperty insItemSubProp) + { + string itemId = insItemSubProp.Name; + const string itemCategory = "Ins"; + string itemName = (insItemSubProp["name"] as WzStringProperty)?.Value ?? "NO NAME"; + string itemDesc = (insItemSubProp["desc"] as WzStringProperty)?.Value ?? "NO DESC"; - int intName = 0; - int.TryParse(itemId, out intName); + int intName = 0; + int.TryParse(itemId, out intName); - if (!Program.InfoManager.ItemNameCache.ContainsKey(intName)) - Program.InfoManager.ItemNameCache[intName] = new Tuple(itemCategory, itemName, itemDesc); - else + if (!Program.InfoManager.ItemNameCache.ContainsKey(intName)) + Program.InfoManager.ItemNameCache[intName] = new Tuple(itemCategory, itemName, itemDesc); + else + { + string error = string.Format("[Initialization] Duplicate [Ins] item name in String.wz. ItemId='{0}', Category={1}", itemId, insItemSubProp.Name); + ErrorLogger.Log(ErrorLevel.IncorrectStructure, error); + } + } else { - string error = string.Format("[Initialization] Duplicate [Ins] item name in String.wz. ItemId='{0}', Category={1}", itemId, insItemImg.Name); - ErrorLogger.Log(ErrorLevel.IncorrectStructure, error); + // TOOD: Handle MapleStoryU related items } } @@ -1245,23 +1251,29 @@ private void ExtractStringFile_ProcessEtcItem(WzSubProperty itemProp, string par ErrorLogger.Log(ErrorLevel.IncorrectStructure, error); } } - private void ExtractStringFile_ProcessEquipmentItem(WzSubProperty itemProp, string category) + private void ExtractStringFile_ProcessEquipmentItem(WzImageProperty itemImageProp, string category) { - string itemId = itemProp.Name; - string itemName = (itemProp["name"] as WzStringProperty)?.Value ?? "NO NAME"; - string itemDesc = (itemProp["desc"] as WzStringProperty)?.Value ?? "NO DESC"; - - if (int.TryParse(itemId, out int intName)) + if (itemImageProp is WzSubProperty itemProp) { - if (!Program.InfoManager.ItemNameCache.ContainsKey(intName)) - { - Program.InfoManager.ItemNameCache[intName] = new Tuple(category, itemName, itemDesc); - } - else + string itemId = itemProp.Name; + string itemName = (itemProp["name"] as WzStringProperty)?.Value ?? "NO NAME"; + string itemDesc = (itemProp["desc"] as WzStringProperty)?.Value ?? "NO DESC"; + + if (int.TryParse(itemId, out int intName)) { - string error = $"[Initialization] Duplicate [Equip] item name in String.wz. ItemId='{itemId}', Category={category}"; - ErrorLogger.Log(ErrorLevel.IncorrectStructure, error); + if (!Program.InfoManager.ItemNameCache.ContainsKey(intName)) + { + Program.InfoManager.ItemNameCache[intName] = new Tuple(category, itemName, itemDesc); + } + else + { + string error = $"[Initialization] Duplicate [Equip] item name in String.wz. ItemId='{itemId}', Category={category}"; + ErrorLogger.Log(ErrorLevel.IncorrectStructure, error); + } } + } else + { + // TODO: Handle MapleStoryU related equipments } }