mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 09:54:10 +03:00
Refactor text box contents to not use a separate length-tracker
This removes the variable numlines from each text box object, in favor of using line.size().
This commit is contained in:
@@ -9,17 +9,10 @@ textboxclass::textboxclass()
|
||||
void textboxclass::firstcreate()
|
||||
{
|
||||
//Like clear, only it creates the actual arrays, etc
|
||||
for (int iter = 0; iter < 10; iter++)
|
||||
{
|
||||
std::string t;
|
||||
t = "";
|
||||
line.push_back(t);
|
||||
}
|
||||
x = 0;
|
||||
y = 0;
|
||||
w = 0;
|
||||
h = 0;
|
||||
numlines = 0;
|
||||
lw = 0;
|
||||
tl = 0;
|
||||
tm = 0;
|
||||
@@ -29,15 +22,11 @@ void textboxclass::firstcreate()
|
||||
void textboxclass::clear()
|
||||
{
|
||||
//Set all values to a default, required for creating a new entity
|
||||
for (size_t iter = 0; iter < line.size(); iter++)
|
||||
{
|
||||
line[iter]="";
|
||||
}
|
||||
line.resize(1);
|
||||
xp = 0;
|
||||
yp = 0;
|
||||
w = 0;
|
||||
h = 0;
|
||||
numlines = 1;
|
||||
lw = 0;
|
||||
tl = 0;
|
||||
tm = 0;
|
||||
@@ -130,7 +119,7 @@ void textboxclass::resize()
|
||||
{
|
||||
//Set the width and height to the correct sizes
|
||||
max = 0;
|
||||
for (int iter = 0; iter < numlines; iter++)
|
||||
for (size_t iter = 0; iter < line.size(); iter++)
|
||||
{
|
||||
unsigned int len = utf8::unchecked::distance(line[iter].begin(), line[iter].end());
|
||||
if (len > (unsigned int)max) max = len;
|
||||
@@ -138,7 +127,7 @@ void textboxclass::resize()
|
||||
|
||||
lw = max;
|
||||
w = (max +2) * 8;
|
||||
h = (numlines + 2) * 8;
|
||||
h = (line.size() + 2) * 8;
|
||||
textrect.x = xp;
|
||||
textrect.y = yp;
|
||||
textrect.w = w;
|
||||
@@ -147,8 +136,7 @@ void textboxclass::resize()
|
||||
|
||||
void textboxclass::addline(std::string t)
|
||||
{
|
||||
line[numlines] = t;
|
||||
numlines++;
|
||||
line.push_back(t);
|
||||
resize();
|
||||
if (numlines >= 12) numlines = 0;
|
||||
if ((int) line.size() >= 12) line.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user