2
0

guiKeyChangeMenu.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #pragma once
  19. #include "irrlichttypes_extrabloated.h"
  20. #include "modalMenu.h"
  21. #include "gettext.h"
  22. #include "client/keycode.h"
  23. #include <string>
  24. #include <vector>
  25. class ISimpleTextureSource;
  26. struct key_setting
  27. {
  28. int id;
  29. std::wstring button_name;
  30. KeyPress key;
  31. std::string setting_name;
  32. gui::IGUIButton *button;
  33. };
  34. class GUIKeyChangeMenu : public GUIModalMenu
  35. {
  36. public:
  37. GUIKeyChangeMenu(gui::IGUIEnvironment *env, gui::IGUIElement *parent, s32 id,
  38. IMenuManager *menumgr, ISimpleTextureSource *tsrc);
  39. ~GUIKeyChangeMenu();
  40. /*
  41. Remove and re-add (or reposition) stuff
  42. */
  43. void regenerateGui(v2u32 screensize);
  44. void drawMenu();
  45. bool acceptInput();
  46. bool OnEvent(const SEvent &event);
  47. bool pausesGame() { return true; }
  48. protected:
  49. std::wstring getLabelByID(s32 id) { return L""; }
  50. std::string getNameByID(s32 id) { return ""; }
  51. private:
  52. void init_keys();
  53. bool resetMenu();
  54. void add_key(int id, std::wstring button_name, const std::string &setting_name);
  55. bool shift_down = false;
  56. key_setting *active_key = nullptr;
  57. gui::IGUIStaticText *key_used_text = nullptr;
  58. std::vector<key_setting *> key_settings;
  59. ISimpleTextureSource *m_tsrc;
  60. };