mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-02-24 12:51:45 +00:00
Toggle showing password with tab
This commit is contained in:
parent
1b6035e322
commit
870a800d89
1 changed files with 30 additions and 12 deletions
42
src/m_menu.c
42
src/m_menu.c
|
@ -2384,6 +2384,9 @@ static void M_NextOpt(void)
|
|||
{
|
||||
INT16 oldItemOn = itemOn; // prevent infinite loop
|
||||
|
||||
if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_PASSWORD)
|
||||
((consvar_t *)currentMenu->menuitems[itemOn].itemaction)->value = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if (itemOn + 1 > currentMenu->numitems - 1)
|
||||
|
@ -2397,6 +2400,9 @@ static void M_PrevOpt(void)
|
|||
{
|
||||
INT16 oldItemOn = itemOn; // prevent infinite loop
|
||||
|
||||
if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_PASSWORD)
|
||||
((consvar_t *)currentMenu->menuitems[itemOn].itemaction)->value = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if (!itemOn)
|
||||
|
@ -2685,6 +2691,9 @@ boolean M_Responder(event_t *ev)
|
|||
{
|
||||
if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING || (currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_PASSWORD)
|
||||
{
|
||||
if (ch == KEY_TAB)
|
||||
((consvar_t *)currentMenu->menuitems[itemOn].itemaction)->value ^= 1;
|
||||
|
||||
if (shiftdown && ch >= 32 && ch <= 127)
|
||||
ch = shiftxform[ch];
|
||||
if (M_ChangeStringCvar(ch))
|
||||
|
@ -3567,6 +3576,27 @@ static void M_DrawGenericMenu(void)
|
|||
case IT_CV_NOPRINT: // color use this
|
||||
case IT_CV_INVISSLIDER: // monitor toggles use this
|
||||
break;
|
||||
case IT_CV_PASSWORD:
|
||||
if (i == itemOn)
|
||||
{
|
||||
V_DrawRightAlignedThinString(x + MAXSTRINGLENGTH*8 + 10, y, V_ALLOWLOWERCASE, va(M_GetText("Tab: %s password"), cv->value ? "hide" : "show"));
|
||||
}
|
||||
|
||||
if (!cv->value || i != itemOn)
|
||||
{
|
||||
sl = strlen(cv->string);
|
||||
memset(asterisks, '*', sl);
|
||||
memset(asterisks + sl, 0, MAXSTRINGLENGTH+1-sl);
|
||||
|
||||
M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1);
|
||||
V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, asterisks);
|
||||
if (skullAnimCounter < 4 && i == itemOn)
|
||||
V_DrawCharacter(x + 8 + V_StringWidth(asterisks, 0), y + 12,
|
||||
'_' | 0x80, false);
|
||||
y += 16;
|
||||
break;
|
||||
}
|
||||
/* fallthru */
|
||||
case IT_CV_STRING:
|
||||
M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1);
|
||||
V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, cv->string);
|
||||
|
@ -3575,18 +3605,6 @@ static void M_DrawGenericMenu(void)
|
|||
'_' | 0x80, false);
|
||||
y += 16;
|
||||
break;
|
||||
case IT_CV_PASSWORD:
|
||||
sl = strlen(cv->string);
|
||||
memset(asterisks, '*', sl);
|
||||
memset(asterisks + sl, 0, MAXSTRINGLENGTH+1-sl);
|
||||
|
||||
M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1);
|
||||
V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, asterisks);
|
||||
if (skullAnimCounter < 4 && i == itemOn)
|
||||
V_DrawCharacter(x + 8 + V_StringWidth(asterisks, 0), y + 12,
|
||||
'_' | 0x80, false);
|
||||
y += 16;
|
||||
break;
|
||||
default:
|
||||
w = V_StringWidth(cv->string, 0);
|
||||
V_DrawString(BASEVIDWIDTH - x - w, y,
|
||||
|
|
Loading…
Reference in a new issue