1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Text utility defines 22 */ 23 24 #ifndef TINSEL_TEXT_H // prevent multiple includes 25 #define TINSEL_TEXT_H 26 27 #include "common/coroutines.h" 28 #include "tinsel/object.h" // object manager defines 29 30 namespace Tinsel { 31 32 /** text mode flags - defaults to left justify */ 33 enum { 34 TXT_CENTER = 0x0001, ///< center justify text 35 TXT_RIGHT = 0x0002, ///< right justify text 36 TXT_SHADOW = 0x0004, ///< shadow each character 37 TXT_ABSOLUTE = 0x0008 ///< position of text is absolute (only for object text) 38 }; 39 40 /** maximum number of characters in a font */ 41 #define MAX_FONT_CHARS 256 42 43 #define C16_240 0x4000 44 #define C16_224 0x8000 45 #define C16_MAP 0xC000 46 #define C16_FLAG_MASK (C16_240 | C16_224 | C16_MAP) 47 48 #include "common/pack-start.h" // START STRUCT PACKING 49 50 /** 51 * Text font data structure. 52 * @note only the pointer is used so the size of fontDef[] is not important. 53 * It is currently set at 300 because it suited me for debugging. 54 */ 55 struct FONT { 56 int xSpacing; ///< x spacing between characters 57 int ySpacing; ///< y spacing between characters 58 int xShadow; ///< x shadow offset 59 int yShadow; ///< y shadow offset 60 int spaceSize; ///< x spacing to use for a space character 61 OBJ_INIT fontInit; ///< structure used to init text objects 62 SCNHANDLE fontDef[300]; ///< image handle array for all characters in the font 63 } PACKED_STRUCT; 64 65 #include "common/pack-end.h" // END STRUCT PACKING 66 67 68 /** structure for passing the correct parameters to ObjectTextOut */ 69 struct TEXTOUT { 70 OBJECT *pList; ///< object list to add text to 71 char *szStr; ///< string to output 72 int color; ///< color for monochrome text 73 int xPos; ///< x position of string 74 int yPos; ///< y position of string 75 SCNHANDLE hFont; ///< which font to use 76 int mode; ///< mode flags for the string 77 int sleepTime; ///< sleep time between each character (if non-zero) 78 }; 79 80 81 /*----------------------------------------------------------------------*\ 82 |* Text Function Prototypes *| 83 \*----------------------------------------------------------------------*/ 84 85 /** 86 * Main text outputting routine. If a object list is specified a 87 * multi-object is created for the whole text and a pointer to the head 88 * of the list is returned. 89 * @param pList object list to add text to 90 * @param szStr string to output 91 * @param color color for monochrome text 92 * @param xPos x position of string 93 * @param yPos y position of string 94 * @param hFont which font to use 95 * @param mode mode flags for the string 96 * @param sleepTime Sleep time between each character (if non-zero) 97 */ 98 OBJECT *ObjectTextOut(OBJECT **pList, char *szStr, int color, 99 int xPos, int yPos, SCNHANDLE hFont, int mode, int sleepTime = 0); 100 101 OBJECT *ObjectTextOutIndirect( // output a string of text 102 TEXTOUT *pText); // pointer to TextOut struct with all parameters 103 104 bool IsCharImage( // Is there an image for this character in this font? 105 SCNHANDLE hFont, // which font to use 106 char c); // character to test 107 108 } // End of namespace Tinsel 109 110 #endif // TINSEL_TEXT_H 111