Exemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            if (Root.WasKeyPressed(Keys.Enter, ModifierKey.Alt))
            {
                graphics.ToggleFullScreen();
            }

            InputTextBox.Update();
            if (InputTextBox.Text != OldInputText)
            {
                OldInputText     = InputTextBox.Text;
                ChosenSuggestion = 0;
            }
            if (Root.WasKeyPressed(Keys.Down))
            {
                ChosenSuggestion++;
                if (ChosenSuggestion >= Math.Min(maxsuggestioncount, AvailableCommands.Count))
                {
                    ChosenSuggestion = 0;
                }
            }
            if (Root.WasKeyPressed(Keys.Up))
            {
                ChosenSuggestion--;
                if (ChosenSuggestion < 0)
                {
                    ChosenSuggestion = Math.Min(maxsuggestioncount, AvailableCommands.Count) - 1;
                }
            }
            CurrentSuggestions = new List <Command>();
            foreach (Command c in AvailableCommands)
            {
                if (c.TotalString.ToUpper().Contains(InputTextBox.Text.ToUpper()))
                {
                    CurrentSuggestions.Add(c);
                }
            }
            if (InputTextBox.Text.ToUpper().StartsWith("FEEDBACK "))
            {
                CurrentSuggestions.Add(new Command("feedback", InputTextBox.Text.Substring("feedback ".Length)));
            }


            // Online
            if (!OnlineWorker.IsBusy)
            {
                List <string> commands = new List <string>();
                foreach (string cmd in CommandsToSendOverInternet)
                {
                    if (TrackingPermitted || cmd.ToUpper().StartsWith("FEEDBACK"))
                    {
                        commands.Add(cmd);
                    }
                }
                CommandsToSendOverInternet.Clear();
                OnlineWorker.RunWorkerAsync(commands);
            }



            Root.Update(gameTime);
            base.Update(gameTime);
        }