watersounds playing all over the map is fixed.

'M' key shows faded console messages again (currently ingame only )
This commit is contained in:
Titus Tscharntke 2010-04-14 20:49:14 +00:00
parent 4c8e4eaccb
commit e5d9631a9f
7 changed files with 51 additions and 13 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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

View File

@ -68,6 +68,7 @@ private:
bool paused;
bool gameOver;
bool renderNetworkStatus;
bool showFullConsole;
float scrollSpeed;
Speed speed;
GraphicMessageBox mainMessageBox;

View File

@ -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; i<console->getLineCount(); ++i){
renderTextShadow(
console->getLine(i),
CoreData::getInstance().getConsoleFont(),
fontColor,
20, i*20+20);
}
if(showFullConsole){
for(int i=0; i<console->getStoredLineCount(); ++i){
renderTextShadow(
console->getStoredLine(i),
CoreData::getInstance().getConsoleFont(),
fontColor,
20, i*20+20);
}
}
else{
for(int i=0; i<console->getLineCount(); ++i){
renderTextShadow(
console->getLine(i),
CoreData::getInstance().getConsoleFont(),
fontColor,
20, i*20+20);
}
}
glPopAttrib();
}

View File

@ -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();

View File

@ -100,7 +100,11 @@ void UnitUpdater::updateUnit(Unit *unit){
//play water sound
if(map->getCell(unit->getPos())->getHeight()<map->getWaterLevel() && unit->getCurrField()==fLand){
soundRenderer.playFx(CoreData::getInstance().getWaterSound());
soundRenderer.playFx(
CoreData::getInstance().getWaterSound(),
unit->getCurrVector(),
gameCamera->getPos()
);
}
}
}