Пример #1
0
        public override void Selected(GUI.Selection selection)
        {
            bool promptQuit = false;

            GUI.ListBox listBox = selection.RowIndex switch
            {
                0 => BackedUpLevelsList,
                1 => BackedUpScriptsList,
                _ => throw new NotImplementedException(),
            };
            CommandsList.HighlightCurrentItem();
            listBox.Clear();
            listBox.Draw();
            listBox.NavigateToDefault();
            while (!promptQuit)
            {
                var subSelection = BackedUpLevelsList.PromptSelection();
                if (subSelection.Command == Properties.Command.Cancel)
                {
                    promptQuit = true;
                }
            }

            CommandsList.SelectCurrentItem();
            DetailsTextBox.Clear();
            WriteSummary();
        }
Пример #2
0
        public virtual void Show()
        {
            Menu.NavigateToDefault();
            DrawAll();
            WindowQuit = false;
            while (!WindowQuit)
            {
                GUI.Selection selection = Menu.PromptSelection();
                switch (selection.Command)
                {
                case Properties.Command.Confirm:
                    if (selection.List != null && selection.SelectedItem != null)
                    {
                        Selected(selection);
                    }
                    break;

                case Properties.Command.Cancel:
                    Program.currentWindow = Program.navigationWindow;
                    WindowQuit            = true;
                    break;
                }

                if (!WindowQuit)
                {
                    WindowQuit = ChangeWindow(selection.Command);
                }
            }
        }
Пример #3
0
        public void Show()
        {
            GUI.Reset();
            windowsMenu.NavigateToDefault();
            DrawAll();
            windowQuit = false;
            while (!windowQuit)
            {
                GUI.Selection selection = windowsMenu.PromptSelection();
                switch (selection.Command)
                {
                case Properties.Command.Confirm:
                    windowQuit = true;
                    switch (selection.RowIndex)
                    {
                    case 0:
                        Program.currentWindow = Program.launcherWindow;
                        break;

                    case 1:
                        Program.currentWindow = Program.mapInstallerWindow;
                        break;

                    case 2:
                        Program.currentWindow = Program.saveManagerWindow;
                        break;

                    case 3:
                        Program.currentWindow = Program.backupsWindow;
                        break;

                    case 4:
                        Program.currentWindow = Program.mapEditorWindow;
                        break;

                    default:
                        windowQuit = false;
                        break;
                    }
                    break;

                case Properties.Command.Cancel:
                    windowQuit   = true;
                    Program.quit = true;
                    break;
                }

                if (!windowQuit)
                {
                    windowQuit = DefaultWindow.ChangeWindow(selection.Command);
                }
            }
        }
Пример #4
0
        public void SetStartupLevel(Map map)
        {
            StartupLevelList.SetItems(map.GetLevelsWithoutExtension());
            StartupLevelList.Clear();
            StartupLevelList.Draw();
            StartupLevelList.Select(0);

            GUI.Selection selection = StartupLevelList.PromptSelection();
            switch (selection.Command)
            {
            case Properties.Command.Confirm:
                map.StartupLevel = selection.Text;
                Program.SaveInstalledMaps();
                break;

            case Properties.Command.Cancel:
                break;
            }

            StartupLevelList.Clear();
        }
Пример #5
0
        public override void Selected(GUI.Selection selection)
        {
            if (selection.List.IsEmpty)
            {
                return;
            }
            LogTextBox.ClearContent();

            switch (selection.RowIndex)
            {
            case 0:                     // Backup current map
                LogTextBox.WriteLine(Text.BackingUpCurrentSave);
                BackupCurrentSave();
                RefreshInfo();
                WriteSummary();
                LogTextBox.WriteLine(string.Format(Text.BackedUpMap, currentSavedMapName));
                break;

            case 1:                     // View backups...
                CommandsList.HighlightCurrentItem();
                ShowBackups();
                CommandsList.SelectCurrentItem();
                break;

            case 2:
                if (Program.manageSaves)
                {
                    Program.manageSaves = false;
                    LogTextBox.WriteLine(Text.DisabledManageSaves);
                }
                else
                {
                    Program.manageSaves = true;
                    LogTextBox.WriteLine(Text.EnabledManageSaves);
                }
                Program.SaveSettings();
                WriteSummary();
                break;
            }
        }
