bool Font::serialize(const ConfigParserPtr& cfg) { if(cfg && !mGlyphs.empty()) { cfg->beginNode(L"font"); cfg->setString(L"name", mFontName); cfg->setBool(L"shadow", mEnableShadow); cfg->setBool(L"stroke", mEnableStroke); cfg->setInt(L"shadow_offset_x", mShadowXOffset); cfg->setInt(L"shadow_offset_y", mShadowYOffset); cfg->setInt(L"stroke_width", mStrokeWidth); cfg->setInt(L"size", mFontSize); cfg->setBool(L"bold", (bool)(mFace->face->style_flags & FT_STYLE_FLAG_BOLD)); cfg->setBool(L"italic", (bool)(mFace->face->style_flags & FT_STYLE_FLAG_ITALIC)); cfg->endNode(); return true; } else { log_error(L"ukn::Font::serialize: unable to serialize font "+mFontName); } return false; }
void Context::saveCfgFile(const UknString& name) { ConfigParserPtr configParser = ConfigParser::MakeEmptyParser(CPT_XML); if(configParser) { configParser->beginNode(L"cfg"); configParser->beginNode(L"graphics"); configParser->setInt(L"width", mCfg.render_cfg.width); configParser->setInt(L"height", mCfg.render_cfg.height); configParser->setInt(L"top", mCfg.render_cfg.top); configParser->setInt(L"left", mCfg.render_cfg.left); configParser->setBool(L"show_mouse", mCfg.render_cfg.show_mouse); configParser->setBool(L"full_screen", mCfg.render_cfg.full_screen); configParser->setBool(L"resizable", mCfg.render_cfg.resizable); configParser->setInt(L"sample_count", mCfg.render_cfg.sample_count); configParser->setInt(L"sample_quality", mCfg.render_cfg.sample_quality); configParser->setString(L"color_fmt", element_format_to_string(mCfg.render_cfg.color_fmt)); configParser->setString(L"depth_stencil_fmt", element_format_to_string(mCfg.render_cfg.depth_stencil_fmt)); configParser->toNode(L"/cfg"); configParser->beginNode(L"plugins"); if(!mCfg.graphic_factory_name.empty()) configParser->setString(L"graphic_factory", mCfg.graphic_factory_name); } UknString formattedString = configParser->writeToString(); ResourcePtr resource = ResourceLoader::Instance().createFileResource(name); if(resource) { resource->getResourceStream()->write((const uint8*)formattedString.data(), formattedString.size()); } }