public void Update()
        {
            KeyboardState state = Keyboard.GetState();

            Keys[] pressedKeys = state.GetPressedKeys();
            //iterate through pressed keys. if key is in dict, execute mapped command
            for (int i = 0; i < pressedKeys.Length; i++)
            {
                LastKey = pressedKeys[0];
                Microsoft.Xna.Framework.Input.Keys key = pressedKeys[i];
                ICommand command;
                //check that lookup was successful before executing
                bool validKey = this.CommandDict.TryGetValue(key, out command);
                if (validKey)
                {
                    command.Execute();
                }
            }

            for (int i = 0; i < UsedKeys.Count; i++)
            {
                if (!KeyPressed((Keys)UsedKeys[i], pressedKeys))
                {
                    ICommand command;
                    if (this.UnpressedCommandDict.TryGetValue((Keys)UsedKeys[i], out command))
                    {
                        command.Execute();
                    }
                }
            }
        }
예제 #2
0
        internal override bool HandleKey(object sender, Microsoft.Xna.Framework.Input.Keys k, bool first)
        {
            if (InputControl.TextBox.ImeActive || (InputControl.TextBox.ImeDeactivateTime > 0 && GameBase.Time - InputControl.TextBox.ImeDeactivateTime < ChatEngine.ImeCheckDelay))
            {
                return(true);
            }

            if (!HasFocus)
            {
                return(false);
            }

            if (KeyboardHandler.ControlPressed)
            {
                switch (k)
                {
                case Keys.C:
                case Keys.X:
                    return(InputControl.TextBox.SelectionLength > 0);

                case Keys.A:
                    return(Text.Length > 0 && this == InputManager.TextBoxOmniscient);    //Handle only when chat is focused

                case Keys.V:
                    return(true);

                case Keys.Left:
                case Keys.Right:
                    return(HandleLeftRightArrows);
                }
            }

            return(false);
        }
예제 #3
0
 /// <summary>
 /// Returns a value that indicates whether the key is a shift key for
 /// this keyboard layout.
 /// </summary>
 /// <param name="key">The key to test.</param>
 /// <returns>true if key is a shift key, false otherwise.</returns>
 public bool IsShiftKey(XnaKeys key)
 {
     return(key == XnaKeys.LeftAlt || key == XnaKeys.RightShift ||
            key == XnaKeys.LeftControl || key == XnaKeys.RightControl ||
            key == XnaKeys.LeftShift || key == XnaKeys.RightAlt ||
            key == (XnaKeys)specialShiftVk);
 }
        /// <summary>
        /// Gets the character associated with the given key/shift pair.
        /// </summary>
        /// <param name="key">
        /// The key being pressed.
        /// </param>
        /// <param name="shift">
        /// Is the shift key down?.
        /// </param>
        /// <param name="capsLock">
        /// Is caps lock on?.
        /// </param>
        /// <param name="numLock">
        /// Is num lock on?.
        /// </param>
        /// <returns>
        /// The character the key/shift pair maps to.
        /// </returns>
        private char?GetCharacter(Keys key, bool shift, bool capsLock, bool numLock)
        {
            var newChar = new char?();

            if (AlphabetKeyMap.Keys.Contains(key))
            {
                var characterMap = AlphabetKeyMap[key];
                newChar = (shift ^ capsLock) ? characterMap.Item2 : characterMap.Item1;
            }
            else if (SymbolNumberKeyMap.Keys.Contains(key))
            {
                var characterMap = SymbolNumberKeyMap[key];
                newChar = shift ? characterMap.Item2 : characterMap.Item1;
            }
            else if (NumPadKeyMap.ContainsKey(key))
            {
                if (numLock)
                {
                    newChar = NumPadKeyMap[key];
                }
            }
            else if (NumPadMathKeyMap.ContainsKey(key))
            {
                newChar = NumPadMathKeyMap[key];
            }

            return(newChar);
        }
예제 #5
0
 //private static bottunNUm;// KeyMap用
 static Controller()
 {
     hasaJoystick = true;
     joysticks    = new List <DInput.Device>();
     jsStates     = new List <DInput.JoystickState>();
     V            = new Vector2();
     Initialize();
     #region ジョイスティックが無かった場合キーボードのコンフィグ設定
     if (joysticks.Count == 0)
     {
         hasaJoystick     = false;
         oldKeyboardState = xnainput.Keyboard.GetState();
         KeyboardConfig   = new xnainput.Keys[(int)config.NUM_KEY];
         KeyboardConfig[(int)config.A]     = xnainput.Keys.Z;     // □
         KeyboardConfig[(int)config.B]     = xnainput.Keys.X;     // △
         KeyboardConfig[(int)config.key3]  = xnainput.Keys.C;     // ○
         KeyboardConfig[(int)config.X]     = xnainput.Keys.A;     // ×
         KeyboardConfig[(int)config.Y]     = xnainput.Keys.F;
         KeyboardConfig[(int)config.key6]  = xnainput.Keys.V;
         KeyboardConfig[(int)config.MENU]  = xnainput.Keys.LeftShift;
         KeyboardConfig[(int)config.LOCK]  = xnainput.Keys.D;     //Space;//TODO:コンフィグが俺コントローラ仕様すぎるから変えないと。。
         KeyboardConfig[(int)config.START] = xnainput.Keys.Enter; // 追加
     }
     #endregion
 }
예제 #6
0
        internal KeyInputEditControl(KeyInputControl control)
        {
            InitializeComponent();

            // Use a lambda here so we can capture the 'control' variable
            // only for as long as needed to set our location/size.
            Load += (object sender, EventArgs e) =>
            {
                Location = control.Parent.PointToScreen(control.Location);
                Size     = control.Size;
                textBox.Focus();
                HookKeyboard();
            };

            FormClosed += (object sender, FormClosedEventArgs e) =>
            {
                UnhookKeyboard();
            };

            liveInput  = control.UserInput;
            isModifier = liveInput.IsModifier;

#pragma warning disable IDE0008 // Use explicit type
            var input = UserCommandInput.DecomposeUniqueDescriptor(liveInput.UniqueDescriptor);
#pragma warning restore IDE0008 // Use explicit type
            shift        = input.Shift;
            this.control = input.Control;
            alt          = input.Alt;
            scanCode     = input.ScanCode;
            virtualKey   = (Xna.Keys)input.VirtualKey;

            UpdateText();
        }
예제 #7
0
        private bool MoveImage(XnaKeys keys)
        {
            if (mSelectedDrawnAnimation == -1 || mSelectedFrame == -1)
            {
                return(false);
            }

            if (keys == XnaKeys.Up)
            {
                SelectedImage.Offset.ReduceY();
            }
            else if (keys == XnaKeys.Down)
            {
                SelectedImage.Offset.AddY();
            }
            else if (keys == XnaKeys.Left)
            {
                SelectedImage.Offset.ReduceX();
            }
            else if (keys == XnaKeys.Right)
            {
                SelectedImage.Offset.AddX();
            }

            return(true);
        }
예제 #8
0
        /// <summary>
        /// All keys except A-Z, 0-9 and `-\[];',./= (and space) are special keys.
        /// With shift pressed this also results in this keys:
        /// </summary>
        internal static bool IsSpecialKey(Keys key)
        {
            // All keys except A-Z, 0-9 and `-\[];',./= (and space) are special keys.
            // With shift pressed this also results in this keys:
            // ~_|{}:"<>? !@#$%^&*().
            int keyNum = (int)key;

            if ((keyNum >= (int)Keys.A && keyNum <= (int)Keys.Z) ||
                (keyNum >= (int)Keys.D0 && keyNum <= (int)Keys.D9) ||
                key == Keys.Space ||            // well, space ^^
                key == Keys.OemTilde ||         // `~
                key == Keys.OemMinus ||         // -_
                key == Keys.OemPipe ||          // \|
                key == Keys.OemOpenBrackets ||  // [{
                key == Keys.OemCloseBrackets || // ]}
                key == Keys.OemQuotes ||        // '"
                key == Keys.OemQuestion ||      // /?
                key == Keys.OemPlus ||
                key == Keys.OemSemicolon ||
                key == Keys.OemComma ||
                key == Keys.OemPeriod) // =+
            {
                return(false);
            }

            return(true);
        }
예제 #9
0
        private void InputManager_KeyPressedCallback(Microsoft.Xna.Framework.Input.Keys key)
        {
            if (HasKeyboardFocus && IsEditable)
            {
                if (key == Keys.Back || key == Keys.Delete)
                {
                    if (Text.Length > 0)
                    {
                        Text  = Text.Remove(Carat - 1, 1);
                        Carat = MathFunctions.Clamp(Carat - 1, 0, Text.Length);
                    }
                }
                else if (key == Keys.Left)
                {
                    Carat = MathFunctions.Clamp(Carat - 1, 0, Text.Length);
                }
                else if (key == Keys.Right)
                {
                    Carat = MathFunctions.Clamp(Carat + 1, 0, Text.Length);
                }
                else
                {
                    char k = ' ';
                    if (InputManager.TryConvertKeyboardInput(key, Keyboard.GetState().IsKeyDown(Keys.LeftShift) || Keyboard.GetState().IsKeyDown(Keys.RightShift), out k))
                    {
                        Text  = Text.Insert(Carat, k.ToString());
                        Carat = MathFunctions.Clamp(Carat + 1, 0, Text.Length);
                    }
                }

                OnTextModified.Invoke(Text);
            }
        }
예제 #10
0
        public override void OnKeyDown(Microsoft.Xna.Framework.Input.Keys key)
        {
            switch (key)
            {
            case Keys.Left:
            {
                GoLeftOnce();
            }
            break;

            case Keys.Right:
            {
                GoRightOnce();
            }
            break;

            case Keys.Enter:
            {
                if (OnSelect != null)
                {
                    OnSelect();
                }
            }
            break;
            }

            base.OnKeyDown(key);
        }
예제 #11
0
        //Updating states (called from ControlsManager)
        public void UpdateKeyState(Keys key, KeyState state)
        {
            if (key == Keys.None || KeyStates[key] == state && !_alwaysNotify) return;

            KeyStates[key] = state;
            _doNotify = true;
        }
예제 #12
0
        internal override bool OnKey(Keys k, bool first)
        {
            if (k == Keys.M && KeyboardHandler.ControlPressed)
            {
                BeatSnapSong();
                return(true);
            }

            if (k == Keys.L && !KeyboardHandler.ControlPressed)
            {
                BeatShiftCircle(0);
                return(true);
            }

            if (k == Keys.T && first)
            {
                tapWindow.Tap();
                return(true);
            }

            if (k == Keys.R)
            {
                TimingReset();
                return(true);
            }

            return(base.OnKey(k, first));
        }
예제 #13
0
        static JoyStick()
        {
            hasaJoyStick = true;
            JoystickState jss = JoystickInput.GetAsJoystickState(0);

            if (!jss.IsConnected)
            {
                hasaJoyStick = false;
            }

            #region ジョイスティックが無かった場合キーボードのコンフィグ設定
            if (!hasaJoyStick)
            {
                oldKeyboardState = xnainput.Keyboard.GetState();
                KeyboardConfig   = new xnainput.Keys[(int)config.NUM_KEY];
                KeyboardConfig[(int)config.A]     = xnainput.Keys.Z;     // □
                KeyboardConfig[(int)config.B]     = xnainput.Keys.X;     // △
                KeyboardConfig[(int)config.key3]  = xnainput.Keys.C;     // ○
                KeyboardConfig[(int)config.X]     = xnainput.Keys.A;     // ×
                KeyboardConfig[(int)config.Y]     = xnainput.Keys.F;
                KeyboardConfig[(int)config.key6]  = xnainput.Keys.V;
                KeyboardConfig[(int)config.MENU]  = xnainput.Keys.LeftShift;
                KeyboardConfig[(int)config.LOCK]  = xnainput.Keys.Space; //Space;//TODO:コンフィグが俺コントローラ仕様すぎるから変えないと。。
                KeyboardConfig[(int)config.START] = xnainput.Keys.Enter; // 追加
            }
            #endregion
        }
