press escape to abort chatting
This commit is contained in:
parent
4cf8f079e7
commit
e02a81d1a2
|
@ -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]="";
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<74>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 <string>
|
||||
|
||||
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
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue