mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 10:09:43 +01:00
Textboxes: Don't use separate RGB variables
Text boxes have `r`, `g`, and `b`, and `tr`, `tg`, and `tb`. `tr`, `tg`, and `tb` are the real colors of the text box, and `r`, `g`, and `b` are merely the colors of the text box as the text box's alpha value is applied to them. Compare this with, say, activity zones (which are drawn like text boxes but aren't text boxes): There is `activity_r`, `activity_g`, and `activity_b`, and when they're drawn they're all multiplied by `act_alpha`. So just do the same thing here. Ditch the `tr`, `tg`, and `tb` variables, and make `r`, `g`, and `b` the new `tr`, `tg`, and `tb` variables. That way, there's simply less state to have to update separately. So we can get rid of `textboxclass::setcol()` as well.
This commit is contained in:
parent
13a0c1282d
commit
730c935218
3 changed files with 20 additions and 36 deletions
|
@ -1002,11 +1002,7 @@ void Graphics::drawgui(void)
|
||||||
yp += 2 * (120 - yp) - 8 * (textbox[i].line.size() + 2);
|
yp += 2 * (120 - yp) - 8 * (textbox[i].line.size() + 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//This routine also updates textbox colors
|
if (textbox[i].r == 0 && textbox[i].g == 0 && textbox[i].b == 0)
|
||||||
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].tr == 0 && textbox[i].tg == 0 && textbox[i].tb == 0)
|
|
||||||
{
|
{
|
||||||
size_t j;
|
size_t j;
|
||||||
for (j = 0; j < textbox[i].line.size(); j++)
|
for (j = 0; j < textbox[i].line.size(); j++)
|
||||||
|
@ -1016,13 +1012,17 @@ void Graphics::drawgui(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const float tl_lerp = lerp(textbox[i].prev_tl, textbox[i].tl);
|
||||||
|
const int r = textbox[i].r * tl_lerp;
|
||||||
|
const int g = textbox[i].g * tl_lerp;
|
||||||
|
const int b = textbox[i].b * tl_lerp;
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
drawtextbox(textbox[i].xp, yp, textbox[i].w/8, textbox[i].h/8, textbox[i].r, textbox[i].g, textbox[i].b);
|
drawtextbox(textbox[i].xp, yp, textbox[i].w/8, textbox[i].h/8, r, g, b);
|
||||||
|
|
||||||
for (j = 0; j < textbox[i].line.size(); j++)
|
for (j = 0; j < textbox[i].line.size(); j++)
|
||||||
{
|
{
|
||||||
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);
|
Print(textbox[i].xp + 8, yp + text_yoff + text_sign * (j * 8), textbox[i].line[j], r, g, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1033,7 +1033,7 @@ void Graphics::drawgui(void)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textbox[i].yp == 12 && textbox[i].tr == 165)
|
if (textbox[i].yp == 12 && textbox[i].r == 165)
|
||||||
{
|
{
|
||||||
if (flipmode)
|
if (flipmode)
|
||||||
{
|
{
|
||||||
|
@ -1044,7 +1044,7 @@ void Graphics::drawgui(void)
|
||||||
drawimage(0, 0, 12, true);
|
drawimage(0, 0, 12, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (textbox[i].yp == 12 && textbox[i].tg == 165)
|
else if (textbox[i].yp == 12 && textbox[i].g == 165)
|
||||||
{
|
{
|
||||||
if (flipmode)
|
if (flipmode)
|
||||||
{
|
{
|
||||||
|
@ -1055,27 +1055,27 @@ void Graphics::drawgui(void)
|
||||||
drawimage(4, 0, 12, true);
|
drawimage(4, 0, 12, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (textbox[i].tr == 175 && textbox[i].tg == 175)
|
if (textbox[i].r == 175 && textbox[i].g == 175)
|
||||||
{
|
{
|
||||||
//purple guy
|
//purple guy
|
||||||
drawsprite(80 - 6, crew_yp, crew_sprite, 220- help.glow/4 - textbox[i].rand, 120- help.glow/4, 210 - help.glow/4);
|
drawsprite(80 - 6, crew_yp, crew_sprite, 220- help.glow/4 - textbox[i].rand, 120- help.glow/4, 210 - help.glow/4);
|
||||||
}
|
}
|
||||||
else if (textbox[i].tr == 175 && textbox[i].tb == 175)
|
else if (textbox[i].r == 175 && textbox[i].b == 175)
|
||||||
{
|
{
|
||||||
//red guy
|
//red guy
|
||||||
drawsprite(80 - 6, crew_yp, crew_sprite, 255 - help.glow/8, 70 - help.glow/4, 70 - help.glow / 4);
|
drawsprite(80 - 6, crew_yp, crew_sprite, 255 - help.glow/8, 70 - help.glow/4, 70 - help.glow / 4);
|
||||||
}
|
}
|
||||||
else if (textbox[i].tr == 175)
|
else if (textbox[i].r == 175)
|
||||||
{
|
{
|
||||||
//green guy
|
//green guy
|
||||||
drawsprite(80 - 6, crew_yp, crew_sprite, 120 - help.glow / 4 - textbox[i].rand, 220 - help.glow / 4, 120 - help.glow / 4);
|
drawsprite(80 - 6, crew_yp, crew_sprite, 120 - help.glow / 4 - textbox[i].rand, 220 - help.glow / 4, 120 - help.glow / 4);
|
||||||
}
|
}
|
||||||
else if (textbox[i].tg == 175)
|
else if (textbox[i].g == 175)
|
||||||
{
|
{
|
||||||
//yellow guy
|
//yellow guy
|
||||||
drawsprite(80 - 6, crew_yp, crew_sprite, 220- help.glow/4 - textbox[i].rand, 210 - help.glow/4, 120- help.glow/4);
|
drawsprite(80 - 6, crew_yp, crew_sprite, 220- help.glow/4 - textbox[i].rand, 210 - help.glow/4, 120- help.glow/4);
|
||||||
}
|
}
|
||||||
else if (textbox[i].tb == 175)
|
else if (textbox[i].b == 175)
|
||||||
{
|
{
|
||||||
//blue guy
|
//blue guy
|
||||||
drawsprite(80 - 6, crew_yp, crew_sprite, 75, 75, 255- help.glow/4 - textbox[i].rand);
|
drawsprite(80 - 6, crew_yp, crew_sprite, 75, 75, 255- help.glow/4 - textbox[i].rand);
|
||||||
|
@ -1097,11 +1097,11 @@ void Graphics::updatetextboxes(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textbox[i].tl >= 1.0f
|
if (textbox[i].tl >= 1.0f
|
||||||
&& ((textbox[i].tr == 175 && textbox[i].tg == 175)
|
&& ((textbox[i].r == 175 && textbox[i].g == 175)
|
||||||
|| textbox[i].tr == 175
|
|| textbox[i].r == 175
|
||||||
|| textbox[i].tg == 175
|
|| textbox[i].g == 175
|
||||||
|| textbox[i].tb == 175)
|
|| textbox[i].b == 175)
|
||||||
&& (textbox[i].tr != 175 || textbox[i].tb != 175))
|
&& (textbox[i].r != 175 || textbox[i].b != 175))
|
||||||
{
|
{
|
||||||
textbox[i].rand = fRandom() * 20;
|
textbox[i].rand = fRandom() * 20;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,6 @@ textboxclass::textboxclass(void)
|
||||||
r = 0;
|
r = 0;
|
||||||
g = 0;
|
g = 0;
|
||||||
b = 0;
|
b = 0;
|
||||||
tr = 0;
|
|
||||||
tg = 0;
|
|
||||||
tb = 0;
|
|
||||||
|
|
||||||
flipme = false;
|
flipme = false;
|
||||||
|
|
||||||
|
@ -49,21 +46,11 @@ void textboxclass::adjust(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void textboxclass::initcol(int rr, int gg, int bb)
|
void textboxclass::initcol(int rr, int gg, int bb)
|
||||||
{
|
|
||||||
tr = rr;
|
|
||||||
tg = gg;
|
|
||||||
tb = bb;
|
|
||||||
r = 0;
|
|
||||||
g = 0;
|
|
||||||
b = 0;
|
|
||||||
tl = 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
void textboxclass::setcol(int rr, int gg, int bb)
|
|
||||||
{
|
{
|
||||||
r = rr;
|
r = rr;
|
||||||
g = gg;
|
g = gg;
|
||||||
b = bb;
|
b = bb;
|
||||||
|
tl = 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void textboxclass::update(void)
|
void textboxclass::update(void)
|
||||||
|
|
|
@ -17,8 +17,6 @@ public:
|
||||||
|
|
||||||
void initcol(int rr, int gg, int bb);
|
void initcol(int rr, int gg, int bb);
|
||||||
|
|
||||||
void setcol(int rr, int gg, int bb);
|
|
||||||
|
|
||||||
void update(void);
|
void update(void);
|
||||||
|
|
||||||
void remove(void);
|
void remove(void);
|
||||||
|
@ -33,7 +31,6 @@ public:
|
||||||
std::vector<std::string> line;
|
std::vector<std::string> line;
|
||||||
int xp, yp, w, h;
|
int xp, yp, w, h;
|
||||||
int r,g,b;
|
int r,g,b;
|
||||||
int tr,tg,tb;
|
|
||||||
int timer;
|
int timer;
|
||||||
|
|
||||||
float tl;
|
float tl;
|
||||||
|
|
Loading…
Reference in a new issue