|
|
|
@ -38,13 +38,13 @@
|
|
|
|
|
#include <components/translation/translation.hpp>
|
|
|
|
|
|
|
|
|
|
#include <components/myguiplatform/myguiplatform.hpp>
|
|
|
|
|
#include <components/myguiplatform/myguidatamanager.hpp>
|
|
|
|
|
#include <components/myguiplatform/myguirendermanager.hpp>
|
|
|
|
|
#include <components/myguiplatform/additivelayer.hpp>
|
|
|
|
|
#include <components/myguiplatform/scalinglayer.hpp>
|
|
|
|
|
|
|
|
|
|
#include <components/vfs/manager.hpp>
|
|
|
|
|
|
|
|
|
|
#include <components/widgets/widgets.hpp>
|
|
|
|
|
#include <components/widgets/tags.hpp>
|
|
|
|
|
|
|
|
|
|
#include <components/sdlutil/sdlcursormanager.hpp>
|
|
|
|
@ -132,8 +132,8 @@ namespace MWGui
|
|
|
|
|
|
|
|
|
|
WindowManager::WindowManager(
|
|
|
|
|
osgViewer::Viewer* viewer, osg::Group* guiRoot, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue,
|
|
|
|
|
const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts,
|
|
|
|
|
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts, const std::map<std::string, std::string>& fallbackMap, const std::string& versionDescription)
|
|
|
|
|
const std::string& logpath, const std::string& resourcePath, bool consoleOnlyScripts, Translation::Storage& translationDataStorage,
|
|
|
|
|
ToUTF8::FromType encoding, bool exportFonts, const std::map<std::string, std::string>& fallbackMap, const std::string& versionDescription, const std::string& userDataPath)
|
|
|
|
|
: mStore(NULL)
|
|
|
|
|
, mResourceSystem(resourceSystem)
|
|
|
|
|
, mWorkQueue(workQueue)
|
|
|
|
@ -196,6 +196,7 @@ namespace MWGui
|
|
|
|
|
, mFallbackMap(fallbackMap)
|
|
|
|
|
, mShowOwned(0)
|
|
|
|
|
, mEncoding(encoding)
|
|
|
|
|
, mFontHeight(16)
|
|
|
|
|
, mVersionDescription(versionDescription)
|
|
|
|
|
{
|
|
|
|
|
float uiScale = Settings::Manager::getFloat("scaling factor", "GUI");
|
|
|
|
@ -210,8 +211,8 @@ namespace MWGui
|
|
|
|
|
MyGUI::LanguageManager::getInstance().eventRequestTag = MyGUI::newDelegate(this, &WindowManager::onRetrieveTag);
|
|
|
|
|
|
|
|
|
|
// Load fonts
|
|
|
|
|
mFontLoader.reset(new Gui::FontLoader(encoding, resourceSystem->getVFS()));
|
|
|
|
|
mFontLoader->loadAllFonts(exportFonts);
|
|
|
|
|
mFontLoader.reset(new Gui::FontLoader(encoding, resourceSystem->getVFS(), userDataPath));
|
|
|
|
|
mFontLoader->loadBitmapFonts(exportFonts);
|
|
|
|
|
|
|
|
|
|
//Register own widgets with MyGUI
|
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Widgets::MWSkill>("Widget");
|
|
|
|
@ -233,11 +234,19 @@ namespace MWGui
|
|
|
|
|
SpellView::registerComponents();
|
|
|
|
|
Gui::registerAllWidgets();
|
|
|
|
|
|
|
|
|
|
int fontSize = Settings::Manager::getInt("font size", "GUI");
|
|
|
|
|
fontSize = std::min(std::max(12, fontSize), 20);
|
|
|
|
|
mFontHeight = fontSize;
|
|
|
|
|
|
|
|
|
|
MyGUI::ResourceManager::getInstance().unregisterLoadXmlDelegate("Resource");
|
|
|
|
|
MyGUI::ResourceManager::getInstance().registerLoadXmlDelegate("Resource") = newDelegate(this, &WindowManager::loadFontDelegate);
|
|
|
|
|
|
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Controllers::ControllerRepeatEvent>("Controller");
|
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Controllers::ControllerFollowMouse>("Controller");
|
|
|
|
|
|
|
|
|
|
MyGUI::FactoryManager::getInstance().registerFactory<ResourceImageSetPointerFix>("Resource", "ResourceImageSetPointer");
|
|
|
|
|
MyGUI::ResourceManager::getInstance().load("core.xml");
|
|
|
|
|
loadUserFonts();
|
|
|
|
|
|
|
|
|
|
bool keyboardNav = Settings::Manager::getBool("keyboard navigation", "GUI");
|
|
|
|
|
mKeyboardNavigation.reset(new KeyboardNavigation());
|
|
|
|
@ -284,6 +293,99 @@ namespace MWGui
|
|
|
|
|
mShowOwned = Settings::Manager::getInt("show owned", "Game");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WindowManager::loadFontDelegate(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version)
|
|
|
|
|
{
|
|
|
|
|
const std::string templateName = "Journalbook ";
|
|
|
|
|
MyGUI::xml::ElementEnumerator font = _node->getElementEnumerator();
|
|
|
|
|
bool createCopy = false;
|
|
|
|
|
while (font.next("Resource"))
|
|
|
|
|
{
|
|
|
|
|
std::string type, name;
|
|
|
|
|
font->findAttribute("type", type);
|
|
|
|
|
font->findAttribute("name", name);
|
|
|
|
|
|
|
|
|
|
if (name.empty())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (Misc::StringUtils::ciEqual(type, "ResourceTrueTypeFont"))
|
|
|
|
|
{
|
|
|
|
|
createCopy = true;
|
|
|
|
|
|
|
|
|
|
// For TrueType fonts we should override Size and Resolution properties
|
|
|
|
|
// to allow to configure font size via config file, without need to edit XML files.
|
|
|
|
|
// Also we should take UI scaling factor in account.
|
|
|
|
|
int resolution = Settings::Manager::getInt("ttf resolution", "GUI");
|
|
|
|
|
resolution = std::min(960, std::max(48, resolution));
|
|
|
|
|
|
|
|
|
|
float uiScale = Settings::Manager::getFloat("scaling factor", "GUI");
|
|
|
|
|
resolution *= uiScale;
|
|
|
|
|
|
|
|
|
|
MyGUI::xml::ElementPtr resolutionNode = font->createChild("Property");
|
|
|
|
|
resolutionNode->addAttribute("key", "Resolution");
|
|
|
|
|
resolutionNode->addAttribute("value", std::to_string(resolution));
|
|
|
|
|
|
|
|
|
|
MyGUI::xml::ElementPtr sizeNode = font->createChild("Property");
|
|
|
|
|
sizeNode->addAttribute("key", "Size");
|
|
|
|
|
sizeNode->addAttribute("value", std::to_string(mFontHeight));
|
|
|
|
|
}
|
|
|
|
|
else if (Misc::StringUtils::ciEqual(type, "ResourceSkin"))
|
|
|
|
|
{
|
|
|
|
|
// We should adjust line height for MyGUI widgets depending on font size
|
|
|
|
|
MyGUI::xml::ElementPtr heightNode = font->createChild("Property");
|
|
|
|
|
heightNode->addAttribute("key", "HeightLine");
|
|
|
|
|
heightNode->addAttribute("value", std::to_string(mFontHeight+2));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyGUI::ResourceManager::getInstance().loadFromXmlNode(_node, _file, _version);
|
|
|
|
|
|
|
|
|
|
if (createCopy)
|
|
|
|
|
{
|
|
|
|
|
MyGUI::xml::ElementPtr copy = _node->createCopy();
|
|
|
|
|
|
|
|
|
|
MyGUI::xml::ElementEnumerator copyFont = copy->getElementEnumerator();
|
|
|
|
|
while (copyFont.next("Resource"))
|
|
|
|
|
{
|
|
|
|
|
std::string type, name;
|
|
|
|
|
copyFont->findAttribute("type", type);
|
|
|
|
|
copyFont->findAttribute("name", name);
|
|
|
|
|
|
|
|
|
|
if (name.empty())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (Misc::StringUtils::ciEqual(type, "ResourceTrueTypeFont"))
|
|
|
|
|
{
|
|
|
|
|
// Since the journal and books use the custom scaling factor depending on resolution,
|
|
|
|
|
// setup separate fonts with different Resolution to fit these windows.
|
|
|
|
|
// These fonts have an internal prefix.
|
|
|
|
|
int resolution = Settings::Manager::getInt("ttf resolution", "GUI");
|
|
|
|
|
resolution = std::min(960, std::max(48, resolution));
|
|
|
|
|
|
|
|
|
|
float currentX = Settings::Manager::getInt("resolution x", "Video");
|
|
|
|
|
float currentY = Settings::Manager::getInt("resolution y", "Video");
|
|
|
|
|
// TODO: read size from openmw_layout.xml
|
|
|
|
|
float heightScale = (currentY / 520);
|
|
|
|
|
float widthScale = (currentX / 600);
|
|
|
|
|
float uiScale = std::min(widthScale, heightScale);
|
|
|
|
|
resolution *= uiScale;
|
|
|
|
|
|
|
|
|
|
MyGUI::xml::ElementPtr resolutionNode = copyFont->createChild("Property");
|
|
|
|
|
resolutionNode->addAttribute("key", "Resolution");
|
|
|
|
|
resolutionNode->addAttribute("value", std::to_string(resolution));
|
|
|
|
|
|
|
|
|
|
copyFont->setAttribute("name", "Journalbook " + name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyGUI::ResourceManager::getInstance().loadFromXmlNode(copy, _file, _version);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WindowManager::loadUserFonts()
|
|
|
|
|
{
|
|
|
|
|
mFontLoader->loadTrueTypeFonts();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WindowManager::initUI()
|
|
|
|
|
{
|
|
|
|
|
// Get size info from the Gui object
|
|
|
|
@ -504,6 +606,11 @@ namespace MWGui
|
|
|
|
|
updateVisible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int WindowManager::getFontHeight() const
|
|
|
|
|
{
|
|
|
|
|
return mFontHeight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WindowManager::setNewGame(bool newgame)
|
|
|
|
|
{
|
|
|
|
|
if (newgame)
|
|
|
|
@ -522,6 +629,7 @@ namespace MWGui
|
|
|
|
|
{
|
|
|
|
|
mKeyboardNavigation.reset();
|
|
|
|
|
|
|
|
|
|
MyGUI::ResourceManager::getInstance().unregisterLoadXmlDelegate("Resource");
|
|
|
|
|
MyGUI::LanguageManager::getInstance().eventRequestTag.clear();
|
|
|
|
|
MyGUI::PointerManager::getInstance().eventChangeMousePointer.clear();
|
|
|
|
|
MyGUI::InputManager::getInstance().eventChangeKeyFocus.clear();
|
|
|
|
|