mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-05-03 15:32:45 +00:00
Menus: handle caret codes in text fields
- All text boxes render caret code colors - On-screen keyboard updates colors in real time
This commit is contained in:
parent
a5c4b3705f
commit
3646850ff6
3 changed files with 17 additions and 3 deletions
|
|
@ -69,6 +69,7 @@
|
||||||
|
|
||||||
#include "i_time.h"
|
#include "i_time.h"
|
||||||
#include "m_easing.h"
|
#include "m_easing.h"
|
||||||
|
#include "sanitize.h"
|
||||||
|
|
||||||
#ifdef PC_DOS
|
#ifdef PC_DOS
|
||||||
#include <stdio.h> // for snprintf
|
#include <stdio.h> // for snprintf
|
||||||
|
|
@ -532,12 +533,12 @@ static void M_DrawMenuTyping(void)
|
||||||
V_DrawFill(x + 4, y + 4 + 5, 1, 8+6, 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_DrawFill(x + 5 + boxwidth - 8, y + 4 + 5, 1, 8+6, 121);
|
||||||
|
|
||||||
V_DrawString(x + 8, y + 12, 0, menutyping.cache);
|
INT32 textwidth = M_DrawCaretString(x + 8, y + 12, menutyping.cache, true);
|
||||||
if (skullAnimCounter < 4
|
if (skullAnimCounter < 4
|
||||||
&& menutyping.menutypingclose == false
|
&& menutyping.menutypingclose == false
|
||||||
&& menutyping.menutypingfade == (menutyping.keyboardtyping ? 9 : 18))
|
&& menutyping.menutypingfade == (menutyping.keyboardtyping ? 9 : 18))
|
||||||
{
|
{
|
||||||
V_DrawCharacter(x + 8 + V_StringWidth(menutyping.cache, 0), y + 12 + 1, '_', false);
|
V_DrawCharacter(x + 8 + textwidth, y + 12 + 1, '_', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const INT32 buttonwidth = ((boxwidth + 1)/NUMVIRTUALKEYSINROW);
|
const INT32 buttonwidth = ((boxwidth + 1)/NUMVIRTUALKEYSINROW);
|
||||||
|
|
@ -4493,7 +4494,7 @@ box_found:
|
||||||
V_DrawMenuString(x + (skullAnimCounter/5) + 7, y + 9, highlightflags, "\x1D");
|
V_DrawMenuString(x + (skullAnimCounter/5) + 7, y + 9, highlightflags, "\x1D");
|
||||||
}
|
}
|
||||||
|
|
||||||
V_DrawString(x + xoffs + 8, y + 9, 0, cv->string);
|
M_DrawCaretString(x + xoffs + 8, y + 9, cv->string, false);
|
||||||
|
|
||||||
y += LINEHEIGHT;
|
y += LINEHEIGHT;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "doomtype.h"
|
#include "doomtype.h"
|
||||||
#include "sanitize.h"
|
#include "sanitize.h"
|
||||||
|
#include "v_draw.hpp"
|
||||||
|
|
||||||
using namespace srb2::sanitize;
|
using namespace srb2::sanitize;
|
||||||
|
|
||||||
|
|
@ -131,3 +132,12 @@ void D_ParseCarets(char *out, const char *in, size_t out_size)
|
||||||
{
|
{
|
||||||
strlcpy(out, parse_carets(in, ParseMode::kConsume).c_str(), out_size);
|
strlcpy(out, parse_carets(in, ParseMode::kConsume).c_str(), out_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INT32 M_DrawCaretString(INT32 x, INT32 y, const char *string, boolean preserve)
|
||||||
|
{
|
||||||
|
using srb2::Draw;
|
||||||
|
Draw::TextElement text(parse_carets(string, preserve ? ParseMode::kPreserve : ParseMode::kConsume));
|
||||||
|
text.font(Draw::Font::kConsole);
|
||||||
|
Draw(x, y).text(text);
|
||||||
|
return text.width();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,9 @@ extern "C" {
|
||||||
void D_SanitizeKeepColors(char *out, const char *in, size_t out_size); // SanitizeMode::kKeepColors
|
void D_SanitizeKeepColors(char *out, const char *in, size_t out_size); // SanitizeMode::kKeepColors
|
||||||
void D_ParseCarets(char *out, const char *in, size_t out_size); // ParseMode::kConsume
|
void D_ParseCarets(char *out, const char *in, size_t out_size); // ParseMode::kConsume
|
||||||
|
|
||||||
|
// returns string width in pixels
|
||||||
|
INT32 M_DrawCaretString(INT32 x, INT32 y, const char *string, boolean preserve);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue