2018-12-30 18:00:05 +08:00
|
|
|
using System;
|
2016-10-13 14:28:13 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2017-07-28 08:28:39 +08:00
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
using StardewValley;
|
|
|
|
using StardewValley.Menus;
|
|
|
|
using Object = StardewValley.Object;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-31 11:07:07 +08:00
|
|
|
namespace Omegasis.BuyBackCollectables.Framework
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The clickable menu which lets the player buy back collectables.</summary>
|
|
|
|
internal class BuyBackMenu : IClickableMenu
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
/*********
|
2019-01-06 15:23:07 +08:00
|
|
|
** Fields
|
2017-07-30 02:18:46 +08:00
|
|
|
*********/
|
|
|
|
/// <summary>The organics tab ID.</summary>
|
|
|
|
private const int OrganicsTab = 0;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The fish tab ID.</summary>
|
|
|
|
private const int FishTab = 1;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The archaeology tab ID.</summary>
|
|
|
|
private const int ArchaeologyTab = 2;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The minerals tab ID.</summary>
|
|
|
|
private const int MineralsTab = 3;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The cooking tab ID.</summary>
|
|
|
|
private const int CookingTab = 4;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The achievements tab ID.</summary>
|
|
|
|
private const int AchievementsTab = 5;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The offset to apply to the selected tab.</summary>
|
|
|
|
private readonly int WidthToMoveActiveTab = Game1.tileSize / 8;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The multiplier applied to the cost of buying back a collectable.</summary>
|
|
|
|
private readonly double CostMultiplier;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The back button.</summary>
|
|
|
|
private readonly ClickableTextureComponent BackButton;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The forward button.</summary>
|
|
|
|
private readonly ClickableTextureComponent ForwardButton;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The category tabs shown along the side.</summary>
|
|
|
|
private readonly List<ClickableTextureComponent> SideTabs = new List<ClickableTextureComponent>();
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The text to display in a hover tooltip.</summary>
|
|
|
|
private string HoverText = "";
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The selected tab.</summary>
|
|
|
|
private int CurrentTab;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The selected page.</summary>
|
|
|
|
private int CurrentPage;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The buttons to show for each tab.</summary>
|
|
|
|
private readonly Dictionary<int, List<List<ClickableTextureComponent>>> Collections = new Dictionary<int, List<List<ClickableTextureComponent>>>();
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The cost to buy back the selected item.</summary>
|
|
|
|
private int Value;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The selected item.</summary>
|
|
|
|
public Item NewItem;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The cost to buy back the selected item.</summary>
|
|
|
|
public int NewItemValue;
|
2016-10-13 14:28:13 +08:00
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
|
|
|
|
/*********
|
|
|
|
** Public methods
|
|
|
|
*********/
|
|
|
|
/// <summary>Construct an instance.</summary>
|
|
|
|
/// <param name="costMultiplier">The multiplier applied to the cost of buying back a collectable.</param>
|
|
|
|
public BuyBackMenu(double costMultiplier)
|
|
|
|
: base(Game1.viewport.Width / 2 - (800 + IClickableMenu.borderWidth * 2) / 2, Game1.viewport.Height / 2 - (600 + IClickableMenu.borderWidth * 2) / 2, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
// initialise
|
|
|
|
this.CostMultiplier = costMultiplier;
|
|
|
|
|
|
|
|
// create components
|
|
|
|
this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4 + this.WidthToMoveActiveTab, this.yPositionOnScreen + Game1.tileSize * 2, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Shipped"), Game1.mouseCursors, new Rectangle(640, 80, 16, 16), Game1.pixelZoom));
|
|
|
|
this.Collections.Add(BuyBackMenu.OrganicsTab, new List<List<ClickableTextureComponent>>());
|
|
|
|
this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 3, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Fish"), Game1.mouseCursors, new Rectangle(640, 64, 16, 16), Game1.pixelZoom));
|
|
|
|
this.Collections.Add(BuyBackMenu.FishTab, new List<List<ClickableTextureComponent>>());
|
|
|
|
this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 4, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Artifacts"), Game1.mouseCursors, new Rectangle(656, 64, 16, 16), Game1.pixelZoom));
|
|
|
|
this.Collections.Add(BuyBackMenu.ArchaeologyTab, new List<List<ClickableTextureComponent>>());
|
|
|
|
this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 5, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Minerals"), Game1.mouseCursors, new Rectangle(672, 64, 16, 16), Game1.pixelZoom));
|
|
|
|
this.Collections.Add(BuyBackMenu.MineralsTab, new List<List<ClickableTextureComponent>>());
|
|
|
|
this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 6, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Cooking"), Game1.mouseCursors, new Rectangle(688, 64, 16, 16), Game1.pixelZoom));
|
|
|
|
this.Collections.Add(BuyBackMenu.CookingTab, new List<List<ClickableTextureComponent>>());
|
|
|
|
this.SideTabs.Add(new ClickableTextureComponent("", new Rectangle(this.xPositionOnScreen - Game1.tileSize * 3 / 4, this.yPositionOnScreen + Game1.tileSize * 7, Game1.tileSize, Game1.tileSize), "", Game1.content.LoadString("Strings\\UI:Collections_Achievements"), Game1.mouseCursors, new Rectangle(656, 80, 16, 16), Game1.pixelZoom));
|
|
|
|
this.Collections.Add(BuyBackMenu.AchievementsTab, new List<List<ClickableTextureComponent>>());
|
2017-07-31 11:07:07 +08:00
|
|
|
this.BackButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + Game1.tileSize * 3 / 4, this.yPositionOnScreen + this.height - 20 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), Game1.pixelZoom);
|
|
|
|
this.ForwardButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + this.width - Game1.tileSize / 2 - 15 * Game1.pixelZoom, this.yPositionOnScreen + this.height - 20 * Game1.pixelZoom, 12 * Game1.pixelZoom, 11 * Game1.pixelZoom), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), Game1.pixelZoom);
|
2017-07-30 02:18:46 +08:00
|
|
|
int[] array = new int[this.SideTabs.Count];
|
2016-10-13 14:28:13 +08:00
|
|
|
int num = this.xPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearSideBorder;
|
|
|
|
int num2 = this.yPositionOnScreen + IClickableMenu.borderWidth + IClickableMenu.spaceToClearTopBorder - Game1.tileSize / 4;
|
|
|
|
int num3 = 10;
|
2017-07-30 02:18:46 +08:00
|
|
|
foreach (KeyValuePair<int, string> entry in Game1.objectInformation)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
string fields = entry.Value.Split('/')[3];
|
2016-10-13 14:28:13 +08:00
|
|
|
bool drawShadow = false;
|
2017-07-30 02:18:46 +08:00
|
|
|
int selectedTab;
|
|
|
|
if (fields.Contains("Arch"))
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
selectedTab = BuyBackMenu.ArchaeologyTab;
|
|
|
|
if (Game1.player.archaeologyFound.ContainsKey(entry.Key))
|
2016-10-13 14:28:13 +08:00
|
|
|
drawShadow = true;
|
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
else if (fields.Contains("Fish"))
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
if (entry.Key >= 167 && entry.Key < 173)
|
2016-10-13 14:28:13 +08:00
|
|
|
continue;
|
2017-07-30 02:18:46 +08:00
|
|
|
selectedTab = BuyBackMenu.FishTab;
|
|
|
|
if (Game1.player.fishCaught.ContainsKey(entry.Key))
|
2016-10-13 14:28:13 +08:00
|
|
|
drawShadow = true;
|
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
else if (fields.Contains("Mineral") || fields.Substring(fields.Length - 3).Equals("-2"))
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
selectedTab = BuyBackMenu.MineralsTab;
|
|
|
|
if (Game1.player.mineralsFound.ContainsKey(entry.Key))
|
2016-10-13 14:28:13 +08:00
|
|
|
drawShadow = true;
|
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
else if (fields.Contains("Cooking") || fields.Substring(fields.Length - 3).Equals("-7"))
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
selectedTab = BuyBackMenu.CookingTab;
|
|
|
|
if (Game1.player.recipesCooked.ContainsKey(entry.Key))
|
2016-10-13 14:28:13 +08:00
|
|
|
drawShadow = true;
|
2017-07-30 02:18:46 +08:00
|
|
|
if (entry.Key == 217 || entry.Key == 772 || entry.Key == 773)
|
2016-10-13 14:28:13 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
if (!Object.isPotentialBasicShippedCategory(entry.Key, fields.Substring(fields.Length - 3)))
|
2016-10-13 14:28:13 +08:00
|
|
|
continue;
|
2017-07-30 02:18:46 +08:00
|
|
|
selectedTab = BuyBackMenu.OrganicsTab;
|
|
|
|
if (Game1.player.basicShipped.ContainsKey(entry.Key))
|
2016-10-13 14:28:13 +08:00
|
|
|
drawShadow = true;
|
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
int x2 = num + array[selectedTab] % num3 * (Game1.tileSize + 4);
|
|
|
|
int num5 = num2 + array[selectedTab] / num3 * (Game1.tileSize + 4);
|
2017-07-31 11:07:07 +08:00
|
|
|
if (num5 > this.yPositionOnScreen + this.height - 128)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
this.Collections[selectedTab].Add(new List<ClickableTextureComponent>());
|
|
|
|
array[selectedTab] = 0;
|
2016-10-13 14:28:13 +08:00
|
|
|
x2 = num;
|
|
|
|
num5 = num2;
|
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
if (this.Collections[selectedTab].Count == 0)
|
|
|
|
this.Collections[selectedTab].Add(new List<ClickableTextureComponent>());
|
|
|
|
this.Collections[selectedTab].Last().Add(new ClickableTextureComponent(entry.Key + " " + drawShadow, new Rectangle(x2, num5, Game1.tileSize, Game1.tileSize), null, "", Game1.objectSpriteSheet, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, entry.Key, 16, 16), Game1.pixelZoom, drawShadow));
|
|
|
|
array[selectedTab]++;
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
if (this.Collections[5].Count == 0)
|
|
|
|
this.Collections[5].Add(new List<ClickableTextureComponent>());
|
2016-10-13 14:28:13 +08:00
|
|
|
foreach (KeyValuePair<int, string> current2 in Game1.achievements)
|
|
|
|
{
|
|
|
|
bool flag = Game1.player.achievements.Contains(current2.Key);
|
2017-07-30 02:18:46 +08:00
|
|
|
string[] array2 = current2.Value.Split('^');
|
|
|
|
if (flag || (array2[2].Equals("true") && (array2[3].Equals("-1") || this.FarmerHasAchievements(array2[3]))))
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
|
|
|
int x3 = num + array[5] % num3 * (Game1.tileSize + 4);
|
|
|
|
int y2 = num2 + array[5] / num3 * (Game1.tileSize + 4);
|
2017-07-30 02:18:46 +08:00
|
|
|
this.Collections[5][0].Add(new ClickableTextureComponent(current2.Key + " " + flag, new Rectangle(x3, y2, Game1.tileSize, Game1.tileSize), null, "", Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 25), 1f));
|
2016-10-13 14:28:13 +08:00
|
|
|
array[5]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
|
|
|
|
/*********
|
|
|
|
** Private methods
|
|
|
|
*********/
|
|
|
|
/// <summary>Get whether the farmer has the given achievements.</summary>
|
|
|
|
/// <param name="listOfAchievementNumbers">The achievement IDs as a space-separated list.</param>
|
|
|
|
private bool FarmerHasAchievements(string listOfAchievementNumbers)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
string[] array = listOfAchievementNumbers.Split(' ');
|
|
|
|
foreach (string text in array)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
|
|
|
if (!Game1.player.achievements.Contains(Convert.ToInt32(text)))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The method invoked when the player left-clicks on the menu.</summary>
|
|
|
|
/// <param name="x">The X-position of the cursor.</param>
|
|
|
|
/// <param name="y">The Y-position of the cursor.</param>
|
|
|
|
/// <param name="playSound">Whether to enable sound.</param>
|
2016-10-13 14:28:13 +08:00
|
|
|
public override void receiveLeftClick(int x, int y, bool playSound = true)
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
for (int i = 0; i < this.SideTabs.Count; i++)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
if (this.SideTabs[i].containsPoint(x, y) && this.CurrentTab != i)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
|
|
|
Game1.playSound("smallSelect");
|
2017-07-30 02:18:46 +08:00
|
|
|
ClickableTextureComponent curTab = this.SideTabs[this.CurrentTab];
|
|
|
|
curTab.bounds.X = curTab.bounds.X - this.WidthToMoveActiveTab;
|
|
|
|
this.CurrentTab = i;
|
|
|
|
this.CurrentPage = 0;
|
|
|
|
ClickableTextureComponent newTab = this.SideTabs[i];
|
|
|
|
newTab.bounds.X = newTab.bounds.X + this.WidthToMoveActiveTab;
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
if (this.CurrentPage > 0 && this.BackButton.containsPoint(x, y))
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
this.CurrentPage--;
|
2016-10-13 14:28:13 +08:00
|
|
|
Game1.playSound("shwip");
|
2017-07-30 02:18:46 +08:00
|
|
|
this.BackButton.scale = this.BackButton.baseScale;
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
if (this.CurrentPage < this.Collections[this.CurrentTab].Count - 1 && this.ForwardButton.containsPoint(x, y))
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
this.CurrentPage++;
|
2016-10-13 14:28:13 +08:00
|
|
|
Game1.playSound("shwip");
|
2017-07-30 02:18:46 +08:00
|
|
|
this.ForwardButton.scale = this.ForwardButton.baseScale;
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
foreach (ClickableTextureComponent current2 in this.Collections[this.CurrentTab][this.CurrentPage])
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
if (current2.containsPoint(x, y) && this.NewItem != null && Game1.player.money >= this.Value)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
Game1.player.money -= this.Value;
|
2018-05-07 09:21:31 +08:00
|
|
|
Game1.playSound("coin");
|
2017-07-30 02:18:46 +08:00
|
|
|
Game1.player.addItemByMenuIfNecessary(this.NewItem);
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The method invoked when the player right-clicks on the lookup UI.</summary>
|
|
|
|
/// <param name="x">The X-position of the cursor.</param>
|
|
|
|
/// <param name="y">The Y-position of the cursor.</param>
|
|
|
|
/// <param name="playSound">Whether to enable sound.</param>
|
2016-10-13 14:28:13 +08:00
|
|
|
public override void receiveRightClick(int x, int y, bool playSound = true)
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
if (this.NewItem != null && Game1.player.money >= this.Value)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
Game1.player.money -= this.Value;
|
|
|
|
Game1.player.addItemByMenuIfNecessary(this.NewItem);
|
2018-05-07 09:21:31 +08:00
|
|
|
Game1.playSound("coin");
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>The method invoked when the player hovers the cursor over the menu.</summary>
|
|
|
|
/// <param name="x">The X-position of the cursor.</param>
|
|
|
|
/// <param name="y">The Y-position of the cursor.</param>
|
2016-10-13 14:28:13 +08:00
|
|
|
public override void performHoverAction(int x, int y)
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
this.HoverText = "";
|
|
|
|
this.Value = -1;
|
|
|
|
foreach (ClickableTextureComponent current in this.SideTabs)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
|
|
|
if (current.containsPoint(x, y))
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
this.HoverText = current.hoverText;
|
2016-10-13 14:28:13 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
foreach (ClickableTextureComponent current2 in this.Collections[this.CurrentTab][this.CurrentPage])
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
|
|
|
if (current2.containsPoint(x, y))
|
|
|
|
{
|
|
|
|
current2.scale = Math.Min(current2.scale + 0.02f, current2.baseScale + 0.1f);
|
2017-07-30 02:18:46 +08:00
|
|
|
if (Convert.ToBoolean(current2.name.Split(' ')[1]) || this.CurrentTab == 5)
|
|
|
|
this.HoverText = this.CreateDescription(Convert.ToInt32(current2.name.Split(' ')[0]));
|
2016-10-13 14:28:13 +08:00
|
|
|
else
|
2017-07-30 02:18:46 +08:00
|
|
|
this.HoverText = "???";
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
current2.scale = Math.Max(current2.scale - 0.02f, current2.baseScale);
|
|
|
|
}
|
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
this.ForwardButton.tryHover(x, y, 0.5f);
|
|
|
|
this.BackButton.tryHover(x, y, 0.5f);
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>Generate the item description for an item ID.</summary>
|
|
|
|
/// <param name="index">The item ID.</param>
|
|
|
|
private string CreateDescription(int index)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
|
|
|
string text = "";
|
2017-07-30 02:18:46 +08:00
|
|
|
if (this.CurrentTab == 5)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
string[] array = Game1.achievements[index].Split('^');
|
2016-10-13 14:28:13 +08:00
|
|
|
text = text + array[0] + Environment.NewLine + Environment.NewLine;
|
|
|
|
text += array[1];
|
2017-07-30 02:18:46 +08:00
|
|
|
this.NewItem = null;
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
string[] array2 = Game1.objectInformation[index].Split('/');
|
2016-10-13 14:28:13 +08:00
|
|
|
foreach (KeyValuePair<int, string> meh in Game1.objectInformation)
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
string[] array3 = meh.Value.Split('/');
|
2016-10-13 14:28:13 +08:00
|
|
|
if (array3[0] == array2[0])
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
this.NewItem = new Object(Convert.ToInt32(meh.Key), 1);
|
|
|
|
if (this.NewItem.Name == "Stone" || this.NewItem.Name == "stone") this.NewItem = new Object(390, 1);
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
text = string.Concat(text, array2[0], Environment.NewLine, Environment.NewLine, Game1.parseText(array2[4], Game1.smallFont, Game1.tileSize * 4), Environment.NewLine, Environment.NewLine);
|
2016-10-13 14:28:13 +08:00
|
|
|
if (array2[3].Contains("Arch"))
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
text += (Game1.player.archaeologyFound.ContainsKey(index) ? Game1.content.LoadString("Strings\\UI:Collections_Description_ArtifactsFound", Game1.player.archaeologyFound[index][0]) : "");
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
else if (array2[3].Contains("Cooking"))
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
text += (Game1.player.recipesCooked.ContainsKey(index) ? Game1.content.LoadString("Strings\\UI:Collections_Description_RecipesCooked", Game1.player.recipesCooked[index]) : "");
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
else if (array2[3].Contains("Fish"))
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
text += Game1.content.LoadString("Strings\\UI:Collections_Description_FishCaught", Game1.player.fishCaught.ContainsKey(index) ? Game1.player.fishCaught[index][0] : 0);
|
2016-10-13 14:28:13 +08:00
|
|
|
if (Game1.player.fishCaught.ContainsKey(index) && Game1.player.fishCaught[index][1] > 0)
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
text = text + Environment.NewLine + Game1.content.LoadString("Strings\\UI:Collections_Description_BiggestCatch", Game1.player.fishCaught[index][1]);
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (array2[3].Contains("Minerals") || array2[3].Substring(array2[3].Length - 3).Equals("-2"))
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
text += Game1.content.LoadString("Strings\\UI:Collections_Description_MineralsFound", Game1.player.mineralsFound.ContainsKey(index) ? Game1.player.mineralsFound[index] : 0);
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
text += Game1.content.LoadString("Strings\\UI:Collections_Description_NumberShipped", Game1.player.basicShipped.ContainsKey(index) ? Game1.player.basicShipped[index] : 0);
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
2017-07-30 02:18:46 +08:00
|
|
|
this.Value = Convert.ToInt32(array2[1]);
|
|
|
|
this.Value = (int)(this.Value * this.CostMultiplier);
|
|
|
|
this.NewItemValue = this.Value;
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2017-07-30 02:18:46 +08:00
|
|
|
/// <summary>Draw the menu to the screen.</summary>
|
|
|
|
/// <param name="b">The sprite batch.</param>
|
2016-10-13 14:28:13 +08:00
|
|
|
public override void draw(SpriteBatch b)
|
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
Game1.drawDialogueBox(this.xPositionOnScreen, this.yPositionOnScreen, this.width, this.height, false, true);
|
|
|
|
|
|
|
|
foreach (var tab in this.SideTabs)
|
|
|
|
tab.draw(b);
|
|
|
|
|
|
|
|
if (this.CurrentPage > 0)
|
|
|
|
this.BackButton.draw(b);
|
|
|
|
if (this.CurrentPage < this.Collections[this.CurrentTab].Count - 1)
|
|
|
|
this.ForwardButton.draw(b);
|
2016-10-13 14:28:13 +08:00
|
|
|
b.End();
|
|
|
|
b.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null);
|
2017-07-30 02:18:46 +08:00
|
|
|
foreach (ClickableTextureComponent current in this.Collections[this.CurrentTab][this.CurrentPage])
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
bool flag = Convert.ToBoolean(current.name.Split(' ')[1]);
|
2016-10-13 14:28:13 +08:00
|
|
|
current.draw(b, flag ? Color.White : (Color.Black * 0.2f), 0.86f);
|
2017-07-30 02:18:46 +08:00
|
|
|
if (this.CurrentTab == 5 & flag)
|
2016-10-13 14:28:13 +08:00
|
|
|
{
|
2017-07-30 02:18:46 +08:00
|
|
|
int num = new Random(Convert.ToInt32(current.name.Split(' ')[0])).Next(12);
|
|
|
|
b.Draw(Game1.mouseCursors, new Vector2(current.bounds.X + 16 + Game1.tileSize / 4, current.bounds.Y + 20 + Game1.tileSize / 4), new Rectangle(256 + num % 6 * Game1.tileSize / 2, 128 + num / 6 * Game1.tileSize / 2, Game1.tileSize / 2, Game1.tileSize / 2), Color.White, 0f, new Vector2(Game1.tileSize / 4, Game1.tileSize / 4), current.scale, SpriteEffects.None, 0.88f);
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
b.End();
|
|
|
|
b.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
2017-07-30 02:18:46 +08:00
|
|
|
if (!this.HoverText.Equals(""))
|
|
|
|
IClickableMenu.drawHoverText(b, this.HoverText, Game1.smallFont, 0, 0, this.Value);
|
2016-10-13 14:28:13 +08:00
|
|
|
if (!Game1.options.hardwareCursor)
|
2017-07-30 02:18:46 +08:00
|
|
|
b.Draw(Game1.mouseCursors, new Vector2(Game1.getMouseX(), Game1.getMouseY()), Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 0, 16, 16), Color.White * Game1.mouseCursorTransparency, 0f, Vector2.Zero, Game1.pixelZoom + Game1.dialogueButtonScale / 150f, SpriteEffects.None, 1f);
|
|
|
|
|
2016-10-13 14:28:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|