예제 #1
0
void FMODSoundEvent::PerformCallback(FMOD::Event * fmodEvent)
{
    Vector<FMOD::Event *>::iterator it = std::find(fmodEventInstances.begin(), fmodEventInstances.end(), fmodEvent);
    if(it != fmodEventInstances.end())
    {
		PerformEvent(SoundEvent::EVENT_END);
		fmodEventInstances.erase(it);
		SoundSystem::Instance()->ReleaseOnUpdate(this);
    }
}
예제 #2
0
void Animation::OnStart()
{
//#ifdef ANIMATIONS_DEBUG
//	if(AnimationManager::Instance()->IsAnimationLoggerEnabled())
//	{
//		Logger::Debug("ANIMATION LOGGER: Animation::OnStart 0x%x    for owner 0x%x", (int)this, (int)owner);
//	}
//#endif
	PerformEvent(EVENT_ANIMATION_START);
};
예제 #3
0
void UISlider::Input(UIEvent *currentInput)
{
#if !defined(__DAVAENGINE_IPHONE__) && !defined(__DAVAENGINE_ANDROID__)                                        
	if (currentInput->phase == UIEvent::PHASE_MOVE || currentInput->phase == UIEvent::PHASE_KEYCHAR)
		return;
#endif
	
	const Rect & absRect = GetGeometricData().GetUnrotatedRect();
	//absTouchPoint = currentInput->point;
	
	relTouchPoint = currentInput->point;
	relTouchPoint -= absRect.GetPosition();
	
	
	float oldVal = currentValue;
	currentValue = Interpolation::Linear(minValue, maxValue, (float32)leftInactivePart, relTouchPoint.x, size.x - (float32)rightInactivePart);
	
	if(currentValue < minValue)
	{
		currentValue = minValue;
	}
	if(currentValue > maxValue)
	{
		currentValue = maxValue;
	}

	if (isEventsContinuos) // if continuos events
	{
		if(oldVal != currentValue)
		{
			PerformEvent(EVENT_VALUE_CHANGED);
		}
	}else if (currentInput->phase == UIEvent::PHASE_ENDED) 
	{
		/* if not continuos always perform event because last move position almost always the same as end pos */
		PerformEvent(EVENT_VALUE_CHANGED);
	}
			  
			  
	RecalcButtonPos();
}
예제 #4
0
bool UIList::SystemInput(UIEvent *currentInput)
{
	if(!inputEnabled || !visible || controlState & STATE_DISABLED)
	{
		return false;
	}

	if(currentInput->touchLocker != this)
	{
		if(currentInput->phase == UIEvent::PHASE_BEGAN)
		{
			if(IsPointInside(currentInput->point))
			{
				PerformEvent(EVENT_TOUCH_DOWN);
				Input(currentInput);
			}
		}
		else if(currentInput->tid == mainTouch && currentInput->phase == UIEvent::PHASE_DRAG)
		{
			if(orientation == ORIENTATION_HORIZONTAL)
			{
				if(abs(currentInput->point.x - newPos) > touchHoldSize)
				{
					UIControlSystem::Instance()->SwitchInputToControl(mainTouch, this);
					newPos = currentInput->point.x;
					return TRUE;
				}
			}
			else 
			{
				if(abs(currentInput->point.y - newPos) > touchHoldSize)
				{
					UIControlSystem::Instance()->SwitchInputToControl(mainTouch, this);
					newPos = currentInput->point.y;
					return TRUE;
				}
			}
		}
		else if(currentInput->tid == mainTouch && currentInput->phase == UIEvent::PHASE_ENDED)
		{
			mainTouch = 0;
			lockTouch = false;
		}

		

	}

	return UIControl::SystemInput(currentInput);
}
예제 #5
0
void FMODSoundEvent::Stop(bool force /* = false */)
{
    SoundSystem * soundSystem = SoundSystem::Instance();

	Vector<FMOD::Event *> instancesCopy(fmodEventInstances);
	int32 instancesCount = instancesCopy.size();
	for(int32 i = 0; i < instancesCount; ++i)
	{
        FMOD::Event * fEvent = instancesCopy[i];
		FMOD_VERIFY(fEvent->setCallback(0, 0));
        FMOD_VERIFY(fEvent->stop(force));

		PerformEvent(SoundEvent::EVENT_END);
		soundSystem->ReleaseOnUpdate(this);
	}
	fmodEventInstances.clear();
}
예제 #6
0
bool FMODSoundEvent::Trigger()
{
    SoundSystem * soundSystem = SoundSystem::Instance();
    FMOD::EventSystem * fmodEventSystem = soundSystem->fmodEventSystem;
    
    if(is3D)
    {
        FMOD::Event * fmodEventInfo = 0;
        FMOD_VERIFY(fmodEventSystem->getEvent(eventName.c_str(), FMOD_EVENT_INFOONLY, &fmodEventInfo));
        if(fmodEventInfo)
        {
            FMOD_VERIFY(fmodEventInfo->set3DAttributes((FMOD_VECTOR*)&position, 0, isDirectional ? (FMOD_VECTOR*)&direction : NULL));
            FMOD_VERIFY(fmodEventInfo->setVolume(volume));
            ApplyParamsToEvent(fmodEventInfo);
        }
    }
    
    FMOD::Event * fmodEvent = 0;
    FMOD_RESULT result = fmodEventSystem->getEvent(eventName.c_str(), FMOD_EVENT_DEFAULT, &fmodEvent);
    if(result == FMOD_OK)
    {
        ApplyParamsToEvent(fmodEvent);

		FMOD_VERIFY(fmodEvent->setVolume(volume));
		FMOD_RESULT startResult = fmodEvent->start();
		if(startResult == FMOD_OK)
		{
			FMOD_VERIFY(fmodEvent->setCallback(FMODEventCallback, this));
			fmodEventInstances.push_back(fmodEvent);
			Retain();
		}
		else if(startResult != FMOD_ERR_EVENT_FAILED) //'just fail' max playbacks behavior
		{
			Logger::Error("[FMODSoundEvent::Trigger()] Failed to start event by %d on eventID: %s", startResult, eventName.c_str());
		}
    }
    else if(result != FMOD_ERR_EVENT_FAILED) //'just fail' max playbacks behavior
    {
        Logger::Error("[FMODSoundEvent::Trigger()] Failed to retrieve event by %d on eventID: %s", result, eventName.c_str());
    }

    PerformEvent(EVENT_TRIGGERED);

    return fmodEvent != 0;
}
예제 #7
0
bool UIHierarchy::SystemInput(UIEvent *currentInput)
{
    if(!inputEnabled || !visible || controlState & STATE_DISABLED)
    {
        return false;
    }
    
    if(currentInput->touchLocker != this)
    {
        if(currentInput->phase == UIEvent::PHASE_BEGAN)
        {
            if(IsPointInside(currentInput->point))
            {
                PerformEvent(EVENT_TOUCH_DOWN);
                Input(currentInput);
            }
        }
        else if(currentInput->tid == mainTouch && currentInput->phase == UIEvent::PHASE_DRAG)
        {
            bool isCommandPressed =     InputSystem::Instance()->GetKeyboard()->IsKeyPressed(DVKEY_CTRL) 
                                    ||  InputSystem::Instance()->GetKeyboard()->IsKeyPressed(DVKEY_SHIFT);
            if(!isCommandPressed)
            {
                if(abs(currentInput->point.y - newPos) > touchHoldSize)
                {
                    UIControlSystem::Instance()->SwitchInputToControl(mainTouch, this);
                    newPos = currentInput->point.y;
                    return true;
                }
            }
            else
            {
                UIControlSystem::Instance()->SwitchInputToControl(mainTouch, this);
            }
        }
        else if(currentInput->tid == mainTouch && currentInput->phase == UIEvent::PHASE_ENDED)
        {
            mainTouch = 0;
            lockTouch = false;
        }
    }
    
    return UIControl::SystemInput(currentInput);
}
void EventDispatcher::PerformEvent(int32 eventType)
{
	PerformEvent(eventType, this);
}
예제 #9
0
void Animation::OnCancel()
{
	PerformEvent(EVENT_ANIMATION_CANCELLED);
}