Improve GUI scaling (bug #3288)

pull/1768/head
Andrei Kortunov 7 years ago
parent 6100e34051
commit adbaeb7cca

@ -20,6 +20,7 @@
Bug #3059: Unable to hit with marksman weapons when too close to an enemy Bug #3059: Unable to hit with marksman weapons when too close to an enemy
Bug #3072: Fatal error on AddItem <item> that has a script containing Equip <item> Bug #3072: Fatal error on AddItem <item> that has a script containing Equip <item>
Bug #3249: Fixed revert function not updating views properly Bug #3249: Fixed revert function not updating views properly
Bug #3288: TrueType fonts are handled incorrectly
Bug #3374: Touch spells not hitting kwama foragers Bug #3374: Touch spells not hitting kwama foragers
Bug #3486: [Mod] NPC Commands does not work Bug #3486: [Mod] NPC Commands does not work
Bug #3533: GetSpellEffects should detect effects with zero duration Bug #3533: GetSpellEffects should detect effects with zero duration

@ -219,6 +219,7 @@ namespace MWBase
virtual const MWWorld::Ptr& getSelectedEnchantItem() const = 0; virtual const MWWorld::Ptr& getSelectedEnchantItem() const = 0;
virtual void setSelectedWeapon(const MWWorld::Ptr& item) = 0; virtual void setSelectedWeapon(const MWWorld::Ptr& item) = 0;
virtual const MWWorld::Ptr& getSelectedWeapon() const = 0; virtual const MWWorld::Ptr& getSelectedWeapon() const = 0;
virtual int getFontHeight() const = 0;
virtual void unsetSelectedSpell() = 0; virtual void unsetSelectedSpell() = 0;
virtual void unsetSelectedWeapon() = 0; virtual void unsetSelectedWeapon() = 0;

@ -1,6 +1,5 @@
#include "bookpage.hpp" #include "bookpage.hpp"
#include "MyGUI_FontManager.h"
#include "MyGUI_RenderItem.h" #include "MyGUI_RenderItem.h"
#include "MyGUI_RenderManager.h" #include "MyGUI_RenderManager.h"
#include "MyGUI_TextureUtility.h" #include "MyGUI_TextureUtility.h"
@ -8,6 +7,9 @@
#include <components/misc/utf8stream.hpp> #include <components/misc/utf8stream.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
namespace MWGui namespace MWGui
{ {
struct TypesetBookImpl; struct TypesetBookImpl;
@ -497,9 +499,9 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
while (!stream.eof () && !ucsLineBreak (stream.peek ()) && ucsBreakingSpace (stream.peek ())) while (!stream.eof () && !ucsLineBreak (stream.peek ()) && ucsBreakingSpace (stream.peek ()))
{ {
MyGUI::GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ()); MWGui::GlyphInfo info = GlyphInfo(style->mFont, stream.peek());
if (gi) if (info.codePoint >= 0)
space_width += static_cast<int>(gi->advance + gi->bearingX); space_width += static_cast<int>(info.advance + info.bearingX);
stream.consume (); stream.consume ();
} }
@ -507,9 +509,9 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
while (!stream.eof () && !ucsLineBreak (stream.peek ()) && !ucsBreakingSpace (stream.peek ())) while (!stream.eof () && !ucsLineBreak (stream.peek ()) && !ucsBreakingSpace (stream.peek ()))
{ {
MyGUI::GlyphInfo* gi = style->mFont->getGlyphInfo (stream.peek ()); MWGui::GlyphInfo info = GlyphInfo(style->mFont, stream.peek());
if (gi) if (info.codePoint >= 0)
word_width += static_cast<int>(gi->advance + gi->bearingX); word_width += static_cast<int>(info.advance + info.bearingX);
stream.consume (); stream.consume ();
} }
@ -530,6 +532,7 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
if (mPartialWhitespace.empty() && mPartialWord.empty()) if (mPartialWhitespace.empty() && mPartialWord.empty())
return; return;
int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight();
int space_width = 0; int space_width = 0;
int word_width = 0; int word_width = 0;
@ -549,9 +552,8 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
for (PartialTextConstIterator i = mPartialWhitespace.begin (); i != mPartialWhitespace.end (); ++i) for (PartialTextConstIterator i = mPartialWhitespace.begin (); i != mPartialWhitespace.end (); ++i)
{ {
int top = mLine ? mLine->mRect.top : mBook->mRect.bottom; int top = mLine ? mLine->mRect.top : mBook->mRect.bottom;
int line_height = i->mStyle->mFont->getDefaultHeight ();
append_run ( i->mStyle, i->mBegin, i->mEnd, 0, left + i->mWidth, top + line_height); append_run ( i->mStyle, i->mBegin, i->mEnd, 0, left + i->mWidth, top + fontHeight);
left = mLine->mRect.right; left = mLine->mRect.right;
} }
@ -560,9 +562,8 @@ struct TypesetBookImpl::Typesetter : BookTypesetter
for (PartialTextConstIterator i = mPartialWord.begin (); i != mPartialWord.end (); ++i) for (PartialTextConstIterator i = mPartialWord.begin (); i != mPartialWord.end (); ++i)
{ {
int top = mLine ? mLine->mRect.top : mBook->mRect.bottom; int top = mLine ? mLine->mRect.top : mBook->mRect.bottom;
int line_height = i->mStyle->mFont->getDefaultHeight ();
append_run (i->mStyle, i->mBegin, i->mEnd, i->mEnd - i->mBegin, left + i->mWidth, top + line_height); append_run (i->mStyle, i->mBegin, i->mEnd, i->mEnd - i->mBegin, left + i->mWidth, top + fontHeight);
left = mLine->mRect.right; left = mLine->mRect.right;
} }
@ -756,32 +757,32 @@ namespace
void emitGlyph (wchar_t ch) void emitGlyph (wchar_t ch)
{ {
MyGUI::GlyphInfo* gi = mFont->getGlyphInfo (ch); MWGui::GlyphInfo info = GlyphInfo(mFont, ch);
if (!gi) if (info.codePoint < 0)
return; return;
MyGUI::FloatRect vr; MyGUI::FloatRect vr;
vr.left = mCursor.left + gi->bearingX; vr.left = mCursor.left + info.bearingX;
vr.top = mCursor.top + gi->bearingY; vr.top = mCursor.top + info.bearingY;
vr.right = vr.left + gi->width; vr.right = vr.left + info.width;
vr.bottom = vr.top + gi->height; vr.bottom = vr.top + info.height;
MyGUI::FloatRect tr = gi->uvRect; MyGUI::FloatRect tr = info.uvRect;
if (mRenderXform.clip (vr, tr)) if (mRenderXform.clip (vr, tr))
quad (vr, tr); quad (vr, tr);
mCursor.left += gi->bearingX + gi->advance; mCursor.left += static_cast<int>(info.bearingX + info.advance);
} }
void emitSpace (wchar_t ch) void emitSpace (wchar_t ch)
{ {
MyGUI::GlyphInfo* gi = mFont->getGlyphInfo (ch); MWGui::GlyphInfo info = GlyphInfo(mFont, ch);
if (gi) if (info.codePoint >= 0)
mCursor.left += gi->bearingX + gi->advance; mCursor.left += static_cast<int>(info.bearingX + info.advance);
} }
private: private:

@ -3,10 +3,17 @@
#include "MyGUI_Colour.h" #include "MyGUI_Colour.h"
#include "MyGUI_Widget.h" #include "MyGUI_Widget.h"
#include "MyGUI_FontManager.h"
#include <functional> #include <functional>
#include <stdint.h> #include <stdint.h>
#include <components/settings/settings.hpp>
#include <components/widgets/widgets.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
namespace MWGui namespace MWGui
{ {
/// A formatted and paginated document to be used with /// A formatted and paginated document to be used with
@ -28,6 +35,45 @@ namespace MWGui
virtual std::pair <unsigned int, unsigned int> getSize () const = 0; virtual std::pair <unsigned int, unsigned int> getSize () const = 0;
}; };
struct GlyphInfo
{
char codePoint;
float width;
float height;
float advance;
float bearingX;
float bearingY;
MyGUI::FloatRect uvRect;
GlyphInfo(MyGUI::IFont* font, MyGUI::Char ch)
{
static const int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight();
MyGUI::GlyphInfo* gi = font->getGlyphInfo(ch);
if (gi)
{
const float scale = font->getDefaultHeight() / (float) fontHeight;
codePoint = gi->codePoint;
bearingX = (int) gi->bearingX / scale;
bearingY = (int) gi->bearingY / scale;
width = (int) gi->width / scale;
height = (int) gi->height / scale;
advance = (int) gi->advance / scale;
uvRect = gi->uvRect;
}
else
{
codePoint = -1;
bearingX = 0;
bearingY = 0;
width = 0;
height = 0;
advance = 0;
}
}
};
/// A factory class for creating a typeset book instance. /// A factory class for creating a typeset book instance.
struct BookTypesetter struct BookTypesetter
{ {

@ -152,12 +152,6 @@ namespace MWGui
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mCommandLine); MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mCommandLine);
} }
void Console::setFont(const std::string &fntName)
{
mHistory->setFontName(fntName);
mCommandLine->setFontName(fntName);
}
void Console::print(const std::string &msg, const std::string& color) void Console::print(const std::string &msg, const std::string& color)
{ {
mHistory->addText(color + MyGUI::TextIterator::toTagsString(msg)); mHistory->addText(color + MyGUI::TextIterator::toTagsString(msg));

@ -41,8 +41,6 @@ namespace MWGui
virtual void onOpen(); virtual void onOpen();
void setFont(const std::string &fntName);
void onResChange(int width, int height); void onResChange(int width, int height);
// Print a message to the console, in specified color. // Print a message to the console, in specified color.

@ -415,7 +415,7 @@ namespace MWGui
: GraphicElement(parent, pag, blockStyle), : GraphicElement(parent, pag, blockStyle),
mTextStyle(textStyle) mTextStyle(textStyle)
{ {
MyGUI::EditBox* box = parent->createWidget<MyGUI::EditBox>("NormalText", Gui::EditBox* box = parent->createWidget<Gui::EditBox>("NormalText",
MyGUI::IntCoord(0, pag.getCurrentTop(), pag.getPageWidth(), 0), MyGUI::Align::Left | MyGUI::Align::Top, MyGUI::IntCoord(0, pag.getCurrentTop(), pag.getPageWidth(), 0), MyGUI::Align::Left | MyGUI::Align::Top,
parent->getName() + MyGUI::utility::toString(parent->getChildCount())); parent->getName() + MyGUI::utility::toString(parent->getChildCount()));
box->setEditStatic(true); box->setEditStatic(true);
@ -432,15 +432,6 @@ namespace MWGui
mEditBox = box; mEditBox = box;
} }
int TextElement::currentFontHeight() const
{
std::string fontName(mTextStyle.mFont == "Default" ? MyGUI::FontManager::getInstance().getDefaultFont() : mTextStyle.mFont);
MyGUI::IFont* font = MyGUI::FontManager::getInstance().getByName(fontName);
if (!font)
return 0;
return font->getDefaultHeight();
}
int TextElement::getHeight() int TextElement::getHeight()
{ {
return mEditBox->getTextSize().height; return mEditBox->getTextSize().height;
@ -449,7 +440,7 @@ namespace MWGui
int TextElement::pageSplit() int TextElement::pageSplit()
{ {
// split lines // split lines
const int lineHeight = currentFontHeight(); const int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight();
unsigned int lastLine = (mPaginator.getStartTop() + mPaginator.getPageHeight() - mPaginator.getCurrentTop()); unsigned int lastLine = (mPaginator.getStartTop() + mPaginator.getPageHeight() - mPaginator.getCurrentTop());
if (lineHeight > 0) if (lineHeight > 0)
lastLine /= lineHeight; lastLine /= lineHeight;

@ -4,6 +4,8 @@
#include <MyGUI_Colour.h> #include <MyGUI_Colour.h>
#include <map> #include <map>
#include <components/widgets/box.hpp>
namespace MWGui namespace MWGui
{ {
namespace Formatting namespace Formatting
@ -152,7 +154,7 @@ namespace MWGui
private: private:
int currentFontHeight() const; int currentFontHeight() const;
TextStyle mTextStyle; TextStyle mTextStyle;
MyGUI::EditBox * mEditBox; Gui::EditBox * mEditBox;
}; };
class ImageElement : public GraphicElement class ImageElement : public GraphicElement

@ -218,21 +218,24 @@ book JournalBooks::createQuestBook (const std::string& questName)
return typesetter->complete (); return typesetter->complete ();
} }
book JournalBooks::createTopicIndexBook () book JournalBooks::createTopicIndexBook (int& columnsCount)
{ {
bool isRussian = (mEncoding == ToUTF8::WINDOWS_1251); bool isRussian = (mEncoding == ToUTF8::WINDOWS_1251);
BookTypesetter::Ptr typesetter = isRussian ? createCyrillicJournalIndex() : createLatinJournalIndex(); BookTypesetter::Ptr typesetter = isRussian ? createCyrillicJournalIndex(columnsCount) : createLatinJournalIndex(columnsCount);
return typesetter->complete (); return typesetter->complete ();
} }
BookTypesetter::Ptr JournalBooks::createLatinJournalIndex () BookTypesetter::Ptr JournalBooks::createLatinJournalIndex (int& columnsCount)
{ {
BookTypesetter::Ptr typesetter = BookTypesetter::create (92, 250); BookTypesetter::Ptr typesetter = BookTypesetter::create (92, 260);
typesetter->setSectionAlignment (BookTypesetter::AlignCenter); typesetter->setSectionAlignment (BookTypesetter::AlignCenter);
// Latin journal index always has two columns for now.
columnsCount = 2;
char ch = 'A'; char ch = 'A';
BookTypesetter::Style* body = typesetter->createStyle ("", MyGUI::Colour::Black); BookTypesetter::Style* body = typesetter->createStyle ("", MyGUI::Colour::Black);
@ -258,14 +261,25 @@ BookTypesetter::Ptr JournalBooks::createLatinJournalIndex ()
return typesetter; return typesetter;
} }
BookTypesetter::Ptr JournalBooks::createCyrillicJournalIndex () BookTypesetter::Ptr JournalBooks::createCyrillicJournalIndex (int& columnsCount)
{ {
BookTypesetter::Ptr typesetter = BookTypesetter::create (92, 250); BookTypesetter::Ptr typesetter = BookTypesetter::create (92, 260);
typesetter->setSectionAlignment (BookTypesetter::AlignCenter); typesetter->setSectionAlignment (BookTypesetter::AlignCenter);
BookTypesetter::Style* body = typesetter->createStyle ("", MyGUI::Colour::Black); BookTypesetter::Style* body = typesetter->createStyle ("", MyGUI::Colour::Black);
int fontHeight = MWBase::Environment::get().getWindowManager()->getFontHeight();
// for small font size split alphabet to two columns (2x15 characers), for big font size split it to three colums (3x10 characters).
int sectionBreak = 10;
columnsCount = 3;
if (fontHeight < 18)
{
sectionBreak = 15;
columnsCount = 2;
}
unsigned char ch[2] = {0xd0, 0x90}; // CYRILLIC CAPITAL A is a 0xd090 in UTF-8 unsigned char ch[2] = {0xd0, 0x90}; // CYRILLIC CAPITAL A is a 0xd090 in UTF-8
for (int i = 0; i < 32; ++i) for (int i = 0; i < 32; ++i)
@ -287,7 +301,7 @@ BookTypesetter::Ptr JournalBooks::createCyrillicJournalIndex ()
if (i == 26 || i == 28) if (i == 26 || i == 28)
continue; continue;
if (i == 15) if (i % sectionBreak == 0)
typesetter->sectionBreak (); typesetter->sectionBreak ();
typesetter->write (style, to_utf8_span (buffer)); typesetter->write (style, to_utf8_span (buffer));

@ -22,14 +22,14 @@ namespace MWGui
Book createTopicBook (uintptr_t topicId); Book createTopicBook (uintptr_t topicId);
Book createTopicBook (const std::string& topicId); Book createTopicBook (const std::string& topicId);
Book createQuestBook (const std::string& questName); Book createQuestBook (const std::string& questName);
Book createTopicIndexBook (); Book createTopicIndexBook (int& columnsCount);
ToUTF8::FromType mEncoding; ToUTF8::FromType mEncoding;
private: private:
BookTypesetter::Ptr createTypesetter (); BookTypesetter::Ptr createTypesetter ();
BookTypesetter::Ptr createLatinJournalIndex (); BookTypesetter::Ptr createLatinJournalIndex (int& columnsCount);
BookTypesetter::Ptr createCyrillicJournalIndex (); BookTypesetter::Ptr createCyrillicJournalIndex (int& columnsCount);
}; };
} }

@ -43,6 +43,7 @@ namespace
static char const LeftBookPage [] = "LeftBookPage"; static char const LeftBookPage [] = "LeftBookPage";
static char const RightBookPage [] = "RightBookPage"; static char const RightBookPage [] = "RightBookPage";
static char const LeftTopicIndex [] = "LeftTopicIndex"; static char const LeftTopicIndex [] = "LeftTopicIndex";
static char const CenterTopicIndex [] = "CenterTopicIndex";
static char const RightTopicIndex [] = "RightTopicIndex"; static char const RightTopicIndex [] = "RightTopicIndex";
struct JournalWindowImpl : MWGui::JournalBooks, MWGui::JournalWindow struct JournalWindowImpl : MWGui::JournalBooks, MWGui::JournalWindow
@ -148,6 +149,7 @@ namespace
callback = std::bind(&JournalWindowImpl::notifyIndexLinkClicked, this, std::placeholders::_1); callback = std::bind(&JournalWindowImpl::notifyIndexLinkClicked, this, std::placeholders::_1);
getPage (LeftTopicIndex)->adviseLinkClicked (callback); getPage (LeftTopicIndex)->adviseLinkClicked (callback);
getPage (CenterTopicIndex)->adviseLinkClicked (callback);
getPage (RightTopicIndex)->adviseLinkClicked (callback); getPage (RightTopicIndex)->adviseLinkClicked (callback);
} }
@ -312,6 +314,7 @@ namespace
setVisible (TopicsList, false); setVisible (TopicsList, false);
setVisible (QuestsList, mQuestMode); setVisible (QuestsList, mQuestMode);
setVisible (LeftTopicIndex, !mQuestMode); setVisible (LeftTopicIndex, !mQuestMode);
setVisible (CenterTopicIndex, !mQuestMode);
setVisible (RightTopicIndex, !mQuestMode); setVisible (RightTopicIndex, !mQuestMode);
setVisible (ShowAllBTN, mQuestMode && !mAllQuests); setVisible (ShowAllBTN, mQuestMode && !mAllQuests);
setVisible (ShowActiveBTN, mQuestMode && mAllQuests); setVisible (ShowActiveBTN, mQuestMode && mAllQuests);
@ -462,11 +465,21 @@ namespace
{ {
setOptionsMode (); setOptionsMode ();
int pagesCount;
if (!mTopicIndexBook) if (!mTopicIndexBook)
mTopicIndexBook = createTopicIndexBook (); mTopicIndexBook = createTopicIndexBook (pagesCount);
getPage (LeftTopicIndex)->showPage (mTopicIndexBook, 0); if (pagesCount == 3)
getPage (RightTopicIndex)->showPage (mTopicIndexBook, 1); {
getPage (LeftTopicIndex)->showPage (mTopicIndexBook, 0);
getPage (CenterTopicIndex)->showPage (mTopicIndexBook, 1);
getPage (RightTopicIndex)->showPage (mTopicIndexBook, 2);
}
else
{
getPage (LeftTopicIndex)->showPage (mTopicIndexBook, 0);
getPage (RightTopicIndex)->showPage (mTopicIndexBook, 1);
}
} }
void notifyJournal(MyGUI::Widget* _sender) void notifyJournal(MyGUI::Widget* _sender)
@ -480,6 +493,7 @@ namespace
void notifyIndexLinkClicked (MWGui::TypesetBook::InteractiveId index) void notifyIndexLinkClicked (MWGui::TypesetBook::InteractiveId index)
{ {
setVisible (LeftTopicIndex, false); setVisible (LeftTopicIndex, false);
setVisible (CenterTopicIndex, false);
setVisible (RightTopicIndex, false); setVisible (RightTopicIndex, false);
setVisible (TopicsList, true); setVisible (TopicsList, true);
@ -502,6 +516,7 @@ namespace
mQuestMode = false; mQuestMode = false;
mTopicsMode = false; mTopicsMode = false;
setVisible (LeftTopicIndex, true); setVisible (LeftTopicIndex, true);
setVisible (CenterTopicIndex, true);
setVisible (RightTopicIndex, true); setVisible (RightTopicIndex, true);
setVisible (TopicsList, false); setVisible (TopicsList, false);
setVisible (QuestsList, false); setVisible (QuestsList, false);
@ -540,6 +555,7 @@ namespace
mQuestMode = true; mQuestMode = true;
setVisible (LeftTopicIndex, false); setVisible (LeftTopicIndex, false);
setVisible (CenterTopicIndex, true);
setVisible (RightTopicIndex, false); setVisible (RightTopicIndex, false);
setVisible (TopicsList, false); setVisible (TopicsList, false);
setVisible (QuestsList, true); setVisible (QuestsList, true);

@ -20,8 +20,6 @@
namespace MWGui namespace MWGui
{ {
const int MerchantRepair::sLineHeight = 18;
MerchantRepair::MerchantRepair() MerchantRepair::MerchantRepair()
: WindowBase("openmw_merchantrepair.layout") : WindowBase("openmw_merchantrepair.layout")
{ {
@ -39,6 +37,7 @@ void MerchantRepair::setPtr(const MWWorld::Ptr &actor)
while (mList->getChildCount()) while (mList->getChildCount())
MyGUI::Gui::getInstance().destroyWidget(mList->getChildAt(0)); MyGUI::Gui::getInstance().destroyWidget(mList->getChildAt(0));
int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
int currentY = 0; int currentY = 0;
MWWorld::Ptr player = MWMechanics::getPlayer(); MWWorld::Ptr player = MWMechanics::getPlayer();
@ -67,28 +66,26 @@ void MerchantRepair::setPtr(const MWWorld::Ptr &actor)
int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mActor, x, true); int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mActor, x, true);
std::string name = iter->getClass().getName(*iter) std::string name = iter->getClass().getName(*iter)
+ " - " + MyGUI::utility::toString(price) + " - " + MyGUI::utility::toString(price)
+ MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>() + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
.find("sgp")->mValue.getString(); .find("sgp")->mValue.getString();
MyGUI::Button* button = MyGUI::Button* button =
mList->createWidget<MyGUI::Button>(price <= playerGold ? "SandTextButton" : "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip mList->createWidget<MyGUI::Button>(price <= playerGold ? "SandTextButton" : "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip
0, 0,
currentY, currentY,
0, 0,
sLineHeight, lineHeight,
MyGUI::Align::Default MyGUI::Align::Default
); );
currentY += sLineHeight; currentY += lineHeight;
button->setUserString("Price", MyGUI::utility::toString(price)); button->setUserString("Price", MyGUI::utility::toString(price));
button->setUserData(MWWorld::Ptr(*iter)); button->setUserData(MWWorld::Ptr(*iter));
button->setCaptionWithReplacing(name); button->setCaptionWithReplacing(name);
button->setSize(mList->getWidth(),sLineHeight); button->setSize(mList->getWidth(), lineHeight);
button->eventMouseWheel += MyGUI::newDelegate(this, &MerchantRepair::onMouseWheel); button->eventMouseWheel += MyGUI::newDelegate(this, &MerchantRepair::onMouseWheel);
button->setUserString("ToolTipType", "ItemPtr"); button->setUserString("ToolTipType", "ItemPtr");
button->eventMouseButtonClick += MyGUI::newDelegate(this, &MerchantRepair::onRepairButtonClick); button->eventMouseButtonClick += MyGUI::newDelegate(this, &MerchantRepair::onRepairButtonClick);

@ -27,8 +27,6 @@ protected:
void onMouseWheel(MyGUI::Widget* _sender, int _rel); void onMouseWheel(MyGUI::Widget* _sender, int _rel);
void onRepairButtonClick(MyGUI::Widget* sender); void onRepairButtonClick(MyGUI::Widget* sender);
void onOkButtonClick(MyGUI::Widget* sender); void onOkButtonClick(MyGUI::Widget* sender);
static const int sLineHeight;
}; };
} }

