/// <summary> /// Plugin initialization /// </summary> public void Initialize() { Debug.Log("Initializing Satellite Reign LoadCustomData mod"); try { var translations = FileManager.LoadTranslationsXML("Translations.xml"); var langLookup = TextManager.Get().GetFieldValue <Dictionary <string, TextManager.LocElement> >("m_FastLanguageLookup"); foreach (var e in translations) { if (langLookup.ContainsKey(e.Key)) { langLookup[e.Key] = e.Element; } else { langLookup.Add(e.Key, e.Element); } } SRInfoHelper.Log("Updated LangLookup with new translations"); var items = FileManager.LoadXML("ItemData.xml"); SRInfoHelper.isLogging = false; var remappedItems = items.Select(d => SRMapper.ReflectionObjectBuilder <ItemManager.ItemData>(d)).ToList(); Manager.GetItemManager().m_ItemDefinitions = remappedItems; } catch (Exception e) { SRInfoHelper.isLogging = true; SRInfoHelper.Log("Exception thrown while serializing: " + e.Message + " inner: " + e.InnerException); SRInfoHelper.isLogging = false; System.IO.Directory.CreateDirectory(FileManager.FilePathCheck($@"icons\")); ExportData(); } SRInfoHelper.isLogging = true; SRInfoHelper.Log("Initialized"); }
public ItemBrowser() { SRMapper.LanguageMapper(); InitializeComponent(); ItemListBox.ClearSelected(); _translations = FileManager.LoadTranslationsXML("Translations.xml", FileManager.ExecPath).ToList(); itemDTOs = FileManager.LoadItemDataXML("ItemData.xml", FileManager.ExecPath).OrderBy(i => i.m_ID).ToList(); UpdateItemInfo(); ItemSlotTypeDropDown.DataSource = Enum.GetValues(typeof(ItemSlotTypes)).Cast <ItemSlotTypes>().ToList().Take(8).ToList(); GearSubTypeDropDown.DataSource = Enum.GetValues(typeof(ItemSubCategories)); //.Cast<ItemSubCategories>().ToList().Take(8).ToList(); WeaponTypeDropDown.DataSource = Enum.GetValues(typeof(WeaponType)).Cast <WeaponType>().ToList().Take(29).ToList(); abilities = _translations.Where(t => t.Key.StartsWith("ABILITY_") && t.Key.EndsWith("_NAME")).Select(a => { int id = int.Parse(a.Key.Replace("ABILITY_", "").Replace("_NAME", "")); LocElement desc = null; if (_translations.Where(t => t.Key == "ABILITY_" + id + "_DESC").Any()) { desc = _translations.Where(t => t.Key == "ABILITY_" + id + "_DESC").First().Element; } return(new Models.Ability() { Id = id, LocName = a.Element, LocDesc = desc }); }).ToList(); AbilityDropdown.DataSource = abilities; AbilityDropdown.DisplayMember = "Name"; AbilityDropdown.ValueMember = "Desc"; ModifierDropdown.DataSource = Enum.GetValues(typeof(ModifierType)).Cast <ModifierType>().ToList().Skip(1).ToList(); //MultiplierTypeDropDown.DataSource = Enum.GetValues(typeof(ModifierType)).Cast<ModifierType>().ToList(); }
public void ExportData() { try { var data = Manager.GetItemManager().m_ItemDefinitions.OrderBy(d => d.m_ID).Select(d => SRMapper.ReflectionObjectBuilder <dto.ItemData>(d)).ToList(); var langLookup = TextManager.Get().GetFieldValue <Dictionary <string, TextManager.LocElement> >("m_FastLanguageLookup"); var mappedTranslations = langLookup.OrderBy(l => l.Key).Select(l => new dto.TranslationElementDTO() { Key = l.Key, Element = l.Value }).ToList(); try { FileManager.SaveAsXML(data, "ItemData.xml"); FileManager.SaveAsXML(mappedTranslations, "Translations.xml"); } catch (Exception e) { SRInfoHelper.Log("Exception thrown while serializing: " + e.Message); } } catch (Exception e) { SRInfoHelper.isLogging = true; SRInfoHelper.Log("Exception thrown while mapping. Message: " + e.Message + " --InnerException: " + e.InnerException); } }