mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 07:21:12 +00:00
Rework StatsHandler to support VFS
This commit is contained in:
parent
6f6b5ba04b
commit
59c4ea014d
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <osg/PolygonMode>
|
#include <osg/PolygonMode>
|
||||||
|
|
||||||
|
#include <osgText/Font>
|
||||||
#include <osgText/Text>
|
#include <osgText/Text>
|
||||||
|
|
||||||
#include <osgDB/Registry>
|
#include <osgDB/Registry>
|
||||||
@ -90,8 +91,8 @@ StatsHandler::StatsHandler(bool offlineCollect, VFS::Manager* vfs):
|
|||||||
_offlineCollect(offlineCollect),
|
_offlineCollect(offlineCollect),
|
||||||
_statsWidth(1280.0f),
|
_statsWidth(1280.0f),
|
||||||
_statsHeight(1024.0f),
|
_statsHeight(1024.0f),
|
||||||
_font(""),
|
_characterSize(18.0f),
|
||||||
_characterSize(18.0f)
|
_VFS(vfs)
|
||||||
{
|
{
|
||||||
_camera = new osg::Camera;
|
_camera = new osg::Camera;
|
||||||
_camera->getOrCreateStateSet()->setGlobalDefaults();
|
_camera->getOrCreateStateSet()->setGlobalDefaults();
|
||||||
@ -99,11 +100,6 @@ StatsHandler::StatsHandler(bool offlineCollect, VFS::Manager* vfs):
|
|||||||
_camera->setProjectionResizePolicy(osg::Camera::FIXED);
|
_camera->setProjectionResizePolicy(osg::Camera::FIXED);
|
||||||
|
|
||||||
_resourceStatsChildNum = 0;
|
_resourceStatsChildNum = 0;
|
||||||
|
|
||||||
if (osgDB::Registry::instance()->getReaderWriterForExtension("ttf") && vfs->exists(sFontName))
|
|
||||||
{
|
|
||||||
_font = vfs->getAbsoluteFileName(sFontName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Profiler::Profiler(bool offlineCollect, VFS::Manager* vfs):
|
Profiler::Profiler(bool offlineCollect, VFS::Manager* vfs):
|
||||||
@ -431,7 +427,6 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase *viewer)
|
|||||||
osg::ref_ptr<osgText::Text> staticText = new osgText::Text;
|
osg::ref_ptr<osgText::Text> staticText = new osgText::Text;
|
||||||
group->addChild( staticText.get() );
|
group->addChild( staticText.get() );
|
||||||
staticText->setColor(staticTextColor);
|
staticText->setColor(staticTextColor);
|
||||||
staticText->setFont(_font);
|
|
||||||
staticText->setCharacterSize(_characterSize);
|
staticText->setCharacterSize(_characterSize);
|
||||||
staticText->setPosition(pos);
|
staticText->setPosition(pos);
|
||||||
|
|
||||||
@ -457,11 +452,19 @@ void StatsHandler::setUpScene(osgViewer::ViewerBase *viewer)
|
|||||||
group->addChild( statsText.get() );
|
group->addChild( statsText.get() );
|
||||||
|
|
||||||
statsText->setColor(dynamicTextColor);
|
statsText->setColor(dynamicTextColor);
|
||||||
statsText->setFont(_font);
|
|
||||||
statsText->setCharacterSize(_characterSize);
|
statsText->setCharacterSize(_characterSize);
|
||||||
statsText->setPosition(pos);
|
statsText->setPosition(pos);
|
||||||
statsText->setText("");
|
statsText->setText("");
|
||||||
statsText->setDrawCallback(new ResourceStatsTextDrawCallback(viewer->getViewerStats(), statNames));
|
statsText->setDrawCallback(new ResourceStatsTextDrawCallback(viewer->getViewerStats(), statNames));
|
||||||
|
|
||||||
|
if (osgDB::Registry::instance()->getReaderWriterForExtension("ttf") && _VFS->exists(sFontName))
|
||||||
|
{
|
||||||
|
Files::IStreamPtr streamPtr = _VFS->get(sFontName);
|
||||||
|
osg::ref_ptr<osgText::Font> font = osgText::readRefFontStream(*streamPtr.get());
|
||||||
|
|
||||||
|
staticText->setFont(font);
|
||||||
|
statsText->setFont(font);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,11 +61,11 @@ namespace Resource
|
|||||||
float _statsWidth;
|
float _statsWidth;
|
||||||
float _statsHeight;
|
float _statsHeight;
|
||||||
|
|
||||||
std::string _font;
|
|
||||||
float _characterSize;
|
float _characterSize;
|
||||||
|
|
||||||
int _resourceStatsChildNum;
|
int _resourceStatsChildNum;
|
||||||
|
|
||||||
|
VFS::Manager* _VFS;
|
||||||
};
|
};
|
||||||
|
|
||||||
void CollectStatistics(osgViewer::ViewerBase* viewer);
|
void CollectStatistics(osgViewer::ViewerBase* viewer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user