/*********************************************************** handle event when list is selected ***********************************************************/ bool ChatBox::HandleLbSelected (const CEGUI::EventArgs& e) { const CEGUI::ListboxTextItem * it = static_cast<const CEGUI::ListboxTextItem *>(_lb->getFirstSelectedItem()); std::string txt = it->getText().c_str(); if(txt == "New..") { _myChannels->show(); CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/chooseChannel/edit")); bed->activate(); _myChat->setEnabled(false); } else if(txt == "Whisper..") { _myChooseName->show(); CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/choosePlayerName/edit")); bed->activate(); _myChat->setEnabled(false); } else { CEGUI::PushButton * bch = static_cast<CEGUI::PushButton *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/bChannel")); bch->setProperty("Text", it->getText()); _currSelectedch= (int)_lb->getItemIndex(it); } _lb->hide(); return true; }
/*********************************************************** add a channel to the chat ***********************************************************/ void ChatBox::AddChannel(const std::string & channel) { std::list<std::string>::iterator it = std::find(_channels.begin(), _channels.end(), channel); if(it != _channels.end()) return; _channels.push_back(channel); AddTab(channel); CEGUI::PushButton * bch = static_cast<CEGUI::PushButton *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/bChannel")); bch->setProperty("Text", (const unsigned char *)channel.c_str()); std::string tosend("/join "); tosend +=channel; ThreadSafeWorkpile::getInstance()->AddChatText(tosend); }
/*********************************************************** add a whisper channel ***********************************************************/ void ChatBox::AddWhisperChanel(const std::string & name) { std::string wchtmp = "w:" + name; if(std::find(_whisper_channels.begin(), _whisper_channels.end(), name) == _whisper_channels.end()) { _whisper_channels.push_back(name); if(_whisper_channels.size() > 3) _whisper_channels.pop_front(); } CEGUI::PushButton * bch = static_cast<CEGUI::PushButton *> (CEGUI::WindowManager::getSingleton().getWindow("Chat/bChannel")); bch->setProperty("Text", (const unsigned char *)wchtmp.c_str()); }