Пример #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            /*
             *          logoTexture = Content.Load<Texture2D>("images/cannonBalls/ball_inner.png");
             *          spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
             */

            client = new XnaClient();

            renderer = new XnaRenderer(GraphicsDevice, Content, graphics, client);
            client.LoadImages(renderer);
            bool opened = false;

            client.Init(renderer, new XnaClientSettings()
            {
                GetKeyboardInput = (callback) =>
                {
                    if (opened)
                    {
                        return;
                    }
                    opened = true;
                    Guide.BeginShowKeyboardInput(PlayerIndex.One, "", "", "", (asyncer) =>
                    {
                        var endShowKeyboardInput = Guide.EndShowKeyboardInput(asyncer);
                        opened = false;
                        callback(endShowKeyboardInput);
                    }, null);
                },
                OneLayoutAtATime = true
            });
            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft;
        }
Пример #2
0
        private void ShowGuide(PlayerIndex?allowedPlayer)
        {
#if XNA
            Guide.BeginShowKeyboardInput(
                allowedPlayer.HasValue ? allowedPlayer.Value : PlayerIndex.One,
                GuideTitle ?? string.Empty,
                GuideDescription ?? string.Empty,
                Text ?? string.Empty,
                GuideCallback,
                null,
                IsPassword);
#else
            KeyboardInput.Show(GuideTitle ?? string.Empty,
                               GuideDescription ?? string.Empty,
                               Text ?? string.Empty,
                               IsPassword)
            .ContinueWith(task =>
            {
                if (task.Result != null)
                {
                    Text = task.Result;
                }
            });
#endif
        }
Пример #3
0
        public void BeginTyping(PlayerIndex player)
        {
            typing = true;
#if !WINDOWS
            Guide.BeginShowKeyboardInput(player, title, description, text.ToString(), GuideCallback, null);
#endif
        }
Пример #4
0
        /// <summary>
        /// Finish the current game
        /// </summary>
        private void FinishCurrentGame()
        {
            IsActive = false;

            foreach (GameScreen screen in ScreenManager.GetScreens())
            {
                screen.ExitScreen();
            }

            if (HighScoreScreen.IsInHighscores(gameTime))
            {
                // Show the device's keyboard
                Guide.BeginShowKeyboardInput(PlayerIndex.One,
                                             "Player Name", "Enter your name (max 15 characters)", "Player", (r) =>
                {
                    string playerName = Guide.EndShowKeyboardInput(r);

                    if (playerName != null && playerName.Length > 15)
                    {
                        playerName = playerName.Substring(0, 15);
                    }

                    HighScoreScreen.PutHighScore(playerName, gameTime);

                    ScreenManager.AddScreen(new BackgroundScreen(), null);
                    ScreenManager.AddScreen(new HighScoreScreen(), null);
                }, null);
                return;
            }

            ScreenManager.AddScreen(new BackgroundScreen(), null);
            ScreenManager.AddScreen(new HighScoreScreen(), null);
        }
Пример #5
0
        /// <summary>
        /// Advance to the gameplay screen on a tap.
        /// </summary>
        /// <param name="input">Player input information.</param>
        public override void HandleInput(InputState input)
        {
            if (input.IsPauseGame(null))
            {
                ExitScreen();

                ScreenManager.AddScreen(new MainMenuScreen(), null);
            }

            if (!isExit)
            {
                if (input.Gestures.Count > 0 &&
                    input.Gestures[0].GestureType == GestureType.Tap)
                {
                    if (askName)
                    {
                        Guide.BeginShowKeyboardInput(PlayerIndex.One, "Enter your name", String.Empty, "Player1",
                                                     EnterNameDialogEnded, null);
                    }
                    else
                    {
                        isExit = true;
                    }
                }
            }
        }
Пример #6
0
 /// <summary>
 /// Draw the keyboard onto the screen.
 /// </summary>
 private void ShowKeyboard()
 {
     kbResult = Guide.BeginShowKeyboardInput(PlayerIndex.One,
                                             "Keyboard Touch Input", "Please type your nickname",
                                             ((typedText == null) ? "" : typedText),
                                             GetTypedChars, null);
 }
