private static void MouseChanged(object sender, EventArgsMouseStateChanged args)
 {
     HandleState(args);
 }
Example #2
0
 private void MouseChanged(object sender, EventArgsMouseStateChanged e)
 {
     game.MouseChanged(e.NewPosition);
 }
Example #3
0
 public void MouseStateChanged(EventArgsMouseStateChanged e)
 {
     throw new System.NotImplementedException();
 }
Example #4
0
 public virtual void OnMouseStateChange(EventArgsMouseStateChanged e)
 {
     // Empty
 }
 private void MouseChanged(object sender, EventArgsMouseStateChanged e)
 {
     this.intendedState.XPosition = e.NewPosition.X;
 }
        protected virtual void MouseChanged(object sender, EventArgsMouseStateChanged e)
        {
            if (GameMenu.forcePreventClose)
            {
                return;
            }
            if (!(Game1.activeClickableMenu is GameMenu))
            {
                return;
            }                                                                     // must be main menu
            if ((Game1.activeClickableMenu as GameMenu).currentTab != MenuController.PageIndex)
            {
                return;
            }                                                                                                           //must be mod tab

            var currentSheet = Sheets.Find(x => x.Visible);

            if (e.NewState.ScrollWheelValue > e.PriorState.ScrollWheelValue)
            {
                if (currentSheet != null)
                {
                    currentSheet.receiveScrollWheelAction(1);
                }
            }
            else if (e.NewState.ScrollWheelValue < e.PriorState.ScrollWheelValue)
            {
                if (currentSheet != null)
                {
                    currentSheet.receiveScrollWheelAction(-1);
                }
            }

            if (e.PriorState.LeftButton == ButtonState.Released)
            {
                if (e.NewState.LeftButton == ButtonState.Pressed)
                {
                    // clicked
                    if (currentSheet != null)
                    {
                        currentSheet.receiveLeftClick(e.NewPosition.X, e.NewPosition.Y);
                    }
                    ModDropdown.ReceiveLeftClick(e.NewPosition.X, e.NewPosition.Y);
                }
            }
            else if (e.PriorState.LeftButton == ButtonState.Pressed)
            {
                if (e.NewState.LeftButton == ButtonState.Pressed)
                {
                    if (currentSheet != null)
                    {
                        currentSheet.leftClickHeld(e.NewPosition.X, e.NewPosition.Y);
                    }
                    ModDropdown.LeftClickHeld(e.NewPosition.X, e.NewPosition.Y);
                }
                else if (e.NewState.LeftButton == ButtonState.Released)
                {
                    if (currentSheet != null)
                    {
                        currentSheet.releaseLeftClick(e.NewPosition.X, e.NewPosition.Y);
                    }
                    ModDropdown.ReleaseLeftClick(e.NewPosition.X, e.NewPosition.Y);
                }
            }
        }
Example #7
0
        private void ControlEvents_MouseChanged(object sender, EventArgsMouseStateChanged e)
        {
            // If the world isn't ready, or the player didn't left click, we have nothing to work with.
            if (!Context.IsWorldReady || e.NewState.LeftButton != ButtonState.Pressed)
            {
                return;
            }

            // Create a reference to the current menu, and make sure it isn't null.
            var menu = (Game1.activeClickableMenu as GameMenu);

            if (menu == null || menu.currentTab != GameMenu.mapTab) // Also make sure it's on the right tab(Map)
            {
                return;
            }

            // Get the map page from the menu.
            var mapPage = (Helper.Reflection.GetField <List <IClickableMenu> >(menu, "pages").GetValue()[3]) as MapPage;

            if (mapPage == null) // Gotta be safe
            {
                return;
            }

            // Do balanced behavior.
            // (This is done after getting the map/menu to prevent spamming notifications when the player isn't in the menu)
            if (Config.BalancedMode && Game1.player.mount == null)
            {
                Game1.showGlobalMessage("You can't fast travel without a horse!");
                Game1.exitActiveMenu();
                return;
            }

            int x = Game1.getMouseX();
            int y = Game1.getMouseY();

            foreach (ClickableComponent point in mapPage.points)
            {
                // If the player isn't hovering over this point, don't worry about anything.
                if (!point.containsPoint(x, y))
                {
                    continue;
                }

                // Lonely Stone is blocked because it's not an actual place
                // Quarry is blocked because it's broken currently.
                // TODO - Fix the visual bug with Quarry
                if (point.name == "Lonely Stone")
                {
                    continue;
                }

                // Make sure the location is valid
                if (!FastTravelUtils.PointExistsInConfig(point))
                {
                    Monitor.Log($"Failed to find a warp for point [{point.name}]!", LogLevel.Warn);

                    // Right now this closes the map and opens the players bag and doesn't give
                    // the player any information in game about what just happened
                    // so we tell them a warp point wasnt found and close the menu.
                    Game1.showGlobalMessage($"No warp point found.");
                    Game1.exitActiveMenu();
                    continue;
                }

                // Get the location, and warp the player to it's first warp.
                var location        = FastTravelUtils.GetLocationForMapPoint(point);
                var fastTravelPoint = FastTravelUtils.GetFastTravelPointForMapPoint(point);

                // If the player is in balanced mode, block warping to calico altogether.
                if (Config.BalancedMode && fastTravelPoint.GameLocationIndex == 28)
                {
                    Game1.showGlobalMessage("Fast-Travel to Calico Desert is disabled in balanced mode!");
                    Game1.exitActiveMenu();
                    return;
                }

                // Dismount the player if they're going to calico desert, since the bus glitches with mounts.
                if (fastTravelPoint.GameLocationIndex == 28 && Game1.player.mount != null)
                {
                    Game1.player.mount.dismount();
                }

                // Warp the player to their location, and exit the map.
                Game1.warpFarmer(fastTravelPoint.RerouteName == null ? location.Name : fastTravelPoint.RerouteName, fastTravelPoint.SpawnPosition.X, fastTravelPoint.SpawnPosition.Y, false);
                Game1.exitActiveMenu();

                // Lets check for warp status and give the player feed back on what happened to the warp.
                // We are doing this check on a thread because we have to wait untill the warp has finished
                // to check its result.
                var locationNames = new String[] { fastTravelPoint.RerouteName, location.Name };
                var t1            = new Thread(new ParameterizedThreadStart(CheckIfWarped));
                t1.Start(locationNames);
            }
        }