Пример #6
0
 public abstract void Selected(GUI.Selection selection);
Пример #7
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();
        }
Пример #8
0
        public override void Selected(GUI.Selection selection)
        {
            selection.SelectedItem.Highlight();

            if (selection.ColumnIndex == 0)               // Installed Maps -> Uninstall
            {
                var selectedMap = Program.installedMaps[selection.RowIndex];
                LogTextBox.ClearContent();
                string[] selections;
                var      options = new GUI.SelectionPrompt.Options()
                {
                    AllowCancel = true,
                };
                if (selectedMap.IsValid)
                {
                    selections = new string[] { Text.Uninstall };
                }
                else
                {
                    selections    = new string[] { Text.Uninstall, Text.ShowIssues };
                    options.Index = 1;
                }
                int response = SelectionPrompt.PromptSelection(selections, options);
                switch (response)
                {
                case 0:
                    if (selectedMap.IsWIP)
                    {
                        LogTextBox.WriteLine(Text.CantUninstallWIP);
                        ignoreNextSelectionChangedEvent = true;
                    }
                    else
                    {
                        var currentRow = Menu.CurrentRow;
                        UninstallMap(selectedMap);
                        bool keepIgnoringSelectionChanged = ignoreNextSelectionChangedEvent;
                        if (InstalledMapsList.CanNavigate)
                        {
                            InstalledMapsList.Select(currentRow);
                        }
                        else
                        {
                            Menu.NavigateToDefault();
                        }
                        ignoreNextSelectionChangedEvent = keepIgnoringSelectionChanged;
                    }
                    break;

                case 1:
                    selectedMap.ShowIssues();
                    DrawAll();
                    break;
                }
            }
            else if (selection.ColumnIndex == 1)                 // Available Maps -> Install/Reinstall/Overwrite
            {
                var selectedLoadableMap = Program.availableMaps[selection.RowIndex];
                var alreadyInstalledMap = FindInstalledMap(selectedLoadableMap.Name);
                if (alreadyInstalledMap != null)                   // If the map is already installed
                {
                    LogTextBox.ClearContent();
                    LogTextBox.WriteLine(string.Format(Text.PromptReinstall, alreadyInstalledMap.Name));
                    string[] selections;
                    var      options = new GUI.SelectionPrompt.Options()
                    {
                        AllowCancel = true,
                    };
                    if (selectedLoadableMap.IsValid)
                    {
                        selections = new string[] { Text.Reinstall };
                    }
                    else
                    {
                        selections    = new string[] { Text.Reinstall, Text.ShowIssues };
                        options.Index = 1;
                    }
                    int response = SelectionPrompt.PromptSelection(selections, options);
                    switch (response)
                    {
                    case 0:
                        ReinstallMap(alreadyInstalledMap, selectedLoadableMap);
                        break;

                    case 1:
                        selectedLoadableMap.ShowIssues();
                        DrawAll();
                        break;

                    default:
                        LogTextBox.WriteShortMapInfo(selectedLoadableMap);
                        break;
                    }
                }
                else if (VerifyNothingOverwritten(selectedLoadableMap))
                {
                    LogTextBox.ClearContent();
                    string[] selections;
                    var      options = new GUI.SelectionPrompt.Options()
                    {
                        AllowCancel = true,
                    };
                    if (selectedLoadableMap.IsValid)
                    {
                        selections = new string[] { Text.Install };
                    }
                    else
                    {
                        selections    = new string[] { Text.Install, Text.ShowIssues };
                        options.Index = 1;
                    }
                    int response = SelectionPrompt.PromptSelection(selections, options);
                    switch (response)
                    {
                    case 0:
                        InstallMap(selectedLoadableMap, false);
                        break;

                    case 1:
                        selectedLoadableMap.ShowIssues();
                        DrawAll();
                        break;

                    default:
                        LogTextBox.WriteShortMapInfo(selectedLoadableMap);
                        break;
                    }
                }
            }
            selection.List.Select(selection.RowIndex);
        }
