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 public class ModEntry : Mod
{ {
private readonly SkipIntro _skipIntro = new SkipIntro(); private readonly SkipIntro _skipIntro = new SkipIntro();
private String _modDataFileName; private String _modDataFileName;
@ -38,6 +37,11 @@ namespace UIInfoSuite
} }
~ModEntry()
{
}
public override void Entry(IModHelper helper) public override void Entry(IModHelper helper)
{ {
//Helper = helper; //Helper = helper;
@ -70,7 +74,7 @@ namespace UIInfoSuite
private void ReturnToTitle(object sender, EventArgs e) private void ReturnToTitle(object sender, EventArgs e)
{ {
_modOptionsPageHandler.Dispose(); _modOptionsPageHandler?.Dispose();
_modOptionsPageHandler = null; _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 // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.13.0")] [assembly: AssemblyVersion("1.7.18.0")]
[assembly: AssemblyFileVersion("1.7.13.0")] [assembly: AssemblyFileVersion("1.7.18.0")]

View File

@ -71,6 +71,8 @@
<Compile Include="Extensions\CollectionExtensions.cs" /> <Compile Include="Extensions\CollectionExtensions.cs" />
<Compile Include="Extensions\ObjectExtensions.cs" /> <Compile Include="Extensions\ObjectExtensions.cs" />
<Compile Include="LanguageKeys.cs" /> <Compile Include="LanguageKeys.cs" />
<Compile Include="LEEvents.cs" />
<Compile Include="LevelExtenderInterface.cs" />
<Compile Include="ModConfig.cs" /> <Compile Include="ModConfig.cs" />
<Compile Include="Options\ModOptionsCheckbox.cs" /> <Compile Include="Options\ModOptionsCheckbox.cs" />
<Compile Include="Options\ModOptionsPageButton.cs" /> <Compile Include="Options\ModOptionsPageButton.cs" />
@ -151,7 +153,7 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<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> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild"> <Target Name="AfterBuild">
@ -163,11 +165,11 @@
<Copy SourceFiles="$(TargetDir)\$(TargetName).dll.mdb" DestinationFolder="$(ModPath)" Condition="Exists('$(TargetDir)\$(TargetName).dll.mdb')" /> <Copy SourceFiles="$(TargetDir)\$(TargetName).dll.mdb" DestinationFolder="$(ModPath)" Condition="Exists('$(TargetDir)\$(TargetName).dll.mdb')" />
<Copy SourceFiles="$(ProjectDir)manifest.json" DestinationFolder="$(ModPath)" /> <Copy SourceFiles="$(ProjectDir)manifest.json" DestinationFolder="$(ModPath)" />
</Target> </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"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <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> <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> </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> </Target>
</Project> </Project>

View File

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

View File

@ -49,6 +49,8 @@ namespace UIInfoSuite.UIElements
GameMenu gameMenu = Game1.activeClickableMenu as GameMenu; GameMenu gameMenu = Game1.activeClickableMenu as GameMenu;
if (gameMenu.currentTab == 2) if (gameMenu.currentTab == 2)
{
if (_socialPage != null)
{ {
int slotPosition = (int)typeof(SocialPage) int slotPosition = (int)typeof(SocialPage)
.GetField( .GetField(
@ -102,6 +104,11 @@ namespace UIInfoSuite.UIElements
hoverText, hoverText,
Game1.smallFont); Game1.smallFont);
} }
else
{
OnMenuChange(sender, null);
}
}
} }
} }

View File

