1 ///////////////////////////////////////////////
3 ///////////////////////
4 // This file belongs to dpmod/darkplaces
5 // AK contains all cursor specific functions
6 ///////////////////////////////////////////////
8 void(void) cursor_reset =
10 cursor_x = rint(GFX_WIDTH /2);
11 cursor_y = rint(GFX_HEIGHT /2);
15 cursor_last_frame_time = time;
16 cursor_color = CURSOR_COLOR;
17 cursor_transparency = CURSOR_TRANSPARENCY;
18 cursor_type = CT_NORMAL;
21 void(void) cursor_toggle =
23 cursor_x = rint(GFX_WIDTH /2);
24 cursor_y = rint(GFX_HEIGHT /2);
25 cursor_type = CT_NORMAL;
28 void(void) cursor_init =
32 CF_NORMAL = gfx_loadpic(CF_NORMAL, CURSOR_ENFORCELOADING);
35 CF_NORMAL = gfx_loadpic("ui/mousepointer.tga", true); // always
38 CF_PULSE_0 = gfx_loadpic(CF_PULSE_0, CURSOR_ENFORCELOADING);
40 CF_PULSE_1 = gfx_loadpic(CF_PULSE_1, CURSOR_ENFORCELOADING);
42 CF_PULSE_2 = gfx_loadpic(CF_PULSE_2, CURSOR_ENFORCELOADING);
44 CF_PULSE_3 = gfx_loadpic(CF_PULSE_3, CURSOR_ENFORCELOADING);
46 CF_PULSE_4 = gfx_loadpic(CF_PULSE_4, CURSOR_ENFORCELOADING);
48 CF_PULSE_5 = gfx_loadpic(CF_PULSE_5, CURSOR_ENFORCELOADING);
50 CF_PULSE_6 = gfx_loadpic(CF_PULSE_6, CURSOR_ENFORCELOADING);
56 void(void) cursor_shutdown =
59 gfx_unloadpic(CF_NORMAL);
61 gfx_unloadpic(CF_PULSE_0);
63 gfx_unloadpic(CF_PULSE_1);
65 gfx_unloadpic(CF_PULSE_2);
67 gfx_unloadpic(CF_PULSE_3);
69 gfx_unloadpic(CF_PULSE_4);
71 gfx_unloadpic(CF_PULSE_5);
73 gfx_unloadpic(CF_PULSE_6);
76 void(void) cursor_frame =
78 // update cursor animations
80 if(cursor_type > CT_LAST_PULSE || cursor_type < CT_FIRST_PULSE)
81 cursor_last_frame_time = time;
82 else if(cursor_last_frame_time + CA_PULSE_SPEED <= time)
84 cursor_type = CT_FIRST_PULSE +
85 mod((time - cursor_last_frame_time) / CA_PULSE_SPEED, CT_LAST_PULSE - CT_FIRST_PULSE +1);
87 cursor_last_frame_time += rint((time - cursor_last_frame_time) / CA_PULSE_SPEED) * CA_PULSE_SPEED;
90 // update cursor position
91 cursor_rel = getmousepos();
92 cursor_rel = gfx_converttogfx(cursor_rel);
94 cursor_rel = cursor_rel * CURSOR_SPEED;
95 cursor = cursor + cursor_rel;
97 cursor_x = bound(0, cursor_x, GFX_WIDTH);
98 cursor_y = bound(0, cursor_y, GFX_HEIGHT);
101 void(void) cursor_draw =
105 if(cursor_type == CT_FIRST_PULSE + 0 && CF_PULSE_0 != "")
107 else if(cursor_type == CT_FIRST_PULSE + 1 && CF_PULSE_1 != "")
109 else if(cursor_type == CT_FIRST_PULSE + 2 && CF_PULSE_2 != "")
111 else if((cursor_type == CT_FIRST_PULSE + 3 || cursor_type == CT_GLOW) && CF_PULSE_3 != "")
113 else if(cursor_type == CT_FIRST_PULSE + 4 && CF_PULSE_4 != "")
115 else if(cursor_type == CT_FIRST_PULSE + 5 && CF_PULSE_5 != "")
117 else if(cursor_type == CT_FIRST_PULSE + 6 && CF_PULSE_6 != "")
119 else // if(cursor_tpye = CT_NORMAL)
122 gfx_drawpic(cursor,pic, gfx_getimagesize(pic) * CURSOR_SCALE, cursor_color, cursor_transparency, 0);