예제 #14
0
 public void keyboardButtonClicked(Microsoft.Xna.Framework.Input.Keys buttonPressed)
 {
     if (buttonPressed.Equals(Microsoft.Xna.Framework.Input.Keys.OemPlus))
     {
         this.zoom += 0.1f;
         if (this.zoom > 1.5f)
         {
             this.zoom = 1.5f;
         }
     }
     if (buttonPressed.Equals(Microsoft.Xna.Framework.Input.Keys.OemMinus))
     {
         this.zoom -= 0.1f;
         if (this.zoom < 0.5f)
         {
             this.zoom = 0.5f;
         }
     }
     if (buttonPressed.Equals(Microsoft.Xna.Framework.Input.Keys.Z))
     {
         if (this.zoom == 0.1f)
         {
             this.zoom = 1.0f;
         }
         else
         {
             this.zoom = 0.1f;
         }
     }
 }
예제 #15
0
 public override void KeyboardCallback(Microsoft.Xna.Framework.Input.Keys key, int x, int y, GameTime gameTime, bool released, ref Microsoft.Xna.Framework.Input.KeyboardState newState, ref Microsoft.Xna.Framework.Input.KeyboardState oldState)
 {
     base.KeyboardCallback(key, x, y, gameTime, released, ref newState, ref oldState);
     if (key == Keys.V && released)
     {
         DropBall();
     }
 }
예제 #16
0
        private void HandleKey(Microsoft.Xna.Framework.Input.Keys key)
        {
            string textToAdd = "";

            if (keyName.Length == 1 && (font.MeasureString(text).X < DrawRectangle.Width - (TEXT_EDGE_SPACING_X * 4)))
            {
                if (!(keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightControl) || keyboard.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl)))
                {
                    if (!NumbersOnly)
                    {
                        if (HoldingShift(keyboard))
                        {
                            textToAdd = HandleShift(keyboard, key);
                        }
                        else
                        {
                            textToAdd = keyName.ToLower();
                        }
                    }
                }
            }
            else if (key == Microsoft.Xna.Framework.Input.Keys.Space &&
                     (font.MeasureString(text).X < DrawRectangle.Width - (TEXT_EDGE_SPACING_X * 4)))
            {
                if (!NumbersOnly)
                {
                    textToAdd = " ";
                }
            }
            else if (key == Microsoft.Xna.Framework.Input.Keys.Back && text.Length > 0 && cursorPosition > 0)
            {
                cursorPosition--;
                text = text.Remove(cursorPosition, 1);
            }
            else if (key == Microsoft.Xna.Framework.Input.Keys.Delete && text.Length > 0 && cursorPosition < text.Length)
            {
                // We've hit the delete key and are not on the last character of the string
                text = text.Remove(cursorPosition, 1);
            }
            else if (key == Microsoft.Xna.Framework.Input.Keys.Enter)
            {
                onEnterPress?.Invoke(text);
            }
            else if (keyName.Length > 1 && (font.MeasureString(text).X < DrawRectangle.Width - (TEXT_EDGE_SPACING_X * 4)))
            {
                textToAdd = HandleSymbol(key, keyboard);
            }

            // This is for arrow key support
            if (!(font.MeasureString(text + textToAdd).X > DrawRectangle.Width))
            {
                text = text.Insert(cursorPosition, textToAdd);

                cursorPosition   += textToAdd.Length;
                cursorRectangle.X = DrawRectangle.X + ((int)font.MeasureString(text.Substring(0, cursorPosition)).X + cursorRectangle.Width);
            }
        }
예제 #17
0
 private void Keyboard_KeyUp(object sender, KeyboardKeyEventArgs e)
 {
     Microsoft.Xna.Framework.Input.Keys keys = KeyboardUtil.ToXna(e.Key);
     if (!this.keys.Contains(keys))
     {
         return;
     }
     this.keys.Remove(keys);
 }
예제 #18
0
 /// <summary>
 /// Changes the order of starting points such that the starting
 /// point under mouse cursor is moved to a given index.
 /// </summary>
 private void ReorderStartingPoint(Keys key, int index, AxialCoord mouseHex, List <AxialCoord> hoverList)
 {
     if (InputManager.Instance.IsKeyJustPressed(key))
     {
         var tmp = hoverList[index];
         var i   = hoverList.IndexOf(mouseHex);
         hoverList[index] = hoverList[i];
         hoverList[i]     = tmp;
     }
 }
예제 #19
0
파일: Keyboard.cs 프로젝트: patridge/Gum
 public bool KeyPushed(Microsoft.Xna.Framework.Input.Keys key)
 {
     if (mControl.Focused)
     {
         return(mKeyboardState.IsKeyDown(key) && !mLastKeyboardState.IsKeyDown(key));
     }
     else
     {
         return(false);
     }
 }
예제 #20
0
        private Button AddKey(XNA.Keys key)
        {
            var driver = new KeyboardDriver(key);
            var k      = new Button(driver);

            keys[key] = k;
            keylist.Add(key);
            allKeys.Add(k);

            return(k);
        }
