Skip to content

Commit

Permalink
Fix InventoryIcons rendering over mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
JLannoo committed Apr 21, 2024
1 parent 08df421 commit d76a692
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
12 changes: 1 addition & 11 deletions HaveIDonated/Hover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public Hover(IModHelper helper, List<BundleData> bundleData) {
_bundles = bundleData;

_helper.Events.Display.RenderingHud += OnRendering;
_helper.Events.Display.RenderedHud += OnRendered;
_helper.Events.Display.RenderedActiveMenu += OnRenderedActiveMenu;
_helper.Events.Input.ButtonPressed += OnButtonPressed;
}
Expand Down Expand Up @@ -77,15 +76,7 @@ private void OnButtonPressed(object? sender, ButtonPressedEventArgs e) {
}

private void OnRenderedActiveMenu(object? sender, RenderedActiveMenuEventArgs e) {
if (Game1.activeClickableMenu != null) {
Draw(Game1.spriteBatch);
}
}

private void OnRendered(object? sender, RenderedHudEventArgs e) {
if (Game1.activeClickableMenu == null) {
Draw(Game1.spriteBatch);
}
Draw(Game1.spriteBatch);
}

private void OnRendering(object? sender, RenderingHudEventArgs e) {
Expand All @@ -95,7 +86,6 @@ private void OnRendering(object? sender, RenderingHudEventArgs e) {

public void Dispose() {
_helper.Events.Display.RenderingHud -= OnRendering;
_helper.Events.Display.RenderedHud -= OnRendered;
_helper.Events.Display.RenderedActiveMenu -= OnRenderedActiveMenu;
_helper.Events.Input.ButtonPressed -= OnButtonPressed;

Expand Down
6 changes: 5 additions & 1 deletion HaveIDonated/InventoryIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ private void Draw(SpriteBatch spriteBatch) {
}
}
}

if(Game1.activeClickableMenu is IClickableMenu menu) {
menu.drawMouse(spriteBatch);

}
}

private List<(Item, ClickableComponent)> GetItemsBeingDrawn() {
Expand Down Expand Up @@ -209,7 +214,6 @@ private static List<Bundle> GetBundlesBeingDraw() {
foreach (var bundle in menu.bundles) {
items.Add(bundle);
}

}

return items;
Expand Down
4 changes: 2 additions & 2 deletions HaveIDonated/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ private void OnInventoryChanged(object? sender, InventoryChangedEventArgs e) {

#region Methods
private void RestartModFunctions() {
hover?.Dispose();
inventoryIcons?.Dispose();
hover?.Dispose();

List<BundleData> bundleData = Utils.GetBundleData();

hover = new Hover(_helper, bundleData);
inventoryIcons = new InventoryIcons(_helper, bundleData);
hover = new Hover(_helper, bundleData);

}
#endregion
Expand Down
4 changes: 1 addition & 3 deletions HaveIDonated/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ public static void DrawTooltip(SpriteBatch spriteBatch, List<Line> lines) {
);
}

// Draw text
spriteBatch.DrawString(Game1.smallFont, line.text, textPosition + new Vector2(2, 2), Game1.textShadowColor);
spriteBatch.DrawString(Game1.smallFont, line.text, textPosition, Game1.textColor);
Utility.drawTextWithShadow(spriteBatch, line.text, Game1.smallFont, textPosition, Game1.textColor);
}
}

Expand Down

0 comments on commit d76a692

Please sign in to comment.