diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index d90e31f1..01a4947d 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -591,14 +591,14 @@ void Graphics::drawgui() { if(flipmode) { - for (j = 0; j < textbox[i].numlines; j++) + for (j = 0; j < (int) textbox[i].line.size(); j++) { - Print(textbox[i].xp + 8, textbox[i].yp + (textbox[i].numlines*8) - (j * 8), textbox[i].line[j], 196, 196, 255 - help.glow); + Print(textbox[i].xp + 8, textbox[i].yp + (textbox[i].line.size()*8) - (j * 8), textbox[i].line[j], 196, 196, 255 - help.glow); } } else { - for (j = 0; j < textbox[i].numlines; j++) + for (j = 0; j < (int) textbox[i].line.size(); j++) { Print(textbox[i].xp + 8, textbox[i].yp + 8 + (j * 8), textbox[i].line[j], 196, 196, 255 - help.glow); } @@ -618,7 +618,7 @@ void Graphics::drawgui() 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); } - for (int k = 0; k < textbox[i].numlines; k++) + 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); @@ -626,14 +626,14 @@ void Graphics::drawgui() if(flipmode) { - for (j = 0; j < textbox[i].numlines; j++) + for (j = 0; j < (int) textbox[i].line.size(); j++) { - Print(textbox[i].xp + 8, textbox[i].yp + (textbox[i].numlines*8) - (j * 8), textbox[i].line[j], textbox[i].r, textbox[i].g, textbox[i].b); + Print(textbox[i].xp + 8, textbox[i].yp + (textbox[i].line.size()*8) - (j * 8), textbox[i].line[j], textbox[i].r, textbox[i].g, textbox[i].b); } } else { - for (j = 0; j < textbox[i].numlines; j++) + for (j = 0; j < (int) textbox[i].line.size(); j++) { Print(textbox[i].xp + 8, textbox[i].yp +8 + (j * 8), textbox[i].line[j], textbox[i].r, textbox[i].g, textbox[i].b); } @@ -1008,8 +1008,7 @@ void Graphics::createtextbox( std::string t, int xp, int yp, int r/*= 255*/, int if(m<20) { textboxclass text; - text.clear(); - text.line[0] = t; + text.line.push_back(t); text.xp = xp; int length = utf8::unchecked::distance(t.begin(), t.end()); if (xp == -1) text.xp = 160 - (((length / 2) + 1) * 8); diff --git a/desktop_version/src/Textbox.cpp b/desktop_version/src/Textbox.cpp index 30861000..3b9234dc 100644 --- a/desktop_version/src/Textbox.cpp +++ b/desktop_version/src/Textbox.cpp @@ -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(); } diff --git a/desktop_version/src/Textbox.h b/desktop_version/src/Textbox.h index 71490f7e..79657f23 100644 --- a/desktop_version/src/Textbox.h +++ b/desktop_version/src/Textbox.h @@ -36,7 +36,7 @@ public: public: //Fundamentals std::vector line; - int xp, yp, lw, w, h, numlines; + int xp, yp, lw, w, h; int x,y; int r,g,b; int tr,tg,tb;