/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="button">The button on the controller, keyboard, or mouse.</param> /// <param name="cursor">The cursor position.</param> /// <param name="isActionButton">Whether the input should trigger actions on the affected tile.</param> /// <param name="isUseToolButton">Whether the input should use tools on the affected tile.</param> public EventArgsInput(SButton button, ICursorPosition cursor, bool isActionButton, bool isUseToolButton) { this.Button = button; this.Cursor = cursor; this.IsActionButton = isActionButton; this.IsUseToolButton = isUseToolButton; }
//void OnButtonPressed(object sender, ButtonPressedEventArgs e) { // if (!Context.IsWorldReady) // return; // if (!Context.IsPlayerFree) // return; // if (e.Button.IsUseToolButton()) { // Vector2 tilePos = this.Helper.Input.GetCursorPosition().Tile; // AttemptCatchCritter(tilePos); // } //} private void OnRendered(object sender, RenderedEventArgs e) { if (!Context.IsWorldReady) { return; } if (!Context.IsPlayerFree) { return; } ICursorPosition cursorPos = this.Helper.Input.GetCursorPosition(); Critter c = GetCrittersAtPosition(cursorPos.AbsolutePixels, Game1.tileSize); string str = "Critter: None"; if (c != null) { str = "Critter: " + c.GetType().ToString(); } str += $"({cursorPos.AbsolutePixels})"; //string str = $"Mouse: {cursorPos.AbsolutePixels}"; Game1.spriteBatch.DrawString(Game1.smallFont, str, cursorPos.ScreenPixels, Color.Black); }
/* * Private Void Events */ /// <summary> /// Event that gets triggered when a button is pressed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { if (!Context.IsWorldReady || !e.IsDown(SButton.MouseLeft)) { return; } //Make sure the player has a fertilizer selected and that they are left clicking if (e.IsDown(SButton.MouseLeft)) { GameLocation loc = Game1.player.currentLocation; ICursorPosition curs = Helper.Input.GetCursorPosition(); if (loc is null) { return; } //Go through the locations object. Then we look for hoedirt foreach (var obj in loc.objects.Pairs) { if (loc.terrainFeatures.TryGetValue(curs.GrabTile, out TerrainFeature terrainFeature) && terrainFeature is HoeDirt hoeDirt) { if (hoeDirt.crop != null && Game1.player.ActiveObject.Category == -19 && hoeDirt.fertilizer.Value == 0) { hoeDirt.fertilizer.Value = Game1.player.ActiveObject.ParentSheetIndex; Game1.player.reduceActiveItemByOne(); } else { Monitor.Log($"Couldn't fertilize. Fertilizer: {hoeDirt.fertilizer.Value}"); } } } } }
private void DoAction() { SFarmer player = Game1.player; GameLocation location = Game1.currentLocation; Tool tool = GetTool();//player.CurrentTool; Item item = player.CurrentItem; ITool[] tools = _tools .Where(tools1 => tools1.IsEnabled(player, tool, item, location)) .ToArray(); if (!tools.Any()) { return; } ICursorPosition c = Helper.Input.GetCursorPosition(); Vector2[] grid = GetGrid(c.Tile, _config.ToolRadius).ToArray(); /* * if (_config.ShowGrid) * _showGrid = true; */ foreach (Vector2 tile in grid) { location.objects.TryGetValue(tile, out SObject tileObj); location.terrainFeatures.TryGetValue(tile, out TerrainFeature tileFeature); foreach (ITool tool1 in tools) { if (tool1.Apply(tile, tileObj, tileFeature, player, tool, item, location)) { break; } } } }
/// <summary> /// Handle the click event if it was on the fridge icon. /// </summary> /// <param name="cursor">The current cursor position.</param> public void HandleClick(ICursorPosition cursor) { var chest = GetOpenChest(); if (chest == null) { return; } var screenPixels = Utility.ModifyCoordinatesForUIScale(cursor.ScreenPixels); if (!_fridgeSelected.containsPoint((int)screenPixels.X, (int)screenPixels.Y)) { return; } Game1.playSound("smallSelect"); if (_chests.Contains(chest)) { _chests.Remove(chest); } else { _chests.Add(chest); } }
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); }
/// <summary>Draw a radius around the player.</summary> /// <param name="spriteBatch">The sprite batch being drawn.</param> /// <param name="radius">The radius to draw</param> public void DrawRadius(SpriteBatch spriteBatch, int radius) { //bool enabled = this.IsEnabled(); ICursorPosition cur = Helper.Input.GetCursorPosition(); foreach (Vector2 tile in GetTileGrid(cur.Tile * 64f, radius)) { // get tile area in screen pixels Rectangle area = new Rectangle((int)(tile.X * Game1.tileSize - Game1.viewport.X), (int)(tile.Y * Game1.tileSize - Game1.viewport.Y), Game1.tileSize, Game1.tileSize); // choose tile color Color color = Color.Green;//enabled ? Color.Green : Color.Red; // draw background spriteBatch.DrawLine(area.X, area.Y, new Vector2(area.Width, area.Height), color * 0.2f); // draw border int borderSize = 1; Color borderColor = color * 0.5f; spriteBatch.DrawLine(area.X, area.Y, new Vector2(area.Width, borderSize), borderColor); // top spriteBatch.DrawLine(area.X, area.Y, new Vector2(borderSize, area.Height), borderColor); // left spriteBatch.DrawLine(area.X + area.Width, area.Y, new Vector2(borderSize, area.Height), borderColor); // right spriteBatch.DrawLine(area.X, area.Y + area.Height, new Vector2(area.Width, borderSize), borderColor); // bottom } }
/// <summary> /// Handle the click event if it was on the fridge icon. /// </summary> /// <param name="cursor">The current cursor position.</param> public void HandleClick(ICursorPosition cursor) { var chest = GetOpenChest(); if (chest == null) { return; } var screenPixels = cursor.ScreenPixels; if (!_fridgeSelected.containsPoint((int)screenPixels.X, (int)screenPixels.Y)) { return; } Game1.playSound("smallSelect"); if (Chests.Contains(chest)) { Chests.Remove(chest); } else { Chests.Add(chest); } }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="button">The button on the controller, keyboard, or mouse.</param> /// <param name="cursor">The cursor position.</param> /// <param name="isActionButton">Whether the input should trigger actions on the affected tile.</param> /// <param name="isUseToolButton">Whether the input should use tools on the affected tile.</param> /// <param name="suppressButtons">The buttons to suppress.</param> public EventArgsInput(SButton button, ICursorPosition cursor, bool isActionButton, bool isUseToolButton, HashSet <SButton> suppressButtons) { this.Button = button; this.Cursor = cursor; this.IsActionButton = isActionButton; this.IsUseToolButton = isUseToolButton; this.SuppressButtons = suppressButtons; }
/// <summary>Returns Vector2 global coordinates of mouse position, adjusted for scale.</summary> /// <param name="cursor">The cursor position data.</param> public static Vector2 convertCursorPosition(ICursorPosition cursor) { Vector2 mousePosition = Utility.ModifyCoordinatesFromUIScale(cursor.ScreenPixels); mousePosition.X += Game1.viewport.X; mousePosition.Y += Game1.viewport.Y; return(mousePosition); }
private void UpdateGrabTileAndCursor(ICursorPosition cursor) { double angle = GetAngle(cursor.ScreenPixels); Vector2 grabTile = Game1.player.getTileLocation(); angle += 22.5; int dir; if (angle < 45) { grabTile += new Vector2(1, 0); dir = Game1.right; } else if (angle < 90) { grabTile += new Vector2(1, -1); dir = Game1.up; } else if (angle < 135) { grabTile += new Vector2(0, -1); dir = Game1.up; } else if (angle < 180) { grabTile += new Vector2(-1, -1); dir = Game1.up; } else if (angle < 225) { grabTile += new Vector2(-1, 0); dir = Game1.left; } else if (angle < 270) { grabTile += new Vector2(-1, 1); dir = Game1.down; } else if (angle < 315) { grabTile += new Vector2(0, 1); dir = Game1.down; } else if (angle < 360) { grabTile += new Vector2(1, 1); dir = Game1.down; } else { grabTile += new Vector2(1, 0); dir = Game1.right; } Game1.player.lastClick = grabTile * 64 + new Vector2(32, 32); Game1.player.FacingDirection = dir; }
public void ButtonPressed(object sender, ButtonPressedEventArgs e) { if (!Context.IsWorldReady) { return; } if (e.Button == SButton.Delete) { GameLocation curLocation = Game1.currentLocation; // FarmHouse house = curLocation is FarmHouse ? curLocation as FarmHouse : null; //Populate furniture dictionary. //furniture = house.furniture; Dictionary <Vector2, Furniture> furniture = new Dictionary <Vector2, Furniture>(); //curTile = new Vector2((Game1.getMouseX() + Game1.viewport.X) / Game1.tileSize, (Game1.getMouseY() + Game1.viewport.Y) / Game1.tileSize); ICursorPosition curTile = Helper.Input.GetCursorPosition(); //coords = curTile; /* * if(house != null) * { * foreach(Furniture f in house.furniture) * { * furniture.Add(new Vector2(f.tileLocation.X, f.tileLocation.Y), f); * * } * }*/ bool occupied = curLocation.isTileOccupied(curTile.Tile); bool t = curLocation is FarmHouse ? true : false; curLocation.Objects.TryGetValue(curTile.Tile, out SObject @object); curLocation.terrainFeatures.TryGetValue(curTile.Tile, out TerrainFeature @terrain); if (@object != null) { List <Response> options = new List <Response>() { new Response("1", "Yes"), new Response("2", "No") }; curLocation.createQuestionDialogue($"Are you sure you want to delete {@object.Name}?", options.ToArray(), new GameLocation.afterQuestionBehavior(this.answer), (NPC)null); } else if (@terrain != null) { List <Response> options = new List <Response>() { new Response("3", "Yes"), new Response("4", "No") }; string tName = GetTerrainName(@terrain); curLocation.createQuestionDialogue($"Are you sure you want to delete {tName}?", options.ToArray(), new GameLocation.afterQuestionBehavior(this.answer), (NPC)null); } this.Monitor.Log($"X:{curTile.Tile.X} Y:{curTile.Tile.Y} FarmHouse: {t} Occupied: {occupied}\n\n", LogLevel.Alert); } }
/// <summary>Returns <see cref="ICursorPosition.ScreenPixels"/>, always adjusted for UI Scaling. SMAPI version 3.8.1 and earlier used to always do this, but changes were made to SMAPI 3.8.2+.</summary> public static Vector2 LegacyScreenPixels(this ICursorPosition value) { if (!Constants.ApiVersion.IsNewerThan("3.8.1")) { return(value.ScreenPixels); } else { return(Utility.ModifyCoordinatesForUIScale(value.ScreenPixels)); } }
/// <summary>Raised after the player presses a button.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { // ignore if player hasn't loaded a save yet if (!Context.IsWorldReady) { return; } // checks if the key pressed matches the hotkey in the config and if the player is able to move if (this.Config.ToggleKey.JustPressed() && (Context.IsPlayerFree)) { var model = this.Helper.Data.ReadSaveData <ModData>("TileChecksData") ?? new ModData(); // adds a new location to save data if it doesn't already exist if (!model.TileChecks.ContainsKey(Game1.currentLocation.NameOrUniqueName)) { model.TileChecks.Add(Game1.currentLocation.NameOrUniqueName, new Dictionary <string, string>()); model.TileChecks[Game1.currentLocation.NameOrUniqueName].Add("DisplayName", GenerateDisplayName(Game1.currentLocation)); this.Helper.Data.WriteSaveData("TileChecksData", model); } string playerLocation = Game1.currentLocation.NameOrUniqueName; this.cursorPos = this.Helper.Input.GetCursorPosition(); bool tileAlreadyExists = false; string tileToBeRemoved = ""; // checks if tile is already saved foreach (KeyValuePair <string, string> entry in model.TileChecks[playerLocation]) { if (entry.Value == this.cursorPos.Tile.ToString()) { tileAlreadyExists = true; tileToBeRemoved = entry.Key; } } // if tile is saved, unsave it if (tileAlreadyExists) { model.TileChecks[playerLocation].Remove(tileToBeRemoved); this.Helper.Data.WriteSaveData("TileChecksData", model); Game1.addHUDMessage(new HUDMessage($"{tileToBeRemoved} has been removed from the tile checks for {GetDisplayName(playerLocation)}.", "")); } // open naming menu else { Game1.activeClickableMenu = new NamingMenu(ReturnTileName, "Enter Tile Name:", ""); } } }
/// <summary> /// Event that runs when a button is pressed. /// </summary> /// <param name="sender">The event sender</param> /// <param name="e">The event args</param> private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { if (!Context.IsWorldReady || !_modEnabled) { return; } //Check to see if Action Key was pressed if (e.IsDown(_activationKey)) { ProcessLiveStock(); HarvestCrops(); CheckDogCat(); } //Check to see if Clear location key was pressed if (e.IsDown(_clearLocationKey)) { ClearCurrentLocation(Game1.currentLocation); } if (e.IsDown(_useToolKey)) { ICursorPosition cur = Helper.Input.GetCursorPosition(); UseTool(Game1.player.getTileLocation(), cur.Tile, Game1.currentLocation); } if (e.IsDown(_forageKey)) { DoForageHarvest(); } if (e.IsDown(_singleKey)) { ICursorPosition cur = Helper.Input.GetCursorPosition(); SingleToolUse(cur.Tile, Game1.currentLocation); } if (e.IsDown(SButton.F3)) { ICursorPosition c = Helper.Input.GetCursorPosition(); Game1.player.position.Value = c.Tile * Game1.tileSize; } if (e.IsDown(SButton.F4)) { GameLocation loc = Game1.currentLocation; if (loc != null && loc is MineShaft shaft && shaft.mineLevel > 120) { shaft.enterMineShaft(); } } }
/// <summary>Checks if an android player's cursor is on their farmer.</summary> /// <returns>true if player did tap on farmer, or not on android; false otherwise</returns> private bool TappedOnFarmerIfAndroid(ICursorPosition cursor) { int x = (int)cursor.AbsolutePixels.X; int y = (int)cursor.AbsolutePixels.Y; if (Constants.TargetPlatform == GamePlatform.Android) { return(new Rectangle((int)Game1.player.position.X, (int)Game1.player.position.Y - 85, 64, 125).Contains(x, y)); //From android code } else { return(true); //Game1.player.GetBoundingBox().Contains(x, y); } }
/// <summary>Returns <see cref="ICursorPosition.ScreenPixels"/>, always adjusted for UI Scaling. SMAPI version 3.8.1 and earlier used to always do this, but changes were made to SMAPI 3.8.2+.</summary> public static Vector2 LegacyScreenPixels(this ICursorPosition value) { #if ANDROID && LEGACYVERSION return(value.ScreenPixels); #else if (IsLegacyCursorPosition) { return(value.ScreenPixels); } else { return(Utility.ModifyCoordinatesForUIScale(value.ScreenPixels)); } #endif }
private void KeyPressed(object sender, ButtonPressedEventArgs e) { if (!Context.IsWorldReady) { return; } //Reload Config file if (Helper.Input.IsDown(SButton.F5)) { _config = Helper.ReadConfig <Config>(); _enableMod = _config.EnableMod; _enableSnowWatering = _config.EnableSnowWatering; _enableSprinklers = _config.EnableSprinklerWatering; _waterBowlLocation = _config.WaterBowlLocation; Monitor.Log("Config Reloaded", LogLevel.Info); } //Grab the Coords of the mouse cursor if (Helper.Input.IsDown(SButton.F9)) { ICursorPosition cur = Helper.Input.GetCursorPosition(); _config.WaterBowlLocation = new Vector2(cur.Tile.X, cur.Tile.Y); Helper.WriteConfig(_config); //Reload the config after writing to it. _config = Helper.ReadConfig <Config>(); _enableMod = _config.EnableMod; _enableSnowWatering = _config.EnableSnowWatering; _enableSprinklers = _config.EnableSprinklerWatering; _waterBowlLocation = _config.WaterBowlLocation; Monitor.Log($"Current Water Bowl Location: X:{cur.Tile.X}, Y:{cur.Tile.Y}. Settings Updated."); } //For my testing purposes if (Helper.Input.IsDown(SButton.NumPad9) && debugging) { Monitor.Log($"Sprinkler Watering Activated: {_enableSprinklers}"); } //Check for water bowl at location if (Helper.Input.IsDown(SButton.NumPad8) && debugging) { if (CheckBowlLocation(_waterBowlLocation)) { Monitor.Log("Bowl found.", LogLevel.Alert); } else { Monitor.Log("Bowl not found", LogLevel.Alert); } } }
public static void checkForSigns(ICursorPosition cursor) { if (Game1.activeClickableMenu != null) { return; } Vector2 pos = cursor.Tile; Vector2 oneDown = new Vector2(pos.X, pos.Y + 1); if (Game1.currentLocation != null && Game1.currentLocation.objects.ContainsKey(pos) && Game1.currentLocation.objects[pos] is Sign sign && sign.displayItem.Value is Note n) { displayNote = n.text; }
/// <summary> /// Plays the sound and fills fridges if the user clicks on the button /// and the fridges are not in use by other players. /// </summary> /// <param name="cursor"></param> internal void HandleClick(ICursorPosition cursor) { var screenPixels = cursor.ScreenPixels; if (!button.containsPoint((int)screenPixels.X, (int)screenPixels.Y)) { return; } if (FridgesAreFree()) { Game1.playSound("Ship"); FillFridges(); } }
/// <summary> /// Apply fertilizer to crops that have started growing but aren't /// yet harvestable if the user is clicking /// </summary> /// <param name="sender">The event sender</param> /// <param name="e">The event arguments</param> private void UpdateTicking(object sender, UpdateTickingEventArgs e) { if (Game1.hasLoadedGame && Clicking) { GameLocation location = Game1.currentLocation; Farmer player = Game1.player; ICursorPosition cursor = Helper.Input.GetCursorPosition(); Vector2 tileToFertilize = cursor.GrabTile; if (location.isCropAtTile((int)tileToFertilize.X, (int)tileToFertilize.Y) && IsValidTileAndItem(location, tileToFertilize, player.CurrentItem, out HoeDirt dirt)) { location.playSound("dirtyHit"); dirt.fertilizer.Value = player.CurrentItem.ParentSheetIndex; player.removeItemsFromInventory(player.CurrentItem.ParentSheetIndex, 1); } } }
///<summary>Activate the tool. </summary> private void UpdateTools() { //Variables Farmer who = Game1.player; GameLocation loc = Game1.currentLocation; Tool tool = this.SelectTool; Item item = who.CurrentItem; ICursorPosition cur = Helper.Input.GetCursorPosition(); //Gather all the tools ITool[] tools = this.GetTools; if (!tools.Any()) { return; } //Grab the tiles to use the tool on Vector2[] g = this.GetTileGrid(cur.GrabTile, Config.ToolLevel).ToArray(); }
private static bool InOnScreenMenu(ICursorPosition cursor) { bool save = Game1.uiMode; Game1.uiMode = true; Vector2 v = cursor.GetScaledScreenPixels(); Game1.uiMode = save; int x = (int)v.X; int y = (int)v.Y; for (int i = 0; i < Game1.onScreenMenus.Count; i++) { if (Game1.onScreenMenus[i].isWithinBounds(x, y)) { return(true); } } return(false); }
private void DoMine() { SFarmer player = Game1.player; GameLocation location = Game1.currentLocation; Tool tool = player.CurrentTool; Item item = player.CurrentItem; Dictionary <Vector2, SObject> curObj = new Dictionary <Vector2, SObject>(); Dictionary <Vector2, TerrainFeature> curTerrain = new Dictionary <Vector2, TerrainFeature>(); ITool[] tools = _tools .Where(tools1 => tools1.IsEnabled(player, tool, item, location)) .ToArray(); if (!tools.Any()) { return; } if (location.IsFarm || location.Name.Contains("Greenhouse") || location.Name.Contains("FarmExpan")) { return; } ICursorPosition c = Helper.Input.GetCursorPosition(); Vector2[] grid = GetGrid(c.Tile, 50).ToArray(); foreach (Vector2 tile in grid) { location.objects.TryGetValue(tile, out SObject tileObj); location.terrainFeatures.TryGetValue(tile, out TerrainFeature tileFeature); foreach (ITool tool1 in tools) { if (tool1.Apply(tile, tileObj, tileFeature, player, tool, item, location)) { break; } } } }
//Highlight Affected Area public void HighlightRadius(SpriteBatch spriteBatch) { ICursorPosition c = Helper.Input.GetCursorPosition(); Vector2[] grid = GetGrid(c.Tile, _config.ToolRadius).ToArray(); foreach (Vector2 tile in grid) { bool enabled = IsEnabled(); Rectangle area = new Rectangle((int)(tile.X * Game1.tileSize - Game1.viewport.X), (int)(tile.Y * Game1.tileSize - Game1.viewport.Y), Game1.tileSize, Game1.tileSize); Color color = enabled ? Color.Green : Color.Red; if (_showGrid) { spriteBatch.DrawLine(area.X, area.Y, new Vector2(area.Width, area.Height), color * 0.2f); int bSize = 1; Color bColor = color * 0.5f; spriteBatch.DrawLine(area.X, area.Y, new Vector2(area.Width, bSize), bColor); spriteBatch.DrawLine(area.X, area.Y, new Vector2(bSize, area.Height), bColor); spriteBatch.DrawLine(area.X + area.Width, area.Y, new Vector2(bSize, area.Height), bColor); spriteBatch.DrawLine(area.X, area.Y + area.Height, new Vector2(area.Width, bSize), bColor); } } }
private bool checkButtonConditions(SButton button, ICursorPosition cursor, out int x, out int y) { cursor ??= Helper.Input.GetCursorPosition(); var trueMenu = this.trueMenu; x = (int)cursor.ScreenPixels.X - trueMenu?.xPositionOnScreen ?? 0; y = (int)cursor.ScreenPixels.Y - trueMenu?.yPositionOnScreen ?? 0; if (button != SButton.MouseLeft && button != SButton.ControllerA && button != SButton.C) { return(false); } if (OptionsDropDown.selected == dropdown) { return(true); } return(dropdown.bounds.Contains(x, y)); }
/* * Private Methods */ private void Button(object sender, ButtonPressedEventArgs e) { if (!Context.IsWorldReady) { return; } if (e.IsDown(SButton.F8)) { ICursorPosition c = Helper.Input.GetCursorPosition(); int x = Game1.getMouseX(); int y = Game1.getMouseY(); //Try adding new monsters to the map. //BigSlime bs = new BigSlime(new Vector2(x, y), 1); int mineLevel = 1; if (Game1.player.CombatLevel >= 10) { mineLevel = 140; } else if (Game1.player.CombatLevel >= 8) { mineLevel = 100; } else if (Game1.player.CombatLevel >= 4) { mineLevel = 41; } IList <NPC> characters = Game1.currentLocation.characters; MonsterData MetalHead metal = new MetalHead(c.Tile * 64f, mineLevel) { wildernessFarmMonster = true }; characters.Add((NPC)metal); } }
public void GraphicsEvents_OnPostRenderEvent(object sender, EventArgs e) { if (Game1.hasLoadedGame) { //monitor.Log($"" + Game1.currentLocation.Name); if (Game1.currentLocation.mapPath.Value == "Maps\\Winery" && Game1.currentLocation != null) { var timeRemaining = Game1.spriteBatch; ICursorPosition cursorPos = this.Helper.Input.GetCursorPosition(); foreach (var entry in Game1.currentLocation.objects) { if (Game1.currentLocation.Objects.TryGetValue(cursorPos.Tile, out SObject obj)) { if (obj.heldObject.Value != null) { string textTimeRemaining; if (obj.Name.Equals("Keg") && obj.MinutesUntilReady > 0) { textTimeRemaining = Math.Round((obj.MinutesUntilReady * 0.6) / 84, 1).ToString() + " minutes"; IClickableMenu.drawHoverText(Game1.spriteBatch, textTimeRemaining, Game1.smallFont, 0, 0, -1, obj.heldObject.Value.Name.Length > 0 ? obj.heldObject.Value.Name : (string)null, -1, (string[])null, (Item)null, 0, -1, -1, -1, -1, 1f, (CraftingRecipe)null); } if (obj is Cask c && c.daysToMature.Value > 0) { textTimeRemaining = Math.Round(c.daysToMature.Value * 0.6, 1).ToString() + " days"; IClickableMenu.drawHoverText(Game1.spriteBatch, textTimeRemaining, Game1.smallFont, 0, 0, -1, obj.heldObject.Value.Name.Length > 0 ? obj.heldObject.Value.Name : (string)null, -1, (string[])null, (Item)null, 0, -1, -1, -1, -1, 1f, (CraftingRecipe)null); } } } } } } }
/// <summary>The draw calls for the UI elements</summary> public override void draw(SpriteBatch b) { CursorPosition = Utilities.Data.Helper.Input.GetCursorPosition(); // suppress the Menu button Utilities.Data.Helper.Input.Suppress(Utilities.Data.MenuButton); // draw screen fade b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.75f); // draw menu box Game1.drawDialogueBox(xPositionOnScreen, yPositionOnScreen, width, height - 12, false, true); // draw title scroll SpriteText.drawStringWithScrollCenteredAt(b, "Display Recurring Reminders", Game1.viewport.Width / 2, yPositionOnScreen, "Display Recurring Reminders"); // draw boxes foreach (ClickableTextureComponent box in Boxes) { box.draw(b); } // draw labels foreach (ClickableComponent label in ReminderMessages) { string text = ""; Color color = Game1.textColor; Utility.drawTextWithShadow(b, label.name, Game1.smallFont, new Vector2(label.bounds.X, label.bounds.Y), color); if (text.Length > 0) { Utility.drawTextWithShadow(b, text, Game1.smallFont, new Vector2((label.bounds.X + Game1.tileSize / 3) - Game1.smallFont.MeasureString(text).X / 2f, (label.bounds.Y + Game1.tileSize / 2)), color); } } if (Reminders.Count > (PageIndex + 1) * 5) { NextPageButton.draw(b); } if (PageIndex != 0) { PrevPageButton.draw(b); } // draw the delete buttons foreach (ClickableTextureComponent button in DeleteButtons) { button.draw(b); } // draw the warning for no reminder if (Reminders.Count <= 0) { Utility.drawTextWithShadow(b, NoRemindersWarning.name, Game1.smallFont, new Vector2(NoRemindersWarning.bounds.X, NoRemindersWarning.bounds.Y), Game1.textColor); } // draw new reminders button NewReminderButton.draw(b); // draw the boxes hover text foreach (ClickableTextureComponent box in Boxes) { if (box.containsPoint((int)CursorPosition.ScreenPixels.X, (int)CursorPosition.ScreenPixels.Y)) { if (box.hoverText != null) { int x = Game1.getMouseX() + 32; int y = Game1.getMouseY() + 32 + 16; IClickableMenu.drawTextureBox(b, Game1.menuTexture, new Rectangle(0, 256, 60, 60), x, y - 16, Utilities.Extras.EstimateStringDimension(box.hoverText) + 8, Game1.tileSize + 16, Color.White, 1f, true); SpriteText.drawString(b, box.hoverText, x + 32, y, 999, -1, 99, 1f, 0.88f, false, -1, "", 8, SpriteText.ScrollTextAlignment.Left); } } } // draw cursor drawMouse(b); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="button">The button on the controller, keyboard, or mouse.</param> /// <param name="cursor">The cursor position.</param> /// <param name="inputState">The game's current input state.</param> internal ButtonPressedEventArgs(SButton button, ICursorPosition cursor, SInputState inputState) { this.Button = button; this.Cursor = cursor; this.InputState = inputState; }