diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-06-25 22:35:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-06-25 22:35:30 +0300 |
commit | dcfc97836830d4100a0a520b77d68d908314ee60 (patch) | |
tree | c35eccea345638b1abe2a3875065a36065bf8691 /src | |
parent | f939a7bbbc19bb69726377eed7b36542d6a5cf3f (diff) | |
download | manaverse-dcfc97836830d4100a0a520b77d68d908314ee60.tar.gz manaverse-dcfc97836830d4100a0a520b77d68d908314ee60.tar.bz2 manaverse-dcfc97836830d4100a0a520b77d68d908314ee60.tar.xz manaverse-dcfc97836830d4100a0a520b77d68d908314ee60.zip |
Add npc font size with 13 pixels size.
Diffstat (limited to 'src')
-rw-r--r-- | src/defaults.cpp | 1 | ||||
-rw-r--r-- | src/gui/gui.cpp | 24 | ||||
-rw-r--r-- | src/gui/gui.h | 21 | ||||
-rw-r--r-- | src/gui/npcdialog.cpp | 4 | ||||
-rw-r--r-- | src/gui/setup_theme.cpp | 47 | ||||
-rw-r--r-- | src/gui/setup_theme.h | 7 |
6 files changed, 77 insertions, 27 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index 3aeca07a6..13ed6f7c1 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -261,6 +261,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "hideErased", false); AddDEF(configData, "enableDelayedAnimations", true); AddDEF(configData, "enableCompoundSpriteDelay", true); + AddDEF(configData, "npcfontSize", 13); return configData; } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index afced01b2..8dcaaafa1 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -201,6 +201,22 @@ Gui::Gui(Graphics *graphics): std::string("': ") + e.getMessage()); } + // Set npc font + fontFile = config.getValue("npcFont", ""); + const int npcFontSize = config.getIntValue("npcfontSize"); + if (fontFile.empty()) + fontFile = branding.getStringValue("npcFont"); + + try + { + mNpcFont = new SDLFont(fontFile, npcFontSize); + } + catch (const gcn::Exception &e) + { + logger->error(std::string("Unable to load '") + fontFile + + std::string("': ") + e.getMessage()); + } + gcn::Widget::setGlobalFont(mGuiFont); // Initialize mouse cursor and listen for changes to the option @@ -463,11 +479,13 @@ void Gui::updateFonts() boldFont->loadFont(fontFile, fontSize); - fontFile = config.getValue("secureFont", ""); + const int npcFontSize = config.getIntValue("npcfontSize"); + + fontFile = config.getValue("npcFont", ""); if (fontFile.empty()) - fontFile = branding.getStringValue("secureFont"); + fontFile = branding.getStringValue("npcFont"); - mSecureFont->loadFont(fontFile, fontSize); + mNpcFont->loadFont(fontFile, npcFontSize); } void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, diff --git a/src/gui/gui.h b/src/gui/gui.h index 9468d2b68..6df01a5a9 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -98,6 +98,12 @@ class Gui : public gcn::Gui { return mSecureFont; } /** + * Return npc font. + */ + SDLFont *getNpcFont() const + { return mNpcFont; } + + /** * Return the Font used for "Info Particles", i.e. ones showing, what * you picked up, etc. */ @@ -151,18 +157,19 @@ class Gui : public gcn::Gui private: GuiConfigListener *mConfigListener; SDLFont *mGuiFont; /**< The global GUI font */ - SDLFont *mInfoParticleFont; /**< Font for Info Particles*/ - SDLFont *mHelpFont; /**< Font for Help Window*/ - SDLFont *mSecureFont; /**< Font for secure labels*/ - bool mCustomCursor; /**< Show custom cursor */ - ImageSet *mMouseCursors; /**< Mouse cursor images */ + SDLFont *mInfoParticleFont; /**< Font for Info Particles */ + SDLFont *mHelpFont; /**< Font for Help Window */ + SDLFont *mSecureFont; /**< Font for secure labels */ + SDLFont *mNpcFont; /**< Font for npc text */ + bool mCustomCursor; /**< Show custom cursor */ + ImageSet *mMouseCursors; /**< Mouse cursor images */ float mMouseCursorAlpha; int mMouseInactivityTimer; int mCursorType; }; -extern Gui *gui; /**< The GUI system */ -extern SDLInput *guiInput; /**< GUI input */ +extern Gui *gui; /**< The GUI system */ +extern SDLInput *guiInput; /**< GUI input */ /** * Bolded text font diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index ec33f3f0d..39f4d75b3 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -25,6 +25,8 @@ #include "configuration.h" #include "client.h" +#include "gui/gui.h" +#include "gui/sdlfont.h" #include "gui/setup.h" #include "gui/viewport.h" @@ -86,6 +88,7 @@ NpcDialog::NpcDialog(int npcId) : mTextBox->setOpaque(false); mTextBox->setMaxRow(config.getIntValue("ChatLogLength")); mTextBox->setLinkHandler(mItemLinkHandler); + mTextBox->setFont(gui->getNpcFont()); mScrollArea = new ScrollArea(mTextBox); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); @@ -97,6 +100,7 @@ NpcDialog::NpcDialog(int npcId) : mItemList->setActionEventId("ok"); mItemList->addActionListener(this); mItemList->setDistributeMousePressed(false); + mItemList->setFont(gui->getNpcFont()); setContentSize(260, 175); diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp index 7386f496a..798dcd6f2 100644 --- a/src/gui/setup_theme.cpp +++ b/src/gui/setup_theme.cpp @@ -160,7 +160,8 @@ Setup_Theme::Setup_Theme(): mHelpFont(config.getStringValue("helpFont")), mSecureFont(config.getStringValue("secureFont")), mJapanFont(config.getStringValue("japanFont")), - mFontSize(config.getIntValue("fontSize")) + mFontSize(config.getIntValue("fontSize")), + mNpcFontSize(config.getIntValue("npcfontSize")) { setName(_("Theme")); @@ -208,12 +209,18 @@ Setup_Theme::Setup_Theme(): mJapanFontDropDown->setActionEventId(ACTION_JAPAN_FONT); mJapanFontDropDown->addActionListener(this); - fontSizeLabel = new Label(_("Font size")); + mFontSizeLabel = new Label(_("Font size")); mFontSizeListModel = new FontSizeChoiceListModel; mFontSizeDropDown = new DropDown(mFontSizeListModel); mFontSizeDropDown->setSelected(mFontSize - 10); mFontSizeDropDown->adjustHeight(); + mNpcFontSizeLabel = new Label(_("Npc font size")); + mNpcFontSizeListModel = new FontSizeChoiceListModel; + mNpcFontSizeDropDown = new DropDown(mNpcFontSizeListModel); + mNpcFontSizeDropDown->setSelected(mNpcFontSize - 10); + mNpcFontSizeDropDown->adjustHeight(); + std::string skin = Theme::getThemeName(); if (!skin.empty()) mThemeDropDown->setSelectedString(skin); @@ -250,23 +257,25 @@ Setup_Theme::Setup_Theme(): place(0, 0, mThemeLabel, 5); place(0, 1, mLangLabel, 5); - place(0, 2, fontSizeLabel, 5); - place(0, 3, mFontLabel, 5); - place(0, 4, mBoldFontLabel, 5); - place(0, 5, mParticleFontLabel, 5); - place(0, 6, mHelpFontLabel, 5); - place(0, 7, mSecureFontLabel, 5); - place(0, 8, mJapanFontLabel, 5); + place(0, 2, mFontSizeLabel, 5); + place(0, 3, mNpcFontSizeLabel, 5); + place(0, 4, mFontLabel, 5); + place(0, 5, mBoldFontLabel, 5); + place(0, 6, mParticleFontLabel, 5); + place(0, 7, mHelpFontLabel, 5); + place(0, 8, mSecureFontLabel, 5); + place(0, 9, mJapanFontLabel, 5); place(6, 0, mThemeDropDown, 10); place(6, 1, mLangDropDown, 10); place(6, 2, mFontSizeDropDown, 10); - place(6, 3, mFontDropDown, 10); - place(6, 4, mBoldFontDropDown, 10); - place(6, 5, mParticleFontDropDown, 10); - place(6, 6, mHelpFontDropDown, 10); - place(6, 7, mSecureFontDropDown, 10); - place(6, 8, mJapanFontDropDown, 10); + place(6, 3, mNpcFontSizeDropDown, 10); + place(6, 4, mFontDropDown, 10); + place(6, 5, mBoldFontDropDown, 10); + place(6, 6, mParticleFontDropDown, 10); + place(6, 7, mHelpFontDropDown, 10); + place(6, 8, mSecureFontDropDown, 10); + place(6, 9, mJapanFontDropDown, 10); place.getCell().matchColWidth(0, 0); place = h.getPlacer(0, 1); @@ -285,6 +294,9 @@ Setup_Theme::~Setup_Theme() delete mFontSizeListModel; mFontSizeListModel = nullptr; + delete mNpcFontSizeListModel; + mNpcFontSizeListModel = nullptr; + delete mLangListModel; mLangListModel = nullptr; } @@ -363,7 +375,9 @@ void Setup_Theme::apply() || config.getValue("secureFont", "dejavusansmono.ttf") != mSecureFont || config.getValue("japanFont", "mplus-1p-regular.ttf") != mJapanFont || config.getIntValue("fontSize") - != static_cast<int>(mFontSizeDropDown->getSelected()) + 10) + != static_cast<int>(mFontSizeDropDown->getSelected()) + 10 + || config.getIntValue("npcfontSize") + != static_cast<int>(mNpcFontSizeDropDown->getSelected()) + 10) { config.setValue("font", "fonts/" + getFileName(mFont)); config.setValue("boldFont", "fonts/" + getFileName(mBoldFont)); @@ -372,6 +386,7 @@ void Setup_Theme::apply() config.setValue("secureFont", "fonts/" + getFileName(mSecureFont)); config.setValue("japanFont", "fonts/" + getFileName(mJapanFont)); config.setValue("fontSize", mFontSizeDropDown->getSelected() + 10); + config.setValue("npcfontSize", mNpcFontSizeDropDown->getSelected() + 10); gui->updateFonts(); } } diff --git a/src/gui/setup_theme.h b/src/gui/setup_theme.h index a8f87fd43..f22fc2fd1 100644 --- a/src/gui/setup_theme.h +++ b/src/gui/setup_theme.h @@ -89,10 +89,15 @@ class Setup_Theme : public SetupTab std::string mJapanFont; FontSizeChoiceListModel *mFontSizeListModel; - gcn::Label *fontSizeLabel; + gcn::Label *mFontSizeLabel; int mFontSize; gcn::DropDown *mFontSizeDropDown; + FontSizeChoiceListModel *mNpcFontSizeListModel; + gcn::Label *mNpcFontSizeLabel; + int mNpcFontSize; + gcn::DropDown *mNpcFontSizeDropDown; + EditDialog *mEditDialog; }; |