mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
Interpolate text box alpha
This makes text boxes fade in and out pretty smoothly. This requires that the textboxclass::setcol() be in Graphics::drawgui(), so now it's moved there. Text box fading is only really noticeable if you're playing in slowmode.
This commit is contained in:
parent
4ba9954eb8
commit
c56df48d75
3 changed files with 7 additions and 2 deletions
|
@ -609,6 +609,10 @@ void Graphics::drawgui()
|
||||||
//Draw all the textboxes to the screen
|
//Draw all the textboxes to the screen
|
||||||
for (size_t i = 0; i<textbox.size(); i++)
|
for (size_t i = 0; i<textbox.size(); i++)
|
||||||
{
|
{
|
||||||
|
//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);
|
||||||
|
|
||||||
if (textbox[i].r == 0 && textbox[i].g == 0 && textbox[i].b == 0)
|
if (textbox[i].r == 0 && textbox[i].g == 0 && textbox[i].b == 0)
|
||||||
{
|
{
|
||||||
if(flipmode)
|
if(flipmode)
|
||||||
|
|
|
@ -9,6 +9,7 @@ textboxclass::textboxclass()
|
||||||
h = 0;
|
h = 0;
|
||||||
lw = 0;
|
lw = 0;
|
||||||
tl = 0;
|
tl = 0;
|
||||||
|
prev_tl = 0;
|
||||||
tm = 0;
|
tm = 0;
|
||||||
timer = 0;
|
timer = 0;
|
||||||
}
|
}
|
||||||
|
@ -56,6 +57,7 @@ void textboxclass::setcol(int rr, int gg, int bb)
|
||||||
|
|
||||||
void textboxclass::update()
|
void textboxclass::update()
|
||||||
{
|
{
|
||||||
|
prev_tl = tl;
|
||||||
if (tm == 0)
|
if (tm == 0)
|
||||||
{
|
{
|
||||||
tl += .1f;
|
tl += .1f;
|
||||||
|
@ -64,7 +66,6 @@ void textboxclass::update()
|
||||||
tl = 1;
|
tl = 1;
|
||||||
tm = 1;
|
tm = 1;
|
||||||
}
|
}
|
||||||
setcol(int(tr * tl), int(tg * tl), int(tb * tl));
|
|
||||||
}
|
}
|
||||||
else if (tm == 2)
|
else if (tm == 2)
|
||||||
{
|
{
|
||||||
|
@ -74,7 +75,6 @@ void textboxclass::update()
|
||||||
tl = 0.5;
|
tl = 0.5;
|
||||||
//this textbox will be removed by updatetextboxes() later
|
//this textbox will be removed by updatetextboxes() later
|
||||||
}
|
}
|
||||||
setcol(int(tr * tl), int(tg * tl), int(tb * tl));
|
|
||||||
}
|
}
|
||||||
if (timer > 0)
|
if (timer > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
int timer;
|
int timer;
|
||||||
|
|
||||||
float tl;
|
float tl;
|
||||||
|
float prev_tl;
|
||||||
int tm;
|
int tm;
|
||||||
|
|
||||||
int max;
|
int max;
|
||||||
|
|
Loading…
Reference in a new issue