mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 10:36:42 +00:00
Add --export-fonts command line option
This commit is contained in:
parent
cf22d2fa36
commit
63cb91db2e
7 changed files with 40 additions and 15 deletions
|
@ -181,7 +181,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
||||||
, mActivationDistanceOverride(-1)
|
, mActivationDistanceOverride(-1)
|
||||||
, mGrab(true)
|
, mGrab(true)
|
||||||
, mScriptBlacklistUse (true)
|
, mScriptBlacklistUse (true)
|
||||||
|
, mExportFonts(false)
|
||||||
{
|
{
|
||||||
std::srand ( std::time(NULL) );
|
std::srand ( std::time(NULL) );
|
||||||
MWClass::registerClasses();
|
MWClass::registerClasses();
|
||||||
|
@ -372,7 +372,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||||
|
|
||||||
MWGui::WindowManager* window = new MWGui::WindowManager(
|
MWGui::WindowManager* window = new MWGui::WindowManager(
|
||||||
mExtensions, mFpsLevel, mOgre, mCfgMgr.getLogPath().string() + std::string("/"),
|
mExtensions, mFpsLevel, mOgre, mCfgMgr.getLogPath().string() + std::string("/"),
|
||||||
mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage, mEncoding);
|
mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts);
|
||||||
mEnvironment.setWindowManager (window);
|
mEnvironment.setWindowManager (window);
|
||||||
|
|
||||||
// Create sound system
|
// Create sound system
|
||||||
|
@ -577,3 +577,8 @@ void OMW::Engine::setScriptBlacklistUse (bool use)
|
||||||
{
|
{
|
||||||
mScriptBlacklistUse = use;
|
mScriptBlacklistUse = use;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OMW::Engine::enableFontExport(bool exportFonts)
|
||||||
|
{
|
||||||
|
mExportFonts = exportFonts;
|
||||||
|
}
|
||||||
|
|
|
@ -83,6 +83,8 @@ namespace OMW
|
||||||
// Grab mouse?
|
// Grab mouse?
|
||||||
bool mGrab;
|
bool mGrab;
|
||||||
|
|
||||||
|
bool mExportFonts;
|
||||||
|
|
||||||
Compiler::Extensions mExtensions;
|
Compiler::Extensions mExtensions;
|
||||||
Compiler::Context *mScriptContext;
|
Compiler::Context *mScriptContext;
|
||||||
|
|
||||||
|
@ -187,6 +189,8 @@ namespace OMW
|
||||||
|
|
||||||
void setScriptBlacklistUse (bool use);
|
void setScriptBlacklistUse (bool use);
|
||||||
|
|
||||||
|
void enableFontExport(bool exportFonts);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Files::ConfigurationManager& mCfgMgr;
|
Files::ConfigurationManager& mCfgMgr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -168,6 +168,9 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
||||||
|
|
||||||
("no-grab", "Don't grab mouse cursor")
|
("no-grab", "Don't grab mouse cursor")
|
||||||
|
|
||||||
|
("export-fonts", bpo::value<bool>()->implicit_value(true)
|
||||||
|
->default_value(false), "Export Morrowind .fnt fonts to PNG image and XML file in current directory")
|
||||||
|
|
||||||
("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override");
|
("activate-dist", bpo::value <int> ()->default_value (-1), "activation distance override");
|
||||||
|
|
||||||
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
|
bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv)
|
||||||
|
@ -268,6 +271,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
|
||||||
engine.setSoundUsage(!variables["no-sound"].as<bool>());
|
engine.setSoundUsage(!variables["no-sound"].as<bool>());
|
||||||
engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap);
|
engine.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap);
|
||||||
engine.setActivationDistanceOverride (variables["activate-dist"].as<int>());
|
engine.setActivationDistanceOverride (variables["activate-dist"].as<int>());
|
||||||
|
engine.enableFontExport(variables["export-fonts"].as<bool>());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace MWGui
|
||||||
mEncoding = encoding;
|
mEncoding = encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontLoader::loadAllFonts()
|
void FontLoader::loadAllFonts(bool exportToFile)
|
||||||
{
|
{
|
||||||
Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups ();
|
Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups ();
|
||||||
for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it)
|
for (Ogre::StringVector::iterator it = groups.begin(); it != groups.end(); ++it)
|
||||||
|
@ -142,7 +142,7 @@ namespace MWGui
|
||||||
Ogre::StringVectorPtr resourcesInThisGroup = Ogre::ResourceGroupManager::getSingleton ().findResourceNames (*it, "*.fnt");
|
Ogre::StringVectorPtr resourcesInThisGroup = Ogre::ResourceGroupManager::getSingleton ().findResourceNames (*it, "*.fnt");
|
||||||
for (Ogre::StringVector::iterator resource = resourcesInThisGroup->begin(); resource != resourcesInThisGroup->end(); ++resource)
|
for (Ogre::StringVector::iterator resource = resourcesInThisGroup->begin(); resource != resourcesInThisGroup->end(); ++resource)
|
||||||
{
|
{
|
||||||
loadFont(*resource);
|
loadFont(*resource, exportToFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ namespace MWGui
|
||||||
float ascent;
|
float ascent;
|
||||||
} GlyphInfo;
|
} GlyphInfo;
|
||||||
|
|
||||||
void FontLoader::loadFont(const std::string &fileName)
|
void FontLoader::loadFont(const std::string &fileName, bool exportToFile)
|
||||||
{
|
{
|
||||||
Ogre::DataStreamPtr file = Ogre::ResourceGroupManager::getSingleton().openResource(fileName);
|
Ogre::DataStreamPtr file = Ogre::ResourceGroupManager::getSingleton().openResource(fileName);
|
||||||
|
|
||||||
|
@ -221,6 +221,9 @@ namespace MWGui
|
||||||
width, height, 0, Ogre::PF_BYTE_RGBA);
|
width, height, 0, Ogre::PF_BYTE_RGBA);
|
||||||
texture->loadImage(image);
|
texture->loadImage(image);
|
||||||
|
|
||||||
|
if (exportToFile)
|
||||||
|
image.save(resourceName + ".png");
|
||||||
|
|
||||||
// Register the font with MyGUI
|
// Register the font with MyGUI
|
||||||
MyGUI::ResourceManualFont* font = static_cast<MyGUI::ResourceManualFont*>(
|
MyGUI::ResourceManualFont* font = static_cast<MyGUI::ResourceManualFont*>(
|
||||||
MyGUI::FactoryManager::getInstance().createObject("Resource", "ResourceManualFont"));
|
MyGUI::FactoryManager::getInstance().createObject("Resource", "ResourceManualFont"));
|
||||||
|
@ -240,10 +243,10 @@ namespace MWGui
|
||||||
|
|
||||||
for(int i = 0; i < 256; i++)
|
for(int i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
int x1 = data[i].top_left.x*width;
|
float x1 = data[i].top_left.x*width;
|
||||||
int y1 = data[i].top_left.y*height;
|
float y1 = data[i].top_left.y*height;
|
||||||
int w = data[i].top_right.x*width - x1;
|
float w = data[i].top_right.x*width - x1;
|
||||||
int h = data[i].bottom_left.y*height - y1;
|
float h = data[i].bottom_left.y*height - y1;
|
||||||
|
|
||||||
ToUTF8::Utf8Encoder encoder(mEncoding);
|
ToUTF8::Utf8Encoder encoder(mEncoding);
|
||||||
unsigned long unicodeVal = utf8ToUnicode(getUtf8(i, encoder, mEncoding));
|
unsigned long unicodeVal = utf8ToUnicode(getUtf8(i, encoder, mEncoding));
|
||||||
|
@ -355,6 +358,12 @@ namespace MWGui
|
||||||
cursorCode->addAttribute("size", "0 0");
|
cursorCode->addAttribute("size", "0 0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exportToFile)
|
||||||
|
{
|
||||||
|
xmlDocument.createDeclaration();
|
||||||
|
xmlDocument.save(resourceName + ".xml");
|
||||||
|
}
|
||||||
|
|
||||||
font->deserialization(root, MyGUI::Version(3,2,0));
|
font->deserialization(root, MyGUI::Version(3,2,0));
|
||||||
|
|
||||||
MyGUI::ResourceManager::getInstance().removeByName(font->getResourceName());
|
MyGUI::ResourceManager::getInstance().removeByName(font->getResourceName());
|
||||||
|
|
|
@ -12,12 +12,15 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FontLoader (ToUTF8::FromType encoding);
|
FontLoader (ToUTF8::FromType encoding);
|
||||||
void loadAllFonts ();
|
|
||||||
|
/// @param exportToFile export the converted fonts (Images and XML with glyph metrics) to files?
|
||||||
|
void loadAllFonts (bool exportToFile);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ToUTF8::FromType mEncoding;
|
ToUTF8::FromType mEncoding;
|
||||||
|
|
||||||
void loadFont (const std::string& fileName);
|
/// @param exportToFile export the converted font (Image and XML with glyph metrics) to files?
|
||||||
|
void loadFont (const std::string& fileName, bool exportToFile);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace MWGui
|
||||||
WindowManager::WindowManager(
|
WindowManager::WindowManager(
|
||||||
const Compiler::Extensions& extensions, int fpsLevel, OEngine::Render::OgreRenderer *ogre,
|
const Compiler::Extensions& extensions, int fpsLevel, OEngine::Render::OgreRenderer *ogre,
|
||||||
const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts,
|
const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts,
|
||||||
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding)
|
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts)
|
||||||
: mConsoleOnlyScripts(consoleOnlyScripts)
|
: mConsoleOnlyScripts(consoleOnlyScripts)
|
||||||
, mGuiManager(NULL)
|
, mGuiManager(NULL)
|
||||||
, mRendering(ogre)
|
, mRendering(ogre)
|
||||||
|
@ -148,7 +148,7 @@ namespace MWGui
|
||||||
|
|
||||||
// Load fonts
|
// Load fonts
|
||||||
FontLoader fontLoader (encoding);
|
FontLoader fontLoader (encoding);
|
||||||
fontLoader.loadAllFonts();
|
fontLoader.loadAllFonts(exportFonts);
|
||||||
|
|
||||||
//Register own widgets with MyGUI
|
//Register own widgets with MyGUI
|
||||||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace MWGui
|
||||||
WindowManager(const Compiler::Extensions& extensions, int fpsLevel,
|
WindowManager(const Compiler::Extensions& extensions, int fpsLevel,
|
||||||
OEngine::Render::OgreRenderer *mOgre, const std::string& logpath,
|
OEngine::Render::OgreRenderer *mOgre, const std::string& logpath,
|
||||||
const std::string& cacheDir, bool consoleOnlyScripts,
|
const std::string& cacheDir, bool consoleOnlyScripts,
|
||||||
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding);
|
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts);
|
||||||
virtual ~WindowManager();
|
virtual ~WindowManager();
|
||||||
|
|
||||||
void initUI();
|
void initUI();
|
||||||
|
|
Loading…
Reference in a new issue