X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmainmenumanager.h;h=ea9327813407e03dae232ebfaba72cb6793dd84e;hb=5f489efc69e5e8e31891481d412ad569a6e1bcf8;hp=28fe1ac116a6707906aebe7fec5ffa72ad3e5ddc;hpb=1cc40c0a7c260f0562572bc99f39a666a12f1b09;p=oweals%2Fminetest.git diff --git a/src/mainmenumanager.h b/src/mainmenumanager.h index 28fe1ac11..ea9327813 100644 --- a/src/mainmenumanager.h +++ b/src/mainmenumanager.h @@ -17,26 +17,28 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef MAINMENUMANAGER_HEADER -#define MAINMENUMANAGER_HEADER +#pragma once /* All kinds of stuff that needs to be exposed from main.cpp */ -#include "debug.h" // assert #include "modalMenu.h" +#include #include class IGameCallback { public: virtual void exitToOS() = 0; + virtual void keyConfig() = 0; virtual void disconnect() = 0; virtual void changePassword() = 0; virtual void changeVolume() = 0; + + virtual void signalKeyConfigChange() = 0; }; -extern gui::IGUIEnvironment* guienv; +extern gui::IGUIEnvironment *guienv; extern gui::IGUIStaticText *guiroot; // Handler for the modal menus @@ -44,27 +46,26 @@ extern gui::IGUIStaticText *guiroot; class MainMenuManager : public IMenuManager { public: - virtual void createdMenu(GUIModalMenu *menu) + virtual void createdMenu(gui::IGUIElement *menu) { - for(std::list::iterator - i = m_stack.begin(); - i != m_stack.end(); ++i) - { - assert(*i != menu); +#ifndef NDEBUG + for (gui::IGUIElement *i : m_stack) { + assert(i != menu); } +#endif - if(m_stack.size() != 0) + if(!m_stack.empty()) m_stack.back()->setVisible(false); m_stack.push_back(menu); } - virtual void deletingMenu(GUIModalMenu *menu) + virtual void deletingMenu(gui::IGUIElement *menu) { // Remove all entries if there are duplicates bool removed_entry; do{ removed_entry = false; - for(std::list::iterator + for(std::list::iterator i = m_stack.begin(); i != m_stack.end(); ++i) { @@ -80,18 +81,18 @@ public: /*core::list::Iterator i = m_stack.getLast(); assert(*i == menu); m_stack.erase(i);*/ - - if(m_stack.size() != 0) + + if(!m_stack.empty()) m_stack.back()->setVisible(true); } // Returns true to prevent further processing virtual bool preprocessEvent(const SEvent& event) { - if(m_stack.size() != 0) - return m_stack.back()->preprocessEvent(event); - else + if (m_stack.empty()) return false; + GUIModalMenu *mm = dynamic_cast(m_stack.back()); + return mm && mm->preprocessEvent(event); } u32 menuCount() @@ -101,40 +102,30 @@ public: bool pausesGame() { - for(std::list::iterator - i = m_stack.begin(); i != m_stack.end(); ++i) - { - if((*i)->pausesGame()) + for (gui::IGUIElement *i : m_stack) { + GUIModalMenu *mm = dynamic_cast(i); + if (mm && mm->pausesGame()) return true; } return false; } - std::list m_stack; + std::list m_stack; }; extern MainMenuManager g_menumgr; -extern bool noMenuActive(); +extern bool isMenuActive(); class MainGameCallback : public IGameCallback { public: - MainGameCallback(IrrlichtDevice *a_device): - disconnect_requested(false), - changepassword_requested(false), - changevolume_requested(false), - shutdown_requested(false), - device(a_device) - { - } + MainGameCallback() = default; + virtual ~MainGameCallback() = default; virtual void exitToOS() { shutdown_requested = true; -#ifndef __ANDROID__ - device->closeDevice(); -#endif } virtual void disconnect() @@ -151,15 +142,25 @@ public: { changevolume_requested = true; } - - bool disconnect_requested; - bool changepassword_requested; - bool changevolume_requested; - bool shutdown_requested; - IrrlichtDevice *device; -}; -extern MainGameCallback *g_gamecallback; + virtual void keyConfig() + { + keyconfig_requested = true; + } + + virtual void signalKeyConfigChange() + { + keyconfig_changed = true; + } -#endif + bool disconnect_requested = false; + bool changepassword_requested = false; + bool changevolume_requested = false; + bool keyconfig_requested = false; + bool shutdown_requested = false; + + bool keyconfig_changed = false; +}; + +extern MainGameCallback *g_gamecallback;