X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fgame.h;h=df32e339716876cd19a06329f379bf5e41f21c5a;hb=0f0502109eac44128e87906fff30b5d049392f1d;hp=b74a7a8da33c620a6a0e3c2e553c2106e5f07797;hpb=9f031a67594162a53b07acbfbc65faf8c4938e99;p=minetest.git diff --git a/src/game.h b/src/game.h index b74a7a8da..df32e3397 100644 --- a/src/game.h +++ b/src/game.h @@ -1,6 +1,6 @@ /* -Minetest-c55 -Copyright (C) 2011 celeron55, Perttu Ahola +Minetest +Copyright (C) 2013 celeron55, Perttu Ahola 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 @@ -22,40 +22,52 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes_extrabloated.h" #include +#include "client/keys.h" +#include "client/joystick_controller.h" #include "keycode.h" +#include -class KeyList : protected core::list +class KeyList : protected std::list { - typedef core::list super; - typedef super::Iterator Iterator; - typedef super::ConstIterator ConstIterator; + typedef std::list super; + typedef super::iterator iterator; + typedef super::const_iterator const_iterator; - virtual ConstIterator find(const KeyPress &key) const + virtual const_iterator find(const KeyPress &key) const { - ConstIterator f(begin()); - ConstIterator e(end()); - while (f!=e) { + 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) + virtual iterator find(const KeyPress &key) { - Iterator f(begin()); - Iterator e(end()); - while (f!=e) { + iterator f(begin()); + iterator e(end()); + + 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) { @@ -65,14 +77,16 @@ class KeyList : protected core::list void unset(const KeyPress &key) { - Iterator p(find(key)); + iterator p(find(key)); + if (p != end()) erase(p); } void toggle(const KeyPress &key) { - Iterator p(this->find(key)); + iterator p(this->find(key)); + if (p != end()) erase(p); else @@ -97,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; @@ -113,34 +130,33 @@ 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, - std::string configpath, - ChatBackend &chat_backend, - const SubgameSpec &gamespec, // Used for local game - bool simple_singleplayer_mode -); +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