Exemplo n.º 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;
        }
Exemplo n.º 2
0
        private void GetText(IAsyncResult result)
        {
            try
            {
                string resultString = Guide.EndShowKeyboardInput(result);;

                if (resultString != null)
                {
                    if (resultString.Length > 10)
                    {
                        resultString = resultString.Remove(10);
                    }

                    if (resultString.Length < 3)
                    {
                        return;
                    }
                    username = resultString;
                }
                else
                {
                    username = "******";
                }
            }
            catch (Exception ex)
            {
                username = "******";
                return;
            }

            entries.Add(new highscoreEntry(username, newLevel, newTS));
            sortHighscore();
            saveHighscore();
        }
Exemplo n.º 3
0
        void keyboardCallback(IAsyncResult result)
        {
            string retval = Guide.EndShowKeyboardInput(result);

            List <HighScoreEntry> l = new List <HighScoreEntry>();

            if (retval == null)
            {
                l.Add(new HighScoreEntry("Anon.", time));
            }
            else
            {
                l.Add(new HighScoreEntry(retval, time));
                //RESET XBOX SCORES
                //l.Add(new HighScoreEntry("Anonymous", 9999999999));
                //l.Add(new HighScoreEntry("Anonymous", 9999999999));
                //l.Add(new HighScoreEntry("Anonymous", 9999999999));
                //l.Add(new HighScoreEntry("Anonymous", 9999999999));
                //l.Add(new HighScoreEntry("Anonymous", 9999999999));
                //l.Add(new HighScoreEntry("Anonymous", 9999999999));
                //l.Add(new HighScoreEntry("Anonymous", 9999999999));
                //l.Add(new HighScoreEntry("Anonymous", 9999999999));
                //l.Add(new HighScoreEntry("Anonymous", 9999999999));
                //l.Add(new HighScoreEntry("Anonymous", 9999999999));

                // Do whatever you want with the string you got from the user, which is now stored in retval
            }
            HighScore.getHighScores(MapManager.currentMap.currentMapName, raceType, l);
        }
Exemplo n.º 4
0
        private void InputHandler(IAsyncResult result)
        {
#if !WINDOWS_PHONE && !XBOX && !PSM
            var newText = Guide.EndShowKeyboardInput(result);

            m_pGuideShowHandle = null;

            if (newText != null && Text != newText)
            {
                bool canceled = false;

                ScheduleOnce(
                    time =>
                {
                    DoEndEditing(ref newText, ref canceled);

                    if (!canceled)
                    {
                        Text = newText;
                    }
                },
                    0
                    );
            }
#endif
        }
Exemplo n.º 5
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();
     }
 }
Exemplo n.º 6
0
        void TouchTextEntered(IAsyncResult result)
        {
            string typedText = Guide.EndShowKeyboardInput(result);

            InputBox.Text = typedText != null ? typedText : "";
            Close();
        }
Exemplo n.º 7
0
        /// <summary>
        /// A handler invoked after the user has enter his name.
        /// </summary>
        /// <param name="result"></param>
        private void AfterPlayerEnterName(IAsyncResult result)
        {
            // Gets the name entered
            string playerName = Guide.EndShowKeyboardInput(result);

            if (!string.IsNullOrEmpty(playerName))
            {
                // Ensure that it is valid
                if (playerName != null && playerName.Length > 15)
                {
                    playerName = playerName.Substring(0, 15);
                }

                // Puts it in high score
                HighScoreScreen.PutHighScore(playerName, GameplayScreen.FinalScore);
                HighScoreScreen.HighScoreChanged();
            }

            // Moves to the next screen
            foreach (GameScreen screen in ScreenManager.GetScreens())
            {
                screen.ExitScreen();
            }

            ScreenManager.AddScreen(new BackgroundScreen("highScoreScreen"), null);
            ScreenManager.AddScreen(new HighScoreScreen(), null);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
 /// <summary>
 /// Store the text that was typed in by the user.
 /// </summary>
 /// <param name="r">Result of the keyboard input.</param>
 protected void GetTypedChars(IAsyncResult r)
 {
     typedText = Guide.EndShowKeyboardInput(r);
     HighScoreTable.SendScore(typedText, PlayerManager.Score); //call to send the score to the database
     gameState        = GameStates.TitleScreen;                //leave the game, go to the title screen
     bannerAd.Visible = true;                                  //set the ad to visible since we are leaving the playing state
 }
Exemplo n.º 10
0
        /// <summary>
        /// Asynchronous handler for the highscore player name popup messagebox.
        /// </summary>
        /// <param name="result">The popup messagebox result. The result's
        /// AsyncState property should be true if the user successfully finished
        /// the game, or false otherwise.</param>
        private void ShowHighscorePromptEnded(IAsyncResult result)
        {
            string playerName = Guide.EndShowKeyboardInput(result);

            bool finishedGame = (bool)result.AsyncState;

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

                HighScoreScreen.PutHighScore(playerName, currentLevelNumber);
            }

            if (finishedGame)
            {
                moveToHighScore = true;
            }
            else
            {
                AudioManager.PlaySound("fail");
                isActive           = true;
                currentLevelNumber = 1;
                isLevelChange      = true;
            }
        }
