2 /* This is a layer between main and different functions that can be called
3 when the mouse pointer is over */
14 static int fade, old_over = -1;
15 static unsigned char *screen;
16 static Over_settings over_settings;
17 static AquariumData *ad;
20 Over_settings *over_get_settings_ptr(void)
22 return &over_settings;
25 void over_keypress(int key)
27 if(over_settings.type == OVER_TETRIS)
31 void over_joystick(GaiFlagsJoystick jflags)
33 if(over_settings.type == OVER_TETRIS)
34 tetris_joystick(jflags);
44 ad = aquarium_get_settings_ptr();
47 if(over_settings.cursor_off)
48 gf = GAI_FLAGS_MOUSE_PTR_HIDE;
50 gf = GAI_FLAGS_MOUSE_PTR_SHOW;
52 gf |= GAI_FLAGS_ALLOW_ROTATE;
56 if(over_settings.type == OVER_OFF)
59 old_over = over_settings.type;
61 if(over_settings.type == OVER_MATRIX)
63 if(over_settings.type == OVER_PLASMA)
65 if(over_settings.type == OVER_TETRIS)
76 if(over_settings.type == OVER_OFF)
79 screen = g_malloc0((ad->xmax+2)*4*(ad->ymax+2));
81 if(over_settings.type == OVER_MATRIX)
83 if(over_settings.type == OVER_PLASMA)
85 if(over_settings.type == OVER_TETRIS)
96 if(over_settings.type == OVER_OFF)
99 if(over_settings.type == OVER_MATRIX)
101 if(over_settings.type == OVER_PLASMA)
103 if(over_settings.type == OVER_TETRIS)
116 if(old_over == OVER_MATRIX)
118 if(old_over == OVER_PLASMA)
120 if(old_over == OVER_TETRIS)
126 int over_update(int mouse_over)
133 if(over_settings.type == OVER_OFF)
136 /* All is faded up and mouse is over, return */
138 if(fade==0 && !mouse_over) return 0;
148 if(!over_settings.fade)
155 if(!over_settings.fade)
165 if(fade==0) full_over = 1;
167 if(over_settings.type == OVER_MATRIX)
169 if(over_settings.type == OVER_PLASMA)
171 if(over_settings.type == OVER_TETRIS)
174 draw_pic_alpha(screen, ad->xmax, ad->ymax, 0, 0, 0, fade);
181 /* This one is very alike to draw_fish - Only small differences.*/
183 void over_draw(int x, int y, int idx, int width, int height, unsigned char *pic)
185 /* bounding box of the clipped sprite */
188 int w, h, pos, fidx, ypos, pic_pos;
190 /* completely off the screen, don't bother drawing */
191 if ((y < (-height)) || (y > (ad->ymax)) || (x > (ad->xmax)) || (x < -(width)))
195 /* do clipping for top side */
200 /* do clipping for bottom side */
202 if ((y + height) > ad->ymax)
205 /* do clipping for right side */
207 if ((x + width) > ad->xmax)
208 dw = width - ((x + width) - ad->xmax);
210 /* do clipping for left side */
215 fidx = width * height * 4 * idx;
217 for (h = ds; h < dh; h++) {
218 /* offset to beginning of current row */
219 ypos = (h + y) * ad->xmax * 4;
220 for (w = di; w < dw; w++) {
221 pic_pos = h * width * 4 + w * 4 + fidx;
222 pos = ypos + w * 4 + x * 4;
223 if (pic[pic_pos + 3] != 0) {
224 screen[pos] = pic[pic_pos];
225 screen[pos + 1] = pic[pic_pos + 1];
226 screen[pos + 2] = pic[pic_pos + 2];