Example #8
0
 private void ControlEvents_MouseChanged(object sender, EventArgsMouseStateChanged e)
 {
     this.currentMenu?.MouseStateChanged(e);
 }
Example #9
0
        private void on_post_render_event(object sender, EventArgsMouseStateChanged e)
        {
            if (Game1.activeClickableMenu != null)
            {
                terrain = null;
                return;
            }

            if (terrain != null && ButtonState.Pressed.Equals(e.PriorState.RightButton) && ButtonState.Released.Equals(e.NewState.RightButton))
            {
                this.Monitor.Log("removed terrain");
                terrain = null;
            }

            Vector2 vector2 = (double)Game1.mouseCursorTransparency == 0.0 ? Game1.player.GetToolLocation(false) : new Vector2((float)(Game1.getOldMouseX() + Game1.viewport.X), (float)(Game1.getOldMouseY() + Game1.viewport.Y));

            if (Game1.currentLocation != null)
            {
                Vector2 index = new Vector2((float)((Game1.getOldMouseX() + Game1.viewport.X) / Game1.tileSize), (float)((Game1.getOldMouseY() + Game1.viewport.Y) / Game1.tileSize));

                SerializableDictionary <Vector2, StardewValley.TerrainFeatures.TerrainFeature> terrainMap = Game1.currentLocation.terrainFeatures;
                if (terrainMap != null && terrainMap.ContainsKey(index))
                {
                    if (terrainMap[index] is StardewValley.TerrainFeatures.HoeDirt && (terrain == null || terrain != terrainMap[index]))
                    {
                        terrain = (terrainMap[index] as StardewValley.TerrainFeatures.HoeDirt);
                        StardewValley.Crop crop = terrain.crop;
                        if (crop != null)
                        {
                            String cropName          = Game1.objectInformation[crop.indexOfHarvest].Split('/')[0];
                            bool   isCropHarvestable = crop.currentPhase >= crop.phaseDays.Count - 1 && (!crop.fullyGrown || crop.dayOfCurrentPhase <= 0);

                            String cropInformation = $"\nCrop Information: \n\tname: {cropName}\n\tisHarvestable: {isCropHarvestable}";
                            foreach (System.Reflection.FieldInfo field in crop.GetType().GetFields())
                            {
                                cropInformation += $"\n\t{field.Name}: ";

                                if (field.GetValue(crop) is System.Collections.Generic.List <String> )
                                {
                                    System.Collections.Generic.List <String> asd = field.GetValue(crop) as System.Collections.Generic.List <String>;

                                    cropInformation += String.Join(", ", asd.ToArray());
                                }
                                else if (field.GetValue(crop) is System.Collections.Generic.List <Int32> )
                                {
                                    System.Collections.Generic.List <Int32> asd = field.GetValue(crop) as System.Collections.Generic.List <Int32>;
                                    cropInformation += String.Join(", ", asd.ToArray());
                                }
                                else
                                {
                                    cropInformation += $"{field.GetValue(crop).ToString()}";
                                }
                            }
                            this.Monitor.Log(cropInformation);
                        }
                    }
                    else if (!(terrainMap[index] is StardewValley.TerrainFeatures.HoeDirt))
                    {
                        terrain = null;
                    }
                }
            }
        }
Example #10
0
        private void OnMouseStateChange(object sender, EventArgsMouseStateChanged e)
        {
            Debug.Assert(currentGiftHelper != null, "OnMouseStateChange listener invoked when currentGiftHelper is null.");

            currentGiftHelper.OnMouseStateChange(e);
        }