@ -26,9 +26,6 @@ namespace
namespace MWGui namespace MWGui
{ {
const int ReviewDialog::sLineHeight = 18;
ReviewDialog::ReviewDialog() ReviewDialog::ReviewDialog()
: WindowModal("openmw_chargen_review.layout"), : WindowModal("openmw_chargen_review.layout"),
mUpdateSkillArea(false) mUpdateSkillArea(false)
@ -261,8 +258,9 @@ namespace MWGui
groupWidget->setCaption(label); groupWidget->setCaption(label);
mSkillWidgets.push_back(groupWidget); mSkillWidgets.push_back(groupWidget);
coord1.top += sLineHeight; int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
coord2.top += sLineHeight; coord1.top += lineHeight;
coord2.top += lineHeight;
} }
MyGUI::TextBox* ReviewDialog::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) MyGUI::TextBox* ReviewDialog::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
@ -282,8 +280,9 @@ namespace MWGui
mSkillWidgets.push_back(skillNameWidget); mSkillWidgets.push_back(skillNameWidget);
mSkillWidgets.push_back(skillValueWidget); mSkillWidgets.push_back(skillValueWidget);
coord1.top += sLineHeight; int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
coord2.top += sLineHeight; coord1.top += lineHeight;
coord2.top += lineHeight;
return skillValueWidget; return skillValueWidget;
} }
@ -298,8 +297,9 @@ namespace MWGui
mSkillWidgets.push_back(skillNameWidget); mSkillWidgets.push_back(skillNameWidget);
coord1.top += sLineHeight; int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
coord2.top += sLineHeight; coord1.top += lineHeight;
coord2.top += lineHeight;
} }
void ReviewDialog::addItem(const ESM::Spell* spell, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2) void ReviewDialog::addItem(const ESM::Spell* spell, MyGUI::IntCoord& coord1, MyGUI::IntCoord& coord2)
@ -312,8 +312,9 @@ namespace MWGui
mSkillWidgets.push_back(widget); mSkillWidgets.push_back(widget);
coord1.top += sLineHeight; int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
coord2.top += sLineHeight; coord1.top += lineHeight;
coord2.top += lineHeight;
} }
void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId, const std::string &titleDefault, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)

