1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 |
|
---|
10 | #include "image/image.hh"
|
---|
11 | #include "window/cursor.hh"
|
---|
12 | #include "string/string.hh"
|
---|
13 | #include "loaders/load.hh"
|
---|
14 | #include "image/context.hh"
|
---|
15 |
|
---|
16 | i4_cursor_class *i4_load_cursor(char *cursor_name,
|
---|
17 | i4_string_manager_class *sman)
|
---|
18 | {
|
---|
19 | i4_const_str st=sman->get(cursor_name); // looks up the resource
|
---|
20 | sw32 trans,hot_x,hot_y;
|
---|
21 |
|
---|
22 | i4_const_str::iterator s=st.begin();
|
---|
23 | i4_str *fn=s.read_string();
|
---|
24 | trans=s.read_number();
|
---|
25 | hot_x=s.read_number();
|
---|
26 | hot_y=s.read_number();
|
---|
27 |
|
---|
28 |
|
---|
29 | i4_image_class *im=i4_load_image(*fn); // try to load up the cursor image
|
---|
30 | if (!im)
|
---|
31 | {
|
---|
32 | delete fn;
|
---|
33 | return 0;
|
---|
34 | }
|
---|
35 | else
|
---|
36 | {
|
---|
37 | i4_cursor_class *c=new i4_cursor_class(im,(i4_color)trans,hot_x,hot_y);
|
---|
38 | delete im;
|
---|
39 | delete fn;
|
---|
40 | return c;
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 | i4_cursor_class::i4_cursor_class(i4_image_class *_pict,
|
---|
48 | i4_color trans,
|
---|
49 | i4_coord hot_x, i4_coord hot_y,
|
---|
50 | const i4_pal *convert_to)
|
---|
51 | : trans(trans),
|
---|
52 | hot_x(hot_x),hot_y(hot_y)
|
---|
53 | {
|
---|
54 | if (convert_to)
|
---|
55 | {
|
---|
56 | int w=_pict->width(), h=_pict->height();
|
---|
57 | pict=i4_create_image(w,h, convert_to);
|
---|
58 |
|
---|
59 | i4_draw_context_class context(0,0, w-1,h-1);
|
---|
60 | pict->clear(trans, context);
|
---|
61 | _pict->put_image_trans(pict, 0,0, trans, context);
|
---|
62 | }
|
---|
63 | else pict=_pict->copy();
|
---|
64 | }
|
---|
65 |
|
---|
66 | i4_cursor_class::~i4_cursor_class()
|
---|
67 | {
|
---|
68 | if (pict)
|
---|
69 | delete pict;
|
---|
70 | }
|
---|
71 |
|
---|
72 | i4_cursor_class::i4_cursor_class()
|
---|
73 | {
|
---|
74 | pict = 0;
|
---|
75 | }
|
---|
76 |
|
---|
77 | i4_cursor_class *i4_cursor_class::copy(const i4_pal *convert_to)
|
---|
78 | {
|
---|
79 | return new i4_cursor_class(pict, trans, hot_x, hot_y, convert_to);
|
---|
80 | }
|
---|
81 |
|
---|