Exemplo n.º 11
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);
                }
            });
        }
Exemplo n.º 12
0
        private void GetText(IAsyncResult result)
        {
            string res = Guide.EndShowKeyboardInput(result);

            Text = res != null ? res : "";
            Pos  = text.Length;
        }
Exemplo n.º 13
0
        public virtual void keyboard_done(IAsyncResult r)
        {
#if WINDOWS
            string msg = Guide.EndShowKeyboardInput(r);
            sayMessage(msg);
            SendMessage("T" + msg);
#endif
        }
Exemplo n.º 14
0
        /*
         * Updates the wating room
         */
        void UpdateWR()
        {
            KeyboardState keyState = Keyboard.GetState();

            if (networkSession.SessionState == NetworkSessionState.Playing)
            {
                beginGame();
            }


            //startgame if host
            if (keyState.IsKeyDown(Keys.S) && isHost && !isChatting)
            {
                beginGame();
            }
            //chat
            if (keyState.IsKeyDown(Keys.T) && !isChatting)
            {
                chat();
            }
            if (keyState.IsKeyDown(Keys.R) && !isChatting)
            {
                networkSession.LocalGamers[0].IsReady = true;
            }

            if (isHost)
            {
                bool start = true;
                GamerCollection <NetworkGamer> players = networkSession.AllGamers;
                for (int i = 0; i < players.Count; i++)
                {
                    if (!players[i].IsReady)
                    {
                        start = false;
                    }
                }
                if (start)
                {
                    beginGame();
                }
            }

            recievePacket();

            String inputString;

            if (KeyboardResult != null && KeyboardResult.IsCompleted)
            {
                inputString = Guide.EndShowKeyboardInput(KeyboardResult);
                if (inputString == null)
                {
                    inputString = "";
                }
                KeyboardResult = null;

                sendChatPacket(inputString);
            }
        }
Exemplo n.º 15
0
        private void GuideCallback(IAsyncResult result)
        {
            string input = Guide.EndShowKeyboardInput(result);

            Text = input;

            selectionStartIndex = selectionEndIndex = 0;
            typing = false;
        }
Exemplo n.º 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);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Gets the result text of the Guide keyboard.
        /// </summary>
        private void GuideCallback(IAsyncResult result)
        {
            string resultText = Guide.EndShowKeyboardInput(result);

            if (resultText != null)
            {
                Text = resultText;
            }
        }
Exemplo n.º 18
0
 public void EndEdit()
 {
     if (guideShowHandle != null)
     {
         #if !WINDOWS_PHONE && !ANDROID
         Guide.EndShowKeyboardInput(guideShowHandle);
         #endif
         guideShowHandle = null;
     }
 }
Exemplo n.º 19
0
        public void EndEdit()
        {
            if (m_pGuideShowHandle != null)
            {
#if !WINDOWS_PHONE && !XBOX && !PSM
                Guide.EndShowKeyboardInput(m_pGuideShowHandle);
#endif
                m_pGuideShowHandle = null;
            }
        }
Exemplo n.º 20
0
        private void HandleKeyboardInputComplete(IAsyncResult asyncResult)
        {
            var text = Guide.EndShowKeyboardInput(asyncResult);

            Text = text;

            _clickSubscription = Gestures.Subscribe(HandleClick);

            InvokeTextChanged(EventArgs.Empty);
        }
Exemplo n.º 21
0
        // Invoked after the user inputs text from the on screen keyboard
        private void InputDebugCommandCallback(IAsyncResult result)
        {
            // get the string they entered
            string cmd = Guide.EndShowKeyboardInput(result);

            // if they entered something, execute the command
            if (!string.IsNullOrEmpty(cmd))
            {
                debugSystem.DebugCommandUI.ExecuteCommand(cmd);
            }
        }
