private void GetWeatherIconSpriteLocation() { switch (Game1.weatherForTomorrow) { case Game1.weather_sunny: case Game1.weather_debris: case Game1.weather_festival: case Game1.weather_wedding: _IsNextDayRainy = false; break; case Game1.weather_rain: _IsNextDayRainy = true; _weatherIconSpriteLocation = new Rectangle(0, 0, 15, 15); _hoverText = _helper.SafeGetString(LanguageKeys.RainNextDay); break; case Game1.weather_lightning: _IsNextDayRainy = true; _weatherIconSpriteLocation = new Rectangle(15, 0, 15, 15); _hoverText = _helper.SafeGetString(LanguageKeys.ThunderstormNextDay); break; case Game1.weather_snow: _IsNextDayRainy = true; _weatherIconSpriteLocation = new Rectangle(30, 0, 15, 15); _hoverText = _helper.SafeGetString(LanguageKeys.SnowNextDay); break; default: _IsNextDayRainy = false; break; } }
/// <summary>Raised after the game state is updated (≈60 times per second).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { // calculate luck if (e.IsMultipleOf(30)) // half second { _color = new Color(Color.White.ToVector4()); if (Game1.player.DailyLuck < -0.04) { _hoverText = _helper.SafeGetString(LanguageKeys.MaybeStayHome); _color.B = 155; _color.G = 155; } else if (Game1.player.DailyLuck < 0) { _hoverText = _helper.SafeGetString(LanguageKeys.NotFeelingLuckyAtAll); _color.B = 165; _color.G = 165; _color.R = 165; _color *= 0.8f; } else if (Game1.player.DailyLuck <= 0.04) { _hoverText = _helper.SafeGetString(LanguageKeys.LuckyButNotTooLucky); } else { _hoverText = _helper.SafeGetString(LanguageKeys.FeelingLucky); _color.B = 155; _color.R = 155; } } }
/// <summary>Raised after drawing the HUD (item toolbar, clock, etc) to the sprite batch, but before it's rendered to the screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnRenderedHud(object sender, RenderedHudEventArgs e) { // draw hover text if (Constants.TargetPlatform == GamePlatform.Android) { if (_travelingMerchantIsHere && (_travelingMerchantIcon?.containsPoint((int)(Game1.getMouseX() * Game1.options.zoomLevel), (int)(Game1.getMouseY() * Game1.options.zoomLevel)) ?? false)) { string hoverText = _helper.SafeGetString( LanguageKeys.TravelingMerchantIsInTown); IClickableMenu.drawHoverText( Game1.spriteBatch, hoverText, Game1.dialogueFont); } return; } if (_travelingMerchantIsHere && (_travelingMerchantIcon?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false)) { string hoverText = _helper.SafeGetString( LanguageKeys.TravelingMerchantIsInTown); IClickableMenu.drawHoverText( Game1.spriteBatch, hoverText, Game1.dialogueFont); } }
/// <summary>Raised after the game state is updated (≈60 times per second).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { // calculate luck if (e.IsMultipleOf(30)) // half second { if (Game1.player.DailyLuck < -0.04) { _hoverText.Value = _helper.SafeGetString(LanguageKeys.MaybeStayHome); _color.Value = _maybeStayHomeColor; } else if (Game1.player.DailyLuck < 0) { _hoverText.Value = _helper.SafeGetString(LanguageKeys.NotFeelingLuckyAtAll); _color.Value = _notFeelingLuckyAtAllColor; } else if (Game1.player.DailyLuck <= 0.04) { _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckyButNotTooLucky); _color.Value = _luckyButNotTooLuckyColor; } else { _hoverText.Value = _helper.SafeGetString(LanguageKeys.FeelingLucky); _color.Value = _feelingLuckyColor; } } }
private void CalculateLuck(object sender, EventArgs e) { _color = new Color(Color.White.ToVector4()); if (Game1.dailyLuck < -0.04) { _hoverText = _helper.SafeGetString(LanguageKeys.MaybeStayHome); _color.B = 155; _color.G = 155; } else if (Game1.dailyLuck < 0) { _hoverText = _helper.SafeGetString(LanguageKeys.NotFeelingLuckyAtAll); _color.B = 165; _color.G = 165; _color.R = 165; _color *= 0.8f; } else if (Game1.dailyLuck <= 0.04) { _hoverText = _helper.SafeGetString(LanguageKeys.LuckyButNotTooLucky); } else { _hoverText = _helper.SafeGetString(LanguageKeys.FeelingLucky); _color.B = 155; _color.R = 155; } }
/// <summary>Raised after drawing the HUD (item toolbar, clock, etc) to the sprite batch, but before it's rendered to the screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnRenderedHud(object sender, RenderedHudEventArgs e) { // draw hover text if (Constants.TargetPlatform == GamePlatform.Android) { if (_drawQueenOfSauceIcon && _queenOfSauceIcon.containsPoint((int)(Game1.getMouseX() * Game1.options.zoomLevel), (int)(Game1.getMouseY() * Game1.options.zoomLevel))) { IClickableMenu.drawHoverText( Game1.spriteBatch, _helper.SafeGetString( LanguageKeys.TodaysRecipe) + _todaysRecipe, Game1.dialogueFont); } return; } if (_drawQueenOfSauceIcon && _queenOfSauceIcon.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { IClickableMenu.drawHoverText( Game1.spriteBatch, _helper.SafeGetString( LanguageKeys.TodaysRecipe) + _todaysRecipe, Game1.dialogueFont); } }
private void UpdateToolInfo() { // if (Game1.player.toolBeingUpgraded.Value != null) { var toolBeingUpgraded = _toolBeingUpgraded.Value = Game1.player.toolBeingUpgraded.Value; var toolTexturePosition = new Rectangle(); if (toolBeingUpgraded is StardewValley.Tools.WateringCan) { toolTexturePosition.X = 32; toolTexturePosition.Y = 228; toolTexturePosition.Width = 16; toolTexturePosition.Height = 11; } else { toolTexturePosition.Width = 16; toolTexturePosition.Height = 16; toolTexturePosition.X = 81; toolTexturePosition.Y = 31; if (!(toolBeingUpgraded is StardewValley.Tools.Hoe)) { toolTexturePosition.Y += 64; if (!(toolBeingUpgraded is StardewValley.Tools.Pickaxe)) { toolTexturePosition.Y += 64; } } } toolTexturePosition.X += (111 * toolBeingUpgraded.UpgradeLevel); if (toolTexturePosition.X > Game1.toolSpriteSheet.Width) { toolTexturePosition.Y += 32; toolTexturePosition.X -= 333; } if (Game1.player.daysLeftForToolUpgrade.Value > 0) { _hoverText.Value = string.Format(_helper.SafeGetString(LanguageKeys.DaysUntilToolIsUpgraded), Game1.player.daysLeftForToolUpgrade.Value, toolBeingUpgraded.DisplayName); } else { _hoverText.Value = string.Format(_helper.SafeGetString(LanguageKeys.ToolIsFinishedBeingUpgraded), toolBeingUpgraded.DisplayName); } _toolTexturePosition.Value = toolTexturePosition; } else { _toolBeingUpgraded.Value = null; } }
private void DayChanged(object sender, EventArgs e) { if (Game1.player.toolBeingUpgraded.Value != null) { _toolBeingUpgraded = Game1.player.toolBeingUpgraded.Value; _toolTexturePosition = new Rectangle(); if (_toolBeingUpgraded is StardewValley.Tools.WateringCan) { _toolTexturePosition.X = 32; _toolTexturePosition.Y = 228; _toolTexturePosition.Width = 16; _toolTexturePosition.Height = 11; } else { _toolTexturePosition.Width = 16; _toolTexturePosition.Height = 16; _toolTexturePosition.X = 81; _toolTexturePosition.Y = 31; if (!(_toolBeingUpgraded is StardewValley.Tools.Hoe)) { _toolTexturePosition.Y += 64; if (!(_toolBeingUpgraded is StardewValley.Tools.Pickaxe)) { _toolTexturePosition.Y += 64; } } } _toolTexturePosition.X += (111 * _toolBeingUpgraded.UpgradeLevel); if (_toolTexturePosition.X > Game1.toolSpriteSheet.Width) { _toolTexturePosition.Y += 32; _toolTexturePosition.X -= 333; } if (Game1.player.daysLeftForToolUpgrade.Value > 0) { _hoverText = String.Format(_helper.SafeGetString(LanguageKeys.DaysUntilToolIsUpgraded), Game1.player.daysLeftForToolUpgrade.Value, _toolBeingUpgraded.DisplayName); } else { _hoverText = String.Format(_helper.SafeGetString(LanguageKeys.ToolIsFinishedBeingUpgraded), _toolBeingUpgraded.DisplayName); } } else { _toolBeingUpgraded = null; } }
private void SetToolHoverText() { if (Game1.player.daysLeftForToolUpgrade.Value > 0) { _hoverText = string.Format(_helper.SafeGetString(LanguageKeys.DaysUntilToolIsUpgraded), Game1.player.daysLeftForToolUpgrade.Value, _toolBeingUpgraded.DisplayName); } else { _hoverText = string.Format(_helper.SafeGetString(LanguageKeys.ToolIsFinishedBeingUpgraded), _toolBeingUpgraded.DisplayName); } }
public override void draw(SpriteBatch b) { base.draw(b); Game1.spriteBatch.Draw(Game1.mouseCursors, new Vector2(xPositionOnScreen, yPositionOnScreen), new Rectangle(16, 368, 16, 16), Color.White, 0.0f, Vector2.Zero, Game1.pixelZoom, SpriteEffects.None, 1f); b.Draw(Game1.mouseCursors, new Vector2(xPositionOnScreen + 8, yPositionOnScreen + 14), new Rectangle(32, 672, 16, 16), Color.White, 0.0f, Vector2.Zero, 3f, SpriteEffects.None, 1f); if (isWithinBounds(Game1.getMouseX(), Game1.getMouseY())) { IClickableMenu.drawHoverText(Game1.spriteBatch, _helper.SafeGetString(OptionKeys.UIOptions), Game1.smallFont); } Tools.DrawMouseCursor(); }
private void OnRenderedHud(object sender, RenderedHudEventArgs e) { if (_drawQueenOfSauceIcon.Value && !Game1.IsFakedBlackScreen() && (_icon.Value?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false)) { IClickableMenu.drawHoverText(Game1.spriteBatch, _helper.SafeGetString(LanguageKeys.TodaysRecipe) + _todaysRecipe, Game1.dialogueFont); } }
private void DrawHoverText() { string hoverText = string.Format(_helper.SafeGetString(LanguageKeys.NpcBirthday), _birthdayNPC.displayName); IClickableMenu.drawHoverText( Game1.spriteBatch, hoverText, Game1.dialogueFont); }
private void CalculateLuck(UpdateTickedEventArgs e) { if (e.IsMultipleOf(30)) // half second { switch (Game1.player.DailyLuck) { // Spirits are very happy (FeelingLucky) case var l when(l > 0.07): _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus1); _color.Value = Luck1Color; break; // Spirits are in good humor (LuckyButNotTooLucky) case var l when(l > 0.02 && l <= 0.07): _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus2); _color.Value = Luck2Color; break; // The spirits feel neutral case var l when(l >= -0.02 && l <= 0.02 && l != 0): _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus3); _color.Value = Luck3Color; break; // The spirits feel absolutely neutral case var l when(l == 0): _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus4); _color.Value = Luck4Color; break; // The spirits are somewhat annoyed (NotFeelingLuckyAtAll) case var l when(l >= -0.07 && l < -0.02): _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus5); _color.Value = Luck5Color; break; // The spirits are very displeased (MaybeStayHome) case var l when(l < -0.07): _hoverText.Value = _helper.SafeGetString(LanguageKeys.LuckStatus6); _color.Value = Luck6Color; break; } // Rewrite the text, but keep the color if (ShowExactValue) { _hoverText.Value = string.Format(_helper.SafeGetString(LanguageKeys.DailyLuckValue), Game1.player.DailyLuck); } } }
/// <summary>Raised before drawing the HUD (item toolbar, clock, etc) to the screen. The vanilla HUD may be hidden at this point (e.g. because a menu is open).</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnRenderingHud(object sender, RenderingHudEventArgs e) { if (!Game1.eventUp) { if (_shouldDrawLevelUp) { Vector2 playerLocalPosition = Game1.player.getLocalPosition(Game1.viewport); Game1.spriteBatch.Draw( Game1.mouseCursors, new Vector2( playerLocalPosition.X - 74, playerLocalPosition.Y - 130), _levelUpIconRectangle, _iconColor, 0, Vector2.Zero, Game1.pixelZoom, SpriteEffects.None, 0.85f); Game1.drawWithBorder( _helper.SafeGetString( LanguageKeys.LevelUp), Color.DarkSlateGray, Color.PaleTurquoise, new Vector2( playerLocalPosition.X - 28, playerLocalPosition.Y - 130)); } for (int i = _experiencePointDisplays.Count - 1; i >= 0; --i) { if (_experiencePointDisplays[i].IsInvisible) { _experiencePointDisplays.RemoveAt(i); } else { _experiencePointDisplays[i].Draw(); } } if (_experienceRequiredToLevel > 0 && _experienceBarShouldBeVisible && _showExperienceBar) { int experienceDifferenceBetweenLevels = _experienceRequiredToLevel - _experienceFromPreviousLevels; int barWidth = (int)((double)_experienceEarnedThisLevel / experienceDifferenceBetweenLevels * MaxBarWidth); DrawExperienceBar(barWidth, _experienceEarnedThisLevel, experienceDifferenceBetweenLevels, _currentSkillLevel); } } }
private void DrawHoverText(object sender, EventArgs e) { if (_drawQueenOfSauceIcon && _queenOfSauceIcon.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { IClickableMenu.drawHoverText( Game1.spriteBatch, _helper.SafeGetString( LanguageKeys.TodaysRecipe) + _todaysRecipe, Game1.dialogueFont); } }
private void DrawHoverText(object sender, EventArgs e) { if (_travelingMerchantIsHere && _travelingMerchantIcon.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { string hoverText = _helper.SafeGetString( LanguageKeys.TravelingMerchantIsInTown); IClickableMenu.drawHoverText( Game1.spriteBatch, hoverText, Game1.dialogueFont); } }
/// <summary>Raised after drawing the HUD (item toolbar, clock, etc) to the sprite batch, but before it's rendered to the screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnRenderedHud(object sender, RenderedHudEventArgs e) { // draw hover text if (_travelingMerchantIsHere && (_travelingMerchantIcon?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false)) { var hoverText = _helper.SafeGetString( LanguageKeys.TravelingMerchantIsInTown); IClickableMenu.drawHoverText( Game1.spriteBatch, hoverText, Game1.dialogueFont); } }
/// <summary>Raised after drawing the HUD (item toolbar, clock, etc) to the sprite batch, but before it's rendered to the screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnRenderedHud(object sender, RenderedHudEventArgs e) { // draw hover text if (_drawQueenOfSauceIcon && (_queenOfSauceIcon?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false)) { IClickableMenu.drawHoverText( Game1.spriteBatch, _helper.SafeGetString( LanguageKeys.TodaysRecipe) + _todaysRecipe, Game1.dialogueFont); } }
/// <summary>Raised after drawing the HUD (item toolbar, clock, etc) to the sprite batch, but before it's rendered to the screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnRenderedHud(object sender, RenderedHudEventArgs e) { // draw hover text if (_birthdayNPC != null && (_birthdayIcon?.containsPoint(Game1.getMouseX(), Game1.getMouseY()) ?? false)) { String hoverText = String.Format(_helper.SafeGetString(LanguageKeys.NPCBirthday), _birthdayNPC.Name); IClickableMenu.drawHoverText( Game1.spriteBatch, hoverText, Game1.dialogueFont); } }
private void GetWeatherIconSpriteLocation() { WorldDate date = new WorldDate(Game1.Date); ++date.TotalDays; switch (!Game1.IsMasterGame ? Game1.getWeatherModificationsForDate(date, Game1.netWorldState.Value.WeatherForTomorrow) : Game1.getWeatherModificationsForDate(date, Game1.weatherForTomorrow)) { case Game1.weather_sunny: case Game1.weather_debris: case Game1.weather_festival: case Game1.weather_wedding: _IsNextDayRainy = false; break; case Game1.weather_rain: _IsNextDayRainy = true; _weatherIconSpriteLocation = new Rectangle(0, 0, 15, 15); _hoverText = _helper.SafeGetString(LanguageKeys.RainNextDay); break; case Game1.weather_lightning: _IsNextDayRainy = true; _weatherIconSpriteLocation = new Rectangle(15, 0, 15, 15); _hoverText = _helper.SafeGetString(LanguageKeys.ThunderstormNextDay); break; case Game1.weather_snow: _IsNextDayRainy = true; _weatherIconSpriteLocation = new Rectangle(30, 0, 15, 15); _hoverText = _helper.SafeGetString(LanguageKeys.SnowNextDay); break; default: _IsNextDayRainy = false; break; } }
private void UpdateRobinBuindingStatusData() { Building buildingUnderConstruction = Game1.getFarm().getBuildingUnderConstruction(); if (buildingUnderConstruction is null) { _IsBuildingInProgress = false; _hoverText = String.Empty; } else { _IsBuildingInProgress = true; _hoverText = String.Format(_helper.SafeGetString(LanguageKeys.RobinBuildingStatus), buildingUnderConstruction.daysOfConstructionLeft.Value > 0 ? buildingUnderConstruction.daysOfConstructionLeft.Value : buildingUnderConstruction.daysUntilUpgrade.Value); FindRobinSpritesheet(); } }
private void DrawBillboard() { _showBillboardButton.bounds.X = Game1.activeClickableMenu.xPositionOnScreen + Game1.activeClickableMenu.width - 160; _showBillboardButton.bounds.Y = Game1.activeClickableMenu.yPositionOnScreen + Game1.activeClickableMenu.height - // For compatiblity with BiggerBackpack mod (_helper.ModRegistry.IsLoaded("spacechase0.BiggerBackpack") ? 230 : 300); _showBillboardButton.draw(Game1.spriteBatch); if (_showBillboardButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { string hoverText = Game1.getMouseX() < _showBillboardButton.bounds.X + _showBillboardButton.bounds.Width / 2 ? LanguageKeys.Calendar : LanguageKeys.Billboard; IClickableMenu.drawHoverText( Game1.spriteBatch, _helper.SafeGetString(hoverText), Game1.dialogueFont); } }
private void RenderButtons(object sender, EventArgs e) { if (_hoverItem == null && Game1.activeClickableMenu is GameMenu && (Game1.activeClickableMenu as GameMenu).currentTab == 0) { _showBillboardButton.bounds.X = Game1.activeClickableMenu.xPositionOnScreen + Game1.activeClickableMenu.width - 160; _showBillboardButton.bounds.Y = Game1.activeClickableMenu.yPositionOnScreen + Game1.activeClickableMenu.height - 300; _showBillboardButton.draw(Game1.spriteBatch); if (_showBillboardButton.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { String hoverText = Game1.getMouseX() < _showBillboardButton.bounds.X + _showBillboardButton.bounds.Width / 2 ? LanguageKeys.Calendar : LanguageKeys.Billboard; IClickableMenu.drawHoverText( Game1.spriteBatch, _helper.SafeGetString(hoverText), Game1.dialogueFont); } } }
private void DrawTravelingMerchant(object sender, EventArgs e) { if (!Game1.eventUp && _travelingMerchantIsHere) { Point iconPosition = IconHandler.Handler.GetNewIconPosition(); ClickableTextureComponent textureComponent = new ClickableTextureComponent( new Rectangle(iconPosition.X, iconPosition.Y, 40, 40), Game1.mouseCursors, new Rectangle(192, 1411, 20, 20), 2f); textureComponent.draw(Game1.spriteBatch); if (textureComponent.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { string hoverText = _helper.SafeGetString( LanguageKeys.TravelingMerchantIsInTown); IClickableMenu.drawHoverText( Game1.spriteBatch, hoverText, Game1.dialogueFont); } } }
/// <summary>When a menu is open (<see cref="Game1.activeClickableMenu"/> isn't null), raised after that menu is drawn to the sprite batch but before it's rendered to the screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnRenderedActiveMenu(object sender, EventArgs e) { if (_hoverItem.Value == null && Game1.activeClickableMenu is GameMenu gameMenu && gameMenu.currentTab == 0 && _heldItem.Value == null) { var billboardButton = _showBillboardButton.Value; billboardButton.bounds.X = Game1.activeClickableMenu.xPositionOnScreen + Game1.activeClickableMenu.width - 160; billboardButton.bounds.Y = Game1.activeClickableMenu.yPositionOnScreen + Game1.activeClickableMenu.height - 300; _showBillboardButton.Value = billboardButton; _showBillboardButton.Value.draw(Game1.spriteBatch); if (_showBillboardButton.Value.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { var hoverText = Game1.getMouseX() < _showBillboardButton.Value.bounds.X + _showBillboardButton.Value.bounds.Width / 2 ? LanguageKeys.Calendar : LanguageKeys.Billboard; IClickableMenu.drawHoverText( Game1.spriteBatch, _helper.SafeGetString(hoverText), Game1.dialogueFont); } } }
private void DrawIcon(object sender, EventArgs e) { if (!Game1.eventUp) { if (_drawQueenOfSauceIcon) { Point iconPosition = IconHandler.Handler.GetNewIconPosition(); ClickableTextureComponent texture = new ClickableTextureComponent( new Rectangle(iconPosition.X, iconPosition.Y, 40, 40), Game1.mouseCursors, new Rectangle(609, 361, 28, 28), 1.3f); texture.draw(Game1.spriteBatch); if (texture.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { IClickableMenu.drawHoverText( Game1.spriteBatch, _helper.SafeGetString( LanguageKeys.TodaysRecipe) + _todaysRecipe, Game1.dialogueFont); } } if (_drawDishOfDayIcon) { Point iconLocation = IconHandler.Handler.GetNewIconPosition(); float scale = 2.9f; Game1.spriteBatch.Draw( Game1.objectSpriteSheet, new Vector2(iconLocation.X, iconLocation.Y), new Rectangle(306, 291, 14, 14), Color.White, 0, Vector2.Zero, scale, SpriteEffects.None, 1f); ClickableTextureComponent texture = new ClickableTextureComponent( _gus.name, new Rectangle( iconLocation.X - 7, iconLocation.Y - 2, (int)(16.0 * scale), (int)(16.0 * scale)), null, _gus.name, _gus.sprite.Texture, _gus.GetHeadShot(), 2f); texture.draw(Game1.spriteBatch); if (texture.containsPoint(Game1.getMouseX(), Game1.getMouseY())) { IClickableMenu.drawHoverText( Game1.spriteBatch, "Gus is selling " + Game1.dishOfTheDay.DisplayName + " recipe today!", Game1.dialogueFont); } } } }
/// <summary>When a menu is open (<see cref="Game1.activeClickableMenu"/> isn't null), raised after that menu is drawn to the sprite batch but before it's rendered to the screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnRenderedActiveMenu(object sender, RenderedActiveMenuEventArgs e) { if (!(Game1.activeClickableMenu is ShopMenu menu)) { return; } if (!(menu.hoveredItem is Item hoverItem)) { return; } // draw shop harvest prices bool isSeeds = hoverItem is StardewValley.Object hoverObject && hoverObject.Type == "Seeds"; bool isSapling = hoverItem.Name.EndsWith("Sapling"); int value = 0; if (isSeeds && hoverItem.Name != "Mixed Seeds" && hoverItem.Name != "Winter Seeds") { bool itemHasPriceInfo = Tools.GetTruePrice(hoverItem) > 0; if (itemHasPriceInfo) { StardewValley.Object temp = new StardewValley.Object( new Debris( new Crop( hoverItem.ParentSheetIndex, 0, 0) .indexOfHarvest.Value, Game1.player.position, Game1.player.position).chunkType.Value, 1); value = temp.Price; } else { switch (hoverItem.ParentSheetIndex) { case 802: value = 75; break; // Cactus } } } else if (isSapling) { switch (hoverItem.ParentSheetIndex) { case 628: value = 80; break; // Cherry case 629: value = 50; break; // Apricot case 630: // Orange case 633: value = 100; break; // Apple case 631: // Peach case 632: value = 140; break; // Pomegranate } } if (value > 0) { int xPosition = menu.xPositionOnScreen - 30; int yPosition = menu.yPositionOnScreen + 580; IClickableMenu.drawTextureBox( Game1.spriteBatch, xPosition + 20, yPosition - 52, 264, 108, Color.White); // Title "Harvest Price" string textToRender = _helper.SafeGetString(LanguageKeys.HarvestPrice); Game1.spriteBatch.DrawString( Game1.dialogueFont, textToRender, new Vector2(xPosition + 30, yPosition - 38), Color.Black * 0.2f); Game1.spriteBatch.DrawString( Game1.dialogueFont, textToRender, new Vector2(xPosition + 32, yPosition - 40), Color.Black * 0.8f); // Tree Icon xPosition += 80; Game1.spriteBatch.Draw( Game1.mouseCursors, new Vector2(xPosition, yPosition), new Rectangle(60, 428, 10, 10), Color.White, 0, Vector2.Zero, Game1.pixelZoom, SpriteEffects.None, 0.85f); // Coin Game1.spriteBatch.Draw( Game1.debrisSpriteSheet, new Vector2(xPosition + 32, yPosition + 10), Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 8, 16, 16), Color.White, 0, new Vector2(8, 8), 4, SpriteEffects.None, 0.95f); // Price Game1.spriteBatch.DrawString( Game1.dialogueFont, value.ToString(), new Vector2(xPosition + 50, yPosition + 6), Color.Black * 0.2f); Game1.spriteBatch.DrawString( Game1.dialogueFont, value.ToString(), new Vector2(xPosition + 52, yPosition + 4), Color.Black * 0.8f); /* * I have no Idea why this is here... * As far as I can see it only overrides the existing Tooltip with a price that is 500 coins higher? * * string hoverText = _helper.Reflection.GetField<string>(menu, "hoverText").GetValue(); * string hoverTitle = _helper.Reflection.GetField<string>(menu, "boldTitleText").GetValue(); * IReflectedMethod getHoveredItemExtraItemIndex = _helper.Reflection.GetMethod(menu, "getHoveredItemExtraItemIndex"); * IReflectedMethod getHoveredItemExtraItemAmount = _helper.Reflection.GetMethod(menu, "getHoveredItemExtraItemAmount"); * IClickableMenu.drawToolTip( * Game1.spriteBatch, * hoverText, * hoverTitle, * hoverItem, * menu.heldItem != null, * -1, * menu.currency, * getHoveredItemExtraItemIndex.Invoke<int>(new object[0]), * getHoveredItemExtraItemAmount.Invoke<int>(new object[0]), * null, * menu.hoverPrice); */ } }
public ModOptionsPageHandler(IModHelper helper, IDictionary <String, String> options) { _options = options; MenuEvents.MenuChanged += AddModOptionsToMenu; MenuEvents.MenuClosed += RemoveModOptionsFromMenu; _helper = helper; ModConfig modConfig = _helper.ReadConfig <ModConfig>(); _luckOfDay = new LuckOfDay(helper); _locationOfTownsfolk = new LocationOfTownsfolk(_helper, _options); _showWhenAnimalNeedsPet = new ShowWhenAnimalNeedsPet(_helper); _showCalendarAndBillboardOnGameMenuButton = new ShowCalendarAndBillboardOnGameMenuButton(helper); _showScarecrowAndSprinklerRange = new ShowItemEffectRanges(modConfig); _experienceBar = new ExperienceBar(helper); _shopHarvestPrices = new ShopHarvestPrices(helper); _showQueenOfSauceIcon = new ShowQueenOfSauceIcon(helper); _showTravelingMerchant = new ShowTravelingMerchant(helper); _showCropAndBarrelTime = new ShowCropAndBarrelTime(helper); _showToolUpgradeStatus = new ShowToolUpgradeStatus(helper); _elementsToDispose = new List <IDisposable>() { _luckOfDay, _showBirthdayIcon, _showAccurateHearts, _locationOfTownsfolk, _showWhenAnimalNeedsPet, _showCalendarAndBillboardOnGameMenuButton, _showCropAndBarrelTime, _experienceBar, _showItemHoverInformation, _showTravelingMerchant, _shopHarvestPrices, _showQueenOfSauceIcon, _showToolUpgradeStatus }; int whichOption = 1; Version thisVersion = Assembly.GetAssembly(this.GetType()).GetName().Version; _optionsElements.Add(new ModOptionsElement("UI Info Suite v" + thisVersion.Major + "." + thisVersion.Minor + "." + thisVersion.Build)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowLuckIcon), whichOption++, _luckOfDay.Toggle, _options, OptionKeys.ShowLuckIcon)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowLevelUpAnimation), whichOption++, _experienceBar.ToggleLevelUpAnimation, _options, OptionKeys.ShowLevelUpAnimation)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowExperienceBar), whichOption++, _experienceBar.ToggleShowExperienceBar, _options, OptionKeys.ShowExperienceBar)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.AllowExperienceBarToFadeOut), whichOption++, _experienceBar.ToggleExperienceBarFade, _options, OptionKeys.AllowExperienceBarToFadeOut)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowExperienceGain), whichOption++, _experienceBar.ToggleShowExperienceGain, _options, OptionKeys.ShowExperienceGain)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowLocationOfTownsPeople), whichOption++, _locationOfTownsfolk.ToggleShowNPCLocationsOnMap, _options, OptionKeys.ShowLocationOfTownsPeople)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowBirthdayIcon), whichOption++, _showBirthdayIcon.ToggleOption, _options, OptionKeys.ShowBirthdayIcon)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowHeartFills), whichOption++, _showAccurateHearts.ToggleOption, _options, OptionKeys.ShowHeartFills)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowAnimalsNeedPets), whichOption++, _showWhenAnimalNeedsPet.ToggleOption, _options, OptionKeys.ShowAnimalsNeedPets)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.DisplayCalendarAndBillboard), whichOption++, _showCalendarAndBillboardOnGameMenuButton.ToggleOption, _options, OptionKeys.DisplayCalendarAndBillboard)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowCropAndBarrelTooltip), whichOption++, _showCropAndBarrelTime.ToggleOption, _options, OptionKeys.ShowCropAndBarrelTooltip)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowItemEffectRanges), whichOption++, _showScarecrowAndSprinklerRange.ToggleOption, _options, OptionKeys.ShowItemEffectRanges)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowExtraItemInformation), whichOption++, _showItemHoverInformation.ToggleOption, _options, OptionKeys.ShowExtraItemInformation)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowTravelingMerchant), whichOption++, _showTravelingMerchant.ToggleOption, _options, OptionKeys.ShowTravelingMerchant)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowHarvestPricesInShop), whichOption++, _shopHarvestPrices.ToggleOption, _options, OptionKeys.ShowHarvestPricesInShop)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowWhenNewRecipesAreAvailable), whichOption++, _showQueenOfSauceIcon.ToggleOption, _options, OptionKeys.ShowWhenNewRecipesAreAvailable)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowToolUpgradeStatus), whichOption++, _showToolUpgradeStatus.ToggleOption, _options, OptionKeys.ShowToolUpgradeStatus)); }
/// <summary>When a menu is open (<see cref="Game1.activeClickableMenu"/> isn't null), raised after that menu is drawn to the sprite batch but before it's rendered to the screen.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnRenderedActiveMenu(object sender, RenderedActiveMenuEventArgs e) { // draw shop harvest prices if (Game1.activeClickableMenu is ShopMenu menu) { if (typeof(ShopMenu).GetField("hoveredItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(menu) is Item hoverItem) { String text = string.Empty; bool itemHasPriceInfo = Tools.GetTruePrice(hoverItem) > 0; if (hoverItem is StardewValley.Object && (hoverItem as StardewValley.Object).Type == "Seeds" && itemHasPriceInfo && hoverItem.Name != "Mixed Seeds" && hoverItem.Name != "Winter Seeds") { StardewValley.Object temp = new StardewValley.Object( new Debris( new Crop( hoverItem.ParentSheetIndex, 0, 0) .indexOfHarvest.Value, Game1.player.position, Game1.player.position).chunkType.Value, 1); text = " " + temp.Price; } Item heldItem = typeof(ShopMenu).GetField("heldItem", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(menu) as Item; if (heldItem == null) { int value = 0; switch (hoverItem.ParentSheetIndex) { case 628: value = 50; break; case 629: value = 80; break; case 630: case 633: value = 100; break; case 631: case 632: value = 140; break; } if (value > 0) { text = " " + value; } if (text != "" && (hoverItem as StardewValley.Object).Type == "Seeds") { String textToRender = _helper.SafeGetString( LanguageKeys.HarvestPrice); int xPosition = menu.xPositionOnScreen - 30; int yPosition = menu.yPositionOnScreen + 580; IClickableMenu.drawTextureBox( Game1.spriteBatch, xPosition + 20, yPosition - 52, 264, 108, Color.White); Game1.spriteBatch.DrawString( Game1.dialogueFont, textToRender, new Vector2(xPosition + 30, yPosition - 38), Color.Black * 0.2f); Game1.spriteBatch.DrawString( Game1.dialogueFont, textToRender, new Vector2(xPosition + 32, yPosition - 40), Color.Black * 0.8f); xPosition += 80; Game1.spriteBatch.Draw( Game1.mouseCursors, new Vector2(xPosition, yPosition), new Rectangle(60, 428, 10, 10), Color.White, 0, Vector2.Zero, Game1.pixelZoom, SpriteEffects.None, 0.85f); Game1.spriteBatch.Draw( Game1.debrisSpriteSheet, new Vector2(xPosition + 32, yPosition + 10), Game1.getSourceRectForStandardTileSheet(Game1.debrisSpriteSheet, 8, 16, 16), Color.White, 0, new Vector2(8, 8), 4, SpriteEffects.None, 0.95f); Game1.spriteBatch.DrawString( Game1.dialogueFont, text, new Vector2(xPosition - 2, yPosition + 6), Color.Black * 0.2f); Game1.spriteBatch.DrawString( Game1.dialogueFont, text, new Vector2(xPosition, yPosition + 4), Color.Black * 0.8f); String hoverText = _helper.Reflection.GetField <String>(menu, "hoverText").GetValue(); String hoverTitle = _helper.Reflection.GetField <String>(menu, "boldTitleText").GetValue(); Item hoverItem2 = _helper.Reflection.GetField <Item>(menu, "hoveredItem").GetValue(); int currency = _helper.Reflection.GetField <int>(menu, "currency").GetValue(); int hoverPrice = _helper.Reflection.GetField <int>(menu, "hoverPrice").GetValue(); IReflectedMethod getHoveredItemExtraItemIndex = _helper.Reflection.GetMethod(menu, "getHoveredItemExtraItemIndex"); IReflectedMethod getHoveredItemExtraItemAmount = _helper.Reflection.GetMethod(menu, "getHoveredItemExtraItemAmount"); IClickableMenu.drawToolTip( Game1.spriteBatch, hoverText, hoverTitle, hoverItem2, heldItem != null, -1, currency, getHoveredItemExtraItemIndex.Invoke <int>(new object[0]), getHoveredItemExtraItemAmount.Invoke <int>(new object[0]), null, hoverPrice); } } } } }
public ModOptionsPageHandler(IModHelper helper, IDictionary <string, string> options) { _options = options; helper.Events.Display.MenuChanged += ToggleModOptions; _helper = helper; _luckOfDay = new LuckOfDay(helper); _showBirthdayIcon = new ShowBirthdayIcon(helper.Events); _showAccurateHearts = new ShowAccurateHearts(helper.Events); _locationOfTownsfolk = new LocationOfTownsfolk(helper, _options); _showWhenAnimalNeedsPet = new ShowWhenAnimalNeedsPet(helper); _showCalendarAndBillboardOnGameMenuButton = new ShowCalendarAndBillboardOnGameMenuButton(helper); _showScarecrowAndSprinklerRange = new ShowItemEffectRanges(helper); _experienceBar = new ExperienceBar(helper); _showItemHoverInformation = new ShowItemHoverInformation(helper.Events); _shopHarvestPrices = new ShopHarvestPrices(helper); _showQueenOfSauceIcon = new ShowQueenOfSauceIcon(helper); _showTravelingMerchant = new ShowTravelingMerchant(helper); _showRainyDayIcon = new ShowRainyDayIcon(helper); _showCropAndBarrelTime = new ShowCropAndBarrelTime(helper); _showToolUpgradeStatus = new ShowToolUpgradeStatus(helper); _showRobinBuildingStatusIcon = new ShowRobinBuildingStatusIcon(helper); _elementsToDispose = new List <IDisposable>() { _luckOfDay, _showBirthdayIcon, _showAccurateHearts, _locationOfTownsfolk, _showWhenAnimalNeedsPet, _showCalendarAndBillboardOnGameMenuButton, _showCropAndBarrelTime, _experienceBar, _showItemHoverInformation, _showTravelingMerchant, _showRainyDayIcon, _shopHarvestPrices, _showQueenOfSauceIcon, _showToolUpgradeStatus, _showRobinBuildingStatusIcon }; int whichOption = 1; Version thisVersion = Assembly.GetAssembly(this.GetType()).GetName().Version; _optionsElements.Add(new ModOptionsElement("UI Info Suite 2 v" + thisVersion.Major + "." + thisVersion.Minor + "." + thisVersion.Build)); var luckIcon = new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowLuckIcon), whichOption++, _luckOfDay.ToggleOption, _options, OptionKeys.ShowLuckIcon); _optionsElements.Add(luckIcon); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowExactValue), whichOption++, _luckOfDay.ToggleShowExactValueOption, _options, OptionKeys.ShowExactValue, luckIcon, false)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowLevelUpAnimation), whichOption++, _experienceBar.ToggleLevelUpAnimation, _options, OptionKeys.ShowLevelUpAnimation)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowExperienceBar), whichOption++, _experienceBar.ToggleShowExperienceBar, _options, OptionKeys.ShowExperienceBar)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.AllowExperienceBarToFadeOut), whichOption++, _experienceBar.ToggleExperienceBarFade, _options, OptionKeys.AllowExperienceBarToFadeOut)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowExperienceGain), whichOption++, _experienceBar.ToggleShowExperienceGain, _options, OptionKeys.ShowExperienceGain)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowLocationOfTownsPeople), whichOption++, _locationOfTownsfolk.ToggleShowNPCLocationsOnMap, _options, OptionKeys.ShowLocationOfTownsPeople)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowBirthdayIcon), whichOption++, _showBirthdayIcon.ToggleOption, _options, OptionKeys.ShowBirthdayIcon)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowHeartFills), whichOption++, _showAccurateHearts.ToggleOption, _options, OptionKeys.ShowHeartFills)); var animalPetIcon = new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowAnimalsNeedPets), whichOption++, _showWhenAnimalNeedsPet.ToggleOption, _options, OptionKeys.ShowAnimalsNeedPets); _optionsElements.Add(animalPetIcon); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.HideAnimalPetOnMaxFriendship), whichOption++, _showWhenAnimalNeedsPet.ToggleDisableOnMaxFirendshipOption, _options, OptionKeys.HideAnimalPetOnMaxFriendship, animalPetIcon)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.DisplayCalendarAndBillboard), whichOption++, _showCalendarAndBillboardOnGameMenuButton.ToggleOption, _options, OptionKeys.DisplayCalendarAndBillboard)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowCropAndBarrelTooltip), whichOption++, _showCropAndBarrelTime.ToggleOption, _options, OptionKeys.ShowCropAndBarrelTooltip)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowItemEffectRanges), whichOption++, _showScarecrowAndSprinklerRange.ToggleOption, _options, OptionKeys.ShowItemEffectRanges)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowExtraItemInformation), whichOption++, _showItemHoverInformation.ToggleOption, _options, OptionKeys.ShowExtraItemInformation)); var travellingMerchantIcon = new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowTravelingMerchant), whichOption++, _showTravelingMerchant.ToggleOption, _options, OptionKeys.ShowTravelingMerchant); _optionsElements.Add(travellingMerchantIcon); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.HideMerchantWhenVisited), whichOption++, _showTravelingMerchant.ToggleHideWhenVisitedOption, _options, OptionKeys.HideMerchantWhenVisited, travellingMerchantIcon, false)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowRainyDay), whichOption++, _showRainyDayIcon.ToggleOption, _options, OptionKeys.ShowRainyDay)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowHarvestPricesInShop), whichOption++, _shopHarvestPrices.ToggleOption, _options, OptionKeys.ShowHarvestPricesInShop)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowWhenNewRecipesAreAvailable), whichOption++, _showQueenOfSauceIcon.ToggleOption, _options, OptionKeys.ShowWhenNewRecipesAreAvailable)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowToolUpgradeStatus), whichOption++, _showToolUpgradeStatus.ToggleOption, _options, OptionKeys.ShowToolUpgradeStatus)); _optionsElements.Add(new ModOptionsCheckbox(_helper.SafeGetString(OptionKeys.ShowRobinBuildingStatusIcon), whichOption++, _showRobinBuildingStatusIcon.ToggleOption, _options, OptionKeys.ShowRobinBuildingStatusIcon)); }