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 ***********************************************************/
20 int getFontWidth(int font_size, int font_type)
22 return (font_size == FS_BIG ? FONT1_XSIZE :
23 font_size == FS_MEDIUM ? FONT6_XSIZE :
24 font_type == FC_SPECIAL1 ? FONT3_XSIZE :
25 font_type == FC_SPECIAL2 ? FONT4_XSIZE :
26 font_type == FC_SPECIAL3 ? FONT5_XSIZE :
30 int getFontHeight(int font_size, int font_type)
32 return (font_size == FS_BIG ? FONT1_YSIZE :
33 font_size == FS_MEDIUM ? FONT6_YSIZE :
34 font_type == FC_SPECIAL1 ? FONT3_YSIZE :
35 font_type == FC_SPECIAL2 ? FONT4_YSIZE :
36 font_type == FC_SPECIAL3 ? FONT5_YSIZE :
40 void DrawInitText(char *text, int ypos, int color)
42 if (window && pix[PIX_SMALLFONT])
44 ClearRectangle(window, 0, ypos, WIN_XSIZE, FONT2_YSIZE);
45 DrawTextExt(window, gc, (WIN_XSIZE - strlen(text) * FONT2_XSIZE)/2,
46 ypos, text, FS_SMALL, color);
51 void DrawTextFCentered(int y, int font_type, char *format, ...)
53 char buffer[FULL_SXSIZE / FONT5_XSIZE + 10];
54 int font_width = getFontWidth(FS_SMALL, font_type);
58 vsprintf(buffer, format, ap);
61 DrawText(SX + (SXSIZE - strlen(buffer) * font_width) / 2, SY + y,
62 buffer, FS_SMALL, font_type);
65 void DrawTextF(int x, int y, int font_type, char *format, ...)
67 char buffer[FULL_SXSIZE / FONT5_XSIZE + 10];
71 vsprintf(buffer, format, ap);
74 DrawText(SX + x, SY + y, buffer, FS_SMALL, font_type);
77 void DrawText(int x, int y, char *text, int font_size, int font_type)
79 DrawTextExt(drawto, gc, x, y, text, font_size, font_type);
82 redraw_mask |= REDRAW_FIELD;
84 redraw_mask |= REDRAW_DOOR_1;
87 void DrawTextExt(DrawBuffer d, GC gc, int x, int y,
88 char *text, int font_size, int font_type)
90 int font_width, font_height, font_start;
92 boolean print_inverse = FALSE;
94 if (font_size != FS_SMALL && font_size != FS_BIG && font_size != FS_MEDIUM)
96 if (font_type < FC_RED || font_type > FC_SPECIAL3)
99 font_width = getFontWidth(font_size, font_type);
100 font_height = getFontHeight(font_size, font_type);
102 font_bitmap = (font_size == FS_BIG ? PIX_BIGFONT :
103 font_size == FS_MEDIUM ? PIX_MEDIUMFONT :
105 font_start = (font_type * (font_size == FS_BIG ? FONT1_YSIZE :
106 font_size == FS_MEDIUM ? FONT6_YSIZE :
108 FONT_LINES_PER_FONT);
110 if (font_type == FC_SPECIAL3)
111 font_start += (FONT4_YSIZE - FONT2_YSIZE) * FONT_LINES_PER_FONT;
117 if (c == '~' && font_size == FS_SMALL)
119 print_inverse = TRUE;
123 if (c >= 'a' && c <= 'z')
125 else if (c == 'ä' || c == 'Ä')
127 else if (c == 'ö' || c == 'Ö')
129 else if (c == 'ü' || c == 'Ü')
132 if (c >= 32 && c <= 95)
134 int src_x = ((c - 32) % FONT_CHARS_PER_LINE) * font_width;
135 int src_y = ((c - 32) / FONT_CHARS_PER_LINE) * font_height + font_start;
136 int dest_x = x, dest_y = y;
140 BlitBitmap(pix[font_bitmap], d,
141 FONT_CHARS_PER_LINE * font_width,
142 3 * font_height + font_start,
143 font_width, font_height, x, y);
145 SetClipOrigin(clip_gc[font_bitmap], dest_x - src_x, dest_y - src_y);
146 BlitBitmapMasked(pix_masked[font_bitmap], d,
147 0, 0, font_width, font_height, dest_x, dest_y);
150 BlitBitmap(pix[font_bitmap], d,
151 src_x, src_y, font_width, font_height, dest_x, dest_y);