Exemplo n.º 22
0
        private void GetVirtualKeyboardResult(IAsyncResult result)
        {
            Text = Guide.EndShowKeyboardInput(result);

            if (OnVirtualKeyboardClose != null)
            {
                OnVirtualKeyboardClose.Invoke(this, EventArgs.Empty);
            }

            VirtualKeyboard = null;
        }
Exemplo n.º 23
0
 private void gotText(IAsyncResult result)
 {
     if (result.IsCompleted)
     {
         string caca = Guide.EndShowKeyboardInput(result);
         if (caca != null && caca.Count() < 11)
         {
             IsolatedStorageSettings.ApplicationSettings["player1"] = Guide.EndShowKeyboardInput(result);
         }
     }
 }
Exemplo n.º 24
0
        void ComposeCompleted(IAsyncResult textResult)
        {
            HandleError(() =>
            {
                RefreshFeed();

                string text = Guide.EndShowKeyboardInput(textResult);
                if (!string.IsNullOrWhiteSpace(text))
                {
                    Yammer.Api.BeginComposeMessage(accessToken, text, res =>
                    {
                        HandleError(() =>
                        {
                            var addedMessage = res.messages.FirstOrDefault();
                            if (addedMessage != null)
                            {
                                var users = new Dictionary <string, Yammer.Reference>();
                                foreach (var item in res.references)
                                {
                                    if (item.type == "user")
                                    {
                                        users.Add(item.id, item);
                                    }
                                }

                                var messageView = new MessageViewModel(addedMessage);
                                if (users.ContainsKey(addedMessage.sender_id))
                                {
                                    messageView.LineOne = users[addedMessage.sender_id].full_name;
                                    if (!string.IsNullOrEmpty(users[addedMessage.sender_id].mugshot_url))
                                    {
                                        messageView.Image = users[addedMessage.sender_id].mugshot_url;
                                    }
                                }

                                Dispatcher.BeginInvoke(() =>
                                {
                                    HandleError(() =>
                                    {
                                        data.MyFeedItems.Insert(0, messageView);
                                        data.CompanyFeedItems.Insert(0, new MessageViewModel {
                                            LineOne = messageView.LineOne, LineTwo = messageView.LineTwo, Date = messageView.Date, Image = messageView.Image
                                        });
                                        data.SentFeedItems.Insert(0, new MessageViewModel {
                                            LineOne = messageView.LineOne, LineTwo = messageView.LineTwo, Date = messageView.Date, Image = messageView.Image
                                        });
                                    });
                                });
                            }
                        });
                    });
                }
            });
        }
Exemplo n.º 25
0
        /// <summary>
        /// Handler launched once the user selects a location to zoom on.
        /// </summary>
        /// <param name="result">Asynchronous call result containing the text typed by the user.</param>
        private void LocationSelected(IAsyncResult result)
        {
            locationToFocusOn = Guide.EndShowKeyboardInput(result);

            if (String.IsNullOrEmpty(locationToFocusOn))
            {
                return;
            }

            // Cancel any ongoing request, or do nothing if there was none
            locationWebClient.CancelAsync();
        }
        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>");
        }
Exemplo n.º 27
0
        /// <summary>
        /// get input string from album name input dialog
        /// </summary>
        /// <param name="res"></param>
        void GetInputString(IAsyncResult res)
        {
            NewAlbumName = Guide.EndShowKeyboardInput(res);
            // check null or empty string.
            if (string.IsNullOrEmpty(NewAlbumName) ||
                string.IsNullOrWhiteSpace(NewAlbumName))
            {
                return;
            }

            Create_new_album();
        }
Exemplo n.º 28
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);
                 }
             }
         }
     }
 }
Exemplo n.º 29
0
 private void gotText(IAsyncResult result)
 {
     if (result.IsCompleted)
     {
         string caca = Guide.EndShowKeyboardInput(result);
         if (caca != null && caca.Count() < 13)
         {
             IsolatedStorageSettings.ApplicationSettings["player1"] = Guide.EndShowKeyboardInput(result);
         }
     }
     this.ExitScreen();
     ScreenManager.AddScreen(new OptionScreen());
 }
Exemplo n.º 30
0
        private void loadSearch(IAsyncResult res)
        {
            string data = Guide.EndShowKeyboardInput(res);

            if (data == null)
            {
                return;
            }
            if (data.Length <= 1)
            {
                return;
            }
            App.LatestShows.queryListing(data);
        }