Skip to content

Commit

Permalink
Game Menu: Crude but functional page scrolling
Browse files Browse the repository at this point in the history
Todo: Finesse!
  • Loading branch information
danij-deng committed Dec 31, 2011
1 parent 0fcb815 commit 793bbcb
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions doomsday/plugins/common/src/hu_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,8 +942,23 @@ void MN_DrawPage(mn_page_t* page, float alpha, boolean showFocusCursor)
}

DGL_MatrixMode(DGL_MODELVIEW);
DGL_PushMatrix();
DGL_Translatef(page->origin.x, page->origin.y, 0);

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

if(cursorOrigin.y > minY)
{
DGL_Translatef(0, -(cursorOrigin.y - minY), 0);
}
}

// Draw child objects.
for(i = 0; i < page->objectsCount; ++i)
{
mn_object_t* obj = &page->objects[i];
Expand All @@ -959,8 +974,15 @@ void MN_DrawPage(mn_page_t* page, float alpha, boolean showFocusCursor)
FR_PopAttrib();
}

// Finally, the focus cursor?
/// \todo cursor should be drawn on top of the page drawer.
if(showFocusCursor && focusObj)
{
Hu_MenuDrawFocusCursor(cursorOrigin.x, cursorOrigin.y, focusObjHeight, alpha);
}

DGL_MatrixMode(DGL_MODELVIEW);
DGL_Translatef(-page->origin.x, -page->origin.y, 0);
DGL_PopMatrix();

// The page has its own drawer.
if(page->drawer)
Expand All @@ -969,18 +991,6 @@ void MN_DrawPage(mn_page_t* page, float alpha, boolean showFocusCursor)
page->drawer(page, &page->origin);
FR_PopAttrib();
}

// Finally, the focus cursor?
if(showFocusCursor && focusObj)
{
DGL_MatrixMode(DGL_MODELVIEW);
DGL_Translatef(page->origin.x, page->origin.y, 0);

Hu_MenuDrawFocusCursor(cursorOrigin.x, cursorOrigin.y, focusObjHeight, alpha);

DGL_MatrixMode(DGL_MODELVIEW);
DGL_Translatef(-page->origin.x, -page->origin.y, 0);
}
}

static boolean MNActionInfo_IsActionExecuteable(mn_actioninfo_t* info)
Expand Down

0 comments on commit 793bbcb

Please sign in to comment.