Exemplo n.º 1
0
 // When user move the cursor we save position of mouse if
 public void OnCursorMoved(object sender, CursorMovedEventArgs e)
 {
     if (isClicking)
     {
         aim = Game1.currentCursorTile;
     }
 }
Exemplo n.º 2
0
        /// <summary>Raised after the player moves the in-game cursor.</summary>
        /// <param name="e">The event arguments.</param>
        public virtual void OnCursorMoved(CursorMovedEventArgs e)
        {
            if (this.CurrentModal != null)
            {
                this.CurrentModal.OnCursorMoved(e);
                return;
            }

            int x = (int)e.NewPosition.ScreenPixels.X;
            int y = (int)e.NewPosition.ScreenPixels.Y;

            foreach (IDrawable drawable in this.drawables)
            {
                switch (drawable)
                {
                case IHighlightable highlightable:
                    highlightable.Highlighted = highlightable.Bounds.Contains(x, y);
                    break;

                case ConditionalElement conditional:
                    if (conditional.GetElementForHighlight() is IHighlightable condHighlightable)
                    {
                        condHighlightable.Highlighted = condHighlightable.Bounds.Contains(x, y);
                    }
                    break;

                case ElementContainer container:
                    foreach (IHighlightable element in container.Elements.OfType <IHighlightable>())
                    {
                        element.Highlighted = element.Bounds.Contains(x, y);
                    }
                    break;
                }
            }
        }
Exemplo n.º 3
0
        private void Input_CursorMoved(object sender, CursorMovedEventArgs e)
        {
            this.CursorPosition = e.NewPosition;

            if (!Context.IsWorldReady || Game1.currentLocation?.currentEvent != null)
            {
                return;
            }

            Vector2      cursorTile = e.OldPosition.Tile;
            GameLocation location   = Game1.currentLocation;
            NPC          n          = location.isCharacterAtTile(cursorTile);

            if (n == null)
            {
                // Try next Y position if no NPC fetched
                n = location.isCharacterAtTile(cursorTile + new Vector2(0f, 1f));
                if (n == null)
                {
                    this.ResetHint();
                    return;
                }
            }

            this.OnCheckHint(n);
        }
Exemplo n.º 4
0
        /// <summary>Raised after the player moves the in-game cursor.</summary>
        /// <param name="e">The event data.</param>
        public override void OnCursorMoved(CursorMovedEventArgs e)
        {
            base.OnCursorMoved(e);

            _minusButton.OnCursorMoved(e);
            _plusButton.OnCursorMoved(e);
        }
Exemplo n.º 5
0
        public void OnMouseMoved(CursorMovedEventArgs e)
        {
            Point NewPos = e.NewPosition.ScreenPixels.AsPoint();

            if (TextureDestination.Contains(NewPos))
            {
                Point     RelativePos = new Point(NewPos.X - TextureDestination.X, NewPos.Y - TextureDestination.Y);
                Rectangle?Previous    = HoveredSprite;
                Rectangle Current     = new Rectangle(RelativePos.X / SpriteSize * SpriteSize, RelativePos.Y / SpriteSize * SpriteSize, SpriteSize, SpriteSize);
                if (!Previous.HasValue || Previous.Value.X != Current.X || Previous.Value.Y != Current.Y)
                {
                    this.HoveredSprite = Current;
                }
            }
            else
            {
                HoveredSprite = null;
            }

            if (DefaultButtonDestination.Contains(NewPos))
            {
                this.HoveredButton = DefaultButtonDestination;
            }
            else if (CloseButtonDestination.Contains(NewPos))
            {
                this.HoveredButton = CloseButtonDestination;
            }
            else
            {
                this.HoveredButton = null;
            }
        }
