Skip to content

Commit

Permalink
Game Menu: Implemented an upper page scroll limit
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Dec 31, 2011
1 parent 34171bc commit 3845d15
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions doomsday/plugins/common/src/hu_lib.c
Expand Up @@ -946,15 +946,27 @@ void MN_DrawPage(mn_page_t* page, float alpha, boolean showFocusCursor)
DGL_Translatef(page->origin.x, page->origin.y, 0);

// Apply page scroll?
if(focusObj && Rect_Height(page->geometry) > SCREENHEIGHT)
if(focusObj)
{
RectRaw geometry;
const int minY = -page->origin.y + SCREENHEIGHT/2;
Rect_Raw(page->geometry, &geometry);
RectRaw pageGeometry, viewRegion;
Rect_Raw(page->geometry, &pageGeometry);

// Determine available screen region for the page.
viewRegion.origin.x = 0;
viewRegion.origin.y = page->origin.y;
viewRegion.size.width = SCREENWIDTH;
viewRegion.size.height = SCREENHEIGHT - 40/*arbitrary but enough for the help message*/;

if(cursorOrigin.y > minY)
// Is scrolling in effect?
if(pageGeometry.size.height > viewRegion.size.height)
{
DGL_Translatef(0, -(cursorOrigin.y - minY), 0);
const int minY = -viewRegion.origin.y/2 + viewRegion.size.height/2;
if(cursorOrigin.y > minY)
{
const int scrollLimitY = pageGeometry.size.height - viewRegion.size.height/2;
const int scrollOriginY = MIN_OF(cursorOrigin.y, scrollLimitY) - minY;
DGL_Translatef(0, -scrollOriginY, 0);
}
}
}

Expand Down

0 comments on commit 3845d15

Please sign in to comment.