mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 10:29:45 +01:00
Add flipme attribute to textboxclass
Instead of calculating the y-position of the text box when it's created, we will store a flag that says whether or not the text box should be flipped in Flip Mode (and thus stay right-side-up), and when it comes time to draw the text box, we will check Flip Mode and calculate the position then.
This commit is contained in:
parent
2ac13815e4
commit
1a9f2d9342
3 changed files with 22 additions and 11 deletions
|
@ -833,6 +833,7 @@ void Graphics::drawgui(void)
|
|||
for (size_t i = 0; i<textbox.size(); i++)
|
||||
{
|
||||
int text_yoff;
|
||||
int yp;
|
||||
if (flipmode)
|
||||
{
|
||||
text_yoff = textbox[i].line.size() * 8;
|
||||
|
@ -842,6 +843,12 @@ void Graphics::drawgui(void)
|
|||
text_yoff = 8;
|
||||
}
|
||||
|
||||
yp = textbox[i].yp;
|
||||
if (flipmode && textbox[i].flipme)
|
||||
{
|
||||
yp += 2 * (120 - yp) - 8 * (textbox[i].line.size() + 2);
|
||||
}
|
||||
|
||||
//This routine also updates textbox colors
|
||||
float tl_lerp = lerp(textbox[i].prev_tl, textbox[i].tl);
|
||||
textbox[i].setcol(textbox[i].tr * tl_lerp, textbox[i].tg * tl_lerp, textbox[i].tb * tl_lerp);
|
||||
|
@ -850,33 +857,33 @@ void Graphics::drawgui(void)
|
|||
{
|
||||
for (size_t j = 0; j < textbox[i].line.size(); j++)
|
||||
{
|
||||
Print(textbox[i].xp + 8, textbox[i].yp + text_yoff + text_sign * (j * 8), textbox[i].line[j], 196, 196, 255 - help.glow);
|
||||
Print(textbox[i].xp + 8, yp + text_yoff + text_sign * (j * 8), textbox[i].line[j], 196, 196, 255 - help.glow);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_Rect textrect = {textbox[i].xp, textbox[i].yp, textbox[i].w, textbox[i].h};
|
||||
SDL_Rect textrect = {textbox[i].xp, yp, textbox[i].w, textbox[i].h};
|
||||
|
||||
FillRect(backBuffer, textrect, textbox[i].r/6, textbox[i].g/6, textbox[i].b / 6 );
|
||||
|
||||
drawcoloredtile(textbox[i].xp, textbox[i].yp, 40, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp+textbox[i].w-8, textbox[i].yp, 42, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp, textbox[i].yp+textbox[i].h-8, 45, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp+textbox[i].w-8, textbox[i].yp+textbox[i].h-8, 47, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp, yp, 40, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp+textbox[i].w-8, yp, 42, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp, yp+textbox[i].h-8, 45, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp+textbox[i].w-8, yp+textbox[i].h-8, 47, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
for (int k = 0; k < textbox[i].lw; k++)
|
||||
{
|
||||
drawcoloredtile(textbox[i].xp + 8 + (k * 8), textbox[i].yp, 41, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp + 8 + (k * 8), textbox[i].yp+textbox[i].h-8, 46, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp + 8 + (k * 8), yp, 41, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp + 8 + (k * 8), yp+textbox[i].h-8, 46, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
}
|
||||
for (size_t k = 0; k < textbox[i].line.size(); k++)
|
||||
{
|
||||
drawcoloredtile(textbox[i].xp, textbox[i].yp + 8 + (k * 8), 43, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp + textbox[i].w-8, textbox[i].yp + 8 + (k * 8), 44, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp, yp + 8 + (k * 8), 43, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
drawcoloredtile(textbox[i].xp + textbox[i].w-8, yp + 8 + (k * 8), 44, textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < textbox[i].line.size(); j++)
|
||||
{
|
||||
Print(textbox[i].xp + 8, textbox[i].yp + text_yoff + text_sign * (j * 8), textbox[i].line[j], textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
Print(textbox[i].xp + 8, yp + text_yoff + text_sign * (j * 8), textbox[i].line[j], textbox[i].r, textbox[i].g, textbox[i].b);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ textboxclass::textboxclass(void)
|
|||
tg = 0;
|
||||
tb = 0;
|
||||
max = 0;
|
||||
|
||||
flipme = false;
|
||||
}
|
||||
|
||||
void textboxclass::centerx(void)
|
||||
|
|
|
@ -43,6 +43,8 @@ public:
|
|||
|
||||
int max;
|
||||
|
||||
/* Whether to flip text box y-position in Flip Mode. */
|
||||
bool flipme;
|
||||
};
|
||||
|
||||
#endif /* TEXTBOX_H */
|
||||
|
|
Loading…
Reference in a new issue