예제 #21
0
 public bool doesInputListContain(InputButton[] list, Microsoft.Xna.Framework.Input.Keys key)
 {
     for (int index = 0; index < list.Length; ++index)
     {
         if (list[index].key == key)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #22
0
        public override void OnKeyDown(Microsoft.Xna.Framework.Input.Keys key)
        {
            // HACK Write keydowns to debug box for debug purposes. Change key handling for proper release.
            System.Diagnostics.Debug.WriteLine(key.ToString());


            if (key.Equals(Keys.Back) && !keyboardHandler.Typing)
            {
                currentGame.screenManager.FocusScreen(GameScreen.TITLE_MAINMENU);
            }
        }
예제 #23
0
 public bool isKeyInUse(Microsoft.Xna.Framework.Input.Keys key)
 {
     foreach (InputButton allUsedInputButton in this.getAllUsedInputButtons())
     {
         if (allUsedInputButton.key == key)
         {
             return(true);
         }
     }
     return(false);
 }
        private int VirtualKeyToScancode(Keys key)
        {
            var sc = MonoGameSquidRenderer.VirtualKeyToScancode((int)key);

            if (_specialKeys.ContainsKey(key))
            {
                sc = _specialKeys[key];
            }

            return(sc);
        }
예제 #25
0
        public void AddListener(Keys k, InputState inputState, Action a)
        {
            var e = new Event(k, inputState, a);

            if (mEvents.Contains(e))
            {
                return;
            }

            mEvents.Add(e);
        }
예제 #26
0
        private void KeyPressHandler(Keys key, KeyModifier modifier)
        {
            if ((key == Keys.Escape) && finalized)
            {
                this.Exit();
            }

            if ((key == Keys.Enter || key == Keys.Space) && useImageSequence && !finalized)
            {
                calibrateNextSequence = true;
            }
        }
예제 #27
0
        void InputManager_KeyReleasedCallback(Microsoft.Xna.Framework.Input.Keys key)
        {
            if (!IsActiveState)
            {
                return;
            }

            if (key == Keys.Escape)
            {
                back_OnClicked();
            }
        }
예제 #28
0
        private void InputManager_KeyPressedCallback(Microsoft.Xna.Framework.Input.Keys key)
        {
            if (!HasKeyboardFocus || !IsEditable)
            {
                return;
            }
            Keys prevKey = Key;

            Key  = key;
            Text = key.ToString();
            OnTextModified.Invoke(Text);
            OnKeyModified.Invoke(prevKey, Key, this);
        }
예제 #29
0
        protected override void Update(GameTime gameTime)
        {
            KeyboardState ks = new KeyboardState();

            Keys[] keys = ks.GetPressedKeys();

            if (ks.IsKeyUp(lastKey))
            {
                lastKey = Keys.None;
            }

            if (keys.Length > 0 && lastKey == Keys.None)
            {
                lastKey = keys[0];
                var keyValue = keys[0].ToString();
                Sgml.keyboard_string += keyValue;
            }

            MousePositionTranslated = cam.Camera.ScreenToWorld(MousePosition);
            GridSizeRender          = new Vector2(SimplexMath.Lerp(GridSizeRender.X, GridSize.X, 0.2f), SimplexMath.Lerp(GridSizeRender.Y, GridSize.Y, 0.2f));

            Input.KeyboardState = ks;

            g = gameTime;
            base.Update(gameTime);

            cam.UpdatePosition();

            foreach (RoomLayer rl in roomLayers)
            {
                if (rl.Visible)
                {
                    if (rl is ObjectLayer)
                    {
                        foreach (GameObject o in ((ObjectLayer)rl).Objects)
                        {
                            if (o.Position.X != o.PositionPrevious.X || o.Position.Y != o.PositionPrevious.Y)
                            {
                                sh.UnregisterObject(o);
                                sh.RegisterObject(o);
                            }

                            if (GameRunning || o == clickedObject)
                            {
                                o.EvtStep();
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Modifies the StringBuilder based on the pressed key.
        /// </summary>
        /// <param name="key">
        /// The key being pressed.
        /// </param>
        /// <param name="shift">
        /// Is the shift key down or capslock on?.
        /// </param>
        /// <param name="capsLock">
        /// Is caps lock on?.
        /// </param>
        /// <param name="numLock">
        /// Is num lock on?.
        /// </param>
        /// <param name="text">
        /// The StringBuilder to be modified.
        /// </param>
        private void ProcessKey(Keys key, bool shift, bool capsLock, bool numLock, StringBuilder text)
        {
            if (key == Keys.Back && text.Length > 0)
            {
                text = text.Remove(text.Length - 1, 1);
            }

            var newChar = GetCharacter(key, shift, capsLock, numLock);

            if (newChar.HasValue)
            {
                text.Append(newChar.Value);
            }
        }
예제 #31
0
파일: Keyboard.cs 프로젝트: patridge/Gum
 public bool KeyDown(Microsoft.Xna.Framework.Input.Keys key)
 {
     if (mControl == null)
     {
         throw new Exception("The Keyboard must be initialized before calling KeyDown");
     }
     if (mControl.Focused)
     {
         return(mKeyboardState.IsKeyDown(key));
     }
     else
     {
         return(false);
     }
 }
예제 #32
0
 /// <summary>
 ///     Gets the key state for the specified keyboard key.
 /// </summary>
 /// <param name="key">Requested key.</param>
 /// <returns>State of the requested key.</returns>
 public KeyboardKey this[Keys key]
 {
     get { return keys[key]; }
     internal set { keys[key] = value; }
 }
예제 #33
0
파일: Main.cs 프로젝트: NoviaDroid/Terraria
		protected override void Update(GameTime gameTime)
		{
			Main.ignoreErrors = true;
			Main.gameInactive = !base.IsActive;
			if (Main.netMode == 2)
			{
				Main.cloudAlpha = Main.maxRaining;
			}
			if (base.IsActive && Main.cloudAlpha > 0f)
			{
				Rain.MakeRain();
			}
			if (Main.netMode != 1)
			{
				this.updateCloudLayer();
			}
			this.UpdateWeather();
			Main.Ambience();
			if (Main.netMode != 2)
			{
				if (Main.ignoreErrors)
				{
					try
					{
						Main.snowing();
						goto IL_76;
					}
					catch
					{
						goto IL_76;
					}
				}
				Main.snowing();
			}
			IL_76:
			if (Main.chTitle)
			{
				Main.chTitle = false;
				this.SetTitle();
			}
			Stopwatch stopwatch = new Stopwatch();
			stopwatch.Start();
			WorldGen.destroyObject = false;
			if (Main.gameMenu)
			{
				Main.mapFullscreen = false;
			}
			if (Main.dedServ)
			{
				if (Main.dedServFPS)
				{
					Main.updateTime++;
					if (!Main.fpsTimer.IsRunning)
					{
						Main.fpsTimer.Restart();
					}
					if (Main.fpsTimer.ElapsedMilliseconds >= 1000L)
					{
						Main.dedServCount1 += Main.updateTime;
						Main.dedServCount2++;
						float num = (float)Main.dedServCount1 / (float)Main.dedServCount2;
						Console.WriteLine(string.Concat(new object[]
						{
							Main.updateTime,
							"  (",
							num,
							")"
						}));
						Main.updateTime = 0;
						Main.fpsTimer.Restart();
					}
				}
				else
				{
					if (Main.fpsTimer.IsRunning)
					{
						Main.fpsTimer.Stop();
					}
					Main.updateTime = 0;
				}
			}
			if (!Main.dedServ)
			{
				if (Main.superFast)
				{
					base.IsFixedTimeStep = false;
					Main.graphics.SynchronizeWithVerticalRetrace = false;
				}
				else
				{
					if (Main.fixedTiming)
					{
						if (base.IsActive)
						{
							base.IsFixedTimeStep = false;
						}
						else
						{
							base.IsFixedTimeStep = true;
						}
					}
					else
					{
						base.IsFixedTimeStep = true;
						Main.graphics.SynchronizeWithVerticalRetrace = true;
					}
					Main.graphics.SynchronizeWithVerticalRetrace = true;
				}
				if (Main.treeMntBG[1] == 94 || (Main.treeMntBG[1] >= 114 && Main.treeMntBG[1] <= 116))
				{
					Main.bgFrameCounter[0]++;
					if (Main.bgFrameCounter[0] >= 6)
					{
						Main.bgFrameCounter[0] = 0;
						Main.bgFrame[0]++;
						if (Main.bgFrame[0] >= 4)
						{
							Main.bgFrame[0] = 0;
						}
					}
					if (Main.bgFrame[0] == 0)
					{
						Main.treeMntBG[1] = 94;
					}
					else
					{
						if (Main.bgFrame[0] == 1)
						{
							Main.treeMntBG[1] = 114;
						}
						else
						{
							if (Main.bgFrame[0] == 2)
							{
								Main.treeMntBG[1] = 115;
							}
							else
							{
								Main.treeMntBG[1] = 116;
							}
						}
					}
					if (Main.bgFrame[0] == 0)
					{
						Main.treeMntBG[0] = 93;
					}
					else
					{
						if (Main.bgFrame[0] == 1)
						{
							Main.treeMntBG[0] = 168;
						}
						else
						{
							if (Main.bgFrame[0] == 2)
							{
								Main.treeMntBG[0] = 169;
							}
							else
							{
								Main.treeMntBG[0] = 170;
							}
						}
					}
				}
				if (Main.treeMntBG[1] >= 180 && Main.treeMntBG[1] <= 183)
				{
					Main.bgFrameCounter[0]++;
					if (Main.bgFrameCounter[0] >= 6)
					{
						Main.bgFrameCounter[0] = 0;
						Main.bgFrame[0]++;
						if (Main.bgFrame[0] >= 4)
						{
							Main.bgFrame[0] = 0;
						}
					}
					if (Main.bgFrame[0] == 0)
					{
						Main.treeMntBG[1] = 180;
					}
					else
					{
						if (Main.bgFrame[0] == 1)
						{
							Main.treeMntBG[1] = 181;
						}
						else
						{
							if (Main.bgFrame[0] == 2)
							{
								Main.treeMntBG[1] = 182;
							}
							else
							{
								Main.treeMntBG[1] = 183;
							}
						}
					}
				}
				this.UpdateMusic();
				if (Main.showSplash)
				{
					return;
				}
				if (!Main.gameMenu && Main.netMode == 1)
				{
					if (!Main.saveTime.IsRunning)
					{
						Main.saveTime.Start();
					}
					if (Main.saveTime.ElapsedMilliseconds > 300000L)
					{
						Main.saveTime.Reset();
						WorldGen.saveToonWhilePlaying();
					}
				}
				else
				{
					if (!Main.gameMenu && Main.autoSave)
					{
						if (!Main.saveTime.IsRunning)
						{
							Main.saveTime.Start();
						}
						if (Main.saveTime.ElapsedMilliseconds > 600000L)
						{
							Main.saveTime.Reset();
							WorldGen.saveToonWhilePlaying();
							WorldGen.saveAndPlay();
						}
					}
					else
					{
						if (Main.saveTime.IsRunning)
						{
							Main.saveTime.Stop();
						}
					}
				}
				if (Main.teamCooldown > 0)
				{
					Main.teamCooldown--;
				}
				Main.updateTime++;
				if (Main.fpsTimer.ElapsedMilliseconds >= 1000L)
				{
					if ((float)Main.fpsCount >= 30f + 30f * Main.gfxQuality)
					{
						Main.gfxQuality += Main.gfxRate;
						Main.gfxRate += 0.005f;
					}
					else
					{
						if ((float)Main.fpsCount < 29f + 30f * Main.gfxQuality)
						{
							Main.gfxRate = 0.01f;
							Main.gfxQuality -= 0.1f;
						}
					}
					if (Main.gfxQuality < 0f)
					{
						Main.gfxQuality = 0f;
					}
					if (Main.gfxQuality > 1f)
					{
						Main.gfxQuality = 1f;
					}
					if (Main.maxQ && base.IsActive)
					{
						Main.gfxQuality = 1f;
						Main.maxQ = false;
					}
					Main.updateRate = Main.uCount;
					Main.frameRate = Main.fpsCount;
					Main.fpsCount = 0;
					Main.fpsTimer.Restart();
					Main.updateTime = 0;
					Main.drawTime = 0;
					Main.uCount = 0;
					if ((double)Main.gfxQuality < 0.8)
					{
						Main.mapTimeMax = (int)((1f - Main.gfxQuality) * 60f);
					}
					else
					{
						Main.mapTimeMax = 0;
					}
					int arg_5DA_0 = Main.netMode;
				}
				if (Main.fixedTiming)
				{
					float num2 = 16f;
					float num3 = (float)Main.updateTimer.ElapsedMilliseconds;
					if (num3 + Main.uCarry < num2 && !Main.superFast)
					{
						Main.drawSkip = true;
						return;
					}
					Main.uCarry += num3 - num2;
					if (Main.uCarry > 1000f)
					{
						Main.uCarry = 1000f;
					}
					Main.updateTimer.Restart();
				}
				Main.uCount++;
				Main.drawSkip = false;
				if (Main.qaStyle == 1)
				{
					Main.gfxQuality = 1f;
				}
				else
				{
					if (Main.qaStyle == 2)
					{
						Main.gfxQuality = 0.5f;
					}
					else
					{
						if (Main.qaStyle == 3)
						{
							Main.gfxQuality = 0f;
						}
					}
				}
				Main.numDust = (int)(6000f * (Main.gfxQuality * 0.7f + 0.3f));
				if ((double)Main.gfxQuality < 0.9)
				{
					Main.numDust = (int)((float)Main.numDust * Main.gfxQuality);
				}
				if (Main.numDust < 1000)
				{
					Main.numDust = 1000;
				}
				Gore.goreTime = (int)(600f * Main.gfxQuality);
				Liquid.maxLiquid = (int)(2500f + 2500f * Main.gfxQuality);
				Liquid.cycles = (int)(17f - 10f * Main.gfxQuality);
				if ((double)Main.gfxQuality < 0.5)
				{
					Main.graphics.SynchronizeWithVerticalRetrace = false;
				}
				else
				{
					Main.graphics.SynchronizeWithVerticalRetrace = true;
				}
				if (Main.superFast)
				{
					Main.graphics.SynchronizeWithVerticalRetrace = false;
					Main.drawSkip = false;
				}
				if ((double)Main.gfxQuality < 0.2)
				{
					Lighting.maxRenderCount = 8;
				}
				else
				{
					if ((double)Main.gfxQuality < 0.4)
					{
						Lighting.maxRenderCount = 7;
					}
					else
					{
						if ((double)Main.gfxQuality < 0.6)
						{
							Lighting.maxRenderCount = 6;
						}
						else
						{
							if ((double)Main.gfxQuality < 0.8)
							{
								Lighting.maxRenderCount = 5;
							}
							else
							{
								Lighting.maxRenderCount = 4;
							}
						}
					}
				}
				if (Liquid.quickSettle)
				{
					Liquid.maxLiquid = Liquid.resLiquid;
					Liquid.cycles = 1;
				}
				if (!base.IsActive)
				{
					Main.hasFocus = false;
				}
				else
				{
					Main.hasFocus = true;
				}
				if (!Main.gameMenu || Main.netMode == 2)
				{
					WorldFile.tempRaining = Main.raining;
					WorldFile.tempRainTime = Main.rainTime;
					WorldFile.tempMaxRain = Main.maxRaining;
				}
				if (!base.IsActive && Main.netMode == 0)
				{
					base.IsMouseVisible = true;
					if (Main.netMode != 2 && Main.myPlayer >= 0)
					{
						Main.player[Main.myPlayer].delayUseItem = true;
					}
					Main.mouseLeftRelease = false;
					Main.mouseRightRelease = false;
					if (Main.gameMenu)
					{
						Main.UpdateMenu();
					}
					Main.gamePaused = true;
					return;
				}
				base.IsMouseVisible = false;
				Main.CursorColor();
				Main.mouseTextColor += (byte)Main.mouseTextColorChange;
				if (Main.mouseTextColor >= 250)
				{
					Main.mouseTextColorChange = -4;
				}
				if (Main.mouseTextColor <= 175)
				{
					Main.mouseTextColorChange = 4;
				}
				Main.demonTorch += (float)Main.demonTorchDir * 0.01f;
				if (Main.demonTorch > 1f)
				{
					Main.demonTorch = 1f;
					Main.demonTorchDir = -1;
				}
				if (Main.demonTorch < 0f)
				{
					Main.demonTorch = 0f;
					Main.demonTorchDir = 1;
				}
				int num4 = 7;
				if (this.DiscoStyle == 0)
				{
					Main.DiscoG += num4;
					if (Main.DiscoG >= 255)
					{
						Main.DiscoG = 255;
						this.DiscoStyle++;
					}
				}
				if (this.DiscoStyle == 1)
				{
					Main.DiscoR -= num4;
					if (Main.DiscoR <= 0)
					{
						Main.DiscoR = 0;
						this.DiscoStyle++;
					}
				}
				if (this.DiscoStyle == 2)
				{
					Main.DiscoB += num4;
					if (Main.DiscoB >= 255)
					{
						Main.DiscoB = 255;
						this.DiscoStyle++;
					}
				}
				if (this.DiscoStyle == 3)
				{
					Main.DiscoG -= num4;
					if (Main.DiscoG <= 0)
					{
						Main.DiscoG = 0;
						this.DiscoStyle++;
					}
				}
				if (this.DiscoStyle == 4)
				{
					Main.DiscoR += num4;
					if (Main.DiscoR >= 255)
					{
						Main.DiscoR = 255;
						this.DiscoStyle++;
					}
				}
				if (this.DiscoStyle == 5)
				{
					Main.DiscoB -= num4;
					if (Main.DiscoB <= 0)
					{
						Main.DiscoB = 0;
						this.DiscoStyle = 0;
					}
				}
				if (Main.gFadeDir == 1)
				{
					Main.gFader += 0.1f;
					Main.gFade = (byte)Main.gFader;
					if (Main.gFade > 150)
					{
						Main.gFadeDir = 0;
					}
				}
				else
				{
					Main.gFader -= 0.1f;
					Main.gFade = (byte)Main.gFader;
					if (Main.gFade < 100)
					{
						Main.gFadeDir = 1;
					}
				}
				Main.wFrCounter += Main.windSpeed * 2f;
				if (Main.wFrCounter > 4f)
				{
					Main.wFrCounter = 0f;
					Main.wFrame += 1f;
				}
				if (Main.wFrCounter < 0f)
				{
					Main.wFrCounter = 4f;
					Main.wFrame -= 1f;
				}
				if (Main.wFrame > 16f)
				{
					Main.wFrame = 1f;
				}
				if (Main.wFrame < 1f)
				{
					Main.wFrame = 16f;
				}
				this.waterfallManager.UpdateFrame();
				byte[] expr_B50_cp_0 = Main.wallFrameCounter;
				int expr_B50_cp_1 = 136;
				expr_B50_cp_0[expr_B50_cp_1] += 1;
				if (Main.wallFrameCounter[136] >= 5)
				{
					Main.wallFrameCounter[136] = 0;
					byte[] expr_B87_cp_0 = Main.wallFrame;
					int expr_B87_cp_1 = 136;
					expr_B87_cp_0[expr_B87_cp_1] += 1;
					if (Main.wallFrame[136] > 7)
					{
						Main.wallFrame[136] = 0;
					}
				}
				byte[] expr_BBE_cp_0 = Main.wallFrameCounter;
				int expr_BBE_cp_1 = 137;
				expr_BBE_cp_0[expr_BBE_cp_1] += 1;
				if (Main.wallFrameCounter[137] >= 10)
				{
					Main.wallFrameCounter[137] = 0;
					byte[] expr_BF6_cp_0 = Main.wallFrame;
					int expr_BF6_cp_1 = 137;
					expr_BF6_cp_0[expr_BF6_cp_1] += 1;
					if (Main.wallFrame[137] > 7)
					{
						Main.wallFrame[137] = 0;
					}
				}
				byte[] expr_C2D_cp_0 = Main.wallFrameCounter;
				int expr_C2D_cp_1 = 168;
				expr_C2D_cp_0[expr_C2D_cp_1] += 1;
				if (Main.wallFrameCounter[168] >= 5)
				{
					Main.wallFrameCounter[168] = 0;
					byte[] expr_C64_cp_0 = Main.wallFrame;
					int expr_C64_cp_1 = 168;
					expr_C64_cp_0[expr_C64_cp_1] += 1;
					if (Main.wallFrame[168] > 7)
					{
						Main.wallFrame[168] = 0;
					}
				}
				byte[] expr_C9B_cp_0 = Main.wallFrameCounter;
				int expr_C9B_cp_1 = 169;
				expr_C9B_cp_0[expr_C9B_cp_1] += 1;
				if (Main.wallFrameCounter[169] >= 5)
				{
					Main.wallFrameCounter[169] = 0;
					byte[] expr_CD2_cp_0 = Main.wallFrame;
					int expr_CD2_cp_1 = 169;
					expr_CD2_cp_0[expr_CD2_cp_1] += 1;
					if (Main.wallFrame[169] > 7)
					{
						Main.wallFrame[169] = 0;
					}
				}
				byte[] expr_D09_cp_0 = Main.wallFrameCounter;
				int expr_D09_cp_1 = 144;
				expr_D09_cp_0[expr_D09_cp_1] += 1;
				int num5 = 5;
				int num6 = 10;
				if ((int)Main.wallFrameCounter[144] < num5)
				{
					Main.wallFrame[144] = 0;
				}
				else
				{
					if ((int)Main.wallFrameCounter[144] < num5)
					{
						Main.wallFrame[144] = 1;
					}
					else
					{
						if ((int)Main.wallFrameCounter[144] < num5 * 2)
						{
							Main.wallFrame[144] = 2;
						}
						else
						{
							if ((int)Main.wallFrameCounter[144] < num5 * 3)
							{
								Main.wallFrame[144] = 3;
							}
							else
							{
								if ((int)Main.wallFrameCounter[144] < num5 * 4)
								{
									Main.wallFrame[144] = 4;
								}
								else
								{
									if ((int)Main.wallFrameCounter[144] < num5 * 5)
									{
										Main.wallFrame[144] = 5;
									}
									else
									{
										if ((int)Main.wallFrameCounter[144] < num5 * 6)
										{
											Main.wallFrame[144] = 6;
										}
										else
										{
											if ((int)Main.wallFrameCounter[144] < num5 * 7)
											{
												Main.wallFrame[144] = 7;
											}
											else
											{
												if ((int)Main.wallFrameCounter[144] < num5 * (8 + num6))
												{
													Main.wallFrame[144] = 8;
												}
												else
												{
													if ((int)Main.wallFrameCounter[144] < num5 * (9 + num6))
													{
														Main.wallFrame[144] = 7;
													}
													else
													{
														if ((int)Main.wallFrameCounter[144] < num5 * (10 + num6))
														{
															Main.wallFrame[144] = 6;
														}
														else
														{
															if ((int)Main.wallFrameCounter[144] < num5 * (11 + num6))
															{
																Main.wallFrame[144] = 5;
															}
															else
															{
																if ((int)Main.wallFrameCounter[144] < num5 * (12 + num6))
																{
																	Main.wallFrame[144] = 4;
																}
																else
																{
																	if ((int)Main.wallFrameCounter[144] < num5 * (13 + num6))
																	{
																		Main.wallFrame[144] = 3;
																	}
																	else
																	{
																		if ((int)Main.wallFrameCounter[144] < num5 * (14 + num6))
																		{
																			Main.wallFrame[144] = 2;
																		}
																		else
																		{
																			if ((int)Main.wallFrameCounter[144] < num5 * (15 + num6))
																			{
																				Main.wallFrame[144] = 1;
																			}
																			else
																			{
																				Main.wallFrame[144] = 0;
																				if ((int)Main.wallFrameCounter[144] > num5 * (16 + num6 * 2))
																				{
																					Main.wallFrameCounter[144] = 0;
																				}
																			}
																		}
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
				Main.tileFrameCounter[12]++;
				if (Main.tileFrameCounter[12] > 5)
				{
					Main.tileFrameCounter[12] = 0;
					Main.tileFrame[12]++;
					if (Main.tileFrame[12] >= 10)
					{
						Main.tileFrame[12] = 0;
					}
				}
				Main.tileFrameCounter[17]++;
				if (Main.tileFrameCounter[17] > 5)
				{
					Main.tileFrameCounter[17] = 0;
					Main.tileFrame[17]++;
					if (Main.tileFrame[17] >= 12)
					{
						Main.tileFrame[17] = 0;
					}
				}
				Main.tileFrameCounter[31]++;
				if (Main.tileFrameCounter[31] > 10)
				{
					Main.tileFrameCounter[31] = 0;
					Main.tileFrame[31]++;
					if (Main.tileFrame[31] > 1)
					{
						Main.tileFrame[31] = 0;
					}
				}
				Main.tileFrameCounter[77]++;
				if (Main.tileFrameCounter[77] > 5)
				{
					Main.tileFrameCounter[77] = 0;
					Main.tileFrame[77]++;
					if (Main.tileFrame[77] >= 12)
					{
						Main.tileFrame[77] = 0;
					}
				}
				Main.tileFrameCounter[106]++;
				if (Main.tileFrameCounter[106] > 4)
				{
					Main.tileFrameCounter[106] = 0;
					Main.tileFrame[106]++;
					if (Main.tileFrame[106] >= 2)
					{
						Main.tileFrame[106] = 0;
					}
				}
				Main.tileFrameCounter[207]++;
				if (Main.tileFrameCounter[207] > 4)
				{
					Main.tileFrameCounter[207] = 0;
					Main.tileFrame[207]++;
					if (Main.tileFrame[207] >= 6)
					{
						Main.tileFrame[207] = 0;
					}
				}
				Main.tileFrameCounter[215]++;
				if (Main.tileFrameCounter[215] > 4)
				{
					Main.tileFrameCounter[215] = 0;
					Main.tileFrame[215]++;
					if (Main.tileFrame[215] >= 4)
					{
						Main.tileFrame[215] = 0;
					}
				}
				Main.tileFrameCounter[217]++;
				if (Main.tileFrameCounter[217] > 4)
				{
					Main.tileFrameCounter[217] = 0;
					Main.tileFrame[217]++;
					if (Main.tileFrame[217] >= 5)
					{
						Main.tileFrame[217] = 0;
					}
				}
				Main.tileFrameCounter[218]++;
				if (Main.tileFrameCounter[218] > 4)
				{
					Main.tileFrameCounter[218] = 0;
					Main.tileFrame[218]++;
					if (Main.tileFrame[218] >= 2)
					{
						Main.tileFrame[218] = 0;
					}
				}
				Main.tileFrameCounter[219]++;
				if (Main.tileFrameCounter[219] > 4)
				{
					Main.tileFrameCounter[219] = 0;
					Main.tileFrame[219]++;
					if (Main.tileFrame[219] >= 10)
					{
						Main.tileFrame[219] = 0;
					}
				}
				Main.tileFrameCounter[220]++;
				if (Main.tileFrameCounter[220] > 4)
				{
					Main.tileFrameCounter[220] = 0;
					Main.tileFrame[220]++;
					if (Main.tileFrame[220] >= 4)
					{
						Main.tileFrame[220] = 0;
					}
				}
				Main.tileFrameCounter[231]++;
				if (Main.tileFrameCounter[231] > 16)
				{
					Main.tileFrameCounter[231] = 0;
					Main.tileFrame[231]++;
					if (Main.tileFrame[231] >= 7)
					{
						Main.tileFrame[231] = 0;
					}
				}
				Main.tileFrameCounter[235]++;
				if (Main.tileFrameCounter[235] > 20)
				{
					Main.tileFrameCounter[235] = 0;
					Main.tileFrame[235]++;
					if (Main.tileFrame[235] >= 4)
					{
						Main.tileFrame[235] = 0;
					}
					if (Main.tileFrame[235] > 1)
					{
						Main.tileLighted[235] = true;
					}
					else
					{
						Main.tileLighted[235] = false;
					}
				}
				Main.tileFrameCounter[238]++;
				if (Main.tileFrameCounter[238] > 20)
				{
					Main.tileFrameCounter[238] = 0;
					Main.tileFrame[238]++;
					if (Main.tileFrame[238] >= 4)
					{
						Main.tileFrame[238] = 0;
					}
				}
				Main.tileFrameCounter[243]++;
				if (Main.tileFrameCounter[243] > 4)
				{
					Main.tileFrameCounter[243] = 0;
					Main.tileFrame[243]++;
					if (Main.tileFrame[243] >= 6)
					{
						Main.tileFrame[243] = 0;
					}
				}
				Main.tileFrameCounter[244]++;
				if (Main.tileFrameCounter[244] > 4)
				{
					Main.tileFrameCounter[244] = 0;
					Main.tileFrame[244]++;
					if (Main.tileFrame[244] >= 6)
					{
						Main.tileFrame[244] = 0;
					}
				}
				Main.tileFrameCounter[247]++;
				if (Main.tileFrameCounter[247] > 4)
				{
					Main.tileFrameCounter[247] = 0;
					Main.tileFrame[247]++;
					if (Main.tileFrame[247] > 7)
					{
						Main.tileFrame[247] = 0;
					}
				}
				Main.tileFrameCounter[96]++;
				if (Main.tileFrameCounter[96] > 4)
				{
					Main.tileFrameCounter[96] = 0;
					Main.tileFrame[96]++;
					if (Main.tileFrame[96] > 3)
					{
						Main.tileFrame[96] = 0;
					}
				}
				Main.tileFrameCounter[171]++;
				if (Main.tileFrameCounter[171] > 16)
				{
					Main.tileFrameCounter[171] = 0;
					Main.tileFrame[171]++;
					if (Main.tileFrame[171] > 3)
					{
						Main.tileFrame[171] = 0;
					}
				}
				Main.tileFrameCounter[270]++;
				if (Main.tileFrameCounter[270] > 8)
				{
					Main.tileFrameCounter[270] = 0;
					Main.tileFrame[270]++;
					if (Main.tileFrame[270] > 5)
					{
						Main.tileFrame[270] = 0;
					}
				}
				Main.tileFrame[271] = Main.tileFrame[270];
				Main.tileFrameCounter[272]++;
				if (Main.tileFrameCounter[272] >= 10)
				{
					Main.tileFrameCounter[272] = 0;
					Main.tileFrame[272]++;
					if (Main.tileFrame[272] > 1)
					{
						Main.tileFrame[272] = 0;
					}
				}
				Main.tileFrameCounter[300]++;
				if (Main.tileFrameCounter[300] >= 5)
				{
					Main.tileFrameCounter[300] = 0;
					Main.tileFrame[300]++;
					if (Main.tileFrame[300] > 6)
					{
						Main.tileFrame[300] = 0;
					}
				}
				Main.tileFrameCounter[301]++;
				if (Main.tileFrameCounter[301] >= 5)
				{
					Main.tileFrameCounter[301] = 0;
					Main.tileFrame[301]++;
					if (Main.tileFrame[301] > 7)
					{
						Main.tileFrame[301] = 0;
					}
				}
				Main.tileFrameCounter[302]++;
				if (Main.tileFrameCounter[302] >= 5)
				{
					Main.tileFrameCounter[302] = 0;
					Main.tileFrame[302]++;
					if (Main.tileFrame[302] > 3)
					{
						Main.tileFrame[302] = 0;
					}
				}
				Main.tileFrameCounter[303]++;
				if (Main.tileFrameCounter[303] >= 5)
				{
					Main.tileFrameCounter[303] = 0;
					Main.tileFrame[303]++;
					if (Main.tileFrame[303] > 4)
					{
						Main.tileFrame[303] = 0;
					}
				}
				Main.tileFrameCounter[305]++;
				if (Main.tileFrameCounter[305] >= 5)
				{
					Main.tileFrameCounter[305] = 0;
					Main.tileFrame[305]++;
					if (Main.tileFrame[305] > 11)
					{
						Main.tileFrame[305] = 0;
					}
				}
				Main.tileFrameCounter[306]++;
				if (Main.tileFrameCounter[306] >= 5)
				{
					Main.tileFrameCounter[306] = 0;
					Main.tileFrame[306]++;
					if (Main.tileFrame[306] > 11)
					{
						Main.tileFrame[306] = 0;
					}
				}
				Main.tileFrameCounter[307]++;
				if (Main.tileFrameCounter[307] >= 5)
				{
					Main.tileFrameCounter[307] = 0;
					Main.tileFrame[307]++;
					if (Main.tileFrame[307] > 1)
					{
						Main.tileFrame[307] = 0;
					}
				}
				Main.tileFrameCounter[308]++;
				if (Main.tileFrameCounter[308] >= 5)
				{
					Main.tileFrameCounter[308] = 0;
					Main.tileFrame[308]++;
					if (Main.tileFrame[308] > 7)
					{
						Main.tileFrame[308] = 0;
					}
				}
				Main.tileFrameCounter[314]++;
				if (Main.tileFrameCounter[314] >= 10)
				{
					Main.tileFrameCounter[314] = 0;
					Main.tileFrame[314]++;
					if (Main.tileFrame[314] > 4)
					{
						Main.tileFrame[314] = 0;
					}
				}
				Main.tileFrameCounter[326]++;
				if (Main.tileFrameCounter[326] >= 5)
				{
					Main.tileFrameCounter[326] = 0;
					Main.tileFrame[326]++;
					if (Main.tileFrame[326] > 7)
					{
						Main.tileFrame[326] = 0;
					}
				}
				Main.tileFrameCounter[327]++;
				if (Main.tileFrameCounter[327] >= 10)
				{
					Main.tileFrameCounter[327] = 0;
					Main.tileFrame[327]++;
					if (Main.tileFrame[327] > 7)
					{
						Main.tileFrame[327] = 0;
					}
				}
				Main.tileFrameCounter[336]++;
				if (Main.tileFrameCounter[336] >= 5)
				{
					Main.tileFrameCounter[336] = 0;
					Main.tileFrame[336]++;
					if (Main.tileFrame[336] > 3)
					{
						Main.tileFrame[336] = 0;
					}
				}
				Main.tileFrameCounter[328]++;
				if (Main.tileFrameCounter[328] >= 5)
				{
					Main.tileFrameCounter[328] = 0;
					Main.tileFrame[328]++;
					if (Main.tileFrame[328] > 7)
					{
						Main.tileFrame[328] = 0;
					}
				}
				Main.tileFrameCounter[329]++;
				if (Main.tileFrameCounter[329] >= 5)
				{
					Main.tileFrameCounter[329] = 0;
					Main.tileFrame[329]++;
					if (Main.tileFrame[329] > 7)
					{
						Main.tileFrame[329] = 0;
					}
				}
				Main.CritterCages();
				if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F10) && !Main.chatMode && !Main.editSign && !Main.editChest)
				{
					if (Main.frameRelease)
					{
						Main.PlaySound(12, -1, -1, 1);
						if (Main.showFrameRate)
						{
							Main.showFrameRate = false;
						}
						else
						{
							Main.showFrameRate = true;
						}
					}
					Main.frameRelease = false;
				}
				else
				{
					Main.frameRelease = true;
				}
				if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F9) && !Main.chatMode && !Main.editSign && !Main.editChest)
				{
					if (Main.RGBRelease)
					{
						Main.PlaySound(12, -1, -1, 1);
						Lighting.NextLightMode();
					}
					Main.RGBRelease = false;
				}
				else
				{
					Main.RGBRelease = true;
				}
				if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F8) && !Main.chatMode && !Main.editSign && !Main.editChest)
				{
					if (Main.netRelease)
					{
						Main.PlaySound(12, -1, -1, 1);
						if (Main.netDiag)
						{
							Main.netDiag = false;
						}
						else
						{
							Main.netDiag = true;
						}
					}
					Main.netRelease = false;
				}
				else
				{
					Main.netRelease = true;
				}
				if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F7) && !Main.chatMode && !Main.editSign && !Main.editChest)
				{
					if (Main.drawRelease)
					{
						Main.PlaySound(12, -1, -1, 1);
						if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftAlt) || Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightAlt))
						{
							TimeLogger.Start();
						}
						else
						{
							if (Main.drawDiag)
							{
								Main.drawDiag = false;
							}
							else
							{
								Main.drawDiag = true;
							}
						}
					}
					Main.drawRelease = false;
				}
				else
				{
					Main.drawRelease = true;
				}
				if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F11))
				{
					if (Main.releaseUI)
					{
						if (Main.hideUI)
						{
							Main.hideUI = false;
						}
						else
						{
							Main.hideUI = true;
						}
					}
					Main.releaseUI = false;
				}
				else
				{
					Main.releaseUI = true;
				}
				if ((Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftAlt) || Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightAlt)) && Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter))
				{
					if (Main.toggleFullscreen)
					{
						Main.graphics.ToggleFullScreen();
						Main.chatRelease = false;
					}
					Main.toggleFullscreen = false;
				}
				else
				{
					Main.toggleFullscreen = true;
				}
				if (!Main.gamePad || Main.gameMenu)
				{
					Main.oldMouseState = Main.mouseState;
					Main.mouseState = Mouse.GetState();
					Main.mouseX = Main.mouseState.X;
					Main.mouseY = Main.mouseState.Y;
					Main.mouseLeft = false;
					Main.mouseRight = false;
					if (base.IsActive)
					{
						if (Main.mouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
						{
							Main.mouseLeft = true;
						}
						if (Main.mouseState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
						{
							Main.mouseRight = true;
						}
					}
				}
				Main.keyState = Keyboard.GetState();
				if (Main.editSign)
				{
					Main.chatMode = false;
				}
				if (!Main.chatMode)
				{
					Main.startChatLine = 0;
				}
				if (Main.chatMode)
				{
					Main.showCount = (int)((float)(Main.screenHeight / 3) / Main.fontMouseText.MeasureString("1").Y) - 1;
					if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up))
					{
						Main.startChatLine++;
						if (Main.startChatLine + Main.showCount >= Main.numChatLines - 1)
						{
							Main.startChatLine = Main.numChatLines - Main.showCount - 1;
						}
						if (Main.chatLine[Main.startChatLine + Main.showCount].text == "")
						{
							Main.startChatLine--;
						}
					}
					else
					{
						if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
						{
							Main.startChatLine--;
							if (Main.startChatLine < 0)
							{
								Main.startChatLine = 0;
							}
						}
					}
					if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape))
					{
						Main.chatMode = false;
					}
					string text = Main.chatText;
					Main.chatText = Main.GetInputText(Main.chatText);
					int num7 = Main.screenWidth - 330;
					while (Main.fontMouseText.MeasureString(Main.chatText).X > (float)num7)
					{
						Main.chatText = Main.chatText.Substring(0, Main.chatText.Length - 1);
					}
					if (text != Main.chatText)
					{
						Main.PlaySound(12, -1, -1, 1);
					}
					if (Main.inputTextEnter && Main.chatRelease)
					{
						if (Main.chatText != "")
						{
							NetMessage.SendData(25, -1, -1, Main.chatText, Main.myPlayer, 0f, 0f, 0f, 0);
						}
						Main.chatText = "";
						Main.chatMode = false;
						Main.chatRelease = false;
						Main.player[Main.myPlayer].releaseHook = false;
						Main.player[Main.myPlayer].releaseThrow = false;
						Main.PlaySound(11, -1, -1, 1);
					}
				}
				if (Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter) && Main.netMode == 1 && !Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftAlt) && !Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightAlt))
				{
					if (Main.chatRelease && !Main.chatMode && !Main.editSign && !Main.editChest && !Main.gameMenu && !Main.keyState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape))
					{
						Main.PlaySound(10, -1, -1, 1);
						Main.chatMode = true;
						Main.clrInput();
						Main.chatText = "";
					}
					Main.chatRelease = false;
				}
				else
				{
					Main.chatRelease = true;
				}
				if (Main.gameMenu)
				{
					Main.UpdateMenu();
					if (Main.netMode != 2)
					{
						return;
					}
					Main.gamePaused = false;
				}
			}
			if (Main.netMode == 1)
			{
				for (int i = 0; i < 59; i++)
				{
					if (Main.player[Main.myPlayer].inventory[i].IsNotTheSameAs(Main.clientPlayer.inventory[i]))
					{
						NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].inventory[i].name, Main.myPlayer, (float)i, (float)Main.player[Main.myPlayer].inventory[i].prefix, 0f, 0);
					}
				}
				if (Main.player[Main.myPlayer].armor[0].IsNotTheSameAs(Main.clientPlayer.armor[0]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[0].name, Main.myPlayer, 59f, (float)Main.player[Main.myPlayer].armor[0].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[1].IsNotTheSameAs(Main.clientPlayer.armor[1]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[1].name, Main.myPlayer, 60f, (float)Main.player[Main.myPlayer].armor[1].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[2].IsNotTheSameAs(Main.clientPlayer.armor[2]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[2].name, Main.myPlayer, 61f, (float)Main.player[Main.myPlayer].armor[2].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[3].IsNotTheSameAs(Main.clientPlayer.armor[3]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[3].name, Main.myPlayer, 62f, (float)Main.player[Main.myPlayer].armor[3].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[4].IsNotTheSameAs(Main.clientPlayer.armor[4]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[4].name, Main.myPlayer, 63f, (float)Main.player[Main.myPlayer].armor[4].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[5].IsNotTheSameAs(Main.clientPlayer.armor[5]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[5].name, Main.myPlayer, 64f, (float)Main.player[Main.myPlayer].armor[5].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[6].IsNotTheSameAs(Main.clientPlayer.armor[6]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[6].name, Main.myPlayer, 65f, (float)Main.player[Main.myPlayer].armor[6].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[7].IsNotTheSameAs(Main.clientPlayer.armor[7]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[7].name, Main.myPlayer, 66f, (float)Main.player[Main.myPlayer].armor[7].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[8].IsNotTheSameAs(Main.clientPlayer.armor[8]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[8].name, Main.myPlayer, 67f, (float)Main.player[Main.myPlayer].armor[8].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[9].IsNotTheSameAs(Main.clientPlayer.armor[9]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[9].name, Main.myPlayer, 68f, (float)Main.player[Main.myPlayer].armor[9].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[10].IsNotTheSameAs(Main.clientPlayer.armor[10]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[10].name, Main.myPlayer, 69f, (float)Main.player[Main.myPlayer].armor[10].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[11].IsNotTheSameAs(Main.clientPlayer.armor[11]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[11].name, Main.myPlayer, 70f, (float)Main.player[Main.myPlayer].armor[11].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[12].IsNotTheSameAs(Main.clientPlayer.armor[12]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[12].name, Main.myPlayer, 71f, (float)Main.player[Main.myPlayer].armor[12].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[13].IsNotTheSameAs(Main.clientPlayer.armor[13]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[13].name, Main.myPlayer, 72f, (float)Main.player[Main.myPlayer].armor[13].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[14].IsNotTheSameAs(Main.clientPlayer.armor[14]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[14].name, Main.myPlayer, 73f, (float)Main.player[Main.myPlayer].armor[14].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].armor[15].IsNotTheSameAs(Main.clientPlayer.armor[15]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].armor[15].name, Main.myPlayer, 74f, (float)Main.player[Main.myPlayer].armor[15].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].dye[0].IsNotTheSameAs(Main.clientPlayer.dye[0]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[0].name, Main.myPlayer, 75f, (float)Main.player[Main.myPlayer].dye[0].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].dye[1].IsNotTheSameAs(Main.clientPlayer.dye[1]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[1].name, Main.myPlayer, 76f, (float)Main.player[Main.myPlayer].dye[1].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].dye[2].IsNotTheSameAs(Main.clientPlayer.dye[2]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[2].name, Main.myPlayer, 77f, (float)Main.player[Main.myPlayer].dye[2].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].dye[3].IsNotTheSameAs(Main.clientPlayer.dye[3]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[3].name, Main.myPlayer, 78f, (float)Main.player[Main.myPlayer].dye[3].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].dye[4].IsNotTheSameAs(Main.clientPlayer.dye[4]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[4].name, Main.myPlayer, 79f, (float)Main.player[Main.myPlayer].dye[4].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].dye[5].IsNotTheSameAs(Main.clientPlayer.dye[5]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[5].name, Main.myPlayer, 80f, (float)Main.player[Main.myPlayer].dye[5].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].dye[6].IsNotTheSameAs(Main.clientPlayer.dye[6]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[6].name, Main.myPlayer, 81f, (float)Main.player[Main.myPlayer].dye[6].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].dye[7].IsNotTheSameAs(Main.clientPlayer.dye[7]))
				{
					NetMessage.SendData(5, -1, -1, Main.player[Main.myPlayer].dye[7].name, Main.myPlayer, 82f, (float)Main.player[Main.myPlayer].dye[7].prefix, 0f, 0);
				}
				if (Main.player[Main.myPlayer].chest != Main.clientPlayer.chest && Main.player[Main.myPlayer].chest < 0)
				{
					if (Main.player[Main.myPlayer].editedChestName)
					{
						NetMessage.SendData(33, -1, -1, Main.chest[Main.clientPlayer.chest].name, Main.player[Main.myPlayer].chest, 1f, 0f, 0f, 0);
						Main.player[Main.myPlayer].editedChestName = false;
					}
					else
					{
						NetMessage.SendData(33, -1, -1, "", Main.player[Main.myPlayer].chest, 0f, 0f, 0f, 0);
					}
				}
				if (Main.player[Main.myPlayer].talkNPC != Main.clientPlayer.talkNPC)
				{
					NetMessage.SendData(40, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
				}
				if (Main.player[Main.myPlayer].zoneEvil != Main.clientPlayer.zoneEvil)
				{
					NetMessage.SendData(36, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
				}
				if (Main.player[Main.myPlayer].zoneMeteor != Main.clientPlayer.zoneMeteor)
				{
					NetMessage.SendData(36, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
				}
				if (Main.player[Main.myPlayer].zoneDungeon != Main.clientPlayer.zoneDungeon)
				{
					NetMessage.SendData(36, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
				}
				if (Main.player[Main.myPlayer].zoneJungle != Main.clientPlayer.zoneJungle)
				{
					NetMessage.SendData(36, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
				}
				if (Main.player[Main.myPlayer].zoneHoly != Main.clientPlayer.zoneHoly)
				{
					NetMessage.SendData(36, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
				}
				if (Main.player[Main.myPlayer].zoneSnow != Main.clientPlayer.zoneSnow)
				{
					NetMessage.SendData(36, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
				}
				if (Main.player[Main.myPlayer].zoneBlood != Main.clientPlayer.zoneBlood)
				{
					NetMessage.SendData(36, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
				}
				if (Main.player[Main.myPlayer].zoneCandle != Main.clientPlayer.zoneCandle)
				{
					NetMessage.SendData(36, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
				}
				if (Main.player[Main.myPlayer].statLife != Main.clientPlayer.statLife || Main.player[Main.myPlayer].statLifeMax != Main.clientPlayer.statLifeMax)
				{
					Main.player[Main.myPlayer].netLife = true;
				}
				if (Main.player[Main.myPlayer].netLifeTime > 0)
				{
					Main.player[Main.myPlayer].netLifeTime--;
				}
				else
				{
					if (Main.player[Main.myPlayer].netLife)
					{
						Main.player[Main.myPlayer].netLife = false;
						Main.player[Main.myPlayer].netLifeTime = 60;
						NetMessage.SendData(16, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
					}
				}
				if (Main.player[Main.myPlayer].statMana != Main.clientPlayer.statMana || Main.player[Main.myPlayer].statManaMax != Main.clientPlayer.statManaMax)
				{
					Main.player[Main.myPlayer].netMana = true;
				}
				if (Main.player[Main.myPlayer].netManaTime > 0)
				{
					Main.player[Main.myPlayer].netManaTime--;
				}
				else
				{
					if (Main.player[Main.myPlayer].netMana)
					{
						Main.player[Main.myPlayer].netMana = false;
						Main.player[Main.myPlayer].netManaTime = 60;
						NetMessage.SendData(42, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
					}
				}
				bool flag = false;
				for (int j = 0; j < 22; j++)
				{
					if (Main.player[Main.myPlayer].buffType[j] != Main.clientPlayer.buffType[j])
					{
						flag = true;
					}
				}
				if (flag)
				{
					NetMessage.SendData(50, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
					NetMessage.SendData(13, -1, -1, "", Main.myPlayer, 0f, 0f, 0f, 0);
				}
			}
			if (Main.netMode == 1)
			{
				Main.clientPlayer = (Player)Main.player[Main.myPlayer].clientClone();
			}
			if (Main.netMode == 0 && (Main.playerInventory || Main.npcChatText != "" || Main.player[Main.myPlayer].sign >= 0 || Main.ingameOptionsWindow) && Main.autoPause)
			{
				if (!Main.chatMode && !Main.editSign && !Main.editChest && !Main.blockInput)
				{
					Microsoft.Xna.Framework.Input.Keys[] pressedKeys = Main.keyState.GetPressedKeys();
					if (Main.blockKey != Microsoft.Xna.Framework.Input.Keys.None)
					{
						bool flag2 = false;
						for (int k = 0; k < pressedKeys.Length; k++)
						{
							if (pressedKeys[k] == Main.blockKey)
							{
								pressedKeys[k] = Microsoft.Xna.Framework.Input.Keys.None;
								flag2 = true;
							}
						}
						if (!flag2)
						{
							Main.blockKey = Microsoft.Xna.Framework.Input.Keys.None;
						}
					}
					Main.player[Main.myPlayer].controlInv = false;
					for (int l = 0; l < pressedKeys.Length; l++)
					{
						string text2 = string.Concat(pressedKeys[l]);
						if (text2 == Main.cInv)
						{
							Main.player[Main.myPlayer].controlInv = true;
						}
					}
					if (Main.player[Main.myPlayer].controlInv)
					{
						if (Main.player[Main.myPlayer].releaseInventory)
						{
							Main.player[Main.myPlayer].toggleInv();
						}
						Main.player[Main.myPlayer].releaseInventory = false;
					}
					else
					{
						Main.player[Main.myPlayer].releaseInventory = true;
					}
				}
				if (Main.playerInventory)
				{
					int num8 = (Main.mouseState.ScrollWheelValue - Main.oldMouseState.ScrollWheelValue) / 120;
					Main.focusRecipe += num8;
					if (Main.focusRecipe > Main.numAvailableRecipes - 1)
					{
						Main.focusRecipe = Main.numAvailableRecipes - 1;
					}
					if (Main.focusRecipe < 0)
					{
						Main.focusRecipe = 0;
					}
					Main.player[Main.myPlayer].dropItemCheck();
				}
				Main.player[Main.myPlayer].head = Main.player[Main.myPlayer].armor[0].headSlot;
				Main.player[Main.myPlayer].body = Main.player[Main.myPlayer].armor[1].bodySlot;
				Main.player[Main.myPlayer].legs = Main.player[Main.myPlayer].armor[2].legSlot;
				if (!Main.player[Main.myPlayer].hostile)
				{
					if (Main.player[Main.myPlayer].armor[8].headSlot >= 0)
					{
						Main.player[Main.myPlayer].head = Main.player[Main.myPlayer].armor[8].headSlot;
					}
					if (Main.player[Main.myPlayer].armor[9].bodySlot >= 0)
					{
						Main.player[Main.myPlayer].body = Main.player[Main.myPlayer].armor[9].bodySlot;
					}
					if (Main.player[Main.myPlayer].armor[10].legSlot >= 0)
					{
						Main.player[Main.myPlayer].legs = Main.player[Main.myPlayer].armor[10].legSlot;
					}
				}
				if (Main.editSign)
				{
					if (Main.player[Main.myPlayer].sign == -1)
					{
						Main.editSign = false;
					}
					else
					{
						Main.npcChatText = Main.GetInputText(Main.npcChatText);
						if (Main.inputTextEnter)
						{
							byte[] bytes = new byte[]
							{
								10
							};
							Main.npcChatText += Encoding.ASCII.GetString(bytes);
						}
						else
						{
							if (Main.inputTextEscape)
							{
								Main.PlaySound(12, -1, -1, 1);
								Main.editSign = false;
								Main.blockKey = Microsoft.Xna.Framework.Input.Keys.Escape;
								Main.npcChatText = Main.sign[Main.player[Main.myPlayer].sign].text;
							}
						}
					}
				}
				else
				{
					if (Main.editChest)
					{
						string text3 = Main.GetInputText(Main.npcChatText);
						if (Main.inputTextEnter)
						{
							Main.PlaySound(12, -1, -1, 1);
							Main.editChest = false;
							int num9 = Main.player[Main.myPlayer].chest;
							if (Main.npcChatText == Main.defaultChestName)
							{
								Main.npcChatText = "";
							}
							if (Main.chest[num9].name != Main.npcChatText)
							{
								Main.chest[num9].name = Main.npcChatText;
								if (Main.netMode == 1)
								{
									Main.player[Main.myPlayer].editedChestName = true;
								}
							}
						}
						else
						{
							if (Main.inputTextEscape)
							{
								Main.PlaySound(12, -1, -1, 1);
								Main.editChest = false;
								Main.npcChatText = string.Empty;
								Main.blockKey = Microsoft.Xna.Framework.Input.Keys.Escape;
							}
							else
							{
								if (text3.Length <= 20)
								{
									Main.npcChatText = text3;
								}
							}
						}
					}
				}
				Main.gamePaused = true;
				return;
			}
			Main.gamePaused = false;
			if (!Main.dedServ && (double)Main.screenPosition.Y < Main.worldSurface * 16.0 + 16.0 && Main.netMode != 2)
			{
				Star.UpdateStars();
				Cloud.UpdateClouds();
			}
			Main.numPlayers = 0;
			int m = 0;
			while (m < 255)
			{
				if (Main.ignoreErrors)
				{
					try
					{
						Main.player[m].UpdatePlayer(m);
						goto IL_388A;
					}
					catch
					{
						goto IL_388A;
					}
					goto IL_387B;
				}
				goto IL_387B;
				IL_388A:
				m++;
				continue;
				IL_387B:
				Main.player[m].UpdatePlayer(m);
				goto IL_388A;
			}
			if (Main.netMode != 1)
			{
				try
				{
					NPC.SpawnNPC();
				}
				catch
				{
				}
			}
			for (int n = 0; n < 255; n++)
			{
				Main.player[n].activeNPCs = 0f;
				Main.player[n].townNPCs = 0f;
			}
			if (Main.wof >= 0 && !Main.npc[Main.wof].active)
			{
				Main.wof = -1;
			}
			if (NPC.golemBoss >= 0 && !Main.npc[NPC.golemBoss].active)
			{
				NPC.golemBoss = -1;
			}
			if (NPC.plantBoss >= 0 && !Main.npc[NPC.plantBoss].active)
			{
				NPC.plantBoss = -1;
			}
			if (NPC.crimsonBoss >= 0 && !Main.npc[NPC.crimsonBoss].active)
			{
				NPC.crimsonBoss = -1;
			}
			int num10 = 0;
			while (num10 < 200)
			{
				if (Main.ignoreErrors)
				{
					try
					{
						Main.npc[num10].UpdateNPC(num10);
						goto IL_399F;
					}
					catch (Exception)
					{
						Main.npc[num10] = new NPC();
						goto IL_399F;
					}
					goto IL_3990;
				}
				goto IL_3990;
				IL_399F:
				num10++;
				continue;
				IL_3990:
				Main.npc[num10].UpdateNPC(num10);
				goto IL_399F;
			}
			int num11 = 0;
			while (num11 < 500)
			{
				if (Main.ignoreErrors)
				{
					try
					{
						Main.gore[num11].Update();
						goto IL_39E6;
					}
					catch
					{
						Main.gore[num11] = new Gore();
						goto IL_39E6;
					}
					goto IL_39D9;
				}
				goto IL_39D9;
				IL_39E6:
				num11++;
				continue;
				IL_39D9:
				Main.gore[num11].Update();
				goto IL_39E6;
			}
			int num12 = 0;
			while (num12 < 1000)
			{
				if (Main.ignoreErrors)
				{
					try
					{
						Main.projectile[num12].Update(num12);
						goto IL_3A31;
					}
					catch
					{
						Main.projectile[num12] = new Projectile();
						goto IL_3A31;
					}
					goto IL_3A22;
				}
				goto IL_3A22;
				IL_3A31:
				num12++;
				continue;
				IL_3A22:
				Main.projectile[num12].Update(num12);
				goto IL_3A31;
			}
			int num13 = 0;
			while (num13 < 400)
			{
				if (Main.ignoreErrors)
				{
					try
					{
						Main.item[num13].UpdateItem(num13);
						goto IL_3A7C;
					}
					catch
					{
						Main.item[num13] = new Item();
						goto IL_3A7C;
					}
					goto IL_3A6D;
				}
				goto IL_3A6D;
				IL_3A7C:
				num13++;
				continue;
				IL_3A6D:
				Main.item[num13].UpdateItem(num13);
				goto IL_3A7C;
			}
			if (Main.ignoreErrors)
			{
				try
				{
					Dust.UpdateDust();
					goto IL_3AC2;
				}
				catch
				{
					for (int num14 = 0; num14 < 6000; num14++)
					{
						Main.dust[num14] = new Dust();
					}
					goto IL_3AC2;
				}
			}
			Dust.UpdateDust();
			IL_3AC2:
			if (Main.netMode != 2)
			{
				CombatText.UpdateCombatText();
				ItemText.UpdateItemText();
			}
			if (Main.ignoreErrors)
			{
				try
				{
					Main.UpdateTime();
					goto IL_3AF0;
				}
				catch
				{
					Main.checkForSpawns = 0;
					goto IL_3AF0;
				}
			}
			Main.UpdateTime();
			IL_3AF0:
			if (Main.netMode != 1)
			{
				if (Main.ignoreErrors)
				{
					try
					{
						WorldGen.UpdateWorld();
						Main.UpdateInvasion();
						goto IL_3B18;
					}
					catch
					{
						goto IL_3B18;
					}
				}
				WorldGen.UpdateWorld();
				Main.UpdateInvasion();
			}
			IL_3B18:
			if (Main.ignoreErrors)
			{
				try
				{
					if (Main.netMode == 2)
					{
						Main.UpdateServer();
					}
					if (Main.netMode == 1)
					{
						Main.UpdateClient();
					}
					goto IL_3B60;
				}
				catch
				{
					int arg_3B43_0 = Main.netMode;
					goto IL_3B60;
				}
			}
			if (Main.netMode == 2)
			{
				Main.UpdateServer();
			}
			if (Main.netMode == 1)
			{
				Main.UpdateClient();
			}
			IL_3B60:
			if (Main.ignoreErrors)
			{
				try
				{
					for (int num15 = 0; num15 < Main.numChatLines; num15++)
					{
						if (Main.chatLine[num15].showTime > 0)
						{
							Main.chatLine[num15].showTime--;
						}
					}
					goto IL_3BFF;
				}
				catch
				{
					for (int num16 = 0; num16 < Main.numChatLines; num16++)
					{
						Main.chatLine[num16] = new ChatLine();
					}
					goto IL_3BFF;
				}
			}
			for (int num17 = 0; num17 < Main.numChatLines; num17++)
			{
				if (Main.chatLine[num17].showTime > 0)
				{
					Main.chatLine[num17].showTime--;
				}
			}
			IL_3BFF:
			Main.upTimer = (float)stopwatch.Elapsed.TotalMilliseconds;
			if (Main.upTimerMaxDelay > 0f)
			{
				Main.upTimerMaxDelay -= 1f;
			}
			else
			{
				Main.upTimerMax = 0f;
			}
			if (Main.upTimer > Main.upTimerMax)
			{
				Main.upTimerMax = Main.upTimer;
				Main.upTimerMaxDelay = 400f;
			}
			base.Update(gameTime);
		}
예제 #34
0
 public void AddMapping(Keys key)
 {
     KeyboardState.Add(key, new InputState());
 }
        /// <summary>
        /// Gets the character associated with the given key/shift pair.
        /// </summary>
        /// <param name="key">
        /// The key being pressed.
        /// </param>
        /// <param name="shift">
        /// Is the shift key down?.
        /// </param>
        /// <param name="capsLock">
        /// Is caps lock on?.
        /// </param>
        /// <param name="numLock">
        /// Is num lock on?.
        /// </param>
        /// <returns>
        /// The character the key/shift pair maps to.
        /// </returns>
        private char? GetCharacter(Keys key, bool shift, bool capsLock, bool numLock)
        {
            var newChar = new char?();
            if (alphabetKeyMap.Keys.Contains(key))
            {
                var characterMap = alphabetKeyMap[key];
                newChar = (shift ^ capsLock) ? characterMap.Item2 : characterMap.Item1;
            }
            else if (symbolNumberKeyMap.Keys.Contains(key))
            {
                var characterMap = symbolNumberKeyMap[key];
                newChar = shift ? characterMap.Item2 : characterMap.Item1;
            }
            else if (numPadKeyMap.ContainsKey(key))
            {
                if (numLock)
                {
                    newChar = numPadKeyMap[key];
                }
            }
            else if (numPadMathKeyMap.ContainsKey(key))
            {
                newChar = numPadMathKeyMap[key];
            }

            return newChar;
        }
예제 #36
0
        private static Keys XnaKeyToKey(XnaKeys key)
        {
            Keys kv = Keys.None;

            switch (key)
            {
                case XnaKeys.OemComma:
                    kv = Keys.Oemcomma;
                    break;
                case XnaKeys.OemTilde:
                    kv = Keys.Oemtilde;
                    break;
                case XnaKeys.OemPlus:
                    kv = Keys.Oemplus;
                    break;
                default:
                    if (Enum.IsDefined(typeof(Keys), key.ToString()) | key.ToString().Contains(","))
                    {
                        kv |= (Keys)Enum.Parse(typeof(Keys), key.ToString());
                    }
                    break;
            }

            if (key == XnaKeys.LeftShift)
            {
                kv = Keys.LShiftKey | Keys.Shift;
            }
            if (key == XnaKeys.RightShift)
            {
                kv = Keys.RShiftKey | Keys.Shift;
            }

            return kv;
        }
예제 #37
0
파일: Main.cs 프로젝트: NinjaSteph/SureShot
        private void KeyPressHandler(Keys key, KeyModifier modifier)
        {
            if ((key == Keys.Escape) && finalized)
                this.Exit();

            if ((key == Keys.Enter || key == Keys.Space) && useImageSequence && !finalized)
            {
                calibrateNextSequence = true;
            }
        }
예제 #38
0
		private bool MoveImage(XnaKeys keys) {
			if (mSelectedDrawnAnimation == -1 || mSelectedFrame == -1)
				return false;

			if (keys == XnaKeys.Up)
				SelectedImage.Offset.ReduceY();
			else if (keys == XnaKeys.Down)
				SelectedImage.Offset.AddY();
			else if (keys == XnaKeys.Left)
				SelectedImage.Offset.ReduceX();
			else if (keys == XnaKeys.Right)
				SelectedImage.Offset.AddX();

			return true;
		}
예제 #39
0
        private void handleKeyboardEvents()
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
                Process.GetCurrentProcess().Kill();

            else if (Keyboard.GetState().IsKeyDown(Keys.X))
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Up))
                {
                    this.recentlyPressedKey = Keys.Up;
                    this.windForce.X += Game1.keyAdjustment;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.Down))
                {
                    this.recentlyPressedKey = Keys.Down;
                    this.windForce.X -= Game1.keyAdjustment;
                }
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.Y))
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Up))
                {
                    this.recentlyPressedKey = Keys.Up;
                    this.windForce.Y += Game1.keyAdjustment;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.Down))
                {
                    this.recentlyPressedKey = Keys.Down;
                    this.windForce.Y -= Game1.keyAdjustment;
                }
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.Z))
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Up))
                {
                    this.recentlyPressedKey = Keys.Up;
                    this.windForce.Z += Game1.keyAdjustment;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.Down))
                {
                    this.recentlyPressedKey = Keys.Down;
                    this.windForce.Z -= Game1.keyAdjustment;
                }
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.F1))
            {
                this.windForce = new Vector3(0f, 0f, 0f);
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.F3))
            {
                if (this.recentlyPressedKey != Keys.F3)
                {
                    this.recentlyPressedKey = Keys.F3;
                    Snowflake.tornadoPosition = new Vector3(0f, 25f, 0f);
                    Snowflake.tornadoMode = !Snowflake.tornadoMode;
                }
            }
            else ;

            if (this.recentlyPressedKey == Keys.F3 && Keyboard.GetState()[Keys.F3] == KeyState.Up)
            {
                this.recentlyPressedKey = Keys.None;
            }
            else ;
        }
예제 #40
0
        private void GetKeyPressesName(KeyboardState keyboardState)
        {
            if (keyboardState.GetPressedKeys().Length == 0)
            {
                PreviousKey = Microsoft.Xna.Framework.Input.Keys.Zoom;
                return;
            }
            // if a key is kept pressed. we only need to take its 1st instance

            if (keyboardState.IsKeyUp(PreviousKey))
            {
                PreviousKey = Microsoft.Xna.Framework.Input.Keys.Zoom;
            }

            if (keyboardState.IsKeyDown(PreviousKey))
            {
                return;
            }

            PreviousKey = keyboardState.GetPressedKeys()[0];
             switch (keyboardState.GetPressedKeys()[0])
             {
                 case Microsoft.Xna.Framework.Input.Keys.A:
                     name += "a";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.B:
                     name += "b";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.C:
                     name += "c";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.D:
                     name += "d";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.D0:
                     name += "0";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.D1:
                     name += "1";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.D2:
                     name += "2";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.D3:
                     name += "3";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.D4:
                     name += "4";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.D5:
                     name += "5";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.D6:
                     name += "6";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.D7:
                     name += "7";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.D8:
                     name += "8";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.D9:
                     name += "9";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.E:
                     name += "e";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.Space:
                     name += " ";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.Back:
                     if (name.Length > 0)
                     {
                         name = name.Substring(0, name.Length - 1);
                     }
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.F:
                     name += "f";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.G:
                     name += "g";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.H:
                     name += "h";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.I:
                     name += "i";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.J:
                     name += "j";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.K:
                     name += "k";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.L:
                     name += "l";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.M:
                     name += "m";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.N:
                     name += "n";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.NumPad0:
                     name += "0";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.NumPad1:
                     name += "1";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.NumPad2:
                     name += "2";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.NumPad3:
                     name += "3";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.NumPad4:
                     name += "4";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.NumPad5:
                     name += "5";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.NumPad6:
                     name += "6";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.NumPad7:
                     name += "7";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.NumPad8:
                     name += "8";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.NumPad9:
                     name += "9";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.O:
                     name += "o";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.P:
                     name += "p";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.Q:
                     name += "q";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.R:
                     name += "r";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.S:
                     name += "s";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.T:
                     name += "t";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.U:
                     name += "u";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.V:
                     name += "v";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.W:
                     name += "w";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.X:
                     name += "x";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.Y:
                     name += "y";
                     break;
                 case Microsoft.Xna.Framework.Input.Keys.Z:
                     name += "z";
                     break;
                 default:
                     break;
             }

            if (name.Length == 1)
            {
                name = name.ToUpper();
            }
            else if(name.Length > 1)
            {
                if (name[name.Length - 2] == ' ')
                {
                    //name[name.Length - 1] = (name[name.Length - 1].ToString().ToUpper())[0];
                    string temp1 = name.Substring(0, name.Length - 1);
                    //string temp2 = name[name.Length - 1].ToString();;
                    name = temp1 + (name[name.Length - 1].ToString().ToUpper())[0];
                }
            }
        }
예제 #41
0
        private void GetKeyPressesRounds(KeyboardState keyboardState)
        {
            if (keyboardState.GetPressedKeys().Length == 0)
            {
                PreviousKey = Microsoft.Xna.Framework.Input.Keys.Zoom;
                return;
            }
            // if a key is kept pressed. we only need to take its 1st instance

            if (keyboardState.IsKeyUp(PreviousKey))
            {
                PreviousKey = Microsoft.Xna.Framework.Input.Keys.Zoom;
            }

            if (keyboardState.IsKeyDown(PreviousKey))
            {
                return;
            }

            PreviousKey = keyboardState.GetPressedKeys()[0];
            switch (keyboardState.GetPressedKeys()[0])
            {
                case Microsoft.Xna.Framework.Input.Keys.D0:
                    Rounds += "0";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.D1:
                    Rounds += "1";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.D2:
                    Rounds += "2";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.D3:
                    Rounds += "3";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.D4:
                    Rounds += "4";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.D5:
                    Rounds += "5";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.D6:
                    Rounds += "6";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.D7:
                    Rounds += "7";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.D8:
                    Rounds += "8";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.D9:
                    Rounds += "9";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.Back:
                    if (Rounds.Length > 0)
                    {
                        Rounds = Rounds.Substring(0, Rounds.Length - 1);
                    }
                    break;
                case Microsoft.Xna.Framework.Input.Keys.NumPad0:
                    Rounds += "0";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.NumPad1:
                    Rounds += "1";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.NumPad2:
                    Rounds += "2";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.NumPad3:
                    Rounds += "3";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.NumPad4:
                    Rounds += "4";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.NumPad5:
                    Rounds += "5";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.NumPad6:
                    Rounds += "6";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.NumPad7:
                    Rounds += "7";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.NumPad8:
                    Rounds += "8";
                    break;
                case Microsoft.Xna.Framework.Input.Keys.NumPad9:
                    Rounds += "9";
                    break;
                default:
                    break;
            }
        }
예제 #42
0
		private void MoveTextures(XnaKeys key) {
			if (mMarkerRectangle == Rectangle.Empty || mCurrentLayer == -1 || mTileMap == null) {
				return;
			}

			Point2D moveAdd = Point2D.Zero, startPoint = Point2D.Zero;
			startPoint.X = mMarkerRectangle.X;
			startPoint.Y = mMarkerRectangle.Y;
			var endPoint = new Point2D(startPoint.X + mMarkerRectangle.Width, startPoint.Y + mMarkerRectangle.Height);

			var cells = new TileCell[endPoint.X - startPoint.X, endPoint.Y - startPoint.Y];
			for (var mapY = startPoint.Y; mapY < endPoint.Y; mapY++) {
				for (var mapX = startPoint.X; mapX < endPoint.X; mapX++) {
					cells[mapX - startPoint.X, mapY - startPoint.Y] = mTileMap.Layers[mCurrentLayer].GetCell(mapX, mapY);
				}
			}

			if (key == XnaKeys.Up) {
				moveAdd.Y = -1;
				for (var mapX = startPoint.X; mapX < endPoint.X; mapX++) {
					mTileMap.Layers[mCurrentLayer].SetCell(new Point2D(mapX, endPoint.Y - 1), TileCell.Empty);
				}
			} else if (key == XnaKeys.Left) {
				moveAdd.X = -1;
				for (var mapY = startPoint.Y; mapY < endPoint.Y; mapY++) {
					mTileMap.Layers[mCurrentLayer].SetCell(new Point2D(endPoint.X - 1, mapY), TileCell.Empty);
				}
			} else if (key == XnaKeys.Down) {
				moveAdd.Y = 1;
				for (var mapX = startPoint.X; mapX < endPoint.X; mapX++) {
					mTileMap.Layers[mCurrentLayer].SetCell(new Point2D(mapX, startPoint.Y), TileCell.Empty);
				}
			} else if (key == XnaKeys.Right) {
				moveAdd.X = 1;
				for (var mapY = startPoint.Y; mapY < endPoint.Y; mapY++) {
					mTileMap.Layers[mCurrentLayer].SetCell(new Point2D(startPoint.X, mapY), TileCell.Empty);
				}
			}

			// move saved Cells
			for (var mapY = startPoint.Y; mapY < endPoint.Y; mapY++) {
				for (var mapX = startPoint.X; mapX < endPoint.X; mapX++) {
					mTileMap.Layers[mCurrentLayer].SetCell(mapX + moveAdd.X, mapY + moveAdd.Y, cells[mapX - startPoint.X, mapY - startPoint.Y]);
				}
			}
			
			// move our rectangle
			mMarkerRectangle.X += moveAdd.X;
			mMarkerRectangle.Y += moveAdd.Y;
		}
예제 #43
0
 public TGUIEditBox(Vector2 Pos, Vector2 Size, string DefaultText)
     : base(Pos, Size)
 {
     this.Text = DefaultText;
     TextColor = Color.Black;
     AutoSize = false;
     transparentBackground = false;
     backgroundColor = Color.Azure;
     BorderSize = 1;
     SelectAll = false;
     cursorPos = 0;
     hasFocus = false;
     sameKey = Microsoft.Xna.Framework.Input.Keys.Sleep;
     samekeyTimer = 0;
     drawCursor = false;
     cursorTimer = 0;
     Visible = true;
     Enabled = true;
     ReadOnly = false;
     ResizeOnMouse = true;
 }
예제 #44
0
            public override void Update(MouseState mouseState)
            {
                base.Update(mouseState);

                if (Enabled)
                {
                    if (!Rectangle.Intersect(
                            new Rectangle(
                                (int)(this.Pos.X + Parent.Pos.X),
                                (int)(this.Pos.Y + Parent.Pos.Y),
                                (int)(xDrawSize),
                                (int)(Size.Y)),
                                new Rectangle(
                                    (int)mouseState.X,
                                    (int)mouseState.Y,
                                    1, 1
                                    )).IsEmpty)
                        mouseOver = true;
                    else
                        mouseOver = false;

                    if ((mouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) &&
                            (oldMouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released))
                    {
                        if (mouseOver) /*(!Rectangle.Intersect(
                            new Rectangle(
                                (int)(this.Pos.X + Parent.Pos.X),
                                (int)(this.Pos.Y + Parent.Pos.Y),
                                (int)(xDrawSize),
                                (int)(Size.Y)),
                             new Rectangle(
                                 (int)mouseState.X,
                                 (int)mouseState.Y,
                                 1, 1
                                 )).IsEmpty)*/
                        {
                            if (!hasFocus)
                            {
                                SelectAll = true;
                                cursorPos = Text.Length;
                                hasFocus = true;
                            }
                            else
                            {
                                SelectAll = false;
                                cursorTimer = 0;
                                int i = 0;
                                cursorPos = 0;
                                while (i <= textDLength)
                                {
                                    if ((mouseState.X - this.Pos.X + Parent.Pos.X - 2) < GUI.Fonts[Font].MeasureString(Text.Substring(0, i)).X)
                                        i = Text.Length + 10;
                                    i++;
                                    cursorPos++;
                                }
                                cursorPos--;
                            }
                        }
                        else
                        {
                            SelectAll = false;
                            cursorPos = 0;
                            hasFocus = false;
                            sameKey = Microsoft.Xna.Framework.Input.Keys.Sleep;
                            samekeyTimer = 0;
                            drawCursor = false;
                            cursorTimer = 0;
                        }
                    }
                    oldMouseState = mouseState;

                    keyboardState = Keyboard.GetState();
                    if (!ReadOnly)
                    {
                        if (keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.CapsLock))
                            if (oldkeyboardState.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.CapsLock))
                                capsLocked = !capsLocked;
                        if (hasFocus)
                        {
                            if (keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter))
                            {
                                hasFocus = false;
                                SelectAll = false;
                                drawCursor = false;
                            }
                            if (keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left))
                            {
                                if (keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift) ||
                                    keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightShift))
                                {
                                }
                                else
                                {
                                    if (oldkeyboardState.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Left))
                                    {
                                        samekeyTimer = 0;
                                        cursorPos--;
                                        cursorTimer = 0;
                                        drawCursor = true;
                                        SelectAll = false;
                                    }
                                    else
                                        samekeyTimer++;

                                    if (samekeyTimer > 30)
                                    {
                                        cursorPos--;
                                        samekeyTimer = 25;
                                        cursorTimer = 0;
                                        drawCursor = true;
                                        SelectAll = false;
                                    }
                                }
                            }
                            if (keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right))
                            {
                                if (keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift) ||
                                    keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.RightShift))
                                {
                                }
                                else
                                {
                                    if (oldkeyboardState.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Right))
                                    {
                                        samekeyTimer = 0;
                                        cursorPos++;
                                        cursorTimer = 0;
                                        drawCursor = true;
                                        SelectAll = false;
                                    }
                                    else
                                        samekeyTimer++;

                                    if (samekeyTimer > 30)
                                    {
                                        cursorPos++;
                                        samekeyTimer = 20;
                                        cursorTimer = 0;
                                        drawCursor = true;
                                        SelectAll = false;
                                    }
                                }
                            }

                            foreach (Microsoft.Xna.Framework.Input.Keys key in keyboardState.GetPressedKeys())
                            {
                                if (oldkeyboardState.IsKeyDown(key))
                                    samekeyTimer++;
                                if ((oldkeyboardState.IsKeyUp(key) || (samekeyTimer > 20)) && (
                                    (key != Microsoft.Xna.Framework.Input.Keys.Left) && (key != Microsoft.Xna.Framework.Input.Keys.Right) &&
                                    (key != Microsoft.Xna.Framework.Input.Keys.LeftShift) && (key != Microsoft.Xna.Framework.Input.Keys.RightShift)
                                    ))
                                {
                                    if (key == Microsoft.Xna.Framework.Input.Keys.Back)
                                    {
                                        if (SelectAll)
                                        {
                                            Text = "";
                                            cursorPos = 0;
                                            SelectAll = false;
                                        }
                                        else
                                            if (cursorPos > 0)
                                            {
                                                Text = Text.Remove(cursorPos - 1, 1);
                                                cursorPos--;
                                            }
                                    }
                                    else
                                    {
                                        string adds = " ";
                                        if (key == Microsoft.Xna.Framework.Input.Keys.Space)
                                        {
                                            if (SelectAll)
                                            {
                                                Text = adds;
                                                cursorPos = 0;
                                                SelectAll = false;
                                            }
                                            Text = Text.Insert(cursorPos, adds);
                                        }
                                        else
                                        {
                                            adds = CharFromKey(key, keyboardState, capsLocked);
                                            Text = Text.Insert(cursorPos, adds);
                                            if ((SelectAll) && (adds.Length > 0))
                                            {
                                                Text = adds;
                                                cursorPos = 0;
                                                SelectAll = false;
                                            }
                                        }
                                        cursorPos += adds.Length;
                                    }
                                    if (key == sameKey)
                                        samekeyTimer = 12;
                                    else
                                    {
                                        samekeyTimer = 0;
                                        sameKey = key;
                                    }
                                }
                            }

                            cursorTimer++;
                            if (cursorTimer > 25)
                            {
                                drawCursor = !drawCursor;
                                cursorTimer = 0;
                            }
                        }
                    }
                }

                oldkeyboardState = keyboardState;

                cursorPos = Math.Min(cursorPos, Text.Length);
                cursorPos = Math.Max(cursorPos, 0);

                if (((hasFocus) || (mouseOver)) && (ResizeOnMouse))
                {
                    xDrawSize = Math.Max((int)GUI.Fonts[Font].MeasureString(Text).X + 3, (int)Size.X);
                    textDLength = Text.Length;
                }
                else
                {
                    xDrawSize = (int)Size.X;
                    int i = 0;
                    while ((i < Text.Length) &&
                        (GUI.Fonts[Font].MeasureString(Text.Substring(0, i)).X < xDrawSize))
                        i++;
                    if (i != Text.Length)
                        i--;
                    textDLength = i;
                }
            }
