Exemple #1
0
        async void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new CommonOpenFileDialog
            {
                Title            = Properties.Resources.Common_OpenFileDialog_Title_LoadSetting,
                IsFolderPicker   = false,
                InitialDirectory = startupPath,
                DefaultDirectory = startupPath,
            };

            dialog.Filters.Add(new CommonFileDialogFilter(Properties.Resources.Common_OpenFileDialog_FileType_Json, "*.json"));
            dialog.Filters.Add(new CommonFileDialogFilter(Properties.Resources.Common_OpenFileDialog_FileType_All, "*.*"));

            if (vm.WorkingDirectory != string.Empty)
            {
                dialog.InitialDirectory = vm.WorkingDirectory;
            }

            if (dialog.ShowDialog() != CommonFileDialogResult.Ok)
            {
                return;
            }

            if (File.Exists(dialog.FileName))
            {
                vm.LoadSetting(dialog.FileName);
            }
            else
            {
                var overwriteDialog = new OneButtonDialog(Properties.Resources.Dialog_FileNotExists_Title, Properties.Resources.Dialog_FileNotExists_Message_SettingFile);
                await parentView.dialogHostMain.ShowDialog(overwriteDialog);
            }
        }
Exemple #2
0
        async void StartButton_Click(object sender, RoutedEventArgs e)
        {
            // Working directory is empty
            if (string.IsNullOrEmpty(vm.WorkingDirectory))
            {
                var overwriteDialog = new OneButtonDialog(Properties.Resources.Dialog_DirectoryEmpty_Title, Properties.Resources.Dialog_DirectoryEmpty_Message_WorkingDirectory);
                await parentView.dialogHostMain.ShowDialog(overwriteDialog);

                return;
            }

            // Output file is empty
            if (string.IsNullOrEmpty(vm.OutputFile))
            {
                var overwriteDialog = new OneButtonDialog(Properties.Resources.Dialog_FileNameEmpty_Title, Properties.Resources.Dialog_FileNameEmpty_Message_OutputFile);
                await parentView.dialogHostMain.ShowDialog(overwriteDialog);

                return;
            }

            // Output file already exists
            if (File.Exists(vm.OutputFile))
            {
                var overwriteDialog = new TwoButtonDialog(
                    Properties.Resources.Dialog_FileExists_Title,
                    Path.GetFileName(vm.OutputFile) + " " + Properties.Resources.Dialog_FileExists_Message + Environment.NewLine + Properties.Resources.Dialog_FileExists_Message_Overwrite,
                    Properties.Resources.Common_Yes,
                    Properties.Resources.Common_No);
                var result = await parentView.dialogHostMain.ShowDialog(overwriteDialog) as Selected?;

                if (result == Selected.Negative)
                {
                    return;
                }
            }

            // Start
            var processingDialog = new ProcessingDialogDetail(Properties.Resources.Dialog_Processing_Title, Properties.Resources.Dialog_Processing_Started);
            var re = parentView.dialogHostMain.ShowDialog(processingDialog, async(object s, DialogOpenedEventArgs args) =>
            {
                processingDialog.Button.IsEnabled = false;
                processingDialog.Button.IsEnabled = false;
                await vm.StartAsync();

                processingDialog.Message.Content             = Properties.Resources.Dialog_Processing_Completed;
                processingDialog.ProgressBar.IsIndeterminate = false;
                processingDialog.Button.IsEnabled            = true;
            });
        }
Exemple #3
0
        async void CheckForUpdate_Click(object sender, RoutedEventArgs e)
        {
            string newVersion = null;

            var processingDialog = new ProcessingDialog(Properties.Resources.MsgBox_CheckForUpdates_Title, Properties.Resources.MsgBox_CheckForUpdates_Message);
            await parentView.dialogHostMain.ShowDialog(processingDialog, async (object s, DialogOpenedEventArgs args) =>
            {
                newVersion = await vm.CheckForUpdate();
                args.Session.Close(false);
            });

            if (newVersion == null)
            {
                var okdialog = new OneButtonDialog(Properties.Resources.MsgBox_NotFound_Title, Properties.Resources.MsgBox_NotFound_Message);
                await parentView.dialogHostMain.ShowDialog(okdialog);

                return;
            }

            NewVersionFound(newVersion);
        }
 private void HandleStairs(StairMovement s)
 {
     StairMovmentType stairMovement = m_engine.GameState.IsStairMovementSpecial(s == m_engine.Actions.MoveUpStairs);
     switch (stairMovement)
     {
         case StairMovmentType.QuitGame:
         {
             string text = "Leaving the dungeon will end the game early and delete your current character. To stop playing now and continue your adventure later, use save instead.";
             TwoButtonDialog d = new TwoButtonDialog(m_window, text);
             d.Closed += (o, e) =>
             {
                 if (((TwoButtonDialog)o).DialogResult == true)
                 {
                     // Do quit here? How do you quit SL? go back to main menu?
                 }
             };
             d.Show();
             break;
         }
         case StairMovmentType.WinGame:
         {
             // Don't save if player closes window with dialog up.
             // m_gameInstance.ShouldSaveOnClose = false;
             string text = "Congratulations, you have completed the magecrawl tech demo! " + m_engine.Player.Name + " continues on without you in search of further treasure and fame. Consider telling your story to others, including the creator.";
             OneButtonDialog d = new OneButtonDialog(m_window, text);
             d.Closed += (o, e) =>
             {
                 // Do quit here? How do you quit SL? go back to main menu?
             };
             d.Show();
             break;
         }
         case StairMovmentType.None:
         {
             s();
             m_window.UpdateWorld();
             return;
         }
     }
 }