Move KeyList & InputHandler from game.h to client/inputhandler.h (#5752)
authorLoïc Blot <nerzhul@users.noreply.github.com>
Sat, 13 May 2017 09:05:16 +0000 (11:05 +0200)
committerGitHub <noreply@github.com>
Sat, 13 May 2017 09:05:16 +0000 (11:05 +0200)
* Move KeyList & InputHandler from game.h to client/inputhandler.h

We have a header for inputs, move inputhandler class & related keylist object to it

Also introduce a cpp file for MyEventReceiver::OnEvent function in inputhandler.h because a so huge function doesn't needs to be inlined

* Pass clang-format on inputhandler.{cpp,h} (compatible)

build/android/jni/Android.mk
src/client/CMakeLists.txt
src/client/clientlauncher.cpp
src/client/inputhandler.cpp [new file with mode: 0644]
src/client/inputhandler.h
src/game.cpp
src/game.h
src/mainmenumanager.h
util/travis/clang-format-whitelist.txt

index 44d98fada81c0ef4e39699b09df38f24630826ae..7b741e04bc0c4fc0a04bb81aa3a20b0e70dd5a8f 100644 (file)
@@ -270,6 +270,7 @@ LOCAL_SRC_FILES := \
                jni/src/settings.cpp                      \
                jni/src/wieldmesh.cpp                     \
                jni/src/client/clientlauncher.cpp         \
+               jni/src/client/inputhandler.cpp           \
                jni/src/client/tile.cpp                   \
                jni/src/client/joystick_controller.cpp    \
                jni/src/irrlicht_changes/static_text.cpp
index 5faa186a723e908f950385a62de0c34f04f4fa0c..2d274ae681409451737b0bae8d0aceab2200eb1b 100644 (file)
@@ -1,5 +1,6 @@
 set(client_SRCS
        ${CMAKE_CURRENT_SOURCE_DIR}/clientlauncher.cpp
+       ${CMAKE_CURRENT_SOURCE_DIR}/inputhandler.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/tile.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/joystick_controller.cpp
        PARENT_SCOPE
index be4e82134a4e3a93eb3ca147efe7f80d70702408..289d1537b11d44f9cce13e49e0cda3ab1678fe15 100644 (file)
@@ -42,9 +42,9 @@ gui::IGUIEnvironment *guienv = NULL;
 gui::IGUIStaticText *guiroot = NULL;
 MainMenuManager g_menumgr;
 
-bool noMenuActive()
+bool isMenuActive()
 {
-       return g_menumgr.menuCount() == 0;
+       return g_menumgr.menuCount() != 0;
 }
 
 // Passed to menus to allow disconnecting and exiting
@@ -496,7 +496,7 @@ void ClientLauncher::main_menu(MainMenuData *menudata)
 
        infostream << "Waiting for other menus" << std::endl;
        while (device->run() && *kill == false) {
-               if (noMenuActive())
+               if (!isMenuActive())
                        break;
                driver->beginScene(true, true, video::SColor(255, 128, 128, 128));
                guienv->drawAll();
diff --git a/src/client/inputhandler.cpp b/src/client/inputhandler.cpp
new file mode 100644 (file)
index 0000000..9c7a94c
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+Minetest
+Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2017 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "util/numeric.h"
+#include "inputhandler.h"
+#include "mainmenumanager.h"
+
+bool MyEventReceiver::OnEvent(const SEvent &event)
+{
+       /*
+               React to nothing here if a menu is active
+       */
+       if (isMenuActive()) {
+#ifdef HAVE_TOUCHSCREENGUI
+               if (m_touchscreengui) {
+                       m_touchscreengui->Toggle(false);
+               }
+#endif
+               return g_menumgr.preprocessEvent(event);
+       }
+
+       // Remember whether each key is down or up
+       if (event.EventType == irr::EET_KEY_INPUT_EVENT) {
+               const KeyPress &keyCode = event.KeyInput;
+               if (keysListenedFor[keyCode]) {
+                       if (event.KeyInput.PressedDown) {
+                               keyIsDown.set(keyCode);
+                               keyWasDown.set(keyCode);
+                       } else {
+                               keyIsDown.unset(keyCode);
+                       }
+                       return true;
+               }
+       }
+
+#ifdef HAVE_TOUCHSCREENGUI
+       // case of touchscreengui we have to handle different events
+       if (m_touchscreengui && event.EventType == irr::EET_TOUCH_INPUT_EVENT) {
+               m_touchscreengui->translateEvent(event);
+               return true;
+       }
+#endif
+
+       if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT) {
+               /* TODO add a check like:
+               if (event.JoystickEvent != joystick_we_listen_for)
+                       return false;
+               */
+               return joystick->handleEvent(event.JoystickEvent);
+       }
+       // handle mouse events
+       if (event.EventType == irr::EET_MOUSE_INPUT_EVENT) {
+               if (isMenuActive()) {
+                       left_active = false;
+                       middle_active = false;
+                       right_active = false;
+               } else {
+                       left_active = event.MouseInput.isLeftPressed();
+                       middle_active = event.MouseInput.isMiddlePressed();
+                       right_active = event.MouseInput.isRightPressed();
+
+                       if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) {
+                               leftclicked = true;
+                       }
+                       if (event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN) {
+                               rightclicked = true;
+                       }
+                       if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) {
+                               leftreleased = true;
+                       }
+                       if (event.MouseInput.Event == EMIE_RMOUSE_LEFT_UP) {
+                               rightreleased = true;
+                       }
+                       if (event.MouseInput.Event == EMIE_MOUSE_WHEEL) {
+                               mouse_wheel += event.MouseInput.Wheel;
+                       }
+               }
+       } else if (event.EventType == irr::EET_LOG_TEXT_EVENT) {
+               static const LogLevel irr_loglev_conv[] = {
+                               LL_VERBOSE, // ELL_DEBUG
+                               LL_INFO,    // ELL_INFORMATION
+                               LL_WARNING, // ELL_WARNING
+                               LL_ERROR,   // ELL_ERROR
+                               LL_NONE,    // ELL_NONE
+               };
+               assert(event.LogEvent.Level < ARRLEN(irr_loglev_conv));
+               g_logger.log(irr_loglev_conv[event.LogEvent.Level],
+                               std::string("Irrlicht: ") +
+                                               (const char *)event.LogEvent.Text);
+               return true;
+       }
+       /* always return false in order to continue processing events */
+       return false;
+}
+
+/*
+ * RandomInputHandler
+ */
+s32 RandomInputHandler::Rand(s32 min, s32 max)
+{
+       return (myrand() % (max - min + 1)) + min;
+}
index 824b0da2ee77e97581b1af066b6bb9919737529a..7c422d189fff354edfaf04cb8890469851e2ecee 100644 (file)
@@ -22,104 +22,87 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "irrlichttypes_extrabloated.h"
 #include "joystick_controller.h"
