Fixed a lot of bugs. Updated for official multiplayer release. Started adding integration with level extender mod.

This commit is contained in:
cdaragorn 2018-08-19 15:57:45 -06:00
parent c92c20b6b6
commit fd9c4f28ef
14 changed files with 415 additions and 260 deletions

14
SDVModTest/LEEvents.cs Normal file
View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UIInfoSuite
{
public interface LEEvents
{
event EventHandler OnXPChanged;
void raiseEvent();
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UIInfoSuite
{
public interface LevelExtenderInterface
{
int[] currentXP();
int[] requiredXP();
}
}

View File

@ -20,7 +20,6 @@ namespace UIInfoSuite
{
public class ModEntry : Mod
{
private readonly SkipIntro _skipIntro = new SkipIntro();
private String _modDataFileName;
@ -38,6 +37,11 @@ namespace UIInfoSuite
}
~ModEntry()
{
}
public override void Entry(IModHelper helper)
{
//Helper = helper;
@ -70,7 +74,7 @@ namespace UIInfoSuite
private void ReturnToTitle(object sender, EventArgs e)
{
_modOptionsPageHandler.Dispose();
_modOptionsPageHandler?.Dispose();
_modOptionsPageHandler = null;
}

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.13.0")]
[assembly: AssemblyFileVersion("1.7.13.0")]
[assembly: AssemblyVersion("1.7.18.0")]
[assembly: AssemblyFileVersion("1.7.18.0")]

View File

@ -71,6 +71,8 @@
<Compile Include="Extensions\CollectionExtensions.cs" />
<Compile Include="Extensions\ObjectExtensions.cs" />
<Compile Include="LanguageKeys.cs" />
<Compile Include="LEEvents.cs" />
<Compile Include="LevelExtenderInterface.cs" />
<Compile Include="ModConfig.cs" />
<Compile Include="Options\ModOptionsCheckbox.cs" />
<Compile Include="Options\ModOptionsPageButton.cs" />
@ -151,7 +153,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180630\analyzers\dotnet\cs\StardewModdingAPI.ModBuildConfig.Analyzer.dll" />
<Analyzer Include="..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\analyzers\dotnet\cs\StardewModdingAPI.ModBuildConfig.Analyzer.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
@ -163,11 +165,11 @@
<Copy SourceFiles="$(TargetDir)\$(TargetName).dll.mdb" DestinationFolder="$(ModPath)" Condition="Exists('$(TargetDir)\$(TargetName).dll.mdb')" />
<Copy SourceFiles="$(ProjectDir)manifest.json" DestinationFolder="$(ModPath)" />
</Target>
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180630\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180630\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180630\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0-beta-20180630\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
</Project>

View File

@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Media;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -21,15 +22,20 @@ namespace UIInfoSuite.UIElements
{
class ExperienceBar : IDisposable
{
public interface LevelExtenderEvents
{
event EventHandler OnXPChanged;
}
private const int MaxBarWidth = 175;
//private float _currentExperience = 0;
private int[] _currentExperience = new int[5];
private readonly List<ExperiencePointDisplay> _experiencePointDisplays = new List<ExperiencePointDisplay>();
private GameLocation _currentLocation = new GameLocation();
private readonly TimeSpan _levelUpPauseTime = TimeSpan.FromSeconds(2);
private Color _iconColor = Color.White;
private readonly Color _iconColor = Color.White;
private Color _experienceFillColor = Color.Blue;
private Rectangle _experienceIconPosition = new Rectangle(10, 428, 10, 10);
private Item _previousItem = null;
private bool _experienceBarShouldBeVisible = false;
private bool _shouldDrawLevelUp = false;
@ -44,6 +50,13 @@ namespace UIInfoSuite.UIElements
private readonly IModHelper _helper;
private SoundPlayer _player;
private LevelExtenderInterface _levelExtenderAPI;
private int _currentSkillLevel = 0;
private int _experienceRequiredToLevel = -1;
private int _experienceFromPreviousLevels = -1;
private int _experienceEarnedThisLevel = -1;
public ExperienceBar(IModHelper helper)
{
_helper = helper;
@ -64,6 +77,40 @@ namespace UIInfoSuite.UIElements
_timeToDisappear.Elapsed += StopTimerAndFadeBarOut;
GraphicsEvents.OnPreRenderHudEvent += OnPreRenderHudEvent;
PlayerEvents.Warped += RemoveAllExperiencePointDisplays;
//var something = _helper.ModRegistry.GetApi("DevinLematty.LevelExtender");
try
{
_levelExtenderAPI = _helper.ModRegistry.GetApi<LevelExtenderInterface>("DevinLematty.LevelExtender");
}
catch (Exception ex)
{
int j = 4;
}
int f = 3;
//if (something != null)
//{
// try
// {
// var methods = something.GetType().GetMethods();
// var currentXPMethod = something.GetType().GetMethod("currentXP");
// foreach (var method in methods)
// {
// }
// }
// catch (Exception ex)
// {
// int f = 3;
// }
//}
}
private void LoadModApis(object sender, EventArgs e)
{
}
public void Dispose()
@ -71,8 +118,11 @@ namespace UIInfoSuite.UIElements
PlayerEvents.LeveledUp -= OnLevelUp;
GraphicsEvents.OnPreRenderHudEvent -= OnPreRenderHudEvent;
PlayerEvents.Warped -= RemoveAllExperiencePointDisplays;
GameEvents.QuarterSecondTick -= DetermineIfExperienceHasBeenGained;
_timeToDisappear.Elapsed -= StopTimerAndFadeBarOut;
_timeToDisappear.Stop();
_timeToDisappear.Dispose();
_timeToDisappear = null;
}
public void ToggleLevelUpAnimation(bool showLevelUpAnimation)
@ -93,21 +143,29 @@ namespace UIInfoSuite.UIElements
public void ToggleShowExperienceGain(bool showExperienceGain)
{
GameEvents.QuarterSecondTick -= DetermineIfExperienceHasBeenGained;
for (int i = 0; i < _currentExperience.Length; ++i)
_currentExperience[i] = Game1.player.experiencePoints[i];
_showExperienceGain = showExperienceGain;
if (showExperienceGain)
{
GameEvents.QuarterSecondTick += DetermineIfExperienceHasBeenGained;
}
}
public void ToggleShowExperienceBar(bool showExperienceBar)
{
GameEvents.QuarterSecondTick -= DetermineIfExperienceHasBeenGained;
//GraphicsEvents.OnPreRenderHudEvent -= OnPreRenderHudEvent;
//PlayerEvents.Warped -= RemoveAllExperiencePointDisplays;
_showExperienceBar = showExperienceBar;
//if (showExperienceBar)
//{
// GraphicsEvents.OnPreRenderHudEvent += OnPreRenderHudEvent;
// PlayerEvents.Warped += RemoveAllExperiencePointDisplays;
//}
if (showExperienceBar)
{
//GraphicsEvents.OnPreRenderHudEvent += OnPreRenderHudEvent;
//PlayerEvents.Warped += RemoveAllExperiencePointDisplays;
GameEvents.QuarterSecondTick += DetermineIfExperienceHasBeenGained;
}
}
private void OnLevelUp(object sender, EventArgsLevelUp e)
@ -123,9 +181,7 @@ namespace UIInfoSuite.UIElements
case EventArgsLevelUp.LevelType.Mining: _levelUpIconRectangle.X = 30; break;
}
_shouldDrawLevelUp = true;
_timeToDisappear.Interval = _timeBeforeExperienceBarFades.TotalMilliseconds;
_timeToDisappear.Start();
_experienceBarShouldBeVisible = true;
ShowExperienceBar();
float previousAmbientVolume = Game1.options.ambientVolumeLevel;
float previousMusicVolume = Game1.options.musicVolumeLevel;
@ -160,7 +216,7 @@ namespace UIInfoSuite.UIElements
private void StopTimerAndFadeBarOut(object sender, ElapsedEventArgs e)
{
_timeToDisappear.Stop();
_timeToDisappear?.Stop();
_experienceBarShouldBeVisible = false;
}
@ -169,141 +225,154 @@ namespace UIInfoSuite.UIElements
_experiencePointDisplays.Clear();
}
private void DetermineIfExperienceHasBeenGained(object sender, EventArgs e)
{
Item currentItem = Game1.player.CurrentItem;
int currentLevelIndex = -1;
for (int i = 0; i < _currentExperience.Length; ++i)
{
if (_currentExperience[i] != Game1.player.experiencePoints[i])
{
currentLevelIndex = i;
break;
}
}
if (currentLevelIndex > -1)
{
switch (currentLevelIndex)
{
case 0:
{
_experienceFillColor = new Color(255, 251, 35, 0.38f);
_experienceIconPosition.X = 10;
_currentSkillLevel = Game1.player.farmingLevel.Value;
break;
}
case 1:
{
_experienceFillColor = new Color(17, 84, 252, 0.63f);
_experienceIconPosition.X = 20;
_currentSkillLevel = Game1.player.fishingLevel.Value;
break;
}
case 2:
{
_experienceFillColor = new Color(0, 234, 0, 0.63f);
_experienceIconPosition.X = 60;
_currentSkillLevel = Game1.player.foragingLevel.Value;
break;
}
case 3:
{
_experienceFillColor = new Color(145, 104, 63, 0.63f);
_experienceIconPosition.X = 30;
_currentSkillLevel = Game1.player.miningLevel.Value;
break;
}
case 4:
{
_experienceFillColor = new Color(204, 0, 3, 0.63f);
_experienceIconPosition.X = 120;
_currentSkillLevel = Game1.player.combatLevel.Value;
break;
}
}
_experienceRequiredToLevel = GetExperienceRequiredToLevel(_currentSkillLevel);
_experienceFromPreviousLevels = GetExperienceRequiredToLevel(_currentSkillLevel - 1);
_experienceEarnedThisLevel = Game1.player.experiencePoints[currentLevelIndex] - _experienceFromPreviousLevels;
int experiencePreviouslyEarnedThisLevel = _currentExperience[currentLevelIndex] - _experienceFromPreviousLevels;
if (_experienceRequiredToLevel <= 0 &&
_levelExtenderAPI != null)
{
_experienceEarnedThisLevel = _levelExtenderAPI.currentXP()[currentLevelIndex];
_experienceFromPreviousLevels = _currentExperience[currentLevelIndex] - _experienceEarnedThisLevel;
_experienceRequiredToLevel = _levelExtenderAPI.requiredXP()[currentLevelIndex] + _experienceFromPreviousLevels;
}
ShowExperienceBar();
if (_showExperienceGain &&
_experienceRequiredToLevel > 0)
{
_experiencePointDisplays.Add(
new ExperiencePointDisplay(
Game1.player.experiencePoints[currentLevelIndex] - _currentExperience[currentLevelIndex],
Game1.player.getLocalPosition(Game1.viewport)));
}
_currentExperience[currentLevelIndex] = Game1.player.experiencePoints[currentLevelIndex];
}
else if (_previousItem != currentItem)
{
if (currentItem is FishingRod)
{
_experienceFillColor = new Color(17, 84, 252, 0.63f);
currentLevelIndex = 1;
_experienceIconPosition.X = 20;
_currentSkillLevel = Game1.player.fishingLevel.Value;
}
else if (currentItem is Pickaxe)
{
_experienceFillColor = new Color(145, 104, 63, 0.63f);
currentLevelIndex = 3;
_experienceIconPosition.X = 30;
_currentSkillLevel = Game1.player.miningLevel.Value;
}
else if (currentItem is MeleeWeapon &&
currentItem.Name != "Scythe")
{
_experienceFillColor = new Color(204, 0, 3, 0.63f);
currentLevelIndex = 4;
_experienceIconPosition.X = 120;
_currentSkillLevel = Game1.player.combatLevel.Value;
}
else if (Game1.currentLocation is Farm &&
!(currentItem is Axe))
{
_experienceFillColor = new Color(255, 251, 35, 0.38f);
currentLevelIndex = 0;
_experienceIconPosition.X = 10;
_currentSkillLevel = Game1.player.farmingLevel.Value;
}
else
{
_experienceFillColor = new Color(0, 234, 0, 0.63f);
currentLevelIndex = 2;
_experienceIconPosition.X = 60;
_currentSkillLevel = Game1.player.foragingLevel.Value;
}
_experienceRequiredToLevel = GetExperienceRequiredToLevel(_currentSkillLevel);
_experienceFromPreviousLevels = GetExperienceRequiredToLevel(_currentSkillLevel - 1);
_experienceEarnedThisLevel = Game1.player.experiencePoints[currentLevelIndex] - _experienceFromPreviousLevels;
if (_experienceRequiredToLevel <= 0 &&
_levelExtenderAPI != null)
{
_experienceEarnedThisLevel = _levelExtenderAPI.currentXP()[currentLevelIndex];
_experienceFromPreviousLevels = _currentExperience[currentLevelIndex] - _experienceEarnedThisLevel;
_experienceRequiredToLevel = _levelExtenderAPI.requiredXP()[currentLevelIndex] + _experienceFromPreviousLevels;
}
ShowExperienceBar();
_previousItem = currentItem;
}
}
private void OnPreRenderHudEvent(object sender, EventArgs e)
{
if (!Game1.eventUp)
{
Item currentItem = Game1.player.CurrentItem;
Rectangle rectangle1 = new Rectangle(10, 428, 10, 10);
int experienceLevel = 0;
int currentLevelIndex = -1;
int experienceRequiredToLevel = -1;
int experienceFromPreviousLevels = -1;
int experienceEarnedThisLevel = -1;
for (int i = 0; i < _currentExperience.Length; ++i)
{
if (_currentExperience[i] != Game1.player.experiencePoints[i])
{
currentLevelIndex = i;
break;
}
}
if (currentLevelIndex > -1)
{
switch ((EventArgsLevelUp.LevelType)currentLevelIndex)
{
case EventArgsLevelUp.LevelType.Combat:
{
_experienceFillColor = new Color(204, 0, 3, 0.63f);
rectangle1.X = 120;
experienceLevel = Game1.player.combatLevel.Value;
break;
}
case EventArgsLevelUp.LevelType.Farming:
{
_experienceFillColor = new Color(255, 251, 35, 0.38f);
rectangle1.X = 10;
experienceLevel = Game1.player.farmingLevel.Value;
break;
}
case EventArgsLevelUp.LevelType.Fishing:
{
_experienceFillColor = new Color(17, 84, 252, 0.63f);
rectangle1.X = 20;
experienceLevel = Game1.player.fishingLevel.Value;
break;
}
case EventArgsLevelUp.LevelType.Foraging:
{
_experienceFillColor = new Color(0, 234, 0, 0.63f);
rectangle1.X = 60;
experienceLevel = Game1.player.foragingLevel.Value;
break;
}
case EventArgsLevelUp.LevelType.Mining:
{
_experienceFillColor = new Color(145, 104, 63, 0.63f);
rectangle1.X = 30;
experienceLevel = Game1.player.miningLevel.Value;
break;
}
}
experienceRequiredToLevel = GetExperienceRequiredToLevel(experienceLevel);
experienceFromPreviousLevels = GetExperienceRequiredToLevel(experienceLevel - 1);
experienceEarnedThisLevel = Game1.player.experiencePoints[currentLevelIndex] - experienceFromPreviousLevels;
int experiencePreviouslyEarnedThisLevel = _currentExperience[currentLevelIndex] - experienceFromPreviousLevels;
_currentExperience[currentLevelIndex] = Game1.player.experiencePoints[currentLevelIndex];
ShowExperienceBar();
if (_showExperienceGain)
{
_experiencePointDisplays.Add(
new ExperiencePointDisplay(
experienceEarnedThisLevel - experiencePreviouslyEarnedThisLevel,
Game1.player.getLocalPosition(Game1.viewport)));
}
}
else
{
if (currentItem is FishingRod)
{
_experienceFillColor = new Color(17, 84, 252, 0.63f);
currentLevelIndex = 1;
rectangle1.X = 20;
experienceLevel = Game1.player.fishingLevel.Value;
}
else if (currentItem is Pickaxe)
{
_experienceFillColor = new Color(145, 104, 63, 0.63f);
currentLevelIndex = 3;
rectangle1.X = 30;
experienceLevel = Game1.player.miningLevel.Value;
}
else if (currentItem is MeleeWeapon &&
currentItem.Name != "Scythe")
{
_experienceFillColor = new Color(204, 0, 3, 0.63f);
currentLevelIndex = 4;
rectangle1.X = 120;
experienceLevel = Game1.player.combatLevel.Value;
}
else if (Game1.currentLocation is Farm &&
!(currentItem is Axe))
{
_experienceFillColor = new Color(255, 251, 35, 0.38f);
currentLevelIndex = 0;
rectangle1.X = 10;
experienceLevel = Game1.player.farmingLevel.Value;
}
else
{
_experienceFillColor = new Color(0, 234, 0, 0.63f);
currentLevelIndex = 2;
rectangle1.X = 60;
experienceLevel = Game1.player.foragingLevel.Value;
}
experienceRequiredToLevel = GetExperienceRequiredToLevel(experienceLevel);
experienceFromPreviousLevels = GetExperienceRequiredToLevel(experienceLevel - 1);
experienceEarnedThisLevel = Game1.player.experiencePoints[currentLevelIndex] - experienceFromPreviousLevels;
if (_previousItem != currentItem)
ShowExperienceBar();
}
_previousItem = currentItem;
if (_shouldDrawLevelUp)
{
Vector2 playerLocalPosition = Game1.player.getLocalPosition(Game1.viewport);
@ -342,13 +411,14 @@ namespace UIInfoSuite.UIElements
}
}
if (_experienceBarShouldBeVisible &&
if (_experienceRequiredToLevel > 0 &&
_experienceBarShouldBeVisible &&
_showExperienceBar)
{
int experienceDifferenceBetweenLevels = experienceRequiredToLevel - experienceFromPreviousLevels;
int barWidth = (int)((double)experienceEarnedThisLevel / experienceDifferenceBetweenLevels * MaxBarWidth);
int experienceDifferenceBetweenLevels = _experienceRequiredToLevel - _experienceFromPreviousLevels;
int barWidth = (int)((double)_experienceEarnedThisLevel / experienceDifferenceBetweenLevels * MaxBarWidth);
DrawExperienceBar(barWidth, experienceEarnedThisLevel, experienceDifferenceBetweenLevels, experienceLevel, rectangle1);
DrawExperienceBar(barWidth, _experienceEarnedThisLevel, experienceDifferenceBetweenLevels, _currentSkillLevel);
}
@ -358,38 +428,51 @@ namespace UIInfoSuite.UIElements
private int GetExperienceRequiredToLevel(int currentLevel)
{
int amount = 0;
switch (currentLevel)
{
case 0: amount = 100; break;
case 1: amount = 380; break;
case 2: amount = 770; break;
case 3: amount = 1300; break;
case 4: amount = 2150; break;
case 5: amount = 3300; break;
case 6: amount = 4800; break;
case 7: amount = 6900; break;
case 8: amount = 10000; break;
case 9: amount = 15000; break;
}
//if (currentLevel < 10)
//{
switch (currentLevel)
{
case 0: amount = 100; break;
case 1: amount = 380; break;
case 2: amount = 770; break;
case 3: amount = 1300; break;
case 4: amount = 2150; break;
case 5: amount = 3300; break;
case 6: amount = 4800; break;
case 7: amount = 6900; break;
case 8: amount = 10000; break;
case 9: amount = 15000; break;
}
//}
//else if (_levelExtenderAPI != null &&
// currentLevel < 100)
//{
// var requiredXP = _levelExtenderAPI.requiredXP();
// amount = requiredXP[currentLevel];
//}
return amount;
}
private void ShowExperienceBar()
{
if (_allowExperienceBarToFadeOut)
if (_timeToDisappear != null)
{
_timeToDisappear.Interval = _timeBeforeExperienceBarFades.TotalMilliseconds;
_timeToDisappear.Start();
}
else
{
_timeToDisappear.Stop();
if (_allowExperienceBarToFadeOut)
{
_timeToDisappear.Interval = _timeBeforeExperienceBarFades.TotalMilliseconds;
_timeToDisappear.Start();
}
else
{
_timeToDisappear.Stop();
}
}
_experienceBarShouldBeVisible = true;
}
private void DrawExperienceBar(int barWidth, int experienceGainedThisLevel, int experienceRequiredForNextLevel, int currentLevel, Rectangle iconPosition)
private void DrawExperienceBar(int barWidth, int experienceGainedThisLevel, int experienceRequiredForNextLevel, int currentLevel)
{
float leftSide = Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Left;
@ -474,7 +557,7 @@ namespace UIInfoSuite.UIElements
new Vector2(
leftSide + 54,
Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 62),
iconPosition,
_experienceIconPosition,
_iconColor,
0,
Vector2.Zero,

View File

@ -50,57 +50,64 @@ namespace UIInfoSuite.UIElements
if (gameMenu.currentTab == 2)
{
int slotPosition = (int)typeof(SocialPage)
.GetField(
"slotPosition",
BindingFlags.Instance | BindingFlags.NonPublic)
.GetValue(_socialPage);
int yOffset = 0;
for (int i = slotPosition; i < slotPosition + 5 && i < _friendNames.Length; ++i)
if (_socialPage != null)
{
int yPosition = Game1.activeClickableMenu.yPositionOnScreen + 130 + yOffset;
yOffset += 112;
Friendship friendshipValues;
String nextName = _friendNames[i];
if (Game1.player.friendshipData.TryGetValue(nextName, out friendshipValues))
int slotPosition = (int)typeof(SocialPage)
.GetField(
"slotPosition",
BindingFlags.Instance | BindingFlags.NonPublic)
.GetValue(_socialPage);
int yOffset = 0;
for (int i = slotPosition; i < slotPosition + 5 && i < _friendNames.Length; ++i)
{
int friendshipRawValue = friendshipValues.Points;
if (friendshipRawValue > 0)
int yPosition = Game1.activeClickableMenu.yPositionOnScreen + 130 + yOffset;
yOffset += 112;
Friendship friendshipValues;
String nextName = _friendNames[i];
if (Game1.player.friendshipData.TryGetValue(nextName, out friendshipValues))
{
int pointsToNextHeart = friendshipRawValue % 250;
int numHearts = friendshipRawValue / 250;
int friendshipRawValue = friendshipValues.Points;
if (friendshipRawValue < 3000 &&
_friendNames[i] == Game1.player.spouse ||
friendshipRawValue < 2500)
if (friendshipRawValue > 0)
{
DrawEachIndividualSquare(numHearts, pointsToNextHeart, yPosition);
//if (!Game1.options.hardwareCursor)
// Game1.spriteBatch.Draw(
// Game1.mouseCursors,
// new Vector2(Game1.getMouseX(), Game1.getMouseY()),
// Game1.getSourceRectForStandardTileSheet(
// Game1.mouseCursors, Game1.mouseCursor,
// 16,
// 16),
// Color.White,
// 0.0f,
// Vector2.Zero,
// Game1.pixelZoom + (float)(Game1.dialogueButtonScale / 150.0),
// SpriteEffects.None,
// 1f);
int pointsToNextHeart = friendshipRawValue % 250;
int numHearts = friendshipRawValue / 250;
if (friendshipRawValue < 3000 &&
_friendNames[i] == Game1.player.spouse ||
friendshipRawValue < 2500)
{
DrawEachIndividualSquare(numHearts, pointsToNextHeart, yPosition);
//if (!Game1.options.hardwareCursor)
// Game1.spriteBatch.Draw(
// Game1.mouseCursors,
// new Vector2(Game1.getMouseX(), Game1.getMouseY()),
// Game1.getSourceRectForStandardTileSheet(
// Game1.mouseCursors, Game1.mouseCursor,
// 16,
// 16),
// Color.White,
// 0.0f,
// Vector2.Zero,
// Game1.pixelZoom + (float)(Game1.dialogueButtonScale / 150.0),
// SpriteEffects.None,
// 1f);
}
}
}
}
}
String hoverText = typeof(GameMenu).GetField("hoverText", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(gameMenu) as String;
IClickableMenu.drawHoverText(
Game1.spriteBatch,
hoverText,
Game1.smallFont);
String hoverText = typeof(GameMenu).GetField("hoverText", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(gameMenu) as String;
IClickableMenu.drawHoverText(
Game1.spriteBatch,
hoverText,
Game1.smallFont);
}
else
{
OnMenuChange(sender, null);
}
}
}
}

View File

@ -16,11 +16,13 @@ namespace UIInfoSuite.UIElements
class ShowBirthdayIcon : IDisposable
{
private NPC _birthdayNPC;
private ClickableTextureComponent _birthdayIcon;
public void ToggleOption(bool showBirthdayIcon)
{
TimeEvents.AfterDayStarted -= CheckForBirthday;
GraphicsEvents.OnPreRenderHudEvent -= DrawBirthdayIcon;
GraphicsEvents.OnPostRenderHudEvent -= DrawHoverText;
GameEvents.HalfSecondTick -= CheckIfGiftHasBeenGiven;
if (showBirthdayIcon)
@ -28,6 +30,7 @@ namespace UIInfoSuite.UIElements
CheckForBirthday(null, null);
TimeEvents.AfterDayStarted += CheckForBirthday;
GraphicsEvents.OnPreRenderHudEvent += DrawBirthdayIcon;
GraphicsEvents.OnPostRenderHudEvent += DrawHoverText;
GameEvents.HalfSecondTick += CheckIfGiftHasBeenGiven;
}
}
@ -94,7 +97,7 @@ namespace UIInfoSuite.UIElements
SpriteEffects.None,
1f);
ClickableTextureComponent texture =
_birthdayIcon =
new ClickableTextureComponent(
_birthdayNPC.Name,
new Rectangle(
@ -108,18 +111,22 @@ namespace UIInfoSuite.UIElements
headShot,
2f);
texture.draw(Game1.spriteBatch);
if (texture.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
{
String hoverText = String.Format("{0}'s Birthday", _birthdayNPC.Name);
IClickableMenu.drawHoverText(
Game1.spriteBatch,
hoverText,
Game1.dialogueFont);
}
_birthdayIcon.draw(Game1.spriteBatch);
}
}
}
private void DrawHoverText(object sender, EventArgs e)
{
if (_birthdayNPC != null &&
_birthdayIcon.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
{
String hoverText = String.Format("{0}'s Birthday", _birthdayNPC.Name);
IClickableMenu.drawHoverText(
Game1.spriteBatch,
hoverText,
Game1.dialogueFont);
}
}
}
}

View File

@ -144,11 +144,12 @@ namespace UIInfoSuite.UIElements
{
if (_currentTile.bigCraftable.Value &&
_currentTile.MinutesUntilReady > 0 &&
_currentTile.heldObject.Value != null &&
_currentTile.Name != "Heater")
{
StringBuilder hoverText = new StringBuilder();
hoverText.AppendLine(_currentTile.heldObject.Value.DisplayName);
if (_currentTile is Cask)
{
Cask currentCask = _currentTile as Cask;

View File

@ -23,11 +23,13 @@ namespace UIInfoSuite.UIElements
private NPC _gus;
private bool _drawQueenOfSauceIcon = false;
private bool _drawDishOfDayIcon = false;
private ClickableTextureComponent _queenOfSauceIcon;
private readonly IModHelper _helper;
public void ToggleOption(bool showQueenOfSauceIcon)
{
GraphicsEvents.OnPreRenderHudEvent -= DrawIcon;
GraphicsEvents.OnPostRenderHudEvent -= DrawHoverText;
TimeEvents.AfterDayStarted -= CheckForNewRecipe;
GameEvents.OneSecondTick -= CheckIfLearnedRecipe;
@ -37,6 +39,7 @@ namespace UIInfoSuite.UIElements
CheckForNewRecipe(null, null);
TimeEvents.AfterDayStarted += CheckForNewRecipe;
GraphicsEvents.OnPreRenderHudEvent += DrawIcon;
GraphicsEvents.OnPostRenderHudEvent += DrawHoverText;
GameEvents.OneSecondTick += CheckIfLearnedRecipe;
}
}
@ -145,21 +148,12 @@ namespace UIInfoSuite.UIElements
{
Point iconPosition = IconHandler.Handler.GetNewIconPosition();
ClickableTextureComponent texture = new ClickableTextureComponent(
_queenOfSauceIcon = 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);
}
_queenOfSauceIcon.draw(Game1.spriteBatch);
}
if (_drawDishOfDayIcon)
@ -205,6 +199,19 @@ namespace UIInfoSuite.UIElements
}
}
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);
}
}
public void Dispose()
{
ToggleOption(false);

View File

@ -19,6 +19,7 @@ namespace UIInfoSuite.UIElements
private Rectangle _toolTexturePosition;
private String _hoverText;
private Tool _toolBeingUpgraded;
private ClickableTextureComponent _toolUpgradeIcon;
public ShowToolUpgradeStatus(IModHelper helper)
{
@ -28,6 +29,7 @@ namespace UIInfoSuite.UIElements
public void ToggleOption(bool showToolUpgradeStatus)
{
GraphicsEvents.OnPreRenderHudEvent -= DrawToolUpgradeStatus;
GraphicsEvents.OnPostRenderHudEvent -= DrawHoverText;
TimeEvents.AfterDayStarted -= DayChanged;
GameEvents.OneSecondTick -= CheckForMidDayChanges;
@ -35,6 +37,7 @@ namespace UIInfoSuite.UIElements
{
DayChanged(null, new EventArgsIntChanged(0, Game1.dayOfMonth));
GraphicsEvents.OnPreRenderHudEvent += DrawToolUpgradeStatus;
GraphicsEvents.OnPostRenderHudEvent += DrawHoverText;
TimeEvents.AfterDayStarted += DayChanged;
GameEvents.OneSecondTick += CheckForMidDayChanges;
}
@ -110,20 +113,24 @@ namespace UIInfoSuite.UIElements
_toolBeingUpgraded != null)
{
Point iconPosition = IconHandler.Handler.GetNewIconPosition();
ClickableTextureComponent textureComponent =
_toolUpgradeIcon =
new ClickableTextureComponent(
new Rectangle(iconPosition.X, iconPosition.Y, 40, 40),
Game1.toolSpriteSheet,
_toolTexturePosition,
2.5f);
textureComponent.draw(Game1.spriteBatch);
_toolUpgradeIcon.draw(Game1.spriteBatch);
}
}
if (textureComponent.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
{
IClickableMenu.drawHoverText(
private void DrawHoverText(object sender, EventArgs e)
{
if (_toolBeingUpgraded != null &&
_toolUpgradeIcon.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
{
IClickableMenu.drawHoverText(
Game1.spriteBatch,
_hoverText, Game1.dialogueFont);
}
}
}

View File

@ -17,21 +17,25 @@ namespace UIInfoSuite.UIElements
class ShowTravelingMerchant : IDisposable
{
private bool _travelingMerchantIsHere = false;
private ClickableTextureComponent _travelingMerchantIcon;
private readonly IModHelper _helper;
public void ToggleOption(bool showTravelingMerchant)
{
GraphicsEvents.OnPreRenderHudEvent -= DrawTravelingMerchant;
GraphicsEvents.OnPostRenderHudEvent -= DrawHoverText;
TimeEvents.AfterDayStarted -= DayChanged;
if (showTravelingMerchant)
{
DayChanged(null, new EventArgsIntChanged(0, Game1.dayOfMonth));
GraphicsEvents.OnPreRenderHudEvent += DrawTravelingMerchant;
GraphicsEvents.OnPostRenderHudEvent += DrawHoverText;
TimeEvents.AfterDayStarted += DayChanged;
}
}
public ShowTravelingMerchant(IModHelper helper)
{
_helper = helper;
@ -56,21 +60,26 @@ namespace UIInfoSuite.UIElements
_travelingMerchantIsHere)
{
Point iconPosition = IconHandler.Handler.GetNewIconPosition();
ClickableTextureComponent textureComponent =
_travelingMerchantIcon =
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);
}
_travelingMerchantIcon.draw(Game1.spriteBatch);
}
}
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);
}
}
}

View File

@ -1,10 +1,10 @@
{
"Name": "UI Info Suite",
"Author": "Cdaragorn",
"Version": "1.7.13",
"Version": "1.7.18",
"Description": "Adds a lot of useful information to the user interface. This is based on Demiacle's excellent UIModSuite.",
"UniqueID": "Cdaragorn.UiInfoSuite",
"EntryDll": "UIInfoSuite.dll",
"MinimumApiVersion" : "2.6-beta",
"MinimumApiVersion" : "2.6",
"UpdateKeys": [ "Nexus:1150" ]
}

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Pathoschild.Stardew.ModBuildConfig" version="2.1.0-beta-20180630" targetFramework="net45" />
<package id="Pathoschild.Stardew.ModBuildConfig" version="2.1.0" targetFramework="net45" />
</packages>