guiKeyChangeMenu.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. Minetest
  3. Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. Copyright (C) 2013 Ciaran Gultnieks <ciaran@ciarang.com>
  5. Copyright (C) 2013 teddydestodes <derkomtur@schattengang.net>
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU Lesser General Public License as published by
  8. the Free Software Foundation; either version 2.1 of the License, or
  9. (at your option) any later version.
  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 Lesser General Public License for more details.
  14. You should have received a copy of the GNU Lesser General Public License along
  15. with this program; if not, write to the Free Software Foundation, Inc.,
  16. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #ifndef GUIKEYCHANGEMENU_HEADER
  19. #define GUIKEYCHANGEMENU_HEADER
  20. #include "irrlichttypes_extrabloated.h"
  21. #include "modalMenu.h"
  22. #include "client.h"
  23. #include "gettext.h"
  24. #include "keycode.h"
  25. #include <string>
  26. #include <vector>
  27. struct key_setting
  28. {
  29. int id;
  30. const wchar_t *button_name;
  31. KeyPress key;
  32. std::string setting_name;
  33. gui::IGUIButton *button;
  34. };
  35. class GUIKeyChangeMenu : public GUIModalMenu
  36. {
  37. public:
  38. GUIKeyChangeMenu(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id,
  39. IMenuManager *menumgr);
  40. ~GUIKeyChangeMenu();
  41. void removeChildren();
  42. /*
  43. Remove and re-add (or reposition) stuff
  44. */
  45. void regenerateGui(v2u32 screensize);
  46. void drawMenu();
  47. bool acceptInput();
  48. bool OnEvent(const SEvent &event);
  49. private:
  50. void init_keys();
  51. bool resetMenu();
  52. void add_key(int id, const wchar_t *button_name, const std::string &setting_name);
  53. bool shift_down = false;
  54. s32 activeKey = -1;
  55. std::vector<KeyPress> key_used;
  56. gui::IGUIStaticText *key_used_text = nullptr;
  57. std::vector<key_setting *> key_settings;
  58. };
  59. #endif