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) if (ninepatch != null)
{ {
ninepatch.Draw(batch, Color.White, destination); ninepatch.Draw(batch, color, destination);
} }
else else
{ {

View File

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