inline void create_linear_animation(const MistString& type, void* prop, const ConfigParserPtr& parser, StoryBoard* storyboard) { if(type == L"int") { SharedPtr<LinearAnimation<int> > anim = MakeSharedPtr<LinearAnimation<int> >(); anim->setFrom(parser->getInt(L"from", 0)); anim->setTo(parser->getInt(L"to", 0)); anim->setDuration(parser->getInt(L"duration", 0)); storyboard->children().push_back(StoryBoard::AnimationInfo(parser->getInt(L"time", 0), anim, prop)); return; } if(type == L"float") { SharedPtr<LinearAnimation<float> > anim = MakeSharedPtr<LinearAnimation<float> >(); anim->setFrom(parser->getFloat(L"from", 0)); anim->setTo(parser->getFloat(L"to", 0)); anim->setDuration(parser->getInt(L"duration", 0)); storyboard->children().push_back(StoryBoard::AnimationInfo(parser->getInt(L"time", 0), anim, prop)); return; } if(type == L"uint") { SharedPtr<LinearAnimation<uint32> > anim = MakeSharedPtr<LinearAnimation<uint32> >(); anim->setFrom(parser->getInt(L"from", 0)); anim->setTo(parser->getInt(L"to", 0)); anim->setDuration(parser->getInt(L"duration", 0)); storyboard->children().push_back(StoryBoard::AnimationInfo(parser->getInt(L"time", 0), anim, prop)); return; } if(type == L"double") { SharedPtr<LinearAnimation<double> > anim = MakeSharedPtr<LinearAnimation<double> >(); anim->setFrom(parser->getFloat(L"from", 0)); anim->setTo(parser->getFloat(L"to", 0)); anim->setDuration(parser->getInt(L"duration", 0)); storyboard->children().push_back(StoryBoard::AnimationInfo(parser->getInt(L"time", 0), anim, prop)); return; } if(type == L"color") { // to do return; } }
inline void create_key_frame_animation(const MistString& type, void* prop, const ConfigParserPtr& parser, StoryBoard* storyboard) { if(type == L"int") { SharedPtr<KeyFrameAnimation<int> > anim = MakeSharedPtr<KeyFrameAnimation<int> >(); int32 time = parser->getInt(L"time", 0); int32 duration = parser->getInt(L"duration", 0); if(duration == 0) return; anim->setDuration(duration); if(parser->toFirstChild()) { do { if(parser->hasAttribute(L"val")) { int32 val = parser->getInt(L"val", 0); int32 dur = parser->getInt(L"duration", 0); int32 type = parser->getInt(L"type", 0); anim->getKeyFrames().push_back(KeyFrameAnimation<int>::KeyFrame(val, dur, type == 0 ? KFT_Linear : KFT_Discrete)); } } while(parser->toNextChild()); storyboard->children().push_back(StoryBoard::AnimationInfo(time, anim, prop)); } return; } if(type == L"float") { SharedPtr<KeyFrameAnimation<float> > anim = MakeSharedPtr<KeyFrameAnimation<float> >(); int32 time = parser->getInt(L"time", 0); int32 duration = parser->getInt(L"duration", 0); if(duration == 0) return; anim->setDuration(duration); if(parser->toFirstChild()) { do { if(parser->hasAttribute(L"val")) { float val = parser->getFloat(L"val", 0); int32 dur = parser->getInt(L"duration", 0); int32 type = parser->getInt(L"type", 0); anim->getKeyFrames().push_back(KeyFrameAnimation<float>::KeyFrame(val, dur, type == 0 ? KFT_Linear : KFT_Discrete)); } } while(parser->toNextChild()); storyboard->children().push_back(StoryBoard::AnimationInfo(time, anim, prop)); } return; } if(type == L"double") { SharedPtr<KeyFrameAnimation<double> > anim = MakeSharedPtr<KeyFrameAnimation<double> >(); int32 time = parser->getInt(L"time", 0); int32 duration = parser->getInt(L"duration", 0); if(duration == 0) return; anim->setDuration(duration); if(parser->toFirstChild()) { do { if(parser->hasAttribute(L"val")) { int32 val = parser->getInt(L"val", 0); int32 dur = parser->getInt(L"duration", 0); int32 type = parser->getInt(L"type", 0); anim->getKeyFrames().push_back(KeyFrameAnimation<double>::KeyFrame(val, dur, type == 0 ? KFT_Linear : KFT_Discrete)); } } while(parser->toNextChild()); storyboard->children().push_back(StoryBoard::AnimationInfo(time, anim, prop)); } return; } if(type == L"uint") { SharedPtr<KeyFrameAnimation<uint32> > anim = MakeSharedPtr<KeyFrameAnimation<uint32> >(); int32 time = parser->getInt(L"time", 0); int32 duration = parser->getInt(L"duration", 0); if(duration == 0) return; anim->setDuration(duration); if(parser->toFirstChild()) { do { if(parser->hasAttribute(L"val")) { int32 val = parser->getInt(L"val", 0); int32 dur = parser->getInt(L"duration", 0); int32 type = parser->getInt(L"type", 0); anim->getKeyFrames().push_back(KeyFrameAnimation<uint32>::KeyFrame(val, dur, type == 0 ? KFT_Linear : KFT_Discrete)); } } while(parser->toNextChild()); storyboard->children().push_back(StoryBoard::AnimationInfo(time, anim, prop)); } return; } if(type == L"color") { // to do } }