Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions UIInfoSuite2/UIElements/ExperienceBar.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Enums;
using StardewModdingAPI.Events;
using StardewModdingAPI.Utilities;
using StardewValley;
using StardewValley.Tools;
using StardewValley.Menus;
using UIInfoSuite2.Compatibility;
using UIInfoSuite2.Infrastructure;
using UIInfoSuite2.Infrastructure.Extensions;
Expand All @@ -18,6 +19,7 @@ public partial class ExperienceBar
#region Properties
private readonly PerScreen<Item> _previousItem = new();
private readonly PerScreen<int[]> _currentExperience = new(() => new int[5]);
private readonly PerScreen<int> _currentMasteryXP = new(() => 0);
private readonly PerScreen<int[]> _currentLevelExtenderExperience = new(() => new int[5]);
private readonly PerScreen<int> _currentSkillLevel = new(() => 0);
private readonly PerScreen<int> _experienceRequiredToLevel = new(() => -1);
Expand Down Expand Up @@ -61,6 +63,7 @@ public partial class ExperienceBar

private readonly PerScreen<Rectangle> _levelUpIconRectangle = new(() => SkillIconRectangles[SkillType.Farming]);
private readonly PerScreen<Color> _experienceFillColor = new(() => ExperienceFillColor[SkillType.Farming]);
private readonly PerScreen<Color> _experienceTextColor = new(() => Color.Black);

private bool ExperienceBarFadeoutEnabled { get; set; } = true;
private bool ExperienceGainTextEnabled { get; set; } = true;
Expand Down Expand Up @@ -244,6 +247,7 @@ private void OnRenderingHud(object sender, RenderingHudEventArgs e)
{
_displayedExperienceBar.Value.Draw(
_experienceFillColor.Value,
_experienceTextColor.Value,
_experienceIconRectangle.Value,
_experienceEarnedThisLevel.Value,
_experienceRequiredToLevel.Value - _experienceFromPreviousLevels.Value,
Expand All @@ -261,7 +265,12 @@ private void InitializeExperiencePoints()
_currentExperience.Value[i] = Game1.player.experiencePoints[i];
}

if (_levelExtenderApi != null)
if (Game1.player.Level >= 25)
{
_currentMasteryXP.Value = (int)Game1.stats.Get("MasteryExp");
}

if (_levelExtenderApi != null)
{
for (var i = 0; i < _currentLevelExtenderExperience.Value.Length; ++i)
{
Expand Down Expand Up @@ -307,10 +316,24 @@ private void UpdateExperience(int currentLevelIndex, bool displayExperience)
_experienceFillColor.Value = ExperienceFillColor[(SkillType)currentLevelIndex];
_currentSkillLevel.Value = Game1.player.GetUnmodifiedSkillLevel(currentLevelIndex);

_experienceRequiredToLevel.Value = GetExperienceRequiredToLevel(_currentSkillLevel.Value);
_experienceFromPreviousLevels.Value = GetExperienceRequiredToLevel(_currentSkillLevel.Value - 1);
_experienceEarnedThisLevel.Value =
Game1.player.experiencePoints[currentLevelIndex] - _experienceFromPreviousLevels.Value;

if (Game1.player.Level >= 25 && (MasteryTrackerMenu.getCurrentMasteryLevel() < 5))
{
_experienceRequiredToLevel.Value = MasteryTrackerMenu.getMasteryExpNeededForLevel(MasteryTrackerMenu.getCurrentMasteryLevel() + 1);
_experienceFromPreviousLevels.Value = MasteryTrackerMenu.getMasteryExpNeededForLevel(MasteryTrackerMenu.getCurrentMasteryLevel());
_experienceEarnedThisLevel.Value = (int)Game1.stats.Get("MasteryExp") - MasteryTrackerMenu.getMasteryExpNeededForLevel(MasteryTrackerMenu.getCurrentMasteryLevel());
_currentMasteryXP.Value = (int)Game1.stats.Get("MasteryExp");

_experienceFillColor.Value = new Color(0, 0.443f, 0.243f , 1.0f);
_experienceTextColor.Value = Color.White;
_experienceIconRectangle.Value = SkillIconRectangles[SkillType.Luck];
}
else
{
_experienceRequiredToLevel.Value = GetExperienceRequiredToLevel(_currentSkillLevel.Value);
_experienceFromPreviousLevels.Value = GetExperienceRequiredToLevel(_currentSkillLevel.Value - 1);
_experienceEarnedThisLevel.Value = Game1.player.experiencePoints[currentLevelIndex] - _experienceFromPreviousLevels.Value;
}

if (_experienceRequiredToLevel.Value <= 0 && _levelExtenderApi != null)
{
Expand Down Expand Up @@ -369,5 +392,5 @@ private static int GetExperienceRequiredToLevel(int currentLevel)
_ => -1
};
}
#endregion Logic
#endregion Logic
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ namespace UIInfoSuite2.UIElements.ExperienceElements;

public class DisplayedExperienceBar
{
private const int MaxBarWidth = 175;
private const int MaxBarWidth = 235;

public void Draw(
Color experienceFillColor,
Color textColor,
Rectangle experienceIconPosition,
int experienceEarnedThisLevel,
int experienceDifferenceBetweenLevels,
Expand All @@ -24,7 +25,7 @@ int currentLevel
Game1.drawDialogueBox(
(int)leftSide,
Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 160,
240,
300,
160,
false,
true
Expand Down Expand Up @@ -59,34 +60,57 @@ int currentLevel
experienceFillColor
);

if (IsMouseOverExperienceBar(leftSide))
if (IsMouseOverExperienceBar(leftSide))
{
Game1.drawWithBorder(
experienceEarnedThisLevel + "/" + experienceDifferenceBetweenLevels,
Color.Black,
Color.Black,
textColor,
textColor,
new Vector2(leftSide + 33, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 70)
);
}
else
{
Game1.spriteBatch.Draw(
Game1.mouseCursors,
new Vector2(leftSide + 54, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 62),
experienceIconPosition,
Color.White,
0,
Vector2.Zero,
2.9f,
SpriteEffects.None,
0.85f
);
String levelNumber = "";
int masteryMargin = 0;
if (Game1.player.Level < 25)
{
Game1.spriteBatch.Draw(
Game1.mouseCursors,
new Vector2(leftSide + 54, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 62),
experienceIconPosition,
Color.White,
0,
Vector2.Zero,
2.9f,
SpriteEffects.None,
0.85f
);
levelNumber = currentLevel.ToString();
}
else
{
Game1.spriteBatch.Draw(
Game1.mouseCursors_1_6,
new Vector2(leftSide + 38, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 62),
new Rectangle(458,299,10,10),
Color.White,
0,
Vector2.Zero,
2.9f,
SpriteEffects.None,
0.85f
);

levelNumber = MasteryTrackerMenu.getCurrentMasteryLevel().ToString();
masteryMargin = 37;
}

Game1.drawWithBorder(
currentLevel.ToString(),
Color.Black * 0.6f,
Color.Black,
new Vector2(leftSide + 33, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 70)
levelNumber,
textColor * 0.6f,
textColor,
new Vector2(leftSide + 33 + masteryMargin, Game1.graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - 70)
);
}
}
Expand Down