Пример #7
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            client = new XnaClient();

            renderer = new XnaRenderer(GraphicsDevice, Content, graphics, client);
            client.LoadImages(renderer);
            bool opened = false;

            client.Init(renderer, new XnaClientSettings()
            {
                OneLayoutAtATime = true,
                GetKeyboardInput = (callback) =>
                {
                    if (opened)
                    {
                        return;
                    }
                    opened = true;
                    Guide.BeginShowKeyboardInput(PlayerIndex.One, "", "", "", (asyncer) =>
                    {
                        var endShowKeyboardInput = Guide.EndShowKeyboardInput(asyncer);
                        opened = false;
                        callback(endShowKeyboardInput);
                    }, null);
                }
            });
        }
Пример #8
0
        /// <summary>
        /// Starts new level or exit to High Score
        /// </summary>
        /// <param name="input"></param>
        private void StartNewLevelOrExit(InputState input)
        {
            // If there is no next level - go to high score screen
            if (!difficultyMode.HasValue)
            {
                // If is in high score, gets is name
                if (GameplayScreen.FinalScore != 0 && HighScoreScreen.IsInHighscores(GameplayScreen.FinalScore))
                {
                    Guide.BeginShowKeyboardInput(PlayerIndex.One,
                                                 "Player Name", "What is your name (max 15 characters)?", "Player",
                                                 AfterPlayerEnterName, null);
                }
                else
                {
                    foreach (GameScreen screen in ScreenManager.GetScreens())
                    {
                        screen.ExitScreen();
                    }

                    ScreenManager.AddScreen(new BackgroundScreen("highScoreScreen"), null);
                    ScreenManager.AddScreen(new HighScoreScreen(), null);
                }
            }
            // If not already loading
            else if (!isLoading)
            {
                // Start loading the resources in an additional thread
                thread = new Thread(new ThreadStart(gameplayScreen.LoadAssets));

                isLoading = true;
                thread.Start();
            }
        }
Пример #9
0
 private void UpdateViaXboxVirtualKeyboard(GameTime gameTime)
 {
     if (VirtualKeyboard == null)
     {
         VirtualKeyboard = Guide.BeginShowKeyboardInput(GameEnvironment.PlayerIndex, Title, Description, DefaultText, GetVirtualKeyboardResult, null);
     }
 }
Пример #10
0
        /// <summary>
        /// Handle the input of the sample.
        /// </summary>
        private void HandleInput()
        {
            // Read all gesture
            while (TouchPanel.IsGestureAvailable)
            {
                GestureSample sample = TouchPanel.ReadGesture();

                if (switchViewButton.HandleInput(sample))
                {
                    return;
                }

                if (sample.GestureType == GestureType.Tap)
                {
                    if (!Guide.IsVisible)
                    {
                        Guide.BeginShowKeyboardInput(PlayerIndex.One, "Select location", "Type in a location to focus on.",
                                                     String.Empty, LocationSelected, null);
                    }
                }
                else if (sample.GestureType == GestureType.FreeDrag)
                {
                    // Move the map when dragging
                    bingMapsViewer.MoveByOffset(sample.Delta);
                }
            }
        }
Пример #11
0
        private void NameInput(CCObject p_Sender)
        {
            IAsyncResult result = Guide.BeginShowKeyboardInput(PlayerIndex.One, sipTitle, sipDescription,
                                                               sipResult, UserInputCallBack, new object());

            m_Image = p_Sender as CCMenuItemImage;
        }
Пример #12
0
 private void HandleGuide(PlayerIndex pi)
 {
     if (Manager.UseGuide && !Guide.IsVisible)
     {
         Guide.BeginShowKeyboardInput(pi, "Enter Text", "", Text, GetText, pi.ToString());
     }
 }
Пример #13
0
 public void OnFocusChanged(FocusEvent newFocus)
 {
     IsFocused = newFocus == FocusEvent.FocusIn;
     if (IsFocused)
     {
         m_cursorBlink         = true;
         m_cursorBlinkLastTime = GameFacade.LastUpdateState.Time.TotalGameTime.Ticks;
         if (FSOEnvironment.SoftwareKeyboard && FSOEnvironment.SoftwareDepth)
         {
             try
             {
                 Guide.BeginShowKeyboardInput(PlayerIndex.One, "", "", CurrentText, (ar) =>
                 {
                     var str = Guide.EndShowKeyboardInput(ar);
                     lock (this)
                     {
                         QueuedChange = str;
                     }
                 }, null);
             }
             catch (Exception e) { }
         }
     }
     else
     {
         m_cursorBlink  = false;
         SelectionEnd   = -1;
         SelectionStart = -1;
         m_DrawDirty    = true;
         Invalidate();
     }
 }
