mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-19 12:39:42 +00:00
Avoid code duplication
This commit is contained in:
parent
facdc8fc0d
commit
dc0d6fe31d
1 changed files with 13 additions and 10 deletions
|
@ -104,6 +104,17 @@ private:
|
||||||
osgText::Font* mFont;
|
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):
|
StatsHandler::StatsHandler(bool offlineCollect, VFS::Manager* vfs):
|
||||||
_key(osgGA::GUIEventAdapter::KEY_F4),
|
_key(osgGA::GUIEventAdapter::KEY_F4),
|
||||||
_initialized(false),
|
_initialized(false),
|
||||||
|
@ -120,11 +131,7 @@ StatsHandler::StatsHandler(bool offlineCollect, VFS::Manager* vfs):
|
||||||
|
|
||||||
_resourceStatsChildNum = 0;
|
_resourceStatsChildNum = 0;
|
||||||
|
|
||||||
if (osgDB::Registry::instance()->getReaderWriterForExtension("ttf") && vfs->exists(sFontName))
|
_textFont = getMonoFont(vfs);
|
||||||
{
|
|
||||||
Files::IStreamPtr streamPtr = vfs->get(sFontName);
|
|
||||||
_textFont = osgText::readRefFontStream(*streamPtr.get());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Profiler::Profiler(bool offlineCollect, VFS::Manager* vfs):
|
Profiler::Profiler(bool offlineCollect, VFS::Manager* vfs):
|
||||||
|
@ -134,11 +141,7 @@ Profiler::Profiler(bool offlineCollect, VFS::Manager* vfs):
|
||||||
_characterSize = 18;
|
_characterSize = 18;
|
||||||
_font.clear();
|
_font.clear();
|
||||||
|
|
||||||
if (osgDB::Registry::instance()->getReaderWriterForExtension("ttf") && vfs->exists(sFontName))
|
_textFont = getMonoFont(vfs);
|
||||||
{
|
|
||||||
Files::IStreamPtr streamPtr = vfs->get(sFontName);
|
|
||||||
_textFont = osgText::readRefFontStream(*streamPtr.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
setKeyEventTogglesOnScreenStats(osgGA::GUIEventAdapter::KEY_F3);
|
setKeyEventTogglesOnScreenStats(osgGA::GUIEventAdapter::KEY_F3);
|
||||||
setupStatCollection();
|
setupStatCollection();
|
||||||
|
|
Loading…
Reference in a new issue