timout animation test

This commit is contained in:
doitux
2009-04-19 20:23:20 +00:00
parent d6c04c96e6
commit 6328ecfe44
9 changed files with 1578 additions and 1312 deletions
+936 -912
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -29,6 +29,8 @@
#include "myavatarlabel.h"
#include "myactionbutton.h"
#include "mychancelabel.h"
#include "mytimeoutlabel.h"
#include "mymenubar.h"
#include "log.h"
#include "chat.h"
@@ -265,6 +267,7 @@ gameTableImpl::gameTableImpl(ConfigFile *c, QMainWindow *parent)
setLabelArray[8] = textLabel_Set8;
setLabelArray[9] = textLabel_Set9;
for (i=0; i<MAX_NUMBER_OF_PLAYERS; i++) { setLabelArray[i]->setMyW(this); }
label_Timeout0->setMyW(this);
// statusLabelArray init
actionLabelArray[0] = textLabel_Status0;
@@ -1497,6 +1500,7 @@ void gameTableImpl::startTimeoutAnimation(int playerId, int timeoutSec) {
//beep for player 0
if(playerId) { setLabelArray[playerId]->startTimeOutAnimation(timeoutSec, FALSE); }
else { setLabelArray[playerId]->startTimeOutAnimation(timeoutSec, TRUE); }
label_Timeout0->startTimeOutAnimation(timeoutSec, FALSE);
}
void gameTableImpl::stopTimeoutAnimation(int playerId) {
+1
View File
@@ -40,6 +40,7 @@ class BoardInterface;
class PlayerInterface;
class MyCardsPixmapLabel;
class MyAvatarLabel;
class MyTimeoutLabel;
class settingsDialogImpl;
class startWindowImpl;
+11
View File
@@ -0,0 +1,11 @@
#include "mymenubar.h"
MyMenuBar::MyMenuBar(QMainWindow* parent)
: QMenuBar(parent)
{
}
void MyMenuBar::paintEvent(QPaintEvent * event) {
QMenuBar::paintEvent(event);
}
+16
View File
@@ -0,0 +1,16 @@
#ifndef MYMENUBAR_H
#define MYMENUBAR_H
#include <QtGui>
#include <QtCore>
class MyMenuBar : public QMenuBar
{
Q_OBJECT
public:
MyMenuBar(QMainWindow*);
void paintEvent(QPaintEvent * event);
};
#endif
+127
View File
@@ -0,0 +1,127 @@
//
// C++ Implementation: mycardspixmaplabel
//
// Description:
//
//
// Author: FThauer FHammer <f.thauer@web.de>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include "mytimeoutlabel.h"
#include "gametableimpl.h"
using namespace std;
MyTimeoutLabel::MyTimeoutLabel(QGroupBox* parent)
: QLabel(parent), timeOutAnimation(FALSE), timeOutValue(0), timeOutFrame(0), waitFrames(0), timerIntervall(0), isBeep(0), isBeepPlayed(0)
{
timeOutAnimationTimer = new QTimer;
connect(timeOutAnimationTimer, SIGNAL(timeout()), this, SLOT(nextTimeOutAnimationFrame()));
}
MyTimeoutLabel::~MyTimeoutLabel()
{
}
void MyTimeoutLabel::startTimeOutAnimation(int secs, bool beep) {
isBeepPlayed = FALSE;
isBeep = beep;
timeOutValue = secs;
timeOutFrame = 1;
timeOutAnimationWidth = 50;
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 MyTimeoutLabel::startTimeOutAnimationNow() {
timeOutAnimation = TRUE;
timeOutAnimationTimer->start(83);
}
void MyTimeoutLabel::stopTimeOutAnimation() {
// timeOutAnimationKickOnTimer->stop();
timeOutAnimationTimer->stop();
timeOutAnimation = FALSE;
update();
}
void MyTimeoutLabel::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 = 50-(((realTimerValue-3000)*50)/((timeOutValue-3)*1000));
}
timeOutFrame++;
update();
}
else {
stopTimeOutAnimation();
// no callback is called here.
// the server initiates any action required.
}
}
void MyTimeoutLabel::paintEvent(QPaintEvent * event) {
if(!timeOutAnimation || timeOutFrame <= waitFrames) {
QLabel::paintEvent(event);
}
if(timeOutAnimation && timeOutFrame > waitFrames) {
QPainter painter(this);
QLinearGradient linearGrad(QPointF(0, 10), QPointF(45, 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);
}
}
+70
View File
@@ -0,0 +1,70 @@
//
// C++ Interface: mycardspixmaplabel
//
// Description:
//
//
// Author: FThauer FHammer <f.thauer@web.de>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef MYTIMEOUTLABEL_H
#define MYTIMEOUTLABEL_H
#include <iostream>
#include <QtGui>
#include <QtCore>
#include <third_party/boost/timers.hpp>
#include "sdlplayer.h"
class gameTableImpl;
class MyTimeoutLabel : public QLabel
{
Q_OBJECT
public:
MyTimeoutLabel(QGroupBox*);
~MyTimeoutLabel();
void setMyW ( gameTableImpl* theValue ) { myW = theValue; }
void startTimeOutAnimation(int secs, bool beep);
void stopTimeOutAnimation();
void paintEvent(QPaintEvent * event);
public slots:
void startTimeOutAnimationNow();
void nextTimeOutAnimationFrame();
private:
gameTableImpl *myW;
QTimer *timeOutAnimationTimer;
QTimer *timeOutAnimationKickOnTimer;
// boost::shared_ptr<SDLPlayer> mySDLPlayer;
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
+1 -1
View File
@@ -562,7 +562,7 @@ void GameTableStyleReader::setCardHolderStyle(QLabel *l, int bero)
void GameTableStyleReader::setMenuBarStyle(QMenuBar *mb)
{
mb->setStyleSheet("QMenuBar { background-color: #"+MenuBgColor+"; font-size:12px; } QMenuBar::item { color: #"+MenuTextColor+"; }");
mb->setStyleSheet("QMenuBar { background-color: #"+MenuBgColor+"; font-size:12px; } QMenuBar::item { color: #"+MenuTextColor+"; }");
}
void GameTableStyleReader::setBreakButtonStyle(QPushButton *bb, int state)