Exemplo n.º 6
0
        public override void OnCursorMoved(CursorMovedEventArgs e)
        {
            Debug.Assert(this.Calendar.IsOpen, "OnCursorMoved being called but the calendar isn't open");

            // This gets the scaled mouse position
            SVector2 mouse = new SVector2(Game1.getMouseX(), Game1.getMouseY());

            int hoveredDay = this.Calendar.GetHoveredDayIndex(mouse) + 1; // Days start at one

            if (hoveredDay == this.HoveredDay)
            {
                return;
            }

            this.HoveredDay = hoveredDay;
            if (this.Birthdays.ContainsKey(hoveredDay))
            {
                string npcName = this.Birthdays[hoveredDay].Name;
                this.DrawCurrentFrame = SetSelectedNPC(npcName);
            }
            else
            {
                this.DrawCurrentFrame = false;
            }
        }
Exemplo n.º 7
0
        private void OnCursorMoved(object sender, CursorMovedEventArgs e)
        {
            isHoveringClock = false;

            if (!Context.IsWorldReady)
            {
                return;
            }

            if (!Context.IsPlayerFree)
            {
                return;
            }

            if (!Context.IsMainPlayer)
            {
                return;
            }

            float   clockRadius    = 111f / 1600f;
            Vector2 clockCenter    = new Vector2(1336f / 1600f, 117f / 900f);
            Vector2 boxTopLeft     = new Vector2(1343f / 1600f, 14f / 900f);
            Vector2 boxBottomRight = new Vector2(1576f / 1600f, 211f / 900f);
            Vector2 cursorRelative = new Vector2(e.NewPosition.ScreenPixels.X / (float)Game1.viewport.Width, e.NewPosition.ScreenPixels.Y / (float)Game1.viewport.Height);

            if (Vector2.DistanceSquared(cursorRelative, clockCenter) < clockRadius * clockRadius ||
                (boxTopLeft.X <= cursorRelative.X && cursorRelative.X <= boxBottomRight.X &&
                 boxTopLeft.Y <= cursorRelative.Y && cursorRelative.Y <= boxBottomRight.Y))
            //if( Vector2.DistanceSquared( cursorRelative, clockCenter ) < clockRadius * clockRadius )
            {
                isHoveringClock = true;
            }
            //this.Log( $"{Game1.mouse}" );
        }
Exemplo n.º 8
0
 private void Input_CursorMoved(object sender, CursorMovedEventArgs e)
 {
     if (Context.IsWorldReady)
     {
         m_aoeOverlayManager.SetItemToDraw(m_doDrawMouseOver ? Game1.currentLocation.getObjectAtTile((int)e.NewPosition.Tile.X, (int)e.NewPosition.Tile.Y) : null);
     }
 }
Exemplo n.º 9
0
 /// <summary>Raised after the player moves the in-game cursor.</summary>
 /// <param name="e">The event data.</param>
 internal static void OnCursorMoved(CursorMovedEventArgs e)
 {
     foreach (var button in PrestigeButtons)
     {
         button.OnCursorMoved(e);
     }
 }
Exemplo n.º 10
0
 /// <summary>Raised after the player moves the in-game cursor.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event data.</param>
 private void OnCursorMoved(object sender, CursorMovedEventArgs e)
 {
     SkillsMenuExtension.OnCursorMoved(e);
     if (Game1.activeClickableMenu is IInputHandler handler)
     {
         handler.OnCursorMoved(e);
     }
 }
Exemplo n.º 11
0
 // Update the hitbox when further away from character
 private void Input_CursorMoved(object sender, CursorMovedEventArgs e)
 {
     if (!Context.IsWorldReady || !Context.IsPlayerFree || Game1.player.isCharging || Game1.player.isRidingHorse() || Game1.player.UsingTool)
     {
         return;
     }
     UpdateGrabTileAndCursor(e.NewPosition);
 }