Пример #9
0
        private void EditLevels(Map map)
        {
            RefreshLevelList(map);
            levelList.NavigateToDefault();
            bool quitPrompt = false;

            while (!quitPrompt)
            {
                GUI.Selection selection = levelList.PromptSelection();
                switch (selection.Command)
                {
                case Properties.Command.Confirm:
                    switch (selection.RowIndex)
                    {
                    case 0:                                     // Add New Level
                        if (levelNameInput.PromptText())
                        {
                            LogTextBox.ClearContent();
                            string levelName = levelNameInput.Text;
                            // Check if level already exists
                            string levelDestination  = Path.Combine(Program.installedLevelsPath, levelName + Program.LevelFileExtension);
                            string scriptDestination = Path.Combine(Program.installedScriptsPath, levelName + Program.ScriptFileExtension);
                            if (File.Exists(levelDestination) || File.Exists((scriptDestination)))
                            {
                                LogTextBox.WriteLine(string.Format(Text.LevelOrScriptAlreadyExists, levelName + Program.LevelFileExtension, levelName + Program.ScriptFileExtension));
                            }
                            else
                            {
                                File.Copy(Program.emptyLevelTemplatePath, levelDestination);
                                File.Copy(Program.emptyScriptTemplatePath, scriptDestination);
                                map.AddLevel(levelName);
                                Program.SaveInstalledMaps();
                                RefreshLevelList(map);
                                LogTextBox.WriteLine(string.Format(Text.AddedLevel, levelName));
                            }
                        }
                        break;

                    case 1:                                     // Assign Existing Levels
                        LogTextBox.Clear();
                        AssignExistingLevels(map);
                        assignedLevelsList.Clear();
                        LogTextBox.Draw();
                        break;

                    case 2:                                     // Separator
                        break;

                    default:                                     // Level
                        LogTextBox.ClearContent();
                        string selectedLevelName = selection.Text;
                        string currentLevelName  = selectedLevelName + Program.LevelFileExtension;
                        string currentScriptName = selectedLevelName + Program.ScriptFileExtension;
                        string levelSource       = Path.Combine(Program.installedLevelsPath, currentLevelName);
                        string scriptSource      = Path.Combine(Program.installedScriptsPath, currentScriptName);

                        switch (SelectionPrompt.PromptSelection(levelCommands, true))
                        {
                        case 0:                                                 // Rename
                            levelRenameInput.Top = levelList.Top + selection.RowIndex;
                            bool renamed = levelRenameInput.PromptText(new GUI.TextInput.PromptOptions(false, true, false, selectedLevelName));
                            if (renamed)
                            {
                                string newLevelName      = levelRenameInput.Text;
                                string levelDestination  = Path.Combine(Program.installedLevelsPath, newLevelName + Program.LevelFileExtension);
                                string scriptDestination = Path.Combine(Program.installedScriptsPath, newLevelName + Program.ScriptFileExtension);
                                if (File.Exists(levelDestination) || File.Exists((scriptDestination)))
                                {
                                    LogTextBox.WriteLine(string.Format(Text.LevelOrScriptAlreadyExists, newLevelName + Program.LevelFileExtension, newLevelName + Program.ScriptFileExtension));
                                }
                                else
                                {
                                    try {
                                        map.RenameLevel(selectedLevelName, newLevelName);
                                        File.Move(levelSource, levelDestination);
                                        File.Move(scriptSource, scriptDestination);
                                        Program.SaveInstalledMaps();
                                        RefreshLevelList(map);
                                    } catch (Exception e) {
                                        LogTextBox.WriteLine(string.Format(Text.ErrorWithMessage, e.Message));
                                        if (File.Exists(levelDestination))
                                        {
                                            LogTextBox.WriteLine(string.Format(Text.RevertLevelRename, currentLevelName));
                                            File.Move(levelDestination, levelSource);
                                            LogTextBox.AppendLastLine(Text.Renamed);
                                        }
                                        if (File.Exists(scriptDestination))
                                        {
                                            LogTextBox.WriteLine(string.Format(Text.RevertScriptRename, currentScriptName));
                                            File.Move(scriptDestination, scriptSource);
                                            LogTextBox.AppendLastLine(Text.Renamed);
                                        }
                                    }
                                }
                            }
                            break;

                        case 1:                                                 // Delete
                            LogTextBox.WriteLine(string.Format(Text.ConfirmDelete, currentLevelName, currentScriptName));
                            LogTextBox.WriteLine(Text.AreYouSureYouWantToContinue);
                            LogTextBox.WriteLine(Text.UnassignInsteadOfDelteInstructions);
                            int confirmation = SelectionPrompt.PromptSelection(confirmDeleteCommands, new GUI.SelectionPrompt.Options()
                            {
                                AllowCancel = true, Index = 1
                            });
                            if (confirmation == 0)                                                       // Confirmed deletion
                            {
                                try {
                                    LogTextBox.ClearContent();
                                    map.RemoveLevel(selectedLevelName);
                                    Program.SaveInstalledMaps();
                                    LogTextBox.WriteLine(string.Format(Text.Deleting, currentLevelName));
                                    File.Delete(levelSource);
                                    LogTextBox.AppendLastLine(Text.Deleted);
                                    LogTextBox.WriteLine(string.Format(Text.Deleting, currentScriptName));
                                    File.Delete(scriptSource);
                                    LogTextBox.AppendLastLine(Text.Deleted);
                                } catch (Exception e) {
                                    LogTextBox.WriteLine(string.Format(Text.ErrorWithMessage, e.Message));
                                }
                                RefreshLevelList(map);
                            }
                            break;
                        }
                        break;
                    }

                    levelList.SelectCurrentItem();
                    break;

                case Properties.Command.Cancel:
                    quitPrompt = true;
                    break;
                }
            }
        }
