public void InitCampaignList(string campaignXmlFile) { if (!isCampaignsInited) { campaigns = new List <ICampaign>(); CampaignListsXml campaignListsXml; isCampaignsInited = true; XmlObjectLoader loader = new XmlObjectLoader(); loader.Load <CampaignListsXml>(campaignXmlFile, out campaignListsXml); foreach (var campaignListXml in campaignListsXml.Campaigns) { ICampaign campaign; if (campaignListXml.type == "Scriptable") { campaign = new ScriptableCampaign(campaignListXml.value); campaign.Name = campaignListXml.id; campaign.Desc = campaignListXml.desc; campaigns.Add(campaign); } } } }
public void Init() { RegistryKey key = Registry.LocalMachine; RegistryKey keySteam = key.OpenSubKey("software\\wow6432Node\\Valve\\Steam", true); if (keySteam != null) { string steamPath = keySteam.GetValue("InstallPath").ToString(); string bannerlordPath = Path.Combine(steamPath, "steamapps\\common\\Mount & Blade II Bannerlord\\bin\\Win64_Shipping_Client\\TaleWorlds.MountAndBlade.Launcher.exe"); if (File.Exists(bannerlordPath)) { bannerlordExePath = bannerlordPath; string bannerlordModulePath = Path.Combine(steamPath, "steamapps\\common\\Mount & Blade II Bannerlord\\Modules"); DirectoryInfo di = new DirectoryInfo(bannerlordModulePath); foreach (var dii in di.EnumerateDirectories()) { if (dii.EnumerateFiles().Where(o => o.Name == "SubModule.xml").Count() == 1) { MBModule module; var moduleFile = dii.EnumerateFiles().Where(o => o.Name == "SubModule.xml").FirstOrDefault(); XmlObjectLoader xmlObjectLoader = new XmlObjectLoader(moduleFile.FullName); xmlObjectLoader.Load(out module); if (module.Official != null && module.Official.value == "true") { MBBannerlordModule officalModule = new MBBannerlordModule(dii.FullName); OfficialMods.Add(officalModule); } } } } } }
public void LoadNPCCharacters(string destFileFullPath) { MBNPCCharacters characters; var xmlLoader = new XmlObjectLoader(destFileFullPath); xmlLoader.Load(out characters); characters.FilePath = destFileFullPath; moduleNPCCharacters.Add(characters); }
public void LoadKingdoms(string destFileFullPath) { MBKingdoms kingdoms; var xmlLoader = new XmlObjectLoader(destFileFullPath); xmlLoader.Load(out kingdoms); kingdoms.FilePath = destFileFullPath; moduleKingdoms.Add(kingdoms); }
private void btnDelete_Click(object sender, EventArgs e) { if (factionList.SelectedNode != null) { int index = factionList.Nodes.IndexOf(factionList.SelectedNode); kingdoms.Kingdoms.RemoveAt(index); factionList.Nodes.RemoveAt(index); XmlObjectLoader xmlObjectLoader = new XmlObjectLoader(kingdoms.FilePath); xmlObjectLoader.Save(kingdoms); RefreshData(); } }
public void DeleteSelected() { if (npcCharacterList.SelectedNode != null) { int index = npcCharacterList.Nodes.IndexOf(npcCharacterList.SelectedNode); npcCharacters.NPCCharacters.RemoveAt(index); npcCharacterList.Nodes.RemoveAt(index); XmlObjectLoader xmlObjectLoader = new XmlObjectLoader(npcCharacters.FilePath); xmlObjectLoader.Save(npcCharacters); RefreshData(); } }
private void CharacterDetailsCtrl_SaveNPCCharacterInfoFinished(MBNPCCharacter savedCharatcer, AddEditState state, int index) { if (state == AddEditState.Add) { characters.NPCCharacters.Add(savedCharatcer); XmlObjectLoader xmlObjectLoader = new XmlObjectLoader(characters.FilePath); xmlObjectLoader.Save(characters); trooperListCtrl.ChangeAddEditState(AddEditState.View); trooperListCtrl.RefreshData(); } else if (state == AddEditState.Edit) { characters.NPCCharacters[index] = savedCharatcer; XmlObjectLoader xmlObjectLoader = new XmlObjectLoader(characters.FilePath); xmlObjectLoader.Save(characters); trooperListCtrl.ChangeAddEditState(AddEditState.View); trooperListCtrl.RefreshData(); } }
private void FactionDetailsCtrl_SaveKingdomInfoFinished(MBKingdom savedKingdom, AddEditState state, int index) { if (state == AddEditState.Add) { kingdoms.Kingdoms.Add(savedKingdom); XmlObjectLoader xmlObjectLoader = new XmlObjectLoader(kingdoms.FilePath); xmlObjectLoader.Save(kingdoms); factionListCtrl.ChangeAddEditState(AddEditState.View); factionListCtrl.RefreshData(); } else if (state == AddEditState.Edit) { kingdoms.Kingdoms[index] = savedKingdom; XmlObjectLoader xmlObjectLoader = new XmlObjectLoader(kingdoms.FilePath); xmlObjectLoader.Save(kingdoms); factionListCtrl.ChangeAddEditState(AddEditState.View); factionListCtrl.RefreshData(); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); LanguageManager.Instance.Init(); AppSetting appSetting = new AppSetting("app.ini"); RecentOperations recentOperations; XmlObjectLoader xmlObjectLoader = new XmlObjectLoader("RecentOperations.xml"); xmlObjectLoader.Load(out recentOperations); frmAppSetting appSettingSelector = new frmAppSetting(appSetting); if (appSettingSelector.ShowDialog() == DialogResult.OK) { Application.Run(new frmMain(appSettingSelector.AppSetting, recentOperations)); } }
private void importModuleProject() { frmImportProject importProjectForm = new frmImportProject(); if (importProjectForm.ShowDialog() == DialogResult.OK) { currentProject = importProjectForm.Project; OpenProject(currentProject); string loc = currentProject.Location.Replace("\\", "/"); if (recentOperations.RecentOperationList.Where(o => o.Value == loc).Count() == 0) { recentOperations.RecentOperationList.Add(new RecentOperation() { Type = "Import", Value = currentProject.Location.Replace("\\", "/") }); XmlObjectLoader xmlObjectLoader = new XmlObjectLoader("RecentOperations.xml"); xmlObjectLoader.Save(recentOperations); } } }
private void loadMod() { XmlObjectLoader xmlLoader = new XmlObjectLoader(Path.Combine(path, "SubModule.xml")); xmlLoader.Load <MBModule>(out moduleInfo); var findedSPKingdomsNode = moduleInfo.XmlNodes.Where(o => o.XmlName.id == "Kingdoms"); foreach (var node in findedSPKingdomsNode) { string kingdomsXmlPath = Path.Combine(path, "ModuleData\\" + node.XmlName.path) + ".xml"; if (File.Exists(kingdomsXmlPath)) { hasModuleKingdomsFile = true; LoadKingdoms(kingdomsXmlPath); } } var findedSPCulturesNode = moduleInfo.XmlNodes.Where(o => o.XmlName.id == "SPCultures"); foreach (var node in findedSPCulturesNode) { MBCultures cultures; string culturesXmlPath = Path.Combine(path, "ModuleData\\" + node.XmlName.path) + ".xml"; if (File.Exists(culturesXmlPath)) { xmlLoader = new XmlObjectLoader(Path.Combine(culturesXmlPath)); xmlLoader.Load(out cultures); cultures.FilePath = culturesXmlPath; moduleCultures.Add(cultures); } } var findedHeroesNode = moduleInfo.XmlNodes.Where(o => o.XmlName.id == "Heroes"); foreach (var node in findedHeroesNode) { MBHeroes heroes; string heroesXmlPath = Path.Combine(path, "ModuleData\\" + node.XmlName.path) + ".xml"; if (File.Exists(heroesXmlPath)) { xmlLoader = new XmlObjectLoader(heroesXmlPath); xmlLoader.Load(out heroes); heroes.FilePath = heroesXmlPath; moduleHeroes.Add(heroes); } } var findedItemNode = moduleInfo.XmlNodes.Where(o => o.XmlName.id == "Items"); foreach (var node in findedItemNode) { MBItems items; string itemsXmlPath = Path.Combine(path, "ModuleData\\" + node.XmlName.path); if (Directory.Exists(itemsXmlPath)) { DirectoryInfo di = new DirectoryInfo(itemsXmlPath); foreach (var file in di.EnumerateFiles()) { if (file.Extension == ".xml") { xmlLoader = new XmlObjectLoader(file.FullName); xmlLoader.Load(out items); items.FilePath = file.FullName; moduleItems.Add(items); } } } else if (File.Exists(itemsXmlPath + ".xml")) { itemsXmlPath = itemsXmlPath + ".xml"; xmlLoader = new XmlObjectLoader(itemsXmlPath); xmlLoader.Load(out items); items.FilePath = itemsXmlPath; moduleItems.Add(items); } } var findedNPCCharacterNodes = moduleInfo.XmlNodes.Where(o => o.XmlName.id == "NPCCharacters"); foreach (var node in findedNPCCharacterNodes) { string charactersXmlPath = Path.Combine(path, "ModuleData\\" + node.XmlName.path); if (Directory.Exists(charactersXmlPath)) { DirectoryInfo di = new DirectoryInfo(charactersXmlPath); foreach (var file in di.EnumerateFiles()) { if (file.Extension == ".xml") { LoadNPCCharacters(file.FullName); } } } else if (File.Exists(charactersXmlPath + ".xml")) { hasModuleCharactersFile = true; charactersXmlPath = charactersXmlPath + ".xml"; LoadNPCCharacters(charactersXmlPath); } } }
public void SaveModuleInfo() { XmlObjectLoader xmlObjectLoader = new XmlObjectLoader(Path.Combine(BannerlordModule.ModulePath, "SubModule.xml")); xmlObjectLoader.Save(bannerlordModule.ModuleInfo); }