From a75abcbb6a0cd2c491bb4c7b00549f73ea0cc382 Mon Sep 17 00:00:00 2001 From: doitux Date: Mon, 20 Apr 2009 21:13:49 +0000 Subject: [PATCH] move timeout animation from setlabel to new position --- src/gui/qt/gametable.ui | 125 +++++++++++++++++++++++- src/gui/qt/gametable/gametableimpl.cpp | 27 +++-- src/gui/qt/gametable/gametableimpl.h | 1 + src/gui/qt/gametable/mysetlabel.cpp | 98 +------------------ src/gui/qt/gametable/mysetlabel.h | 32 +----- src/gui/qt/gametable/mytimeoutlabel.cpp | 8 +- 6 files changed, 148 insertions(+), 143 deletions(-) diff --git a/src/gui/qt/gametable.ui b/src/gui/qt/gametable.ui index 846d85a0..ba126460 100644 --- a/src/gui/qt/gametable.ui +++ b/src/gui/qt/gametable.ui @@ -256,6 +256,19 @@ Qt::AlignCenter + + + + 12 + 70 + 52 + 10 + + + + + + @@ -461,6 +474,19 @@ Qt::AlignCenter + + + + 12 + 61 + 52 + 10 + + + + + + @@ -673,6 +699,19 @@ Qt::AlignCenter + + + + 12 + 70 + 52 + 10 + + + + + + @@ -865,6 +904,19 @@ Qt::AlignCenter + + + + 12 + 70 + 52 + 10 + + + + + + @@ -1057,6 +1109,19 @@ Qt::AlignCenter + + + + 12 + 70 + 52 + 10 + + + + + + @@ -1269,6 +1334,19 @@ Qt::AlignCenter + + + + 12 + 70 + 52 + 10 + + + + + + @@ -1474,6 +1552,19 @@ Qt::AlignCenter + + + + 12 + 61 + 52 + 10 + + + + + + @@ -2118,6 +2209,19 @@ Qt::AlignCenter + + + + 12 + 61 + 52 + 10 + + + + + + @@ -2313,10 +2417,10 @@ - 10 - 60 - 50 - 17 + 12 + 61 + 52 + 10 @@ -2515,6 +2619,19 @@ Qt::AlignCenter + + + + 12 + 61 + 52 + 10 + + + + + + diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index d5300607..70c1fb60 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -255,6 +255,19 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent) playerAvatarLabelArray[i]->setMyId(i); } + // timeoutLabelArray init + timeoutLabelArray[0] = label_Timeout0; + timeoutLabelArray[1] = label_Timeout1; + timeoutLabelArray[2] = label_Timeout2; + timeoutLabelArray[3] = label_Timeout3; + timeoutLabelArray[4] = label_Timeout4; + timeoutLabelArray[5] = label_Timeout5; + timeoutLabelArray[6] = label_Timeout6; + timeoutLabelArray[7] = label_Timeout7; + timeoutLabelArray[8] = label_Timeout8; + timeoutLabelArray[9] = label_Timeout9; + for (i=0; isetMyW(this); } + // setLabelArray init setLabelArray[0] = textLabel_Set0; setLabelArray[1] = textLabel_Set1; @@ -1498,14 +1511,13 @@ void gameTableImpl::startTimeoutAnimation(int playerId, int timeoutSec) { assert(playerId >= 0 && playerId < myStartWindow->getSession()->getCurrentGame()->getStartQuantityPlayers()); //beep for player 0 - if(playerId) { setLabelArray[playerId]->startTimeOutAnimation(timeoutSec, FALSE); } - else { setLabelArray[playerId]->startTimeOutAnimation(timeoutSec, TRUE); } - label_Timeout0->startTimeOutAnimation(timeoutSec, FALSE); + if(playerId) { timeoutLabelArray[playerId]->startTimeOutAnimation(timeoutSec, FALSE); } + else { timeoutLabelArray[playerId]->startTimeOutAnimation(timeoutSec, TRUE); } } void gameTableImpl::stopTimeoutAnimation(int playerId) { assert(playerId >= 0 && playerId < myStartWindow->getSession()->getCurrentGame()->getStartQuantityPlayers()); - setLabelArray[playerId]->stopTimeOutAnimation(); + timeoutLabelArray[playerId]->stopTimeOutAnimation(); } void gameTableImpl::disableMyButtons() { @@ -2390,7 +2402,7 @@ void gameTableImpl::nextRoundCleanGui() { boardCardsArray[i]->setPixmap(onePix, FALSE); boardCardsArray[i]->setFadeOutAction(FALSE); boardCardsArray[i]->stopFlipCardsAnimation(); - setLabelArray[i]->stopTimeOutAnimation(); + timeoutLabelArray[i]->stopTimeOutAnimation(); } for (i=0; ikey() == Qt::Key_M) { startVoteOnKick(3,60, 6); } - //if (event->key() == Qt::Key_N) { endVoteOnKick(); } + //if (event->key() == Qt::Key_M) { startVoteOnKick(3,60, 6); } } void gameTableImpl::changePlayingMode() { @@ -2760,7 +2771,7 @@ void gameTableImpl::localGameModification() { int i; for (i=0; istopTimeOutAnimation(); + timeoutLabelArray[i]->stopTimeOutAnimation(); playerAvatarLabelArray[i]->setEnabledContextMenu(FALSE); } diff --git a/src/gui/qt/gametable/gametableimpl.h b/src/gui/qt/gametable/gametableimpl.h index 393342c2..47deefc7 100755 --- a/src/gui/qt/gametable/gametableimpl.h +++ b/src/gui/qt/gametable/gametableimpl.h @@ -356,6 +356,7 @@ private: QLabel *actionLabelArray[MAX_NUMBER_OF_PLAYERS]; QLabel *playerNameLabelArray[MAX_NUMBER_OF_PLAYERS]; MyAvatarLabel *playerAvatarLabelArray[MAX_NUMBER_OF_PLAYERS]; + MyTimeoutLabel *timeoutLabelArray[MAX_NUMBER_OF_PLAYERS]; QGroupBox *groupBoxArray[MAX_NUMBER_OF_PLAYERS]; MyCardsPixmapLabel *boardCardsArray[5]; diff --git a/src/gui/qt/gametable/mysetlabel.cpp b/src/gui/qt/gametable/mysetlabel.cpp index 38bc3634..377b9cda 100755 --- a/src/gui/qt/gametable/mysetlabel.cpp +++ b/src/gui/qt/gametable/mysetlabel.cpp @@ -16,12 +16,8 @@ using namespace std; MySetLabel::MySetLabel(QGroupBox* parent) - : QLabel(parent), timeOutAnimation(FALSE), timeOutValue(0), timeOutFrame(0), waitFrames(0), timerIntervall(0), isBeep(0), isBeepPlayed(0) + : QLabel(parent) { - - timeOutAnimationTimer = new QTimer; - - connect(timeOutAnimationTimer, SIGNAL(timeout()), this, SLOT(nextTimeOutAnimationFrame())); } @@ -29,99 +25,7 @@ MySetLabel::~MySetLabel() { } -void MySetLabel::startTimeOutAnimation(int secs, bool beep) { - - isBeepPlayed = FALSE; - isBeep = beep; - - timeOutValue = secs; - timeOutFrame = 1; - timeOutAnimationWidth = 103; - - int preTimerIntervall = ((timeOutValue-3) * 1000)/timeOutAnimationWidth; - - timerIntervall = preTimerIntervall; - - //save gfx ressources and never play more the 10 pps - while(timerIntervall < 100) { - if(secs <= 9 && secs >= 6) { - //fix inaccuracies caused by integer division - timerIntervall = timerIntervall + preTimerIntervall + 5; - } - else { - timerIntervall = timerIntervall + preTimerIntervall; - } - } - - waitFrames = 3000/timerIntervall; - - //start the real timer - realTimer.reset(); - realTimer.start(); - -// std::cout << timerIntervall << endl; - timeOutAnimation = TRUE; - timeOutAnimationTimer->start(timerIntervall); -} - -void MySetLabel::startTimeOutAnimationNow() { - - timeOutAnimation = TRUE; - timeOutAnimationTimer->start(83); - -} - -void MySetLabel::stopTimeOutAnimation() { - -// timeOutAnimationKickOnTimer->stop(); - timeOutAnimationTimer->stop(); - timeOutAnimation = FALSE; - update(); -} - -void MySetLabel::nextTimeOutAnimationFrame() { - - if(timeOutAnimationWidth >=0) { - if(timeOutFrame > waitFrames) { - //play beep after waitFrames one time - if(isBeep && !isBeepPlayed) { - myW->getMySDLPlayer()->playSound("yourturn",0); - isBeepPlayed = TRUE; - } - //save gfx ressources and never play more the 10 pps - unsigned int realTimerValue = realTimer.elapsed().total_milliseconds(); - timeOutAnimationWidth = 103-(((realTimerValue-3000)*103)/((timeOutValue-3)*1000)); - - } - timeOutFrame++; - update(); - } - else { - stopTimeOutAnimation(); - // no callback is called here. - // the server initiates any action required. - } -} - - void MySetLabel::paintEvent(QPaintEvent * event) { - if(!timeOutAnimation || timeOutFrame <= waitFrames) { QLabel::paintEvent(event); - } - - if(timeOutAnimation && timeOutFrame > waitFrames) { - - QPainter painter(this); - - QLinearGradient linearGrad(QPointF(0, 10), QPointF(98, 10)); - linearGrad.setColorAt(0, Qt::red); - linearGrad.setColorAt(0.5, Qt::yellow); - linearGrad.setColorAt(1, Qt::green); - - painter.setBrush(linearGrad); - - painter.setPen(QColor(0,0,0)); - painter.drawRect(0,2,timeOutAnimationWidth-1,8); - } } diff --git a/src/gui/qt/gametable/mysetlabel.h b/src/gui/qt/gametable/mysetlabel.h index b7e67683..fbb4ab9e 100644 --- a/src/gui/qt/gametable/mysetlabel.h +++ b/src/gui/qt/gametable/mysetlabel.h @@ -16,8 +16,6 @@ #include #include -#include -#include "sdlplayer.h" class gameTableImpl; @@ -31,40 +29,14 @@ public: void setMyW ( gameTableImpl* theValue ) { myW = theValue; } - - void startTimeOutAnimation(int secs, bool beep); - void stopTimeOutAnimation(); - - void paintEvent(QPaintEvent * event); - + void paintEvent(QPaintEvent * event); public slots: - void startTimeOutAnimationNow(); - void nextTimeOutAnimationFrame(); - private: - gameTableImpl *myW; - QTimer *timeOutAnimationTimer; - QTimer *timeOutAnimationKickOnTimer; - -// boost::shared_ptr mySDLPlayer; + gameTableImpl *myW; - boost::timers::portable::microsec_timer realTimer; - - bool timeOutAnimation; - - int timeOutAnimationWidth; - int timeOutValue; - int timeOutFrame; - int waitFrames; - int decreaseWidthIntervall; - int timerIntervall; - bool isBeep; - bool isBeepPlayed; - - }; #endif diff --git a/src/gui/qt/gametable/mytimeoutlabel.cpp b/src/gui/qt/gametable/mytimeoutlabel.cpp index 25b3438e..0f45b96e 100644 --- a/src/gui/qt/gametable/mytimeoutlabel.cpp +++ b/src/gui/qt/gametable/mytimeoutlabel.cpp @@ -36,7 +36,7 @@ void MyTimeoutLabel::startTimeOutAnimation(int secs, bool beep) { timeOutValue = secs; timeOutFrame = 1; - timeOutAnimationWidth = 50; + timeOutAnimationWidth = 52; int preTimerIntervall = ((timeOutValue-3) * 1000)/timeOutAnimationWidth; @@ -90,7 +90,7 @@ void MyTimeoutLabel::nextTimeOutAnimationFrame() { } //save gfx ressources and never play more the 10 pps unsigned int realTimerValue = realTimer.elapsed().total_milliseconds(); - timeOutAnimationWidth = 50-(((realTimerValue-3000)*50)/((timeOutValue-3)*1000)); + timeOutAnimationWidth = 52-(((realTimerValue-3000)*52)/((timeOutValue-3)*1000)); } timeOutFrame++; @@ -114,7 +114,7 @@ void MyTimeoutLabel::paintEvent(QPaintEvent * event) { QPainter painter(this); - QLinearGradient linearGrad(QPointF(0, 10), QPointF(45, 10)); + QLinearGradient linearGrad(QPointF(0, 10), QPointF(47, 10)); linearGrad.setColorAt(0, Qt::red); linearGrad.setColorAt(0.5, Qt::yellow); linearGrad.setColorAt(1, Qt::green); @@ -122,6 +122,6 @@ void MyTimeoutLabel::paintEvent(QPaintEvent * event) { painter.setBrush(linearGrad); painter.setPen(QColor(0,0,0)); - painter.drawRect(0,2,timeOutAnimationWidth-1,8); + painter.drawRect(0,1,timeOutAnimationWidth-1,8); } }