Пример #10
0
        public override void Selected(GUI.Selection selection)
        {
            switch (selection.RowIndex)
            {
            case 0:
                ShowOnlyWIPCheckBox.Checked = !ShowOnlyWIPCheckBox.Checked;
                RefreshMapList();
                mapList.NavigateToDefault();
                break;

            case 1:
                if (NewMapNameInput.PromptText())
                {
                    var newMap = new Map(
                        NewMapNameInput.Text,
                        null,
                        null,
                        null,
                        null,
                        new string[0],
                        new string[0],
                        true);
                    Program.installedMaps.Add(newMap);
                    Program.SaveInstalledMaps();
                    RefreshMapList();
                }
                mapList.Select(mapList.Items.Count - 1);
                break;

            case 2:                     // Separator
                break;

            default:
                mapList.HighlightCurrentItem();
                var      selectedMap = (GUI.SelectableMap)(selection.SelectedItem);
                var      map         = selectedMap.Map;
                string[] selections;
                var      options = new GUI.SelectionPrompt.Options()
                {
                    AllowCancel = true,
                };
                if (map.IsValid)
                {
                    selections = mapCommands;
                }
                else
                {
                    selections    = mapCommandsWithIssues;
                    options.Index = 3;
                }

                int response = SelectionPrompt.PromptSelection(selections, options);
                switch (response)
                {
                case 0:                                 // Edit Map Info
                    EditMapInfo(map);
                    break;

                case 1:                                 // Edit Levels
                    EditLevels(map);
                    mapList.Clear();
                    mapList.Draw();
                    break;

                case 2:                                 // Export
                    PromptExportMap(map);
                    break;

                case 3:                                 // Show Issues
                    map.ShowIssues();
                    DrawAll();
                    break;
                }

                mapList.SelectCurrentItem();
                break;
            }
        }