Added irc support for lobby dialog. Takes some time to connect before messages can be sent/received. No special stuff yet, no user list, no connection notifications. Still work in progress.
This commit is contained in:
@@ -38,7 +38,11 @@ gameLobbyDialogImpl::gameLobbyDialogImpl(QWidget *parent, ConfigFile *c)
|
||||
|
||||
void gameLobbyDialogImpl::exec()
|
||||
{
|
||||
assert(mySession);
|
||||
mySession->terminateIrcClient();
|
||||
mySession->startIrcClient();
|
||||
QDialog::exec();
|
||||
mySession->terminateIrcClient();
|
||||
clearDialog();
|
||||
}
|
||||
|
||||
@@ -384,9 +388,10 @@ void gameLobbyDialogImpl::kickPlayer() {
|
||||
}
|
||||
|
||||
void gameLobbyDialogImpl::sendChatMessage() { myChat->sendMessage(); }
|
||||
void gameLobbyDialogImpl::displayChatMessage(QString nickName, QString msg) { myChat->receiveMessage(nickName, msg); }
|
||||
void gameLobbyDialogImpl::checkChatInputLength(QString string) { myChat->checkInputLength(string); }
|
||||
|
||||
void gameLobbyDialogImpl::keyPressEvent ( QKeyEvent * event ) {
|
||||
|
||||
if (event->key() == Qt::Key_Enter) {}
|
||||
}
|
||||
if (event->key() == Qt::Key_Enter) { sendChatMessage(); }
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ public slots:
|
||||
void clearDialog();
|
||||
|
||||
void sendChatMessage();
|
||||
void displayChatMessage(QString nickName, QString msg);
|
||||
void checkChatInputLength(QString string);
|
||||
|
||||
void keyPressEvent(QKeyEvent * event);
|
||||
|
||||
@@ -38,8 +38,12 @@ LobbyChat::~LobbyChat()
|
||||
|
||||
void LobbyChat::sendMessage() {
|
||||
|
||||
myLobby->getSession().sendChatMessage(myLobby->lineEdit_ChatInput->text().toUtf8().constData());
|
||||
QString tmpMsg(myLobby->lineEdit_ChatInput->text());
|
||||
myLobby->getSession().sendIrcChatMessage(tmpMsg.toUtf8().constData());
|
||||
myLobby->lineEdit_ChatInput->setText("");
|
||||
|
||||
// TODO: just temporary instead of callback
|
||||
receiveMessage("(me)", tmpMsg);
|
||||
}
|
||||
|
||||
void LobbyChat::receiveMessage(QString playerName, QString message) {
|
||||
|
||||
@@ -139,3 +139,5 @@ void GuiWrapper::SignalNetClientWaitDialog() { myW->signalShowNetworkStartDialog
|
||||
void GuiWrapper::SignalNetServerSuccess(int actionID) { }
|
||||
void GuiWrapper::SignalNetServerError(int errorID, int osErrorID) { myW->signalNetServerError(errorID, osErrorID); }
|
||||
|
||||
void GuiWrapper::SignalIrcChatMsg(const std::string &nickName, const std::string &msg) { myW->signalIrcChatMessage(QString::fromUtf8(nickName.c_str()), QString::fromUtf8(msg.c_str())); }
|
||||
|
||||
|
||||
@@ -118,6 +118,8 @@ public:
|
||||
void SignalNetServerSuccess(int actionID);
|
||||
void SignalNetServerError(int errorID, int osErrorID);
|
||||
|
||||
void SignalIrcChatMsg(const std::string &nickName, const std::string &msg);
|
||||
|
||||
private:
|
||||
|
||||
Log *myLog;
|
||||
|
||||
@@ -676,6 +676,8 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
|
||||
connect(this, SIGNAL(signalNetServerError(int, int)), this, SLOT(networkError(int, int)));
|
||||
connect(this, SIGNAL(signalNetClientGameStart(boost::shared_ptr<Game>)), this, SLOT(networkStart(boost::shared_ptr<Game>)));
|
||||
|
||||
connect(this, SIGNAL(signalIrcChatMessage(QString, QString)), myGameLobbyDialog, SLOT(displayChatMessage(QString, QString)));
|
||||
|
||||
//Sound
|
||||
mySDLPlayer = new SDLPlayer(myConfig);
|
||||
|
||||
@@ -758,7 +760,7 @@ void mainWindowImpl::callCreateNetworkGameDialog() {
|
||||
if (!myServerGuiInterface.get())
|
||||
{
|
||||
// Create pseudo Gui Wrapper for the server.
|
||||
myServerGuiInterface.reset(new ServerGuiWrapper(myConfig, mySession->getGui(), mySession->getGui()));
|
||||
myServerGuiInterface.reset(new ServerGuiWrapper(myConfig, mySession->getGui(), mySession->getGui(), mySession->getGui()));
|
||||
{
|
||||
boost::shared_ptr<Session> session(new Session(myServerGuiInterface.get(), myConfig));
|
||||
myServerGuiInterface->setSession(session);
|
||||
|
||||
@@ -138,6 +138,8 @@ signals:
|
||||
void signalNetClientGameListPlayerLeft(unsigned gameId, unsigned playerId);
|
||||
void signalNetClientGameStart(boost::shared_ptr<Game> game);
|
||||
|
||||
void signalIrcChatMessage(QString nickName, QString msg);
|
||||
|
||||
public slots:
|
||||
|
||||
void initGui(int speed);
|
||||
|
||||
Reference in New Issue
Block a user