mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-10 03:39:55 +00:00
Avoid code duplication
This commit is contained in:
parent
facdc8fc0d
commit
dc0d6fe31d
@ -104,6 +104,17 @@ private:
|
||||
osgText::Font* mFont;
|
||||
};
|
||||
|
||||
osg::ref_ptr<osgText::Font> getMonoFont(VFS::Manager* vfs)
|
||||
{
|
||||
if (osgDB::Registry::instance()->getReaderWriterForExtension("ttf") && vfs->exists(sFontName))
|
||||
{
|
||||
Files::IStreamPtr streamPtr = vfs->get(sFontName);
|
||||
return osgText::readRefFontStream(*streamPtr.get());
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
StatsHandler::StatsHandler(bool offlineCollect, VFS::Manager* vfs):
|
||||
_key(osgGA::GUIEventAdapter::KEY_F4),
|
||||
_initialized(false),
|
||||
@ -120,11 +131,7 @@ StatsHandler::StatsHandler(bool offlineCollect, VFS::Manager* vfs):
|
||||
|
||||
_resourceStatsChildNum = 0;
|
||||
|
||||
if (osgDB::Registry::instance()->getReaderWriterForExtension("ttf") && vfs->exists(sFontName))
|
||||
{
|
||||
Files::IStreamPtr streamPtr = vfs->get(sFontName);
|
||||
_textFont = osgText::readRefFontStream(*streamPtr.get());
|
||||
}
|
||||
_textFont = getMonoFont(vfs);
|
||||
}
|
||||
|
||||
Profiler::Profiler(bool offlineCollect, VFS::Manager* vfs):
|
||||
@ -134,11 +141,7 @@ Profiler::Profiler(bool offlineCollect, VFS::Manager* vfs):
|
||||
_characterSize = 18;
|
||||
_font.clear();
|
||||
|
||||
if (osgDB::Registry::instance()->getReaderWriterForExtension("ttf") && vfs->exists(sFontName))
|
||||
{
|
||||
Files::IStreamPtr streamPtr = vfs->get(sFontName);
|
||||
_textFont = osgText::readRefFontStream(*streamPtr.get());
|
||||
}
|
||||
_textFont = getMonoFont(vfs);
|
||||
|
||||
setKeyEventTogglesOnScreenStats(osgGA::GUIEventAdapter::KEY_F3);
|
||||
setupStatCollection();
|
||||
|
Loading…
x
Reference in New Issue
Block a user