mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-06 00:55:50 +00:00
Add --export-fonts command line option
This commit is contained in:
parent
cf22d2fa36
commit
63cb91db2e
@ -181,7 +181,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
||||
, mActivationDistanceOverride(-1)
|
||||
, mGrab(true)
|
||||
, mScriptBlacklistUse (true)
|
||||
|
||||
, mExportFonts(false)
|
||||
{
|
||||
std::srand ( std::time(NULL) );
|
||||
MWClass::registerClasses();
|
||||
@ -372,7 +372,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||
|
||||
MWGui::WindowManager* window = new MWGui::WindowManager(
|
||||
mExtensions, mFpsLevel, mOgre, mCfgMgr.getLogPath().string() + std::string("/"),
|
||||
mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage, mEncoding);
|
||||
mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts);
|
||||
mEnvironment.setWindowManager (window);
|
||||
|
||||
// Create sound system
|
||||
@ -576,4 +576,9 @@ void OMW::Engine::setScriptBlacklist (const std::vector<std::string>& list)
|
||||
void OMW::Engine::setScriptBlacklistUse (bool use)
|
||||
{
|
||||
mScriptBlacklistUse = use;
|
||||
}
|
||||
}
|
||||
|
||||
void OMW::Engine::enableFontExport(bool exportFonts)
|
||||
{
|
||||
mExportFonts = exportFonts;
|
||||
}
|
||||
|
@ -83,6 +83,8 @@ namespace OMW
|
||||
// Grab mouse?
|
||||
bool mGrab;
|
||||
|
||||
bool mExportFonts;
|
||||
|
||||
Compiler::Extensions mExtensions;
|
||||
Compiler::Context *mScriptContext;
|
||||
|
||||
@ -187,6 +189,8 @@ namespace OMW
|
||||
|
||||
void setScriptBlacklistUse (bool use);
|
||||
|
||||
void enableFontExport(bool exportFonts);
|
||||
|
||||
private:
|
||||
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")
|
||||
|
||||
("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");
|
||||
|
||||
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.setFallbackValues(variables["fallback"].as<FallbackMap>().mMap);
|
||||
engine.setActivationDistanceOverride (variables["activate-dist"].as<int>());
|
||||
engine.enableFontExport(variables["export-fonts"].as<bool>());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ namespace MWGui
|
||||
mEncoding = encoding;
|
||||
}
|
||||
|
||||
void FontLoader::loadAllFonts()
|
||||
void FontLoader::loadAllFonts(bool exportToFile)
|
||||
{
|
||||
Ogre::StringVector groups = Ogre::ResourceGroupManager::getSingleton().getResourceGroups ();
|
||||
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");
|
||||
for (Ogre::StringVector::iterator resource = resourcesInThisGroup->begin(); resource != resourcesInThisGroup->end(); ++resource)
|
||||
{
|
||||
loadFont(*resource);
|
||||
loadFont(*resource, exportToFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -168,7 +168,7 @@ namespace MWGui
|
||||
float ascent;
|
||||
} 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);
|
||||
|
||||
@ -221,6 +221,9 @@ namespace MWGui
|
||||
width, height, 0, Ogre::PF_BYTE_RGBA);
|
||||
texture->loadImage(image);
|
||||
|
||||
if (exportToFile)
|
||||
image.save(resourceName + ".png");
|
||||
|
||||
// Register the font with MyGUI
|
||||
MyGUI::ResourceManualFont* font = static_cast<MyGUI::ResourceManualFont*>(
|
||||
MyGUI::FactoryManager::getInstance().createObject("Resource", "ResourceManualFont"));
|
||||
@ -240,10 +243,10 @@ namespace MWGui
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
int x1 = data[i].top_left.x*width;
|
||||
int y1 = data[i].top_left.y*height;
|
||||
int w = data[i].top_right.x*width - x1;
|
||||
int h = data[i].bottom_left.y*height - y1;
|
||||
float x1 = data[i].top_left.x*width;
|
||||
float y1 = data[i].top_left.y*height;
|
||||
float w = data[i].top_right.x*width - x1;
|
||||
float h = data[i].bottom_left.y*height - y1;
|
||||
|
||||
ToUTF8::Utf8Encoder encoder(mEncoding);
|
||||
unsigned long unicodeVal = utf8ToUnicode(getUtf8(i, encoder, mEncoding));
|
||||
@ -355,6 +358,12 @@ namespace MWGui
|
||||
cursorCode->addAttribute("size", "0 0");
|
||||
}
|
||||
|
||||
if (exportToFile)
|
||||
{
|
||||
xmlDocument.createDeclaration();
|
||||
xmlDocument.save(resourceName + ".xml");
|
||||
}
|
||||
|
||||
font->deserialization(root, MyGUI::Version(3,2,0));
|
||||
|
||||
MyGUI::ResourceManager::getInstance().removeByName(font->getResourceName());
|
||||
|
@ -12,12 +12,15 @@ namespace MWGui
|
||||
{
|
||||
public:
|
||||
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:
|
||||
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(
|
||||
const Compiler::Extensions& extensions, int fpsLevel, OEngine::Render::OgreRenderer *ogre,
|
||||
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)
|
||||
, mGuiManager(NULL)
|
||||
, mRendering(ogre)
|
||||
@ -148,7 +148,7 @@ namespace MWGui
|
||||
|
||||
// Load fonts
|
||||
FontLoader fontLoader (encoding);
|
||||
fontLoader.loadAllFonts();
|
||||
fontLoader.loadAllFonts(exportFonts);
|
||||
|
||||
//Register own widgets with MyGUI
|
||||
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
|
||||
|
@ -97,7 +97,7 @@ namespace MWGui
|
||||
WindowManager(const Compiler::Extensions& extensions, int fpsLevel,
|
||||
OEngine::Render::OgreRenderer *mOgre, const std::string& logpath,
|
||||
const std::string& cacheDir, bool consoleOnlyScripts,
|
||||
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding);
|
||||
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts);
|
||||
virtual ~WindowManager();
|
||||
|
||||
void initUI();
|
||||
|
Loading…
Reference in New Issue
Block a user