Exemplo n.º 12
0
 private static void Input_MouseMoved(object sender, CursorMovedEventArgs e)
 {
     if (Game1.activeClickableMenu != null && Game1.activeClickableMenu is ItemBagMenu IBM)
     {
         try { IBM.OnMouseMoved(e); }
         catch (Exception ex) { Monitor.Log(string.Format("Unhandled error while handling Mouse moved: {0}\n\n{1}", ex.Message, ex.ToString()), LogLevel.Error); }
     }
 }
Exemplo n.º 13
0
 private void InputEvents_CursorMoved(object sender, CursorMovedEventArgs e)
 {
     if (!Context.IsPlayerFree || current_location == null || !mouse_hover && !is_button_pressed)
     {
         return;
     }
     FindCrop();
 }
Exemplo n.º 14
0
 private void Input_CursorMoved(object sender, CursorMovedEventArgs e)
 {
     MouseScreenPosition = e.NewPosition.ScreenPixels;
     HoveredTile         = new Vector2(
         (int)((Game1.viewport.X + MouseScreenPosition.X / (Game1.options.zoomLevel / Game1.options.uiScale)) / Game1.tileSize),
         (int)((Game1.viewport.Y + MouseScreenPosition.Y / (Game1.options.zoomLevel / Game1.options.uiScale)) / Game1.tileSize)
         );
 }
Exemplo n.º 15
0
        /// <summary>Raised after the player moves the in-game cursor.</summary>
        /// <param name="e">The event data.</param>
        public void OnCursorMoved(CursorMovedEventArgs e)
        {
            if (_debounceTimer > 0)
            {
                return;
            }

            _okayButton.OnCursorMoved(e);
        }
Exemplo n.º 16
0
 /// <summary>Raised after the player moves the in-game cursor.</summary>
 /// <param name="e">The event data.</param>
 public virtual void OnCursorMoved(CursorMovedEventArgs e)
 {
     IsHovered = ContainsPoint(e.NewPosition);
     if (IsHovered && !ContainsPoint(e.OldPosition))
     {
         Logger.LogVerbose($"{Text ?? HoverText} button has focus.");
         OnMouseHovered();
     }
 }
Exemplo n.º 17
0
        private void OnCursorMoved(object sender, CursorMovedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }

            UpdateHoverText();
        }
Exemplo n.º 18
0
        /// <summary>Raised after the player moves the in-game cursor.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnCursorMoved(object sender, CursorMovedEventArgs e)
        {
            Debug.Assert(this.CurrentGiftHelper != null, "OnCursorMoved listener invoked when currentGiftHelper is null.");

            if (this.CurrentGiftHelper.CanTick())
            {
                this.CurrentGiftHelper.OnCursorMoved(e);
            }
        }
Exemplo n.º 19
0
        public void OnMouseMoved(CursorMovedEventArgs e)
        {
            if (Bounds.Contains(e.OldPosition.ScreenPixels.AsPoint()) || Bounds.Contains(e.NewPosition.ScreenPixels.AsPoint()))
            {
                Rectangle?PreviouslyHovered = HoveredSlot;

                this.HoveredSlot = null;
                if (SlotBounds != null)
                {
                    foreach (Rectangle Rect in SlotBounds)
                    {
                        if (Rect.Contains(e.NewPosition.ScreenPixels.AsPoint()))
                        {
                            if (PreviouslyHovered.HasValue && Rect != PreviouslyHovered.Value)
                            {
                                SecondaryActionButtonPressedLocation = null;
                            }
                            this.HoveredSlot             = Rect;
                            this.IsNavigatingWithGamepad = false;
                            break;
                        }
                    }
                }
            }

            if (IsRightSidebarVisible)
            {
                Point OldPos = e.OldPosition.ScreenPixels.AsPoint();
                Point NewPos = e.NewPosition.ScreenPixels.AsPoint();

                if (ContentsRightSidebarButtonBounds.Any(x => x.Contains(OldPos) || x.Contains(NewPos)))
                {
                    if (SortingPropertyBounds.Contains(NewPos))
                    {
                        this.HoveredContentsButton   = ContentsSidebarButton.SortingProperty;
                        this.IsNavigatingWithGamepad = false;
                    }
                    else if (SortingOrderBounds.Contains(NewPos))
                    {
                        this.HoveredContentsButton   = ContentsSidebarButton.SortingOrder;
                        this.IsNavigatingWithGamepad = false;
                    }
                    else
                    {
                        this.HoveredContentsButton = null;
                    }
                }
                else
                {
                    this.HoveredContentsButton = null;
                }
            }

            UpdateHoveredItem(e);
        }
