void Manual::run() { eng->renderer->clearScreen(); string str; int topElement = 0; int btmElement = min(topElement + MAP_Y_CELLS - 1, int(lines.size()) - 1); drawManualInterface(); int yCell = 2; for(int i = topElement; i <= btmElement; i++) { eng->renderer->drawText(lines.at(i), renderArea_screen, 1, yCell, clrWhite); yCell++; } eng->renderer->updateScreen(); //Read keys bool done = false; while(done == false) { const KeyboardReadReturnData& d = eng->input->readKeysUntilFound(); if(d.key_ == '2' || d.sdlKey_ == SDLK_DOWN) { topElement = max(0, min(topElement + 3, int(lines.size()) - int(MAP_Y_CELLS))); btmElement = min(topElement + MAP_Y_CELLS - 1, int(lines.size()) - 1); eng->renderer->coverArea(renderArea_screen, 0, 2, MAP_X_CELLS, MAP_Y_CELLS); drawManualInterface(); yCell = 2; for(int i = topElement; i <= btmElement; i++) { eng->renderer->drawText(lines.at(i), renderArea_screen, 1, yCell, clrWhite); yCell++; } eng->renderer->updateScreen(); } else if(d.key_ == '8' || d.sdlKey_ == SDLK_UP) { topElement = max(0, min(topElement - 3, int(lines.size()) - int(MAP_Y_CELLS))); btmElement = min(topElement + MAP_Y_CELLS - 1, int(lines.size()) - 1); eng->renderer->coverArea(renderArea_screen, 0, 2, MAP_X_CELLS, MAP_Y_CELLS); drawManualInterface(); yCell = 2; for(int i = topElement; i <= btmElement; i++) { eng->renderer->drawText(lines.at(i), renderArea_screen, 1, yCell, clrWhite); yCell++; } eng->renderer->updateScreen(); } else if(d.sdlKey_ == SDLK_SPACE || d.sdlKey_ == SDLK_ESCAPE) { done = true; } } eng->renderer->coverRenderArea(renderArea_screen); }
void Manual::run() { const int LINE_JUMP = 3; const int NR_LINES_TOT = lines.size(); const int MAX_NR_LINES_ON_SCR = SCREEN_H - 2; int topNr = 0; int btmNr = min(topNr + MAX_NR_LINES_ON_SCR - 1, NR_LINES_TOT - 1); while(true) { Renderer::clearScreen(); drawManualInterface(); int yPos = 1; for(int i = topNr; i <= btmNr; i++) { Renderer::drawText(lines.at(i), Panel::screen, Pos(0, yPos++), clrWhite); } Renderer::updateScreen(); const KeyboardReadRetData& d = Input::readKeysUntilFound(eng); if(d.key_ == '2' || d.sdlKey_ == SDLK_DOWN || d.key_ == 'j') { topNr += LINE_JUMP; if(NR_LINES_TOT <= MAX_NR_LINES_ON_SCR) { topNr = 0; } else { topNr = min(NR_LINES_TOT - MAX_NR_LINES_ON_SCR, topNr); } } else if(d.key_ == '8' || d.sdlKey_ == SDLK_UP || d.key_ == 'k') { topNr = max(0, topNr - LINE_JUMP); } else if(d.sdlKey_ == SDLK_SPACE || d.sdlKey_ == SDLK_ESCAPE) { break; } btmNr = min(topNr + MAX_NR_LINES_ON_SCR - 1, NR_LINES_TOT - 1); } }