Logo Search packages:      
Sourcecode: schafkopf version File versions  Download package

void SchafKopf::customEvent ( QCustomEvent *  e  )  [protected]

Event handler to receive thread events

Definition at line 137 of file schafkopf.cpp.

References enableControls().

{
    if( e->type() == SCHAFKOPF_EVENT )
    {
        int* a;
        bool force_select = false;
        
        t_EventData* data = (t_EventData*)e->data();
        switch( data->type )
        {
            case GameEnded:
                //EXIT_LOOP();
                m_canvasview->resetPlayerCards();
                // fall through!

            case RedrawPlayers:
                m_canvasview->redrawPlayers();
                enableControls();
                break;
            
            case GameStarted:
                m_canvasview->resetPlayers();
                m_canvasview->redrawPlayers();
                enableControls();
                break;
                        
            case GameInfoSetup:
                updateInfo();
                break;
                
            case PlayerIsLast:
                m_canvasview->playerIsLast( data->playerid );
                break;
                
            case PlayerDoubled:
                updateInfo();
                m_canvasview->information( data->data );
                break;
                
            case PlayerHasDoubled:
                m_canvasview->playerHasDoubled( data->playerid, true );
                break;
                
            case CardPlayed:
                m_canvasview->slotPlayerPlayedCard( data->playerid, *(data->cardids) );
                break;
            
            case PlayerMadeStich:
                m_canvasview->slotPlayerMadeStich( data->playerid );
                m_stichdlg->changed( data->data, data->cardids, data->playernames );
                break;
            
            case PlayerResults:
                this->slotPlayerResult( data->playerid, data->data );
                break;
                
            case InfoMessage:
                m_canvasview->information( data->data );
                break;
                
            case QuestionYesNo:
                a = new int;
                *a = m_canvasview->questionYesNo( data->data ) ? YES : NO;
                data->returncode = (void*)a;
                break;
            
            case HumanPlayerGetCard:
                a = new int;
                *a = m_canvasview->getCard();
                data->returncode = (void*)a;
                break;
            
            case ForbiddenCard:
                m_canvasview->cardForbidden( *(data->cardids) );
                break;
            
            case ForcedSelectGame:
                force_select = true;
                // fall through!
            case SelectGame:
                data->returncode = (void*)selectGame( force_select, data->cardids );
                break;
                
            case PlayerNameChanged:
                m_canvasview->setPlayerName( data->playerid, data->data );
                break;
                
            case PlayerGotCards:
                m_canvasview->setPlayerCards( data->playerid, data->cardids );
                break;
                
            default:
                break;
        }
        
        data->quitgame = m_terminated;
        
        if( data->wait )
        {
            sem_post( &m_sem );
        }
        else        
        {
            // compiler warns that deleting void is undefined....
            // data->returncode should be NULL anyways...
            // so why is it there???
            // stupid comments...
            if( data->returncode )
                delete data->returncode;
                
            if( data->cardids )
                delete [] data->cardids;

            if( data->playernames )
                delete data->playernames;
                
            delete data;
        }
    }
}


Generated by  Doxygen 1.6.0   Back to index