@ -87,8 +87,6 @@ namespace MWGui
void addItem(const ESM::Spell* spell, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2); void addItem(const ESM::Spell* spell, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2);
void updateSkillArea(); void updateSkillArea();
static const int sLineHeight;
MyGUI::TextBox *mNameWidget, *mRaceWidget, *mClassWidget, *mBirthSignWidget; MyGUI::TextBox *mNameWidget, *mRaceWidget, *mClassWidget, *mBirthSignWidget;
MyGUI::ScrollView* mSkillView; MyGUI::ScrollView* mSkillView;

@ -18,8 +18,6 @@
namespace MWGui namespace MWGui
{ {
const int SpellBuyingWindow::sLineHeight = 18;
SpellBuyingWindow::SpellBuyingWindow() : SpellBuyingWindow::SpellBuyingWindow() :
WindowBase("openmw_spell_buying_window.layout") WindowBase("openmw_spell_buying_window.layout")
, mCurrentY(0) , mCurrentY(0)
@ -52,21 +50,23 @@ namespace MWGui
// TODO: refactor to use MyGUI::ListBox // TODO: refactor to use MyGUI::ListBox
int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
MyGUI::Button* toAdd = MyGUI::Button* toAdd =
mSpellsView->createWidget<MyGUI::Button>( mSpellsView->createWidget<MyGUI::Button>(
price <= playerGold ? "SandTextButton" : "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip price <= playerGold ? "SandTextButton" : "SandTextButtonDisabled", // can't use setEnabled since that removes tooltip
0, 0,
mCurrentY, mCurrentY,
200, 200,
sLineHeight, lineHeight,
MyGUI::Align::Default MyGUI::Align::Default
); );
mCurrentY += sLineHeight; mCurrentY += lineHeight;
toAdd->setUserData(price); toAdd->setUserData(price);
toAdd->setCaptionWithReplacing(spell.mName+" - "+MyGUI::utility::toString(price)+"#{sgp}"); toAdd->setCaptionWithReplacing(spell.mName+" - "+MyGUI::utility::toString(price)+"#{sgp}");
toAdd->setSize(mSpellsView->getWidth(),sLineHeight); toAdd->setSize(mSpellsView->getWidth(), lineHeight);
toAdd->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &SpellBuyingWindow::onMouseWheel);
toAdd->setUserString("ToolTipType", "Spell"); toAdd->setUserString("ToolTipType", "Spell");
toAdd->setUserString("Spell", spell.mId); toAdd->setUserString("Spell", spell.mId);

@ -48,8 +48,6 @@ namespace MWGui
void clearSpells(); void clearSpells();
int mCurrentY; int mCurrentY;
static const int sLineHeight;
void updateLabels(); void updateLabels();
virtual void onReferenceUnavailable(); virtual void onReferenceUnavailable();

@ -6,6 +6,7 @@
#include <MyGUI_Gui.h> #include <MyGUI_Gui.h>
#include <components/widgets/sharedstatebutton.hpp> #include <components/widgets/sharedstatebutton.hpp>
#include <components/widgets/box.hpp>
#include "tooltips.hpp" #include "tooltips.hpp"
@ -240,7 +241,7 @@ namespace MWGui
mLines.push_back(LineInfo(separator, (MyGUI::Widget*)NULL, NoSpellIndex)); mLines.push_back(LineInfo(separator, (MyGUI::Widget*)NULL, NoSpellIndex));
} }
MyGUI::TextBox* groupWidget = mScrollView->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::TextBox* groupWidget = mScrollView->createWidget<Gui::TextBox>("SandBrightText",
MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24), MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24),
MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::Align::Left | MyGUI::Align::Top);
groupWidget->setCaptionWithReplacing(label); groupWidget->setCaptionWithReplacing(label);
@ -249,7 +250,7 @@ namespace MWGui
if (label2 != "") if (label2 != "")
{ {
MyGUI::TextBox* groupWidget2 = mScrollView->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::TextBox* groupWidget2 = mScrollView->createWidget<Gui::TextBox>("SandBrightText",
MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24), MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24),
MyGUI::Align::Left | MyGUI::Align::Top); MyGUI::Align::Left | MyGUI::Align::Top);
groupWidget2->setCaptionWithReplacing(label2); groupWidget2->setCaptionWithReplacing(label2);

