|
|
|
@ -29,15 +29,13 @@
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
MyGUI::xml::ElementPtr getProperty(MyGUI::xml::ElementPtr resourceNode, const std::string propertyName)
|
|
|
|
|
MyGUI::xml::ElementPtr getProperty(MyGUI::xml::ElementPtr resourceNode, std::string_view propertyName)
|
|
|
|
|
{
|
|
|
|
|
MyGUI::xml::ElementPtr propertyNode = nullptr;
|
|
|
|
|
MyGUI::xml::ElementEnumerator propertyIterator = resourceNode->getElementEnumerator();
|
|
|
|
|
while (propertyIterator.next("Property"))
|
|
|
|
|
{
|
|
|
|
|
std::string key = propertyIterator->findAttribute("key");
|
|
|
|
|
|
|
|
|
|
if (key == propertyName)
|
|
|
|
|
if (propertyIterator->findAttribute("key") == propertyName)
|
|
|
|
|
{
|
|
|
|
|
propertyNode = propertyIterator.current();
|
|
|
|
|
break;
|
|
|
|
@ -55,17 +53,17 @@ namespace
|
|
|
|
|
MyGUI::xml::ElementEnumerator layersIterator = root->getElementEnumerator();
|
|
|
|
|
while (layersIterator.next("Layer"))
|
|
|
|
|
{
|
|
|
|
|
std::string name = layersIterator->findAttribute("name");
|
|
|
|
|
|
|
|
|
|
if (name == "JournalBooks")
|
|
|
|
|
if (layersIterator->findAttribute("name") == "JournalBooks")
|
|
|
|
|
{
|
|
|
|
|
MyGUI::xml::ElementPtr sizeProperty = getProperty(layersIterator.current(), "Size");
|
|
|
|
|
const std::string& sizeValue
|
|
|
|
|
= sizeProperty != nullptr ? sizeProperty->findAttribute("value") : std::string();
|
|
|
|
|
if (sizeProperty != nullptr)
|
|
|
|
|
{
|
|
|
|
|
std::string sizeValue = sizeProperty->findAttribute("value");
|
|
|
|
|
if (!sizeValue.empty())
|
|
|
|
|
return MyGUI::IntSize::parse(sizeValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return MyGUI::RenderManager::getInstance().getViewSize();
|
|
|
|
|
}
|
|
|
|
@ -215,7 +213,7 @@ namespace
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[[noreturn]] void fail(std::istream& stream, const std::string& fileName, const std::string& message)
|
|
|
|
|
[[noreturn]] void fail(std::istream& stream, std::string_view fileName, std::string_view message)
|
|
|
|
|
{
|
|
|
|
|
std::stringstream error;
|
|
|
|
|
error << "Font loading error: " << message;
|
|
|
|
@ -291,7 +289,7 @@ namespace Gui
|
|
|
|
|
MyGUI::IntSize bookSize = getBookSize(layersStream.get());
|
|
|
|
|
float bookScale = osgMyGUI::ScalingLayer::getScaleFactor(bookSize);
|
|
|
|
|
|
|
|
|
|
const auto oldDataPath = dataManager->getDataPath("");
|
|
|
|
|
const auto oldDataPath = dataManager->getDataPath({});
|
|
|
|
|
dataManager->setResourcePath("fonts");
|
|
|
|
|
std::unique_ptr<MyGUI::IDataStream> dataStream(dataManager->getData(fileName));
|
|
|
|
|
|
|
|
|
@ -303,8 +301,7 @@ namespace Gui
|
|
|
|
|
bool valid = false;
|
|
|
|
|
if (resourceNode.next("Resource"))
|
|
|
|
|
{
|
|
|
|
|
std::string type = resourceNode->findAttribute("type");
|
|
|
|
|
valid = (type == "ResourceTrueTypeFont");
|
|
|
|
|
valid = resourceNode->findAttribute("type") == "ResourceTrueTypeFont";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (valid == false)
|
|
|
|
@ -450,7 +447,7 @@ namespace Gui
|
|
|
|
|
defaultHeight->addAttribute("value", fontSize);
|
|
|
|
|
MyGUI::xml::ElementPtr source = root->createChild("Property");
|
|
|
|
|
source->addAttribute("key", "Source");
|
|
|
|
|
source->addAttribute("value", std::string(bitmapFilename));
|
|
|
|
|
source->addAttribute("value", bitmapFilename);
|
|
|
|
|
MyGUI::xml::ElementPtr codes = root->createChild("Codes");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 256; i++)
|
|
|
|
@ -532,12 +529,12 @@ namespace Gui
|
|
|
|
|
additional.insert(std::make_pair(84, 0x2122)); // trademark sign
|
|
|
|
|
additional.insert(std::make_pair(45, 0x2212)); // minus sign
|
|
|
|
|
|
|
|
|
|
for (std::multimap<int, int>::iterator it = additional.begin(); it != additional.end(); ++it)
|
|
|
|
|
for (const auto [key, value] : additional)
|
|
|
|
|
{
|
|
|
|
|
if (it->first != i)
|
|
|
|
|
if (key != i)
|
|
|
|
|
continue;
|
|
|
|
|
code = codes->createChild("Code");
|
|
|
|
|
code->addAttribute("index", it->second);
|
|
|
|
|
code->addAttribute("index", value);
|
|
|
|
|
code->addAttribute("coord",
|
|
|
|
|
MyGUI::utility::toString(x1) + " " + MyGUI::utility::toString(y1) + " "
|
|
|
|
|
+ MyGUI::utility::toString(w) + " " + MyGUI::utility::toString(h));
|
|
|
|
@ -638,10 +635,9 @@ namespace Gui
|
|
|
|
|
return mFontHeight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string FontLoader::getFontForFace(const std::string& face)
|
|
|
|
|
std::string_view FontLoader::getFontForFace(std::string_view face)
|
|
|
|
|
{
|
|
|
|
|
const std::string lowerFace = Misc::StringUtils::lowerCase(face);
|
|
|
|
|
if (lowerFace == "daedric")
|
|
|
|
|
if (Misc::StringUtils::ciEqual(face, "daedric"))
|
|
|
|
|
return "ScrollFont";
|
|
|
|
|
|
|
|
|
|
return "DefaultFont";
|
|
|
|
|