Пример #14
0
        /// <summary>
        /// Updates the screen.
        /// </summary>
        /// <param name="gameTime">Game time information.</param>
        /// <param name="otherScreenHasFocus">Whether another screen has the focus currently.</param>
        /// <param name="coveredByOtherScreen">Whether this screen is covered by another screen.</param>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            if (isInvalidName)
            {
                isInvalidName = false;

                Guide.BeginShowKeyboardInput(PlayerIndex.One, "Enter your name", "The name is not valid.", invalidName,
                                             EnterNameDialogEnded, null);

                return;
            }

            if (isExit && !screenExited)
            {
                // Move on to the gameplay screen
                foreach (GameScreen screen in ScreenManager.GetScreens())
                {
                    screen.ExitScreen();
                }


                ScreenManager.AddScreen(new GameplayScreen(name, GameTypes.Offline), null);

                screenExited = true;
            }

            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }
Пример #15
0
 /// <summary>
 /// Handler called when the user clicks the button to search new location.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void serachButton_Click(object sender, EventArgs e)
 {
     if (!Guide.IsVisible)
     {
         Guide.BeginShowKeyboardInput(PlayerIndex.One, "Select location", "Type in a location to focus on.",
                                      String.Empty, LocationSelected, null);
     }
 }
Пример #16
0
        /// <summary>
        /// Shows the specified text, caption and default input text, and awaits for the user to reply.
        /// </summary>
        /// <param name="text">The message to display.</param>
        /// <param name="caption">The title of the input box.</param>
        /// <param name="defaultText">The default text displayed in the input area when the interface dialog box is first shown.</param>
        /// <param name="usePasswordMode">true if password mode is enabled; otherwise, false.</param>
        /// <param name="textInputed">The <see cref="T:Action{string}" /> to be called once the operation is finished.</param>
        public void Show(string text, string caption, string defaultText, bool usePasswordMode, Action <string> textInputed)
        {
            Guide.BeginShowKeyboardInput(PlayerIndex.One, caption, text, defaultText, ar =>
            {
                text = Guide.EndShowKeyboardInput(ar);

                Deployment.Current.Dispatcher.BeginInvoke(() => textInputed(text));
            }, null, usePasswordMode);
        }
Пример #17
0
        /// <summary>
        /// Launches a dialog for entering a name when creating a new game.
        /// </summary>
        /// <param name="description">Description to display for the dialog.</param>
        /// <param name="defaultName">Default name to display in the dialog.</param>

        private void EnterGameName(string description, string defaultName)
        {
            while (Guide.IsVisible)
            {
            }

            Guide.BeginShowKeyboardInput(PlayerIndex.One, "Enter game name", description,
                                         defaultName, EnterGameNameDialogEnded, null);
        }
Пример #18
0
        void HandleTouchInput()
        {
            // Read Gestures.
            while (TouchPanel.IsGestureAvailable)
            {
                GestureSample gesture = TouchPanel.ReadGesture();

                switch (gesture.GestureType)
                {
                case GestureType.Tap:
                    // if the user tapped and the debug command UI is focused,
                    // show the keyboard input
                    if (debugSystem.DebugCommandUI.Focused && !Guide.IsVisible)
                    {
                        Guide.BeginShowKeyboardInput(
                            PlayerIndex.One,
                            "Input Debug Command",
                            "type debug command\n" +
                            "'help' command shows available commands",
                            "",
                            InputDebugCommandCallback,
                            null);
                    }
                    break;

                case GestureType.Flick:
                    // if the user flicked, we determine the angle of the flick and
                    // use that to either show or hide the debug command UI
                    if (gesture.Delta.Length() > 5)
                    {
                        const float cos30 = 0.87f;
                        Vector2     nd    = Vector2.Normalize(gesture.Delta);

                        // Same as "Vector2.Dot(new Vector2(0,1), nd)" that
                        // returns flick angle.
                        float dot = -nd.Y;

                        if (debugSystem.DebugCommandUI.Focused)
                        {
                            if (dot > cos30)
                            {
                                debugSystem.DebugCommandUI.Hide();
                            }
                        }
                        else
                        {
                            if (dot < -cos30)
                            {
                                debugSystem.DebugCommandUI.Show();
                            }
                        }
                    }
                    break;
                }
            }
        }
