Fix menu textinput cursor and remove ST_DrawTextInput
This commit is contained in:
parent
88ecd2f5d6
commit
4ebbaa7b58
3 changed files with 17 additions and 104 deletions
|
|
@ -2334,9 +2334,10 @@ static void M_DrawRightString(menuitem_t *item, INT16 x, INT16 y, INT32 vflags,
|
|||
w = M_StringCvarLength(cv);
|
||||
|
||||
M_DrawTextBox(x + xofs, y + yofs, w, 1);
|
||||
V_DrawString(x + xofs + 8, y + yofs + 8, vflags|V_ALLOWLOWERCASE, cv->string);
|
||||
if (selected)
|
||||
M_DrawTextInput(x + xofs + 8, y + yofs + 8, &menuinput, vflags|V_ALLOWLOWERCASE);
|
||||
else
|
||||
V_DrawString(x + xofs + 8, y + yofs + 8, vflags|V_ALLOWLOWERCASE, cv->string);
|
||||
}
|
||||
else if (item->status & IT_SLIDER)
|
||||
{
|
||||
|
|
@ -3521,7 +3522,7 @@ void MD_DrawAddons(void)
|
|||
M_DrawTextBox(x - (21 + 5), y, MAXSTRINGLENGTH, 1);
|
||||
|
||||
if (menusearch.length)
|
||||
M_DrawTextInput(x - 18, y + 8, &menusearch, 0);
|
||||
M_DrawTextInput(x - 18, y + 8, &menusearch, V_ALLOWLOWERCASE);
|
||||
else
|
||||
V_DrawString(x - 18, y + 8, V_ALLOWLOWERCASE|V_TRANSLUCENT, "Type to search...");
|
||||
|
||||
|
|
|
|||
|
|
@ -498,22 +498,22 @@ void M_DrawTextInputScroll(INT32 x, INT32 y, textinput_t *input, INT32 flags, IN
|
|||
|
||||
INT32 skullx = x;
|
||||
|
||||
while (V_SubStringWidth(input->buffer+drawstart, input->cursor-drawstart, V_ALLOWLOWERCASE) > MAXINPUTWIDTH)
|
||||
while (V_SubStringWidth(input->buffer+drawstart, input->cursor-drawstart, flags) > MAXINPUTWIDTH)
|
||||
++drawstart;
|
||||
|
||||
size_t drawlength = V_SubStringLengthToFit(input->buffer+drawstart, MAXINPUTWIDTH+8, V_ALLOWLOWERCASE)+1;
|
||||
size_t drawlength = V_SubStringLengthToFit(input->buffer+drawstart, MAXINPUTWIDTH+8, flags)+1;
|
||||
drawend = drawstart + drawlength;
|
||||
|
||||
memcpy(nametodraw, input->buffer+drawstart, drawlength);
|
||||
|
||||
if (input->length)
|
||||
skullx += V_SubStringWidth(nametodraw, input->cursor-drawstart, V_ALLOWLOWERCASE);
|
||||
skullx += V_SubStringWidth(nametodraw, input->cursor-drawstart, flags);
|
||||
|
||||
V_DrawString(x, y, V_ALLOWLOWERCASE|flags, nametodraw);
|
||||
V_DrawString(x, y, flags, nametodraw);
|
||||
|
||||
// draw text cursor for name
|
||||
if (input->skull < 4) // blink cursor
|
||||
V_DrawCharacter(skullx, y+3, '_'|flags, false);
|
||||
V_DrawCharacter(skullx, y+3, '_'|(flags & ~(V_FLIP|V_PARAMMASK)), false);
|
||||
|
||||
// draw selection
|
||||
if (input->select != input->cursor)
|
||||
|
|
@ -521,32 +521,14 @@ void M_DrawTextInputScroll(INT32 x, INT32 y, textinput_t *input, INT32 flags, IN
|
|||
size_t start = min(input->select, input->cursor);
|
||||
size_t end = max(input->select, input->cursor);
|
||||
|
||||
INT32 startx = 0;
|
||||
INT32 width = 0;
|
||||
ssize_t leftofs = start - drawstart;
|
||||
INT32 startx = leftofs >= 0 ? V_SubStringWidth(nametodraw, leftofs, flags) : -2;
|
||||
INT32 width = V_SubStringWidth(nametodraw + max(0, leftofs), end - start + min(0, leftofs), flags);
|
||||
if (startx < 0)
|
||||
width -= startx;
|
||||
if (end > drawend)
|
||||
width += 2;
|
||||
|
||||
// I couldn't figure out one formula so here's bunch of separate cases
|
||||
if (start < drawstart && end > drawend) // Selection covers whole visible portion of demo name
|
||||
{
|
||||
startx = -2;
|
||||
width = V_StringWidth(nametodraw, V_ALLOWLOWERCASE)+4;
|
||||
}
|
||||
else if (start < drawstart) // Only left side of selection is off visible part
|
||||
{
|
||||
startx = -2;
|
||||
size_t len = (end - start) - (drawstart - start);
|
||||
width = V_SubStringWidth(nametodraw, len, V_ALLOWLOWERCASE)+2;
|
||||
}
|
||||
else if (end > drawend) // Only right side of selection is off visible part
|
||||
{
|
||||
startx = V_SubStringWidth(nametodraw, start-drawstart, V_ALLOWLOWERCASE);
|
||||
width = V_StringWidth(nametodraw+(start-drawstart), V_ALLOWLOWERCASE)+2;
|
||||
}
|
||||
else // All selection is on visible part
|
||||
{
|
||||
startx = V_SubStringWidth(nametodraw, start-drawstart, V_ALLOWLOWERCASE);
|
||||
width = V_SubStringWidth(nametodraw+(start-drawstart), end-start, V_ALLOWLOWERCASE);
|
||||
}
|
||||
|
||||
V_DrawFill(x+startx, y, width, 8, 103|V_TRANSLUCENT|flags);
|
||||
V_DrawFill(x+startx, y, width, 8, 103|V_TRANSLUCENT|(flags & ~(V_ALPHAMASK|V_PARAMMASK)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -863,83 +863,13 @@ static void ST_overlayDrawer(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void ST_DrawTextInput(INT32 x, INT32 y, textinput_t *input, INT32 flags)
|
||||
{
|
||||
static UINT8 skullAnimCounter = 0;
|
||||
static const INT32 MAXINPUTWIDTH = (MAXSTRINGLENGTH-1)*8;
|
||||
|
||||
if (renderisnewtic)
|
||||
skullAnimCounter++;
|
||||
skullAnimCounter %= 8;
|
||||
|
||||
char nametodraw[MAXSTRINGLENGTH*2+1] = {0};
|
||||
|
||||
size_t drawstart = 0;
|
||||
size_t drawend = 0; // Only used for selection
|
||||
|
||||
INT32 skullx = x;
|
||||
|
||||
while (V_SubStringWidth(input->buffer+drawstart, input->cursor-drawstart, V_ALLOWLOWERCASE) > MAXINPUTWIDTH)
|
||||
++drawstart;
|
||||
|
||||
size_t drawlength = V_SubStringLengthToFit(input->buffer+drawstart, MAXINPUTWIDTH+8, V_ALLOWLOWERCASE)+1;
|
||||
drawend = drawstart + drawlength;
|
||||
|
||||
memcpy(nametodraw, input->buffer+drawstart, drawlength);
|
||||
|
||||
|
||||
if (input->length)
|
||||
skullx += V_SubStringWidth(nametodraw, input->cursor-drawstart, V_ALLOWLOWERCASE);
|
||||
|
||||
V_DrawString(x, y, V_ALLOWLOWERCASE|flags, nametodraw);
|
||||
|
||||
// draw text cursor for name
|
||||
if (skullAnimCounter < 4) // blink cursor
|
||||
V_DrawCharacter(skullx, y+3, '_'|flags, false);
|
||||
|
||||
// draw selection
|
||||
if (input->select != input->cursor)
|
||||
{
|
||||
size_t start = min(input->select, input->cursor);
|
||||
size_t end = max(input->select, input->cursor);
|
||||
|
||||
INT32 startx = 0;
|
||||
INT32 width = 0;
|
||||
|
||||
// I couldn't figure out one formula so here's bunch of separate cases
|
||||
if (start < drawstart && end > drawend) // Selection covers whole visible portion of demo name
|
||||
{
|
||||
startx = -2;
|
||||
width = V_StringWidth(nametodraw, V_ALLOWLOWERCASE);
|
||||
}
|
||||
else if (start < drawstart) // Only left side of selection is off visible part
|
||||
{
|
||||
startx = -2;
|
||||
size_t len = (end - start) - (drawstart - start);
|
||||
width = V_SubStringWidth(nametodraw, len, V_ALLOWLOWERCASE)+2;
|
||||
}
|
||||
else if (end > drawend) // Only right side of selection is off visible part
|
||||
{
|
||||
startx = V_SubStringWidth(nametodraw, start-drawstart, V_ALLOWLOWERCASE);
|
||||
width = V_StringWidth(nametodraw+(start-drawstart), V_ALLOWLOWERCASE)+2;
|
||||
}
|
||||
else // All selection is on visible part
|
||||
{
|
||||
startx = V_SubStringWidth(nametodraw, start-drawstart, V_ALLOWLOWERCASE);
|
||||
width = V_SubStringWidth(nametodraw+(start-drawstart), end-start, V_ALLOWLOWERCASE);
|
||||
}
|
||||
|
||||
V_DrawFill(x+startx, y, width, 8, 103|V_TRANSLUCENT|flags);
|
||||
}
|
||||
}
|
||||
|
||||
void ST_DrawDemoTitleEntry(void)
|
||||
{
|
||||
#define x (BASEVIDWIDTH/2 - 139)
|
||||
#define y (BASEVIDHEIGHT/2)
|
||||
M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1);
|
||||
|
||||
ST_DrawTextInput(x + 8, y + 12, &demo.titlenameinput, 0);
|
||||
M_DrawTextInputScroll(x + 8, y + 12, &demo.titlenameinput, V_ALLOWLOWERCASE, (MAXSTRINGLENGTH-1)*8);
|
||||
|
||||
M_DrawTextBox(x + 30, y - 24, 26, 1);
|
||||
V_DrawString(x + 38, y - 16, V_ALLOWLOWERCASE, "Enter the name of the replay.");
|
||||
|
|
|
|||
Loading…
Reference in a new issue