예제 #45
0
 private void CheckForClick(ref KeyboardState keyboardState, ref KeyboardState oldKeyboardState, Keys key, Vector3 direction)
 {
     if (keyboardState.IsKeyDown(key) && oldKeyboardState.IsKeyUp(key))
     {
         AlgOrder += (VectorToChar(direction));
         AllTimeAlgOrder += (VectorToChar(direction));
         if (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))
             AlgOrder += "I";
         YAlgOrder = "";
     }
     //camera.RealRotate(cameraPos);
 }
        /// <summary>
        /// Modifies the StringBuilder based on the pressed key.
        /// </summary>
        /// <param name="key">
        /// The key being pressed.
        /// </param>
        /// <param name="shift">
        /// Is the shift key down or capslock on?.
        /// </param>
        /// <param name="capsLock">
        /// Is caps lock on?.
        /// </param>
        /// <param name="numLock">
        /// Is num lock on?.
        /// </param>
        /// <param name="text">
        /// The StringBuilder to be modified.
        /// </param>
        private void ProcessKey(Keys key, bool shift, bool capsLock, bool numLock, StringBuilder text)
        {
            if (key == Keys.Back && text.Length > 0)
            {
                text = text.Remove(text.Length - 1, 1);
            }

            var newChar = this.GetCharacter(key, shift, capsLock, numLock);

            if (newChar.HasValue)
            {
                text.Append(newChar.Value);
            }
        }