~ubuntu-branches/ubuntu/precise/pingus/precise

« back to all changes in this revision

Viewing changes to src/pingus_menu_manager.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-02-28 19:44:25 UTC
  • mfrom: (4.1.4 hardy)
  • Revision ID: james.westby@ubuntu.com-20080228194425-e8ilohlijv02kgcf
Tags: 0.7.2-2
* Fix FTBFS with gcc-4.3 by adding the missing include in
  src/input/evdev_device.cpp (Closes: #462238):
   + debian/patches/20_fix_FTBFS_with_gcc-4.3.
* Rename former patch so that the filename reflects the order in which
  the patches are applied:
   - debian/patches/data_dir.patch
   + debian/patches/10_fix_data_directory.
* Bump Standards-Version from 3.7.2 to 3.7.3, no changes needed.
* Add a dh_desktop call in the arch-dep part of debian/rules.
* Adjust the “missing-dep-for-interpreter guile” override since lintian
  now lists an alternative for that dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//  $Id: pingus_menu_manager.cxx,v 1.25 2003/04/11 14:30:05 grumbel Exp $
2
 
//
3
 
//  Pingus - A free Lemmings clone
4
 
//  Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de>
5
 
//
6
 
//  This program is free software; you can redistribute it and/or
7
 
//  modify it under the terms of the GNU General Public License
8
 
//  as published by the Free Software Foundation; either version 2
9
 
//  of the License, or (at your option) any later version.
10
 
//
11
 
//  This program is distributed in the hope that it will be useful,
12
 
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
//  GNU General Public License for more details.
15
 
//
16
 
//  You should have received a copy of the GNU General Public License
17
 
//  along with this program; if not, write to the Free Software
18
 
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
 
 
20
 
#include <iostream>
21
 
#include <ClanLib/Display/Display/display.h>
22
 
#include "gui/screen_manager.hxx"
23
 
#include "sound/sound.hxx"
24
 
#include "pingus_menu_manager.hxx"
25
 
 
26
 
PingusMenuManager* PingusMenuManager::instance_ = 0;
27
 
 
28
 
PingusMenuManager::PingusMenuManager ()
29
 
  : mainmenu (this),
30
 
    exitmenu (this)
31
 
{
32
 
  push_menu (&mainmenu);
33
 
}
34
 
 
35
 
PingusMenuManager::~PingusMenuManager ()
36
 
{
37
 
}
38
 
 
39
 
bool
40
 
PingusMenuManager::draw (GraphicContext& gc)
41
 
{
42
 
  background.draw (gc);
43
 
  
44
 
  gc.draw_fillrect(0, CL_Display::get_height () - 22,
45
 
                   CL_Display::get_width (), CL_Display::get_height (),
46
 
                   0, 0, 0, 1.0f);
47
 
 
48
 
  for (MenuStackIter i = menu_stack.begin (); i != menu_stack.end (); ++i)
49
 
    (*i)->draw (gc);
50
 
 
51
 
  return true;
52
 
}
53
 
 
54
 
void
55
 
PingusMenuManager::update (const GameDelta& delta)
56
 
{
57
 
  background.update (delta.get_time ());
58
 
  // We copy the menu_stack so that we don't invalidate our
59
 
  // iterators when menu's are removed/added in update()
60
 
  //std::vector<PingusSubMenu *> tmp_menu_stack = menu_stack;
61
 
  /*for (MenuStackIter i = tmp_menu_stack.begin (); i != tmp_menu_stack.end (); ++i)
62
 
    (*i)->update (delta);*/
63
 
  menu_stack.back ()->update (delta);
64
 
}
65
 
 
66
 
void 
67
 
PingusMenuManager::set_menu (PingusSubMenu * menu)
68
 
{
69
 
  pop_menu ();
70
 
  push_menu (menu);
71
 
}
72
 
 
73
 
void 
74
 
PingusMenuManager::push_menu (PingusSubMenu * menu)
75
 
{
76
 
  menu->preload ();
77
 
  menu_stack.push_back (menu);
78
 
}
79
 
 
80
 
void 
81
 
PingusMenuManager::pop_menu ()
82
 
{
83
 
  if (!menu_stack.empty ())
84
 
    menu_stack.pop_back();
85
 
}
86
 
 
87
 
PingusSubMenu *
88
 
PingusMenuManager::current_menu ()
89
 
{
90
 
  if (!menu_stack.empty ())
91
 
    {
92
 
      MenuStackRIter i = menu_stack.rbegin ();
93
 
      if (! *i)
94
 
        std::cout << "PingusMenuManager: Error: current_menu is " << *i << std::endl;
95
 
      return *i;
96
 
    }
97
 
  else
98
 
    {
99
 
      std::cout << "PingusMenuManager: Error: MenuStack empty!" << std::endl;
100
 
      return 0;
101
 
    }
102
 
}
103
 
 
104
 
void 
105
 
PingusMenuManager::fadeout ()
106
 
{
107
 
  std::cout << "PingusMenuManager::fadeout () Not implemented" << std::endl;
108
 
#if 0
109
 
  DeltaManager delta_manager;
110
 
  EnlargingRectFadeOut fadeout;
111
 
 
112
 
  while (!fadeout.finished ())
113
 
    {
114
 
      float time_delta = delta_manager.getset ();
115
 
      fadeout.update (time_delta);
116
 
 
117
 
      current_menu ()->draw ();
118
 
      fadeout.draw ();
119
 
      Display::flip_display ();
120
 
 
121
 
      CL_System::keep_alive ();
122
 
    }
123
 
#endif 
124
 
}
125
 
 
126
 
void
127
 
PingusMenuManager::show_exit_menu ()
128
 
{
129
 
  push_menu (&exitmenu);
130
 
}
131
 
 
132
 
void
133
 
PingusMenuManager::exit ()
134
 
{
135
 
  //std::cout << "poping PingusMenuManager" << std::endl;
136
 
  ScreenManager::instance ()->pop_screen ();
137
 
}
138
 
 
139
 
void
140
 
PingusMenuManager::on_startup()
141
 
{
142
 
  PingusSound::play_music("pingus-1.it");
143
 
}
144
 
 
145
 
PingusMenuManager*
146
 
PingusMenuManager::instance ()
147
 
{
148
 
  if (instance_)
149
 
    return instance_;
150
 
  else
151
 
    return instance_ = new PingusMenuManager ();
152
 
}
153
 
 
154
 
void
155
 
PingusMenuManager::init()
156
 
{
157
 
  instance_ = 0;
158
 
}
159
 
 
160
 
void
161
 
PingusMenuManager::deinit()
162
 
{
163
 
  delete instance_;
164
 
}
165
 
 
166
 
/* EOF */