@ -23,9 +23,6 @@
namespace MWGui namespace MWGui
{ {
const int StatsWindow::sLineHeight = 18;
StatsWindow::StatsWindow (DragAndDrop* drag) StatsWindow::StatsWindow (DragAndDrop* drag)
: WindowPinnableBase("openmw_stats_window.layout") : WindowPinnableBase("openmw_stats_window.layout")
, NoDrop(drag, mMainWidget) , NoDrop(drag, mMainWidget)
@ -376,8 +373,9 @@ namespace MWGui
groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); groupWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel);
mSkillWidgets.push_back(groupWidget); mSkillWidgets.push_back(groupWidget);
coord1.top += sLineHeight; int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
coord2.top += sLineHeight; coord1.top += lineHeight;
coord2.top += lineHeight;
} }
std::pair<MyGUI::TextBox*, MyGUI::TextBox*> StatsWindow::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2) std::pair<MyGUI::TextBox*, MyGUI::TextBox*> StatsWindow::addValueItem(const std::string& text, const std::string &value, const std::string& state, MyGUI::IntCoord &coord1, MyGUI::IntCoord &coord2)
@ -401,8 +399,9 @@ namespace MWGui
mSkillWidgets.push_back(skillNameWidget); mSkillWidgets.push_back(skillNameWidget);
mSkillWidgets.push_back(skillValueWidget); mSkillWidgets.push_back(skillValueWidget);
coord1.top += sLineHeight; int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
coord2.top += sLineHeight; coord1.top += lineHeight;
coord2.top += lineHeight;
return std::make_pair(skillNameWidget, skillValueWidget); return std::make_pair(skillNameWidget, skillValueWidget);
} }
@ -421,8 +420,9 @@ namespace MWGui
mSkillWidgets.push_back(skillNameWidget); mSkillWidgets.push_back(skillNameWidget);
coord1.top += sLineHeight; int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
coord2.top += sLineHeight; coord1.top += lineHeight;
coord2.top += lineHeight;
return skillNameWidget; return skillNameWidget;
} }

