public ShipItem(kcsapi_mst_ship ship) { this.api_index_no = ship.api_sortno; this.api_state = new int[][] { new int[] { 1, 1, 1, 0, 0 } }; this.api_table_id = new int[] { ship.api_id }; this.api_name = ship.api_name; this.api_yomi = ship.api_yomi; this.api_stype = ship.api_stype; this.api_ctype = ship.api_ctype; this.api_cnum = ship.api_cnum; this.api_taik = ship.api_taik[0]; this.api_souk = ship.api_souk[0]; this.api_houg = ship.api_houg[0]; this.api_raig = ship.api_raig[0]; this.api_tyku = ship.api_tyku[0]; this.api_leng = ship.api_leng; var ext = PictureBookExt.GetItem(ship.api_sortno); this.api_kaih = ext == null ? 0 : ext.api_kaih; this.api_tais = ext == null ? 0 : ext.api_tais; this.api_sinfo = ext == null ? "" : ext.api_sinfo; }
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); } }