1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
19 /* ========================================================================= */
20 /* exported variables */
21 /* ========================================================================= */
26 /* ========================================================================= */
28 /* ========================================================================= */
30 void InitFontInfo(Bitmap bitmap_big, Bitmap bitmap_medium,
33 font.bitmap_big = bitmap_big;
34 font.bitmap_medium = bitmap_medium;
35 font.bitmap_small = bitmap_small;
38 int getFontWidth(int font_size, int font_type)
40 return (font_size == FS_BIG ? FONT1_XSIZE :
41 font_size == FS_MEDIUM ? FONT6_XSIZE :
42 font_type == FC_SPECIAL1 ? FONT3_XSIZE :
43 font_type == FC_SPECIAL2 ? FONT4_XSIZE :
44 font_type == FC_SPECIAL3 ? FONT5_XSIZE :
48 int getFontHeight(int font_size, int font_type)
50 return (font_size == FS_BIG ? FONT1_YSIZE :
51 font_size == FS_MEDIUM ? FONT6_YSIZE :
52 font_type == FC_SPECIAL1 ? FONT3_YSIZE :
53 font_type == FC_SPECIAL2 ? FONT4_YSIZE :
54 font_type == FC_SPECIAL3 ? FONT5_YSIZE :
58 void DrawInitText(char *text, int ypos, int color)
60 if (window && font.bitmap_small)
62 ClearRectangle(window, 0, ypos, video.width, FONT2_YSIZE);
63 DrawTextExt(window, (video.width - strlen(text) * FONT2_XSIZE)/2,
64 ypos, text, FS_SMALL, color);
69 void DrawTextFCentered(int y, int font_type, char *format, ...)
71 char buffer[MAX_OUTPUT_LINESIZE + 1];
72 int font_width = getFontWidth(FS_SMALL, font_type);
76 vsprintf(buffer, format, ap);
79 DrawText(gfx.sx + (gfx.sxsize - strlen(buffer) * font_width) / 2,
80 gfx.sy + y, buffer, FS_SMALL, font_type);
83 void DrawTextF(int x, int y, int font_type, char *format, ...)
85 char buffer[MAX_OUTPUT_LINESIZE + 1];
89 vsprintf(buffer, format, ap);
92 DrawText(gfx.sx + x, gfx.sy + y, buffer, FS_SMALL, font_type);
95 void DrawText(int x, int y, char *text, int font_size, int font_type)
97 DrawTextExt(drawto, x, y, text, font_size, font_type);
100 redraw_mask |= REDRAW_FIELD;
102 redraw_mask |= REDRAW_DOOR_1;
105 void DrawTextExt(DrawBuffer bitmap, int x, int y,
106 char *text, int font_size, int font_type)
109 int font_width, font_height, font_start;
110 boolean print_inverse = FALSE;
112 if (font_size != FS_SMALL && font_size != FS_BIG && font_size != FS_MEDIUM)
113 font_size = FS_SMALL;
114 if (font_type < FC_RED || font_type > FC_SPECIAL3)
117 font_width = getFontWidth(font_size, font_type);
118 font_height = getFontHeight(font_size, font_type);
120 font_bitmap = (font_size == FS_BIG ? font.bitmap_big :
121 font_size == FS_MEDIUM ? font.bitmap_medium :
123 font_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE :
124 font_size == FS_MEDIUM ? FONT6_YSIZE :
126 FONT_LINES_PER_FONT);
128 if (font_type == FC_SPECIAL3)
129 font_start += (FONT4_YSIZE - FONT2_YSIZE) * FONT_LINES_PER_FONT;
135 if (c == '~' && font_size == FS_SMALL)
137 print_inverse = TRUE;
141 if (c >= 'a' && c <= 'z')
143 else if (c == 'ä' || c == 'Ä')
145 else if (c == 'ö' || c == 'Ö')
147 else if (c == 'ü' || c == 'Ü')
150 if (c >= 32 && c <= 95)
152 int src_x = ((c - 32) % FONT_CHARS_PER_LINE) * font_width;
153 int src_y = ((c - 32) / FONT_CHARS_PER_LINE) * font_height + font_start;
154 int dest_x = x, dest_y = y;
158 BlitBitmap(font_bitmap, bitmap,
159 FONT_CHARS_PER_LINE * font_width,
160 3 * font_height + font_start,
161 font_width, font_height, x, y);
163 SetClipOrigin(font_bitmap, font_bitmap->stored_clip_gc,
164 dest_x - src_x, dest_y - src_y);
165 BlitBitmapMasked(font_bitmap, bitmap,
166 0, 0, font_width, font_height, dest_x, dest_y);
169 BlitBitmap(font_bitmap, bitmap,
170 src_x, src_y, font_width, font_height, dest_x, dest_y);