@ -53,8 +53,6 @@ namespace MWGui
void onWindowResize(MyGUI::Window* window); void onWindowResize(MyGUI::Window* window);
void onMouseWheel(MyGUI::Widget* _sender, int _rel); void onMouseWheel(MyGUI::Widget* _sender, int _rel);
static const int sLineHeight;
MyGUI::Widget* mLeftPane; MyGUI::Widget* mLeftPane;
MyGUI::Widget* mRightPane; MyGUI::Widget* mRightPane;

@ -8,6 +8,7 @@
#include <MyGUI_ImageBox.h> #include <MyGUI_ImageBox.h>
#include <components/settings/settings.hpp> #include <components/settings/settings.hpp>
#include <components/widgets/box.hpp>
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -421,7 +422,7 @@ namespace MWGui
std::string realImage = MWBase::Environment::get().getWindowManager()->correctIconPath(image); std::string realImage = MWBase::Environment::get().getWindowManager()->correctIconPath(image);
MyGUI::EditBox* captionWidget = mDynamicToolTipBox->createWidget<MyGUI::EditBox>("NormalText", MyGUI::IntCoord(0, 0, 300, 300), MyGUI::Align::Left | MyGUI::Align::Top, "ToolTipCaption"); Gui::EditBox* captionWidget = mDynamicToolTipBox->createWidget<Gui::EditBox>("NormalText", MyGUI::IntCoord(0, 0, 300, 300), MyGUI::Align::Left | MyGUI::Align::Top, "ToolTipCaption");
captionWidget->setEditStatic(true); captionWidget->setEditStatic(true);
captionWidget->setNeedKeyFocus(false); captionWidget->setNeedKeyFocus(false);
captionWidget->setCaptionWithReplacing(caption); captionWidget->setCaptionWithReplacing(caption);
@ -429,7 +430,7 @@ namespace MWGui
int captionHeight = std::max(caption != "" ? captionSize.height : 0, imageSize); int captionHeight = std::max(caption != "" ? captionSize.height : 0, imageSize);
MyGUI::EditBox* textWidget = mDynamicToolTipBox->createWidget<MyGUI::EditBox>("SandText", MyGUI::IntCoord(0, captionHeight+imageCaptionVPadding, 300, 300-captionHeight-imageCaptionVPadding), MyGUI::Align::Stretch, "ToolTipText"); Gui::EditBox* textWidget = mDynamicToolTipBox->createWidget<Gui::EditBox>("SandText", MyGUI::IntCoord(0, captionHeight+imageCaptionVPadding, 300, 300-captionHeight-imageCaptionVPadding), MyGUI::Align::Stretch, "ToolTipText");
textWidget->setEditStatic(true); textWidget->setEditStatic(true);
textWidget->setEditMultiLine(true); textWidget->setEditMultiLine(true);
textWidget->setEditWordWrap(info.wordWrap); textWidget->setEditWordWrap(info.wordWrap);
@ -447,7 +448,7 @@ namespace MWGui
MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("MarkerButton", MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("MarkerButton",
MyGUI::IntCoord(padding.left, totalSize.height+padding.top, 8, 8), MyGUI::Align::Default); MyGUI::IntCoord(padding.left, totalSize.height+padding.top, 8, 8), MyGUI::Align::Default);
icon->setColour(MyGUI::Colour(1.0f, 0.3f, 0.3f)); icon->setColour(MyGUI::Colour(1.0f, 0.3f, 0.3f));
MyGUI::EditBox* edit = mDynamicToolTipBox->createWidget<MyGUI::EditBox>("SandText", Gui::EditBox* edit = mDynamicToolTipBox->createWidget<Gui::EditBox>("SandText",
MyGUI::IntCoord(padding.left+8+4, totalSize.height+padding.top, 300-padding.left-8-4, 300-totalSize.height), MyGUI::IntCoord(padding.left+8+4, totalSize.height+padding.top, 300-padding.left-8-4, 300-totalSize.height),
MyGUI::Align::Default); MyGUI::Align::Default);
edit->setEditMultiLine(true); edit->setEditMultiLine(true);

