private void CountdownSelector_Load(object sender, EventArgs e)
        {
            EditorMainPage page           = Globals.MainWindow.GetPage <EditorMainPage>("pages:editormain");
            int            index          = page.CampaignGamemode.SelectedIndex;
            bool           adventure_mode = GameModeId.GetIdFromIndex(index) == GameModeId.ConversionTable["Adventure"];

            if (!adventure_mode)
            {
                if (MessageDialog.Show("The campaign must use the adventure game mode to use the countdown settings!\n\nDo you want to set the campaign mode to adventure?", "Error", Buttons.YesNo) == Result.Yes)
                {
                    page.CampaignGamemode.SelectedIndex = GameModeId.GetIndexFromId(GameModeId.ConversionTable["Adventure"]);
                }
                else
                {
                    Close(Result.Cancel);
                }
            }
        }
Example #2
0
        public void LoadCampaign(string path)
        {
            #region File loading
            FileInfo file = new FileInfo(path);
            if (!file.Exists)
            {
                throw new FileNotFoundException($"The file \"{path}\" does not exist!");
            }

            Config.AppendRecentFile(file.FullName);

            Serializer <Campaign> serializer = new Serializer <Campaign>(SerializerType.Json, path, true);
            Editor.current_campaign = serializer.Data;
            Editor.current_path     = file.DirectoryName;
            #endregion

            #region Filling the user interface with the data
            Levels.Items.Clear();
            Addons.Items.Clear();

            CampaignName.Text        = Editor.current_campaign.name;
            CampaignDescription.Text = Editor.current_campaign.description;
            CampaignLogo.Text        = Editor.current_campaign.logopath;
            CampaignAuthors.Text     = Editor.current_campaign.authors;
            SprintPlaylist.Checked   = Editor.current_campaign.sprint_playlist;
            OldIntro.Checked         = Editor.current_campaign.use_earlyaccess_levelintro;

            CampaignUnlockStyle.SelectedIndex = Editor.current_campaign.lockmode;
            CampaignGamemode.SelectedIndex    = GameModeId.GetIndexFromId(Editor.current_campaign.gamemode);

            Editor.current_campaign.levels.ForEach((level) => Levels.Items.Add(level));
            Editor.current_campaign.addons.ForEach((addon) => Addons.Items.Add(addon));

            UpdateOverviewList();
            #endregion

            Levels.SelectedIndex = -1;
            Addons.SelectedIndex = -1;
            Levels_SelectedIndexChanged(Levels, EventArgs.Empty);
            Addons_SelectedIndexChanged(Levels, EventArgs.Empty);
        }