add chat functions
This commit is contained in:
@@ -94,6 +94,8 @@ void ServerGuiWrapper::meInAction() {}
|
||||
void ServerGuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) {}
|
||||
void ServerGuiWrapper::logNewGameHandMsg(int gameID, int handID) {}
|
||||
|
||||
void ServerGuiWrapper::chatAppendMsg(std::string msg) {}
|
||||
|
||||
void ServerGuiWrapper::SignalNetClientConnect(int actionID) { if (myClientcb) myClientcb->SignalNetClientConnect(actionID); }
|
||||
void ServerGuiWrapper::SignalNetClientGameInfo(int actionID) { if (myClientcb) myClientcb->SignalNetClientGameInfo(actionID); }
|
||||
void ServerGuiWrapper::SignalNetClientError(int errorID, int osErrorID) { if (myClientcb) myClientcb->SignalNetClientError(errorID, osErrorID); }
|
||||
|
||||
@@ -77,6 +77,8 @@ public:
|
||||
void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
|
||||
void logNewGameHandMsg(int gameID, int handID) ;
|
||||
|
||||
void chatAppendMsg(std::string msg);
|
||||
|
||||
void SignalNetClientConnect(int actionID);
|
||||
void SignalNetClientGameInfo(int actionID);
|
||||
void SignalNetClientError(int errorID, int osErrorID);
|
||||
|
||||
@@ -93,6 +93,9 @@ public:
|
||||
virtual void logPlayerActionMsg(std::string playName, int action, int setValue) =0;
|
||||
virtual void logNewGameHandMsg(int gameID, int HandID) =0;
|
||||
|
||||
//chat
|
||||
virtual void chatAppendMsg(std::string msg) =0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "guiwrapper.h"
|
||||
#include "session.h"
|
||||
#include "log.h"
|
||||
#include "chat.h"
|
||||
#include "mainwindowimpl.h"
|
||||
#include "configfile.h"
|
||||
|
||||
@@ -34,6 +35,7 @@ GuiWrapper::GuiWrapper(ConfigFile *c) : myLog(0), myW(0), myConfig(c)
|
||||
myW = new mainWindowImpl(myConfig);
|
||||
myW->show();
|
||||
myLog = new Log(myW, myConfig);
|
||||
myChat = new Chat(myW, myConfig);
|
||||
|
||||
}
|
||||
|
||||
@@ -90,6 +92,8 @@ void GuiWrapper::meInAction() { myW->signalMeInAction(); }
|
||||
void GuiWrapper::logPlayerActionMsg(string playerName, int action, int setValue) { myLog->signalLogPlayerActionMsg(QString::fromUtf8(playerName.c_str()), action, setValue); }
|
||||
void GuiWrapper::logNewGameHandMsg(int gameID, int handID) { myLog->signalLogNewGameHandMsg(gameID, handID); }
|
||||
|
||||
void GuiWrapper::chatAppendMsg(string msg) { myChat->receiveMessage(msg); }
|
||||
|
||||
void GuiWrapper::SignalNetClientConnect(int actionID) { myW->signalNetClientConnect(actionID); }
|
||||
void GuiWrapper::SignalNetClientGameInfo(int actionID) { myW->signalNetClientGameInfo(actionID); }
|
||||
void GuiWrapper::SignalNetClientError(int errorID, int osErrorID) { myW->signalNetClientError(errorID, osErrorID); }
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
class Session;
|
||||
class mainWindowImpl;
|
||||
class Log;
|
||||
class Chat;
|
||||
class ConfigFile;
|
||||
|
||||
class GuiWrapper : public GuiInterface
|
||||
@@ -84,6 +85,8 @@ public:
|
||||
void logPlayerActionMsg(std::string playerName, int action, int setValue) ;
|
||||
void logNewGameHandMsg(int gameID, int handID) ;
|
||||
|
||||
void chatAppendMsg(std::string msg);
|
||||
|
||||
void SignalNetClientConnect(int actionID);
|
||||
void SignalNetClientGameInfo(int actionID);
|
||||
void SignalNetClientError(int errorID, int osErrorID);
|
||||
@@ -100,6 +103,7 @@ public:
|
||||
private:
|
||||
|
||||
Log *myLog;
|
||||
Chat *myChat;
|
||||
mainWindowImpl *myW;
|
||||
ConfigFile *myConfig;
|
||||
|
||||
|
||||
@@ -1847,7 +1847,7 @@
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex" >
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_Log" >
|
||||
<attribute name="title" >
|
||||
|
||||
@@ -20,12 +20,14 @@
|
||||
#include "chat.h"
|
||||
|
||||
#include "mainwindowimpl.h"
|
||||
#include "session.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
Chat::Chat(mainWindowImpl* w, ConfigFile *c) : myW(w), myConfig(c)
|
||||
{
|
||||
// myW->setChat(this);
|
||||
|
||||
myW->setChat(this);
|
||||
|
||||
}
|
||||
|
||||
@@ -34,3 +36,11 @@ Chat::~Chat()
|
||||
delete myConfig;
|
||||
myConfig = 0;
|
||||
}
|
||||
|
||||
void Chat::sendMessage() {
|
||||
|
||||
myW->getSession().sendChatMessage(myW->lineEdit_ChatInput->text().toUtf8().constData());
|
||||
myW->lineEdit_ChatInput->setText("");
|
||||
}
|
||||
|
||||
void Chat::receiveMessage(std::string message) { myW->textBrowser_Chat->append(QString::fromUtf8(message.c_str())); }
|
||||
@@ -40,10 +40,9 @@ public:
|
||||
|
||||
public slots:
|
||||
|
||||
public:
|
||||
|
||||
signals:
|
||||
|
||||
void sendMessage();
|
||||
void receiveMessage(std::string);
|
||||
|
||||
private:
|
||||
|
||||
mainWindowImpl *myW;
|
||||
|
||||
@@ -558,6 +558,9 @@ mainWindowImpl::mainWindowImpl(ConfigFile *c, QMainWindow *parent)
|
||||
connect ( horizontalSlider_speed, SIGNAL( valueChanged(int)), this, SLOT ( setGameSpeed(int) ) );
|
||||
connect ( pushButton_break, SIGNAL( clicked()), this, SLOT ( breakButtonClicked() ) ); // auch wieder starten!!!!
|
||||
|
||||
connect( tabWidget, SIGNAL( currentChanged(int) ), this, SLOT( setChatFocus() ) );
|
||||
connect( lineEdit_ChatInput, SIGNAL( returnPressed () ), this, SLOT( sendChatMessage() ) );
|
||||
|
||||
//Nachrichten Thread-Save
|
||||
connect(this, SIGNAL(signalRefreshSet()), this, SLOT(refreshSet()));
|
||||
connect(this, SIGNAL(signalRefreshCash()), this, SLOT(refreshCash()));
|
||||
@@ -862,7 +865,7 @@ void mainWindowImpl::setSession(boost::shared_ptr<Session> session)
|
||||
mySession = session;
|
||||
}
|
||||
|
||||
void mainWindowImpl::setLog(Log* l) { myLog = l; }
|
||||
|
||||
|
||||
//refresh-Funktionen
|
||||
void mainWindowImpl::refreshSet() {
|
||||
@@ -2506,6 +2509,15 @@ void mainWindowImpl::blinkingStartButtonAnimationAction() {
|
||||
pushButton_break->setPalette(tempPalette);
|
||||
}
|
||||
|
||||
void mainWindowImpl::sendChatMessage() { myChat->sendMessage(); }
|
||||
|
||||
void mainWindowImpl::setChatFocus() {
|
||||
|
||||
if(tabWidget->currentIndex() == 1) lineEdit_ChatInput->setFocus();
|
||||
else lineEdit_ChatInput->clearFocus();
|
||||
|
||||
}
|
||||
|
||||
void mainWindowImpl::closeEvent(QCloseEvent *event) {
|
||||
|
||||
mySession->terminateNetworkClient();
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <QtCore>
|
||||
|
||||
class Log;
|
||||
class Chat;
|
||||
class ConfigFile;
|
||||
class Session;
|
||||
class Game;
|
||||
@@ -66,7 +67,8 @@ public:
|
||||
Session &getSession();
|
||||
void setSession(boost::shared_ptr<Session> session);
|
||||
|
||||
void setLog(Log*);
|
||||
void setLog(Log* l) { myLog = l; }
|
||||
void setChat(Chat* c) { myChat = c; }
|
||||
|
||||
void setSpeeds();
|
||||
|
||||
@@ -234,6 +236,9 @@ public slots:
|
||||
|
||||
void paintStartSplash();
|
||||
|
||||
void sendChatMessage();
|
||||
void setChatFocus();
|
||||
|
||||
void networkError(int, int);
|
||||
void networkStart(boost::shared_ptr<Game> game);
|
||||
|
||||
@@ -244,6 +249,7 @@ private:
|
||||
boost::shared_ptr<GuiInterface> myServerGuiInterface;
|
||||
boost::shared_ptr<Session> mySession;
|
||||
Log *myLog;
|
||||
Chat *myChat;
|
||||
ConfigFile *myConfig;
|
||||
|
||||
//Logo
|
||||
|
||||
@@ -189,3 +189,8 @@ void Session::sendClientPlayerAction()
|
||||
myNetClient->SendPlayerAction();
|
||||
}
|
||||
|
||||
void Session::sendChatMessage(std::string message) {
|
||||
|
||||
//hi lothar --> zum testen schick ich es gleich wieder zurück an die gui. wie du siehst klappt es ;-)
|
||||
myGui->chatAppendMsg(message);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "playerdata.h"
|
||||
#include "game_defs.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
class GuiInterface;
|
||||
@@ -58,6 +59,8 @@ public:
|
||||
void setCurrentGameID(const int& theValue) { currentGameID = theValue; }
|
||||
int getCurrentGameID() const { return currentGameID; }
|
||||
|
||||
void sendChatMessage(std::string message);
|
||||
|
||||
private:
|
||||
|
||||
int currentGameID;
|
||||
|
||||
Reference in New Issue
Block a user