home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / TOP / USR / SRC / yahtzee.t.Z / yahtzee.t / help.c < prev    next >
Text File  |  1988-07-28  |  2KB  |  83 lines

  1. /* help.c
  2.  *    interactive help routines available at all stages of play.
  3.  */
  4. #include <curses.h>
  5. #include "defs.h"
  6. #include "help.h"
  7.  
  8. extern int BadStandout;
  9.  
  10. /* help_out is the main help routine, 'help_scr' is the number of the
  11.  * help page to be displayed (see help.h), the window that help is
  12.  * requested for is 'screen' (this will be overwritten and must be
  13.  * redrawn at the end of this procedure) */
  14. help_out(help_scr, screen)
  15.  
  16. int help_scr;
  17. WINDOW *screen;
  18.  
  19.     {
  20.     int tmp_y, tmp_x, i;
  21.     char ch;
  22.     WINDOW *help;
  23.  
  24. /* move the cursor to the top of the back window as initialisation
  25.  * of this routine can take a few seconds on a slow machine (leaving
  26.  * an impatient user wondering what key to hit to get help working) */
  27.     getyx(screen, tmp_y, tmp_x);
  28.     wmove(screen, 0, 0);
  29.     wrefresh(screen);
  30.  
  31. /* create the help window */
  32.     help = newwin(max_lines, max_cols, 4, 15);
  33.     BoxUp(help, max_lines, max_cols);
  34.  
  35. /* move the relevant data to the window */
  36.     for (i = 0; help_words[help_scr][i][0] != '\0'; ++i)
  37.         mvwaddstr(help, i + 1, 1, help_words[help_scr][i]);
  38.     mvwaddstr(help, max_lines - 2, 1, "--(q)uit--");
  39. #ifndef SYS5_3
  40.     wrefresh(help);
  41. #endif
  42.     do
  43.         {
  44.         ch = wgetch(help);
  45.         switch (ch)
  46.             {
  47.             case Form_Feed : redraw(help);
  48.                    break;
  49.             case '?' : help_out(5, help);
  50.                    break;
  51.             case 'b' : rools(help);
  52.                    break;
  53.             case 's' : dis_score(help);
  54.                    break;
  55.             case '!' : shell(help);
  56.                    break;
  57.             case 'v' : version(help);
  58.                    break;
  59. #if defined(SYS5) || defined(SYS5_3)
  60.             case '$' : shwin(help);
  61.                    break;
  62.             case 'q' :
  63.             case ' ' : break;
  64.             default : flash();
  65.                   break;
  66. #endif
  67.             }
  68.         } while (ch != 'q' && ch != ' ');
  69.  
  70. /* remove the input prompt */
  71.     mvwaddstr(help, max_lines - 2, 1, "               ");
  72.     wmove(help, 0, 0);
  73.     wrefresh(help);
  74.  
  75. /* get rid of help window */
  76.     delwin(help);
  77.  
  78. /* restore previous window */
  79.     touchwin(screen);
  80.     wmove(screen, tmp_y, tmp_x);
  81.     wrefresh(screen);
  82.     }
  83.