Inheritance: Knot3.Framework.Widgets.Dialog, IKeyEventListener
Ejemplo n.º 1
0
        public void OnChallengeFinished(GameTime time)
        {
            playerKnotInput.IsEnabled = false;
            challengeKnotInput.IsEnabled = false;
            // erstelle einen Dialog zum Eingeben des Spielernamens
            TextInputDialog nameDialog = new TextInputDialog (screen: this, drawOrder: DisplayLayer.Dialog,
                    title: "Challenge", text: "Your name:",
                    inputText: Config.Default ["profile", "name", String.Empty]);
            // füge ihn zur Spielkomponentenliste hinzu
            nameDialog.NoCloseEmpty = true;
            nameDialog.NoWhiteSpace = true;
            nameDialog.Text = "Press Enter to submit your name. ";

            AddGameComponents (time, nameDialog);

            Action<GameTime> openHighscoreDialog = (t) => {
                // erstelle einen Highscoredialog
                Dialog highscoreDialog = new HighscoreDialog (screen: this, drawOrder: DisplayLayer.Dialog, challenge: Challenge);
                // füge ihn zur Spielkomponentenliste hinzu
                AddGameComponents (time, highscoreDialog);
            };

            // wenn der Dialog geschlossen wird...
            nameDialog.Submit += (t) => {
                Challenge.AddToHighscore (name: nameDialog.InputText, time: (int)playTime.TotalSeconds);
                openHighscoreDialog (t);
            };
            nameDialog.Cancel += (t) => {
                openHighscoreDialog (t);
            };

            Undo.Clear ();
            Redo.Clear ();

            RemoveGameComponents (time, undoButton);
            RemoveGameComponents (time, undoButtonBorder);
            RemoveGameComponents (time, redoButton);
            RemoveGameComponents (time, redoButtonBorder);
        }
Ejemplo n.º 2
0
 private void KnotSaveAs(Action onClose, GameTime time)
 {
     TextInputDialog saveDialog = new TextInputDialog (
         screen: Screen,
         drawOrder: DisplayLayer.Dialog,
         title: "Save Knot",
         text: "Name:",
         inputText: knot.Name != null ? knot.Name : String.Empty
     );
     saveDialog.NoCloseEmpty = true;
     saveDialog.NoWhiteSpace = true;
     saveDialog.Text = "Press Enter to save the Knot.";
     Screen.AddGameComponents (null, saveDialog);
     saveDialog.Submit += (t) => {
         try {
             knot.Name = saveDialog.InputText;
             knot.Save (false);
             onClose ();
         }
         catch (FileAlreadyExistsException) {
             ConfirmDialog confirm = new ConfirmDialog (
                 screen: Screen,
                 drawOrder: DisplayLayer.Dialog,
                 title: "Warning",
                 text: "Do you want to overwrite the existing knot?"
             );
             confirm.Cancel += (l) => {
                 KnotSaveAs (() => onClose (), time);
             };
             confirm.Submit += (r) => {
                 knot.Save (true);
                 onClose ();
             };
             Screen.AddGameComponents (null, confirm);
         }
     };
 }