diff --git a/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs b/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs index 417182e..db847c2 100644 --- a/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs +++ b/RecrownedAthenaeum/UI/Modular/Modules/UIScrollable.cs @@ -31,12 +31,17 @@ namespace RecrownedAthenaeum.UI.Modular.Modules { get { - return -shiftX; + return (Width - horizontalScrollBarBounds.Width) * (-shiftX / (group.Width - viewport.Width)); } set { - shiftX = -value; + if (value > Width - verticalScrollBarBounds.Height) + { + value = Width - verticalScrollBarBounds.Height; + } + if (value < 0) value = 0; + shiftX = -(group.Width - viewport.Width) * (value / (Width - horizontalScrollBarBounds.Width)); WidthOrXChange(true); } } @@ -44,12 +49,17 @@ namespace RecrownedAthenaeum.UI.Modular.Modules { get { - return shiftY; + return (Height - verticalScrollBarBounds.Height) * (-shiftY / (group.Height - viewport.Height)); } set { - shiftY = value; + if (value > Height - verticalScrollBarBounds.Height) + { + value = Height - verticalScrollBarBounds.Height; + } + if (value < 0) value = 0; + shiftY = -(group.Height - viewport.Height) * (value/(Height - verticalScrollBarBounds.Height)); HeightOrYChange(true); } } @@ -203,12 +213,12 @@ namespace RecrownedAthenaeum.UI.Modular.Modules if (horScrollAvailable) { - horizontalScrollBarBounds.X = (int)(((float)-shiftX / group.Width) * (viewport.Width - horizontalScrollBarBounds.Width)); + horizontalScrollBarBounds.X = (int)XScrollPosition; } if (vertScrollAvailable) { - verticalScrollBarBounds.Y = (int)(((float)-shiftY / group.Height) * (viewport.Height - verticalScrollBarBounds.Height)); + verticalScrollBarBounds.Y = (int)YScrollPosition; } @@ -373,7 +383,7 @@ namespace RecrownedAthenaeum.UI.Modular.Modules { if (state.IsKeyDown(Keys.Right)) { - XScrollPosition += 20; + XScrollPosition += 1; } return base.KeyboardStateChanged(state); @@ -420,13 +430,13 @@ namespace RecrownedAthenaeum.UI.Modular.Modules { if (horizontalSelected) { - float latestPosition = state.X - mouseRelativePosition.X; - XScrollPosition = (latestPosition / (Width - horizontalScrollBarBounds.Width)) * group.Width; + float latestPosition = state.X - mouseRelativePosition.X - X; + XScrollPosition = latestPosition; } else { - float latestPosition = state.Y - mouseRelativePosition.Y; - YScrollPosition = -(latestPosition / (Height - verticalScrollBarBounds.Height)) * group.Height; + float latestPosition = state.Y - mouseRelativePosition.Y - Y; + YScrollPosition = latestPosition; } if (state.LeftButton == ButtonState.Released)