From b785ecae044d503d103d5df59b0fb0157a8fb079 Mon Sep 17 00:00:00 2001 From: cdaragorn Date: Sun, 6 Jan 2019 22:25:05 -0700 Subject: [PATCH] Fixed mouse disappearing in one case. Updated version info. --- SDVModTest/ModEntry.cs | 1 + SDVModTest/Properties/AssemblyInfo.cs | 4 +- SDVModTest/UIElements/ExperienceBar.cs | 43 +++++++++++++++++--- SDVModTest/UIElements/LocationOfTownsfolk.cs | 35 ++++++++-------- SDVModTest/manifest.json | 2 +- SDVModTest/packages.config | 4 ++ 6 files changed, 64 insertions(+), 25 deletions(-) create mode 100644 SDVModTest/packages.config diff --git a/SDVModTest/ModEntry.cs b/SDVModTest/ModEntry.cs index 1cd1867..78a2a03 100644 --- a/SDVModTest/ModEntry.cs +++ b/SDVModTest/ModEntry.cs @@ -79,6 +79,7 @@ namespace UIInfoSuite writer.WriteEndElement(); } writer.WriteEndElement(); + writer.Close(); } } } diff --git a/SDVModTest/Properties/AssemblyInfo.cs b/SDVModTest/Properties/AssemblyInfo.cs index f014f19..a2906b0 100644 --- a/SDVModTest/Properties/AssemblyInfo.cs +++ b/SDVModTest/Properties/AssemblyInfo.cs @@ -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.18.0")] -[assembly: AssemblyFileVersion("1.7.18.0")] +[assembly: AssemblyVersion("1.7.20.0")] +[assembly: AssemblyFileVersion("1.7.20.0")] diff --git a/SDVModTest/UIElements/ExperienceBar.cs b/SDVModTest/UIElements/ExperienceBar.cs index 5234b14..89cf5c0 100644 --- a/SDVModTest/UIElements/ExperienceBar.cs +++ b/SDVModTest/UIElements/ExperienceBar.cs @@ -28,6 +28,7 @@ namespace UIInfoSuite.UIElements private const int MaxBarWidth = 175; private int[] _currentExperience = new int[5]; + private int[] _currentLevelExtenderExperience = new int[5]; private readonly List _experiencePointDisplays = new List(); private readonly TimeSpan _levelUpPauseTime = TimeSpan.FromSeconds(2); private readonly Color _iconColor = Color.White; @@ -75,7 +76,7 @@ namespace UIInfoSuite.UIElements helper.Events.Display.RenderingHud += OnRenderingHud; helper.Events.Player.Warped += OnWarped_RemoveAllExperiencePointDisplays; - //var something = _helper.ModRegistry.GetApi("DevinLematty.LevelExtender"); + var something = _helper.ModRegistry.GetApi("DevinLematty.LevelExtender"); try { _levelExtenderAPI = _helper.ModRegistry.GetApi("DevinLematty.LevelExtender"); @@ -145,12 +146,19 @@ namespace UIInfoSuite.UIElements _currentExperience[i] = Game1.player.experiencePoints[i]; _showExperienceGain = showExperienceGain; + if (_levelExtenderAPI != null) + { + for (int i = 0; i < _currentLevelExtenderExperience.Length; ++i) + _currentLevelExtenderExperience[i] = _levelExtenderAPI.currentXP()[i]; + } + if (showExperienceGain) { _helper.Events.GameLoop.UpdateTicked += OnUpdateTicked_DetermineIfExperienceHasBeenGained; } } + public void ToggleShowExperienceBar(bool showExperienceBar) { _helper.Events.GameLoop.UpdateTicked -= OnUpdateTicked_DetermineIfExperienceHasBeenGained; @@ -241,9 +249,15 @@ namespace UIInfoSuite.UIElements int currentLevelIndex = -1; + int[] levelExtenderExperience = null; + if (_levelExtenderAPI != null) + levelExtenderExperience = _levelExtenderAPI.currentXP(); + for (int i = 0; i < _currentExperience.Length; ++i) { - if (_currentExperience[i] != Game1.player.experiencePoints[i]) + if (_currentExperience[i] != Game1.player.experiencePoints[i] || + (_levelExtenderAPI != null && + _currentLevelExtenderExperience[i] != levelExtenderExperience[i])) { currentLevelIndex = i; break; @@ -312,14 +326,31 @@ namespace UIInfoSuite.UIElements if (_showExperienceGain && _experienceRequiredToLevel > 0) { - _experiencePointDisplays.Add( - new ExperiencePointDisplay( - Game1.player.experiencePoints[currentLevelIndex] - _currentExperience[currentLevelIndex], - Game1.player.getLocalPosition(Game1.viewport))); + int currentExperienceToUse = Game1.player.experiencePoints[currentLevelIndex]; + int previousExperienceToUse = _currentExperience[currentLevelIndex]; + if (_levelExtenderAPI != null && + _currentSkillLevel > 9) + { + currentExperienceToUse = _levelExtenderAPI.currentXP()[currentLevelIndex]; + previousExperienceToUse = _currentLevelExtenderExperience[currentLevelIndex]; + } + + int experienceGain = currentExperienceToUse - previousExperienceToUse; + + if (experienceGain > 0) + { + _experiencePointDisplays.Add( + new ExperiencePointDisplay( + experienceGain, + Game1.player.getLocalPosition(Game1.viewport))); + } } _currentExperience[currentLevelIndex] = Game1.player.experiencePoints[currentLevelIndex]; + if (_levelExtenderAPI != null) + _currentLevelExtenderExperience[currentLevelIndex] = _levelExtenderAPI.currentXP()[currentLevelIndex]; + } else if (_previousItem != currentItem) { diff --git a/SDVModTest/UIElements/LocationOfTownsfolk.cs b/SDVModTest/UIElements/LocationOfTownsfolk.cs index f9df1e3..69eacfa 100644 --- a/SDVModTest/UIElements/LocationOfTownsfolk.cs +++ b/SDVModTest/UIElements/LocationOfTownsfolk.cs @@ -495,22 +495,25 @@ namespace UIInfoSuite.UIElements 4), Color.BurlyWood); } - //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 + (Game1.dialogueButtonScale / 150.0f), - // SpriteEffects.None, - // 1f); + 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 + (Game1.dialogueButtonScale / 150.0f), + SpriteEffects.None, + 1f); + } if (checkbox.bounds.Contains(Game1.getMouseX(), Game1.getMouseY())) IClickableMenu.drawHoverText( diff --git a/SDVModTest/manifest.json b/SDVModTest/manifest.json index 2d3177a..a514cb2 100644 --- a/SDVModTest/manifest.json +++ b/SDVModTest/manifest.json @@ -1,7 +1,7 @@ { "Name": "UI Info Suite", "Author": "Cdaragorn", - "Version": "1.7.18", + "Version": "1.7.20", "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", diff --git a/SDVModTest/packages.config b/SDVModTest/packages.config new file mode 100644 index 0000000..1402bc4 --- /dev/null +++ b/SDVModTest/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file