@ -16,11 +16,13 @@ namespace UIInfoSuite.UIElements
class ShowBirthdayIcon : IDisposable class ShowBirthdayIcon : IDisposable
{ {
private NPC _birthdayNPC; private NPC _birthdayNPC;
private ClickableTextureComponent _birthdayIcon;
public void ToggleOption(bool showBirthdayIcon) public void ToggleOption(bool showBirthdayIcon)
{ {
TimeEvents.AfterDayStarted -= CheckForBirthday; TimeEvents.AfterDayStarted -= CheckForBirthday;
GraphicsEvents.OnPreRenderHudEvent -= DrawBirthdayIcon; GraphicsEvents.OnPreRenderHudEvent -= DrawBirthdayIcon;
GraphicsEvents.OnPostRenderHudEvent -= DrawHoverText;
GameEvents.HalfSecondTick -= CheckIfGiftHasBeenGiven; GameEvents.HalfSecondTick -= CheckIfGiftHasBeenGiven;
if (showBirthdayIcon) if (showBirthdayIcon)
@ -28,6 +30,7 @@ namespace UIInfoSuite.UIElements
CheckForBirthday(null, null); CheckForBirthday(null, null);
TimeEvents.AfterDayStarted += CheckForBirthday; TimeEvents.AfterDayStarted += CheckForBirthday;
GraphicsEvents.OnPreRenderHudEvent += DrawBirthdayIcon; GraphicsEvents.OnPreRenderHudEvent += DrawBirthdayIcon;
GraphicsEvents.OnPostRenderHudEvent += DrawHoverText;
GameEvents.HalfSecondTick += CheckIfGiftHasBeenGiven; GameEvents.HalfSecondTick += CheckIfGiftHasBeenGiven;
} }
} }
@ -94,7 +97,7 @@ namespace UIInfoSuite.UIElements
SpriteEffects.None, SpriteEffects.None,
1f); 1f);
ClickableTextureComponent texture = _birthdayIcon =
new ClickableTextureComponent( new ClickableTextureComponent(
_birthdayNPC.Name, _birthdayNPC.Name,
new Rectangle( new Rectangle(
@ -108,9 +111,15 @@ namespace UIInfoSuite.UIElements
headShot, headShot,
2f); 2f);
texture.draw(Game1.spriteBatch); _birthdayIcon.draw(Game1.spriteBatch);
}
}
}
if (texture.containsPoint(Game1.getMouseX(), Game1.getMouseY())) 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); String hoverText = String.Format("{0}'s Birthday", _birthdayNPC.Name);
IClickableMenu.drawHoverText( IClickableMenu.drawHoverText(
@ -120,6 +129,4 @@ namespace UIInfoSuite.UIElements
} }
} }
} }
}
}
} }

View File

