Working 1.4 upgrade

This commit is contained in:
Jewel
2022-08-02 05:44:07 +01:00
parent e4b625d459
commit 8c17c38585
21 changed files with 1291 additions and 552 deletions

View File

@@ -1,9 +1,12 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ItemChecklist.UIElements;
using System;
using System.Collections.Generic;
using ReLogic.Content;
using Terraria;
using Terraria.UI;
using Terraria.GameInput;
namespace ItemChecklist.UIElements
{
@@ -40,8 +43,8 @@ namespace ItemChecklist.UIElements
private float _innerListWidth;
public float ListPadding = 5f;
public static Texture2D moreLeftTexture;
public static Texture2D moreRightTexture;
public static Asset<Texture2D> moreLeftTexture;
public static Asset<Texture2D> moreRightTexture;
public int Count
{
@@ -203,6 +206,8 @@ namespace ItemChecklist.UIElements
{
this._innerList.Left.Set(-this._scrollbar.GetValue(), 0f);
}
if(IsMouseHovering)
PlayerInput.LockVanillaMouseScroll("RecipeBrowser/UIHorizontalGrid");
this.Recalculate();
}
@@ -215,11 +220,13 @@ namespace ItemChecklist.UIElements
var inner = GetInnerDimensions().ToRectangle();
if (this._scrollbar.ViewPosition != 0)
{
spriteBatch.Draw(moreLeftTexture, new Vector2(inner.X, inner.Y), Color.White * .5f);
int centeredY = inner.Y + inner.Height / 2 - moreLeftTexture.Height() / 2;
spriteBatch.Draw(moreLeftTexture.Value, new Vector2(inner.X, centeredY), Color.White * .5f);
}
if (this._scrollbar.ViewPosition < _innerListWidth - inner.Width)
if (this._scrollbar.ViewPosition < _innerListWidth - inner.Width - 1) // -1 due to odd width leading to 0.5 view position offset.
{
spriteBatch.Draw(moreRightTexture, new Vector2(inner.Right - moreRightTexture.Width, inner.Y), Color.White * .5f);
int centeredY = inner.Y + inner.Height / 2 - moreRightTexture.Height() / 2;
spriteBatch.Draw(moreRightTexture.Value, new Vector2(inner.Right - moreRightTexture.Width(), centeredY), Color.White * .5f);
}
}
}