X-Git-Url: https://git.jsancho.org/?p=lugaru.git;a=blobdiff_plain;f=Source%2FGameDraw.cpp;h=de4d97d37926a04e4ddd725f26a8684651f41c43;hp=a24df6970c9e94e12155f46edc62130b19507cda;hb=762fb78d53f8be2003944fbdcc84f87e7851f453;hpb=b9a46d8e2b7e7e22c706e7dd3734f31015db4408 diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index a24df69..de4d97d 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2003, 2010 - Wolfire Games -Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file) +Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file) This file is part of Lugaru. @@ -597,7 +597,7 @@ int Game::DrawGLScene(StereoSide side) } text->glPrintOutlined(1, 0, 0, 1 - bonustime, 1024 / 2 - 10 * strlen(bonus_name), 768 / 16 + 768 * 4 / 5, bonus_name, 1, 2, 1024, 768); - string = to_string((int)bonusvalue); + string = to_string(bonusvalue); text->glPrintOutlined(1, 0, 0, 1 - bonustime, 1024 / 2 - 10 * string.size(), 768 / 16 - 20 + 768 * 4 / 5, string, 1, 2 * .8, 1024, 768); glColor4f(.5, .5, .5, 1); @@ -664,6 +664,7 @@ int Game::DrawGLScene(StereoSide side) } } + /* Drawing dialogs */ if (Dialog::inDialog() && !mainmenu) { glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); @@ -713,41 +714,23 @@ int Game::DrawGLScene(StereoSide side) starty = screenheight * 1 / 5 - screenheight / 16; } - // FIXME - What is that char[] building for? - char tempname[264]; - int tempnum = 0; - for (int i = 0; i < 264; i++) { - tempname[i] = '\0'; - } - - for (unsigned i = 0; i < Dialog::currentScene().name.size(); i++) { - tempname[tempnum] = Dialog::currentScene().name[i]; - if (tempname[tempnum] == '#' || tempname[tempnum] == '\0') { - tempname[tempnum] = '\0'; - } else { - tempnum++; - } - } - - string = std::string(tempname) + ": "; + /* Get speaker name, and remove potential '#' chars hardcoded in it. */ + string = Dialog::currentScene().name + ": "; + string.erase(std::remove(string.begin(), string.end(), '#'), string.end()); + /* Print speaker name in dialog box. */ if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) { - text->glPrintOutlined(0.7, 0.7, 0.7, tutorialopac, startx - 2 * 7.6 * string.size() * screenwidth / 1024, starty, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight); + text->glPrintOutlined(0.7, 0.7, 0.7, tutorialopac, startx - 2 * 7.6 * string.size() * screenwidth / 1024, starty, string, 1, 1.4 * screenwidth / 1024, screenwidth, screenheight); } else { glColor4f(0, 0, 0, tutorialopac); - text->glPrintOutline(startx - 2 * 7.6 * string.size() * screenwidth / 1024 - 4, starty - 4, string, 1, 1.5 * 1.25 * screenwidth / 1024, screenwidth, screenheight); - } - - tempnum = 0; - for (unsigned i = 0; i < Dialog::currentScene().text.size() + 1; i++) { - tempname[tempnum] = Dialog::currentScene().text[i]; - if (Dialog::currentScene().text[i] != '#') { - tempnum++; - } + text->glPrintOutline(startx - 2 * 7.6 * string.size() * screenwidth / 1024 - 4, starty - 4, string, 1, 1.4 * 1.25 * screenwidth / 1024, screenwidth, screenheight); } - string = tempname; + /* Get dialog text, and remove potential '#' chars hardcoded in it.' */ + string = Dialog::currentScene().text; + string.erase(std::remove(string.begin(), string.end(), '#'), string.end()); + /* Print dialog text in dialog box. */ int lastline = 0; int line = 0; bool done = false; @@ -755,10 +738,10 @@ int Game::DrawGLScene(StereoSide side) while (!done) { if (string[i] == '\n' || string[i] > 'z' || string[i] < ' ' || string[i] == '\0') { if (Dialog::currentScene().color[0] + Dialog::currentScene().color[1] + Dialog::currentScene().color[2] < 1.5) { - text->glPrintOutlined(1, 1, 1, tutorialopac, startx, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i); + text->glPrintOutlined(1, 1, 1, tutorialopac, startx, starty - 20 * screenwidth / 1024 * line, string, 1, 1.4 * screenwidth / 1024, screenwidth, screenheight, lastline, i); } else { glColor4f(0, 0, 0, tutorialopac); - text->glPrint(startx, starty - 20 * screenwidth / 1024 * line, string, 1, 1.5 * screenwidth / 1024, screenwidth, screenheight, lastline, i); + text->glPrint(startx, starty - 20 * screenwidth / 1024 * line, string, 1, 1.4 * screenwidth / 1024, screenwidth, screenheight, lastline, i); } lastline = i + 1; line++;