+#include <list>
+#include "keycode.h"
 
-class MyEventReceiver : public IEventReceiver
-{
-public:
-       // This is the one method that we have to implement
-       virtual bool OnEvent(const SEvent& event)
-       {
-               /*
-                       React to nothing here if a menu is active
-               */
-               if (noMenuActive() == false) {
 #ifdef HAVE_TOUCHSCREENGUI
-                       if (m_touchscreengui != 0) {
-                               m_touchscreengui->Toggle(false);
-                       }
+#include "touchscreengui.h"
 #endif
-                       return g_menumgr.preprocessEvent(event);
-               }
 
-               // Remember whether each key is down or up
-               if (event.EventType == irr::EET_KEY_INPUT_EVENT) {
-                       const KeyPress &keyCode = event.KeyInput;
-                       if (keysListenedFor[keyCode]) {
-                               if (event.KeyInput.PressedDown) {
-                                       keyIsDown.set(keyCode);
-                                       keyWasDown.set(keyCode);
-                               } else {
-                                       keyIsDown.unset(keyCode);
-                               }
-                               return true;
-                       }
-               }
+class KeyList : private std::list<KeyPress>
+{
+       typedef std::list<KeyPress> super;
+       typedef super::iterator iterator;
+       typedef super::const_iterator const_iterator;
 
-#ifdef HAVE_TOUCHSCREENGUI
-               // case of touchscreengui we have to handle different events
-               if ((m_touchscreengui != 0) &&
-                               (event.EventType == irr::EET_TOUCH_INPUT_EVENT)) {
-                       m_touchscreengui->translateEvent(event);
-                       return true;
-               }
-#endif
+       virtual const_iterator find(const KeyPress &key) const
+       {
+               const_iterator f(begin());
+               const_iterator e(end());
+
+               while (f != e) {
+                       if (*f == key)
+                               return f;
 
-               if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT) {
-                       /* TODO add a check like:
-                       if (event.JoystickEvent != joystick_we_listen_for)
-                               return false;
-                       */
-                       return joystick->handleEvent(event.JoystickEvent);
+                       ++f;
                }
-               // handle mouse events
-               if (event.EventType == irr::EET_MOUSE_INPUT_EVENT) {
-                       if (noMenuActive() == false) {
-                               left_active = false;
-                               middle_active = false;
-                               right_active = false;
-                       } else {
-                               left_active = event.MouseInput.isLeftPressed();
-                               middle_active = event.MouseInput.isMiddlePressed();
-                               right_active = event.MouseInput.isRightPressed();
-
-                               if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN) {
-                                       leftclicked = true;
-                               }
-                               if (event.MouseInput.Event == EMIE_RMOUSE_PRESSED_DOWN) {
-                                       rightclicked = true;
-                               }
-                               if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP) {
-                                       leftreleased = true;
-                               }
-                               if (event.MouseInput.Event == EMIE_RMOUSE_LEFT_UP) {
-                                       rightreleased = true;
-                               }
-                               if (event.MouseInput.Event == EMIE_MOUSE_WHEEL) {
-                                       mouse_wheel += event.MouseInput.Wheel;
-                               }
-                       }
-               } else if (event.EventType == irr::EET_LOG_TEXT_EVENT) {
-                       static const LogLevel irr_loglev_conv[] = {
-                               LL_VERBOSE, // ELL_DEBUG
-                               LL_INFO,    // ELL_INFORMATION
-                               LL_WARNING, // ELL_WARNING
-                               LL_ERROR,   // ELL_ERROR
-                               LL_NONE,    // ELL_NONE
-                       };
-                       assert(event.LogEvent.Level < ARRLEN(irr_loglev_conv));
-                       g_logger.log(irr_loglev_conv[event.LogEvent.Level],
-                               std::string("Irrlicht: ") + (const char*) event.LogEvent.Text);
-                       return true;
+
+               return e;
+       }
+
+       virtual iterator find(const KeyPress &key)
+       {
+               iterator f(begin());
+               iterator e(end());
+
+               while (f != e) {
+                       if (*f == key)
+                               return f;
+
+                       ++f;
                }
-               /* always return false in order to continue processing events */
-               return false;
+
+               return e;
+       }
+
+public:
+       void clear() { super::clear(); }
+
+       void set(const KeyPress &key)
+       {
+               if (find(key) == end())
+                       push_back(key);
        }
 
-       bool IsKeyDown(const KeyPress &keyCode) const
+       void unset(const KeyPress &key)
        {
-               return keyIsDown[keyCode];
+               iterator p(find(key));
+
+               if (p != end())
+                       erase(p);
        }
 
+       void toggle(const KeyPress &key)
+       {
+               iterator p(this->find(key));
+
+               if (p != end())
+                       erase(p);
+               else
+                       push_back(key);
+       }
+
+       bool operator[](const KeyPress &key) const { return find(key) != end(); }
+};
+
+class MyEventReceiver : public IEventReceiver
+{
+public:
+       // This is the one method that we have to implement
+       virtual bool OnEvent(const SEvent &event);
+
+       bool IsKeyDown(const KeyPress &keyCode) const { return keyIsDown[keyCode]; }
+
        // Checks whether a key was down and resets the state
        bool WasKeyDown(const KeyPress &keyCode)
        {
@@ -129,14 +112,8 @@ public:
                return b;
        }
 
-       void listenForKey(const KeyPress &keyCode)
-       {
-               keysListenedFor.set(keyCode);
-       }
-       void dontListenForKeys()
-       {
-               keysListenedFor.clear();
-       }
+       void listenForKey(const KeyPress &keyCode) { keysListenedFor.set(keyCode); }
+       void dontListenForKeys() { keysListenedFor.clear(); }
 
        s32 getMouseWheel()
        {
@@ -184,7 +161,7 @@ public:
        JoystickController *joystick;
 
 #ifdef HAVE_TOUCHSCREENGUI
-       TouchScreenGUIm_touchscreengui;
+       TouchScreenGUI *m_touchscreengui;
 #endif
 
 private:
@@ -200,7 +177,42 @@ private:
        KeyList keysListenedFor;
 };
 
+class InputHandler
+{
+public:
+       InputHandler() {}
+       virtual ~InputHandler() {}
+
+       virtual bool isKeyDown(const KeyPress &keyCode) = 0;
+       virtual bool wasKeyDown(const KeyPress &keyCode) = 0;
+
+       virtual void listenForKey(const KeyPress &keyCode) {}
+       virtual void dontListenForKeys() {}
+
+       virtual v2s32 getMousePos() = 0;
+       virtual void setMousePos(s32 x, s32 y) = 0;
+
+       virtual bool getLeftState() = 0;
+       virtual bool getRightState() = 0;
+
+       virtual bool getLeftClicked() = 0;
+       virtual bool getRightClicked() = 0;
+       virtual void resetLeftClicked() = 0;
+       virtual void resetRightClicked() = 0;
+
+       virtual bool getLeftReleased() = 0;
+       virtual bool getRightReleased() = 0;
+       virtual void resetLeftReleased() = 0;
+       virtual void resetRightReleased() = 0;
 
+       virtual s32 getMouseWheel() = 0;
+
+       virtual void step(float dtime) {}
+
+       virtual void clear() {}
+
+       JoystickController joystick;
+};
 /*
        Separated input handler
 */
@@ -208,10 +220,8 @@ private:
 class RealInputHandler : public InputHandler
 {
 public:
-       RealInputHandler(IrrlichtDevice *device, MyEventReceiver *receiver):
-               m_device(device),
-               m_receiver(receiver),
-               m_mousepos(0,0)
+       RealInputHandler(IrrlichtDevice *device, MyEventReceiver *receiver)
+           : m_device(device), m_receiver(receiver), m_mousepos(0, 0)
        {
                m_receiver->joystick = &joystick;
        }
@@ -227,16 +237,12 @@ public:
        {
                m_receiver->listenForKey(keyCode);
        }
-       virtual void dontListenForKeys()
-       {
-               m_receiver->dontListenForKeys();
-       }
+       virtual void dontListenForKeys() { m_receiver->dontListenForKeys(); }
        virtual v2s32 getMousePos()
        {
                if (m_device->getCursorControl()) {
                        return m_device->getCursorControl()->getPosition();
-               }
-               else {
+               } else {
                        return m_mousepos;
                }
        }
@@ -244,69 +250,36 @@ public:
        {
                if (m_device->getCursorControl()) {
                        m_device->getCursorControl()->setPosition(x, y);
-               }
-               else {
-                       m_mousepos = v2s32(x,y);
+               } else {
+                       m_mousepos = v2s32(x, y);
                }
        }
 
-       virtual bool getLeftState()
-       {
-               return m_receiver->left_active;
-       }
-       virtual bool getRightState()
-       {
-               return m_receiver->right_active;
-       }
+       virtual bool getLeftState() { return m_receiver->left_active; }
+       virtual bool getRightState() { return m_receiver->right_active; }
 
-       virtual bool getLeftClicked()
-       {
-               return m_receiver->leftclicked;
-       }
-       virtual bool getRightClicked()
-       {
-               return m_receiver->rightclicked;
-       }
-       virtual void resetLeftClicked()
-       {
-               m_receiver->leftclicked = false;
-       }
-       virtual void resetRightClicked()
-       {
-               m_receiver->rightclicked = false;
-       }
+       virtual bool getLeftClicked() { return m_receiver->leftclicked; }
+       virtual bool getRightClicked() { return m_receiver->rightclicked; }
+       virtual void resetLeftClicked() { m_receiver->leftclicked = false; }
+       virtual void resetRightClicked() { m_receiver->rightclicked = false; }
 
-       virtual bool getLeftReleased()
-       {
-               return m_receiver->leftreleased;
-       }
-       virtual bool getRightReleased()
-       {
-               return m_receiver->rightreleased;
-       }
-       virtual void resetLeftReleased()
-       {
-               m_receiver->leftreleased = false;
-       }
-       virtual void resetRightReleased()
-       {
-               m_receiver->rightreleased = false;
-       }
+       virtual bool getLeftReleased() { return m_receiver->leftreleased; }
+       virtual bool getRightReleased() { return m_receiver->rightreleased; }
+       virtual void resetLeftReleased() { m_receiver->leftreleased = false; }
+       virtual void resetRightReleased() { m_receiver->rightreleased = false; }
 
-       virtual s32 getMouseWheel()
-       {
-               return m_receiver->getMouseWheel();
-       }
+       virtual s32 getMouseWheel() { return m_receiver->getMouseWheel(); }
 
        void clear()
        {
                joystick.clear();
                m_receiver->clearInput();
        }
+
 private:
-       IrrlichtDevice  *m_device;
+       IrrlichtDevice *m_device;
        MyEventReceiver *m_receiver;
-       v2s32           m_mousepos;
+       v2s32 m_mousepos;
 };
 
 class RandomInputHandler : public InputHandler
@@ -322,70 +295,25 @@ public:
                rightreleased = false;
                keydown.clear();
        }
-       virtual bool isKeyDown(const KeyPress &keyCode)
-       {
-               return keydown[keyCode];
-       }
-       virtual bool wasKeyDown(const KeyPress &keyCode)
-       {
-               return false;
-       }
-       virtual v2s32 getMousePos()
-       {
-               return mousepos;
-       }
-       virtual void setMousePos(s32 x, s32 y)
-       {
-               mousepos = v2s32(x, y);
-       }
+       virtual bool isKeyDown(const KeyPress &keyCode) { return keydown[keyCode]; }
+       virtual bool wasKeyDown(const KeyPress &keyCode) { return false; }
+       virtual v2s32 getMousePos() { return mousepos; }
+       virtual void setMousePos(s32 x, s32 y) { mousepos = v2s32(x, y); }
 
-       virtual bool getLeftState()
-       {
-               return leftdown;
-       }
-       virtual bool getRightState()
-       {
-               return rightdown;
-       }
+       virtual bool getLeftState() { return leftdown; }
+       virtual bool getRightState() { return rightdown; }
 
-       virtual bool getLeftClicked()
-       {
-               return leftclicked;
-       }
-       virtual bool getRightClicked()
-       {
-               return rightclicked;
-       }
-       virtual void resetLeftClicked()
-       {
-               leftclicked = false;
-       }
-       virtual void resetRightClicked()
-       {
-               rightclicked = false;
-       }
+       virtual bool getLeftClicked() { return leftclicked; }
+       virtual bool getRightClicked() { return rightclicked; }
+       virtual void resetLeftClicked() { leftclicked = false; }
+       virtual void resetRightClicked() { rightclicked = false; }
 
-       virtual bool getLeftReleased()
-       {
-               return leftreleased;
-       }
-       virtual bool getRightReleased()
-       {
-               return rightreleased;
-       }
-       virtual void resetLeftReleased()
-       {
-               leftreleased = false;
-       }
-       virtual void resetRightReleased()
-       {
-               rightreleased = false;
-       }
+       virtual bool getLeftReleased() { return leftreleased; }
+       virtual bool getRightReleased() { return rightreleased; }
+       virtual void resetLeftReleased() { leftreleased = false; }
+       virtual void resetRightReleased() { rightreleased = false; }
 
-       virtual s32 getMouseWheel()
-       {
-               return 0;
-       }
+       virtual s32 getMouseWheel() { return 0; }
 
        virtual void step(float dtime)
        {
@@ -456,10 +384,8 @@ public:
                mousepos += mousespeed;
        }
 
-       s32 Rand(s32 min, s32 max)
-       {
-               return (myrand()%(max-min+1))+min;
-       }
+       s32 Rand(s32 min, s32 max);
+
 private:
        KeyList keydown;
        v2s32 mousepos;
index 2b7d50eb53600b1f8f9820c38cd155a1a8ba0ca0..ab8eb5c704b321b3ec0a7e0cc226e4ee1fb67554 100644 (file)
@@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <iomanip>
 #include "camera.h"
 #include "client.h"
+#include "client/inputhandler.h"
 #include "client/tile.h"     // For TextureSource
 #include "client/keys.h"
 #include "client/joystick_controller.h"
@@ -50,7 +51,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "quicktune_shortcutter.h"
 #include "server.h"
 #include "settings.h"
-#include "shader.h"          // For ShaderSource
 #include "sky.h"
 #include "subgame.h"
 #include "tool.h"
@@ -59,20 +59,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "util/pointedthing.h"
 #include "irrlicht_changes/static_text.h"
 #include "version.h"
-#include "minimap.h"
-#include "mapblock_mesh.h"
 #include "script/scripting_client.h"
 
-#include "sound.h"
-
 #if USE_SOUND
        #include "sound_openal.h"
 #endif
 
-#ifdef HAVE_TOUCHSCREENGUI
-       #include "touchscreengui.h"
-#endif
-
 extern Settings *g_settings;
 extern Profiler *g_profiler;
 
@@ -2434,7 +2426,7 @@ void Game::updateStats(RunStats *stats, const FpsControl &draw_times,
 void Game::processUserInput(f32 dtime)
 {
        // Reset input if window not active or some menu is active
-       if (!device->isWindowActive() || !noMenuActive() || guienv->hasFocus(gui_chat_console)) {
+       if (!device->isWindowActive() || isMenuActive() || guienv->hasFocus(gui_chat_console)) {
                input->clear();
 #ifdef HAVE_TOUCHSCREENGUI
                g_touchscreengui->hide();
@@ -2964,7 +2956,7 @@ void Game::toggleFullViewRange()
 
 void Game::updateCameraDirection(CameraOrientation *cam, float dtime)
 {
-       if ((device->isWindowActive() && noMenuActive()) || random_input) {
+       if ((device->isWindowActive() && !isMenuActive()) || random_input) {
 
 #ifndef __ANDROID__
                if (!random_input) {
@@ -3709,12 +3701,9 @@ PointedThing Game::updatePointedThing(
                float sin_r = 0.08 * sin(timerf);
                float sin_g = 0.08 * sin(timerf + irr::core::PI * 0.5);
                float sin_b = 0.08 * sin(timerf + irr::core::PI);
-               c.setRed(
-                       core::clamp(core::round32(c.getRed() * (0.8 + sin_r)), 0, 255));
-               c.setGreen(
-                       core::clamp(core::round32(c.getGreen() * (0.8 + sin_g)), 0, 255));
-               c.setBlue(
-                       core::clamp(core::round32(c.getBlue() * (0.8 + sin_b)), 0, 255));
+               c.setRed(core::clamp(core::round32(c.getRed() * (0.8 + sin_r)), 0, 255));
+               c.setGreen(core::clamp(core::round32(c.getGreen() * (0.8 + sin_g)), 0, 255));
+               c.setBlue(core::clamp(core::round32(c.getBlue() * (0.8 + sin_b)), 0, 255));
 
                // Set mesh final color
                hud->setSelectionMeshColor(c);
@@ -4183,7 +4172,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
                if (current_formspec->getReferenceCount() == 1) {
                        current_formspec->drop();
                        current_formspec = NULL;
-               } else if (!noMenuActive()) {
+               } else if (isMenuActive()) {
                        guiroot->bringToFront(current_formspec);
                }
        }
index eaedca165d3831b958bcfb3aa05114bdfa3a21d6..4fb198be8a8d3bdb33b6bb44fb2b88ce4813562f 100644 (file)
@@ -22,124 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "irrlichttypes_extrabloated.h"
 #include <string>
-#include "client/keys.h"
-#include "client/joystick_controller.h"
-#include "keycode.h"
-#include <list>
-
-class KeyList : protected std::list<KeyPress>
-{
-       typedef std::list<KeyPress> super;
-       typedef super::iterator iterator;
-       typedef super::const_iterator const_iterator;
-
-       virtual const_iterator find(const KeyPress &key) const
-       {
-               const_iterator f(begin());
-               const_iterator e(end());
-
-               while (f != e) {
-                       if (*f == key)
-                               return f;
-
-                       ++f;
-               }
-
-               return e;
-       }
-
-       virtual iterator find(const KeyPress &key)
-       {
-               iterator f(begin());
-               iterator e(end());
-
-               while (f != e) {
-                       if (*f == key)
-                               return f;
-
-                       ++f;
-               }
-
-               return e;
-       }
-
-public:
-       void clear()
-       {
-               super::clear();
-       }
-
-       void set(const KeyPress &key)
-       {
-               if (find(key) == end())
-                       push_back(key);
-       }
-
-       void unset(const KeyPress &key)
-       {
-               iterator p(find(key));
-
-               if (p != end())
-                       erase(p);
-       }
-
-       void toggle(const KeyPress &key)
-       {
-               iterator p(this->find(key));
-
-               if (p != end())
-                       erase(p);
-               else
-                       push_back(key);
-       }
-
-       bool operator[](const KeyPress &key) const
-       {
-               return find(key) != end();
-       }
-};
-
-class InputHandler
-{
-public:
-       InputHandler()
-       {
-       }
-       virtual ~InputHandler()
-       {
-       }
-
-       virtual bool isKeyDown(const KeyPress &keyCode) = 0;
-       virtual bool wasKeyDown(const KeyPress &keyCode) = 0;
-
-       virtual void listenForKey(const KeyPress &keyCode) {}
-       virtual void dontListenForKeys() {}
-
-       virtual v2s32 getMousePos() = 0;
-       virtual void setMousePos(s32 x, s32 y) = 0;
-
-       virtual bool getLeftState() = 0;
-       virtual bool getRightState() = 0;
-
-       virtual bool getLeftClicked() = 0;
-       virtual bool getRightClicked() = 0;
-       virtual void resetLeftClicked() = 0;
-       virtual void resetRightClicked() = 0;
-
-       virtual bool getLeftReleased() = 0;
-       virtual bool getRightReleased() = 0;
-       virtual void resetLeftReleased() = 0;
-       virtual void resetRightReleased() = 0;
-
-       virtual s32 getMouseWheel() = 0;
-
-       virtual void step(float dtime) {}
-
-       virtual void clear() {}
-
-       JoystickController joystick;
-};
 
+class InputHandler;
 class ChatBackend;  /* to avoid having to include chat.h */
 struct SubgameSpec;
 
index 17133b1642253a8a022c4e095f9e72a45be09bb9..fb715ca9b65e169237b7c0db585b04414f4a70e3 100644 (file)
@@ -83,7 +83,7 @@ public:
                /*core::list<GUIModalMenu*>::Iterator i = m_stack.getLast();
                assert(*i == menu);
                m_stack.erase(i);*/
-               
+
                if(!m_stack.empty())
                        m_stack.back()->setVisible(true);
        }
@@ -119,7 +119,7 @@ public:
 
 extern MainMenuManager g_menumgr;
 
-extern bool noMenuActive();
+extern bool isMenuActive();
 
 class MainGameCallback : public IGameCallback
 {
@@ -168,7 +168,7 @@ public:
                keyconfig_changed = true;
        }
 
-       
+
        bool disconnect_requested;
        bool changepassword_requested;
        bool changevolume_requested;
index 0b290ae8726bc2f55af39ab077f883f0053a47ef..932f59978dae84ce97e97543d0a6da9b68ddb6bf 100644 (file)
@@ -18,7 +18,6 @@ src/clientenvironment.h
 src/client.h
 src/clientiface.cpp
 src/clientiface.h
-src/client/inputhandler.h
 src/client/joystick_controller.cpp
 src/client/joystick_controller.h
 src/clientmap.cpp