mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Make virtual keyboard even stronger
- Show a textbox (with highlighted border) so the console font is more likely to be legible.
- Increases the width of the virtual keys to match this.
- Show menu entry name and tooltip on faded view (if they exist), for additional context for what you're writing
- Make the text entry and the virtual keys slide seperately
This commit is contained in:
parent
d86743f0ba
commit
38ddfeeef8
2 changed files with 171 additions and 127 deletions
271
src/k_menudraw.c
271
src/k_menudraw.c
|
|
@ -357,159 +357,204 @@ void M_DrawMenuForeground(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// M_DrawMenuTooltips
|
||||||
|
//
|
||||||
|
// Draw a banner across the top of the screen, with a description of the current option displayed
|
||||||
|
//
|
||||||
|
static void M_DrawMenuTooltips(void)
|
||||||
|
{
|
||||||
|
if (currentMenu->menuitems[itemOn].tooltip != NULL)
|
||||||
|
{
|
||||||
|
V_DrawFixedPatch(0, 0, FRACUNIT, 0, W_CachePatchName("MENUHINT", PU_CACHE), NULL);
|
||||||
|
V_DrawCenteredThinString(BASEVIDWIDTH/2, 12, V_ALLOWLOWERCASE|V_6WIDTHSPACE, currentMenu->menuitems[itemOn].tooltip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draws the typing submenu
|
// Draws the typing submenu
|
||||||
static void M_DrawMenuTyping(void)
|
static void M_DrawMenuTyping(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
INT32 i, j;
|
INT32 i, j;
|
||||||
|
|
||||||
INT32 x;
|
INT32 x, y;
|
||||||
INT32 y = 100 + (9-menutyping.menutypingfade)*8;
|
|
||||||
INT32 tflag = (9 - menutyping.menutypingfade)<<V_ALPHASHIFT;
|
|
||||||
|
|
||||||
consvar_t *cv = currentMenu->menuitems[itemOn].itemaction.cvar;
|
consvar_t *cv = currentMenu->menuitems[itemOn].itemaction.cvar;
|
||||||
|
|
||||||
char buf[8]; // We write there to use drawstring for convenience.
|
char buf[8]; // We write there to use drawstring for convenience.
|
||||||
|
|
||||||
V_DrawFadeScreen(31, menutyping.menutypingfade);
|
V_DrawFadeScreen(31, (menutyping.menutypingfade+1)/2);
|
||||||
|
|
||||||
// Draw the string we're editing at the top.
|
// Draw the string we're editing at the top.
|
||||||
V_DrawString(60, y-48 + 12, V_ALLOWLOWERCASE|tflag, cv->string);
|
|
||||||
if (skullAnimCounter < 4)
|
|
||||||
V_DrawCharacter(60 + V_StringWidth(cv->string, 0), y - 35, '_' | 0x80, false);
|
|
||||||
|
|
||||||
// Some contextual stuff
|
const INT32 boxwidth = (8*(MAXSTRINGLENGTH + 1)) + 7;
|
||||||
if (menutyping.keyboardtyping)
|
x = (BASEVIDWIDTH - boxwidth)/2;
|
||||||
V_DrawThinString(10, 175, V_ALLOWLOWERCASE|V_6WIDTHSPACE|tflag|V_GRAYMAP, "Type using your keyboard. Press Enter to confirm & exit.\nUse your controller or any directional input to use the Virtual Keyboard.\n");
|
y = 80;
|
||||||
|
if (menutyping.menutypingfade < 9)
|
||||||
|
y += (9-menutyping.menutypingfade)*10;
|
||||||
else
|
else
|
||||||
V_DrawThinString(10, 175, V_ALLOWLOWERCASE|V_6WIDTHSPACE|tflag|V_GRAYMAP, "Type using the Virtual Keyboard. Use the \'OK\' button to confirm & exit.\nPress any keyboard key not bound to a control to use it.");
|
y += (9-menutyping.menutypingfade);
|
||||||
|
|
||||||
#define BUTTONWIDTH (14)
|
if (currentMenu->menuitems[itemOn].text)
|
||||||
|
{
|
||||||
|
V_DrawThinString(x + 5, y - 2, highlightflags|V_ALLOWLOWERCASE, currentMenu->menuitems[itemOn].text);
|
||||||
|
}
|
||||||
|
|
||||||
|
M_DrawMenuTooltips();
|
||||||
|
|
||||||
|
//M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1);
|
||||||
|
V_DrawFill(x + 5, y + 4 + 5, boxwidth - 8, 8+6, 159);
|
||||||
|
|
||||||
|
V_DrawFill(x + 4, y + 4 + 4, boxwidth - 6, 1, 121);
|
||||||
|
V_DrawFill(x + 4, y + 4 + 5 + 8 + 6, boxwidth - 6, 1, 121);
|
||||||
|
|
||||||
|
V_DrawFill(x + 4, y + 4 + 5, 1, 8+6, 121);
|
||||||
|
V_DrawFill(x + 5 + boxwidth - 8, y + 4 + 5, 1, 8+6, 121);
|
||||||
|
|
||||||
|
V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, cv->string);
|
||||||
|
if (skullAnimCounter < 4)
|
||||||
|
V_DrawCharacter(x + 8 + V_StringWidth(cv->string, 0), y + 12 + 1, '_' | 0x80, false);
|
||||||
|
|
||||||
|
const INT32 buttonwidth = ((boxwidth + 1)/NUMVIRTUALKEYSINROW);
|
||||||
#define BUTTONHEIGHT (11)
|
#define BUTTONHEIGHT (11)
|
||||||
|
|
||||||
// Now the keyboard itself
|
// Now the keyboard itself
|
||||||
INT32 returnx = (BASEVIDWIDTH - (((BUTTONWIDTH + 1)*NUMVIRTUALKEYSINROW)-1))/2;
|
x += 5;
|
||||||
INT32 tempkeyboardx = menutyping.keyboardx;
|
INT32 returnx = x;
|
||||||
|
|
||||||
while (virtualKeyboard[menutyping.keyboardy][tempkeyboardx] == 1
|
if (menutyping.menutypingfade > 9)
|
||||||
&& tempkeyboardx > 0)
|
|
||||||
tempkeyboardx--;
|
|
||||||
|
|
||||||
x = returnx;
|
|
||||||
|
|
||||||
for (i=0; i < 5; i++)
|
|
||||||
{
|
{
|
||||||
j = 0;
|
y += 36 + 80 + (9-menutyping.menutypingfade)*10; // double yoffs for animation
|
||||||
while (j < NUMVIRTUALKEYSINROW)
|
|
||||||
|
INT32 tempkeyboardx = menutyping.keyboardx;
|
||||||
|
|
||||||
|
while (virtualKeyboard[menutyping.keyboardy][tempkeyboardx] == 1
|
||||||
|
&& tempkeyboardx > 0)
|
||||||
|
tempkeyboardx--;
|
||||||
|
|
||||||
|
for (i = 0; i < 5; i++)
|
||||||
{
|
{
|
||||||
INT32 mflag = V_ALLOWLOWERCASE|V_6WIDTHSPACE;
|
j = 0;
|
||||||
INT16 c = virtualKeyboard[i][j];
|
while (j < NUMVIRTUALKEYSINROW)
|
||||||
|
|
||||||
INT32 buttonspacing = 1;
|
|
||||||
|
|
||||||
UINT8 col = 27;
|
|
||||||
|
|
||||||
INT32 arrowoffset = 0;
|
|
||||||
|
|
||||||
while (j + buttonspacing < NUMVIRTUALKEYSINROW
|
|
||||||
&& virtualKeyboard[i][j + buttonspacing] == 1)
|
|
||||||
{
|
{
|
||||||
buttonspacing++;
|
INT32 mflag = V_ALLOWLOWERCASE|V_6WIDTHSPACE;
|
||||||
}
|
INT16 c = virtualKeyboard[i][j];
|
||||||
|
|
||||||
if (menutyping.keyboardshift ^ menutyping.keyboardcapslock)
|
INT32 buttonspacing = 1;
|
||||||
c = shift_virtualKeyboard[i][j];
|
|
||||||
|
|
||||||
if (i < 4 && j < NUMVIRTUALKEYSINROW-2)
|
UINT8 col = 27;
|
||||||
{
|
|
||||||
col = 25;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c == KEY_BACKSPACE)
|
INT32 arrowoffset = 0;
|
||||||
{
|
|
||||||
arrowoffset = 1;
|
|
||||||
buf[0] = '\x1C'; // left arrow
|
|
||||||
buf[1] = '\0';
|
|
||||||
}
|
|
||||||
else if (c == KEY_RSHIFT)
|
|
||||||
{
|
|
||||||
arrowoffset = 2;
|
|
||||||
buf[0] = '\x1A'; // up arrow
|
|
||||||
buf[1] = '\0';
|
|
||||||
|
|
||||||
if (menutyping.keyboardcapslock || menutyping.keyboardshift)
|
while (j + buttonspacing < NUMVIRTUALKEYSINROW
|
||||||
|
&& virtualKeyboard[i][j + buttonspacing] == 1)
|
||||||
{
|
{
|
||||||
col = 22;
|
buttonspacing++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (c == KEY_ENTER)
|
|
||||||
{
|
|
||||||
strcpy(buf, "OK");
|
|
||||||
}
|
|
||||||
else if (c == KEY_SPACE)
|
|
||||||
{
|
|
||||||
strcpy(buf, "Space");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
buf[0] = c;
|
|
||||||
buf[1] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
INT32 width = ((BUTTONWIDTH + 1) * buttonspacing) - 1;
|
if (menutyping.keyboardshift ^ menutyping.keyboardcapslock)
|
||||||
|
c = shift_virtualKeyboard[i][j];
|
||||||
|
|
||||||
// highlight:
|
if (i < 4 && j < NUMVIRTUALKEYSINROW-2)
|
||||||
if (menutyping.keyboardtyping)
|
|
||||||
{
|
|
||||||
mflag |= V_TRANSLUCENT; // grey it out if we can't use it.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (tempkeyboardx == j && menutyping.keyboardy == i)
|
|
||||||
{
|
{
|
||||||
V_DrawFill(x + 1, y + 1, width - 2, BUTTONHEIGHT - 2, col - 3);
|
col = 25;
|
||||||
|
}
|
||||||
|
|
||||||
V_DrawFill(x, y, width, 1, 121);
|
if (c == KEY_BACKSPACE)
|
||||||
V_DrawFill(x, y + BUTTONHEIGHT - 1, width, 1, 121);
|
{
|
||||||
|
arrowoffset = 1;
|
||||||
|
buf[0] = '\x1C'; // left arrow
|
||||||
|
buf[1] = '\0';
|
||||||
|
}
|
||||||
|
else if (c == KEY_RSHIFT)
|
||||||
|
{
|
||||||
|
arrowoffset = 2;
|
||||||
|
buf[0] = '\x1A'; // up arrow
|
||||||
|
buf[1] = '\0';
|
||||||
|
|
||||||
V_DrawFill(x, y + 1, 1, BUTTONHEIGHT - 2, 121);
|
if (menutyping.keyboardcapslock || menutyping.keyboardshift)
|
||||||
V_DrawFill(x + width - 1, y + 1, 1, BUTTONHEIGHT - 2, 121);
|
{
|
||||||
|
col = 22;
|
||||||
mflag |= highlightflags;
|
}
|
||||||
|
}
|
||||||
|
else if (c == KEY_ENTER)
|
||||||
|
{
|
||||||
|
strcpy(buf, "OK");
|
||||||
|
}
|
||||||
|
else if (c == KEY_SPACE)
|
||||||
|
{
|
||||||
|
strcpy(buf, "Space");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
V_DrawFill(x, y, width, BUTTONHEIGHT, col);
|
buf[0] = c;
|
||||||
|
buf[1] = '\0';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (arrowoffset != 0)
|
INT32 width = (buttonwidth * buttonspacing) - 1;
|
||||||
{
|
|
||||||
if (c == KEY_RSHIFT)
|
// highlight:
|
||||||
|
/*if (menutyping.keyboardtyping)
|
||||||
{
|
{
|
||||||
V_DrawFill(x + width - 5, y + 1, 4, 4, 31);
|
mflag |= V_TRANSLUCENT; // grey it out if we can't use it.
|
||||||
|
}
|
||||||
if (menutyping.keyboardcapslock)
|
else*/
|
||||||
|
{
|
||||||
|
if (tempkeyboardx == j && menutyping.keyboardy == i)
|
||||||
{
|
{
|
||||||
V_DrawFill(x + width - 4, y + 2, 2, 2, 121);
|
V_DrawFill(x + 1, y + 1, width - 2, BUTTONHEIGHT - 2, col - 3);
|
||||||
|
|
||||||
|
V_DrawFill(x, y, width, 1, 121);
|
||||||
|
V_DrawFill(x, y + BUTTONHEIGHT - 1, width, 1, 121);
|
||||||
|
|
||||||
|
V_DrawFill(x, y + 1, 1, BUTTONHEIGHT - 2, 121);
|
||||||
|
V_DrawFill(x + width - 1, y + 1, 1, BUTTONHEIGHT - 2, 121);
|
||||||
|
|
||||||
|
mflag |= highlightflags;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
V_DrawFill(x, y, width, BUTTONHEIGHT, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
V_DrawCenteredString(x + (width/2), y + 1 + arrowoffset, tflag|mflag, buf);
|
if (arrowoffset != 0)
|
||||||
}
|
{
|
||||||
else
|
if (c == KEY_RSHIFT)
|
||||||
{
|
{
|
||||||
V_DrawCenteredThinString(x + (width/2), y + 1, tflag|mflag, buf);
|
V_DrawFill(x + width - 5, y + 1, 4, 4, 31);
|
||||||
}
|
|
||||||
|
|
||||||
x += width + 1;
|
if (menutyping.keyboardcapslock)
|
||||||
j += buttonspacing;
|
{
|
||||||
|
V_DrawFill(x + width - 4, y + 2, 2, 2, 121);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
V_DrawCenteredString(x + (width/2), y + 1 + arrowoffset, mflag, buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
V_DrawCenteredThinString(x + (width/2), y + 1, mflag, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
x += width + 1;
|
||||||
|
j += buttonspacing;
|
||||||
|
}
|
||||||
|
x = returnx;
|
||||||
|
y += BUTTONHEIGHT + 1;
|
||||||
}
|
}
|
||||||
x = returnx;
|
|
||||||
y += BUTTONHEIGHT + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef BUTTONWIDTH
|
#undef BUTTONHEIGHT
|
||||||
|
|
||||||
|
// Some contextual stuff
|
||||||
|
if (menutyping.keyboardtyping)
|
||||||
|
{
|
||||||
|
V_DrawThinString(returnx, 175, V_ALLOWLOWERCASE|V_6WIDTHSPACE|V_GRAYMAP, "Type using your keyboard. Press Enter to confirm & exit.\nUse your controller or any directional input to use the Virtual Keyboard.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
V_DrawThinString(x, 175, V_ALLOWLOWERCASE|V_6WIDTHSPACE|V_GRAYMAP, "Type using the Virtual Keyboard. Use the \'OK\' button to confirm & exit.\nPress any keyboard key not bound to a control to use it.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -665,20 +710,6 @@ void M_Drawer(void)
|
||||||
// GENERIC MENUS
|
// GENERIC MENUS
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|
||||||
//
|
|
||||||
// M_DrawMenuTooltips
|
|
||||||
//
|
|
||||||
// Draw a banner across the top of the screen, with a description of the current option displayed
|
|
||||||
//
|
|
||||||
static void M_DrawMenuTooltips(void)
|
|
||||||
{
|
|
||||||
if (currentMenu->menuitems[itemOn].tooltip != NULL)
|
|
||||||
{
|
|
||||||
V_DrawFixedPatch(0, 0, FRACUNIT, 0, W_CachePatchName("MENUHINT", PU_CACHE), NULL);
|
|
||||||
V_DrawCenteredThinString(BASEVIDWIDTH/2, 12, V_ALLOWLOWERCASE|V_6WIDTHSPACE, currentMenu->menuitems[itemOn].tooltip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Converts a string into question marks.
|
// Converts a string into question marks.
|
||||||
// Used for the secrets menu, to hide yet-to-be-unlocked stuff.
|
// Used for the secrets menu, to hide yet-to-be-unlocked stuff.
|
||||||
static const char *M_CreateSecretMenuOption(const char *str)
|
static const char *M_CreateSecretMenuOption(const char *str)
|
||||||
|
|
|
||||||
|
|
@ -188,21 +188,34 @@ void M_MenuTypingInput(INT32 key)
|
||||||
|
|
||||||
// Fade-in
|
// Fade-in
|
||||||
|
|
||||||
if (menutyping.menutypingclose) // closing
|
if (menutyping.menutypingclose)
|
||||||
{
|
{
|
||||||
|
// Closing
|
||||||
menutyping.menutypingfade--;
|
menutyping.menutypingfade--;
|
||||||
if (!menutyping.menutypingfade)
|
if (!menutyping.menutypingfade)
|
||||||
menutyping.active = false;
|
menutyping.active = false;
|
||||||
|
|
||||||
return; // prevent inputs while closing the menu.
|
return; // prevent inputs while closing the menu.
|
||||||
}
|
}
|
||||||
else // opening
|
else
|
||||||
{
|
{
|
||||||
menutyping.menutypingfade++;
|
// Opening
|
||||||
if (menutyping.menutypingfade > 9) // Don't fade all the way, but have it VERY strong to be readable
|
const UINT8 destination = (menutyping.keyboardtyping ? 9 : 18);
|
||||||
menutyping.menutypingfade = 9;
|
|
||||||
else if (menutyping.menutypingfade < 9)
|
if (menutyping.menutypingfade > destination)
|
||||||
return; // Don't allow typing until it's fully opened.
|
{
|
||||||
|
menutyping.menutypingfade--;
|
||||||
|
}
|
||||||
|
else if (menutyping.menutypingfade < destination)
|
||||||
|
{
|
||||||
|
menutyping.menutypingfade++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menutyping.menutypingfade != destination)
|
||||||
|
{
|
||||||
|
// Don't allow typing until it's fully opened.
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine when to check for keyboard inputs or controller inputs using menuKey, which is the key passed here as argument.
|
// Determine when to check for keyboard inputs or controller inputs using menuKey, which is the key passed here as argument.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue