mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-17 10:21:11 +00:00
Merge branch 'font_cleanup' into 'master'
Remove code which became redundant due to changes in way how we load bitmap fonts See merge request OpenMW/openmw!2190
This commit is contained in:
commit
2964e0d4fd
@ -166,32 +166,6 @@ namespace Gui
|
|||||||
MyGUI::ResourceManager::getInstance().registerLoadXmlDelegate("Resource") = MyGUI::newDelegate(this, &FontLoader::loadFontFromXml);
|
MyGUI::ResourceManager::getInstance().registerLoadXmlDelegate("Resource") = MyGUI::newDelegate(this, &FontLoader::loadFontFromXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
FontLoader::~FontLoader()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
MyGUI::ResourceManager::getInstance().unregisterLoadXmlDelegate("Resource");
|
|
||||||
}
|
|
||||||
catch(const MyGUI::Exception& e)
|
|
||||||
{
|
|
||||||
Log(Debug::Error) << "Error in the FontLoader destructor: " << e.what();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (std::vector<MyGUI::ResourceManualFont*>::iterator it = mFonts.begin(); it != mFonts.end(); ++it)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
MyGUI::ResourceManager::getInstance().removeByName((*it)->getResourceName());
|
|
||||||
}
|
|
||||||
catch(const MyGUI::Exception& e)
|
|
||||||
{
|
|
||||||
Log(Debug::Error) << "Error in the destructor: " << e.what();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mFonts.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FontLoader::loadBitmapFonts()
|
void FontLoader::loadBitmapFonts()
|
||||||
{
|
{
|
||||||
for (const auto& path : mVFS->getRecursiveDirectoryIterator("Fonts/"))
|
for (const auto& path : mVFS->getRecursiveDirectoryIterator("Fonts/"))
|
||||||
@ -301,13 +275,6 @@ namespace Gui
|
|||||||
fail(*bitmapFile, bitmapFilename, "File too small to be a valid bitmap");
|
fail(*bitmapFile, bitmapFilename, "File too small to be a valid bitmap");
|
||||||
bitmapFile.reset();
|
bitmapFile.reset();
|
||||||
|
|
||||||
std::string resourceName = name;
|
|
||||||
|
|
||||||
// Register the font with MyGUI
|
|
||||||
MyGUI::ResourceManualFont* font = static_cast<MyGUI::ResourceManualFont*>(
|
|
||||||
MyGUI::FactoryManager::getInstance().createObject("Resource", "ResourceManualFont"));
|
|
||||||
mFonts.push_back(font);
|
|
||||||
|
|
||||||
MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().createTexture(bitmapFilename);
|
MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().createTexture(bitmapFilename);
|
||||||
tex->createManual(width, height, MyGUI::TextureUsage::Write, MyGUI::PixelFormat::R8G8B8A8);
|
tex->createManual(width, height, MyGUI::TextureUsage::Write, MyGUI::PixelFormat::R8G8B8A8);
|
||||||
unsigned char* texData = reinterpret_cast<unsigned char*>(tex->lock(MyGUI::TextureUsage::Write));
|
unsigned char* texData = reinterpret_cast<unsigned char*>(tex->lock(MyGUI::TextureUsage::Write));
|
||||||
@ -470,6 +437,9 @@ namespace Gui
|
|||||||
cursorCode->addAttribute("size", "0 0");
|
cursorCode->addAttribute("size", "0 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Register the font with MyGUI
|
||||||
|
MyGUI::ResourceManualFont* font = static_cast<MyGUI::ResourceManualFont*>(
|
||||||
|
MyGUI::FactoryManager::getInstance().createObject("Resource", "ResourceManualFont"));
|
||||||
font->deserialization(root, MyGUI::Version(3,2,0));
|
font->deserialization(root, MyGUI::Version(3,2,0));
|
||||||
|
|
||||||
MyGUI::ResourceManualFont* bookFont = static_cast<MyGUI::ResourceManualFont*>(
|
MyGUI::ResourceManualFont* bookFont = static_cast<MyGUI::ResourceManualFont*>(
|
||||||
@ -478,23 +448,6 @@ namespace Gui
|
|||||||
bookFont->deserialization(root, MyGUI::Version(3,2,0));
|
bookFont->deserialization(root, MyGUI::Version(3,2,0));
|
||||||
bookFont->setResourceName("Journalbook " + getInternalFontName(baseName));
|
bookFont->setResourceName("Journalbook " + getInternalFontName(baseName));
|
||||||
|
|
||||||
// Remove automatically registered fonts
|
|
||||||
for (std::vector<MyGUI::ResourceManualFont*>::iterator it = mFonts.begin(); it != mFonts.end();)
|
|
||||||
{
|
|
||||||
if ((*it)->getResourceName() == font->getResourceName())
|
|
||||||
{
|
|
||||||
MyGUI::ResourceManager::getInstance().removeByName(font->getResourceName());
|
|
||||||
it = mFonts.erase(it);
|
|
||||||
}
|
|
||||||
else if ((*it)->getResourceName() == bookFont->getResourceName())
|
|
||||||
{
|
|
||||||
MyGUI::ResourceManager::getInstance().removeByName(bookFont->getResourceName());
|
|
||||||
it = mFonts.erase(it);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
|
|
||||||
MyGUI::ResourceManager::getInstance().addResource(font);
|
MyGUI::ResourceManager::getInstance().addResource(font);
|
||||||
MyGUI::ResourceManager::getInstance().addResource(bookFont);
|
MyGUI::ResourceManager::getInstance().addResource(bookFont);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ namespace Gui
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FontLoader (ToUTF8::FromType encoding, const VFS::Manager* vfs, float scalingFactor);
|
FontLoader (ToUTF8::FromType encoding, const VFS::Manager* vfs, float scalingFactor);
|
||||||
~FontLoader();
|
|
||||||
|
|
||||||
void loadBitmapFonts ();
|
void loadBitmapFonts ();
|
||||||
void loadTrueTypeFonts ();
|
void loadTrueTypeFonts ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user