Exemple #1
0
 public void CharEntered(object sender, CharacterEventArgs e)
 {
     if (!this.bIsActive || this.bInputWaiting)
     {
         return;
     }
     if (e.Character == '\b')
     {
         if (this.sInput.Length > 0)
         {
             this.sInput = this.sInput.Substring(0, this.sInput.Length - 1);
         }
         return;
     }
     if (e.Character == '\r')
     {
         this.HandleInput();
         return;
     }
     bool arg_5F_0 = e.AltPressed;
     if (this.sInput.Length >= this.iMaxLength)
     {
         return;
     }
     if (!Program.game.xInput_Menu.KeyDown(Keys.LeftControl))
     {
         this.sInput += e.Character;
     }
 }
 void EventInput_CharEntered(object sender, CharacterEventArgs e)
 {
     if (_subscriber == null)
         return;
     if (char.IsControl(e.Character))
     {
         //ctrl-v
         if (e.Character == 0x16)
         {
             //XNA runs in Multiple Thread Apartment state, which cannot recieve clipboard
             Thread thread = new Thread(PasteThread);
             thread.SetApartmentState(ApartmentState.STA);
             thread.Start();
             thread.Join();
             _subscriber.RecieveTextInput(_pasteResult);
         }
         else
         {
             _subscriber.RecieveCommandInput(e.Character);
         }
     }
     else
     {
         _subscriber.RecieveTextInput(e.Character);
     }
 }
 /// <summary>
 /// Handles the character loaded event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">Event.</param>
 protected virtual void HandleCharacterLoaded(object sender, CharacterEventArgs e)
 {
     itemManager = e.Character.GetComponentInChildren<ItemManager>();
     if (itemManager != null)
     {
         itemManager.ItemCollected += HandleItemCollected;
         itemManager.Loaded += HandleItemCollected;
         itemManager.ItemConsumed += HandleItemCollected;
         LevelManager.Instance.Respawned += HandleRespawned;
         UpdateText ();
     } else {
         Debug.LogError ("Character was loaded but not ItemManager was found");
     }
     UpdateText ();
 }
Exemple #4
0
 protected void UpdateText(object sender, CharacterEventArgs e)
 {
     if (_hasFocus)
     {
         if (e.Character == (char)Keys.Back)
         {
             if (Text.Length > 0)
             {
                 Text = Text.Remove(Text.Length - 1);
             }
         }
         else if (Text.Length < _maxTextLength)
         {
             Text += e.Character;
         }
     }
 }
Exemple #5
0
        protected void UpdateText(object sender, CharacterEventArgs e)
        {
            if (HasFocus)
            {
                if (e.Character == (char)Keys.Back)
                {
                    if (trueText.Length > 0)
                        trueText = trueText.Remove(trueText.Length - 1);
                }
                else if (trueText.Length < MaxTextLength)
                    trueText += e.Character;
            }

            Text = "";
            for (int i = 0; i < trueText.Length; i++)
                Text += '*';
        }
Exemple #6
0
 private void CharEventHandler(object sender, CharacterEventArgs eventArgs)
 {
     charEvents.Add(new CharButtonEvent(eventArgs));
 }
            void CharacterUpdate(object source, CharacterEventArgs e) {
                //Unpack the event
                int[] oldPos = e.GetOldPosition();
                int[] newPos = e.GetNewPosition();
                char avatar = e.GetAvatar();

                //Update position, if necessary
                if (oldPos != newPos) {
                    if (GameboardLocationEmpty(newPos)) {
                        //Nothing's at the target destination. Go there
                        this.grid.SetValue(avatar, newPos);

                        //Set the old position to empty
                        //But first, check that 'oldPos' is within the current gridsize, as the grid may have been respawned at a lower size than the previous coordinates
                        if (oldPos[0] < gridSize && oldPos[1] < gridSize) {
                            this.grid.SetValue('-', oldPos);
                        }
                    }
                }

            }
 public CharButtonEvent(CharacterEventArgs args)
 {
     Key = args.Character;
     Alt = args.AltPressed;
 }
