ScummVM API documentation
KeyBindMenu.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_KEYBINDMENU_H
32 #define CRAB_KEYBINDMENU_H
33 
34 #include "crab/ui/ImageData.h"
35 #include "crab/ui/menu.h"
36 #include "crab/ui/OptionSelect.h"
37 
38 namespace Crab {
39 
40 namespace pyrodactyl {
41 namespace ui {
42 class KeyBindMenu {
43  // The keyboard controls menu has 2 types of inputs
44  enum Controls {
45  CON_GAME = 0,
46  CON_UI,
47  CON_TOTAL
48  };
49 
50  // Each menu can be in these 2 states
51  enum States {
52  STATE_NORMAL,
53  STATE_KEY
54  } _state;
55 
56  // This button swaps between sub-sections "Gameplay" and "Interface"
57  OptionSelect _selControls;
58 
59  // These two buttons are the template buttons for the menu
60  Button _prim, _alt;
61 
62  // This is the template text info
63  TextData _desc;
64 
65  // inc tells us what to add to the reference buttons to get multiple buttons
66  // Divide is the space between two columns
67  Vector2i _inc, _divide;
68 
69  // The number of rows and columns
70  Vector2i _dim;
71 
72  // The menu for the keyboard options in both sub categories
73  // all control types have equal entries so we just need to change the text displayed
74  ButtonMenu _menu[CON_TOTAL];
75 
76  // The selected button in the current menu
77  int _choice;
78 
79  struct PromptInfo {
80  int _col, _colPrev;
81  Common::String _text;
82 
83  PromptInfo() {
84  _col = 0;
85  _colPrev = 0;
86  }
87 
88  void load(rapidxml::xml_node<char> *node) {
89  if (nodeValid(node)) {
90  loadStr(_text, "text", node);
91  loadNum(_col, "color", node);
92  }
93  }
94 
95  void swap(Caption &c) {
96  _colPrev = c._col;
97  c._text = _text;
98  c._col = _col;
99  }
100  } _prompt;
101 
102  void startAndSize(const int &type, int &start, int &size);
103  void initMenu(const int &type);
104  void drawDesc(const int &type);
105 
106 public:
107  KeyBindMenu() {
108  reset();
109  _choice = -1;
110  }
111  ~KeyBindMenu() {}
112 
113  void reset() {
114  _state = STATE_NORMAL;
115  }
116 
117  bool disableHotkeys() {
118  return _state != STATE_NORMAL;
119  }
120 
121  void load(rapidxml::xml_node<char> *node);
122 
123  void handleEvents(const Common::Event &event);
124 
125  void setCaption();
126 
127  bool setKey(const Common::Event &event);
128 
129  void draw();
130  void setUI();
131 };
132 } // End of namespace ui
133 } // End of namespace pyrodactyl
134 
135 } // End of namespace Crab
136 
137 #endif // CRAB_KEYBINDMENU_H
Definition: OptionSelect.h:41
Definition: str.h:59
Definition: TextData.h:41
Definition: KeyBindMenu.h:42
Definition: events.h:199
Definition: Caption.h:41
Definition: moveeffect.h:37
Definition: button.h:86