Skip to content

Commit

Permalink
Game Menu: Fixed page object lineheight calculation
Browse files Browse the repository at this point in the history
Page lineheight is always calculated according to page font #1,
however the menu objects were being initialized with inconsistent
usage of the page font indices.
  • Loading branch information
danij-deng committed Jan 4, 2012
1 parent 27994b0 commit 71c54ed
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 54 deletions.
6 changes: 4 additions & 2 deletions doomsday/plugins/common/include/hu_lib.h
Expand Up @@ -267,7 +267,7 @@ boolean MNObject_HasAction(mn_object_t* obj, mn_actionid_t action);
int MNObject_ExecAction(mn_object_t* obj, mn_actionid_t action, void* paramaters);

typedef enum {
MENU_COLOR1,
MENU_COLOR1 = 0,
MENU_COLOR2,
MENU_COLOR3,
MENU_COLOR4,
Expand All @@ -283,7 +283,7 @@ typedef enum {
#define VALID_MNPAGE_COLORID(v) ((v) >= MENU_COLOR1 && (v) < MENU_COLOR_COUNT)

typedef enum {
MENU_FONT1,
MENU_FONT1 = 0,
MENU_FONT2,
MENU_FONT3,
MENU_FONT4,
Expand Down Expand Up @@ -380,6 +380,8 @@ void MNPage_PredefinedColor(mn_page_t* page, mn_page_colorid_t id, float rgb[3])
*/
fontid_t MNPage_PredefinedFont(mn_page_t* page, mn_page_fontid_t id);

void MNPage_SetPredefinedFont(mn_page_t* page, mn_page_fontid_t id, fontid_t fontId);

/**
* Text objects.
*/
Expand Down
19 changes: 16 additions & 3 deletions doomsday/plugins/common/src/hu_lib.c
Expand Up @@ -782,8 +782,8 @@ static void applyPageLayout(mn_page_t* page)
// Calculate leading/line offset.
FR_SetFont(MNPage_PredefinedFont(page, MENU_FONT1));
/// \kludge We cannot yet query line height from the font.
lineHeight = FR_TextHeight("WyQ");
lineOffset = MAX_OF(1, .5f + lineHeight * .08f);
lineHeight = FR_TextHeight("{case}WyQ");
lineOffset = MAX_OF(1, .5f + lineHeight * .4f);

Rect_SetXY(page->geometry, 0, 0);
Rect_SetWidthHeight(page->geometry, 0, 0);
Expand Down Expand Up @@ -1285,14 +1285,27 @@ fontid_t MNPage_PredefinedFont(mn_page_t* page, mn_page_fontid_t id)
if(!VALID_MNPAGE_FONTID(id))
{
#if _DEBUG
Con_Error("MNPage::PredefinedFont: Invalid font id '%i'.", (int)id);
Con_Error("MNPage::PredefinedFont: Invalid font id #%i.", (int)id);
exit(1); // Unreachable.
#endif
return 0; // Not a valid font id.
}
return page->fonts[id];
}

void MNPage_SetPredefinedFont(mn_page_t* page, mn_page_fontid_t id, fontid_t fontId)
{
assert(page);
if(!VALID_MNPAGE_FONTID(id))
{
#if _DEBUG
Con_Message("MNPage::SetPredefinedFont: Invalid font id #%i, ignoring.\n", id);
#endif
return;
}
page->fonts[id] = fontId;
}

void MNPage_PredefinedColor(mn_page_t* page, mn_page_colorid_t id, float rgb[3])
{
uint colorIndex;
Expand Down

0 comments on commit 71c54ed

Please sign in to comment.