void CInfoPanel::AnimationStateChanged(bool state)
{
	if(!CAnimationManager::GetInstance())
		return;
	int stav = state;
	if(iSourceImage)
	{
		CAnimation* animation = NULL;
		if(iSourceImage->GetAnimation())
		{
			animation = iSourceImage->GetAnimation();
			animation->SetActive(state);

		}
		else
		{
			animation = CAnimationManager::GetInstance()->GetAnimation(iSourceImage);
			//animation->SetOwnerImage(iSourceImage);
			iSourceImage->SetAnimation(animation);
		}
		//TODO get animation params from UI
		/*if(animation)
		{
		animation->SetStartFrame(iAnimationStartField->value());
		animation->SetMSInterval(iAnimationMSIntervalField->value());
		animation->SetStopFrame(iAnimationStopField->value());
		animation->SetLoop(true);
		
		}*/
		animation->SetActive(state);
		}
	
}
Exemple #2
0
	//Static
	CAnimation* CSkeleton::AnimationParser(const std::string& p_crszKey, std::ifstream& p_rFile)
	{
		DEBUG(3, __FUNCTION__, "Parsing skeletal animation");
		std::string szData;
		CSkeleton* pSkele = new CSkeleton("data/skeletons/" + p_crszKey + ".skel");
		CAnimation* pAnim = new CAnimation();
		while(!p_rFile.eof())
		{
			p_rFile >> szData;
			DEBUG(3, __FUNCTION__, szData);
			if(szData == "end")
				break;
			
			if(szData == "nxt") //Next frame
			{
				DEBUG(3, __FUNCTION__, "Frame added");
				pAnim->AddFrame(pSkele);
				pSkele = new CSkeleton("data/skeletons/" + p_crszKey + ".skel");
			}
			else //Transformations
			{
				pSkele->ApplyTransformation(szData);
			}
		}

		pAnim->AddFrame(pSkele);
		return pAnim;
	}
Exemple #3
0
////////////////////////////////////////////////////////////////////////////
// Animations drag/drop
////////////////////////////////////////////////////////////////////////////
LRESULT AnimatorBar::OnBeginDrag(WPARAM wParam, LPARAM lParam)
{
	XHTMLTREEMSGDATA *pMsg = (XHTMLTREEMSGDATA *) wParam;
	ASSERT(pMsg);

	XHTMLTREEDRAGMSGDATA *pData = (XHTMLTREEDRAGMSGDATA *) lParam;

	LRESULT lResult = 0;

	if (pMsg && pData)
	{
		// If it's an angle, and there's no other angles..
		CAnimation* pAnimation = (CAnimation*)animations.GetItemData(pData->hItem);

		if (pAnimation->IsAngle())
		{
			// Get parent
			CAnimation* pParent = (CAnimation*)animations.GetItemData(animations.GetParentItem(pData->hItem));

			if (pParent->m_SubAnimations.size() == 1)
				lResult = 1;
		}
	}

	return lResult;	// return 0 to allow drag
}
Exemple #4
0
/*
 * Internal constructor.
 */
