diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-02-16 22:17:22 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-02-16 22:17:22 +0300 |
commit | 6e6c5b2ba399e0ed364ada843c4c759ee54de219 (patch) | |
tree | 562e6a840c856ba8c4d35c6806020289c65d54d2 /src/gui | |
parent | 82ac4641828ec7387863bb18cf4493190c4cc68f (diff) | |
download | manaplus-6e6c5b2ba399e0ed364ada843c4c759ee54de219.tar.gz manaplus-6e6c5b2ba399e0ed364ada843c4c759ee54de219.tar.bz2 manaplus-6e6c5b2ba399e0ed364ada843c4c759ee54de219.tar.xz manaplus-6e6c5b2ba399e0ed364ada843c4c759ee54de219.zip |
combine font classes in one.
Diffstat (limited to 'src/gui')
64 files changed, 133 insertions, 1145 deletions
diff --git a/src/gui/base/font.cpp b/src/gui/base/font.cpp deleted file mode 100644 index ccb2f7022..000000000 --- a/src/gui/base/font.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/font.hpp" - -#include <string> - -#include "debug.h" - -namespace gcn -{ - int Font::getStringIndexAt(const std::string& text, const int x) const - { - const size_t sz = text.size(); - for (size_t i = 0; i < sz; ++i) - { - if (getWidth(text.substr(0, i)) > x) - return i; - } - - return static_cast<int>(sz); - } -} // namespace gcn diff --git a/src/gui/base/font.hpp b/src/gui/base/font.hpp deleted file mode 100644 index 075af4136..000000000 --- a/src/gui/base/font.hpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_FONT_HPP -#define GCN_FONT_HPP - -#include <string> - -#include "localconsts.h" - -class Graphics; - -namespace gcn -{ - /** - * Interface for a font. - * - * @see ImageFont - */ - class Font - { - public: - /** - * Destructor. - */ - virtual ~Font() - { } - - /** - * Gets the width of a string. The width of a string is not necesserily - * the sum of all the widths of it's glyphs. - * - * @param text The string to return the width of. - * @return The width of a string. - */ - virtual int getWidth(const std::string& text) const A_WARN_UNUSED = 0; - - /** - * Gets the height of the glyphs in the font. - * - * @return The height of the glyphs int the font. - */ - virtual int getHeight() const A_WARN_UNUSED = 0; - - /** - * Gets a string index in a string providing an x coordinate. - * Used to retrive a string index (for a character in a - * string) at a certain x position. It is especially useful - * when a mouse clicks in a TextField and you want to know which - * character was clicked. - * - * @return A string index in a string providing an x coordinate. - */ - virtual int getStringIndexAt(const std::string& text, - const int x) const A_WARN_UNUSED; - - /** - * Draws a string. - * - * NOTE: You normally won't use this function to draw text since - * Graphics contains better functions for drawing text. - * - * @param graphics A Graphics object to use for drawing. - * @param text The string to draw. - * @param x The x coordinate where to draw the string. - * @param y The y coordinate where to draw the string. - */ - virtual void drawString(Graphics* graphics, const std::string& text, - int x, int y) = 0; - }; -} // namespace gcn - -#endif // end GCN_FONT_HPP diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index ce32b14f3..a459ab4f2 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -76,6 +76,7 @@ class ActionListener; class DeathListener; class FocusListener; +class Font; class Graphics; class KeyListener; class MouseListener; @@ -85,7 +86,6 @@ namespace gcn { class BasicContainer; class FocusHandler; - class Font; class KeyInput; class MouseInput; diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 1276b82b2..9b7473293 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/button.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index 5f2477b4d..0a3171fe8 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/checkbox.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp index c23666eac..cbee2ac4c 100644 --- a/src/gui/base/widgets/label.cpp +++ b/src/gui/base/widgets/label.cpp @@ -67,7 +67,7 @@ #include "gui/base/widgets/label.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 7f46b4b10..6c6472636 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -67,11 +67,13 @@ #include "gui/base/widgets/listbox.hpp" +#include "gui/font.h" + #include "gui/base/basiccontainer.hpp" -#include "gui/base/font.hpp" #include "gui/base/key.hpp" #include "gui/base/listmodel.hpp" #include "gui/base/mouseinput.hpp" + #include "listeners/selectionlistener.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index e42773de1..f0430c7a2 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/radiobutton.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index 06d0e6379..e994804d8 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -67,8 +67,9 @@ #include "gui/base/widgets/textbox.hpp" +#include "gui/font.h" + #include "gui/base/basiccontainer.hpp" -#include "gui/base/font.hpp" #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index df1b844d4..1514d3afb 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/textfield.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index 9207fe449..fbd42aff2 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/window.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/mouseinput.hpp" #include "render/graphics.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 08794d478..f549727a4 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -25,8 +25,8 @@ #include "gui/gui.h" #include "gui/focushandler.h" +#include "gui/font.h" #include "gui/palette.h" -#include "gui/sdlfont.h" #include "gui/sdlinput.h" #include "gui/theme.h" #include "gui/viewport.h" @@ -60,7 +60,7 @@ Gui *gui = nullptr; SDLInput *guiInput = nullptr; // Bolded font -SDLFont *boldFont = nullptr; +Font *boldFont = nullptr; class GuiConfigListener final : public ConfigListener { @@ -160,7 +160,7 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("font"); - mGuiFont = new SDLFont(fontFile, fontSize); + mGuiFont = new Font(fontFile, fontSize); // Set particle font fontFile = config.getValue("particleFont", ""); @@ -179,28 +179,28 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("particleFont"); - mInfoParticleFont = new SDLFont(fontFile, fontSize, TTF_STYLE_BOLD); + mInfoParticleFont = new Font(fontFile, fontSize, TTF_STYLE_BOLD); // Set bold font fontFile = config.getValue("boldFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("boldFont"); - boldFont = new SDLFont(fontFile, fontSize); + boldFont = new Font(fontFile, fontSize); // Set help font fontFile = config.getValue("helpFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("helpFont"); - mHelpFont = new SDLFont(fontFile, fontSize); + mHelpFont = new Font(fontFile, fontSize); // Set secure font fontFile = config.getValue("secureFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("secureFont"); - mSecureFont = new SDLFont(fontFile, fontSize); + mSecureFont = new Font(fontFile, fontSize); // Set npc font const int npcFontSize = config.getIntValue("npcfontSize"); @@ -220,7 +220,7 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("npcFont"); - mNpcFont = new SDLFont(fontFile, npcFontSize); + mNpcFont = new Font(fontFile, npcFontSize); gcn::Widget::setGlobalFont(mGuiFont); diff --git a/src/gui/gui.h b/src/gui/gui.h index 1ec73e42f..1660fcfbf 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -35,7 +35,7 @@ class GuiConfigListener; class ImageSet; class MouseEvent; class MouseInput; -class SDLFont; +class Font; class SDLInput; class Window; @@ -96,32 +96,32 @@ class Gui final : public gcn::Gui /** * Return game font. */ - SDLFont *getFont() const A_WARN_UNUSED + Font *getFont() const A_WARN_UNUSED { return mGuiFont; } /** * Return help font. */ - SDLFont *getHelpFont() const A_WARN_UNUSED + Font *getHelpFont() const A_WARN_UNUSED { return mHelpFont; } /** * Return secure font. */ - SDLFont *getSecureFont() const A_WARN_UNUSED + Font *getSecureFont() const A_WARN_UNUSED { return mSecureFont; } /** * Return npc font. */ - SDLFont *getNpcFont() const A_WARN_UNUSED + Font *getNpcFont() const A_WARN_UNUSED { return mNpcFont; } /** * Return the Font used for "Info Particles", i.e. ones showing, what * you picked up, etc. */ - SDLFont *getInfoParticleFont() const A_WARN_UNUSED + Font *getInfoParticleFont() const A_WARN_UNUSED { return mInfoParticleFont; } /** @@ -183,11 +183,11 @@ class Gui final : 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 */ - SDLFont *mNpcFont; /**< Font for npc text */ + Font *mGuiFont; /**< The global GUI font */ + Font *mInfoParticleFont; /**< Font for Info Particles */ + Font *mHelpFont; /**< Font for Help Window */ + Font *mSecureFont; /**< Font for secure labels */ + Font *mNpcFont; /**< Font for npc text */ ImageSet *mMouseCursors; /**< Mouse cursor images */ float mMouseCursorAlpha; int mMouseInactivityTimer; @@ -212,6 +212,6 @@ extern SDLInput *guiInput; /**< GUI input */ /** * Bolded text font */ -extern SDLFont *boldFont; +extern Font *boldFont; #endif // GUI_GUI_H diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index 623b19d00..32aa11454 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -24,15 +24,13 @@ #include "being/being.h" #include "being/playerrelations.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/label.h" #include "utils/gettext.h" #include "utils/stringutils.h" -#include "gui/base/font.hpp" - #include "debug.h" BeingPopup::BeingPopup() : diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index f7939b666..d6ea5a48a 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -27,7 +27,7 @@ #include "item.h" #include "units.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/icon.h" #include "gui/widgets/label.h" @@ -38,8 +38,6 @@ #include "resources/image.h" #include "resources/resourcemanager.h" -#include "gui/base/font.hpp" - #include "debug.h" extern int serverVersion; diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp index dd8f9ada9..c74f3f5e6 100644 --- a/src/gui/popups/speechbubble.cpp +++ b/src/gui/popups/speechbubble.cpp @@ -23,15 +23,13 @@ #include "gui/popups/speechbubble.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/label.h" #include "gui/widgets/textbox.h" -#include "gui/base/font.hpp" - #include "debug.h" SpeechBubble::SpeechBubble() : diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp index cc55fef57..141879da4 100644 --- a/src/gui/popups/spellpopup.cpp +++ b/src/gui/popups/spellpopup.cpp @@ -23,7 +23,7 @@ #include "gui/popups/spellpopup.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/label.h" diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp index 2332e20a9..7dd3c3634 100644 --- a/src/gui/popups/statuspopup.cpp +++ b/src/gui/popups/statuspopup.cpp @@ -33,7 +33,7 @@ #include "utils/stringutils.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/popups/textpopup.cpp b/src/gui/popups/textpopup.cpp index 245bf58b0..0ae53ac1f 100644 --- a/src/gui/popups/textpopup.cpp +++ b/src/gui/popups/textpopup.cpp @@ -25,7 +25,7 @@ #include "gui/widgets/label.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp deleted file mode 100644 index 95a3df390..000000000 --- a/src/gui/sdlfont.cpp +++ /dev/null @@ -1,603 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2009 Aethyra Development Team - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "gui/sdlfont.h" - -#include "logger.h" -#include "main.h" - -#include "render/sdlgraphics.h" - -#include "resources/image.h" -#include "resources/imagehelper.h" -#include "resources/resourcemanager.h" -#include "resources/surfaceimagehelper.h" - -#include "utils/paths.h" -#include "utils/physfsrwops.h" -#include "utils/sdlcheckutils.h" -#include "utils/stringutils.h" -#include "utils/timer.h" - -#include "debug.h" - -const unsigned int CACHE_SIZE = 256; -const unsigned int CACHE_SIZE_SMALL1 = 2; -const unsigned int CACHE_SIZE_SMALL2 = 50; -const unsigned int CACHE_SIZE_SMALL3 = 170; -const unsigned int CLEAN_TIME = 7; -const int OUTLINE_SIZE = 1; - -bool SDLFont::mSoftMode(false); - -char *strBuf = nullptr; - -#ifdef UNITTESTS -int sdlTextChunkCnt = 0; -#endif - -SDLTextChunkSmall::SDLTextChunkSmall(const std::string &text0, - const gcn::Color &color0, - const gcn::Color &color1) : - text(text0), - color(color0), - color2(color1) -{ -} - -SDLTextChunkSmall::SDLTextChunkSmall(const SDLTextChunkSmall &old) : - text(old.text), - color(old.color), - color2(old.color2) -{ -} - -bool SDLTextChunkSmall::operator==(const SDLTextChunkSmall &chunk) const -{ - return (chunk.text == text && chunk.color == color - && chunk.color2 == color2); -} - -bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const -{ - if (chunk.text != text) - return chunk.text > text; - - const gcn::Color &c = chunk.color; - if (c.r != color.r) - return c.r > color.r; - if (c.g != color.g) - return c.g > color.g; - if (c.b != color.b) - return c.b > color.b; - - const gcn::Color &c2 = chunk.color2; - if (c2.r != color2.r) - return c2.r > color2.r; - if (c2.g != color2.g) - return c2.g > color2.g; - if (c2.b != color2.b) - return c2.b > color2.b; - - if (c.a != color.a && SDLFont::mSoftMode) - return c.a > color.a; - - return false; -} - -SDLTextChunk::SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1) : - img(nullptr), - text(text0), - color(color0), - color2(color1), - prev(nullptr), - next(nullptr) -{ -#ifdef UNITTESTS - sdlTextChunkCnt ++; -#endif -} - -SDLTextChunk::~SDLTextChunk() -{ - delete img; - img = nullptr; -#ifdef UNITTESTS - sdlTextChunkCnt --; -#endif -} - -bool SDLTextChunk::operator==(const SDLTextChunk &chunk) const -{ - return (chunk.text == text && chunk.color == color - && chunk.color2 == color2); -} - -void SDLTextChunk::generate(TTF_Font *const font, const float alpha) -{ - BLOCK_START("SDLTextChunk::generate") - SDL_Color sdlCol; - sdlCol.b = static_cast<uint8_t>(color.b); - sdlCol.r = static_cast<uint8_t>(color.r); - sdlCol.g = static_cast<uint8_t>(color.g); -#ifdef USE_SDL2 - sdlCol.a = 255; -#else - sdlCol.unused = 0; -#endif - - getSafeUtf8String(text, strBuf); - - SDL_Surface *surface = MTTF_RenderUTF8_Blended( - font, strBuf, sdlCol); - - if (!surface) - { - img = nullptr; - BLOCK_END("SDLTextChunk::generate") - return; - } - - const int width = surface->w; - const int height = surface->h; - - if (color.r != color2.r || color.g != color2.g - || color.b != color2.b) - { // outlining - SDL_Color sdlCol2; - SDL_Surface *const background = imageHelper->create32BitSurface( - width, height); - if (!background) - { - img = nullptr; - MSDL_FreeSurface(surface); - BLOCK_END("SDLTextChunk::generate") - return; - } - sdlCol2.b = static_cast<uint8_t>(color2.b); - sdlCol2.r = static_cast<uint8_t>(color2.r); - sdlCol2.g = static_cast<uint8_t>(color2.g); -#ifdef USE_SDL2 - sdlCol2.a = 255; -#else - sdlCol2.unused = 0; -#endif - SDL_Surface *const surface2 = MTTF_RenderUTF8_Blended( - font, strBuf, sdlCol2); - if (!surface2) - { - img = nullptr; - MSDL_FreeSurface(surface); - BLOCK_END("SDLTextChunk::generate") - return; - } - SDL_Rect rect = - { - OUTLINE_SIZE, - 0, - static_cast<Uint16>(surface->w), - static_cast<Uint16>(surface->h) - }; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = -OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = 0; - rect.y = -OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.y = OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = 0; - rect.y = 0; - SurfaceImageHelper::combineSurface(surface, nullptr, - background, &rect); - MSDL_FreeSurface(surface); - MSDL_FreeSurface(surface2); - surface = background; - } - img = imageHelper->createTextSurface( - surface, width, height, alpha); - MSDL_FreeSurface(surface); - - BLOCK_END("SDLTextChunk::generate") -} - - -TextChunkList::TextChunkList() : - start(nullptr), - end(nullptr), - size(0), - search(), - searchWidth() -{ -} - -void TextChunkList::insertFirst(SDLTextChunk *const item) -{ - SDLTextChunk *const oldFirst = start; - if (start) - start->prev = item; - item->prev = nullptr; - if (oldFirst) - item->next = oldFirst; - else - end = item; - start = item; - size ++; - search[SDLTextChunkSmall(item->text, item->color, item->color2)] = item; - searchWidth[item->text] = item; -} - -void TextChunkList::moveToFirst(SDLTextChunk *item) -{ - if (item == start) - return; - - SDLTextChunk *oldPrev = item->prev; - if (oldPrev) - oldPrev->next = item->next; - SDLTextChunk *oldNext = item->next; - if (oldNext) - oldNext->prev = item->prev; - else - end = oldPrev; - SDLTextChunk *const oldFirst = start; - if (start) - start->prev = item; - item->prev = nullptr; - item->next = oldFirst; - start = item; -} - -void TextChunkList::removeBack() -{ - SDLTextChunk *oldEnd = end; - if (oldEnd) - { - end = oldEnd->prev; - if (end) - end->next = nullptr; - else - start = nullptr; - search.erase(SDLTextChunkSmall(oldEnd->text, - oldEnd->color, oldEnd->color2)); - searchWidth.erase(oldEnd->text); - delete oldEnd; - size --; - } -} - -void TextChunkList::removeBack(int n) -{ - SDLTextChunk *item = end; - while (n && item) - { - n --; - SDLTextChunk *oldEnd = item; - item = item->prev; - search.erase(SDLTextChunkSmall(oldEnd->text, - oldEnd->color, oldEnd->color2)); - searchWidth.erase(oldEnd->text); - delete oldEnd; - size --; - } - if (item) - { - item->next = nullptr; - end = item; - } - else - { - start = nullptr; - end = nullptr; - } -} - -void TextChunkList::clear() -{ - search.clear(); - searchWidth.clear(); - SDLTextChunk *item = start; - while (item) - { - SDLTextChunk *item2 = item->next; - delete item; - item = item2; - } - start = nullptr; - end = nullptr; - size = 0; -} - -static int fontCounter; - -SDLFont::SDLFont(std::string filename, - const int size, - const int style) : - mFont(nullptr), - mCreateCounter(0), - mDeleteCounter(0), - mCleanTime(cur_time + CLEAN_TIME) -{ - if (fontCounter == 0) - { - mSoftMode = imageHelper->useOpenGL() == RENDER_SOFTWARE; - if (TTF_Init() == -1) - { - logger->error("Unable to initialize SDL_ttf: " + - std::string(TTF_GetError())); - } - } - - if (!fontCounter) - { - strBuf = new char[65535]; - memset(strBuf, 0, 65535); - } - - ++fontCounter; - - fixDirSeparators(filename); - mFont = openFont(filename.c_str(), size); - - if (!mFont) - { - logger->log("Error finding font " + filename); - std::string backFile("fonts/dejavusans.ttf"); - mFont = openFont(fixDirSeparators(backFile).c_str(), size); - if (!mFont) - { - logger->error("SDLSDLFont::SDLSDLFont: " + - std::string(TTF_GetError())); - } - } - - TTF_SetFontStyle(mFont, style); -} - -SDLFont::~SDLFont() -{ - TTF_CloseFont(mFont); - mFont = nullptr; - --fontCounter; - clear(); - - if (fontCounter == 0) - { - TTF_Quit(); - delete []strBuf; - } -} - -TTF_Font *SDLFont::openFont(const char *const name, const int size) -{ -// disabled for now because some systems like gentoo cant use it -// #ifdef USE_SDL2 -// SDL_RWops *const rw = MPHYSFSRWOPS_openRead(name); -// if (!rw) -// return nullptr; -// return TTF_OpenFontIndexRW(rw, 1, size, 0); -// #else - return TTF_OpenFontIndex(ResourceManager::getPath(name).c_str(), - size, 0); -// #endif -} - -void SDLFont::loadFont(std::string filename, - const int size, - const int style) -{ - if (fontCounter == 0 && TTF_Init() == -1) - { - logger->log("Unable to initialize SDL_ttf: " + - std::string(TTF_GetError())); - return; - } - - fixDirSeparators(filename); - TTF_Font *const font = openFont(filename.c_str(), size); - - if (!font) - { - logger->log("SDLSDLFont::SDLSDLFont: " + - std::string(TTF_GetError())); - return; - } - - if (mFont) - TTF_CloseFont(mFont); - - mFont = font; - TTF_SetFontStyle(mFont, style); - clear(); -} - -void SDLFont::clear() -{ - for (size_t f = 0; f < CACHES_NUMBER; f ++) - mCache[f].clear(); -} - -void SDLFont::drawString(Graphics *const graphics, - const std::string &text, - const int x, const int y) -{ - BLOCK_START("SDLFont::drawString") - if (text.empty()) - { - BLOCK_END("SDLFont::drawString") - return; - } - - Graphics *const g = dynamic_cast<Graphics *const>(graphics); - if (!g) - return; - - gcn::Color col = g->getColor(); - const gcn::Color &col2 = g->getColor2(); - const float alpha = static_cast<float>(col.a) / 255.0F; - - /* The alpha value is ignored at string generation so avoid caching the - * same text with different alpha values. - */ - col.a = 255; - - const unsigned char chr = text[0]; - TextChunkList *const cache = &mCache[chr]; - - std::map<SDLTextChunkSmall, SDLTextChunk*> &search = cache->search; - std::map<SDLTextChunkSmall, SDLTextChunk*>::iterator i - = search.find(SDLTextChunkSmall(text, col, col2)); - if (i != search.end()) - { - SDLTextChunk *const chunk2 = (*i).second; - cache->moveToFirst(chunk2); - Image *const image = chunk2->img; - if (image) - { - image->setAlpha(alpha); - g->drawImage2(image, x, y); - } - } - else - { - if (cache->size >= CACHE_SIZE) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter ++; -#endif - cache->removeBack(); - } -#ifdef DEBUG_FONT_COUNTERS - mCreateCounter ++; -#endif - SDLTextChunk *chunk2 = new SDLTextChunk(text, col, col2); - - chunk2->generate(mFont, alpha); - cache->insertFirst(chunk2); - - const Image *const image = chunk2->img; - if (image) - g->drawImage2(image, x, y); - } - BLOCK_END("SDLFont::drawString") -} - -void SDLFont::slowLogic(const int rnd) -{ - BLOCK_START("SDLFont::slowLogic") - if (!mCleanTime) - { - mCleanTime = cur_time + CLEAN_TIME + rnd; - } - else if (mCleanTime < cur_time) - { - doClean(); - mCleanTime = cur_time + CLEAN_TIME + rnd; - } - BLOCK_END("SDLFont::slowLogic") -} - -int SDLFont::getWidth(const std::string &text) const -{ - if (text.empty()) - return 0; - - const unsigned char chr = text[0]; - TextChunkList *const cache = &mCache[chr]; - - std::map<std::string, SDLTextChunk*> &search = cache->searchWidth; - std::map<std::string, SDLTextChunk*>::iterator i = search.find(text); - if (i != search.end()) - { - SDLTextChunk *const chunk = (*i).second; - cache->moveToFirst(chunk); - const Image *const image = chunk->img; - if (image) - return image->getWidth(); - else - return 0; - } - - // if string was not drawed - int w, h; - getSafeUtf8String(text, strBuf); - TTF_SizeUTF8(mFont, strBuf, &w, &h); - return w; -} - -int SDLFont::getHeight() const -{ - return TTF_FontHeight(mFont); -} - -void SDLFont::doClean() -{ - for (unsigned int f = 0; f < CACHES_NUMBER; f ++) - { - TextChunkList *const cache = &mCache[f]; - const size_t size = cache->size; -#ifdef DEBUG_FONT_COUNTERS - logger->log("ptr: %d, size: %d", f, size); -#endif - if (size > CACHE_SIZE_SMALL3) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter += 100; -#endif - cache->removeBack(100); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete3"); -#endif - } - else if (size > CACHE_SIZE_SMALL2) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter += 20; -#endif - cache->removeBack(20); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete2"); -#endif - } - else if (size > CACHE_SIZE_SMALL1) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter ++; -#endif - cache->removeBack(); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete1"); -#endif - } - } -} - -const TextChunkList *SDLFont::getCache() const -{ - return mCache; -} diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h deleted file mode 100644 index 1cb6f5c99..000000000 --- a/src/gui/sdlfont.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * Copyright (C) 2009 Aethyra Development Team - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_SDLFONT_H -#define GUI_SDLFONT_H - -#include "gui/base/color.hpp" -#include "gui/base/font.hpp" - -#include <SDL_ttf.h> - -#include <map> -#include <string> - -#include "localconsts.h" - -class Image; - -const unsigned int CACHES_NUMBER = 256; - -class SDLTextChunkSmall -{ - public: - SDLTextChunkSmall(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); - - SDLTextChunkSmall(const SDLTextChunkSmall &old); - - bool operator==(const SDLTextChunkSmall &chunk) const; - bool operator<(const SDLTextChunkSmall &chunk) const; - - std::string text; - gcn::Color color; - gcn::Color color2; -}; - -class SDLTextChunk final -{ - public: - SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); - - A_DELETE_COPY(SDLTextChunk) - - ~SDLTextChunk(); - - bool operator==(const SDLTextChunk &chunk) const; - - void generate(TTF_Font *const font, const float alpha); - - Image *img; - std::string text; - gcn::Color color; - gcn::Color color2; - SDLTextChunk *prev; - SDLTextChunk *next; -}; - - -class TextChunkList final -{ - public: - TextChunkList(); - - A_DELETE_COPY(TextChunkList) - - void insertFirst(SDLTextChunk *const item); - - void moveToFirst(SDLTextChunk *item); - - void removeBack(); - - void removeBack(int n); - - void clear(); - - SDLTextChunk *start; - SDLTextChunk *end; - uint32_t size; - std::map<SDLTextChunkSmall, SDLTextChunk*> search; - std::map<std::string, SDLTextChunk*> searchWidth; -}; - -/** - * A wrapper around SDL_ttf for allowing the use of TrueType fonts. - * - * <b>NOTE:</b> This class initializes SDL_ttf as necessary. - */ -class SDLFont final : public gcn::Font -{ - public: - SDLFont(std::string filename, - const int size, - const int style = 0); - - A_DELETE_COPY(SDLFont) - - ~SDLFont(); - - void loadFont(std::string filename, - const int size, - const int style = 0); - - int getWidth(const std::string &text) const override - final A_WARN_UNUSED; - - int getHeight() const override final A_WARN_UNUSED; - - const TextChunkList *getCache() const A_WARN_UNUSED; - - /** - * @see Font::drawString - */ - void drawString(Graphics *const graphics, - const std::string &text, - const int x, const int y) override final; - - void clear(); - - void doClean(); - - void slowLogic(const int rnd); - - int getCreateCounter() const A_WARN_UNUSED - { return mCreateCounter; } - - int getDeleteCounter() const A_WARN_UNUSED - { return mDeleteCounter; } - - static bool mSoftMode; - - private: - static TTF_Font *openFont(const char *const name, const int size); - - TTF_Font *mFont; - unsigned mCreateCounter; - unsigned mDeleteCounter; - - // Word surfaces cache - int mCleanTime; - mutable TextChunkList mCache[CACHES_NUMBER]; -}; - -#ifdef UNITTESTS -extern int sdlTextChunkCnt; -#endif - -#endif // GUI_SDLFONT_H diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index c3da988b7..ee64736eb 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -42,7 +42,7 @@ #include "gui/windows/ministatuswindow.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -341,7 +341,7 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path, const gcn::Color &color) const { graphics->setColor(color); - gcn::Font *const font = getFont(); + Font *const font = getFont(); #ifdef MANASERV_SUPPORT if (Net::getNetworkType() != ServerInfo::MANASERV) diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 8e4d9e483..298ab657a 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -28,16 +28,14 @@ #include "being/localplayer.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/viewport.h" #include "gui/windows/chatwindow.h" #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" int AvatarListBox::instances = 0; @@ -103,7 +101,7 @@ void AvatarListBox::draw(Graphics *graphics) mListModel); updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int fontHeight = getFont()->getHeight(); const gcn::Widget *const parent = mParent; const std::string name = player_node->getName(); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index c158171c0..60b67dc24 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -25,8 +25,8 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/widgets/linkhandler.h" @@ -37,7 +37,6 @@ #include "utils/stringutils.h" #include "utils/timer.h" -#include "gui/base/font.hpp" #include "gui/base/cliprectangle.hpp" #include "render/graphics.h" @@ -175,7 +174,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) std::string tmp = row; std::string newRow; size_t idx1; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); int linksCount = 0; if (getWidth() < 0) @@ -491,7 +490,7 @@ void BrowserBox::draw(Graphics *graphics) } } - gcn::Font *const font = getFont(); + Font *const font = getFont(); FOR_EACH (LinePartCIter, i, mLineParts) { @@ -530,7 +529,7 @@ int BrowserBox::calcHeight() if (maxWidth < 0) return 1; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int fontHeight = font->getHeight() + 2 * mItemPadding; const int fontWidthMinus = font->getWidth("-"); const char *const hyphen = "~"; diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 8bc3d7540..5d27af68a 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -31,7 +31,7 @@ #include "resources/imageset.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -426,7 +426,7 @@ void Button::draw(Graphics *graphics) const gcn::Rectangle &rect = mDimension; const int width = rect.width; const int height = rect.height; - gcn::Font *const font = getFont(); + Font *const font = getFont(); int textY = height / 2 - font->getHeight() / 2; if (mImages) imageY = height / 2 - mImageHeight / 2; @@ -559,7 +559,7 @@ void Button::widgetMoved(const Event &event A_UNUSED) void Button::adjustSize() { - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const Skin *const skin = button[BUTTON_STANDARD]; if (!skin) return; diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 9b67b0359..0772c0d4f 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -30,7 +30,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -100,7 +100,7 @@ void CheckBox::draw(Graphics *const graphics) BLOCK_START("CheckBox::draw") drawBox(graphics); - gcn::Font *const font = getFont(); + Font *const font = getFont(); graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing, mPadding); diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index a9cf4f71e..6803fbe3c 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -22,7 +22,7 @@ #include "gui/widgets/colormodel.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -33,7 +33,7 @@ ColorPage::ColorPage(const Widget2 *const widget, { mItemPadding = mSkin ? mSkin->getOption("itemPadding") : 1; mRowHeight = 13; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (font) mRowHeight = font->getHeight() + 2 * mItemPadding; if (mListModel) @@ -57,7 +57,7 @@ void ColorPage::draw(Graphics *graphics) mHighlightColor.a = static_cast<int>(mAlpha * 255.0F); graphics->setColor(mHighlightColor); updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int rowHeight = getRowHeight(); const int width = mDimension.width; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 225ea11bb..42fa89b30 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -33,7 +33,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include <algorithm> @@ -235,7 +235,7 @@ void DropDown::draw(Graphics* graphics) gcn::ListModel *const model = mPopup->getListModel(); if (model && mPopup->getSelected() >= 0) { - gcn::Font *const font = getFont(); + Font *const font = getFont(); graphics->setColorAll(mForegroundColor, mForegroundColor2); if (mExtended) { diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 693245c2f..bca1f1e12 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -36,7 +36,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -116,7 +116,7 @@ void DropShortcutContainer::draw(Graphics *graphics) return; } - gcn::Font *const font = getFont(); + Font *const font = getFont(); for (unsigned i = 0; i < mMaxItems; i++) { diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 38c76060b..f5d1c19f0 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -27,14 +27,13 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/textpopup.h" #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" static const int MAX_ITEMS = 48; @@ -112,7 +111,7 @@ void EmoteShortcutContainer::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); drawBackground(graphics); graphics->setColorAll(mForegroundColor, mForegroundColor2); diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index f06e89e55..1fcbabd2b 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -22,7 +22,8 @@ #include "gui/widgets/extendedlistmodel.h" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/listmodel.hpp" #include "render/graphics.h" @@ -58,7 +59,7 @@ void ExtendedListBox::draw(Graphics *graphics) mListModel); updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int height = mRowHeight; const int pad2 = 2 + mPadding; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 4608534b1..b0f887fa2 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -46,7 +46,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "listeners/selectionlistener.h" #include <algorithm> @@ -251,7 +251,7 @@ void ItemContainer::draw(Graphics *graphics) return; BLOCK_START("ItemContainer::draw") - gcn::Font *const font = getFont(); + Font *const font = getFont(); for (int j = 0; j < mGridRows; j++) { diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 984803a99..2496beaa6 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -33,6 +33,7 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/itempopup.h" @@ -45,8 +46,6 @@ #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" ItemShortcutContainer::ItemShortcutContainer(const unsigned number) : @@ -129,7 +128,7 @@ void ItemShortcutContainer::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); drawBackground(graphics); const Inventory *const inv = PlayerInfo::getInventory(); diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index b2b709052..6cc94cc3d 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -21,7 +21,7 @@ #include "gui/widgets/label.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -82,7 +82,7 @@ void Label::draw(Graphics* graphics) int textX; const gcn::Rectangle &rect = mDimension; const int textY = rect.height / 2 - getFont()->getHeight() / 2; - gcn::Font *const font = getFont(); + Font *const font = getFont(); switch (mAlignment) { @@ -108,7 +108,7 @@ void Label::draw(Graphics* graphics) void Label::adjustSize() { - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int pad2 = 2 * mPadding; setWidth(font->getWidth(mCaption) + pad2); setHeight(font->getHeight() + pad2); @@ -129,7 +129,7 @@ void Label::setForegroundColorAll(const gcn::Color &color1, void Label::resizeTo(const int maxSize, const int minSize) { - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int pad2 = 2 * mPadding; setHeight(font->getHeight() + pad2); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 52ff775be..537c7283c 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -28,10 +28,10 @@ #include "input/keydata.h" +#include "gui/font.h" #include "gui/gui.h" #include "gui/base/focushandler.hpp" -#include "gui/base/font.hpp" #include "gui/base/listmodel.hpp" #include "render/graphics.h" @@ -70,7 +70,7 @@ ListBox::ListBox(const Widget2 *const widget, mItemPadding = mSkin->getOption("itemPadding"); } - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (font) mRowHeight = font->getHeight() + 2 * mItemPadding; else @@ -110,7 +110,7 @@ void ListBox::draw(Graphics *graphics) mHighlightColor.a = static_cast<int>(mAlpha * 255.0F); graphics->setColor(mHighlightColor); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int rowHeight = getRowHeight(); const int width = mDimension.width; diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index b120e4289..a1f597da8 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -25,10 +25,8 @@ #include "client.h" #include "graphicsvertexes.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" - -#include "gui/base/font.hpp" #include "debug.h" @@ -271,7 +269,7 @@ void ProgressBar::render(Graphics *graphics) { const gcn::Color oldColor = graphics->getColor(); - gcn::Font *const font = gui->getFont(); + Font *const font = gui->getFont(); const int textX = mDimension.width / 2; const int textY = (mDimension.height - font->getHeight()) / 2; diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 2fec7a9f6..984d84d76 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -30,7 +30,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -161,7 +161,7 @@ void RadioButton::draw(Graphics* graphics) BLOCK_START("RadioButton::draw") drawBox(graphics); - gcn::Font *const font = getFont(); + Font *const font = getFont(); graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing, mPadding); @@ -191,7 +191,7 @@ void RadioButton::keyPressed(KeyEvent& keyEvent) void RadioButton::adjustSize() { - gcn::Font *const font = getFont(); + Font *const font = getFont(); setHeight(font->getHeight() + 2 * mPadding); setWidth(mImagePadding + mImageSize + mSpacing + font->getWidth(mCaption) + mPadding); diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 8b6cca5a7..aeeb8e4bc 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -24,7 +24,7 @@ #include "main.h" #include "soundmanager.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/editdialog.h" @@ -41,8 +41,6 @@ #include "utils/gettext.h" #include "utils/mathutils.h" -#include "gui/base/font.hpp" - #include "debug.h" SetupItem::SetupItem(const std::string &restrict text, @@ -918,7 +916,7 @@ int SetupItemSlider2::getMaxWidth() int maxWidth = 0; SetupItemNamesConstIter it = mValues->begin(); const SetupItemNamesConstIter it_end = mValues->end(); - const gcn::Font *const font = gui->getFont(); + const Font *const font = gui->getFont(); while (it != it_end) { diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index f364aaf46..85ff90261 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -27,6 +27,7 @@ #include "being/playerinfo.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/itempopup.h" @@ -35,7 +36,6 @@ #include "resources/image.h" -#include "gui/base/font.hpp" #include "gui/base/listmodel.hpp" #include "debug.h" @@ -95,7 +95,7 @@ void ShopListBox::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); const int alpha = static_cast<int>(mAlpha * 255.0F); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int sz = mListModel->getNumberOfElements(); const int fontHeigh = getFont()->getHeight(); diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 988db85dd..93a6934ba 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -20,13 +20,12 @@ #include "gui/widgets/sliderlist.h" +#include "gui/font.h" #include "gui/gui.h" #include "gui/widgets/button.h" #include "gui/widgets/label.h" -#include "gui/base/font.hpp" - #include "debug.h" static const int buttonWidth = 27; @@ -209,7 +208,7 @@ int SliderList::getMaxLabelWidth() const return 1; int maxWidth = 0; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int num = mListModel->getNumberOfElements(); for (int f = 0; f < num; f ++) diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 511360b91..e8d34c9d8 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -27,6 +27,7 @@ #include "itemshortcut.h" #include "spellshortcut.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/spellpopup.h" @@ -36,8 +37,6 @@ #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" SpellShortcutContainer::SpellShortcutContainer(const unsigned number) : @@ -103,7 +102,7 @@ void SpellShortcutContainer::draw(Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int selectedId = spellShortcut->getSelectedItem(); graphics->setColorAll(mForegroundColor, mForegroundColor2); diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 1a2bdfeae..d29c56c85 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -21,7 +21,7 @@ #include "gui/widgets/tabs/setup_colors.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/userpalette.h" #include "gui/widgets/browserbox.h" @@ -101,7 +101,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : // TRANSLATORS: color type std::string longText = _("Static"); - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (getFont()->getWidth(_("Pulse")) > font->getWidth(longText)) { // TRANSLATORS: color type diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index ba02eb5a2..22bea9a75 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -125,7 +125,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) : mKeyListModel->setSize(mActionDataSize[0]); refreshKeys(); if (gui) - mKeyList->setFont(reinterpret_cast<gcn::Font*>(gui->getHelpFont())); + mKeyList->setFont(gui->getHelpFont()); mKeyList->addActionListener(this); mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index a85b7927b..a097d28e2 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -264,7 +264,7 @@ void Tab::widgetMoved(const Event &event A_UNUSED) mRedraw = true; } -void Tab::setLabelFont(gcn::Font *const font) +void Tab::setLabelFont(Font *const font) { if (!mLabel) return; diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index d22c6bea5..655fba7ea 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -134,7 +134,7 @@ class Tab : public gcn::BasicContainer, void widgetMoved(const Event &event) override final; - void setLabelFont(gcn::Font *const font); + void setLabelFont(Font *const font); Label *getLabel() const A_WARN_UNUSED { return mLabel; } diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index ecdc0e4d0..5f74fa1f8 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -26,7 +26,7 @@ #include "input/keydata.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include <sstream> @@ -88,7 +88,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension) text.substr(lastNewlinePos, newlinePos - lastNewlinePos); size_t lastSpacePos = 0; xpos = 0; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int spaceWidth = font->getWidth(" "); size_t sz = line.size(); @@ -360,7 +360,7 @@ void TextBox::draw(Graphics* graphics) graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); if (isFocused() && isEditable()) { drawCaret(graphics, font->getWidth( diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 0d01df51d..4dd2f1c7b 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -28,8 +28,8 @@ #include "events/keyevent.h" +#include "gui/font.h" #include "gui/sdlinput.h" - #include "gui/viewport.h" #include "gui/popups/popupmenu.h" @@ -39,8 +39,6 @@ #include "utils/copynpaste.h" #include "utils/timer.h" -#include "gui/base/font.hpp" - #undef DELETE // Win32 compatibility hack #include "debug.h" @@ -142,7 +140,7 @@ void TextField::draw(Graphics *graphics) BLOCK_START("TextField::draw") updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); if (isFocused()) { drawCaret(graphics, diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 5ef553b3c..2caf2e44c 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -24,8 +24,8 @@ #include "client.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "debug.h" @@ -100,12 +100,11 @@ void TextPreview::draw(Graphics* graphics) if (mTextBGColor) { - const SDLFont *const font = dynamic_cast<SDLFont*>(mFont); - if (font) + if (mFont) { - const int x = font->getWidth(mText) + 1 + const int x = mFont->getWidth(mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0); - const int y = font->getHeight() + 1 + const int y = mFont->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); graphics->setColor(gcn::Color(static_cast<int>(mTextBGColor->r), static_cast<int>(mTextBGColor->g), diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index f529e470c..cb524a974 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -78,7 +78,7 @@ class TextPreview final : public gcn::Widget, * * @param font the font to use. */ - inline void setFont(gcn::Font *const font) + inline void setFont(Font *const font) { mFont = font; } /** @@ -123,7 +123,7 @@ class TextPreview final : public gcn::Widget, void adjustSize(); private: - gcn::Font *mFont; + Font *mFont; std::string mText; const gcn::Color *mTextColor; const gcn::Color *mTextColor2; diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index c250e79a1..e2f24a0f2 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -29,6 +29,7 @@ #include "soundconsts.h" #include "soundmanager.h" +#include "gui/font.h" #include "gui/gui.h" #include "gui/viewport.h" @@ -38,7 +39,6 @@ #include "resources/image.h" #include "gui/base/focushandler.hpp" -#include "gui/base/font.hpp" #include "debug.h" @@ -110,7 +110,7 @@ Window::Window(const std::string &caption, const bool modal, { setPadding(mSkin->getPadding()); if (getOptionBool("titlebarBold")) - mCaptionFont = reinterpret_cast<gcn::Font*>(boldFont); + mCaptionFont = boldFont; mTitlePadding = mSkin->getTitlePadding(); mGripPadding = getOption("resizePadding"); mCaptionOffsetX = getOption("captionoffsetx"); diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index a5b6be83c..c6b2ca2cb 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -412,7 +412,7 @@ class Window : public gcn::Window, bool isResizeAllowed(const MouseEvent &event) const A_WARN_UNUSED; - void setCaptionFont(gcn::Font *font) + void setCaptionFont(Font *font) { mCaptionFont = font; } void enableVisibleSound(bool b) @@ -506,7 +506,7 @@ class Window : public gcn::Window, int mGripPadding; int mResizeHandles; int mOldResizeHandles; - gcn::Font *mCaptionFont; + Font *mCaptionFont; bool mShowTitle; /**< Window has a title bar */ bool mModal; /**< Window is modal */ bool mCloseWindowButton; /**< Window has a close button */ diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index cbff544fc..e49c78803 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -39,7 +39,7 @@ #include "input/inputmanager.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/sdlinput.h" #include "gui/viewport.h" diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp index 499538388..6eb21622d 100644 --- a/src/gui/windows/confirmdialog.cpp +++ b/src/gui/windows/confirmdialog.cpp @@ -29,7 +29,7 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 9b3ba857c..58e6d9c24 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -24,7 +24,7 @@ #include "configuration.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/setupwindow.h" diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 5caf30df1..6f2bb3b3d 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -32,6 +32,7 @@ #include "being/localplayer.h" #include "being/playerinfo.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/itempopup.h" @@ -46,8 +47,6 @@ #include "utils/dtor.h" #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include "debug.h" static const int BOX_COUNT = 13; @@ -163,7 +162,7 @@ void EquipmentWindow::draw(Graphics *graphics) Window::draw(graphics); int i = 0; - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int fontHeight = font->getHeight(); if (isBatchDrawRenders(openGLMode)) diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 95bea6e00..0b31a410b 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -24,7 +24,7 @@ #include "configuration.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/didyouknowwindow.h" #include "gui/windows/setupwindow.h" diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 3eb10e0e8..c95c2c54e 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -32,6 +32,7 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/textpopup.h" @@ -43,7 +44,6 @@ #include "gui/windows/shopwindow.h" #include "gui/windows/tradewindow.h" - #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/itemcontainer.h" @@ -58,8 +58,6 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include <string> #include "debug.h" diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index a883406e7..d1823d5cf 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -32,8 +32,8 @@ #include "being/being.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/viewport.h" #include "gui/windows/inventorywindow.h" @@ -59,8 +59,6 @@ #include "utils/copynpaste.h" #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include "debug.h" // TRANSLATORS: npc dialog button @@ -170,7 +168,7 @@ NpcDialog::NpcDialog(const int npcId) : mTextField->setVisible(true); mIntField->setVisible(true); - const gcn::Font *const fnt = mButton->getFont(); + const Font *const fnt = mButton->getFont(); int width = std::max(fnt->getWidth(CAPTION_WAITING), fnt->getWidth(CAPTION_NEXT)); width = std::max(width, fnt->getWidth(CAPTION_CLOSE)); diff --git a/src/gui/windows/okdialog.cpp b/src/gui/windows/okdialog.cpp index b9f26da20..3d734b7ad 100644 --- a/src/gui/windows/okdialog.cpp +++ b/src/gui/windows/okdialog.cpp @@ -30,7 +30,7 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 681949145..2e8c5dcc8 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -26,7 +26,7 @@ #include "being/localplayer.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index ce5c3c815..fb2f5258b 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -31,7 +31,7 @@ #include "input/keydata.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/editserverdialog.h" #include "gui/windows/logindialog.h" @@ -45,8 +45,6 @@ #include "utils/gettext.h" #include "utils/langs.h" -#include "gui/base/font.hpp" - #include <string> #include "debug.h" @@ -182,8 +180,8 @@ public: height)); } - gcn::Font *const font1 = boldFont; - gcn::Font *const font2 = getFont(); + Font *const font1 = boldFont; + Font *const font2 = getFont(); const int fontHeight = font1->getHeight(); const int pad1 = fontHeight + mPadding; const int pad2 = height / 4 + mPadding; @@ -644,7 +642,7 @@ void ServerDialog::loadServers(const bool addNew) version = strprintf(_("requires v%s"), version.c_str()); } - const gcn::Font *const font = gui->getFont(); + const Font *const font = gui->getFont(); for_each_xml_child_node(subNode, serverNode) { diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 8ec8486e3..413f73226 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -29,6 +29,7 @@ #include "being/localplayer.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/textpopup.h" @@ -53,8 +54,6 @@ #include "resources/beingcommon.h" -#include "gui/base/font.hpp" - #include "debug.h" class SkillListBox final : public ListBox @@ -121,7 +120,7 @@ class SkillListBox final : public ListBox // Draw the list elements graphics->setColorAll(mTextColor, mTextColor2); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int space = font->getHeight() + mSpacing; const int width2 = getWidth() - mPadding; for (int i = 0, y = 1; diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp index c4ff71eb7..9b7bb3eb1 100644 --- a/src/gui/windows/textdialog.cpp +++ b/src/gui/windows/textdialog.cpp @@ -30,7 +30,7 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -68,7 +68,7 @@ TextDialog::TextDialog(const std::string &restrict title, place(2, 2, mOkButton); place(3, 2, cancelButton); - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (font) { int width = font->getWidth(title); diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 1793fc2fb..d94b78c34 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -31,7 +31,7 @@ #include "being/playerinfo.h" #include "being/playerrelations.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/inventorywindow.h" #include "gui/windows/itemamountwindow.h" @@ -51,8 +51,6 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include "debug.h" // TRANSLATORS: trade window button @@ -102,7 +100,7 @@ TradeWindow::TradeWindow(): if (setupWindow) setupWindow->registerWindowForReset(this); - const gcn::Font *const fnt = mOkButton->getFont(); + const Font *const fnt = mOkButton->getFont(); int width = std::max(fnt->getWidth(CAPTION_PROPOSE), fnt->getWidth(CAPTION_CONFIRMED)); width = std::max(width, fnt->getWidth(CAPTION_ACCEPT)); |