diff --git a/source/glest_game/game/chat_manager.cpp b/source/glest_game/game/chat_manager.cpp index 7ebba081..06cb0859 100644 --- a/source/glest_game/game/chat_manager.cpp +++ b/source/glest_game/game/chat_manager.cpp @@ -44,6 +44,27 @@ void ChatManager::init(Console* console, int thisTeamIndex){ this->thisTeamIndex= thisTeamIndex; } +void ChatManager::keyUp(char key){ + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + try { + if(editEnabled){ + if(key==vkEscape) + { + text.clear(); + editEnabled= false; + } + } + } + catch(const exception &ex) { + char szBuf[1024]=""; + sprintf(szBuf,"In [%s::%s %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); + throw runtime_error(szBuf); + } + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); +} + + void ChatManager::keyDown(char key){ SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -83,6 +104,7 @@ void ChatManager::keyDown(char key){ text.erase(text.end() -1); } } + } catch(const exception &ex) { char szBuf[1024]=""; diff --git a/source/glest_game/game/chat_manager.h b/source/glest_game/game/chat_manager.h new file mode 100644 index 00000000..36590239 --- /dev/null +++ b/source/glest_game/game/chat_manager.h @@ -0,0 +1,54 @@ +// ============================================================== +// This file is part of Glest (www.glest.org) +// +// Copyright (C) 2001-2008 Marti�o Figueroa +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#ifndef _GLEST_GAME_CHATMANAGER_H_ +#define _GLEST_GAME_CHATMANAGER_H_ + +#include + +using std::string; + +namespace Glest{ namespace Game{ + +class Console; + +// ===================================================== +// class ChatManager +// ===================================================== + +class ChatManager{ +private: + static const int maxTextLenght; + +private: + bool editEnabled; + bool teamMode; + Console* console; + string text; + int thisTeamIndex; + +public: + ChatManager(); + void init(Console* console, int thisTeamIndex); + + void keyDown(char key); + void keyUp(char key); + void keyPress(char c); + void updateNetwork(); + + bool getEditEnabled() const {return editEnabled;} + bool getTeamMode() const {return teamMode;} + string getText() const {return text;} +}; + +}}//end namespace + +#endif diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 710ce670..1a7aead0 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -590,7 +590,7 @@ void Game::keyDown(char key){ Lang &lang= Lang::getInstance(); bool speedChangesAllowed= !NetworkManager::getInstance().isNetworkGame(); - //send ley to the chat manager + //send key to the chat manager chatManager.keyDown(key); if(!chatManager.getEditEnabled()){ @@ -726,7 +726,11 @@ void Game::keyDown(char key){ void Game::keyUp(char key){ - if(!chatManager.getEditEnabled()){ + if(chatManager.getEditEnabled()){ + //send key to the chat manager + chatManager.keyUp(key); + } + else{ switch(key){ case 'N': renderNetworkStatus= false;