1 /* title.c - print the title page
2  *
3  * Copyright 1999, 2000, 2004  Jochen Voss  */
4 
5 static const  char  rcsid[] = "$Id: title.c 6586 2005-11-13 13:34:29Z voss $";
6 
7 
8 #ifdef HAVE_CONFIG_H
9 #include <config.h>
10 #endif
11 
12 #include "moon-buggy.h"
13 
14 
15 struct mode *title_mode;
16 
17 
18 const char *title [] = {
19   "MM     MM   OOOOO    OOOOO   NN     N",
20   "M M   M M  O     O  O     O  N N    N",
21   "M  M M  M  O     O  O     O  N  N   N",
22   "M   M   M  O     O  O     O  N   N  N",
23   "M       M  O     O  O     O  N    N N",
24   "M       M   OOOOO    OOOOO   N     NN",
25   "",
26   "      BBBBBB   U     U   GGGGG    GGGGG   Y     Y",
27   "      B     B  U     U  G     G  G     G   Y   Y",
28   "      BBBBBB   U     U  G        G          Y Y",
29   "      B     B  U     U  G   GGG  G   GGG     Y",
30   "      B     B  U     U  G     G  G     G    Y",
31   "      BBBBBB    UUUUU    GGGGG    GGGGG   YY"
32 };
33 
34 
35 static void
print_title(void)36 print_title (void)
37 /* Print the title screen.  */
38 {
39   int  title_lines = sizeof (title) / sizeof (const char *);
40 
41   mvwaddstr (moon, 0, 0, "  Moon-Buggy version "
42 	     VERSION ", Copyright 2004 Jochen Voss <voss@seehuhn.de>\n");
43   waddstr (moon, "  Moon-Buggy comes with ABSOLUTELY NO WARRANTY;"
44 	   " for details type 'w'.\n");
45   waddstr (moon,
46 	   "  This is free software, and you are welcome to redistribute it\n\
47   under certain conditions; type 'c' for details.\n");
48 
49   if (5 + title_lines + 5 <= LINES) {
50     int  top = (LINES-title_lines)/3.0 + 0.5;
51     int  i;
52 
53     if (top < 5)  top = 5;
54     for (i=0; i<title_lines; ++i) {
55       mvwaddstr (moon, top+i, (COLS-49)/2, title[i]);
56     }
57   }
58 
59   if (5 + title_lines + 7 <= LINES
60       || 5 + title_lines + 5 > LINES)  print_buggy ();
61 
62   wnoutrefresh (moon);
63 }
64 
65 static void
title_redraw(void)66 title_redraw (void)
67 {
68   resize_ground (1);
69   print_ground ();
70   print_title ();
71 }
72 
73 static void
key_handler(game_time t,int val)74 key_handler (game_time t, int val)
75 {
76   switch (val) {
77   case 1:
78     mode_change (game_mode, 0);
79     break;
80   case 2:
81     quit_main_loop ();
82     break;
83   case 3:
84     mode_change (pager_mode, 0);
85     break;
86   case 4:
87     mode_change (pager_mode, 1);
88     break;
89   case 5:
90     mode_change (highscore_mode, 0);
91     break;
92   }
93 }
94 
95 void
setup_title_mode(void)96 setup_title_mode (void)
97 {
98   title_mode = new_mode ();
99   title_mode->redraw = title_redraw;
100   title_mode->keypress = key_handler;
101   mode_add_key (title_mode, mbk_start, "start game", 1);
102   mode_add_key (title_mode, mbk_end, "quit", 2);
103   mode_add_key (title_mode, mbk_copyright, "show copyright", 3);
104   mode_add_key (title_mode, mbk_warranty, "show warranty", 4);
105   mode_add_key (title_mode, mbk_scores, "show scores", 5);
106   mode_complete (title_mode);
107 }
108