CSharedAnimation::CSharedAnimation(const STRING file): 
	m_frame(-1), 
	m_tick(0), 
	m_pAnm(NULL) 
{
	SHARED_ANIMATIONS::iterator i = m_shared.find(file);
	if (i != m_shared.end())
	{
		// Add a user to the current animation.
		i->second->addUser();
		m_pAnm = i->second;
	}
	else
	{
		// Create a new entry.
		CAnimation *p = new CAnimation(file);
		if (p->filename().empty()) 
		{
			// Filename not assigned during ANIMATION loading: failed to load animation.
			delete p;
			return;
		}
		m_shared[file] = m_pAnm = p;
	}
}
Exemple #5
0
void CGUIControl::SetVisible(bool bVisible, bool setVisState)
{
  if (bVisible && setVisState)
  {  // TODO: currently we only update m_visible from GUI_MSG_VISIBLE (SET_CONTROL_VISIBLE)
     //       otherwise we just set m_forceHidden
    GUIVISIBLE visible;
    if (m_visibleCondition)
      visible = m_visibleCondition->Get() ? VISIBLE : HIDDEN;
    else
      visible = VISIBLE;
    if (visible != m_visible)
    {
      m_visible = visible;
      SetInvalid();
    }
  }
  if (m_forceHidden == bVisible)
  {
    m_forceHidden = !bVisible;
    SetInvalid();
    if (m_forceHidden)
      MarkDirtyRegion();
  }
  if (m_forceHidden)
  { // reset any visible animations that are in process
    if (IsAnimating(ANIM_TYPE_VISIBLE))
    {
//        CLog::Log(LOGDEBUG, "Resetting visible animation on control %i (we are %s)", m_controlID, m_visible ? "visible" : "hidden");
      CAnimation *visibleAnim = GetAnimation(ANIM_TYPE_VISIBLE);
      if (visibleAnim) visibleAnim->ResetAnimation();
    }
  }
}
Exemple #6
0
CAnimation CAnimation::CreateFader(float start, float end, unsigned int delay, unsigned int length, ANIMATION_TYPE type)
{
  CAnimation anim;
  anim.m_type = type;
  anim.AddEffect(new CFadeEffect(start, end, delay, length));
  return anim;
}
/**
**  Parse an animation frame
**
**  @param str  string formated as "animationType extraArgs"
*/
static CAnimation *ParseAnimationFrame(lua_State *l, const char *str)
{
	const std::string all(str);
	const size_t len = all.size();
	size_t end = all.find(' ');
	const std::string op1(all, 0, end);
	size_t begin = std::min(len, all.find_first_not_of(' ', end));
	const std::string extraArg(all, begin);

	CAnimation *anim = NULL;
	if (op1 == "frame") {
		anim = new CAnimation_Frame;
	} else if (op1 == "exact-frame") {
		anim = new CAnimation_ExactFrame;
	} else if (op1 == "wait") {
		anim = new CAnimation_Wait;
	} else if (op1 == "random-wait") {
		anim = new CAnimation_RandomWait;
	} else if (op1 == "sound") {
		anim = new CAnimation_Sound;
	} else if (op1 == "random-sound") {
		anim = new CAnimation_RandomSound;
	} else if (op1 == "attack") {
		anim = new CAnimation_Attack;
	} else if (op1 == "spawn-missile") {
		anim = new CAnimation_SpawnMissile;
	} else if (op1 == "spawn-unit") {
		anim = new CAnimation_SpawnUnit;
	} else if (op1 == "if-var") {
		anim = new CAnimation_IfVar;
	} else if (op1 == "set-var") {
		anim = new CAnimation_SetVar;
	} else if (op1 == "set-player-var") {
		anim = new CAnimation_SetPlayerVar;
	} else if (op1 == "die") {
		anim = new CAnimation_Die();
	} else if (op1 == "rotate") {
		anim = new CAnimation_Rotate;
	} else if (op1 == "random-rotate") {
		anim = new CAnimation_RandomRotate;
	} else if (op1 == "move") {
		anim = new CAnimation_Move;
	} else if (op1 == "unbreakable") {
		anim = new CAnimation_Unbreakable;
	} else if (op1 == "label") {
		anim = new CAnimation_Label;
		AddLabel(anim, extraArg);
	} else if (op1 == "goto") {
		anim = new CAnimation_Goto;
	} else if (op1 == "random-goto") {
		anim = new CAnimation_RandomGoto;
	} else if (op1 == "lua-callback") {
		anim = new CAnimation_LuaCallback;
	} else {
		LuaError(l, "Unknown animation: %s" _C_ op1.c_str());
	}
	anim->Init(extraArg.c_str(), l);
	return anim;
}
bool CAnimationManager::IsAnimationPlaying(int nAnimID) const
{
	CAnimation* anim = GetAnimation(nAnimID);
	if(anim)
		return anim->IsPlaying();
	else
		return false;
}
bool CAnimationManager::UpdateAnimation(float fDelta, int nAnimID)
{
	CAnimation* anim = GetAnimation(nAnimID);
	if(anim)
	{
		anim->Update(fDelta);
		return true;
	}
	return false;
}
bool CAnimationManager::PlayAnimation(int nAnimID)
{
	CAnimation* anim = GetAnimation(nAnimID);
	if(anim)
	{
		anim->Play();
		return true;
	}
	return false;
}
bool CAnimationManager::StopAnimation(int nAnimID)
{
	CAnimation* anim = GetAnimation(nAnimID);
	if(anim)
	{
		anim->Stop();
		return true;
	}
	return false;
}
void CInfoPanel::AnimationStartFrameChanged(int val)
{
	if(iSourceImage)
	{
		CAnimation *animation = iSourceImage->GetAnimation();
		if(!animation)
			return;
		animation->SetStartFrame(val);
	}
}
bool CAnimationManager::StopAnimationAtFrame(int nAnimIndex, int nFrameIndex)
{
	CAnimation* anim = GetAnimation(nAnimIndex);
	if(anim)
	{
		anim->StopAtFrame(nFrameIndex);
		return true;
	}
	return false;
}
bool CAnimationManager::ResumeAnimation(int nAnimID)
{
	CAnimation* anim = GetAnimation(nAnimID);
	if(anim)
	{
		anim->Resume();
		return true;
	}
	return false;
}
bool CAnimationManager::SetAnimTexture(const int nAnimID, const int nImageID)
{
	CAnimation* anim = GetAnimation(nAnimID);
	if(anim)
	{
		anim->SetImageID(nImageID);
		return true;
	}
	return false;
}
Exemple #16
0
CNinja* Factory::CreateNinja(int level)
{
	CNinja* ninja = new CNinja();

	CAnimation anim;
	anim.Load("Resources/AnimationInfo/VG_WhiteNinja1.dat", 1,0.75f);
	ninja->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_WhiteNinja1.dat", 2,0.15f);
	ninja->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_WhiteNinja1.dat", 3,0.15f);
	ninja->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_WhiteNinja1.dat", 4,0.15f);
	ninja->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_WhiteNinja1.dat", 5,0.15f, false);
	ninja->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_WhiteNinja1.dat", 6,0.15f);
	ninja->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_WhiteNinja1.dat", 7,0.15f);
	ninja->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_WhiteNinja1.dat", 8,0.15f);
	ninja->AddAnim(anim);

	ninja->SetStrength(16);
	ninja->SetDefense(4);
	ninja->SetAccuracy(10);
	ninja->SetRange(1);
	ninja->SetLevel(level);


	ObjectManager::GetInstance()->Add(ninja);

	return ninja;
}
Exemple #17
0
void CGUIControl::QueueAnimation(ANIMATION_TYPE animType)
{
  MarkDirtyRegion();
  if (!CheckAnimation(animType))
    return;
  CAnimation *reverseAnim = GetAnimation((ANIMATION_TYPE)-animType, false);
  CAnimation *forwardAnim = GetAnimation(animType);
  // we first check whether the reverse animation is in progress (and reverse it)
  // then we check for the normal animation, and queue it
  if (reverseAnim && reverseAnim->IsReversible() && (reverseAnim->GetState() == ANIM_STATE_IN_PROCESS || reverseAnim->GetState() == ANIM_STATE_DELAYED))
  {
    reverseAnim->QueueAnimation(ANIM_PROCESS_REVERSE);
    if (forwardAnim) forwardAnim->ResetAnimation();
  }
  else if (forwardAnim)
  {
    forwardAnim->QueueAnimation(ANIM_PROCESS_NORMAL);
    if (reverseAnim) reverseAnim->ResetAnimation();
  }
  else
  { // hidden and visible animations delay the change of state.  If there is no animations
    // to perform, then we should just change the state straightaway
    if (reverseAnim) reverseAnim->ResetAnimation();
    UpdateStates(animType, ANIM_PROCESS_NORMAL, ANIM_STATE_APPLIED);
  }
}
CAnimation* CAnimationManager::Create(char* szName)
{
	CAnimation* pcAnimation;

	pcAnimation = mcList.Add();
	if (pcAnimation)
	{
		pcAnimation->Init();
	}
	return pcAnimation;
}
CAnimation *CAnimation::CreateFader(float start, float end, unsigned int delay, unsigned int length)
{
  CAnimation *anim = new CAnimation();
  if (anim)
  {
    CFadeEffect *effect = new CFadeEffect(start, end, delay, length);
    if (effect)
      anim->AddEffect(effect);
  }
  return anim;
}
bool CAnimationManager::Draw(int nAnimID,int nPosX, int nPosY, 
	float fScaleX, float fScaleY, float fRotCenterX,
	float fRotCenterY, float fRotation, DWORD dwColor)
{
	CAnimation* anim = GetAnimation(nAnimID);
	if(anim)
	{
		anim->Draw(nPosX, nPosY, fScaleX, fScaleY, fRotCenterX,
			fRotCenterY, fRotation, dwColor);
		return true;
	}
	return false;
}
CAnimation* CTestContainer::CreateAnimationByTypeL(TAnimationFlag aAnimationType)
	{
	__ASSERT_ALWAYS(iAnimationsArray, Panic(TContainerPanicNoArray));
	TInt count = iAnimationsArray->Count();
	CAnimation* singleAnimationCtl = new (ELeave) CAnimation;
	CleanupStack::PushL(singleAnimationCtl);
	singleAnimationCtl->iIndex = count;
	singleAnimationCtl->iType = aAnimationType;
	CAnimateFramesCtl* animationCtl = NULL;
	TRAPD(error, animationCtl = CAnimateFramesCtl::NewL());
	if (error != KErrNone)
		User::Panic(_L("New Animation"), error);

	singleAnimationCtl->iAnimationCtl = animationCtl;
	animationCtl->SetFileName(iFileName);

	TInt resourceReaderId = 0;
	switch (aAnimationType)
		{
	case EDefaultAnimation:
		resourceReaderId = R_TBMPANIM_IMAGE1;
		break;
	case EDefaultAnimationSh:
		resourceReaderId = R_TBMPANIM_IMAGE1;
		break;
	case EBallAnimation:
		resourceReaderId = R_TBMPANIM_IMAGE3;
		break;
	case ERedPurpBallAnimationMaskedBackground:
		resourceReaderId = R_TBMPANIM_IMAGE4;
		break;
	case ETBmpAnimBallAnimWindowCovering:
		resourceReaderId = R_TBMPANIM_IMAGE5;
		break;
	default:
		delete singleAnimationCtl;
		return NULL;
		}

	TResourceReader reader;
	iCoeEnv->CreateResourceReaderLC(reader,resourceReaderId);
	animationCtl->ConstructFromResourceL(reader);
	CleanupStack::PopAndDestroy(); // reader
	singleAnimationCtl->SetAnimationExtent();
	singleAnimationCtl->CopyAttributesFromClientData();
	iAnimationsArray->AppendL(singleAnimationCtl);
	CleanupStack::Pop(); // singleAnimationCtl
	return singleAnimationCtl;
	}
