Author Topic: revision 109 chat bugfix  (Read 2750 times)

ttsmj

  • Guest
revision 109 chat bugfix
« on: 10 February 2008, 07:35:53 »
Typing in chat didn't worked for me, so I've modified glest and it works.. This is the new file game/chat_manager.cpp:

Code: [Select]
// ==============================================================

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

// ==============================================================



#include "chat_manager.h"



#include "window.h"

#include "console.h"

#include "network_manager.h"

#include "lang.h"

#include "leak_dumper.h"



using namespace Shared::Platform;



namespace Glest{ namespace Game{



// =====================================================

// class ChatManager

// =====================================================



const int ChatManager::maxTextLenght= 64;



ChatManager::ChatManager(){

console= NULL;

editEnabled= false;

teamMode= false;

thisTeamIndex= -1;

}



void ChatManager::init(Console* console, int thisTeamIndex){

this->console= console;

this->thisTeamIndex= thisTeamIndex;

}



void ChatManager::keyDown(char key){



Lang &lang= Lang::getInstance();



//toggle team mode

if(!editEnabled && key=='H'){

if(teamMode){

teamMode= false;

console->addLine(lang.get("ChatMode") + ": " + lang.get("All"));

}

else{

teamMode= true;

console->addLine(lang.get("ChatMode") + ": " + lang.get("Team"));

}

}

else if(key==vkReturn){

if(editEnabled){

GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();



editEnabled= false;

console->addLine(gameNetworkInterface->getHostName() + ": " + text);

gameNetworkInterface->sendTextMessage(text, teamMode? thisTeamIndex: -1);

}

else{

editEnabled= true;

text.clear();

}

}

else if(key==vkBack){

if(!text.empty()){

text.erase(text.end() -1);

}

}
else if(editEnabled && text.size()<maxTextLenght){

//space is the first meaningful code

if(key>=' '){

text+= key;

}

}

}



void ChatManager::keyPress(char c){

// if(editEnabled && text.size()<maxTextLenght){

// //space is the first meaningful code

// if(c>=' '){

// text+= c;
// console->addLine("KEYPRESS" + c);

// }

// }

}



void ChatManager::updateNetwork(){

GameNetworkInterface *gameNetworkInterface= NetworkManager::getInstance().getGameNetworkInterface();

string text;

string sender;



if(!gameNetworkInterface->getChatText().empty()){

int teamIndex= gameNetworkInterface->getChatTeamIndex();



if(teamIndex==-1 || teamIndex==thisTeamIndex){

console->addLine(gameNetworkInterface->getChatSender()+": "+gameNetworkInterface->getChatText());

}

}

}



}}//end namespace
« Last Edit: 1 January 1970, 00:00:00 by ttsmj »

martiño

  • Behemoth
  • *******
  • Posts: 1,095
    • View Profile
(No subject)
« Reply #1 on: 10 February 2008, 12:35:58 »
You were just using an outdated version of the code in the svn, Matze fixed or will fix that.
« Last Edit: 1 January 1970, 00:00:00 by martiño »

ttsmj

  • Guest
(No subject)
« Reply #2 on: 10 February 2008, 14:33:02 »
what's the up-to date version? I use revision 109
« Last Edit: 1 January 1970, 00:00:00 by ttsmj »

martiño

  • Behemoth
  • *******
  • Posts: 1,095
    • View Profile
(No subject)
« Reply #3 on: 10 February 2008, 15:27:46 »
Sorry about that, you are right. It is not implemented yet, it is not a bug, Matze will work on it as soon as he can.

I don't think your patch would work property, because this event is still using virtual key codes instead of characters, thats what needs to be implemented in the SDL port.

Regards.
« Last Edit: 1 January 1970, 00:00:00 by martiño »

 

anything