Beispiel #1
0
        public override void Selected(GUI.Selection selection)
        {
            if (selection.List.IsEmpty)
            {
                return;
            }
            LogTextBox.ClearContent();
            LaunchableMapsList.HighlightCurrentItem();
            Map    map = null;
            string mapName;

            if (selection.RowIndex == 0)
            {
                mapName = Text.MainGame;
            }
            else
            {
                map     = ((GUI.SelectableMap)selection.SelectedItem).Map;
                mapName = map.Name;
            }
            var options = new GUI.SelectionPrompt.Options()
            {
                AllowCancel = true
            };

            if (selection.RowIndex == 0)               // main map
            {
                options.DisabledItems.Add(2);          // Disable "Set Startup Level"
            }
            else
            {
                if (string.IsNullOrEmpty(map.StartupLevel))
                {
                    options.DisabledItems.Add(1);                     // Disable "New Game"
                }
                if (!Program.saveManagerWindow.MapHasSave(map))
                {
                    options.DisabledItems.Add(0);                     // Disable "Continue"
                }
            }
            int response = SelectionPrompt.PromptSelection(
                new string[] { Text.Continue, Text.NewGame, Text.SetStartupLevel },
                options);

            switch (response)
            {
            case 0:                     // Continue
                try {
                    if (Program.manageSaves &&
                        Program.saveManagerWindow.GetCurrentSavedMapName() != mapName)
                    {
                        LogTextBox.WriteLine(Text.PreparingSaveFile);
                        Program.saveManagerWindow.SwapSaves(mapName);
                    }
                    LaunchGame(null);
                } catch (Exception e) {
                    LogTextBox.WriteLine(string.Format(Text.ErrorWithMessage, e.Message));
                }
                break;

            case 1:                     // New Game
                try {
                    if (Program.manageSaves)
                    {
                        LogTextBox.WriteLine(Text.BackingUpCurrentSave);
                        Program.saveManagerWindow.BackupCurrentSave();
                        Program.saveManagerWindow.SetCurrentSave(mapName);
                    }
                    LaunchGame((selection.RowIndex == 0) ? null : map);
                } catch (Exception e) {
                    LogTextBox.WriteLine(string.Format(Text.ErrorWithMessage, e.Message));
                }
                break;

            case 2:                     // Set Startup Level
                SetStartupLevel(map);
                DetailsTextBox.WriteLongMapInfo(map);
                break;
            }
            LaunchableMapsList.SelectCurrentItem();
        }
Beispiel #2
0
 public override void Show()
 {
     LaunchableMapsList.SetItems(new string[] { Text.MainGame });
     LaunchableMapsList.AddMaps(Program.installedMaps);
     base.Show();
 }