Ejemplo n.º 1
0
Archivo: Pass.cpp Proyecto: luk2010/GRE
void Pass::setActivated(bool activate)
{
    auto ptr = lock();
    
    if(ptr)
        ptr->setActivated(activate);
}
Ejemplo n.º 2
0
void CMovement::UpdateMovement(vfloat32 time) {
	if(!isActivated())
		return;
	
	_sprite->UpdateAnimation(time);
	
	if(_frame != _sprite->getFrame()){
		_frame = _sprite->getFrame();

		//printf("\n 1 %d %d",_characterPosition->getX(), _characterPosition->getY());
		//printf("\n 2 %d %d %d",_frame, _offsetPerFrame[_frame]->getX(), _offsetPerFrame[_frame]->getY());
		*_characterPosition += *_offsetPerFrame[_frame];
		//printf("\n 3 %d %d",_characterPosition->getX(), _characterPosition->getY());
		_position->setXY(*_characterPosition);
		//printf("\n 4 %d %d",_characterPosition->getX(), _characterPosition->getY());

		/*
		if( _positionPerFrame[_frame]->getX() != 0){
			printf("\nX %d ",_positionPerFrame[_frame]->getX());
			printf("\nY %d ",_positionPerFrame[_frame]->getY());
		}
		*/

		*_position += *_positionPerFrame[_frame];

		_sprite->MoveSpriteToPos(_position);
	}
	

	_currentDuration += time;
	if(_currentDuration >= _totalDuration){
		if(_loopeable){
			_currentDuration = 0;
		}else{
			setActivated(false);
		}
	}
} // UpdateMovement
Ejemplo n.º 3
0
//创建一则消息,包括将其加入MsgTable和MsgQueue中
void createMsg(int msg_type, int pos_x, int pos_y, char key)
{
    int x = pos_x;
    int y = pos_y;
    //if(msg_type != 0) cprintf("msg type: %d\n", msg_type);
    /*if(msg_type == MSG_LPRESS || msg_type == MSG_RPRESS || msg_type == MSG_DOUBLECLICK
        || msg_type == MSG_KEYDOWN || msg_type == MSG_DRAG)
        cprintf("msg type: %d\n", msg_type);*/
	int pid;
    int msg_index;
	if(msg_type == MSG_KEYDOWN)//键盘事件
	{
		pid = getActivated()->pid;
        msg_index = requireMsg(msg_type, x, y, key, 0);
	    if (msg_index == -1) return;
        dispatch(pid, msg_index);
	}
	else//鼠标事件
	{
        if(mouse_x == -1) mouse_x = pos_x;
        if(mouse_y == -1) mouse_y = pos_y;

        struct Window* win_ptr = getWindowByPoint(pos_x, pos_y);
        //cprintf("%d\n", win_ptr);
        pid = win_ptr->pid;

        x = pos_x - win_ptr->window_position.left_x;//relative x
        y = pos_y - win_ptr->window_position.left_y;//relative y

        if(msg_type == MSG_LPRESS || msg_type == MSG_RPRESS || msg_type == MSG_DOUBLECLICK)
        {
            if (win_ptr->next_window != 0)
                setActivated(win_ptr);
            msg_index = requireMsg(msg_type, x, y, key, 0);
	        if (msg_index == -1) return;
            dispatch(pid, msg_index);
        }

        if(msg_type == MSG_DRAG)
        {
            if (win_ptr->next_window != 0)
              setActivated(win_ptr);
        	if(win_ptr->prior_window == 0)//desktop
            {
                mouse_x = pos_x;
                mouse_y = pos_y;
		        drawMouse(pos_x, pos_y);
             	return;
            }

            int dx = pos_x - mouse_x;
            int dy = pos_y - mouse_y;

            int win_left_x = win_ptr->window_position.left_x;
            int win_left_y = win_ptr->window_position.left_y;
            int win_right_x = win_ptr->window_position.right_x;
            int win_right_y = win_ptr->window_position.right_y;

            int x1 = (dx > 0) ? win_left_x : (win_left_x + dx);
            int y1 = (dy > 0) ? win_left_y : (win_left_y + dy);
            int x2 = (dx > 0) ? (win_right_x + dx) : win_right_x;
            int y2 = (dy > 0) ? (win_right_y + dy) : win_right_y;

            /*if( (dx > -10 && dx < 10)|| (dy > -10 && dy < 10))
            {
                //cprintf("one tiny drag!\n");
                return;
            }*/
            if(win_left_x + dx >= 0 && win_left_y + dy >= 0
                && win_right_x + dx < SCREEN_WIDTH
                && win_right_y + dy < SCREEN_HEIGHT)//判断合法位移
            {
                win_ptr->window_position.left_x += dx;
                win_ptr->window_position.left_y += dy;
                win_ptr->window_position.right_x += dx;
                win_ptr->window_position.right_y += dy;
            }
            else
            {
                mouse_x = pos_x;
                mouse_y = pos_y;
		        drawMouse(pos_x, pos_y);
                return;
            }
            /*
	        if (msg_index == -1) return;*/
            //dispatch(pid, msg_index);
            cprintf("update area: x1: %d, y1: %d, x2: %d, y2:%d.\n", x1, y1, x2, y2);
            //drawScreenArea(x1, y1, x2, y2);
            drawScreen();
            mouse_x = pos_x;
            mouse_y = pos_y;
            setMouse(mouse_x, mouse_y);
            return;
        }

        mouse_x = pos_x;
        mouse_y = pos_y;
		drawMouse(pos_x, pos_y);
	}
}
Ejemplo n.º 4
0
void UserInterface::run()
{
    while (true)
    {
        hIMutex.lock();
        while (!hasInterrupt)
            hICondition.wait(&hIMutex);
        hIMutex.unlock();
        if (isAborting)
            return;
        usingUI = true;
        printf("\n");
        printf("  0: Cancel\n");
        printf("  1: Activate\n");
        printf("  2: Deactivate\n");
        printf("  3: Set my name\n");
        printf("  4: Set follow name\n");
        printf("  5: Set target name\n");
        printf("  9: Exit\n");
        int action = -1;
        while (action)
        {
            printf("Action: ");
            fflush(stdout);
            scanf("%d", &action);
            switch (action)
            {
            case 0:
                break;
            case 1:
                emit setActivated(true);
                action = 0;
                break;
            case 2:
                emit setActivated(false);
                action = 0;
                break;
            case 3:
                printf("Name: ");
                fflush(stdout);
                fgets(buffer, 10, stdin);
                emit setMyName(QString(buffer));
                action = 0;
                break;
            case 4:
                printf("Name: ");
                fflush(stdout);
                fgets(buffer, 10, stdin);
                emit setFollowName(QString(buffer));
                action = 0;
                break;
            case 5:
                printf("Name: ");
                fflush(stdout);
                fgets(buffer, 10, stdin);
                emit setTargetName(QString(buffer));
                action = 0;
                break;
            case 9:
                return;
            default:
                printf("Error: Unknown action.\n");
            }
        }
        usingUI = false;
        hasInterrupt = false;
    }
}
Ejemplo n.º 5
0
// Channel/instance number accessors.
void qtractorLadspaPlugin::setChannels ( unsigned short iChannels )
{
	// Check our type...
	qtractorPluginType *pType = type();
	if (pType == NULL)
		return;
		
	// Estimate the (new) number of instances...
	unsigned short iOldInstances = instances();
	unsigned short iInstances
		= pType->instances(iChannels, list()->isMidi());
	// Now see if instance count changed anyhow...
	if (iInstances == iOldInstances)
		return;

	const LADSPA_Descriptor *pLadspaDescriptor = ladspa_descriptor();
	if (pLadspaDescriptor == NULL)
		return;

	// Gotta go for a while...
	bool bActivated = isActivated();
	setActivated(false);

	// Set new instance number...
	setInstances(iInstances);

	if (m_phInstances) {
		if (pLadspaDescriptor->cleanup) {
			for (unsigned short i = 0; i < iOldInstances; ++i)
				(*pLadspaDescriptor->cleanup)(m_phInstances[i]);
		}
		delete [] m_phInstances;
		m_phInstances = NULL;
	}

	// Bail out, if none are about to be created...
	if (iInstances < 1) {
		setActivated(bActivated);
		return;
	}

#ifdef CONFIG_DEBUG
	qDebug("qtractorLadspaPlugin[%p]::setChannels(%u) instances=%u",
		this, iChannels, iInstances);
#endif

	// We'll need output control (not dummy anymore) port indexes...
	unsigned short iControlOuts = pType->controlOuts();
	// Allocate new instances...
	m_phInstances = new LADSPA_Handle [iInstances];
	for (unsigned short i = 0; i < iInstances; ++i) {
		// Instantiate them properly first...
		LADSPA_Handle handle
			= (*pLadspaDescriptor->instantiate)(pLadspaDescriptor, sampleRate());
		// Connect all existing input control ports...
		const qtractorPlugin::Params& params = qtractorPlugin::params();
		qtractorPlugin::Params::ConstIterator param = params.constBegin();
		const qtractorPlugin::Params::ConstIterator& param_end = params.constEnd();
		for ( ; param != param_end; ++param) {
			qtractorPluginParam *pParam = param.value();
			// Just in case the plugin decides
			// to set the port value at this time...
			float *pfValue = pParam->subject()->data();
			float   fValue = *pfValue;
			(*pLadspaDescriptor->connect_port)(handle,
				pParam->index(), pfValue);
			// Make new one the default and restore port value...
			pParam->setDefaultValue(*pfValue);
			*pfValue = fValue;
		}
		// Connect all existing output control ports...
		for (unsigned short j = 0; j < iControlOuts; ++j) {
			(*pLadspaDescriptor->connect_port)(handle,
				m_piControlOuts[j], &m_pfControlOuts[j]);
		}
		// This is it...
		m_phInstances[i] = handle;
	}

	// (Re)issue all configuration as needed...
	realizeConfigs();
	realizeValues();

	// But won't need it anymore.
	releaseConfigs();
	releaseValues();

	// (Re)activate instance if necessary...
	setActivated(bActivated);
}