Пример #19
0
        void OnSaveButtonClick(object sender, EventArgs args)
        {
            DateTime dt       = DateTime.Now;
            string   filename =
                String.Format("spinpaint-{0:D2}-{1:D2}-{2:D2}-{3:D2}-{4:D2}-{5:D2}",
                              dt.Year % 100, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second);

            Guide.BeginShowKeyboardInput(PlayerIndex.One, "spin paint save file",
                                         "enter filename:", filename, KeyboardCallback, null);
        }
Пример #20
0
        public virtual void ShowChat()
        {
#if WINDOWS
            if (!Guide.IsVisible)
            {
                Guide.BeginShowKeyboardInput(PlayerIndex.One, "Chat", "Enter your message",
                                             "", new AsyncCallback(keyboard_done), null);
            }
#endif
        }
Пример #21
0
        /// <summary>
        /// Check for the back button to exit the app, and see if a touch occurred
        /// on one of the images.
        /// </summary>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            // check for touch input
            while (TouchPanel.IsGestureAvailable)
            {
                GestureSample gesture = TouchPanel.ReadGesture();

                // The text input dialog can allow input to occur between when it closes and when the
                // callback occurs, so the game guards against processing input in this state with a
                // simple flag.
                if (gesture.GestureType == GestureType.Tap && !imageSaveInProgress)
                {
                    Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);

                    // An image touch triggersGuide.BeginShowKeyboardInput to receive
                    // a filename.  A hit-test determines which image was touched, and
                    // the callback is different depending on the source of the image.

                    if (gameProjectImageBounds.Contains(tapLocation))
                    {
                        imageSaveInProgress = true;

                        Guide.BeginShowKeyboardInput(
                            0,
                            "Save Picture",
                            "Enter a filename for your image",
                            "gameProjectImage",
                            SaveGameProjectImageCallback,
                            null);
                    }

                    if (contentProjectImageBounds.Contains(tapLocation))
                    {
                        imageSaveInProgress = true;

                        Guide.BeginShowKeyboardInput(
                            0,
                            "Save Picture",
                            "Enter a filename for your image",
                            "contentProjectImage",
                            SaveContentProjectImageCallback,
                            null);
                    }
                }
            }

            base.Update(gameTime);
        }
Пример #22
0
 /**
  * Implementation of chat input
  */
 void chat()
 {
     isChatting = true;
     try
     {
         KeyboardResult = Guide.BeginShowKeyboardInput(PlayerIndex.One, "Chat", "", "", null, null);
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e.Message);
     }
 }
Пример #23
0
        /// <summary>
        /// Perform update logic.
        /// </summary>
        /// <param name="gameTime">Game time information.</param>
        /// <param name="otherScreenHasFocus">Whether another screen has the focus.</param>
        /// <param name="coveredByOtherScreen">Whether this screen is covered by another.</param>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

            if (isInvalidName)
            {
                isInvalidName = false;

                Guide.BeginShowKeyboardInput(PlayerIndex.One, "Enter your name", "The name is not valid.", invalidName,
                                             EnterNameDialogEnded, null);
            }
        }
        private void TestShowKeyboardInput(string title, string description, string defaultText)
        {
            var result = Guide.BeginShowKeyboardInput(
                PlayerIndex.One,
                title,
                description,
                defaultText,
                Guide_ShowKeyboardInputCallback, null);

            _labelEndShowKeyboardInput.Text =
                "EndShow: " + (Guide.EndShowKeyboardInput(result) ?? "<null>");
        }
