mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-30 13:47:59 +03:00
text: add left/right arrow support and new text functions (#456)
This commit is contained in:
parent
a058f4ebd1
commit
f14ec7e036
2 changed files with 40 additions and 13 deletions
|
@ -13,6 +13,7 @@
|
||||||
#define TEXT_BOX_OFFSET 2
|
#define TEXT_BOX_OFFSET 2
|
||||||
#define TEXT_MAX_STRING_SIZE 100
|
#define TEXT_MAX_STRING_SIZE 100
|
||||||
#define TEXT_MAX_STRINGS 64
|
#define TEXT_MAX_STRINGS 64
|
||||||
|
#define RIGHT_ARROW_SYM 109
|
||||||
|
|
||||||
static int16_t m_TextstringCount = 0;
|
static int16_t m_TextstringCount = 0;
|
||||||
static TEXTSTRING m_TextstringTable[TEXT_MAX_STRINGS] = { 0 };
|
static TEXTSTRING m_TextstringTable[TEXT_MAX_STRINGS] = { 0 };
|
||||||
|
@ -42,7 +43,7 @@ static int8_t m_TextASCIIMap[95] = {
|
||||||
79 /*'*/, 69 /*(*/, 70 /*)*/, 92 /***/, 72 /*+*/, 63 /*,*/, 71 /*-*/,
|
79 /*'*/, 69 /*(*/, 70 /*)*/, 92 /***/, 72 /*+*/, 63 /*,*/, 71 /*-*/,
|
||||||
62 /*.*/, 68 /**/, 52 /*0*/, 53 /*1*/, 54 /*2*/, 55 /*3*/, 56 /*4*/,
|
62 /*.*/, 68 /**/, 52 /*0*/, 53 /*1*/, 54 /*2*/, 55 /*3*/, 56 /*4*/,
|
||||||
57 /*5*/, 58 /*6*/, 59 /*7*/, 60 /*8*/, 61 /*9*/, 73 /*:*/, 73 /*;*/,
|
57 /*5*/, 58 /*6*/, 59 /*7*/, 60 /*8*/, 61 /*9*/, 73 /*:*/, 73 /*;*/,
|
||||||
66 /*<*/, 74 /*=*/, 75 /*>*/, 65 /*?*/, 0 /**/, 0 /*A*/, 1 /*B*/,
|
66 /*<*/, 74 /*=*/, 75 /*>*/, 65 /*?*/, 108 /*@*/, 0 /*A*/, 1 /*B*/,
|
||||||
2 /*C*/, 3 /*D*/, 4 /*E*/, 5 /*F*/, 6 /*G*/, 7 /*H*/, 8 /*I*/,
|
2 /*C*/, 3 /*D*/, 4 /*E*/, 5 /*F*/, 6 /*G*/, 7 /*H*/, 8 /*I*/,
|
||||||
9 /*J*/, 10 /*K*/, 11 /*L*/, 12 /*M*/, 13 /*N*/, 14 /*O*/, 15 /*P*/,
|
9 /*J*/, 10 /*K*/, 11 /*L*/, 12 /*M*/, 13 /*N*/, 14 /*O*/, 15 /*P*/,
|
||||||
16 /*Q*/, 17 /*R*/, 18 /*S*/, 19 /*T*/, 20 /*U*/, 21 /*V*/, 22 /*W*/,
|
16 /*Q*/, 17 /*R*/, 18 /*S*/, 19 /*T*/, 20 /*U*/, 21 /*V*/, 22 /*W*/,
|
||||||
|
@ -127,6 +128,15 @@ void Text_ChangeText(TEXTSTRING *textstring, const char *string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Text_SetPos(TEXTSTRING *textstring, int16_t x, int16_t y)
|
||||||
|
{
|
||||||
|
if (!textstring) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
textstring->pos.x = x;
|
||||||
|
textstring->pos.y = y;
|
||||||
|
}
|
||||||
|
|
||||||
void Text_SetScale(TEXTSTRING *textstring, int32_t scale_h, int32_t scale_v)
|
void Text_SetScale(TEXTSTRING *textstring, int32_t scale_h, int32_t scale_v)
|
||||||
{
|
{
|
||||||
if (!textstring) {
|
if (!textstring) {
|
||||||
|
@ -150,6 +160,14 @@ void Text_Flash(TEXTSTRING *textstring, bool enable, int16_t rate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Text_Hide(TEXTSTRING *textstring, bool enable)
|
||||||
|
{
|
||||||
|
if (!textstring) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
textstring->flags.hide = enable;
|
||||||
|
}
|
||||||
|
|
||||||
void Text_AddBackground(
|
void Text_AddBackground(
|
||||||
TEXTSTRING *textstring, int16_t w, int16_t h, int16_t x, int16_t y)
|
TEXTSTRING *textstring, int16_t w, int16_t h, int16_t x, int16_t y)
|
||||||
{
|
{
|
||||||
|
@ -291,6 +309,11 @@ void Text_Draw()
|
||||||
static void Text_DrawText(TEXTSTRING *textstring)
|
static void Text_DrawText(TEXTSTRING *textstring)
|
||||||
{
|
{
|
||||||
int sx, sy, sh, sv;
|
int sx, sy, sh, sv;
|
||||||
|
|
||||||
|
if (textstring->flags.hide) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (textstring->flags.flash) {
|
if (textstring->flags.flash) {
|
||||||
textstring->flash.count -= (int16_t)g_Camera.number_frames;
|
textstring->flash.count -= (int16_t)g_Camera.number_frames;
|
||||||
if (textstring->flash.count <= -textstring->flash.rate) {
|
if (textstring->flash.count <= -textstring->flash.rate) {
|
||||||
|
@ -336,6 +359,8 @@ static void Text_DrawText(TEXTSTRING *textstring)
|
||||||
int32_t sprite_num = letter;
|
int32_t sprite_num = letter;
|
||||||
if (letter >= 16) {
|
if (letter >= 16) {
|
||||||
sprite_num = m_TextASCIIMap[letter - 32];
|
sprite_num = m_TextASCIIMap[letter - 32];
|
||||||
|
} else if (letter == '\t') {
|
||||||
|
sprite_num = RIGHT_ARROW_SYM;
|
||||||
} else if (letter >= 11) {
|
} else if (letter >= 11) {
|
||||||
sprite_num = letter + 91;
|
sprite_num = letter + 91;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -10,8 +10,10 @@
|
||||||
void Text_Init();
|
void Text_Init();
|
||||||
TEXTSTRING *Text_Create(int16_t x, int16_t y, const char *string);
|
TEXTSTRING *Text_Create(int16_t x, int16_t y, const char *string);
|
||||||
void Text_ChangeText(TEXTSTRING *textstring, const char *string);
|
void Text_ChangeText(TEXTSTRING *textstring, const char *string);
|
||||||
|
void Text_SetPos(TEXTSTRING *textstring, int16_t x, int16_t y);
|
||||||
void Text_SetScale(TEXTSTRING *textstring, int32_t scale_h, int32_t scale_v);
|
void Text_SetScale(TEXTSTRING *textstring, int32_t scale_h, int32_t scale_v);
|
||||||
void Text_Flash(TEXTSTRING *textstring, bool enable, int16_t rate);
|
void Text_Flash(TEXTSTRING *textstring, bool enable, int16_t rate);
|
||||||
|
void Text_Hide(TEXTSTRING *textstring, bool enable);
|
||||||
void Text_AddBackground(
|
void Text_AddBackground(
|
||||||
TEXTSTRING *textstring, int16_t w, int16_t h, int16_t x, int16_t y);
|
TEXTSTRING *textstring, int16_t w, int16_t h, int16_t x, int16_t y);
|
||||||
void Text_RemoveBackground(TEXTSTRING *textstring);
|
void Text_RemoveBackground(TEXTSTRING *textstring);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue