1 /* Copyright (C) 1995-2002 FSGames. Ported by Sean Ford and Yan Shosh
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17 #include "button.h"
18
19 extern short scen_level;
20 extern pixieN *backdrops[5];
21
22 vbutton * allbuttons[MAX_BUTTONS];
23 short dumbcount;
24 void get_input_events(bool);
25
26 //vbutton functions, vbutton is a button class that will be self controlled
vbutton(long xpos,long ypos,long wide,long high,long func (long),long pass,char * msg,unsigned char hot)27 vbutton::vbutton(long xpos, long ypos, long wide, long high,
28 long func(long), long pass, char *msg, unsigned char hot )
29 {
30 arg = pass;
31 fun = func;
32 myfunc = 0;
33 xloc = xpos;
34 yloc = ypos;
35 width = wide;
36 height = high;
37 xend = xloc + width;
38 yend = yloc + height;
39 strcpy(label,msg);
40 next = NULL;
41 // prev = NULL;
42 had_focus = 0;
43 do_outline = 0;
44 depressed = 0;
45
46 mypixie = NULL; // by default, no graphic picture
47
48 hotkey = hot;
49
50 vdisplay();
51 }
52
vbutton(long xpos,long ypos,long wide,long high,long func_code,long pass,char * msg,unsigned char hot)53 vbutton::vbutton(long xpos, long ypos, long wide, long high,
54 long func_code, long pass, char *msg, unsigned char hot )
55 {
56 arg = pass;
57 fun = NULL; // don't use this!
58 myfunc = func_code;
59 xloc = xpos;
60 yloc = ypos;
61 width = wide;
62 height = high;
63 xend = xloc + width;
64 yend = yloc + height;
65 strcpy(label,msg);
66 next = NULL;
67 // prev = NULL;
68 had_focus = 0;
69 do_outline = 0;
70 depressed = 0;
71
72 mypixie = NULL; // no graphic by default
73
74 hotkey = hot;
75
76 vdisplay();
77 }
78
vbutton(long xpos,long ypos,long wide,long high,long func_code,long pass,char * msg,char family,unsigned char hot)79 vbutton::vbutton(long xpos, long ypos, long wide, long high,
80 long func_code, long pass, char *msg, char family,
81 unsigned char hot )
82 {
83 arg = pass;
84 fun = NULL; // don't use this!
85 myfunc = func_code;
86 xloc = xpos;
87 yloc = ypos;
88 width = wide;
89 height = high;
90 xend = xloc + width;
91 yend = yloc + height;
92 strcpy(label,msg);
93 next = NULL;
94 // prev = NULL;
95 had_focus = 0;
96 do_outline = 0;
97 depressed = 0;
98
99 mypixie = myscreen->myloader->create_pixieN(ORDER_BUTTON1, family);
100
101 hotkey = hot;
102
103 width = mypixie->sizex;
104 height = mypixie->sizey;
105 xend = xloc + width;
106 yend = yloc + height;
107 vdisplay();
108 printf("Created button\n");
109 }
110
vbutton()111 vbutton::vbutton() //for pointers
112 {
113 next = NULL;
114 // prev = NULL;
115 had_focus = do_outline = depressed = 0;
116 mypixie = NULL;
117 }
118
~vbutton()119 vbutton::~vbutton()
120 {
121 myscreen->draw_box(xloc-4,yloc-4,xend+4,yend+4,0,1,1);
122 if (mypixie)
123 delete mypixie;
124
125 /*
126 release_mouse();
127 myscreen->buffer_to_screen(xloc-4,yloc-4,xend + 4, yend+4);
128 grab_mouse();
129
130 if (next != NULL)
131 {
132 delete next;
133 next = NULL;
134 }
135 */
136 }
137
set_graphic(char family)138 void vbutton::set_graphic(char family)
139 {
140 if (mypixie)
141 delete mypixie;
142 mypixie = myscreen->myloader->create_pixieN(ORDER_BUTTON1, family);
143 width = mypixie->sizex;
144 height= mypixie->sizey;
145 xend = xloc + width;
146 yend = yloc + height;
147 vdisplay();
148 }
149
vdisplay()150 void vbutton::vdisplay()
151 {
152 if (do_outline)
153 {
154 vdisplay(2);
155 return;
156 }
157 if (mypixie) // then use the graphic
158 {
159 mypixie->draw(xloc, yloc, myscreen->viewob[0]);
160 if (strlen(label))
161 mytext->write_xy( (short) ( ((xloc+xend)/2) - (((strlen(label)-1)* (mytext->sizex+1) )/2)) ,
162 (short) (yloc + (height-(mytext->sizey))/2), label, (unsigned char) DARK_BLUE, 1);
163 }
164 else
165 {
166 myscreen->draw_box(xloc,yloc,xend-1,yend-1,BUTTON_FACING,1,1); // front
167 myscreen->draw_box(xloc,yloc,xend-2,yloc,BUTTON_TOP,1,1); // top edge
168 myscreen->draw_box(xloc,yloc+1,xloc,yend-2,BUTTON_LEFT,1,1); // left
169 myscreen->draw_box(xend-1,yloc+1,xend-1,yend-2,BUTTON_RIGHT,1,1); // right
170 myscreen->draw_box(xloc+1,yend-1,xend-1,yend-1,BUTTON_BOTTOM,1,1); // bottom
171 if (strlen(label))
172 mytext->write_xy( (short) ( ((xloc+xend)/2) - (((strlen(label)-1)* (mytext->sizex+1) )/2)) ,
173 (short) (yloc + (height-(mytext->sizey))/2), label, (unsigned char) DARK_BLUE, 1);
174 }
175 //release_mouse();
176 //myscreen->buffer_to_screen(xloc-4,yloc-4,xend+4,yend+4);
177 //grab_mouse();
178 }
179
vdisplay(long status)180 void vbutton::vdisplay(long status)
181 {
182 if (!status) // do normal
183 {
184 vdisplay();
185 return;
186 }
187 if (mypixie) // then use the graphic
188 {
189 mypixie->draw(xloc, yloc, myscreen->viewob[0]);
190 if (strlen(label))
191 mytext->write_xy( (short) ( ((xloc+xend)/2) - (((strlen(label)-1)* (mytext->sizex+1) )/2)) ,
192 (short) (yloc + (height-(mytext->sizey))/2), label, (unsigned char) DARK_BLUE, 1);
193 }
194 else
195 {
196 if (status == 1)
197 {
198 myscreen->draw_box(xloc,yloc,xend-1,yend-1,BUTTON_FACING-3,1,1); // front
199 myscreen->draw_box(xloc,yloc,xend-2,yloc,BUTTON_BOTTOM,1,1); // top edge
200 myscreen->draw_box(xloc,yloc+1,xloc,yend-2,BUTTON_RIGHT,1,1); // left
201 myscreen->draw_box(xend-1,yloc+1,xend-1,yend-2,BUTTON_LEFT,1,1); // right
202 myscreen->draw_box(xloc+1,yend-1,xend-1,yend-1,BUTTON_TOP,1,1); // bottom
203 if (strlen(label))
204 mytext->write_xy( (short) ( ((xloc+xend)/2) - (((strlen(label)-1)* (mytext->sizex+1) )/2)) ,
205 (short) (yloc + (height-(mytext->sizey))/2), label, (unsigned char) DARK_BLUE, 1);
206 myscreen->buffer_to_screen(xloc,yloc,xend-xloc,yend-yloc);
207 }
208 else if (status == 2) // special (red) button..
209 {
210 myscreen->draw_box(xloc,yloc,xend-1,yend-1,BUTTON_FACING+32,1,1); // front
211 myscreen->draw_box(xloc,yloc,xend-2,yloc,BUTTON_TOP+32,1,1); // top edge
212 myscreen->draw_box(xloc,yloc+1,xloc,yend-2,BUTTON_LEFT+32,1,1); // left
213 myscreen->draw_box(xend-1,yloc+1,xend-1,yend-2,BUTTON_RIGHT+32,1,1); // right
214 myscreen->draw_box(xloc+1,yend-1,xend-1,yend-1,BUTTON_BOTTOM+32,1,1); // bottom
215 if (strlen(label))
216 mytext->write_xy( (short) ( ((xloc+xend)/2) - (((strlen(label)-1)* (mytext->sizex+1) )/2)) ,
217 (short) (yloc + (height-(mytext->sizey))/2), label, (unsigned char) DARK_BLUE, 1);
218 }
219 }
220 release_mouse();
221 //buffers: myscreen->buffer_to_screen(0, 0, 320, 200);
222 // Zardus: following isn't really needed and it messes up the fading
223 //myscreen->buffer_to_screen(xloc,yloc,xend-xloc,yend-yloc);
224 grab_mouse();
225 }
226
leftclick()227 long vbutton::leftclick()
228 {
229 long whichone=0;
230 long retvalue=0;
231 // First check hotkeys ...
232 while (allbuttons[whichone])
233 {
234 retvalue = allbuttons[whichone]->leftclick(1);
235 if (retvalue != -1)
236 return retvalue;
237 whichone++;
238 }
239 // Now normal click ..
240 whichone = 0;
241 while (allbuttons[whichone])
242 {
243 retvalue = allbuttons[whichone]->leftclick(2);
244 if (retvalue != -1)
245 return retvalue;
246 whichone++;
247 }
248 return 0; // none worked
249 }
250
rightclick()251 long vbutton::rightclick()
252 {
253 long whichone=0;
254 long retvalue=0;
255 while (allbuttons[whichone])
256 {
257 retvalue = allbuttons[whichone]->rightclick(whichone);
258 if (retvalue != -1)
259 return retvalue;
260 whichone++;
261 }
262 return 0; // none worked
263 }
264
leftclick(long whichbutton)265 long vbutton::leftclick(long whichbutton)
266 {
267 long retvalue=0;
268 char * mousekeys = query_keyboard();
269 long dummy;
270
271 if (whichbutton == 1) // hotkeys
272 {
273 if (mousekeys[hotkey])
274 {
275 myscreen->soundp->play_sound(SOUND_BOW);
276 vdisplay(1);
277 vdisplay();
278 if (myfunc)
279 {
280 retvalue = do_call(myfunc, arg);
281 }
282 while (mousekeys[hotkey])
283 get_input_events(WAIT);
284 return retvalue;
285 }
286 }
287 else
288 {
289 if (mouse_on())
290 {
291 myscreen->soundp->play_sound(SOUND_BOW);
292 vdisplay(1);
293 vdisplay();
294 if (myfunc)
295 {
296 retvalue = do_call(myfunc, arg);
297 }
298 //else
299 // retvalue = fun(arg);
300 while (mousekeys[hotkey])
301 dummy = 1;
302 return retvalue;
303 //vdisplay();
304 }
305 }
306 return -1; // wasn't focused on us
307 }
308
rightclick(long whichbutton)309 long vbutton::rightclick(long whichbutton)
310 {
311 long retvalue=0;
312
313 if (whichbutton)
314 whichbutton = 1;
315 if (mouse_on())
316 {
317 myscreen->soundp->play_sound(SOUND_BOW);
318 vdisplay(1);
319 vdisplay();
320 if (myfunc)
321 {
322 retvalue = do_call_right(myfunc, arg);
323 }
324 return retvalue;
325 }
326
327 return -1; // wasn't focused on us
328 }
329
mouse_on()330 long vbutton::mouse_on()
331 {
332 long mousex,mousey;
333 mymouse = query_mouse();
334 mousex = mymouse[MOUSE_X];
335 mousey = mymouse[MOUSE_Y];
336
337 if (mousex > xloc && mousex < xend && mousey > yloc && mousey < yend)
338 {
339 if (!had_focus) // just gained focus
340 {
341 vdisplay();
342 // Zardus: FIX: comment release and grab mouse out cause there's no need for them here and they're causing choppyness on buttons
343 // release_mouse();
344 if (mypixie)
345 myscreen->draw_box(xloc-1, yloc-1, xend, yend, 27, 0, 1);
346 else
347 myscreen->draw_box(xloc-1, yloc-1, xend, yend, 27, 0, 1);
348 myscreen->buffer_to_screen(0, 0, 320, 200);
349 // grab_mouse();
350 had_focus = 1;
351 }
352 return 1;
353 }
354 else
355 {
356 if (had_focus)
357 {
358 vdisplay();
359 // release_mouse();
360 if (mypixie)
361 myscreen->draw_box(xloc-1, yloc-1, xend, yend, 0, 0, 1);
362 else
363 myscreen->draw_box(xloc-1, yloc-1, xend, yend, 0, 0, 1);
364 myscreen->buffer_to_screen(0, 0, 320, 200);
365 // grab_mouse();
366 had_focus = 0;
367 }
368 return 0;
369 }
370 }
371
ventermenu(vbutton * vbuttons)372 long ventermenu(vbutton * vbuttons)
373 {
374 vbutton * here; // = new vbutton();
375 if (vbuttons == NULL)
376 return 0; //if no buttons, exit
377 here = vbuttons;
378 while(here)
379 {
380 here->vdisplay();
381 here = here->next;
382 }
383 return 1;
384 }
385
vexitmenu(vbutton * vbuttons)386 long vexitmenu(vbutton * vbuttons)
387 {
388 vbutton * here; // = new vbutton();
389 vbutton * nextb; // = new vbutton();
390 if (!vbuttons)
391 return 0;
392 here = vbuttons;
393 while(here)
394 {
395 nextb = here->next;
396 delete(here);
397 here = nextb;
398 }
399 return 1;
400 }
401
buttonmenu(button * buttons,long numbuttons)402 vbutton * buttonmenu(button * buttons, long numbuttons)
403 {
404 //buffers: return buttonmenu(buttons, numbuttons, 1); // default is redraw screen
405 return buttonmenu(buttons,numbuttons,0);
406 }
407
buttonmenu(button * buttons,long numbuttons,long redraw)408 vbutton * buttonmenu(button * buttons, long numbuttons, long redraw)
409 {
410 long i;
411
412 for (i=1; i < MAX_BUTTONS; i++) // skip # 0!
413 {
414 if (allbuttons[i])
415 delete allbuttons[i];
416 allbuttons[i] = NULL;
417 }
418
419 for (i=0; i < 5; i++)
420 if (backdrops[i])
421 backdrops[i]->draw(myscreen->viewob[0]);
422
423 for (i=0; i < numbuttons; i++)
424 {
425 allbuttons[i] = new vbutton(buttons[i].x,buttons[i].y,
426 buttons[i].sizex, buttons[i].sizey,
427 buttons[i].myfun, buttons[i].arg1,
428 buttons[i].label, buttons[i].hotkey);
429 myscreen->draw_box(allbuttons[i]->xloc-1,
430 allbuttons[i]->yloc-1,
431 allbuttons[i]->xend,
432 allbuttons[i]->yend, 0, 0, 1);
433 }
434
435 release_mouse();
436
437 //if (redraw)
438 // myscreen->buffer_to_screen(0, 0, 320, 200);
439 grab_mouse();
440 return allbuttons[0];
441
442 }
443
444 //after this point old code
clearmenu(button * buttons,short numbuttons)445 void clearmenu(button *buttons, short numbuttons)
446 {
447 short i;
448
449 // First remove the mouse ..
450 release_mouse();
451 for (i=0; i < numbuttons; i++)
452 {
453 myscreen->fastbox(buttons[i].x-1,
454 buttons[i].y-1,
455 buttons[i].sizex+3,
456 buttons[i].sizey+3, 0, 1);
457 }
458 // Clear the WHOLE screen
459 //myscreen->clearbuffer();
460 //commented out temporarily to see if ok
461
462 // DARK_BLUEisplay the mouse
463 grab_mouse();
464 }
465
466 /*short buttonmenu(button *buttons, short numbuttons)
467 {
468 return buttonmenu(buttons, numbuttons, 0);
469 }
470
471 short buttonmenu(button *buttons, short numbuttons, short no_clear)
472 {
473 short buttonnum = 0;
474 short i;
475 //char input, temp;
476 //short color = 1;
477 long longtemp = 0;
478 // short DARK_BLUE=0, green=0, blue=0;
479 // char rdelta, gdelta, bdelta;
480 char *mykeyboard;
481 short dumbcount=0;
482 short cyclestage = 0;
483 short focuschanged = 1;
484
485 mykeyboard = query_keyboard(); // get keyboard state
486
487 release_mouse();
488
489 for (i=0; i < numbuttons; i++)
490 {
491 myscreen->draw_button(buttons[i].x,
492 buttons[i].y,
493 buttons[i].x+buttons[i].sizex,
494 buttons[i].y+buttons[i].sizey,2);
495 mytext->write_xy(buttons[i].x +
496 (buttons[i].sizex - (strlen(buttons[i].label)-1)*7)/2,
497 buttons[i].y + (buttons[i].sizey-6)/2,
498 buttons[i].label,(unsigned char) DARK_BLUE, 1);
499 }
500
501 // Highlight the current button number
502 myscreen->draw_box(buttons[buttonnum].x-1,
503 buttons[buttonnum].y-1,
504 buttons[buttonnum].x + buttons[buttonnum].sizex+1,
505 buttons[buttonnum].y + buttons[buttonnum].sizey+1, ORANGE_START, 0);
506
507 // myscreen->refresh();
508
509 grab_mouse();
510
511 // rdelta = (random(3)+1);
512 // gdelta = (random(3)+1);
513 // bdelta = (random(3)+1);
514
515 while(1)
516 {
517 ++longtemp %= 90;
518 // First cycle the colors ..
519 if (!random(80))
520 myscreen->do_cycle(cyclestage++, 8);
521
522 // Cheat key for more cash ..
523 if (mykeyboard[SDLK_CTRL])
524 {
525 if (mykeyboard[SDLK_KP_PLUS])
526 {
527 add_money((long)2);
528 return 1;
529 }
530 if (mykeyboard[SDLK_KP_MINUS])
531 {
532 add_money((long)-2);
533 return 1;
534 }
535 if (mykeyboard[SDLK_LEFTBRACKET]) // lower scen num
536 {
537 if (scen_level > 1)
538 scen_level--;
539 while (mykeyboard[SDLK_LEFTBRACKET])
540 dumbcount++;
541 return 1;
542 }
543 if (mykeyboard[SDLK_RIGHTBRACKET]) // raise scen num
544 {
545 scen_level++;
546 while (mykeyboard[SDLK_RIGHTBRACKET])
547 dumbcount++;
548 return 1;
549 }
550 }
551
552 // Mouse input loop ..
553 mymouse = query_mouse(); // get mouse status
554 for (i=0; i < numbuttons; i++)
555 {
556 if (i == buttonnum && focuschanged)
557 {
558 focuschanged = 0;
559 release_mouse();
560 myscreen->draw_box(buttons[i].x-1,
561 buttons[i].y-1,
562 buttons[i].x + buttons[i].sizex+1,
563 buttons[i].y + buttons[i].sizey+1, ORANGE_START, 0);
564 grab_mouse();
565 buttonnum = i;
566 } // changed selected button
567 if (i != buttonnum && focuschanged)
568 {
569 release_mouse();
570 myscreen->draw_box(buttons[i].x-1,
571 buttons[i].y-1,
572 buttons[i].x + buttons[i].sizex+1,
573 buttons[i].y + buttons[i].sizey+1, 0, 0);
574 grab_mouse();
575 }
576 if (has_mouse_focus(buttons[i]) )
577 {
578 if (i != buttonnum)
579 {
580 release_mouse();
581 myscreen->draw_box(buttons[buttonnum].x-1,
582 buttons[buttonnum].y-1,
583 buttons[buttonnum].x + buttons[buttonnum].sizex+1,
584 buttons[buttonnum].y + buttons[buttonnum].sizey+1,0, 0);
585 grab_mouse();
586 focuschanged = 1;
587 buttonnum = i;
588 }
589 if (mymouse[MOUSE_LEFT]) // have focus, button click
590 {
591 //release_mouse();
592 //fastbox(buttons[buttonnum].x-1,
593 // buttons[buttonnum].y-1,
594 // buttons[buttonnum].sizex+1,
595 // buttons[buttonnum].sizey+1,15);
596 //grab_mouse();
597 // Wait for mouse 'up'
598 while (mymouse[MOUSE_LEFT])
599 mymouse = query_mouse();
600 if (buttons[buttonnum].fun)
601 {
602 if (!no_clear)
603 clearmenu(buttons,numbuttons);
604 buttons[buttonnum].fun(buttons[buttonnum].arg1);
605 grab_mouse();
606 return 1;
607 }
608 else
609 {
610 if (!no_clear)
611 clearmenu(buttons,numbuttons);
612 grab_mouse();
613 return 0;
614 }
615 } // end of check for mouse click
616 } // end of check for mouse focus
617
618 if (mykeyboard[buttons[i].hotkey]) // just do ti
619 {
620 if (i != buttonnum)
621 {
622 release_mouse();
623 // fastbox(buttons[buttonnum].x-1,
624 // buttons[buttonnum].y-1,
625 // buttons[buttonnum].x+buttons[buttonnum].sizex+1,
626 // buttons[buttonnum].y+buttons[buttonnum].sizey+1,0);
627 grab_mouse();
628 buttonnum = i;
629 } // changed selected button
630 release_mouse();
631 // fastbox(buttons[buttonnum].x-1,
632 // buttons[buttonnum].y-1,
633 // buttons[buttonnum].x+buttons[buttonnum].sizex+1,
634 // buttons[buttonnum].y+buttons[buttonnum].sizey+1,15);
635 grab_mouse();
636 // Wait for release of key ..
637 while (mykeyboard[buttons[i].hotkey])
638 dumbcount++;
639 if (buttons[buttonnum].fun)
640 {
641 if (!no_clear)
642 clearmenu(buttons,numbuttons);
643 buttons[buttonnum].fun(buttons[buttonnum].arg1);
644 grab_mouse();
645 return 1;
646 }
647 else
648 {
649 if (!no_clear)
650 clearmenu(buttons,numbuttons);
651 grab_mouse();
652 return 0;
653 }
654 } // end of check for hot-key press
655 } // end of button-check loop
656
657 // input = 0;
658 // while(temp = get_SDLK_code())
659 // input = temp;
660
661 if (mykeyboard[SDLK_DOWN])
662 {
663 release_mouse();
664 myscreen->draw_box(buttons[buttonnum].x-1,
665 buttons[buttonnum].y-1,
666 buttons[buttonnum].x + buttons[buttonnum].sizex+1,
667 buttons[buttonnum].y + buttons[buttonnum].sizey+1,0, 0);
668 grab_mouse();
669 buttonnum++;
670 focuschanged = 1;
671 while (mykeyboard[SDLK_DOWN])
672 dumbcount++;
673 }
674 if (mykeyboard[SDLK_UP])
675 {
676 release_mouse();
677 myscreen->draw_box(buttons[buttonnum].x-1,
678 buttons[buttonnum].y-1,
679 buttons[buttonnum].x + buttons[buttonnum].sizex+1,
680 buttons[buttonnum].y + buttons[buttonnum].sizey+1,0, 0);
681 grab_mouse();
682 buttonnum--;
683 focuschanged = 1;
684 while (mykeyboard[SDLK_UP])
685 dumbcount++;
686 }
687 if (buttonnum < 0) buttonnum = numbuttons-1;
688 buttonnum = buttonnum % numbuttons;
689 //fastbox(buttons[buttonnum].x-1,
690 // buttons[buttonnum].y-1,
691 // buttons[buttonnum].x+buttons[buttonnum].sizex+1,
692 // buttons[buttonnum].y+buttons[buttonnum].sizey+1,14);
693
694 if (mykeyboard[SDLK_RETURN])
695 {
696 while (mykeyboard[SDLK_RETURN])
697 dumbcount++;
698 if (!no_clear)
699 clearmenu(buttons,numbuttons);
700 if (buttons[buttonnum].fun)
701 {
702 buttons[buttonnum].fun(buttons[buttonnum].arg1);
703 grab_mouse();
704 return 1;
705 }
706 else
707 {
708 grab_mouse();
709 return 0;
710 }
711 }
712 }
713 }
714 */
715
has_mouse_focus(button thisbutton)716 short has_mouse_focus(button thisbutton)
717 {
718 long *thismouse;
719
720 thismouse = query_mouse();
721
722 // Check the x and y boundaries of current button to determine
723 // if it has the mouse focus
724 if ( (thisbutton.x <= thismouse[MOUSE_X]) &&
725 (thismouse[MOUSE_X] <= (thisbutton.x + thisbutton.sizex) ) )
726 if ( (thisbutton.y <= thismouse[MOUSE_Y]) &&
727 (thismouse[MOUSE_Y] <= (thisbutton.y + thisbutton.sizey) ) )
728 return 1;
729
730 return 0;
731 }
732
do_call(long whatfunc,long arg)733 long vbutton::do_call(long whatfunc, long arg)
734 {
735 switch (whatfunc)
736 {
737 case BEGINMENU:
738 return beginmenu(arg);
739 case CREATE_TEAM_MENU:
740 return create_team_menu(arg);
741 case SET_PLAYER_MODE:
742 return set_player_mode(arg);
743 case QUIT_MENU:
744 return quit(arg);
745 case CREATE_VIEW_MENU:
746 return create_view_menu(arg);
747 case CREATE_EDIT_MENU:
748 return create_edit_menu(arg);
749 case CREATE_BUY_MENU:
750 return create_buy_menu(arg);
751 case CREATE_LOAD_MENU:
752 return create_load_menu(arg);
753 case CREATE_SAVE_MENU:
754 return create_save_menu(arg);
755 case GO_MENU:
756 return go_menu(arg);
757 case RETURN_MENU:
758 return arg;
759 case CYCLE_TEAM_GUY:
760 return cycle_team_guy(arg);
761 case DECREASE_STAT:
762 return decrease_stat(arg);
763 case INCREASE_STAT:
764 return increase_stat(arg);
765 case EDIT_GUY:
766 return edit_guy(arg);
767 case CYCLE_GUY:
768 return cycle_guy(arg);
769 case ADD_GUY:
770 return add_guy(arg);
771 case DO_SAVE:
772 return do_save(arg);
773 case DO_LOAD:
774 return do_load(arg);
775 case NAME_GUY: // name some guy
776 return name_guy(arg);
777 case CREATE_DETAIL_MENU:
778 return create_detail_menu(NULL);
779 case DO_SET_SCEN_LEVEL:
780 return do_set_scen_level(arg);
781 case SET_DIFFICULTY:
782 return set_difficulty();
783 case CHANGE_TEAM:
784 return change_teamnum(arg);
785 case CHANGE_HIRE_TEAM:
786 return change_hire_teamnum(arg);
787 case ALLIED_MODE:
788 return change_allied();
789 default:
790 return 4;
791 }
792 }
793
794 // For right-button
do_call_right(long whatfunc,long arg)795 long vbutton::do_call_right(long whatfunc, long arg)
796 {
797 switch (whatfunc)
798 {
799 case DECREASE_STAT:
800 return decrease_stat(arg, 5);
801 case INCREASE_STAT:
802 return increase_stat(arg, 5);
803 default:
804 return 4;
805 }
806 }
807
808