Exemplo n.º 20
0
 public void UpdateHoveredItem(CursorMovedEventArgs e)
 {
     if (Bounds.Contains(e.NewPosition.LegacyScreenPixels().AsPoint()))
     {
         HoveredItem = HoveredObject;
     }
     else
     {
         HoveredItem = null;
     }
 }
Exemplo n.º 21
0
 /// <summary>Raised after the player moves the in-game cursor.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 private void OnCursorMoved(object sender, CursorMovedEventArgs e)
 {
     if (this.activeObject != null && Game1.activeClickableMenu == null && this.config.ShowRangeOfHeldItem)
     {
         this.RefreshRangeItems(Game1.currentLocation);
     }
     else if (this.config.ShowRangeOfHoveredOverItem && this.isModifierKeyDown)
     {
         this.RefreshRangeItems(Game1.currentLocation);
     }
 }
Exemplo n.º 22
0
        /// <summary>
        /// Checks to see if the cursor is hovering over the button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnCursorMoved(object sender, CursorMovedEventArgs e)
        {
            if (!Context.IsWorldReady)
            {
                return;
            }
            int x = (int)e.NewPosition.ScreenPixels.X;
            int y = (int)e.NewPosition.ScreenPixels.Y;

            handler.TryHover(x, y);
        }
Exemplo n.º 23
0
 public void UpdateHoveredItem(CursorMovedEventArgs e)
 {
     if (Bounds.Contains(e.NewPosition.ScreenPixels.AsPoint()))
     {
         HoveredItem = GetHoveredItem();
     }
     else
     {
         HoveredItem = null;
     }
 }