Exemple #22
0
// ----------------------------------------------------------------
//	CreateAnimation
// ----------------------------------------------------------------
CAnimation * CAnimationInfo::CreateAnimation()
{
	CAnimation * animation = new CAnimation();

	animation->SetSpeed( m_Fps );

	for ( auto spriteId : m_SpriteId )
	{
		CSpriteInfo * spriteInfo = CResourceManager::GetInstance().GetSpriteInfo( spriteId );
		animation->AddSprite( spriteInfo->CreateSprite() );

		SafeRelease( spriteInfo );
	}

	return animation;
}
Exemple #23
0
void
CApp::OnRender()
{
  CSurface::OnDraw(Surf_Display, Surf_Test, 
    290, 220, 0, yoshi.GetCurrentFrame() * 64, 64, 64); 

  SDL_Flip(Surf_Display);
}
/// Metoda usuwajaca podany uchwyt i jego CAnimation z bazy
void CAnimationMgr::deleteCAnimation( HCAnimation hcanimation )
{
	CAnimation* canimation = mCAnimations_.dereferenceHandle( hcanimation );
	if ( canimation != 0 )
    {
        // usuniecie z wykazu nazw
		cout << canimation->getAnimationName() << endl;
		mNameIndex_.erase( mNameIndex_.find( canimation->getAnimationName() ) );

        // usuniecie z bazy
		canimation->releaseAnimation();
		
        mCAnimations_.releaseHandle( hcanimation );

		CLog::getInstance()->sss << "CAnimationMgr::deleteCAnimation: Uchwyt zostal zwolniony" << endl;
		logs(CLog::getInstance()->sss.str(), INFO);
    }
}
/// Metoda zwracajaca uchwyt do CAnimation, jesli dany uchwyt jeszcze nie istnieje, tworzy nowy
HCAnimation CAnimationMgr::getCAnimation( const std::string name )
{
    // wstawianie i wyszukiwanie
	NameIndexInsertRc rc = mNameIndex_.insert( std::make_pair( name, HCAnimation() ) );
    if ( rc.second )
    {
        // dodanie nowego sprite'a
		//@todo  boost::shared_ptr
		CAnimation* canimation = mCAnimations_.acquireHandle( rc.first->second );
		CLog::getInstance()->sss << "CAnimationMgr::getCAnimation: Dodano uchwyt do nowej CAnimation" << endl;
		logs(CLog::getInstance()->sss.str(), INFO);
		if ( !canimation->openFile( rc.first->first ) )
        {
            deleteCAnimation( rc.first->second );
			rc.first->second = HCAnimation();
        }
    }
    return ( rc.first->second );
}
bool CGUIControlFactory::GetAnimations(TiXmlNode *control, const CRect &rect, int context, vector<CAnimation> &animations)
{
  TiXmlElement* node = control->FirstChildElement("animation");
  bool ret = false;
  if (node)
    animations.clear();
  while (node)
  {
    ret = true;
    if (node->FirstChild())
    {
      CAnimation anim;
      anim.Create(node, rect, context);
      animations.push_back(anim);
      if (strcmpi(node->FirstChild()->Value(), "VisibleChange") == 0)
      { // add the hidden one as well
        TiXmlElement hidden(*node);
        hidden.FirstChild()->SetValue("hidden");
        const char *start = hidden.Attribute("start");
        const char *end = hidden.Attribute("end");
        if (start && end)
        {
          CStdString temp = end;
          hidden.SetAttribute("end", start);
          hidden.SetAttribute("start", temp.c_str());
        }
        else if (start)
          hidden.SetAttribute("end", start);
        else if (end)
          hidden.SetAttribute("start", end);
        CAnimation anim2;
        anim2.Create(&hidden, rect, context);
        animations.push_back(anim2);
      }
    }
    node = node->NextSiblingElement("animation");
  }
  return ret;
}
Exemple #27
0
void CActionScope::ApplyAnimWeight(uint32 layer, float weight)
{
    CRY_ASSERT_MESSAGE(layer < GetTotalLayers(), "Invalid layer");

    if(layer < GetTotalLayers())
    {
        SSequencer &sequencer = m_layerSequencers[layer];

        if(sequencer.pos > 0)
        {
            CAnimation* pAnimation = GetTopAnim(layer);

            if (pAnimation)
            {
                const SAnimClip &animClip = sequencer.sequence[sequencer.pos - 1];
                float baseWeight = animClip.animation.playbackWeight;

                pAnimation->SetPlaybackWeight(max(0.0f, weight * baseWeight));
            }
        }
    }
}
Exemple #28
0
void CGUIControl::QueueAnimation(ANIMATION_TYPE animType)
{
  // rule out the animations we shouldn't perform
  if (!IsVisible() || !HasRendered()) 
  { // hidden or never rendered - don't allow exit or entry animations for this control
    if (animType == ANIM_TYPE_WINDOW_CLOSE)
    { // could be animating a (delayed) window open anim, so reset it
      ResetAnimation(ANIM_TYPE_WINDOW_OPEN);
      return;
    }
  }
  if (!IsVisible())
  { // hidden - only allow hidden anims if we're animating a visible anim
    if (animType == ANIM_TYPE_HIDDEN && !IsAnimating(ANIM_TYPE_VISIBLE))
    {
      // update states to force it hidden
      UpdateStates(animType, ANIM_PROCESS_NORMAL, ANIM_STATE_APPLIED);
      return;
    }
    if (animType == ANIM_TYPE_WINDOW_OPEN)
      return;
  }
  CAnimation *reverseAnim = GetAnimation((ANIMATION_TYPE)-animType, false);
  CAnimation *forwardAnim = GetAnimation(animType);
  // we first check whether the reverse animation is in progress (and reverse it)
  // then we check for the normal animation, and queue it
  if (reverseAnim && reverseAnim->IsReversible() && (reverseAnim->GetState() == ANIM_STATE_IN_PROCESS || reverseAnim->GetState() == ANIM_STATE_DELAYED))
  {
    reverseAnim->QueueAnimation(ANIM_PROCESS_REVERSE);
    if (forwardAnim) forwardAnim->ResetAnimation();
  }
  else if (forwardAnim)
  {
    forwardAnim->QueueAnimation(ANIM_PROCESS_NORMAL);
    if (reverseAnim) reverseAnim->ResetAnimation();
  }
  else
  { // hidden and visible animations delay the change of state.  If there is no animations
    // to perform, then we should just change the state straightaway
    if (reverseAnim) reverseAnim->ResetAnimation();
    UpdateStates(animType, ANIM_PROCESS_NORMAL, ANIM_STATE_APPLIED);
  }
}
Exemple #29
0
void CAnimationSetDlg::OnSetAnimLength() 
{
	// Longest animation
	float longestLength = 0;

	// For each instance
	for (uint instance=0; instance<_ObjView->_ListInstance.size(); instance++)
	{
		// Ref on the instance
		CInstanceInfo &inst = *_ObjView->_ListInstance[instance];

		// There is some anim ?
		if (inst.Saved.PlayList.size())
		{
			// Calculate the length
			float length = 0;

			// For each animation in the list
			for (uint i=0; i<(uint)inst.Saved.PlayList.size(); i++)
			{
				// Get the animation
				CAnimation *anim = inst.AnimationSet.getAnimation (inst.AnimationSet.getAnimationIdByName (inst.Saved.PlayList[i]));

				// Add the length
				length += anim->getEndTime () - anim->getBeginTime ();
			}

			if (length>longestLength)
				longestLength=length;
		}
	}

	// Adjuste length
	if (longestLength>0)
		_ObjView->setAnimTime (0, longestLength * _ObjView->getFrameRate ());
}
Exemple #30
0
CBoss* Factory::CreateBoss()
{
	CBoss* boss = new CBoss();

	boss->SetAccuracy(10);
	boss->SetBaseAP(16);
	boss->SetCurrAP(16);
	boss->SetDefense(10);
	boss->SetHealthMax(250);
	//boss->SetHealth(50);
	boss->SetHealth(400);
	boss->SetSpeed(10);
	boss->SetStrength(20);

	CAnimation anim;
	anim.Load("Resources/AnimationInfo/VG_shredder.dat", 1,0.35f);//idle1,0
	boss->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_shredder.dat", 2,0.35f);//idle2,1
	boss->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_shredder.dat", 3,0.05f, false);//high,2
	boss->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_shredder.dat", 4,0.15f, false);//low,3
	boss->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_shredder.dat", 5,0.15f);//flip
	boss->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_shredder.dat", 6,0.15f);//ko
	boss->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_shredder.dat", 7,0.15f);//lose
	boss->AddAnim(anim);
	anim.Load("Resources/AnimationInfo/VG_shredder.dat", 8,0.15f, false);//ground special
	boss->AddAnim(anim);

	boss->SetVelX(100);
	boss->SetVelY(50);

	
	ObjectManager::GetInstance()->Add(boss);
	return boss;
}