Added #define WATER_ALPHA in content_mapnode.cpp
[oweals/minetest.git] / src / main.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
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 General Public License for more details.
14
15 You should have received a copy of the GNU 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.
18 */
19
20 #ifndef MAIN_HEADER
21 #define MAIN_HEADER
22
23 // Settings
24 #include "utility.h"
25 extern Settings g_settings;
26
27 // This makes and maps textures
28 class ITextureSource;
29 extern ITextureSource *g_texturesource;
30
31 // Global profiler
32 #include "profiler.h"
33 extern Profiler g_profiler;
34
35 // Debug streams
36
37 #include <fstream>
38
39 extern std::ostream *dout_con_ptr;
40 extern std::ostream *derr_con_ptr;
41 extern std::ostream *dout_client_ptr;
42 extern std::ostream *derr_client_ptr;
43 extern std::ostream *dout_server_ptr;
44 extern std::ostream *derr_server_ptr;
45
46 #define dout_con (*dout_con_ptr)
47 #define derr_con (*derr_con_ptr)
48 #define dout_client (*dout_client_ptr)
49 #define derr_client (*derr_client_ptr)
50 #define dout_server (*dout_server_ptr)
51 #define derr_server (*derr_server_ptr)
52
53 /*
54         All kinds of stuff that needs to be exposed from main.cpp
55 */
56
57 #include "modalMenu.h"
58 #include "guiPauseMenu.h" //For IGameCallback
59
60 extern gui::IGUIEnvironment* guienv;
61 extern gui::IGUIStaticText *guiroot;
62
63 // Handler for the modal menus
64
65 class MainMenuManager : public IMenuManager
66 {
67 public:
68         virtual void createdMenu(GUIModalMenu *menu)
69         {
70                 for(core::list<GUIModalMenu*>::Iterator
71                                 i = m_stack.begin();
72                                 i != m_stack.end(); i++)
73                 {
74                         assert(*i != menu);
75                 }
76
77                 if(m_stack.size() != 0)
78                         (*m_stack.getLast())->setVisible(false);
79                 m_stack.push_back(menu);
80         }
81
82         virtual void deletingMenu(GUIModalMenu *menu)
83         {
84                 // Remove all entries if there are duplicates
85                 bool removed_entry;
86                 do{
87                         removed_entry = false;
88                         for(core::list<GUIModalMenu*>::Iterator
89                                         i = m_stack.begin();
90                                         i != m_stack.end(); i++)
91                         {
92                                 if(*i == menu)
93                                 {
94                                         m_stack.erase(i);
95                                         removed_entry = true;
96                                         break;
97                                 }
98                         }
99                 }while(removed_entry);
100
101                 /*core::list<GUIModalMenu*>::Iterator i = m_stack.getLast();
102                 assert(*i == menu);
103                 m_stack.erase(i);*/
104                 
105                 if(m_stack.size() != 0)
106                         (*m_stack.getLast())->setVisible(true);
107         }
108
109         u32 menuCount()
110         {
111                 return m_stack.size();
112         }
113
114         core::list<GUIModalMenu*> m_stack;
115 };
116
117 extern MainMenuManager g_menumgr;
118
119 extern bool noMenuActive();
120
121 class MainGameCallback : public IGameCallback
122 {
123 public:
124         MainGameCallback(IrrlichtDevice *a_device):
125                 disconnect_requested(false),
126                 changepassword_requested(false),
127                 device(a_device)
128         {
129         }
130
131         virtual void exitToOS()
132         {
133                 device->closeDevice();
134         }
135
136         virtual void disconnect()
137         {
138                 disconnect_requested = true;
139         }
140
141         virtual void changePassword()
142         {
143                 changepassword_requested = true;
144         }
145
146         bool disconnect_requested;
147         bool changepassword_requested;
148         IrrlichtDevice *device;
149 };
150
151 extern MainGameCallback *g_gamecallback;
152
153 #endif
154