Exemplo n.º 24
0
 /// <summary>Checks for mouse drag while holding any Tool Button.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event data.</param>
 private void OnCursorMoved(object sender, CursorMovedEventArgs e)
 {
     try
     {
         if (holdingToolButton()) // Update override location as long as a Tool Button is held (range validity checked later)
             specialClickLocation = e.NewPosition.AbsolutePixels;
     }
     catch (Exception ex)
     {
         Log("Error in cursor move: " + ex.Message + Environment.NewLine + ex.StackTrace);
     }
 }
        public override void OnCursorMoved(CursorMovedEventArgs e)
        {
            Debug.Assert(this.IsCorrectMenuTab(Game1.activeClickableMenu));
            if (!Utils.Ensure(this.SocialPage != null, "Social Page is null!"))
            {
                return;
            }

            SVector2 mousePos = new SVector2(e.NewPosition.ScreenPixels.X, e.NewPosition.ScreenPixels.Y);

            UpdateHoveredNPC(mousePos);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Tracks the cursor position to change the sprite if hovered over
        /// </summary>
        private void OnCursorMoved(object sender, CursorMovedEventArgs e)
        {
            if (cycleType != CycleType.Hover || !calendarOpen)
            {
                return;
            }

            // Force the game in UIMode to get the correct scaling for pixel coordinates, since for calendar UIMode = false, for some reason...
            Game1.InUIMode(() =>
            {
                cursorPos = e.NewPosition.GetScaledScreenPixels();
            });
        }
Exemplo n.º 27
0
        /// <summary>Raised after the player moves the in-game cursor.</summary>
        /// <param name="e">The event data.</param>
        public void OnCursorMoved(CursorMovedEventArgs e)
        {
            if (_debounceTimer > 0)
            {
                return;
            }

            foreach (var button in _professionButtons)
            {
                button.OnCursorMoved(e);
            }
            _prestigeButton.OnCursorMoved(e);
            _settingsButton.OnCursorMoved(e);
        }
Exemplo n.º 28
0
        /// <inheritdoc cref="IInputEvents.CursorMoved"/>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnCursorMoved(object?sender, CursorMovedEventArgs e)
        {
            if (Context.ScreenId != this.ScreenId)
            {
                return;
            }

            bool uiMode       = this.AssumeUiMode ?? Game1.uiMode;
            bool hoverHandled = this.ReceiveCursorHover(Game1.getMouseX(uiMode), Game1.getMouseY(uiMode));

            if (hoverHandled)
            {
                Game1.InvalidateOldMouseMovement();
            }
        }
Exemplo n.º 29
0
        private void Input_CursorMoved(object sender, CursorMovedEventArgs e)
        {
            bool flag = Context.IsWorldReady;

            if (isRightClickMoveModeOn)
            {
                if (flag)
                {
                    if (Context.IsPlayerFree)
                    {
                        position_MouseOnScreen.X = (float)e.NewPosition.ScreenPixels.X;
                        position_MouseOnScreen.Y = (float)e.NewPosition.ScreenPixels.Y;
                    }
                }
            }
        }
Exemplo n.º 30
0
        /// <summary>Raised after the player moves the in-game cursor.</summary>
        /// <param name="e">The event data.</param>
        public void OnCursorMoved(CursorMovedEventArgs e)
        {
            if (_debounceTimer > 0)
            {
                return;
            }

            _resetRecipesCheckbox.OnCursorMoved(e);
            _useExperienceMultiplierCheckbox.OnCursorMoved(e);
            _painlessPrestigeModeCheckbox.OnCursorMoved(e);

            _tierOneCostEditor.OnCursorMoved(e);
            _tierTwoCostEditor.OnCursorMoved(e);
            _pointsPerPrestigeEditor.OnCursorMoved(e);
            _experiencePerPainlessPrestigeEditor.OnCursorMoved(e);
        }
Exemplo n.º 31
0
		private void WaveControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) {
			stopPlayer();
			if (e.Button == MouseButtons.Left) {
				cursorEvent = null;
				m_DragStart = e;
				if (m_Cursors != null) {
					// Work out which cursor we are close to
					float pixelsPerSecond = Width / m_LengthSeconds;
					int l = -1, r = -1;
					for (int i = 0; i < m_Cursors.Length; i++) {
						PositionCursor c = m_Cursors[i];
						if (!c.Active)
							continue;
						float x = (c.Position - m_StartSeconds) * pixelsPerSecond;	// Position of cursor in pixels
						if (Math.Abs(x - e.X) < 10) {
							// We are close to this cursor
							if (x < e.X) {
								// Cursor to left of mouse
								if (l == -1 || c.Position >= m_Cursors[l].Position)
									l = i;	// It's the closest one to the mouse, or same position but larger cursor no
							} else {
								// Cursor to right of mouse
								if (r == -1 || c.Position < m_Cursors[r].Position)
									r = i;	// It's the closest one to the mouse or same position but smaller cursor no
							}
						}
					}
					int csr = -1;		// Cursor we want to drag
					if(l == -1) {
						// No cursor to left
						if(r == -1)	// Or right either
							return;
						csr = r;	// Choose one to right
					} else if (r == -1) {
						// No cursor to right
						csr = l;	// Choose one to left
					} else {
						// Cursors on both sides - choose closest
						float lx = (m_Cursors[l].Position - m_StartSeconds) * pixelsPerSecond;
						float rx = (m_Cursors[r].Position - m_StartSeconds) * pixelsPerSecond;
						if (rx - e.X < e.X - lx)
							csr = r;
						else
							csr = l;
					}
					// Set up cursor event for cursor
					cursorEvent = new CursorMovedEventArgs(m_Cursors[csr]);
					m_Dragging = false;	// Not dragging yet
				}
			} else if (e.Button == System.Windows.Forms.MouseButtons.Right) {
				// Right click displays filtered average volume in a tooltip
				try {
					float pixelsPerSecond = Width / m_LengthSeconds;
					float p = m_StartSeconds + e.X / pixelsPerSecond;	// Position of click in seconds
					m_Wavefile.Position = WaveFormat.SecondsToBytes(p);
					FilteredSampleProvider f = new FilteredSampleProvider(m_Wavefile, Properties.Settings.Default.SilenceFilterCentre, Properties.Settings.Default.SilenceFilterQ);
					// Display average volume of block at this position
					float avg = f.AvgBlockVolume();
					string tip = string.Format("pos={0} level={1:#0.0####}", p.ToTimeSpanString(), avg);
					Program.Trace(tip);
					toolTip.Show(tip, this);
				} catch {
				}
			}
		}
