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 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 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); }
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 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); } } }