diff --git a/source/glest_game/game/console.cpp b/source/glest_game/game/console.cpp index 395035c6..8a9deda2 100644 --- a/source/glest_game/game/console.cpp +++ b/source/glest_game/game/console.cpp @@ -31,6 +31,7 @@ namespace Glest{ namespace Game{ Console::Console(){ //config maxLines= Config::getInstance().getInt("ConsoleMaxLines"); + maxStoredLines= Config::getInstance().getInt("ConsoleMaxLinesStored"); timeout= Config::getInstance().getInt("ConsoleTimeout"); timeElapsed= 0.0f; @@ -50,6 +51,10 @@ void Console::addLine(string line, bool playSound){ if(lines.size()>maxLines){ lines.pop_back(); } + storedLines.insert(storedLines.begin(), StringTimePair(line, timeElapsed)); + if(storedLines.size()>maxStoredLines){ + storedLines.pop_back(); + } } catch(const exception &ex) { char szBuf[1024]=""; @@ -58,6 +63,12 @@ void Console::addLine(string line, bool playSound){ } } +void Console::clearStoredLines(){ + while(!storedLines.empty()){ + storedLines.pop_back(); + } +} + void Console::update(){ timeElapsed+= 1.f/GameConstants::updateFps; diff --git a/source/glest_game/game/console.h b/source/glest_game/game/console.h index 6de421f7..4e4d36a8 100644 --- a/source/glest_game/game/console.h +++ b/source/glest_game/game/console.h @@ -42,21 +42,25 @@ public: private: float timeElapsed; Lines lines; + Lines storedLines; //this should be deleted from here someday bool won, lost; //config int maxLines; + int maxStoredLines; float timeout; public: Console(); + int getStoredLineCount() const {return storedLines.size();} int getLineCount() const {return lines.size();} string getLine(int i) const { if(i < 0 || i >= lines.size()) throw runtime_error("i >= Lines.size()"); return lines[i].first;} + string getStoredLine(int i) const { if(i < 0 || i >= storedLines.size()) throw runtime_error("i >= storedLines.size()"); return storedLines[i].first;} - + void clearStoredLines(); void addStdMessage(const string &s); void addLine(string line, bool playSound= false); void update(); diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 22b4503d..f9214402 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -57,6 +57,7 @@ Game::Game(Program *program, const GameSettings *gameSettings): gameOver= false; renderNetworkStatus= false; speed= sNormal; + showFullConsole= false; } Game::~Game(){ @@ -236,6 +237,7 @@ void Game::init() world.init(this, gameSettings.getDefaultUnits()); gui.init(this); chatManager.init(&console, world.getThisTeamIndex()); + console.clearStoredLines(); const Vec2i &v= map->getStartLocation(world.getThisFaction()->getStartLocationIndex()); gameCamera.init(map->getW(), map->getH()); gameCamera.setPos(Vec2f(v.x, v.y)); @@ -597,6 +599,9 @@ void Game::keyDown(char key){ if(key=='N'){ renderNetworkStatus= true; } + else if(key=='M'){ + showFullConsole= true; + } else if(key=='E'){ for(int i=0; i<100; ++i){ string path= "screens/screen" + intToStr(i) + ".tga"; @@ -726,6 +731,9 @@ void Game::keyUp(char key){ case 'N': renderNetworkStatus= false; break; + case 'M': + showFullConsole= false; + break; case 'A': case 'D': gameCamera.setRotate(0); @@ -889,7 +897,7 @@ void Game::render2d(){ //resource info if(!config.getBool("PhotoMode")){ renderer.renderResourceStatus(); - renderer.renderConsole(&console); + renderer.renderConsole(&console,showFullConsole); } //2d mouse diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index 51106663..ff5e4912 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -68,6 +68,7 @@ private: bool paused; bool gameOver; bool renderNetworkStatus; + bool showFullConsole; float scrollSpeed; Speed speed; GraphicMessageBox mainMessageBox; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 7c88ab25..6f27b3ad 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -688,7 +688,7 @@ void Renderer::renderTextureQuad(int x, int y, int w, int h, const Texture2D *te assertGl(); } -void Renderer::renderConsole(const Console *console){ +void Renderer::renderConsole(const Console *console,const bool showFullConsole){ glPushAttrib(GL_ENABLE_BIT); glEnable(GL_BLEND); Vec4f fontColor; @@ -700,15 +700,25 @@ void Renderer::renderConsole(const Console *console){ // white shadowed is default ( in the menu for example ) fontColor=Vec4f(1.f, 1.f, 1.f, 0.0f); } - - for(int i=0; igetLineCount(); ++i){ - renderTextShadow( - console->getLine(i), - CoreData::getInstance().getConsoleFont(), - fontColor, - 20, i*20+20); - } + if(showFullConsole){ + for(int i=0; igetStoredLineCount(); ++i){ + renderTextShadow( + console->getStoredLine(i), + CoreData::getInstance().getConsoleFont(), + fontColor, + 20, i*20+20); + } + } + else{ + for(int i=0; igetLineCount(); ++i){ + renderTextShadow( + console->getLine(i), + CoreData::getInstance().getConsoleFont(), + fontColor, + 20, i*20+20); + } + } glPopAttrib(); } diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index d8a2404e..12119fb2 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -225,7 +225,7 @@ public: void renderMouse3d(); void renderBackground(const Texture2D *texture); void renderTextureQuad(int x, int y, int w, int h, const Texture2D *texture, float alpha=1.f); - void renderConsole(const Console *console); + void renderConsole(const Console *console, const bool showAll=false); void renderChatManager(const ChatManager *chatManager); void renderResourceStatus(); void renderSelectionQuad(); diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index aa211eb9..2a3b324f 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -100,7 +100,11 @@ void UnitUpdater::updateUnit(Unit *unit){ //play water sound if(map->getCell(unit->getPos())->getHeight()getWaterLevel() && unit->getCurrField()==fLand){ - soundRenderer.playFx(CoreData::getInstance().getWaterSound()); + soundRenderer.playFx( + CoreData::getInstance().getWaterSound(), + unit->getCurrVector(), + gameCamera->getPos() + ); } } }