Пример #1
0
/*
 *******************************************************************
 * Function: int BehaviourFunction( const CKBehaviorContext& behaviorContext )
 *
 * Description : The execution function is the function that will be called 
 *               during the process loop of the behavior engine, if the behavior 
 *               is defined as using an execution function. This function is not 
 *               called if the behavior is defined as a graph. This function is the 
 *               heart of the behavior: it should compute the essence of the behavior, 
 *               in an incremental way. The minimum amount of computing should be 
 *               done at each call, to leave time for the other behaviors to run. 
 *               The function receives the delay in milliseconds that has elapsed 
 *               since the last behavioral process, and should rely on this value to 
 *               manage the amount of effect it has on its computation, if the effect 
 *               of this computation relies on time.
 *
 * Parameters :
 *    behaviourContext    r   Behavior context reference, which gives access to 
 *                            frequently used global objects ( context, level, manager, etc... )
 *
 * Returns : int, If it is done, it should return CKBR_OK. If it returns 
 *                CKBR_ACTIVATENEXTFRAME, the behavior will again be called 
 *                during the next process loop.
 *
 *******************************************************************
 */
int GBLPFGetTeamLeader::BehaviourFunction( const CKBehaviorContext& behaviorContext )
{
    CKBehavior *behaviour=behaviorContext.Behavior;
    CKContext *context = behaviorContext.Context;
    CGBLCOError returnValue;

    behaviour->ActivateInput(EGBLGetTeamLeaderBehInputs::In, false);
    XString FieldName("TeamLeaderID");
    CKDataArray* FieldData = (CKDataArray*)context->CreateObject(CKCID_DATAARRAY, "FieldData", CK_OBJECTCREATION_DYNAMIC);
    
    CGBLTeamID TeamId ;
    behaviour->GetInputParameterValue(EGBLGetTeamLeaderParamInputs::TeamId, &TeamId);
    CGBLUserID PlayerId;

    CGBLProfileManager *pm = (CGBLProfileManager *)context->GetManagerByGuid(GBLProfileManagerGUID);
    returnValue = pm->GetProfileField((CGBLProfileID)TeamId, FieldName, (CKDataArray*)FieldData);
    int value;
    if(!FieldData->GetElementValue(0,0,&value))
    {
        returnValue = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL;
    }
    else
    {
        PlayerId = value;
    }
    
    
    if ((int)returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK)
    {
        behaviour->ActivateOutput(EGBLGetTeamLeaderBehOutputs::Success, true);
        behaviour->SetOutputParameterValue(EGBLGetTeamLeaderParamOutputs::UserID, &PlayerId);
    }
    else
    {
        CKParameterOut *pOut = behaviour->GetOutputParameter(EGBLGetTeamLeaderParamOutputs::ErrorCode);
        CGBLCOError::EGBLCOErrorType tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK ;
        switch((CGBLCOError::EGBLCOErrorType)returnValue)
        {
        case 0:
            tType = CGBLCOError::EGBLCOErrorType::GBLCO_OK;
            break;
        case 1:
            tType = CGBLCOError::EGBLCOErrorType::GBLCO_FATAL;
            break;
        case 2:
            tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL;
            break;
        case 3:
            tType = CGBLCOError::EGBLCOErrorType::GBLCO_LOCAL;
            break;
        }
        
        
		const char*errorString = returnValue;
        TGBLError::SetTGBLError(pOut, tType,returnValue, (CKSTRING)errorString);
        behaviour->ActivateOutput(EGBLGetTeamLeaderBehOutputs::Error, true);
    }
    context->DestroyObject(FieldData);
    return CKBR_OK;
}
Пример #2
0
QVariant AbstractTestModel::headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */) const
{
	if (orientation == Qt::Vertical)
		return base_type::headerData(section, orientation, role);

	switch (role)
	{
	    case Qt::DisplayRole:
	    case Qt::ToolTipRole:
		    return FieldName(section);

	    default: return {};
	}
}
Пример #3
0
void TypeStateWriterDatabase::Next()
{
    if( AtEnd() )
        return;

    ++m_Count;

    if( m_Size <= m_Count )
    {
        Stop();
        return;
    }

    QStringList tmp = m_Database->GetRecord(
                          TableName(), FieldName(), QString::number( Count() ) );
    tmp.pop_front();
    m_Data = tmp;
}
Пример #4
0
TypeStateWriterDatabase::TypeStateWriterDatabase( TypeDatabase& database,
        QString table_name, QString field_name, long size, long flags, TypeVariant* parent ):
    TypeStateWriter( flags, parent )
{
    m_Database = &database;
    m_TableName = table_name;
    m_FieldName = field_name;
    m_Size = size;

    if( m_Size < 1 )
    {
        Stop();
        return;
    }

    QStringList tmp = m_Database->GetRecord(
                          TableName(), FieldName(), QString::number( Count() ) );
    tmp.pop_front();
    m_Data = tmp;
}
Пример #5
0
QString AbstractTestModel::FieldName(const QModelIndex & index) const
{
	return FieldName(index.column());
}