]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/game.h
Pass clang-format on various cpp/header files (#5559)
[dragonfireclient.git] / src / game.h
index 1c831c530067527c3bda16135109ec2728eae465..eaedca165d3831b958bcfb3aa05114bdfa3a21d6 100644 (file)
@@ -22,6 +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>
 
@@ -35,11 +37,14 @@ class KeyList : protected std::list<KeyPress>
        {
                const_iterator f(begin());
                const_iterator e(end());
-               while (f!=e) {
+
+               while (f != e) {
                        if (*f == key)
                                return f;
+
                        ++f;
                }
+
                return e;
        }
 
@@ -47,16 +52,22 @@ class KeyList : protected std::list<KeyPress>
        {
                iterator f(begin());
                iterator e(end());
-               while (f!=e) {
+
+               while (f != e) {
                        if (*f == key)
                                return f;
+
                        ++f;
                }
+
                return e;
        }
 
 public:
-       void clear() { super::clear(); }
+       void clear()
+       {
+               super::clear();
+       }
 
        void set(const KeyPress &key)
        {
@@ -67,6 +78,7 @@ class KeyList : protected std::list<KeyPress>
        void unset(const KeyPress &key)
        {
                iterator p(find(key));
+
                if (p != end())
                        erase(p);
        }
@@ -74,6 +86,7 @@ class KeyList : protected std::list<KeyPress>
        void toggle(const KeyPress &key)
        {
                iterator p(this->find(key));
+
                if (p != end())
                        erase(p);
                else
@@ -98,7 +111,10 @@ class 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;
 
@@ -114,33 +130,44 @@ class InputHandler
        virtual bool getRightReleased() = 0;
        virtual void resetLeftReleased() = 0;
        virtual void resetRightReleased() = 0;
-       
+
        virtual s32 getMouseWheel() = 0;
 
-       virtual void step(float dtime) {};
+       virtual void step(float dtime) {}
+
+       virtual void clear() {}
 
-       virtual void clear() {};
+       JoystickController joystick;
 };
 
 class ChatBackend;  /* to avoid having to include chat.h */
 struct SubgameSpec;
 
-void the_game(
-       bool &kill,
-       bool random_input,
-       InputHandler *input,
-       IrrlichtDevice *device,
-       gui::IGUIFont* font,
-       std::string map_dir,
-       std::string playername,
-       std::string password,
-       std::string address, // If "", local server is used
-       u16 port,
-       std::wstring &error_message,
-       ChatBackend &chat_backend,
-       const SubgameSpec &gamespec, // Used for local game
-       bool simple_singleplayer_mode
-);
+// Flags that can, or may, change during main game loop
+struct GameUIFlags
+{
+       bool show_chat;
+       bool show_hud;
+       bool show_minimap;
+       bool force_fog_off;
+       bool show_debug;
+       bool show_profiler_graph;
+       bool disable_camera_update;
+};
 
-#endif
+void the_game(bool *kill,
+               bool random_input,
+               InputHandler *input,
+               IrrlichtDevice *device,
+               const std::string &map_dir,
+               const std::string &playername,
+               const std::string &password,
+               const std::string &address, // If "", local server is used
+               u16 port,
+               std::string &error_message,
+               ChatBackend &chat_backend,
+               bool *reconnect_requested,
+               const SubgameSpec &gamespec, // Used for local game
+               bool simple_singleplayer_mode);
 
+#endif