public EquipmentItem(kcsapi_mst_slotitem item) { this.api_index_no = item.api_sortno; this.api_state = new int[] { 1, 0, 0, 0, 0 }; this.api_table_id = new int[] { item.api_id }; this.api_name = item.api_name; this.api_type = item.api_type; this.api_souk = item.api_souk; this.api_houg = item.api_houg; this.api_raig = item.api_raig; this.api_soku = item.api_soku; this.api_baku = item.api_baku; this.api_tyku = item.api_tyku; this.api_tais = item.api_tais; this.api_houm = item.api_houm; this.api_houk = item.api_houk; this.api_saku = item.api_saku; this.api_leng = item.api_leng; this.api_info = item.api_info; this.api_flag = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 }; var type = item.api_type; if (type[2] == 1 || type[2] == 2 || type[2] == 3 || type[2] == 4) // 小口径主炮 + 中口径主炮 + 大口径主炮 + 副炮 { this.api_flag[0] = 1; } if (type[2] == 5 || type[2] == 22) // 鱼雷 + 甲标的 { this.api_flag[1] = 1; } if (type[2] == 8) // 舰攻 { this.api_flag[2] = 1; } if (type[2] == 7 || type[2] == 11 || type[2] == 25 || type[2] == 26) // 舰爆 + 水爆 + カ号 + 三式指挥联络机 { this.api_flag[3] = 1; } if (type[2] == 21) // 对空机铳 { this.api_flag[4] = 1; } if (type[2] == 6) // 舰战 { this.api_flag[5] = 1; } if (type[2] == 9 || type[2] == 10 || type[2] == 26) // 舰侦 + 水侦 + 三式指挥联络机 { this.api_flag[6] = 1; } if (type[2] == 6 || type[2] == 18 || type[2] == 21) // 舰战 + 三式弹 + 对空机铳 { this.api_flag[7] = 1; } }
public void AddTranslation(Object RawData, TranslationType Type) { if (RawData == null || !EnableAddUntranslated) { return; } try { switch (Type) { case TranslationType.Ships: if (ShipsXML == null) { ShipsXML = new XDocument(); ShipsXML.Add(new XElement("Ships")); } kcsapi_mst_ship ShipData = RawData as kcsapi_mst_ship; if (ShipData == null) { return; } ShipsXML.Root.Add(new XElement("Ship", new XElement("JP-Name", ShipData.api_name), new XElement("TR-Name", ShipData.api_name) )); ShipsXML.Save(Path.Combine(MainFolder, "Translations", "Ships.xml")); break; case TranslationType.ShipTypes: if (ShipTypesXML == null) { ShipTypesXML = new XDocument(); ShipTypesXML.Add(new XElement("ShipTypes")); } kcsapi_mst_stype TypeData = RawData as kcsapi_mst_stype; if (TypeData == null) { return; } ShipTypesXML.Root.Add(new XElement("Type", new XElement("ID", TypeData.api_id), new XElement("JP-Name", TypeData.api_name), new XElement("TR-Name", TypeData.api_name) )); ShipTypesXML.Save(Path.Combine(MainFolder, "Translations", "ShipTypes.xml")); break; case TranslationType.Equipment: if (EquipmentXML == null) { EquipmentXML = new XDocument(); EquipmentXML.Add(new XElement("Equipment")); } kcsapi_mst_slotitem EqiupData = RawData as kcsapi_mst_slotitem; if (EqiupData == null) { return; } EquipmentXML.Root.Add(new XElement("Item", new XElement("JP-Name", EqiupData.api_name), new XElement("TR-Name", EqiupData.api_name) )); EquipmentXML.Save(Path.Combine(MainFolder, "Translations", "Equipment.xml")); break; case TranslationType.OperationMaps: case TranslationType.OperationSortie: if (OperationsXML == null) { OperationsXML = new XDocument(); OperationsXML.Add(new XElement("Operations")); } kcsapi_battleresult OperationsData = RawData as kcsapi_battleresult; if (OperationsData == null) { return; } if (Type == TranslationType.OperationMaps) { OperationsXML.Root.Add(new XElement("Map", new XElement("JP-Name", OperationsData.api_quest_name), new XElement("TR-Name", OperationsData.api_quest_name) )); } else { OperationsXML.Root.Add(new XElement("Sortie", new XElement("JP-Name", OperationsData.api_enemy_info.api_deck_name), new XElement("TR-Name", OperationsData.api_enemy_info.api_deck_name) )); } OperationsXML.Save(Path.Combine(MainFolder, "Translations", "Operations.xml")); break; case TranslationType.Quests: case TranslationType.QuestTitle: case TranslationType.QuestDetail: if (QuestsXML == null) { QuestsXML = new XDocument(); QuestsXML.Add(new XElement("Quests")); } kcsapi_quest QuestData = RawData as kcsapi_quest; if (QuestData == null) { return; } IEnumerable <XElement> FoundTranslationID = QuestsXML.Descendants("Quest").Where(b => b.Element("ID").Value.Equals(QuestData.api_no)); //이 부분에 의심이 가지만 확증은 없음 if (Type == TranslationType.QuestTitle || Type == TranslationType.QuestDetail && FoundTranslationID != null && FoundTranslationID.Any()) { foreach (XElement el in FoundTranslationID) { el.Element("ID").Value = QuestData.api_no.ToString(); } } else { // The quest doesn't exist at all. Add it. QuestsXML.Root.Add(new XElement("Quest", new XElement("ID", QuestData.api_no), new XElement("JP-Name", QuestData.api_title), new XElement("TR-Name", "[" + QuestData.api_no.ToString() + "]" + QuestData.api_title), new XElement("JP-Detail", QuestData.api_detail), new XElement("TR-Detail", "[" + QuestData.api_no.ToString() + "]" + QuestData.api_detail) )); } QuestsXML.Save(Path.Combine(MainFolder, "Translations", "Quests.xml")); break; case TranslationType.Expeditions: case TranslationType.ExpeditionTitle: case TranslationType.ExpeditionDetail: if (ExpeditionXML == null) { ExpeditionXML = new XDocument(); ExpeditionXML.Add(new XElement("Expeditions")); } kcsapi_mission MissionData = RawData as kcsapi_mission; if (MissionData == null) { return; } FoundTranslationID = ExpeditionXML.Descendants("Expedition").Where(b => b.Element("ID").Value.Equals(MissionData.api_id)); if (Type == TranslationType.ExpeditionTitle || Type == TranslationType.ExpeditionDetail && FoundTranslationID != null && FoundTranslationID.Any()) { foreach (XElement el in FoundTranslationID) { el.Element("ID").Value = MissionData.api_id.ToString(); } } else { // The quest doesn't exist at all. Add it. ExpeditionXML.Root.Add(new XElement("Expedition", new XElement("ID", MissionData.api_id), new XElement("JP-Name", MissionData.api_name), new XElement("TR-Name", "[" + MissionData.api_id.ToString() + "]" + MissionData.api_name), new XElement("JP-Detail", MissionData.api_details), new XElement("TR-Detail", "[" + MissionData.api_id.ToString() + "]" + MissionData.api_details) )); } ExpeditionXML.Save(Path.Combine(MainFolder, "Translations", "Expeditions.xml")); break; } } catch { } }
public void AddTranslation(Object RawData, TranslationType Type) { if (RawData == null || !EnableAddUntranslated) { return; } try { switch (Type) { case TranslationType.Ships: if (ShipsXML == null) { ShipsXML = new XDocument(); ShipsXML.Add(new XElement("Ships")); ShipsXML.Root.SetAttributeValue("Version", "0.0.0"); ShipsVersion = "0.0.0"; } kcsapi_mst_ship ShipData = RawData as kcsapi_mst_ship; if (ShipData == null) { return; } ShipsXML.Root.Add(new XElement("Ship", new XElement("JP-Name", ShipData.api_name), new XElement("TR-Name", ShipData.api_name) )); ShipsXML.Save("Translations\\" + CurrentCulture + "Ships.xml"); break; case TranslationType.ShipTypes: if (ShipTypesXML == null) { ShipTypesXML = new XDocument(); ShipTypesXML.Add(new XElement("ShipTypes")); ShipTypesXML.Root.SetAttributeValue("Version", "0.0.0"); ShipTypesVersion = "0.0.0"; } kcsapi_mst_stype TypeData = RawData as kcsapi_mst_stype; if (TypeData == null) { return; } ShipTypesXML.Root.Add(new XElement("Type", new XElement("ID", TypeData.api_id), new XElement("JP-Name", TypeData.api_name), new XElement("TR-Name", TypeData.api_name) )); ShipTypesXML.Save("Translations\\" + CurrentCulture + "ShipTypes.xml"); break; case TranslationType.Equipment: if (EquipmentXML == null) { EquipmentXML = new XDocument(); EquipmentXML.Add(new XElement("Equipment")); EquipmentXML.Root.SetAttributeValue("Version", "0.0.0"); EquipmentVersion = "0.0.0"; } kcsapi_mst_slotitem EqiupData = RawData as kcsapi_mst_slotitem; if (EqiupData == null) { return; } EquipmentXML.Root.Add(new XElement("Item", new XElement("JP-Name", EqiupData.api_name), new XElement("TR-Name", EqiupData.api_name) )); EquipmentXML.Save("Translations\\" + CurrentCulture + "Equipment.xml"); break; case TranslationType.OperationMaps: case TranslationType.OperationSortie: if (OperationsXML == null) { OperationsXML = new XDocument(); OperationsXML.Add(new XElement("Operations")); OperationsXML.Root.SetAttributeValue("Version", "0.0.0"); OperationsVersion = "0.0.0"; } kcsapi_battleresult OperationsData = RawData as kcsapi_battleresult; if (OperationsData == null) { return; } if (Type == TranslationType.OperationMaps) { OperationsXML.Root.Add(new XElement("Map", new XElement("JP-Name", OperationsData.api_quest_name), new XElement("TR-Name", OperationsData.api_quest_name) )); } else { OperationsXML.Root.Add(new XElement("Sortie", new XElement("JP-Name", OperationsData.api_enemy_info.api_deck_name), new XElement("TR-Name", OperationsData.api_enemy_info.api_deck_name) )); } OperationsXML.Save("Translations\\" + CurrentCulture + "Operations.xml"); break; case TranslationType.Quests: case TranslationType.QuestTitle: case TranslationType.QuestDetail: if (QuestsXML == null) { QuestsXML = new XDocument(); QuestsXML.Add(new XElement("Quests")); QuestsXML.Root.SetAttributeValue("Version", "0.0.0"); QuestsVersion = "0.0.0"; } kcsapi_quest QuestData = RawData as kcsapi_quest; if (QuestData == null) { return; } IEnumerable <XElement> FoundTranslationDetail = QuestsXML.Descendants("Quest").Where(b => b.Element("JP-Detail").Value.Equals(QuestData.api_detail)); IEnumerable <XElement> FoundTranslationTitle = QuestsXML.Descendants("Quest").Where(b => b.Element("JP-Name").Value.Equals(QuestData.api_title)); // Check the current list for any errors and fix them before writing a whole new element. if (Type == TranslationType.QuestTitle && FoundTranslationDetail != null && FoundTranslationDetail.Any()) { // The title is wrong, but the detail is right. Fix the title. foreach (XElement el in FoundTranslationDetail) { el.Element("JP-Name").Value = QuestData.api_title; } } else if (Type == TranslationType.QuestDetail && FoundTranslationTitle != null && FoundTranslationTitle.Any()) { // We found an existing detail, the title must be broken. Fix it. foreach (XElement el in FoundTranslationTitle) { el.Element("JP-Detail").Value = QuestData.api_detail; } } else { // The quest doesn't exist at all. Add it. QuestsXML.Root.Add(new XElement("Quest", new XElement("ID", QuestData.api_no), new XElement("JP-Name", QuestData.api_title), new XElement("TR-Name", QuestData.api_title), new XElement("JP-Detail", QuestData.api_detail), new XElement("TR-Detail", QuestData.api_detail) )); } QuestsXML.Save("Translations\\" + CurrentCulture + "Quests.xml"); break; } } catch (Exception ex) { Debug.WriteLine(ex); } }
public void AddTranslation(Object rawData, TranslationType type) { if (rawData == null || !this.EnableAddUntranslated) { return; } try { switch (type) { case TranslationType.Ships: if (this.shipsXml == null) { this.shipsXml = new XDocument(); this.shipsXml.Add(new XElement("Ships")); // ReSharper disable once PossibleNullReferenceException this.shipsXml.Root.SetAttributeValue("Version", "0.0.0"); this.ShipsVersion = "0.0.0"; } kcsapi_mst_ship shipData = rawData as kcsapi_mst_ship; if (shipData == null) { return; } // ReSharper disable once PossibleNullReferenceException this.shipsXml.Root.Add(new XElement("Ship", new XElement("JP-Name", shipData.api_name), new XElement("TR-Name", shipData.api_name) )); this.shipsXml.Save("Translations\\Ships.xml"); break; case TranslationType.ShipTypes: if (this.shipTypesXml == null) { this.shipTypesXml = new XDocument(); this.shipTypesXml.Add(new XElement("ShipTypes")); // ReSharper disable once PossibleNullReferenceException this.shipTypesXml.Root.SetAttributeValue("Version", "0.0.0"); this.ShipTypesVersion = "0.0.0"; } kcsapi_mst_stype typeData = rawData as kcsapi_mst_stype; if (typeData == null) { return; } // ReSharper disable once PossibleNullReferenceException this.shipTypesXml.Root.Add(new XElement("Type", new XElement("ID", typeData.api_id), new XElement("JP-Name", typeData.api_name), new XElement("TR-Name", typeData.api_name) )); this.shipTypesXml.Save("Translations\\ShipTypes.xml"); break; case TranslationType.Equipment: if (this.equipmentXml == null) { this.equipmentXml = new XDocument(); this.equipmentXml.Add(new XElement("Equipment")); // ReSharper disable once PossibleNullReferenceException this.equipmentXml.Root.SetAttributeValue("Version", "0.0.0"); this.EquipmentVersion = "0.0.0"; } kcsapi_mst_slotitem eqiupData = rawData as kcsapi_mst_slotitem; if (eqiupData == null) { return; } // ReSharper disable once PossibleNullReferenceException this.equipmentXml.Root.Add(new XElement("Item", new XElement("JP-Name", eqiupData.api_name), new XElement("TR-Name", eqiupData.api_name) )); this.equipmentXml.Save("Translations\\Equipment.xml"); break; case TranslationType.OperationMaps: case TranslationType.OperationSortie: if (this.operationsXml == null) { this.operationsXml = new XDocument(); this.operationsXml.Add(new XElement("Operations")); // ReSharper disable once PossibleNullReferenceException this.operationsXml.Root.SetAttributeValue("Version", "0.0.0"); this.OperationsVersion = "0.0.0"; } kcsapi_battleresult operationsData = rawData as kcsapi_battleresult; if (operationsData == null) { return; } if (type == TranslationType.OperationMaps) { // ReSharper disable once PossibleNullReferenceException this.operationsXml.Root.Add(new XElement("Map", new XElement("JP-Name", operationsData.api_quest_name), new XElement("TR-Name", operationsData.api_quest_name) )); } else { // ReSharper disable once PossibleNullReferenceException this.operationsXml.Root.Add(new XElement("Sortie", new XElement("JP-Name", operationsData.api_enemy_info.api_deck_name), new XElement("TR-Name", operationsData.api_enemy_info.api_deck_name) )); } this.operationsXml.Save("Translations\\Operations.xml"); break; case TranslationType.Quests: case TranslationType.QuestTitle: case TranslationType.QuestDetail: if (this.questsXml == null) { this.questsXml = new XDocument(); this.questsXml.Add(new XElement("Quests")); // ReSharper disable once PossibleNullReferenceException this.questsXml.Root.SetAttributeValue("Version", "0.0.0"); this.QuestsVersion = "0.0.0"; } kcsapi_quest questData = rawData as kcsapi_quest; if (questData == null) { return; } IEnumerable <XElement> foundTranslation = this.questsXml.Descendants("Quest").Where( b => b.Element("ID") != null && b.Element("JP-Name") != null && b.Element("JP-Detail") != null && b.Element("ID").Value.Equals(questData.api_no.ToString()) ); // ReSharper disable PossibleMultipleEnumeration if (foundTranslation.Any()) { foreach (XElement el in foundTranslation) { if (el.Element("JP-Name") == null) { el.Add(new XElement("JP-Name", questData.api_title)); } else { el.Element("JP-Name").Value = questData.api_title; } if (el.Element("JP-Detail") == null) { el.Add(new XElement("JP-Detail", questData.api_detail)); } else { el.Element("JP-Detail").Value = questData.api_detail; } } } else { int n; bool needAdd = true; IEnumerable <XElement> foundTranslationDetail = this.questsXml.Descendants("Quest").Where(b => b.Element("JP-Detail").Value.Equals(questData.api_detail)); IEnumerable <XElement> foundTranslationTitle = this.questsXml.Descendants("Quest").Where(b => b.Element("JP-Name").Value.Equals(questData.api_title)); // Check the current list for any errors and fix them before writing a whole new element. if (type == TranslationType.QuestTitle && foundTranslationDetail.Any()) { // The title is wrong, but the detail is right. Fix the title. foreach (XElement el in foundTranslationDetail) { if (!Int32.TryParse(el.Element("ID").Value, out n)) { if (el.Element("JP-Name") == null) { el.Add(new XElement("JP-Name", questData.api_title)); } else { el.Element("JP-Name").Value = questData.api_title; } needAdd = false; } } } else if (type == TranslationType.QuestDetail && foundTranslationTitle.Any()) { // We found an existing detail, the title must be broken. Fix it. foreach (XElement el in foundTranslationTitle) { if (!Int32.TryParse(el.Element("ID").Value, out n)) { if (el.Element("JP-Detail") == null) { el.Add(new XElement("JP-Detail", questData.api_detail)); } else { el.Element("JP-Detail").Value = questData.api_detail; } needAdd = false; } } } if (needAdd) { // The quest doesn't exist at all. Add it. // ReSharper disable once PossibleNullReferenceException this.questsXml.Root.Add(new XElement("Quest", new XElement("ID", questData.api_no), new XElement("JP-Name", questData.api_title), new XElement("TR-Name", questData.api_title), new XElement("JP-Detail", questData.api_detail), new XElement("TR-Detail", questData.api_detail) )); } } // ReSharper restore PossibleMultipleEnumeration this.questsXml.Save("Translations\\Quests.xml"); break; case TranslationType.Expeditions: case TranslationType.ExpeditionTitle: case TranslationType.ExpeditionDetail: if (this.expeditionsXml == null) { this.expeditionsXml = new XDocument(); this.expeditionsXml.Add(new XElement("Expeditions")); // ReSharper disable once PossibleNullReferenceException this.expeditionsXml.Root.SetAttributeValue("Version", "0.0.0"); this.ExpeditionsVersion = "0.0.0"; } kcsapi_mission expeditionData = rawData as kcsapi_mission; if (expeditionData == null) { return; } IEnumerable <XElement> foundTranslationExpedition = this.expeditionsXml.Descendants("Expedition").Where(b => b.Element("ID").Value.Equals(expeditionData.api_id.ToString())); // Check the current list for any errors and fix them before writing a whole new element. // ReSharper disable PossibleMultipleEnumeration if (foundTranslationExpedition.Any()) { foreach (var el in foundTranslationExpedition) { if (el.Element("JP-Name") == null) { el.Add(new XElement("JP-Name", expeditionData.api_name)); } else { el.Element("JP-Name").Value = expeditionData.api_name; } if (el.Element("JP-Detail") == null) { el.Add(new XElement("JP-Detail", expeditionData.api_details)); } else { el.Element("JP-Detail").Value = expeditionData.api_details; } } } else { // The quest doesn't exist at all. Add it. // ReSharper disable once PossibleNullReferenceException this.expeditionsXml.Root.Add(new XElement("Expedition", new XElement("ID", expeditionData.api_id), new XElement("JP-Name", expeditionData.api_name), new XElement("TR-Name", expeditionData.api_name), new XElement("JP-Detail", expeditionData.api_details), new XElement("TR-Detail", expeditionData.api_details) )); } this.expeditionsXml.Save("Translations\\Expeditions.xml"); // ReSharper restore PossibleMultipleEnumeration break; } } catch (Exception ex) { Debug.WriteLine(ex); } }