Skip to content

Commit

Permalink
Fix alignment of right-justified small text buttons on main screen
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Mar 31, 2019
1 parent 35e5a8d commit e6aa879
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/frontend.cpp
Expand Up @@ -100,7 +100,7 @@ bool bLimiterLoaded = false;
// ////////////////////////////////////////////////////////////////////////////
// Forward definitions

static void addSmallTextButton(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt, unsigned int style);
static W_BUTTON * addSmallTextButton(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt, unsigned int style);

// ////////////////////////////////////////////////////////////////////////////
// Helper functions
Expand Down Expand Up @@ -163,9 +163,13 @@ static bool startTitleMenu()

addSmallTextButton(FRONTEND_HYPERLINK, FRONTEND_POS8X, FRONTEND_POS8Y, _("Official site: http://wz2100.net/"), 0);
widgSetTip(psWScreen, FRONTEND_HYPERLINK, _("Come visit the forums and all Warzone 2100 news! Click this link."));
addSmallTextButton(FRONTEND_DONATELINK, FRONTEND_POS8X + 360, FRONTEND_POS8Y, _("Donate: http://donations.wz2100.net/"), 0);
W_BUTTON * pRightAlignedButton = addSmallTextButton(FRONTEND_DONATELINK, FRONTEND_POS8X + 360, FRONTEND_POS8Y, _("Donate: http://donations.wz2100.net/"), 0);
// fix-up right-aligned link's positioning (based on size of text)
pRightAlignedButton->move(pRightAlignedButton->parent()->width() - (pRightAlignedButton->width() + 1), pRightAlignedButton->y());
widgSetTip(psWScreen, FRONTEND_DONATELINK, _("Help support the project with our server costs, Click this link."));
addSmallTextButton(FRONTEND_CHATLINK, FRONTEND_POS8X + 360, 0, _("Chat with players on #warzone2100"), 0);
pRightAlignedButton = addSmallTextButton(FRONTEND_CHATLINK, FRONTEND_POS8X + 360, 0, _("Chat with players on #warzone2100"), 0);
// fix-up right-aligned link's positioning (based on size of text)
pRightAlignedButton->move(pRightAlignedButton->parent()->width() - (pRightAlignedButton->width() + 6), pRightAlignedButton->y());
widgSetTip(psWScreen, FRONTEND_CHATLINK, _("Connect to Freenode through webchat by clicking this link."));
addMultiBut(psWScreen, FRONTEND_BOTFORM, FRONTEND_UPGRDLINK, 7, 7, MULTIOP_BUTW, MULTIOP_BUTH, _("Check for a newer version"), IMAGE_GAMEVERSION, IMAGE_GAMEVERSION_HI, true);

Expand Down Expand Up @@ -2078,7 +2082,7 @@ void addTextButton(UDWORD id, UDWORD PosX, UDWORD PosY, const std::string &txt,
}
}

void addSmallTextButton(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt, unsigned int style)
W_BUTTON * addSmallTextButton(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt, unsigned int style)
{
W_BUTINIT sButInit;

Expand All @@ -2090,7 +2094,7 @@ void addSmallTextButton(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt, u
// Align
if (!(style & WBUT_TXTCENTRE))
{
sButInit.width = (short)(iV_GetTextWidth(txt, font_small) + 10);
sButInit.width = (uint16_t)(iV_GetTextWidth(txt, font_small)) + 4;
sButInit.x += 35;
}
else
Expand All @@ -2117,13 +2121,14 @@ void addSmallTextButton(UDWORD id, UDWORD PosX, UDWORD PosY, const char *txt, u
sButInit.pDisplay = displayTextOption;
sButInit.FontID = font_small;
sButInit.pText = txt;
widgAddButton(psWScreen, &sButInit);
W_BUTTON * pButton = widgAddButton(psWScreen, &sButInit);

// Disable button
if (style & WBUT_DISABLE)
{
widgSetButtonState(psWScreen, id, WBUT_DISABLE);
}
return pButton;
}

// ////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit e6aa879

Please sign in to comment.