Fading now works.

This commit is contained in:
Harrison Deng 2019-04-15 20:25:36 -05:00
parent 4bb5c4ce95
commit 53000e6a6c
3 changed files with 33 additions and 14 deletions

View File

@ -174,7 +174,7 @@ namespace RecrownedAthenaeum.SpecialTypes
if (ninepatch != null)
{
ninepatch.Draw(batch, Color.White, destination);
ninepatch.Draw(batch, color, destination);
}
else
{

View File

@ -17,7 +17,8 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
{
UIModuleGroup group;
float opacityOfBar;
Color scrollBarColor;
float opacityOfBar = 1;
bool showingBars;
int shiftX, shiftY;
int furthestX;
@ -30,7 +31,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
/// <summary>
/// How fast the bars fade away in opacity (0 to 254) per second.
/// </summary>
public float barFadeSpeed;
public float barFadeSpeed = 250;
ISpecialDrawable horizontalScrollBar, verticalScrollBar;
ISpecialDrawable background, horizontalBarTrack, verticalBarTrack;
@ -58,8 +59,12 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
set
{
hideScrollBars = value;
WidthOrXChange();
HeightOrYChange();
WidthOrXChange(true);
HeightOrYChange(true);
if (!value)
{
opacityOfBar = 1f;
}
}
}
@ -151,9 +156,10 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
{
if (!showingBars)
{
if (opacityOfBar <= 0)
if (opacityOfBar > 0f)
{
opacityOfBar -= (barFadeSpeed / 255f) * gameTime.ElapsedGameTime.Seconds;
opacityOfBar -= (barFadeSpeed / 255f) * (float)gameTime.ElapsedGameTime.TotalSeconds;
scrollBarColor = color * opacityOfBar;
}
}
else
@ -183,11 +189,11 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
if (horScrollAvailable)
{
horizontalScrollBar.Draw(spriteBatch, horizontalScrollBarBounds, color);
horizontalScrollBar.Draw(spriteBatch, horizontalScrollBarBounds, scrollBarColor);
}
if (vertScrollAvailable)
{
horizontalScrollBar.Draw(spriteBatch, verticalScrollBarBounds, color);
horizontalScrollBar.Draw(spriteBatch, verticalScrollBarBounds, scrollBarColor);
}
base.Draw(spriteBatch);
}
@ -269,15 +275,21 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
}
else { horScrollAvailable = false; }
verticalScrollBarBounds.X = X;
if (!hideScrollBars)
{
verticalScrollBarBounds.X = X;
group.Width -= VerticalBarThickness;
if (!verticalBarLeftPosition)
{
verticalScrollBarBounds.X += group.Width;
}
group.Width -= VerticalBarThickness;
}
else
{
if (!verticalBarLeftPosition)
{
verticalScrollBarBounds.X += group.Width - verticalScrollBarBounds.Width;
}
}
}
}
@ -296,9 +308,9 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
}
else { vertScrollAvailable = false; }
horizontalScrollBarBounds.Y = Y;
if (!hideScrollBars)
{
horizontalScrollBarBounds.Y = Y;
group.Height -= HorizontalBarThickness;
if (!horizontalBarTopPosition)
{
@ -309,6 +321,13 @@ namespace RecrownedAthenaeum.UI.Modular.Modules
group.Y += horizontalScrollBarBounds.Height;
}
}
else
{
if (!horizontalBarTopPosition)
{
horizontalScrollBarBounds.Y += group.Height - horizontalScrollBarBounds.Height;
}
}
}
}

View File

@ -63,7 +63,7 @@ namespace TestGame
uIScrollable = new UIScrollable(skin);
uIScrollable.Width = 256;
uIScrollable.Height = 256;
uIScrollable.HideScrollBars = false;
uIScrollable.HideScrollBars = true;
logoImage = new Image(logo);
uIScrollable.AddModules(logoImage);