3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MAINMENUMANAGER_HEADER
21 #define MAINMENUMANAGER_HEADER
24 All kinds of stuff that needs to be exposed from main.cpp
26 #include "debug.h" // assert
27 #include "modalMenu.h"
33 virtual void exitToOS() = 0;
34 virtual void disconnect() = 0;
35 virtual void changePassword() = 0;
36 virtual void changeVolume() = 0;
39 extern gui::IGUIEnvironment* guienv;
40 extern gui::IGUIStaticText *guiroot;
42 // Handler for the modal menus
44 class MainMenuManager : public IMenuManager
47 virtual void createdMenu(GUIModalMenu *menu)
49 for(std::list<GUIModalMenu*>::iterator
51 i != m_stack.end(); ++i)
56 if(m_stack.size() != 0)
57 m_stack.back()->setVisible(false);
58 m_stack.push_back(menu);
61 virtual void deletingMenu(GUIModalMenu *menu)
63 // Remove all entries if there are duplicates
66 removed_entry = false;
67 for(std::list<GUIModalMenu*>::iterator
69 i != m_stack.end(); ++i)
78 }while(removed_entry);
80 /*core::list<GUIModalMenu*>::Iterator i = m_stack.getLast();
84 if(m_stack.size() != 0)
85 m_stack.back()->setVisible(true);
88 // Returns true to prevent further processing
89 virtual bool preprocessEvent(const SEvent& event)
91 if(m_stack.size() != 0)
92 return m_stack.back()->preprocessEvent(event);
99 return m_stack.size();
104 for(std::list<GUIModalMenu*>::iterator
105 i = m_stack.begin(); i != m_stack.end(); ++i)
107 if((*i)->pausesGame())
113 std::list<GUIModalMenu*> m_stack;
116 extern MainMenuManager g_menumgr;
118 extern bool noMenuActive();
120 class MainGameCallback : public IGameCallback
123 MainGameCallback(IrrlichtDevice *a_device):
124 disconnect_requested(false),
125 changepassword_requested(false),
126 changevolume_requested(false),
127 shutdown_requested(false),
132 virtual void exitToOS()
134 shutdown_requested = true;
136 device->closeDevice();
140 virtual void disconnect()
142 disconnect_requested = true;
145 virtual void changePassword()
147 changepassword_requested = true;
150 virtual void changeVolume()
152 changevolume_requested = true;
155 bool disconnect_requested;
156 bool changepassword_requested;
157 bool changevolume_requested;
158 bool shutdown_requested;
159 IrrlichtDevice *device;
162 extern MainGameCallback *g_gamecallback;