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 keyConfig() = 0;
35 virtual void disconnect() = 0;
36 virtual void changePassword() = 0;
37 virtual void changeVolume() = 0;
39 virtual void signalKeyConfigChange() = 0;
42 extern gui::IGUIEnvironment *guienv;
43 extern gui::IGUIStaticText *guiroot;
45 // Handler for the modal menus
47 class MainMenuManager : public IMenuManager
50 virtual void createdMenu(gui::IGUIElement *menu)
52 for(std::list<gui::IGUIElement*>::iterator
54 i != m_stack.end(); ++i)
60 m_stack.back()->setVisible(false);
61 m_stack.push_back(menu);
64 virtual void deletingMenu(gui::IGUIElement *menu)
66 // Remove all entries if there are duplicates
69 removed_entry = false;
70 for(std::list<gui::IGUIElement*>::iterator
72 i != m_stack.end(); ++i)
81 }while(removed_entry);
83 /*core::list<GUIModalMenu*>::Iterator i = m_stack.getLast();
88 m_stack.back()->setVisible(true);
91 // Returns true to prevent further processing
92 virtual bool preprocessEvent(const SEvent& event)
96 GUIModalMenu *mm = dynamic_cast<GUIModalMenu*>(m_stack.back());
97 return mm && mm->preprocessEvent(event);
102 return m_stack.size();
107 for(std::list<gui::IGUIElement*>::iterator
108 i = m_stack.begin(); i != m_stack.end(); ++i)
110 GUIModalMenu *mm = dynamic_cast<GUIModalMenu*>(*i);
111 if (mm && mm->pausesGame())
117 std::list<gui::IGUIElement*> m_stack;
120 extern MainMenuManager g_menumgr;
122 extern bool noMenuActive();
124 class MainGameCallback : public IGameCallback
127 MainGameCallback(IrrlichtDevice *a_device):
128 disconnect_requested(false),
129 changepassword_requested(false),
130 changevolume_requested(false),
131 keyconfig_requested(false),
132 shutdown_requested(false),
133 keyconfig_changed(false),
138 virtual void exitToOS()
140 shutdown_requested = true;
142 device->closeDevice();
146 virtual void disconnect()
148 disconnect_requested = true;
151 virtual void changePassword()
153 changepassword_requested = true;
156 virtual void changeVolume()
158 changevolume_requested = true;
161 virtual void keyConfig()
163 keyconfig_requested = true;
166 virtual void signalKeyConfigChange()
168 keyconfig_changed = true;
172 bool disconnect_requested;
173 bool changepassword_requested;
174 bool changevolume_requested;
175 bool keyconfig_requested;
176 bool shutdown_requested;
178 bool keyconfig_changed;
180 IrrlichtDevice *device;
183 extern MainGameCallback *g_gamecallback;