mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 09:28:15 +03:00
Refactor text boxes to not use the 'active' system
This removes the variables graphics.ntextbox, as well as removing 'active' from each text box object. Thus, all text boxes are really real, and you don't have to check its 'active' variable.
This commit is contained in:
@@ -85,10 +85,6 @@ void Graphics::init()
|
|||||||
menuoffset = 0;
|
menuoffset = 0;
|
||||||
resumegamemode = false;
|
resumegamemode = false;
|
||||||
|
|
||||||
//Textboxes!
|
|
||||||
textbox.resize(30);
|
|
||||||
ntextbox = 0;
|
|
||||||
|
|
||||||
//Fading stuff
|
//Fading stuff
|
||||||
fadebars.resize(15);
|
fadebars.resize(15);
|
||||||
|
|
||||||
@@ -580,15 +576,17 @@ void Graphics::drawgui()
|
|||||||
{
|
{
|
||||||
textboxcleanup();
|
textboxcleanup();
|
||||||
//Draw all the textboxes to the screen
|
//Draw all the textboxes to the screen
|
||||||
for (int i = 0; i<ntextbox; i++)
|
for (size_t i = 0; i<textbox.size(); i++)
|
||||||
{
|
{
|
||||||
//This routine also updates the textboxs
|
//This routine also updates the textboxs
|
||||||
textbox[i].update();
|
textbox[i].update();
|
||||||
if (textbox[i].active)
|
if (true) //FIXME: remove this later (no more 'active')
|
||||||
{
|
{
|
||||||
if (textbox[i].tm == 2 && textbox[i].tl <= 0.5)
|
if (textbox[i].tm == 2 && textbox[i].tl <= 0.5)
|
||||||
{
|
{
|
||||||
textbox[i].active = false;
|
textbox.erase(textbox.begin() + i);
|
||||||
|
i--;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
@@ -966,7 +964,7 @@ void Graphics::drawtextbox( int x, int y, int w, int h, int r, int g, int b )
|
|||||||
void Graphics::textboxactive()
|
void Graphics::textboxactive()
|
||||||
{
|
{
|
||||||
//Remove all but the most recent textbox
|
//Remove all but the most recent textbox
|
||||||
for (int i = 0; i < ntextbox; i++)
|
for (int i = 0; i < (int) textbox.size(); i++)
|
||||||
{
|
{
|
||||||
if (m != i) textbox[i].remove();
|
if (m != i) textbox[i].remove();
|
||||||
}
|
}
|
||||||
@@ -975,7 +973,7 @@ void Graphics::textboxactive()
|
|||||||
void Graphics::textboxremovefast()
|
void Graphics::textboxremovefast()
|
||||||
{
|
{
|
||||||
//Remove all textboxes
|
//Remove all textboxes
|
||||||
for (int i = 0; i < ntextbox; i++)
|
for (size_t i = 0; i < textbox.size(); i++)
|
||||||
{
|
{
|
||||||
textbox[i].removefast();
|
textbox[i].removefast();
|
||||||
}
|
}
|
||||||
@@ -984,7 +982,7 @@ void Graphics::textboxremovefast()
|
|||||||
void Graphics::textboxremove()
|
void Graphics::textboxremove()
|
||||||
{
|
{
|
||||||
//Remove all textboxes
|
//Remove all textboxes
|
||||||
for (int i = 0; i < ntextbox; i++)
|
for (size_t i = 0; i < textbox.size(); i++)
|
||||||
{
|
{
|
||||||
textbox[i].remove();
|
textbox[i].remove();
|
||||||
}
|
}
|
||||||
@@ -1008,36 +1006,20 @@ void Graphics::textboxadjust()
|
|||||||
|
|
||||||
void Graphics::createtextbox( std::string t, int xp, int yp, int r/*= 255*/, int g/*= 255*/, int b /*= 255*/ )
|
void Graphics::createtextbox( std::string t, int xp, int yp, int r/*= 255*/, int g/*= 255*/, int b /*= 255*/ )
|
||||||
{
|
{
|
||||||
|
m = textbox.size();
|
||||||
if(ntextbox == 0)
|
|
||||||
{
|
|
||||||
//If there are no active textboxes, Z=0;
|
|
||||||
m = 0;
|
|
||||||
ntextbox++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/*i = 0; m = -1;
|
|
||||||
while (i < ntextbox) {
|
|
||||||
if (!textbox[i].active) { m = i; i = ntextbox;}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if (m == -1) {m = ntextbox; ntextbox++;}
|
|
||||||
*/
|
|
||||||
m = ntextbox;
|
|
||||||
ntextbox++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(m<20)
|
if(m<20)
|
||||||
{
|
{
|
||||||
textbox[m].clear();
|
textboxclass text;
|
||||||
textbox[m].line[0] = t;
|
text.clear();
|
||||||
textbox[m].xp = xp;
|
text.line[0] = t;
|
||||||
|
text.xp = xp;
|
||||||
int length = utf8::unchecked::distance(t.begin(), t.end());
|
int length = utf8::unchecked::distance(t.begin(), t.end());
|
||||||
if (xp == -1) textbox[m].xp = 160 - (((length / 2) + 1) * 8);
|
if (xp == -1) text.xp = 160 - (((length / 2) + 1) * 8);
|
||||||
textbox[m].yp = yp;
|
text.yp = yp;
|
||||||
textbox[m].initcol(r, g, b);
|
text.initcol(r, g, b);
|
||||||
textbox[m].resize();
|
text.resize();
|
||||||
|
textbox.push_back(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2891,12 +2873,6 @@ void Graphics::setwarprect( int a, int b, int c, int d )
|
|||||||
|
|
||||||
void Graphics::textboxcleanup()
|
void Graphics::textboxcleanup()
|
||||||
{
|
{
|
||||||
int i = ntextbox - 1;
|
|
||||||
while (i >= 0 && !textbox[i].active)
|
|
||||||
{
|
|
||||||
ntextbox--;
|
|
||||||
i--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::textboxcenter()
|
void Graphics::textboxcenter()
|
||||||
|
|||||||
@@ -265,7 +265,6 @@ public:
|
|||||||
int trinketr, trinketg, trinketb;
|
int trinketr, trinketg, trinketb;
|
||||||
|
|
||||||
std::vector <textboxclass> textbox;
|
std::vector <textboxclass> textbox;
|
||||||
int ntextbox;
|
|
||||||
|
|
||||||
bool showcutscenebars;
|
bool showcutscenebars;
|
||||||
int cutscenebarspos;
|
int cutscenebarspos;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ void textboxclass::firstcreate()
|
|||||||
lw = 0;
|
lw = 0;
|
||||||
tl = 0;
|
tl = 0;
|
||||||
tm = 0;
|
tm = 0;
|
||||||
active = false;
|
|
||||||
timer = 0;
|
timer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +41,6 @@ void textboxclass::clear()
|
|||||||
lw = 0;
|
lw = 0;
|
||||||
tl = 0;
|
tl = 0;
|
||||||
tm = 0;
|
tm = 0;
|
||||||
active = true;
|
|
||||||
timer = 0;
|
timer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ public:
|
|||||||
int r,g,b;
|
int r,g,b;
|
||||||
int tr,tg,tb;
|
int tr,tg,tb;
|
||||||
SDL_Rect textrect;
|
SDL_Rect textrect;
|
||||||
bool active;
|
|
||||||
int timer;
|
int timer;
|
||||||
|
|
||||||
float tl;
|
float tl;
|
||||||
|
|||||||
Reference in New Issue
Block a user