Beispiel #1
0
/*! \fn Widget::switch_cards( int out, int pos )
 *  \param [in] out carte a enlever
 *  \param [in] pos position ou mettre la nouvelle
 *  \brief -1 pour desactiver un des deux 
 */
void Widget::switch_cards( int out, int pos ) //position dans la main
{
	Card *tmp=NULL;
	int x;

//enleve la carte (pas si -1)
if (out!=-1)
   {tmp = findCardOnPos( out );
    tmp->moveAnimated( -500, 500 );}
/*
qDebug()<<"switch : carte enlevee :" << conventionCarte(&joueur.main, pos+1);
*/
if (pos!=-1)
   {
//met la nouvelle (pas si -1)
    tmp = findCardOnPos( conventionCarte(&joueur.main, pos+1) );
    x= pos * (tmp->boundingRect().width() + SPACE);
    tmp->moveAnimated( x, POS_Y );
    tmp->setFlags( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable );
    }
/*
qDebug()<<"switch : carte ajoutee :" << pos;
*/
 }
Beispiel #2
0
void Widget::giveCards( void ) {
   int width, cardNr;
   int space = 10;
   int i = 0;
   Card *tmp;

   if( m_stack.count() != m_cards.count() )
      qDebug() << "FATAL: Stack aint got the same card count";

   while( !m_stack.empty() ) {
      cardNr = m_stack.pop();
      tmp = findCardOnPos( cardNr );
      width = tmp->boundingRect().width(); //FIXME
      tmp->moveAnimated( ( i % 3 ) * ( width + space ) ,
                           i / 3 * 60);
      tmp->setFlags( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable );
      tmp->setZValue( i );
      tmp->setData( NEWPOS , i );
      i++;
   }

   foreach( Card *tmpCard, m_cards ) {
      tmpCard->setData(OLDPOS, tmpCard->data(NEWPOS)) ;
   }