1 /* -*- Mode: C++; c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil -*- 2 * 3 * Quadra, an action puzzle game 4 * Copyright (C) 1998-2000 Ludus Design 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 #ifndef _HEADER_SPRITE 22 #define _HEADER_SPRITE 23 #include "types.h" 24 #include "error.h" 25 #include "bitmap.h" 26 #include "res.h" 27 #include "palette.h" 28 29 #define CENTER (-123456) 30 31 class Font; 32 33 class Fontdata { 34 friend class Font; 35 SDL_Surface* spr[256]; // warning: there is some slack because they are not all used 36 int shrink; // indicates how much to overlap this font 37 int pre_width[256]; // pre-computed 'width' of the glyphs 38 public: 39 Fontdata(Res &res, int s=0); 40 Fontdata(const Fontdata &o); 41 virtual ~Fontdata(); 42 int width(const char *m) const; 43 int width(const char *m, int num) const; height()44 int height() const { 45 return spr[1]->h; 46 } 47 int translate(const char **m) const; 48 }; 49 50 class Font { 51 public: 52 const Fontdata& fdata_original; 53 private: 54 Fontdata fdata; 55 public: 56 Font(const Fontdata& f); 57 Font(const Fontdata& f, const Palette& dst, int r, int g, int b, int r2=0, int g2=0, int b2=0); 58 void colorize(const Palette& dst, int r, int g, int b, int r2=0, int g2=0, int b2=0); 59 void remap(const Remap *map); 60 void draw(const char *m, const Video_bitmap& b, int x, int y) const; width(const char * m)61 int width(const char *m) const { 62 return fdata_original.width(m); 63 } width(const char * m,int num)64 int width(const char *m, int num) const { 65 return fdata_original.width(m, num); 66 } height()67 int height() const { 68 return fdata_original.height(); 69 } 70 }; 71 72 #endif 73