bool Font::deserialize(const ConfigParserPtr& config) { mGlyphs.clear(); if(config && config->toNode(L"font")) { UknString font_name = config->getString(L"name"); if(!font_name.empty()) { UknString fullFontPath = Path::CheckAndGetFontPath(font_name); if(fullFontPath.empty()) { log_error(L"ukn::Font::deserialize: error finding font name " + font_name); return false; } ResourcePtr fontResource = ResourceLoader::Instance().loadResource(fullFontPath); if(fontResource && fontResource->getResourceStream()) { bool result = mFace->load(fontResource); if(result) { mGlyphs.resize(mFace->face->num_glyphs); for(int i = 0; i < mFace->face->num_glyphs; ++i) { mGlyphs[i].size = mFontSize; mGlyphs[i].face = &mFace->face; } } } } mEnableShadow = config->getBool(L"shadow", false); mEnableStroke = config->getBool(L"stroke", false); if(config->getBool(L"bold", false)) { this->setFTStyle(FT_STYLE_FLAG_BOLD); } if(config->getBool(L"italic", false)) { this->setFTStyle(FT_STYLE_FLAG_ITALIC); } mShadowXOffset = config->getInt(L"shadow_offset_x", 0); mShadowYOffset = config->getInt(L"shadow_offset_y", 0); mStrokeWidth = config->getInt(L"stroke_width", 0); mFontSize = config->getInt(L"size", 14); mFontName = font_name; config->toParent(); return true; } return false; }
bool AnimationPlayer::deserialize(const ConfigParserPtr& parser) { if(parser->toNode(L"animations")) { if(parser->toFirstChild()) { do { StoryBoardPtr storyboard = MakeSharedPtr<StoryBoard>(); MistString name = parser->getString(L"name"); if(!name.empty()) { bool isdefault = parser->getBool(L"default", false); if(isdefault) setDefault(name); if(parser->toFirstChild()) { do { MistString type = parser->getCurrentNodeName(); // linear animation if(type == L"linear") { MistString prop_name = parser->getString(L"prop"); MistString prop_type = parser->getString(L"prop_type"); void* prop = getProperty(prop_name); if(prop) { create_linear_animation(prop_type, prop, parser, storyboard.get()); } // keyframe animation } else if(type == L"keyframe") { MistString prop_name = parser->getString(L"prop"); MistString prop_type = parser->getString(L"prop_type"); void* prop = getProperty(prop_name); if(prop) { create_key_frame_animation(prop_type, prop, parser, storyboard.get()); // back to parent node parser->toParent(); } } } while(parser->toNextChild()); // back to parent node parser->toParent(); // add storyboard mStoryBoards[name] = storyboard; // connect to finish event storyboard->onComplete() += Bind(this, &AnimationPlayer::onAnimationFinished); } } } while(parser->toNextChild()); parser->toParent(); } parser->toParent(); } else return false; if(!mDefault.empty()) play(mDefault); return true; }