@ -22,8 +22,6 @@
namespace MWGui namespace MWGui
{ {
const int TravelWindow::sLineHeight = 18;
TravelWindow::TravelWindow() : TravelWindow::TravelWindow() :
WindowBase("openmw_travel_window.layout") WindowBase("openmw_travel_window.layout")
, mCurrentY(0) , mCurrentY(0)
@ -79,9 +77,11 @@ namespace MWGui
else else
price *= std::max(1, static_cast<int>(followers.size())); price *= std::max(1, static_cast<int>(followers.size()));
MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>("SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); int lineHeight = MWBase::Environment::get().getWindowManager()->getFontHeight() + 2;
MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>("SandTextButton", 0, mCurrentY, 200, lineHeight, MyGUI::Align::Default);
toAdd->setEnabled(price <= playerGold); toAdd->setEnabled(price <= playerGold);
mCurrentY += sLineHeight; mCurrentY += lineHeight;
if(interior) if(interior)
toAdd->setUserString("interior","y"); toAdd->setUserString("interior","y");
else else
@ -92,7 +92,7 @@ namespace MWGui
toAdd->setUserString("price",oss.str()); toAdd->setUserString("price",oss.str());
toAdd->setCaptionWithReplacing("#{sCell=" + name + "} - " + MyGUI::utility::toString(price)+"#{sgp}"); toAdd->setCaptionWithReplacing("#{sCell=" + name + "} - " + MyGUI::utility::toString(price)+"#{sgp}");
toAdd->setSize(mDestinationsView->getWidth(),sLineHeight); toAdd->setSize(mDestinationsView->getWidth(),lineHeight);
toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel);
toAdd->setUserString("Destination", name); toAdd->setUserString("Destination", name);
toAdd->setUserData(pos); toAdd->setUserData(pos);

@ -41,8 +41,6 @@ namespace MWGui
void clearDestinations(); void clearDestinations();
int mCurrentY; int mCurrentY;
static const int sLineHeight;
void updateLabels(); void updateLabels();
virtual void onReferenceUnavailable(); virtual void onReferenceUnavailable();

@ -44,7 +44,6 @@
#include <components/vfs/manager.hpp> #include <components/vfs/manager.hpp>
#include <components/widgets/widgets.hpp>
#include <components/widgets/tags.hpp> #include <components/widgets/tags.hpp>
#include <components/sdlutil/sdlcursormanager.hpp> #include <components/sdlutil/sdlcursormanager.hpp>
@ -196,6 +195,7 @@ namespace MWGui
, mFallbackMap(fallbackMap) , mFallbackMap(fallbackMap)
, mShowOwned(0) , mShowOwned(0)
, mEncoding(encoding) , mEncoding(encoding)
, mFontHeight(16)
, mVersionDescription(versionDescription) , mVersionDescription(versionDescription)
{ {
float uiScale = Settings::Manager::getFloat("scaling factor", "GUI"); float uiScale = Settings::Manager::getFloat("scaling factor", "GUI");
@ -233,6 +233,13 @@ namespace MWGui
SpellView::registerComponents(); SpellView::registerComponents();
Gui::registerAllWidgets(); 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::ControllerRepeatEvent>("Controller");
MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Controllers::ControllerFollowMouse>("Controller"); MyGUI::FactoryManager::getInstance().registerFactory<MWGui::Controllers::ControllerFollowMouse>("Controller");
@ -284,6 +291,51 @@ namespace MWGui
mShowOwned = Settings::Manager::getInt("show owned", "Game"); mShowOwned = Settings::Manager::getInt("show owned", "Game");
} }
void WindowManager::loadFontDelegate(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version)
{
MyGUI::xml::ElementEnumerator root = _node->getElementEnumerator();
while (root.next("Resource"))
{
std::string type, name;
root->findAttribute("type", type);
root->findAttribute("name", name);
if (name.empty())
continue;
if (Misc::StringUtils::ciEqual(type, "ResourceTrueTypeFont"))
{
// For TrueType fonts we should override Size and Resolution properties
// to allow to configure font size via config file, without need to edit XML file.
// Also we should take UI scaling factor in account
int resolution = Settings::Manager::getInt("ttf resolution", "GUI");
resolution = std::max(0, resolution);
float uiScale = Settings::Manager::getFloat("scaling factor", "GUI");
if (uiScale > 1.0f)
resolution *= uiScale;
MyGUI::xml::ElementPtr resolutionNode = root->createChild("Property");
resolutionNode->addAttribute("key", "Resolution");
resolutionNode->addAttribute("value", std::to_string(resolution));
MyGUI::xml::ElementPtr sizeNode = root->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 = root->createChild("Property");
heightNode->addAttribute("key", "HeightLine");
heightNode->addAttribute("value", std::to_string(mFontHeight+2));
}
}
MyGUI::ResourceManager::getInstance().loadFromXmlNode(_node, _file, _version);
}
void WindowManager::initUI() void WindowManager::initUI()
{ {
// Get size info from the Gui object // Get size info from the Gui object
@ -504,6 +556,11 @@ namespace MWGui
updateVisible(); updateVisible();
} }
int WindowManager::getFontHeight() const
{
return mFontHeight;
}
void WindowManager::setNewGame(bool newgame) void WindowManager::setNewGame(bool newgame)
{ {
if (newgame) if (newgame)
@ -522,6 +579,7 @@ namespace MWGui
{ {
mKeyboardNavigation.reset(); mKeyboardNavigation.reset();
MyGUI::ResourceManager::getInstance().unregisterLoadXmlDelegate("Resource");
MyGUI::LanguageManager::getInstance().eventRequestTag.clear(); MyGUI::LanguageManager::getInstance().eventRequestTag.clear();
MyGUI::PointerManager::getInstance().eventChangeMousePointer.clear(); MyGUI::PointerManager::getInstance().eventChangeMousePointer.clear();
MyGUI::InputManager::getInstance().eventChangeKeyFocus.clear(); MyGUI::InputManager::getInstance().eventChangeKeyFocus.clear();

@ -246,6 +246,7 @@ namespace MWGui
virtual const MWWorld::Ptr& getSelectedEnchantItem() const; virtual const MWWorld::Ptr& getSelectedEnchantItem() const;
virtual void setSelectedWeapon(const MWWorld::Ptr& item); virtual void setSelectedWeapon(const MWWorld::Ptr& item);
virtual const MWWorld::Ptr& getSelectedWeapon() const; virtual const MWWorld::Ptr& getSelectedWeapon() const;
virtual int getFontHeight() const;
virtual void unsetSelectedSpell(); virtual void unsetSelectedSpell();
virtual void unsetSelectedWeapon(); virtual void unsetSelectedWeapon();
@ -401,6 +402,8 @@ namespace MWGui
MWWorld::Ptr mSelectedEnchantItem; MWWorld::Ptr mSelectedEnchantItem;
MWWorld::Ptr mSelectedWeapon; MWWorld::Ptr mSelectedWeapon;
void loadFontDelegate(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version);
std::vector<WindowModal*> mCurrentModals; std::vector<WindowModal*> mCurrentModals;
// Markers placed manually by the player. Must be shared between both map views (the HUD map and the map window). // Markers placed manually by the player. Must be shared between both map views (the HUD map and the map window).
@ -513,6 +516,8 @@ namespace MWGui
ToUTF8::FromType mEncoding; ToUTF8::FromType mEncoding;
int mFontHeight;
std::string mVersionDescription; std::string mVersionDescription;
MWGui::TextColours mTextColours; MWGui::TextColours mTextColours;

@ -76,6 +76,11 @@ LocalMap::LocalMap(osg::Group* root)
, mAngle(0.f) , mAngle(0.f)
, mInterior(false) , mInterior(false)
{ {
// Increase map resolution, if use UI scaling
float uiScale = Settings::Manager::getFloat("scaling factor", "GUI");
if (uiScale > 1.0)
mMapResolution *= uiScale;
SceneUtil::FindByNameVisitor find("Scene Root"); SceneUtil::FindByNameVisitor find("Scene Root");
mRoot->accept(find); mRoot->accept(find);
mSceneRoot = find.mFoundNode; mSceneRoot = find.mFoundNode;

@ -130,7 +130,7 @@ add_component_dir (myguiplatform
) )
add_component_dir (widgets add_component_dir (widgets
box imagebutton tags list numericeditbox sharedstatebutton windowcaption widgets box fontwrapper imagebutton tags list numericeditbox sharedstatebutton windowcaption widgets
) )
add_component_dir (fontloader add_component_dir (fontloader

@ -48,7 +48,7 @@ namespace Gui
} }
else else
{ {
TextBox::setPropertyOverride (_key, _value); Gui::TextBox::setPropertyOverride (_key, _value);
} }
} }
@ -81,11 +81,10 @@ namespace Gui
} }
else else
{ {
EditBox::setPropertyOverride (_key, _value); Gui::EditBox::setPropertyOverride (_key, _value);
} }
} }
MyGUI::IntSize AutoSizedButton::getRequestedSize() MyGUI::IntSize AutoSizedButton::getRequestedSize()
{ {
MyGUI::IntSize padding(24, 8); MyGUI::IntSize padding(24, 8);
@ -111,16 +110,14 @@ namespace Gui
} }
else else
{ {
Button::setPropertyOverride (_key, _value); Gui::Button::setPropertyOverride (_key, _value);
} }
} }
Box::Box() Box::Box()
: mSpacing(4) : mSpacing(4)
, mPadding(0) , mPadding(0)
, mAutoResize(false) , mAutoResize(false)
{ {
} }
void Box::notifyChildrenSizeChanged () void Box::notifyChildrenSizeChanged ()

