diff options
author | Eugene Sandulenko | 2010-07-29 19:53:02 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2010-10-12 21:38:20 +0000 |
commit | a683a420a9e43705c972b5e74d55e319729e1a81 (patch) | |
tree | bde6e4abd417bdfaec120aa951da9a19be36b654 /engines/sword25/gfx/fontresource.h | |
parent | 7723d91c957d07205c51be32498d45cd0a78568f (diff) | |
download | scummvm-rg350-a683a420a9e43705c972b5e74d55e319729e1a81.tar.gz scummvm-rg350-a683a420a9e43705c972b5e74d55e319729e1a81.tar.bz2 scummvm-rg350-a683a420a9e43705c972b5e74d55e319729e1a81.zip |
SWORD25: Importing original sources
svn-id: r53171
Diffstat (limited to 'engines/sword25/gfx/fontresource.h')
-rwxr-xr-x | engines/sword25/gfx/fontresource.h | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/engines/sword25/gfx/fontresource.h b/engines/sword25/gfx/fontresource.h new file mode 100755 index 0000000000..adb790be6b --- /dev/null +++ b/engines/sword25/gfx/fontresource.h @@ -0,0 +1,104 @@ +// ----------------------------------------------------------------------------- +// This file is part of Broken Sword 2.5 +// Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdörfer +// +// Broken Sword 2.5 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 +// (at your option) any later version. +// +// Broken Sword 2.5 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 Broken Sword 2.5; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +// ----------------------------------------------------------------------------- + +#ifndef BS_FONTRESOURCE_H +#define BS_FONTRESOURCE_H + +// ----------------------------------------------------------------------------- +// Includes +// ----------------------------------------------------------------------------- + +#include "kernel/common.h" +#include "kernel/resource.h" +#include "math/rect.h" + +// ----------------------------------------------------------------------------- +// Forward declarations +// ----------------------------------------------------------------------------- + +class BS_Kernel; +class TiXmlDocument; +class TiXmlElement; + +// ----------------------------------------------------------------------------- +// Klassendefinition +// ----------------------------------------------------------------------------- + +class BS_FontResource : public BS_Resource +{ +public: + /** + @brief Erzeugt eine neues Exemplar von BS_FontResource + @param pKernel ein Pointer auf den Kernel + @param FileName der Dateiname der zu ladenen Resource + @remark Wenn der Konstruktor erfolgreich ausgeführt werden konnte gibt die Methode IsValid true zurück. + */ + BS_FontResource(BS_Kernel * pKernel, const std::string & FileName); + + /** + @brief Gibt true zurück, wenn das Objekt korrekt initialisiert wurde. + + Diese Methode kann dazu benutzt werden um festzustellen, ob der Konstruktor erfolgreich ausgeführt wurde. + */ + bool IsValid() const { return _Valid; } + + /** + @brief Gibt die Zeilenhöhe des Fonts in Pixeln zurück. + + Die Zeilenhöhe ist der Wert, der zur Y-Koordinate addiert wird, wenn ein Zeilenumbruch auftritt. + */ + int GetLineHeight() const { return _LineHeight; } + + /** + @brief Gibt den Buchstabenabstand der Fonts in Pixeln zurück. + + Der Buchstabenabstand ist der Wert, der zwischen zwei Buchstaben freigelassen wird. + */ + int GetGapWidth() const { return _GapWidth; } + + /** + @brief Gibt das Bounding-Rect eines Zeichens auf der Charactermap zurück. + @param Character der ASCII-Code des Zeichens + @return Das Bounding-Rect des übergebenen Zeichens auf der Charactermap. + */ + const BS_Rect & GetCharacterRect(int Character) const { BS_ASSERT(Character >= 0 && Character < 256); return _CharacterRects[Character]; } + + /** + @brief Gibt den Dateinamen der Charactermap zurück. + */ + const std::string & GetCharactermapFileName() const { return _BitmapFileName; } + +private: + BS_Kernel * _pKernel; + bool _Valid; + std::string _BitmapFileName; + int _LineHeight; + int _GapWidth; + BS_Rect _CharacterRects[256]; + + // ----------------------------------------------------------------------------- + // Hilfsmethoden + // ----------------------------------------------------------------------------- + + bool _ParseXMLDocument(const std::string & FileName, TiXmlDocument & Doc) const; + bool _ParseFontTag(TiXmlElement & Tag, std::string & BitmapFileName, int & LineHeight, int & GapWidth) const; + bool _ParseCharacterTag(TiXmlElement & Tag, int & Code, BS_Rect & Rect) const; +}; + +#endif |