File: intro.cpp

package info (click to toggle)
monster-masher 1.8.1-7
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,072 kB
  • ctags: 706
  • sloc: cpp: 4,874; sh: 896; makefile: 126
file content (164 lines) | stat: -rw-r--r-- 5,109 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/* Implementation of Intro class.
 *
 * Copyright (c) 2003, 04 Ole Laursen.
 *
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License as 
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA.
 */

#include <config.h>
#include <gdk/gdkkeysyms.h>

#include "intro.hpp"

#include "main-window.hpp"
#include "i18n.hpp"

Intro::Intro()
  : state(0)
{
  Glib::signal_timeout()
    .connect(sigc::mem_fun(*this, &Intro::main_loop), 1000 / iterations_per_sec);

  update();			// setup first screen
}

Intro::~Intro()
{
  MainWindow::instance().remove_message();
}

void Intro::key_pressed(unsigned int keyval)
{
  switch (keyval) {
  case GDK_space:
  case GDK_Return:
  case GDK_KP_Enter:
    {
      bool changed;
      do {
	changed = update();
      } while (!changed);
    }
    break;

  case GDK_Escape:
    MainWindow::instance().intro_finished();
    break;
  }
}

bool Intro::main_loop()
{
  update();

  return true;
}

bool Intro::update()
{
  MainWindow &mw = MainWindow::instance();

  bool changed = true;
  
  int sum = 0;
  
  if (state == sum)
    mw.display_message(_("In the old days, before man entered the "
			 "world, the gnomes were abundant."), false);
  else if (state == (sum += 5))
    mw.display_message(_("Through centuries of hard labour, only "
			 "slightly eased by the levitational "
			 "powers provided to them by their god, "
			 "they bored out shafts and caves in the "
			 "mountains."), false);
  else if (state == (sum += 10))
    mw.display_message(_("Always seeking the precious stones and "
			 "valuable ore..."), false);
  else if (state == (sum += 5))
    mw.display_message(_("But one clan dug deeper than the "
			 "others. Only its wealth was growing "
			 "quicker than its greed."), false);
  else if (state == (sum += 7))
    mw.display_message(_("The years went by. The chief of the "
			 "clan became the king of the gnomes. "
			 "Thousands of men, women and children "
			 "were sent to work in the deepest, most "
			 "profitable mines."), false);
  else if (state == (sum += 10))
    mw.display_message(_("Then one day a large deposit of coal "
			 "was found. Or so it was thought..."), false);
  else if (state == (sum += 6))
    mw.display_message(_("From the black carbon, a strange "
			 "creature rose!"), false);
  else if (state == (sum += 5))
    mw.display_message(_("The first moments of surprise among "
			 "the workers were replaced with horror "
			 "as hundreds of other shapes broke out "
			 "of the vein, crushing everything and "
			 "everybody on their way."), false);
  else if (state == (sum += 10))
    mw.display_message(_("For months, the clan fought the "
			 "monsters. Only a handful of messengers "
			 "sent out to warn the other clans "
			 "survived."), false);
  else if (state == (sum += 7))
    mw.display_message(_("The world of the gnomes was "
			 "threatened..."), false);
  else if (state == (sum += 5))
    mw.display_message(_("By the black monsters made of carbon "
			 "harder than steel, mechanical in their "
			 "stupidity; but deadly."), false);
  else if (state == (sum += 8))
    mw.display_message(_("By the armoured monsters so "
			 "well-protected that only the bed-rock "
			 "was hard enough to slay them."), false);
  else if (state == (sum += 8))
    mw.display_message(_("By the seekers, sneaky and tricky, red "
			 "from the gnome blood that their spikes "
			 "had spilled."), false);
  else if (state == (sum += 8))
    mw.display_message(_("And by the blue egg layers that "
			 "multiplied their number by thousands."), false);
  else if (state == (sum += 7))
    mw.display_message(_("The only remaining hope of the gnomes "
			 "was a humble levitation worker. He had "
			 "found a way to mash the monsters "
			 "against the mountain rocks."), false);
  else if (state == (sum += 10))
    mw.display_message(_("That hope is you."), false);
  else if (state == (sum += 5))
    mw.display_message(_("You must battle your way deep into the "
			 "mountains, past each of the levels of "
			 "the clan of the kings and clear the way "
			 "for the rock summoners to block the "
			 "vein."), false);
  else if (state == (sum += 10))
    mw.display_message(_("Only then can the gnomes survive..."), false);
  else if (state == (sum += 12))
    ;				// do nothing, just wait
  else if (state >= (sum += 1))
  {
    mw.intro_finished();
    // this Intro has just been deleted, so return immediately
    return true;
  }
  else
    changed = false;
    
  ++state;
  
  return changed;
}