Пример #25
0
 /// <summary>
 /// Checks if the text input is touched and if it is, then opens the virtual keyboard
 /// </summary>
 /// <param name="touchLocation">The touch location</param>
 public void Update(TouchLocation touchLocation)
 {
     if (destination.Contains(new Point((int)touchLocation.Position.X,
                                        (int)touchLocation.Position.Y)))
     {
         if (touchLocation.State == TouchLocationState.Pressed)
         {
             if (!Guide.IsVisible)
             {
                 if (Text == HintText)
                 {
                     Guide.BeginShowKeyboardInput(PlayerIndex.One, "Moto Trial Racer",
                                                  HintText, "",
                                                  delegate(IAsyncResult result)
                     {
                         String tempText = Guide.EndShowKeyboardInput(result);
                         if (tempText != null)
                         {
                             if (tempText == "")
                             {
                                 Text = HintText;
                             }
                             else
                             {
                                 Text = tempText;
                             }
                         }
                     }, null);
                 }
                 else
                 {
                     Guide.BeginShowKeyboardInput(PlayerIndex.One, "Moto Trial Racer",
                                                  HintText, Text,
                                                  delegate(IAsyncResult result)
                     {
                         String tempText = Guide.EndShowKeyboardInput(result);
                         if (tempText != null)
                         {
                             if (tempText == "")
                             {
                                 Text = HintText;
                             }
                             else
                             {
                                 Text = tempText;
                             }
                         }
                     }, null);
                 }
             }
         }
     }
 }
Пример #26
0
 /// <summary>
 /// Respond to "Online Game" Item Selection
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void OnlineGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     if (NetworkManager.Instance.name == null || NetworkManager.Instance.name == "")
     {
         Guide.BeginShowKeyboardInput(PlayerIndex.One, "Enter your name", String.Empty, "Player1",
                                      EnterNameDialogEnded, null);
     }
     else
     {
         ExitScreen();
         ScreenManager.AddScreen(new SelectOnlineGameScreen(NetworkManager.Instance.name), null);
     }
 }
Пример #27
0
        // Adds a score to the highscore board
        public void addHighscoreEntry(int level, TimeSpan ts)
        {
            newLevel = level;
            newTS    = ts;

            // Try to get user input
            try
            {
                Guide.BeginShowKeyboardInput(PlayerIndex.One, "You got a new highscore!", "Please enter a name for the scoreboard (Minimum 3 and no longer than 10 characters)", username, GetText, null);
            }
            catch (Exception ex)
            {
            }
        }
Пример #28
0
        protected override void pointerPressed(int x, int y)
        {
            if (uiDialog.Visible)
            {
                uiDialog.TestHit(x, y);
                return;
            }

            switch (State)
            {
            case LeaderboardState.Fill:
                if (btnSubmit.TestHit(x, y))
                {
                    return;
                }

                if (recUsername.Contains(x, y))
                {
                    if (!Guide.IsVisible)
                    {
                        Guide.BeginShowKeyboardInput(PlayerIndex.One,
                                                     Localize.Instance.NameEntry,
                                                     Localize.Instance.EnterName,
                                                     (_username != DEFAULT_NAME) ? _username : "",
                                                     new AsyncCallback(gotName),
                                                     this);
                    }

                    return;
                }
                break;

            case LeaderboardState.View:
                if (y > 134)
                {
                    if (x < 400 && allowLeftTouch)
                    {
                        leftTouching = true;
                        vOffset      = y - (int)vtView7.Y;
                    }
                    else if (allowRightTouch)
                    {
                        rightTouching = true;
                        vOffset       = y - (int)vtViewAll.Y;
                    }
                }
                break;
            }
        }
Пример #29
0
        /// <summary>
        /// Finish the current game
        /// </summary>
        private void FinishCurrentGame()
        {
            isActive = false;

            if (HighScoreScreen.IsInHighscores(currentLevelNumber))
            {
                // Show the device's keyboard to enter a name for the highscore
                Guide.BeginShowKeyboardInput(PlayerIndex.One,
                                             Constants.HighscorePopupTitle, Constants.HighscorePopupText,
                                             Constants.HighscorePopupDefault, ShowHighscorePromptEnded, true);
            }
            else
            {
                moveToHighScore = true;
            }
        }
Пример #30
0
        private void HandleClick(Gesture gesture)
        {
            if (_clickSubscription != null)
            {
                _clickSubscription.Dispose();
            }

            if (!Guide.IsVisible)
            {
                Guide.BeginShowKeyboardInput(
                    PlayerIndex.One,
                    GuideTitle,
                    GuideDescription,
                    Text, HandleKeyboardInputComplete, null);
            }
        }