@ -4,10 +4,27 @@
#include <MyGUI_Widget.h> #include <MyGUI_Widget.h>
#include <MyGUI_TextBox.h> #include <MyGUI_TextBox.h>
#include <MyGUI_EditBox.h> #include <MyGUI_EditBox.h>
#include <MyGUI_ListBox.h>
#include <MyGUI_Button.h> #include <MyGUI_Button.h>
#include "fontwrapper.hpp"
namespace Gui namespace Gui
{ {
class Button : public FontWrapper<MyGUI::Button>
{
MYGUI_RTTI_DERIVED( Button )
};
class TextBox : public FontWrapper<MyGUI::TextBox>
{
MYGUI_RTTI_DERIVED( TextBox )
};
class EditBox : public FontWrapper<MyGUI::EditBox>
{
MYGUI_RTTI_DERIVED( EditBox )
};
class AutoSizedWidget class AutoSizedWidget
{ {
@ -22,7 +39,7 @@ namespace Gui
MyGUI::Align mExpandDirection; MyGUI::Align mExpandDirection;
}; };
class AutoSizedTextBox : public AutoSizedWidget, public MyGUI::TextBox class AutoSizedTextBox : public AutoSizedWidget, public TextBox
{ {
MYGUI_RTTI_DERIVED( AutoSizedTextBox ) MYGUI_RTTI_DERIVED( AutoSizedTextBox )
@ -32,9 +49,10 @@ namespace Gui
protected: protected:
virtual void setPropertyOverride(const std::string& _key, const std::string& _value); virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
std::string mFontSize;
}; };
class AutoSizedEditBox : public AutoSizedWidget, public MyGUI::EditBox class AutoSizedEditBox : public AutoSizedWidget, public EditBox
{ {
MYGUI_RTTI_DERIVED( AutoSizedEditBox ) MYGUI_RTTI_DERIVED( AutoSizedEditBox )
@ -47,9 +65,10 @@ namespace Gui
protected: protected:
virtual void setPropertyOverride(const std::string& _key, const std::string& _value); virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
std::string mFontSize;
}; };
class AutoSizedButton : public AutoSizedWidget, public MyGUI::Button class AutoSizedButton : public AutoSizedWidget, public Button
{ {
MYGUI_RTTI_DERIVED( AutoSizedButton ) MYGUI_RTTI_DERIVED( AutoSizedButton )
@ -59,6 +78,7 @@ namespace Gui
protected: protected:
virtual void setPropertyOverride(const std::string& _key, const std::string& _value); virtual void setPropertyOverride(const std::string& _key, const std::string& _value);
std::string mFontSize;
}; };
/** /**

@ -0,0 +1,45 @@
#ifndef OPENMW_WIDGETS_WRAPPER_H
#define OPENMW_WIDGETS_WRAPPER_H
#include "widgets.hpp"
#include <components/settings/settings.hpp>
namespace Gui
{
template<class T>
class FontWrapper : public T
{
public:
virtual void setFontName(const std::string& name)
{
T::setFontName(name);
T::setPropertyOverride ("FontHeight", mFontSize);
}
protected:
FontWrapper()
{
// Note: we can not use the WindowManager here, so there is a code duplication a bit.
int fontSize = Settings::Manager::getInt("font size", "GUI");
fontSize = std::min(std::max(12, fontSize), 20);
mFontSize = std::to_string(fontSize);
}
virtual void setPropertyOverride(const std::string& _key, const std::string& _value)
{
T::setPropertyOverride (_key, _value);
// There is a bug in MyGUI: when it initializes the FontName property, it reset the font height.
// We should restore it.
if (_key == "FontName")
{
T::setPropertyOverride ("FontHeight", mFontSize);
}
}
std::string mFontSize;
};
}
#endif

@ -3,13 +3,15 @@
#include <MyGUI_EditBox.h> #include <MyGUI_EditBox.h>
#include "fontwrapper.hpp"
namespace Gui namespace Gui
{ {
/** /**
* @brief A variant of the EditBox that only allows integer inputs * @brief A variant of the EditBox that only allows integer inputs
*/ */
class NumericEditBox : public MyGUI::EditBox class NumericEditBox : public FontWrapper<MyGUI::EditBox>
{ {
MYGUI_RTTI_DERIVED(NumericEditBox) MYGUI_RTTI_DERIVED(NumericEditBox)
@ -17,7 +19,8 @@ namespace Gui
NumericEditBox() NumericEditBox()
: mValue(0), mMinValue(std::numeric_limits<int>::min()), : mValue(0), mMinValue(std::numeric_limits<int>::min()),
mMaxValue(std::numeric_limits<int>::max()) mMaxValue(std::numeric_limits<int>::max())
{} {
}
void initialiseOverride(); void initialiseOverride();
void shutdownOverride(); void shutdownOverride();

@ -7,7 +7,6 @@ namespace Gui
: mIsMousePressed(false) : mIsMousePressed(false)
, mIsMouseFocus(false) , mIsMouseFocus(false)
{ {
} }
void SharedStateButton::shutdownOverride() void SharedStateButton::shutdownOverride()

@ -3,6 +3,8 @@
#include <MyGUI_Button.h> #include <MyGUI_Button.h>
#include "fontwrapper.hpp"
namespace Gui namespace Gui
{ {
@ -11,7 +13,7 @@ namespace Gui
typedef std::vector<SharedStateButton*> ButtonGroup; typedef std::vector<SharedStateButton*> ButtonGroup;
/// @brief A button that applies its own state changes to other widgets, to do this you define it as part of a ButtonGroup. /// @brief A button that applies its own state changes to other widgets, to do this you define it as part of a ButtonGroup.
class SharedStateButton : public MyGUI::Button class SharedStateButton : public FontWrapper<MyGUI::Button>
{ {
MYGUI_RTTI_DERIVED(SharedStateButton) MYGUI_RTTI_DERIVED(SharedStateButton)

@ -18,9 +18,12 @@ namespace Gui
MyGUI::FactoryManager::getInstance().registerFactory<Gui::HBox>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<Gui::HBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::Spacer>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<Gui::Spacer>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::VBox>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<Gui::VBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::EditBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::TextBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedTextBox>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedTextBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedEditBox>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedEditBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedButton>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::Button>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::ImageButton>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<Gui::ImageButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::NumericEditBox>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<Gui::NumericEditBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::SharedStateButton>("Widget"); MyGUI::FactoryManager::getInstance().registerFactory<Gui::SharedStateButton>("Widget");

@ -1,9 +1,10 @@
#ifndef OPENMW_COMPONENTS_WIDGETS_H #ifndef OPENMW_COMPONENTS_WIDGETS_H
#define OPENMW_COMPONENTS_WIDGETS_H #define OPENMW_COMPONENTS_WIDGETS_H
extern int GuiFontHeight;
namespace Gui namespace Gui
{ {
/// Register all widgets from this component with MyGUI's factory manager. /// Register all widgets from this component with MyGUI's factory manager.
void registerAllWidgets(); void registerAllWidgets();

@ -12,6 +12,27 @@ This setting scales the GUI interface windows.
A value of 1.0 results in the normal scale. Larger values are useful to increase the scale of the GUI for high resolution displays. A value of 1.0 results in the normal scale. Larger values are useful to increase the scale of the GUI for high resolution displays.
This setting can only be configured by editing the settings configuration file. This setting can only be configured by editing the settings configuration file.
font size
---------
:Type: integer
:Range: 12 to 20
:Default: 16
Allows to specify glyph size for in-game fonts.
Note: default bitmap fonts are supposed to work with 16px size, otherwise glyphs will be blurry.
TrueType fonts do not have this issue.
ttf resolution
--------------
:Type: integer
:Range: > 0
:Default: 96
Allows to specify resolution for in-game TrueType fonts.
Note: actual resolution depends on "scaling factor" setting value, this value is for 1.0 or lower scaling factor.
menu transparency menu transparency
----------------- -----------------

@ -2,7 +2,6 @@
<MyGUI type="Resource" version="1.1"> <MyGUI type="Resource" version="1.1">
<Resource type="ResourceSkin" name="TextBox" size="16 16"> <Resource type="ResourceSkin" name="TextBox" size="16 16">
<Property key="FontHeight" value = "16" />
<Property key="TextAlign" value = "ALIGN_DEFAULT" /> <Property key="TextAlign" value = "ALIGN_DEFAULT" />
<Property key="TextColour" value = "0.7 0.7 0.7" /> <Property key="TextColour" value = "0.7 0.7 0.7" />

@ -13,7 +13,7 @@
<Property key="NeedKey" value="false"/> <Property key="NeedKey" value="false"/>
</Widget> </Widget>
<Widget type="VBox" position="0 89 352 24" align="Center Bottom"> <Widget type="VBox" position="0 89 352 28" align="Center Bottom">
<Widget type="HBox"> <Widget type="HBox">
<Property key="Spacing" value="8"/> <Property key="Spacing" value="8"/>

@ -50,7 +50,7 @@
</Widget> </Widget>
<!-- Values --> <!-- Values -->
<Widget type="VBox" position="320 7 222 80"> <Widget type="VBox" position="320 7 222 96">
<Widget type="HBox"> <Widget type="HBox">
<UserString key="HStretch" value="true"/> <UserString key="HStretch" value="true"/>
<Widget type="AutoSizedTextBox" skin="NormalText"> <Widget type="AutoSizedTextBox" skin="NormalText">

@ -2,8 +2,6 @@
<MyGUI type="Resource" version="1.1"> <MyGUI type="Resource" version="1.1">
<Resource type="ResourceTrueTypeFont" name="MonoFont"> <Resource type="ResourceTrueTypeFont" name="MonoFont">
<Property key="Source" value="DejaVuLGCSansMono.ttf"/> <Property key="Source" value="DejaVuLGCSansMono.ttf"/>
<Property key="Size" value="17"/>
<Property key="Resolution" value="50"/>
<Property key="Antialias" value="false"/> <Property key="Antialias" value="false"/>
<Property key="TabWidth" value="8"/> <Property key="TabWidth" value="8"/>
<Property key="OffsetHeight" value="0"/> <Property key="OffsetHeight" value="0"/>

@ -29,7 +29,7 @@
</Widget> </Widget>
<!-- Categories --> <!-- Categories -->
<Widget type="HBox" position="0 8 350 24" align="Left Top HStretch" name="Categories"> <Widget type="HBox" position="0 6 350 28" align="Left Top HStretch" name="Categories">
<Widget type="AutoSizedButton" skin="MW_Button" position="0 0 60 24" name="AllButton"> <Widget type="AutoSizedButton" skin="MW_Button" position="0 0 60 24" name="AllButton">
<Property key="Caption" value="#{sAllTab}"/> <Property key="Caption" value="#{sAllTab}"/>
<Property key="NeedKey" value="false"/> <Property key="NeedKey" value="false"/>

@ -59,8 +59,9 @@
<Property key="ImageTexture" value="textures\tx_menubook_bookmark.dds"/> <Property key="ImageTexture" value="textures\tx_menubook_bookmark.dds"/>
<Property key="ImageCoord" value="0 0 164 256"/> <Property key="ImageCoord" value="0 0 164 256"/>
<Widget type="BookPage" skin="MW_BookPage" position="20 15 92 250" name="LeftTopicIndex"/> <Widget type="BookPage" skin="MW_BookPage" position="10 10 92 260" name="LeftTopicIndex"/>
<Widget type="BookPage" skin="MW_BookPage" position="112 15 92 250" name="RightTopicIndex"/> <Widget type="BookPage" skin="MW_BookPage" position="66 10 92 260" name="CenterTopicIndex"/>
<Widget type="BookPage" skin="MW_BookPage" position="122 10 92 260" name="RightTopicIndex"/>
<Widget type="ImageButton" skin="ImageBox" position="71 15 100 20" Align="Top|Left" name="ShowActiveBTN"> <Widget type="ImageButton" skin="ImageBox" position="71 15 100 20" Align="Top|Left" name="ShowActiveBTN">
<!-- Image set at runtime since it may not be available in all versions of the game --> <!-- Image set at runtime since it may not be available in all versions of the game -->

@ -13,11 +13,9 @@
</Resource> </Resource>
<Resource type="ResourceSkin" name="MW_QuestList" size="516 516" align="Left Top"> <Resource type="ResourceSkin" name="MW_QuestList" size="516 516" align="Left Top">
<Property key="ListItemSkin" value="MW_QuestLink"/>
<Property key="ListItemSkin" value="MW_QuestLink"/> <Child type="Widget" skin="" offset="3 3 510 510" align="Top Left Stretch" name="Client"/>
<Child type="Widget" skin="" offset="3 3 510 510" align="Top Left Stretch" name="Client"/>
</Resource> </Resource>
<Resource type="ResourceSkin" name="MW_QuestLink" size="5 5"> <Resource type="ResourceSkin" name="MW_QuestLink" size="5 5">

@ -127,7 +127,6 @@
<Resource type="ResourceSkin" name="MW_List" size="516 516" align="Left Top"> <Resource type="ResourceSkin" name="MW_List" size="516 516" align="Left Top">
<Property key="NeedKey" value="true"/> <Property key="NeedKey" value="true"/>
<Property key="SkinLine" value="MW_ListLine"/> <Property key="SkinLine" value="MW_ListLine"/>
<Property key="HeightLine" value="18"/>
<Child type="Widget" skin="MW_Box" offset="0 0 516 516" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 516 516" align="Stretch"/>
@ -140,8 +139,6 @@
<Resource type="ResourceSkin" name="MW_PopupList" size="516 516" align="Left Top"> <Resource type="ResourceSkin" name="MW_PopupList" size="516 516" align="Left Top">
<Property key="NeedKey" value="true"/> <Property key="NeedKey" value="true"/>
<Property key="SkinLine" value="MW_ListLine"/> <Property key="SkinLine" value="MW_ListLine"/>
<Property key="HeightLine" value="18"/>
<Child type="Widget" skin="BlackBG" offset="0 0 516 516" align="Stretch"/> <Child type="Widget" skin="BlackBG" offset="0 0 516 516" align="Stretch"/>
<Child type="Widget" skin="MW_Box" offset="0 0 516 516" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 516 516" align="Stretch"/>
@ -153,7 +150,6 @@
<Resource type="ResourceSkin" name="MW_PopupListNoTransp" size="516 516" align="Left Top"> <Resource type="ResourceSkin" name="MW_PopupListNoTransp" size="516 516" align="Left Top">
<Property key="NeedKey" value="true"/> <Property key="NeedKey" value="true"/>
<Property key="SkinLine" value="MW_ListLine"/> <Property key="SkinLine" value="MW_ListLine"/>
<Property key="HeightLine" value="18"/>
<Child type="Widget" skin="FullBlackBG" offset="0 0 516 516" align="Stretch"/> <Child type="Widget" skin="FullBlackBG" offset="0 0 516 516" align="Stretch"/>
<Child type="Widget" skin="MW_Box" offset="0 0 516 516" align="Stretch"/> <Child type="Widget" skin="MW_Box" offset="0 0 516 516" align="Stretch"/>

@ -443,7 +443,6 @@
<!-- The actual caption. It contains the edges of the blocks on <!-- The actual caption. It contains the edges of the blocks on
its sides as well --> its sides as well -->
<Resource type="ResourceSkin" name="MW_Caption" size="88 20"> <Resource type="ResourceSkin" name="MW_Caption" size="88 20">
<Property key="FontName" value="Default"/>
<Property key="TextAlign" value="Center"/> <Property key="TextAlign" value="Center"/>
<Child type="Widget" skin="HB_ALL" offset="0 0 30 20" align="Default" name="Left"/> <Child type="Widget" skin="HB_ALL" offset="0 0 30 20" align="Default" name="Left"/>
@ -458,7 +457,6 @@
------------------------------------------------------ --> ------------------------------------------------------ -->
<Resource type="ResourceSkin" name="MW_Window" size="256 256"> <Resource type="ResourceSkin" name="MW_Window" size="256 256">
<Property key="FontName" value="Default"/>
<Property key="TextAlign" value="Center"/> <Property key="TextAlign" value="Center"/>
<Property key="Snap" value="true"/> <Property key="Snap" value="true"/>
<Property key="MinSize" value="64 64"/> <Property key="MinSize" value="64 64"/>
@ -593,7 +591,6 @@
</Resource> </Resource>
<Resource type="ResourceSkin" name="MW_Window_NoCaption" size="256 256"> <Resource type="ResourceSkin" name="MW_Window_NoCaption" size="256 256">
<Property key="FontName" value="Default"/>
<Property key="TextAlign" value="Center"/> <Property key="TextAlign" value="Center"/>
<Property key="Snap" value="true"/> <Property key="Snap" value="true"/>
<Property key="MinSize" value="64 64"/> <Property key="MinSize" value="64 64"/>
@ -730,7 +727,6 @@
</Resource> </Resource>
<Resource type="ResourceSkin" name="MW_Window_Pinnable" size="256 256"> <Resource type="ResourceSkin" name="MW_Window_Pinnable" size="256 256">
<Property key="FontName" value="Default"/>
<Property key="TextAlign" value="Center"/> <Property key="TextAlign" value="Center"/>
<Property key="Snap" value="true"/> <Property key="Snap" value="true"/>
<Property key="MinSize" value="64 64"/> <Property key="MinSize" value="64 64"/>

@ -142,6 +142,12 @@ global = false
# Scales GUI window and widget size. (<1.0 is smaller, >1.0 is larger). # Scales GUI window and widget size. (<1.0 is smaller, >1.0 is larger).
scaling factor = 1.0 scaling factor = 1.0
# Size of in-game fonts
font size = 16
# Resolution of TrueType fonts glyphs
ttf resolution = 96
# Transparency of GUI windows (0.0 to 1.0, transparent to opaque). # Transparency of GUI windows (0.0 to 1.0, transparent to opaque).
menu transparency = 0.84 menu transparency = 0.84

Loading…
Cancel
Save