File: title.c

package info (click to toggle)
moon-buggy 1%3A1.0.51-15
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,316 kB
  • sloc: ansic: 3,824; sh: 3,567; makefile: 162
file content (107 lines) | stat: -rw-r--r-- 2,599 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* title.c - print the title page
 *
 * Copyright 1999, 2000, 2004  Jochen Voss  */

static const  char  rcsid[] = "$Id: title.c 6586 2005-11-13 13:34:29Z voss $";


#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "moon-buggy.h"


struct mode *title_mode;


const char *title [] = {
  "MM     MM   OOOOO    OOOOO   NN     N",
  "M M   M M  O     O  O     O  N N    N",
  "M  M M  M  O     O  O     O  N  N   N",
  "M   M   M  O     O  O     O  N   N  N",
  "M       M  O     O  O     O  N    N N",
  "M       M   OOOOO    OOOOO   N     NN",
  "",
  "      BBBBBB   U     U   GGGGG    GGGGG   Y     Y",
  "      B     B  U     U  G     G  G     G   Y   Y",
  "      BBBBBB   U     U  G        G          Y Y",
  "      B     B  U     U  G   GGG  G   GGG     Y",
  "      B     B  U     U  G     G  G     G    Y",
  "      BBBBBB    UUUUU    GGGGG    GGGGG   YY"
};


static void
print_title (void)
/* Print the title screen.  */
{
  int  title_lines = sizeof (title) / sizeof (const char *);

  mvwaddstr (moon, 0, 0, "  Moon-Buggy version "
	     VERSION ", Copyright 2004 Jochen Voss <voss@seehuhn.de>\n");
  waddstr (moon, "  Moon-Buggy comes with ABSOLUTELY NO WARRANTY;"
	   " for details type 'w'.\n");
  waddstr (moon,
	   "  This is free software, and you are welcome to redistribute it\n\
  under certain conditions; type 'c' for details.\n");

  if (5 + title_lines + 5 <= LINES) {
    int  top = (LINES-title_lines)/3.0 + 0.5;
    int  i;
    
    if (top < 5)  top = 5;
    for (i=0; i<title_lines; ++i) {
      mvwaddstr (moon, top+i, (COLS-49)/2, title[i]);
    }
  }

  if (5 + title_lines + 7 <= LINES
      || 5 + title_lines + 5 > LINES)  print_buggy ();

  wnoutrefresh (moon);
}

static void
title_redraw (void)
{
  resize_ground (1);
  print_ground ();
  print_title ();
}

static void
key_handler (game_time t, int val)
{
  switch (val) {
  case 1:
    mode_change (game_mode, 0);
    break;
  case 2:
    quit_main_loop ();
    break;
  case 3:
    mode_change (pager_mode, 0);
    break;
  case 4:
    mode_change (pager_mode, 1);
    break;
  case 5:
    mode_change (highscore_mode, 0);
    break;
  }
}

void
setup_title_mode (void)
{
  title_mode = new_mode ();
  title_mode->redraw = title_redraw;
  title_mode->keypress = key_handler;
  mode_add_key (title_mode, mbk_start, "start game", 1);
  mode_add_key (title_mode, mbk_end, "quit", 2);
  mode_add_key (title_mode, mbk_copyright, "show copyright", 3);
  mode_add_key (title_mode, mbk_warranty, "show warranty", 4);
  mode_add_key (title_mode, mbk_scores, "show scores", 5);
  mode_complete (title_mode);
}