@ -144,6 +144,7 @@ namespace UIInfoSuite.UIElements
{ {
if (_currentTile.bigCraftable.Value && if (_currentTile.bigCraftable.Value &&
_currentTile.MinutesUntilReady > 0 && _currentTile.MinutesUntilReady > 0 &&
_currentTile.heldObject.Value != null &&
_currentTile.Name != "Heater") _currentTile.Name != "Heater")
{ {
StringBuilder hoverText = new StringBuilder(); StringBuilder hoverText = new StringBuilder();

View File

@ -23,11 +23,13 @@ namespace UIInfoSuite.UIElements
private NPC _gus; private NPC _gus;
private bool _drawQueenOfSauceIcon = false; private bool _drawQueenOfSauceIcon = false;
private bool _drawDishOfDayIcon = false; private bool _drawDishOfDayIcon = false;
private ClickableTextureComponent _queenOfSauceIcon;
private readonly IModHelper _helper; private readonly IModHelper _helper;
public void ToggleOption(bool showQueenOfSauceIcon) public void ToggleOption(bool showQueenOfSauceIcon)
{ {
GraphicsEvents.OnPreRenderHudEvent -= DrawIcon; GraphicsEvents.OnPreRenderHudEvent -= DrawIcon;
GraphicsEvents.OnPostRenderHudEvent -= DrawHoverText;
TimeEvents.AfterDayStarted -= CheckForNewRecipe; TimeEvents.AfterDayStarted -= CheckForNewRecipe;
GameEvents.OneSecondTick -= CheckIfLearnedRecipe; GameEvents.OneSecondTick -= CheckIfLearnedRecipe;
@ -37,6 +39,7 @@ namespace UIInfoSuite.UIElements
CheckForNewRecipe(null, null); CheckForNewRecipe(null, null);
TimeEvents.AfterDayStarted += CheckForNewRecipe; TimeEvents.AfterDayStarted += CheckForNewRecipe;
GraphicsEvents.OnPreRenderHudEvent += DrawIcon; GraphicsEvents.OnPreRenderHudEvent += DrawIcon;
GraphicsEvents.OnPostRenderHudEvent += DrawHoverText;
GameEvents.OneSecondTick += CheckIfLearnedRecipe; GameEvents.OneSecondTick += CheckIfLearnedRecipe;
} }
} }
@ -145,21 +148,12 @@ namespace UIInfoSuite.UIElements
{ {
Point iconPosition = IconHandler.Handler.GetNewIconPosition(); Point iconPosition = IconHandler.Handler.GetNewIconPosition();
ClickableTextureComponent texture = new ClickableTextureComponent( _queenOfSauceIcon = new ClickableTextureComponent(
new Rectangle(iconPosition.X, iconPosition.Y, 40, 40), new Rectangle(iconPosition.X, iconPosition.Y, 40, 40),
Game1.mouseCursors, Game1.mouseCursors,
new Rectangle(609, 361, 28, 28), new Rectangle(609, 361, 28, 28),
1.3f); 1.3f);
texture.draw(Game1.spriteBatch); _queenOfSauceIcon.draw(Game1.spriteBatch);
if (texture.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
{
IClickableMenu.drawHoverText(
Game1.spriteBatch,
_helper.SafeGetString(
LanguageKeys.TodaysRecipe)+ _todaysRecipe,
Game1.dialogueFont);
}
} }
if (_drawDishOfDayIcon) 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() public void Dispose()
{ {
ToggleOption(false); ToggleOption(false);

View File

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

View File

@ -17,21 +17,25 @@ namespace UIInfoSuite.UIElements
class ShowTravelingMerchant : IDisposable class ShowTravelingMerchant : IDisposable
{ {
private bool _travelingMerchantIsHere = false; private bool _travelingMerchantIsHere = false;
private ClickableTextureComponent _travelingMerchantIcon;
private readonly IModHelper _helper; private readonly IModHelper _helper;
public void ToggleOption(bool showTravelingMerchant) public void ToggleOption(bool showTravelingMerchant)
{ {
GraphicsEvents.OnPreRenderHudEvent -= DrawTravelingMerchant; GraphicsEvents.OnPreRenderHudEvent -= DrawTravelingMerchant;
GraphicsEvents.OnPostRenderHudEvent -= DrawHoverText;
TimeEvents.AfterDayStarted -= DayChanged; TimeEvents.AfterDayStarted -= DayChanged;
if (showTravelingMerchant) if (showTravelingMerchant)
{ {
DayChanged(null, new EventArgsIntChanged(0, Game1.dayOfMonth)); DayChanged(null, new EventArgsIntChanged(0, Game1.dayOfMonth));
GraphicsEvents.OnPreRenderHudEvent += DrawTravelingMerchant; GraphicsEvents.OnPreRenderHudEvent += DrawTravelingMerchant;
GraphicsEvents.OnPostRenderHudEvent += DrawHoverText;
TimeEvents.AfterDayStarted += DayChanged; TimeEvents.AfterDayStarted += DayChanged;
} }
} }
public ShowTravelingMerchant(IModHelper helper) public ShowTravelingMerchant(IModHelper helper)
{ {
_helper = helper; _helper = helper;
@ -56,14 +60,20 @@ namespace UIInfoSuite.UIElements
_travelingMerchantIsHere) _travelingMerchantIsHere)
{ {
Point iconPosition = IconHandler.Handler.GetNewIconPosition(); Point iconPosition = IconHandler.Handler.GetNewIconPosition();
ClickableTextureComponent textureComponent = _travelingMerchantIcon =
new ClickableTextureComponent( new ClickableTextureComponent(
new Rectangle(iconPosition.X, iconPosition.Y, 40, 40), new Rectangle(iconPosition.X, iconPosition.Y, 40, 40),
Game1.mouseCursors, Game1.mouseCursors,
new Rectangle(192, 1411, 20, 20), new Rectangle(192, 1411, 20, 20),
2f); 2f);
textureComponent.draw(Game1.spriteBatch); _travelingMerchantIcon.draw(Game1.spriteBatch);
if (textureComponent.containsPoint(Game1.getMouseX(), Game1.getMouseY())) }
}
private void DrawHoverText(object sender, EventArgs e)
{
if (_travelingMerchantIsHere &&
_travelingMerchantIcon.containsPoint(Game1.getMouseX(), Game1.getMouseY()))
{ {
string hoverText = _helper.SafeGetString( string hoverText = _helper.SafeGetString(
LanguageKeys.TravelingMerchantIsInTown); LanguageKeys.TravelingMerchantIsInTown);
@ -73,5 +83,4 @@ namespace UIInfoSuite.UIElements
} }
} }
} }
}
} }

View File

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

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <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> </packages>