1#include "draw.h"
2
3void Draw_FreePic (qpic_t pic) = #0;
4qpic_t Draw_MakePic (int width, int heiight, string data) = #0;
5qpic_t (string name, int alpha) Draw_CachePic = #0;
6
7void (int x, int y, qpic_t pic) Draw_Pic = #0;
8void (float x, float y, qpic_t pic) Draw_Picf = #0;
9void (int x, int y, qpic_t pic, int srcx, int srcy, int width, int height) Draw_SubPic = #0;
10void (int x, int y, qpic_t pic) Draw_CenterPic = #0;
11
12void (int x, int y, int chr) Draw_Character = #0;
13void (int x, int y, string text) Draw_String = #0;
14void (int x, int y, string text, int n) Draw_nString = #0;
15void (int x, int y, string text) Draw_AltString = #0;
16void (int x, int y, int w, int h, int c) Draw_Fill = #0;
17void (int ch, int x, int y) Draw_Crosshair = #0;
18
19void (int x, int y, int width, int lines) text_box =
20{
21	local int cx, cy, n;
22	local qpic_t p;
23
24	cx = x;
25	cy = y;
26	p = Draw_CachePic ("gfx/box_tl.lmp", 1);
27	Draw_Pic (cx, cy, p);
28	p = Draw_CachePic ("gfx/box_ml.lmp", 1);
29	for (n = 0; n < lines; n++) {
30		cy += 8;
31		Draw_Pic (cx, cy, p);
32	}
33	p = Draw_CachePic ("gfx/box_bl.lmp", 1);
34	Draw_Pic (cx, cy + 8, p);
35
36	cx += 8;
37	while (width > 0) {
38		cy = y;
39		p = Draw_CachePic ("gfx/box_tm.lmp", 1);
40		Draw_Pic (cx, cy, p);
41		p = Draw_CachePic ("gfx/box_mm.lmp", 1);
42		for (n = 0; n < lines; n++) {
43			cy += 8;
44			if (n == 1)
45				p = Draw_CachePic ("gfx/box_mm2.lmp", 1);
46			Draw_Pic (cx, cy, p);
47		}
48		p = Draw_CachePic ("gfx/box_bm.lmp", 1);
49		Draw_Pic (cx, cy + 8, p);
50		width -= 2;
51		cx += 16;
52	}
53
54	cy = y;
55	p = Draw_CachePic ("gfx/box_tr.lmp", 1);
56	Draw_Pic (cx, cy, p);
57	p = Draw_CachePic ("gfx/box_mr.lmp", 1);
58	for (n = 0; n < lines; n++) {
59		cy += 8;
60		Draw_Pic (cx, cy, p);
61	}
62	p = Draw_CachePic ("gfx/box_br.lmp", 1);
63	Draw_Pic (cx, cy + 8, p);
64};
65
66@implementation QPic
67
68-initName:(string)n Centered:(BOOL)c
69{
70	[super init];
71	name = n;
72	local qpic_t pic = Draw_CachePic (name, 1);
73	size.width = pic.width;
74	size.height = pic.height;
75	return self;
76}
77
78-initName:(string)n
79{
80	return [self initName:n Centered:NO];
81}
82
83-draw:(int)x :(int)y
84{
85	local qpic_t pic = Draw_CachePic (name, 1);
86	Draw_Pic (x, y, pic);
87	return self;
88}
89
90-draw:(int)x :(int)y :(int)srcx :(int)srcy :(int)width :(int)height
91{
92	local qpic_t pic = Draw_CachePic (name, 1);
93	Draw_SubPic (x, y, pic, srcx, srcy, width, height);
94	return self;
95}
96
97-(int)width
98{
99	return size.width;
100}
101
102-(int)height
103{
104	return size.height;
105}
106
107@end
108