home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Games / xpipeman / popup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  6.5 KB  |  232 lines

  1. /*
  2.  * popup.c  - Xpipeman
  3.  *
  4.  * Send Constructive comments, bug reports, etc. to either
  5.  *
  6.  *          JANET: pavern@uk.ac.man.cs
  7.  *
  8.  *  or      INER : pavern%cs.man.ac.uk@nsfnet-relay.ac.uk
  9.  *
  10.  * All other comments > /dev/null !!
  11.  * 
  12.  * Copyright 1991 Nigel Paver
  13.  * 
  14.  * Permission to use, copy, modify, distribute, and sell this software and its
  15.  * documentation for any purpose is hereby granted without fee, provided that
  16.  * the above copyright notice appear in all copies and that both that
  17.  * copyright notice and this permission notice appear in supporting
  18.  * documentation, and that the author's name not be used in advertising or
  19.  * publicity pertaining to distribution of the software without specific,
  20.  * written prior permission.  The author makes no representations about the
  21.  * suitability of this software for any purpose.  It is provided "as is"
  22.  * without express or implied warranty.
  23.  * 
  24.  * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 
  25.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE 
  26.  * AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 
  27.  * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 
  28.  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 
  29.  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  30.  * 
  31.  */
  32.  
  33. #include <X11/Intrinsic.h>
  34. #include <X11/StringDefs.h>
  35. #include <X11/Shell.h>
  36.  
  37. #ifdef R3
  38. #include <X11/Box.h>
  39. #include <X11/Command.h>
  40. #include <X11/Label.h>
  41. #else
  42. #include <X11/Xaw/Box.h>
  43. #include <X11/Xaw/Command.h>
  44. #include <X11/Xaw/Label.h>
  45. #endif
  46.  
  47. #include "xpipeman.h"
  48.  
  49.  
  50.  
  51. Widget game_over_popup,level_over_popup,nomore_popup;
  52. int game_over_visible,level_over_visible,nomore_visible;
  53.  
  54. void
  55. show_level_over_popup()
  56. {
  57.   level_over_visible=1;
  58.   XtPopup(level_over_popup, XtGrabNone);
  59. }
  60.  
  61. void
  62. level_over_popdown()
  63. {
  64.  if (level_over_visible)  XtPopdown(level_over_popup);
  65.  level_over_visible=0;
  66.  
  67. }
  68.  
  69. void
  70. show_game_over_popup()
  71. {
  72.   game_over_visible=1;
  73.   XtPopup(game_over_popup, XtGrabNone);
  74. }
  75.  
  76. void
  77. game_over_popdown()
  78. {
  79.   if (game_over_visible ) XtPopdown(game_over_popup);
  80.   game_over_visible=0;
  81. }
  82.  
  83. void
  84. show_nomore_popup()
  85. {
  86.   nomore_visible=1;
  87.   XtPopup(nomore_popup, XtGrabNone);
  88. }
  89.  
  90. void
  91. nomore_popdown()
  92. {
  93.   if (nomore_visible) XtPopdown(nomore_popup);
  94.   nomore_visible=0;
  95. }
  96.  
  97. void
  98. all_popdown()
  99. {   /* remove all popups */
  100.  nomore_popdown();
  101.  game_over_popdown();
  102.  level_over_popdown();
  103. }
  104.  
  105. static Arg arglist_game_over_label[] = {
  106.   {  XtNborderWidth, (XtArgVal) 0  },
  107.   {  XtNresize, (XtArgVal) False  },
  108.   {  XtNwidth, (XtArgVal) 320   },
  109.   {  XtNheight, (XtArgVal) 50   },
  110.   {  XtNlabel, (XtArgVal) "Game Over"  },
  111.   {  XtNjustify, (XtArgVal) XtJustifyCenter  },
  112. };
  113.  
  114. static Arg arglist_level_over_label[] = {
  115.   {  XtNborderWidth, (XtArgVal) 0  },
  116.   {  XtNresize, (XtArgVal) False  },
  117.   {  XtNwidth, (XtArgVal) 320   },
  118.   {  XtNheight, (XtArgVal) 50   },
  119.   {  XtNlabel, (XtArgVal) "Level Over"  },
  120.   {  XtNjustify, (XtArgVal) XtJustifyCenter  },
  121. };
  122.  
  123. static Arg arglist_nomore_label[] = {
  124.   {  XtNborderWidth, (XtArgVal) 0  },
  125.   {  XtNresize, (XtArgVal) False  },
  126.   {  XtNwidth, (XtArgVal) 320   },
  127.   {  XtNheight, (XtArgVal) 50   },
  128.   {  XtNlabel, (XtArgVal) "Sorry, No More Levels.."  },
  129.   {  XtNjustify, (XtArgVal) XtJustifyCenter  },
  130. };
  131.  
  132. static Arg arglist_continue_button[] = {
  133.   {  XtNresize, (XtArgVal) False  },
  134.   {  XtNwidth, (XtArgVal) 320   },
  135.   {  XtNlabel, (XtArgVal) "Press to Continue"  },
  136.   {  XtNjustify, (XtArgVal) XtJustifyCenter  },
  137. };
  138.  
  139. /*ARGSUSED*/
  140. static XtCallbackProc 
  141. continue_callback(w, closure, call_data)
  142.   Widget w;
  143.   caddr_t closure;
  144.   caddr_t call_data;
  145. {
  146.  level_over_popdown();
  147.  start_new_level();
  148. }
  149.  
  150. void
  151. create_general_popups(parent)
  152.   Widget parent;
  153. {
  154.   int i;
  155.   Widget info_msg, game_over_box,level_over_box,continue_button,nomore_box;
  156.   Arg wargs[1];
  157.   char *message;
  158.   
  159.   game_over_popup = XtCreatePopupShell(
  160.                                    "game_over",
  161.                                    transientShellWidgetClass,
  162.                                    parent, 0,0);
  163.  
  164.   game_over_box = XtCreateManagedWidget(
  165.                                     "game_over_box",
  166.                                     boxWidgetClass,
  167.                                     game_over_popup,
  168.                                     0,0);
  169.  
  170.    (void)XtCreateManagedWidget(
  171.                                     "game_over_label",
  172.                                     labelWidgetClass,
  173.                                     game_over_box,
  174.                                     arglist_game_over_label,
  175.                                     XtNumber(arglist_game_over_label));
  176.  
  177.  
  178.   
  179.   nomore_popup = XtCreatePopupShell(
  180.                                    "nomore",
  181.                                    transientShellWidgetClass,
  182.                                    parent, 0,0);
  183.  
  184.   nomore_box = XtCreateManagedWidget(
  185.                                     "nomore_box",
  186.                                     boxWidgetClass,
  187.                                     nomore_popup,
  188.                                     0,0);
  189.  
  190.    (void)XtCreateManagedWidget(
  191.                                     "nomore_label",
  192.                                     labelWidgetClass,
  193.                                     nomore_box,
  194.                                     arglist_nomore_label,
  195.                                     XtNumber(arglist_nomore_label));
  196.  
  197.  
  198.   level_over_popup = XtCreatePopupShell(
  199.                                    "level_over",
  200.                                    transientShellWidgetClass,
  201.                                    parent, 0,0);
  202.  
  203.   level_over_box = XtCreateManagedWidget(
  204.                                     "level_over_box",
  205.                                     boxWidgetClass,
  206.                                     level_over_popup,
  207.                                     0,0);
  208.  
  209.    (void)XtCreateManagedWidget(
  210.                                     "level_over_label",
  211.                                     labelWidgetClass,
  212.                                     level_over_box,
  213.                                     arglist_level_over_label,
  214.                                     XtNumber(arglist_level_over_label));
  215.  
  216.   continue_button = XtCreateManagedWidget(
  217.                                     "Continue",
  218.                                     commandWidgetClass,
  219.                                     level_over_box,
  220.                                     arglist_continue_button,
  221.                     XtNumber(arglist_continue_button));
  222.  
  223.   XtAddCallback(continue_button,XtNcallback,continue_callback,0);
  224.  
  225.   nomore_visible=0;
  226.   game_over_visible=0;
  227.   level_over_visible=0;
  228.  
  229. }
  230.  
  231.  
  232.