Exemplo n.º 32
0
		private void WaveControl_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (e.Button == MouseButtons.Left) {
				stopPlayer();
				if (m_Dragging) {
					if (cursorEvent != null) {
						// Have finished dragging - fire event
						cursorEvent.Cursor.FireCursorMoveFinished(cursorEvent);
						cursorEvent = null;
					}
					m_Dragging = false;
				} else if(!m_PlayerJustStopped) {
					if (m_Wavefile != null) {
						if (m_DragStart == null || Math.Abs(e.X - m_DragStart.X) > 5 || Math.Abs(e.Y - m_DragStart.Y) > 5)
							return;		// Ignore everything except click
						float start = m_StartSeconds;					// Where to start playing
						float end = m_StartSeconds + m_LengthSeconds;	// and end
						float pixelsPerSecond = Width / m_LengthSeconds;
						if (m_Cursors != null) {
							// Play only between cursors
							for (int i = 0; i < m_Cursors.Length; i++) {
								PositionCursor c = m_Cursors[i];
								if (!c.Active)
									continue;
								float x = (c.Position - m_StartSeconds) * pixelsPerSecond;
								if (x <= e.X)
									start = Math.Max(start, c.Position);
								else
									end = Math.Min(end, c.Position);
							}
						}
						// If click not near start, start from click position
						float sx = (start - m_StartSeconds) * pixelsPerSecond;
						if (e.X - sx > 20)
							start = m_StartSeconds + e.X / pixelsPerSecond;
						m_Wavefile.Position = WaveFormat.SecondsToBytes(start);
						NotifyingSampleProvider p = new NotifyingSampleProvider(new OffsetSampleProvider(m_Wavefile) {
							Take = new TimeSpan((long)(10000000 * (end - start)))
						});
						p.Sample += SampleCounter;		// To keep track of samples played, for play position cursor
						m_SampleCount = (int)(start * WaveFormat.SampleRate);	// Play position, in samples
						m_Timer.Interval = (int)(1000 / pixelsPerSecond);		// Should fire about every pixel
						m_Timer.Start();
						m_CurrentPlayer = m_Player = new NAudio.Wave.DirectSoundOut();
						m_Player.PlaybackStopped += PlaybackStopped;
						if(Control.ModifierKeys == Keys.Control)	// Play filtered sound
							m_Player.Init(new FilteredSampleProvider(p, Properties.Settings.Default.SilenceFilterCentre, Properties.Settings.Default.SilenceFilterQ));
						else {
								// Play wave file
						}
							m_Player.Init(p);
						m_Player.Play();
						Refresh();
					}
				}
			}
			m_PlayerJustStopped = false;
		}
Exemplo n.º 33
0
			/// <summary>
			/// Fire event if required
			/// </summary>
			public void FireCursorMoveFinished(CursorMovedEventArgs args) {
				if (CursorMoveFinished != null)
					CursorMoveFinished(this, args);
			}