Exemple #9
0
 void EventInput_CharEntered(object sender, CharacterEventArgs e)
 {
     char character = e.Character;
     if (character == 'n' && Network.JoinedGame)
     {
         Weather.Toggle();
     }
     if (acceptTextInput && activeText != null)
     {
         if (character == 8)
         {
             if (activeText.TrueContents.Length != 0)
             {
                 activeText.Contents = activeText.TrueContents.Remove(this.textEditPosition - 1, 1);
                 textEditPosition--;
             }
         }
         else if (((character > 36 && character < 126) || character == 32) && activeText.TrueContents.Length < activeText.maxLength)
         {
             if (this.textEditPosition < activeText.TrueContents.Length)
                 activeText.Contents = activeText.TrueContents.Substring(0, this.textEditPosition) +
                     character + activeText.TrueContents.Substring(this.textEditPosition);
             else
                 activeText.Contents = activeText.TrueContents.Substring(0, this.textEditPosition) + character;
             textEditPosition++;
         }
         else
         {
             activeText.ToNextBox();
         }
     }
 }
 public void CharEnteredHandler(object sender, CharacterEventArgs e)
 {
 }
Exemple #11
0
 void EventInput_CharEntered(object sender, CharacterEventArgs e)
 {
     if (isHandled || !isActive)
     {
         isHandled = false;
         return;
     }
     CommandHistory.Reset();
     switch ((int)e.Character)
     {
         case ENTER: ExecuteBuffer(); break;
         case BACKSPACE:
             if (Buffer.Output.Length > 0)
             {
                 Buffer.Output = Buffer.Output.Substring(0, Buffer.Output.Length - 1);
             }
             break;
         case TAB: AutoComplete(); break;
         default:
             if (IsPrintable(e.Character))
             {
                 Buffer.Output += e.Character;
             }
             break;
     }
 }
Exemple #12
0
 private void OnCharEntered(CharacterEventArgs e)
 {
     if (char.IsControl(e.Character)) {
         //ctrl-v
         if (e.Character == 0x16) {
             //XNA runs in Multiple Thread Apartment state, which cannot receive clipboard
             Thread thread = new Thread(PasteThread);
             thread.SetApartmentState(ApartmentState.STA);
             thread.Start();
             thread.Join();
             ReceiveTextInput(_pasteResult);
         }
         else {
             ReceiveCommandInput(e.Character);
         }
     }
     else {
         ReceiveTextInput(e.Character);
     }
 }
        private void CharacterEntered(object sender, CharacterEventArgs e)
        {
            StringBuilder selected;
            switch (selection)
            {
                case SelectedString.userName:
                    selected = userName;
                    break;
                case SelectedString.hostName:
                    selected = hostName;
                    break;
                case SelectedString.port:
                    selected = port;
                    break;
                default:
                    selected = null;
                    break;
            }

            // Add key to text buffer. If not a symbol key.
            if (!((int)e.Character < 32 || (int)e.Character > 126)) //From space to tilde
            {
                // Capitals are already supported in DLL so we don't have to worry about checking shift
                if (!(Keyboard.GetState().IsKeyDown(Keys.LeftControl) || Keyboard.GetState().IsKeyDown(Keys.RightControl)))
                {
                    selected.Append(e.Character);
                }
            }

            // Backspace - remove character if there are any
            if ((int)e.Character == 0x08 && selected.Length > 0)
            {
                selected.Remove(selected.Length - 1, 1);
            }
        }
 public static void EventInput_CharEntered(object sender, char c, int lParam)
 {
     CharacterEventArgs e = new CharacterEventArgs(c, lParam);
     if(char.IsControl(e.Character)) {
         if(ReceiveCommand != null) {
             ReceiveCommand(sender, e);
         }
     }
     else {
         if(ReceiveChar != null) {
             ReceiveChar(sender, e);
         }
     }
 }
 /// <summary>
 /// Handles the character being loaded.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">Event args.</param>
 protected virtual void HandleCharacterLoaded(object sender, CharacterEventArgs e)
 {
     characterHealth = e.Character.GetComponent<CharacterHealth>();
     if (characterHealth == null) Debug.LogWarning ("The loaded character doesn't have a character health!");
 }
Exemple #16
0
 private void EventInput_CharEntered(object sender, CharacterEventArgs e)
 {
     if (e.Character == '\b' && GetTextboxByID(FocusedTextbox).Text.Length > 0)
     {
         GetTextboxByID(FocusedTextbox).Text = GetTextboxByID(FocusedTextbox).Text.Substring(0, GetTextboxByID(FocusedTextbox).Text.Length - 1);
     }
     else
     {
         if (e.Character != '\r' && e.Character != '\b' && e.Character != '\t' && (int) e.Character != 27)
         {
             GetTextboxByID(FocusedTextbox).Text += e.Character;
         }
     }
 }