1
// $Id: pingus_menu_manager.cxx,v 1.25 2003/04/11 14:30:05 grumbel Exp $
3
// Pingus - A free Lemmings clone
4
// Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de>
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.
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.
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.
21
#include <ClanLib/Display/Display/display.h>
22
#include "gui/screen_manager.hxx"
23
#include "sound/sound.hxx"
24
#include "pingus_menu_manager.hxx"
26
PingusMenuManager* PingusMenuManager::instance_ = 0;
28
PingusMenuManager::PingusMenuManager ()
32
push_menu (&mainmenu);
35
PingusMenuManager::~PingusMenuManager ()
40
PingusMenuManager::draw (GraphicContext& gc)
44
gc.draw_fillrect(0, CL_Display::get_height () - 22,
45
CL_Display::get_width (), CL_Display::get_height (),
48
for (MenuStackIter i = menu_stack.begin (); i != menu_stack.end (); ++i)
55
PingusMenuManager::update (const GameDelta& delta)
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);
67
PingusMenuManager::set_menu (PingusSubMenu * menu)
74
PingusMenuManager::push_menu (PingusSubMenu * menu)
77
menu_stack.push_back (menu);
81
PingusMenuManager::pop_menu ()
83
if (!menu_stack.empty ())
84
menu_stack.pop_back();
88
PingusMenuManager::current_menu ()
90
if (!menu_stack.empty ())
92
MenuStackRIter i = menu_stack.rbegin ();
94
std::cout << "PingusMenuManager: Error: current_menu is " << *i << std::endl;
99
std::cout << "PingusMenuManager: Error: MenuStack empty!" << std::endl;
105
PingusMenuManager::fadeout ()
107
std::cout << "PingusMenuManager::fadeout () Not implemented" << std::endl;
109
DeltaManager delta_manager;
110
EnlargingRectFadeOut fadeout;
112
while (!fadeout.finished ())
114
float time_delta = delta_manager.getset ();
115
fadeout.update (time_delta);
117
current_menu ()->draw ();
119
Display::flip_display ();
121
CL_System::keep_alive ();
127
PingusMenuManager::show_exit_menu ()
129
push_menu (&exitmenu);
133
PingusMenuManager::exit ()
135
//std::cout << "poping PingusMenuManager" << std::endl;
136
ScreenManager::instance ()->pop_screen ();
140
PingusMenuManager::on_startup()
142
PingusSound::play_music("pingus-1.it");
146
PingusMenuManager::instance ()
151
return instance_ = new PingusMenuManager ();
155
PingusMenuManager::init()
161
PingusMenuManager::deinit()