示例#1
0
        private void btnFactions_Click(object sender, EventArgs e)
        {
            string errMsg    = string.Empty;
            bool   canLoaded = false;

            if (!currentProject.BannerlordModule.HasModuleKingdomFile)
            {
                if (MessageBox.Show(Helper.LOC("str_info_message_no_any_characters_found_in_current_module"), Helper.LOC("str_notice"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
                    DialogResult.Yes)
                {
                    return;
                }
                else
                {
                    canLoaded = currentProject.CopyFileIntoCurrentModuleAndLoad("NPCCharacters", "npccharacters", out errMsg);

                    if (!canLoaded)
                    {
                        MessageBox.Show(errMsg, "Notice");
                        return;
                    }
                    else
                    {
                        currentProject.BannerlordModule.ModuleInfo.XmlNodes.Add(new ModdingFiles.MBXmlNode()
                        {
                            XmlName = new ModdingFiles.MBXmlNodeName()
                            {
                                id   = "NPCCharacters",
                                path = "npccharacters"
                            },
                            IncludedGameTypes = new ModdingFiles.MBXmlNodeIncludedGameTypes()
                            {
                                GameTypes = new List <ModdingFiles.MBSubModuleInfoElement>()
                                {
                                    new ModdingFiles.MBSubModuleInfoElement()
                                    {
                                        value = "Campaign"
                                    },
                                    new ModdingFiles.MBSubModuleInfoElement()
                                    {
                                        value = "CampaignStoryMode"
                                    },
                                }
                            }
                        });
                        currentProject.SaveModuleInfo();
                    }
                }
            }

            TabControl tabControl = new TabControl();

            tabControl.Dock = DockStyle.Fill;
            foreach (var kingdoms in currentProject.BannerlordModule.ModuleKingdoms)
            {
                var             moduleName        = (new DirectoryInfo(kingdoms.FilePath).Parent.Parent.Name);
                var             fileName          = new DirectoryInfo(kingdoms.FilePath).Name;
                var             page              = new TabPage(moduleName + " - " + fileName);
                ucKingdomEditor factionEditorCtrl = new ucKingdomEditor(currentProject, kingdoms);
                page.Controls.Clear();
                page.Controls.Add(factionEditorCtrl);
                factionEditorCtrl.Dock = DockStyle.Fill;
                tabControl.TabPages.Add(page);
            }
            panelMain.Controls.Clear();
            panelMain.Controls.Add(tabControl);
        }