From 1962bfe9254795b0604179087e3c61028e673763 Mon Sep 17 00:00:00 2001 From: doitux Date: Mon, 13 Oct 2008 20:03:56 +0000 Subject: [PATCH] start implementing chancelabel --- pokerth_game.pro | 354 ++++++++++++------------- src/gui/qt/gametable.ui | 34 ++- src/gui/qt/gametable/gametableimpl.cpp | 29 +- src/gui/qt/gametable/gametableimpl.h | 3 + src/gui/qt/gametable/mychancelabel.cpp | 24 ++ src/gui/qt/gametable/mychancelabel.h | 39 +++ 6 files changed, 291 insertions(+), 192 deletions(-) create mode 100644 src/gui/qt/gametable/mychancelabel.cpp create mode 100644 src/gui/qt/gametable/mychancelabel.h diff --git a/pokerth_game.pro b/pokerth_game.pro index 432d8067..c8653a7f 100644 --- a/pokerth_game.pro +++ b/pokerth_game.pro @@ -1,27 +1,27 @@ # QMake pro-file for PokerTH game - -isEmpty( PREFIX ) { - PREFIX=/usr -} - + +isEmpty( PREFIX ){ + PREFIX =/usr +} + TEMPLATE = app CODECFORSRC = UTF-8 - + #CONFIG += qt thread embed_manifest_exe exceptions rtti stl warn_on release CONFIG += qt thread embed_manifest_exe exceptions rtti stl warn_on debug - + #####Uncomment this for RELEASE #QTPLUGIN += qjpeg qgif - + UI_DIR = uics MOC_DIR = mocs OBJECTS_DIR = obj DEFINES += ENABLE_IPV6 DEFINES += PREFIX=\"$${PREFIX}\" TARGET = pokerth - + RESOURCES = src/gui/qt/resources/pokerth.qrc - + INCLUDEPATH += . \ src \ src/engine \ @@ -58,7 +58,7 @@ INCLUDEPATH += . \ src/gui/qt/gamelobbydialog \ src/gui/qt/gamelobbydialog/lobbychat \ src/gui/qt/timeoutmsgbox - + DEPENDPATH += . \ src \ src/config \ @@ -97,7 +97,7 @@ DEPENDPATH += . \ src/gui/qt/gamelobbydialog \ src/gui/qt/gamelobbydialog/lobbychat \ src/gui/qt/timeoutmsgbox - + # Input HEADERS += \ src/game.h \ @@ -184,8 +184,9 @@ HEADERS += \ src/gui/qttoolsinterface.h \ src/gui/qt/qttools/qttoolswrapper.h \ src/gui/qt/qttools/qthelper/qthelper.h \ - src/gui/generic/serverguiwrapper.h - + src/gui/generic/serverguiwrapper.h \ + src/gui/qt/gametable/mychancelabel.h + FORMS += \ src/gui/qt/gametable.ui \ src/gui/qt/aboutpokerth.ui \ @@ -203,7 +204,7 @@ FORMS += \ src/gui/qt/gamelobbydialog.ui \ src/gui/qt/mymessagedialog.ui \ src/gui/qt/manualblindsorderdialog.ui - + SOURCES += \ src/pokerth.cpp \ src/gui/qt/chattools/chattools.cpp \ @@ -243,8 +244,9 @@ SOURCES += \ src/gui/qt/gamelobbydialog/lobbychat/lobbychat.cpp \ src/gui/qt/timeoutmsgbox/timeoutmsgboximpl.cpp \ src/net/common/net_helper_client.cpp \ - src/core/common/loghelper_client.cpp - + src/core/common/loghelper_client.cpp \ + src/gui/qt/gametable/mychancelabel.cpp + TRANSLATIONS = \ ts/pokerth_bg.ts \ ts/pokerth_de.ts \ @@ -264,163 +266,161 @@ TRANSLATIONS = \ ts/pokerth_zhcn.ts \ ts/pokerth_fi.ts \ ts/pokerth_START_HERE.ts - -win32{ - DEFINES += CURL_STATICLIB - DEPENDPATH += src/net/win32/ src/core/win32 - INCLUDEPATH += ../boost/ ../SDL/include ../SDL_mixer - INCLUDEPATH += ../SDL/include/SDL ../SDL_mixer/include ../GnuTLS/include ../curl/include ../zlib - LIBPATH += ../boost/stage/lib ../GnuTLS/lib ../curl/lib ../zlib - - LIBS += -lpokerth_lib - - win32-msvc2005{ - LIBPATH += Release/lib ../SDL/VisualC/SDL/Release ../SDL/VisualC/SDLmain/Release ../SDL_mixer/VisualC/Release - #LIBPATH += Debug/lib ../SDL/VisualC/SDL/Debug ../SDL/VisualC/SDLmain/Debug ../SDL_mixer/VisualC/Debug - - LIBS += -llibgnutls-openssl -llibgcrypt - LIBS += -llibcurl - } - - win32-g++{ - #LIBPATH += Release/lib - LIBPATH += Debug/lib - LIBPATH += ../SDL/lib ../SDL_mixer/lib - LIBS += -lgnutls-openssl -lgnutls -lgcrypt -ltasn1 -lgpg-error - LIBS += -lcurl - LIBS += -lz - LIBS += -llibboost_thread-mgw34-mt-1_36 - LIBS += -llibboost_filesystem-mgw34-mt-1_36 - LIBS += -llibboost_system-mgw34-mt-1_36 - LIBS += -llibboost_iostreams-mgw34-mt-1_36 - LIBS += -llibboost_zlib-mgw34-mt-1_36 - } - - LIBS += -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lole32 -luuid -luser32 -lmsimg32 -lshell32 -lkernel32 -lws2_32 -ladvapi32 -lsdl -lsdlmain -lsdl_mixer -lwldap32 - RC_FILE = pokerth.rc -} -!win32{ - DEPENDPATH += src/net/linux/ src/core/linux -} - -unix{ - # workaround for problems with boost_filesystem exceptions - QMAKE_LFLAGS += -no_dead_strip_inits_and_terms -} - -unix: !mac{ - - ##### My release static build options - #QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections - #QMAKE_LFLAGS += -Wl,--gc-sections - - LIBPATH += lib - - LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 - BOOST_FS = boost_filesystem boost_filesystem-mt - BOOST_THREAD = boost_thread boost_thread-mt - BOOST_IOSTREAMS = boost_iostreams boost_iostreams-mt - - - for(dir, LIB_DIRS) { - exists($$dir) { - for(lib, BOOST_THREAD) { - exists($${dir}/lib$${lib}.so*) { - message("Found $$lib") - BOOST_THREAD = -l$$lib - } - } - for(lib, BOOST_FS) { - exists($${dir}/lib$${lib}.so*) { - message("Found $$lib") - BOOST_FS = -l$$lib - } - } - for(lib, BOOST_IOSTREAMS) { - exists($${dir}/lib$${lib}.so*) { - message("Found $$lib") - BOOST_IOSTREAMS = -l$$lib - } - } - } - } - BOOST_LIBS = $$BOOST_THREAD $$BOOST_FS $$BOOST_IOSTREAMS - !count(BOOST_LIBS, 3) { - error("could not locate required library: \ - libboost (version >= 1.34.1) --> http://www.boost.org/") - } - - if ($$system(sdl-config --version)) { - error("Could not determine if required library is installed: \ - libSDL_mixer, libSDL --> http://www.libsdl.org/") - } - - UNAME = $$system(uname -s) - BSD = $$find(UNAME, "BSD") - - LIBS += -lpokerth_lib - LIBS += $$BOOST_LIBS - LIBS += -lSDL_mixer -lcurl - !isEmpty( BSD ) { - LIBS += -lcrypto - } else { - LIBS += -lgnutls-openssl -lgcrypt - } - TARGETDEPS += ./lib/libpokerth_lib.a - - ##### My release static libs - #LIBS += -lgcrypt_static -lgpg-error_static -lgnutls-openssl_static -lgnutls_static -lSDL_mixer_static -lSDL -lmikmod -lcurl - - #### INSTALL #### - - binary.path += $${PREFIX}/bin/ - binary.files += pokerth - - data.path += $${PREFIX}/share/pokerth/data/ - data.files += data/* - - pixmap.path += $${PREFIX}/share/pixmaps/ - pixmap.files += pokerth.png - - desktop.path += $${PREFIX}/share/applications/ - desktop.files += pokerth.desktop - - INSTALLS += binary data pixmap desktop -} - -mac{ - # make it universal - CONFIG += x86 - CONFIG += ppc - QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3 - - # for universal-compilation on PPC-Mac uncomment the following line - # on Intel-Mac you have to comment this line out or build will fail. - # QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/ - - LIBPATH += lib - LIBS += -lpokerth_lib - # Qt static (path is standard for self-compiling qt) - #LIBS += /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.a - #LIBS += /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.a - # QT dynamic linked framework (see also mac_post_make.sh) - LIBS += -framework QtCore - LIBS += -framework QtGui - # SDL and SDL_mixer come as frameworks - LIBS += -framework SDL - LIBS += -framework SDL_mixer - # standard path for darwinports - # make sure you have a universal version of boost - LIBS += /usr/local/lib/libboost_thread-mt-1_35.a - LIBS += /usr/local/lib/libboost_filesystem-mt-1_35.a - LIBS += /usr/local/lib/libboost_system-mt-1_35.a - LIBS += /usr/local/lib/libboost_iostreams-mt-1_35.a - # libraries installed on every mac - LIBS += -lcrypto -lssl -lz -lcurl -framework Carbon - # set the application icon - RC_FILE = pokerth.icns - LIBPATH += /Developer/SDKs/MacOSX10.4u.sdk/usr/lib - INCLUDEPATH += /Developer/SDKs/MacOSX10.4u.sdk/usr/include/ - INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers - INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers -} + +win32 { + DEFINES += CURL_STATICLIB + DEPENDPATH += src/net/win32/ src/core/win32 + INCLUDEPATH += ../boost/ ../SDL/include ../SDL_mixer + INCLUDEPATH += ../SDL/include/SDL ../SDL_mixer/include ../GnuTLS/include ../curl/include ../zlib + LIBPATH += ../boost/stage/lib ../GnuTLS/lib ../curl/lib ../zlib + + LIBS += -lpokerth_lib + + win32-msvc2005 { + LIBPATH += Release/lib ../SDL/VisualC/SDL/Release ../SDL/VisualC/SDLmain/Release ../SDL_mixer/VisualC/Release + #LIBPATH += Debug/lib ../SDL/VisualC/SDL/Debug ../SDL/VisualC/SDLmain/Debug ../SDL_mixer/VisualC/Debug + + LIBS += -llibgnutls-openssl -llibgcrypt + LIBS += -llibcurl + } + + win32-g++ { + #LIBPATH += Release/lib + LIBPATH += Debug/lib + LIBPATH += ../SDL/lib ../SDL_mixer/lib + LIBS += -lgnutls-openssl -lgnutls -lgcrypt -ltasn1 -lgpg-error + LIBS += -lcurl + LIBS += -lz + LIBS += -llibboost_thread-mgw34-mt-1_36 + LIBS += -llibboost_filesystem-mgw34-mt-1_36 + LIBS += -llibboost_system-mgw34-mt-1_36 + LIBS += -llibboost_iostreams-mgw34-mt-1_36 + LIBS += -llibboost_zlib-mgw34-mt-1_36 + } + + LIBS += -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lole32 -luuid -luser32 -lmsimg32 -lshell32 -lkernel32 -lws2_32 -ladvapi32 -lsdl -lsdlmain -lsdl_mixer -lwldap32 + RC_FILE = pokerth.rc +} +!win32 { + DEPENDPATH += src/net/linux/ src/core/linux +} + +unix { + # workaround for problems with boost_filesystem exceptions + QMAKE_LFLAGS += -no_dead_strip_inits_and_terms +} + +unix : !mac { + + ##### My release static build options + #QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections + #QMAKE_LFLAGS += -Wl,--gc-sections + + LIBPATH += lib + + LIB_DIRS = $${PREFIX}/lib $${PREFIX}/lib64 + BOOST_FS = boost_filesystem boost_filesystem-mt + BOOST_THREAD = boost_thread boost_thread-mt + BOOST_IOSTREAMS = boost_iostreams boost_iostreams-mt + + + for(dir, LIB_DIRS){ + exists($$dir){ + for(lib, BOOST_THREAD){ + exists($${dir}/lib$${lib}.so*){ + message("Found $$lib") + BOOST_THREAD = -l$$lib + } + } + for(lib, BOOST_FS){ + exists($${dir}/lib$${lib}.so*){ + message("Found $$lib") + BOOST_FS = -l$$lib + } + } + for(lib, BOOST_IOSTREAMS){ + exists($${dir}/lib$${lib}.so*){ + message("Found $$lib") + BOOST_IOSTREAMS = -l$$lib + } + } + } + } + BOOST_LIBS = $$BOOST_THREAD $$BOOST_FS $$BOOST_IOSTREAMS + !count(BOOST_LIBS, 3){ + error( libboost (version >= 1.34.1) --> http://www.boost.org/") + } + + if($$system(sdl-config --version)){ + error( libSDL_mixer, libSDL --> http://www.libsdl.org/") + } + + UNAME = $$system(uname -s) + BSD = $$find(UNAME, "BSD") + + LIBS += -lpokerth_lib + LIBS += $$BOOST_LIBS + LIBS += -lSDL_mixer -lcurl + !isEmpty( BSD ){ + LIBS += -lcrypto + } else { + LIBS += -lgnutls-openssl -lgcrypt + } + TARGETDEPS += ./lib/libpokerth_lib.a + + ##### My release static libs + #LIBS += -lgcrypt_static -lgpg-error_static -lgnutls-openssl_static -lgnutls_static -lSDL_mixer_static -lSDL -lmikmod -lcurl + + #### INSTALL #### + + binary.path += $${PREFIX}/bin/ + binary.files += pokerth + + data.path += $${PREFIX}/share/pokerth/data/ + data.files += data/* + + pixmap.path += $${PREFIX}/share/pixmaps/ + pixmap.files += pokerth.png + + desktop.path += $${PREFIX}/share/applications/ + desktop.files += pokerth.desktop + + INSTALLS += binary data pixmap desktop + } + +mac { + # make it universal + CONFIG += x86 + CONFIG += ppc + QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3 + + # for universal-compilation on PPC-Mac uncomment the following line + # on Intel-Mac you have to comment this line out or build will fail. + # QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/ + + LIBPATH += lib + LIBS += -lpokerth_lib + # Qt static (path is standard for self-compiling qt) + #LIBS += /usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.a + #LIBS += /usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.a + # QT dynamic linked framework (see also mac_post_make.sh) + LIBS += -framework QtCore + LIBS += -framework QtGui + # SDL and SDL_mixer come as frameworks + LIBS += -framework SDL + LIBS += -framework SDL_mixer + # standard path for darwinports + # make sure you have a universal version of boost + LIBS += /usr/local/lib/libboost_thread-mt-1_35.a + LIBS += /usr/local/lib/libboost_filesystem-mt-1_35.a + LIBS += /usr/local/lib/libboost_system-mt-1_35.a + LIBS += /usr/local/lib/libboost_iostreams-mt-1_35.a + # libraries installed on every mac + LIBS += -lcrypto -lssl -lz -lcurl -framework Carbon + # set the application icon + RC_FILE = pokerth.icns + LIBPATH += /Developer/SDKs/MacOSX10.4u.sdk/usr/lib + INCLUDEPATH += /Developer/SDKs/MacOSX10.4u.sdk/usr/include/ + INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers + INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers +} diff --git a/src/gui/qt/gametable.ui b/src/gui/qt/gametable.ui index 3f57e3ba..a16f0fb3 100644 --- a/src/gui/qt/gametable.ui +++ b/src/gui/qt/gametable.ui @@ -1836,7 +1836,7 @@ - + Qt::Vertical @@ -1849,6 +1849,13 @@ + + + + + + + @@ -2645,6 +2652,26 @@ + + + Chance + + + + 2 + + + 0 + + + + + + + + + + @@ -3116,6 +3143,11 @@ QLabel
myavatarlabel.h
+ + MyChanceLable + QLabel +
mychancelable.h
+
diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index dbf27424..d700e172 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -27,6 +27,7 @@ #include "mycardspixmaplabel.h" #include "mysetlabel.h" #include "myavatarlabel.h" +#include "mychancelabel.h" #include "log.h" #include "chat.h" @@ -398,6 +399,7 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) label_timeout->setStyleSheet("QLabel { color: #99D500;}"); label_kickVoteTimeout->setStyleSheet("QLabel { color: #99D500;}"); label_kickUser->setStyleSheet("QLabel { color: #99D500;}"); + label_votesMonitor->setStyleSheet("QLabel { color: #99D500;}"); statusbar->setStyleSheet(" QStatusBar { "+ font1String +" font-size: 12px; color: #B7FF00; }"); @@ -2651,7 +2653,9 @@ void gameTableImpl::keyPressEvent ( QKeyEvent * event ) { } else { keyUpDownChatCounter = 0; } - + //TESTING UNIT +// if (event->key() == Qt::Key_M) { startVoteOnKick(3,60); } +// if (event->key() == Qt::Key_N) { endVoteOnKick(); } } void gameTableImpl::changePlayingMode() { @@ -2686,14 +2690,6 @@ bool gameTableImpl::eventFilter(QObject *obj, QEvent *event) myChat->nickAutoCompletition(); return true; } - else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_M) { //TESTING UNIT - startVoteOnKick(3,60); - return true; - } - else if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_N) { //TESTING UNIT - stopVoteOnKickTimeout(); - return true; - } else if (event->type() == QEvent::Close) { event->ignore(); closeGameTable(); @@ -2833,7 +2829,7 @@ void gameTableImpl::localGameModification() { void gameTableImpl::networkGameModification() { if(tabWidget_Left->widget(1) != tab_Chat) - tabWidget_Left->insertTab(1, tab_Chat, QString(tr(" Chat "))); /*TODO text abgeschnitten --> stylesheets*/ + tabWidget_Left->insertTab(1, tab_Chat, QString(tr("Chat"))); /*TODO text abgeschnitten --> stylesheets*/ tabWidget_Left->removeTab(2); @@ -3082,9 +3078,10 @@ void gameTableImpl::startVoteOnKick(int playerId, int timeoutSec) tabWidget_Left->setCurrentIndex(2); PlayerInfo info(myStartWindow->getSession()->getClientPlayerInfo(playerId)); - label_kickUser->setText(tr("Do you want to kick %1 \nfrom this game?").arg(QString::fromUtf8(info.playerName.c_str()))); + label_kickUser->setText(tr("Do you want to kick %1 \nfrom this game?").arg(QString::fromUtf8(info.playerName.c_str()))); voteOnKickTimeoutSecs = timeoutSec; + playerAboutToKickId = playerId; startVoteOnKickTimeout(); } @@ -3092,8 +3089,7 @@ void gameTableImpl::endVoteOnKick() { stopVoteOnKickTimeout(); tabWidget_Left->removeTab(2); - - tabWidget_Left->setCurrentIndex(1); +// tabWidget_Left->setCurrentIndex(1); } void gameTableImpl::voteOnKickYes() @@ -3119,7 +3115,12 @@ void gameTableImpl::stopVoteOnKickTimeout() void gameTableImpl::nextVoteOnKickTimeoutAnimationFrame() { - qDebug() << voteOnKickTimeoutSecs-voteOnKickRealTimer.elapsed().total_seconds(); label_kickVoteTimeout->setText(tr("%1 secs left").arg(voteOnKickTimeoutSecs-voteOnKickRealTimer.elapsed().total_seconds())); } +void gameTableImpl::refreshVotesMonitor() +{ + PlayerInfo info(myStartWindow->getSession()->getClientPlayerInfo(playerAboutToKickId)); + label_votesMonitor->setText(tr("Player %1 has %2 votes against him.").arg(QString::fromUtf8(info.playerName.c_str()))); +} + diff --git a/src/gui/qt/gametable/gametableimpl.h b/src/gui/qt/gametable/gametableimpl.h index ac091087..0a3f72b5 100755 --- a/src/gui/qt/gametable/gametableimpl.h +++ b/src/gui/qt/gametable/gametableimpl.h @@ -286,6 +286,7 @@ public slots: void startVoteOnKickTimeout(); void stopVoteOnKickTimeout(); void nextVoteOnKickTimeoutAnimationFrame(); + void refreshVotesMonitor(); private: @@ -402,7 +403,9 @@ private: int keyUpDownChatCounter; int myLastPreActionBetValue; + int voteOnKickTimeoutSecs; + int playerAboutToKickId; // StyleSheetReader *myStyleSheetReader; friend class GuiWrapper; diff --git a/src/gui/qt/gametable/mychancelabel.cpp b/src/gui/qt/gametable/mychancelabel.cpp new file mode 100644 index 00000000..a4050ea8 --- /dev/null +++ b/src/gui/qt/gametable/mychancelabel.cpp @@ -0,0 +1,24 @@ +// +// C++ Implementation: mycardspixmaplabel +// +// Description: +// +// +// Author: FThauer FHammer , (C) 2007 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "mychancelabel.h" +#include "gametableimpl.h" + +using namespace std; + +MyChanceLabel::MyChanceLabel(QWidget* parent) + : QLabel(parent) { + +} + +MyChanceLabel::~MyChanceLabel() +{ +} diff --git a/src/gui/qt/gametable/mychancelabel.h b/src/gui/qt/gametable/mychancelabel.h new file mode 100644 index 00000000..328b9630 --- /dev/null +++ b/src/gui/qt/gametable/mychancelabel.h @@ -0,0 +1,39 @@ +// +// C++ Interface: mycardspixmaplabel +// +// Description: +// +// +// Author: FThauer FHammer , (C) 2007 +// +// Copyright: See COPYING file that comes with this distribution +// +// +#ifndef MYCHANCELABEL_H +#define MYCHANCELABEL_H + +#include + +#include +#include + +class gameTableImpl; + +class MyChanceLabel : public QLabel +{ +Q_OBJECT +public: + MyChanceLabel(QWidget*); + + ~MyChanceLabel(); + + void setMyW ( gameTableImpl* theValue ) { myW = theValue; } + + +private: + + gameTableImpl *myW; + +}; + +#endif