31 #ifndef CRAB_PAGEMENU_H 32 #define CRAB_PAGEMENU_H 34 #include "crab/ui/menu.h" 38 namespace pyrodactyl {
51 uint _currentPage, _elementsPerPage, _rows, _cols;
81 _menu[0].useKeyboard(
true);
85 uint elementsPerPage() {
86 return _elementsPerPage;
91 return _currentPage * _elementsPerPage;
96 return (_currentPage + 1) * _elementsPerPage;
104 void currentPage(
int &val) {
110 if (_menu[_currentPage].hoverIndex() >= 0)
111 return (_currentPage * _elementsPerPage) + _menu[_currentPage].hoverIndex();
117 int baseX(
const int &count) {
118 return _ref.x + _inc.x * (count % _cols);
121 int baseY(
const int &count) {
122 return _ref.y + _inc.y * (count / _cols);
126 const int &curX(
const int &count) {
127 return _menu[_currentPage]._element[count].x;
130 const int &curY(
const int &count) {
131 return _menu[_currentPage]._element[count].y;
134 void image(
const int &slot,
const int &page,
ButtonImage &bi) {
135 _menu[page]._element[slot].img(bi);
139 for (
auto &m : _menu)
143 void useKeyboard(
const bool &val) {
144 for (
auto &m : _menu)
154 for (
auto &m : _menu)
159 _info = numberToString(_currentPage + 1);
161 _info += numberToString(_menu.
size());
164 void load(rapidxml::xml_node<char> *node) {
165 using namespace pyrodactyl::input;
166 if (nodeValid(node)) {
167 if (nodeValid(
"prev", node)) {
168 _prev.load(node->first_node(
"prev"));
169 _prev._hotkey.set(IU_PREV);
172 if (nodeValid(
"next", node)) {
173 _next.load(node->first_node(
"next"));
174 _next._hotkey.set(IU_NEXT);
177 if (nodeValid(
"reference", node))
178 _ref.load(node->first_node(
"reference"));
180 if (nodeValid(
"inc", node))
181 _inc.load(node->first_node(
"inc"));
183 if (nodeValid(
"status", node))
184 _status.load(node->first_node(
"status"));
186 if (nodeValid(
"dim", node)) {
187 rapidxml::xml_node<char> *dimnode = node->first_node(
"dim");
188 loadNum(_rows,
"rows", dimnode);
189 loadNum(_cols,
"cols", dimnode);
190 _elementsPerPage = _rows * _cols;
195 void add(uint &slot, uint &page) {
196 if (slot >= _elementsPerPage) {
200 _menu[page].useKeyboard(
true);
204 b.init(_ref, _inc.x * (slot % _cols), _inc.y * (slot / _cols));
213 uint page = _menu.
size() - 1;
214 uint slot = _menu[page]._element.
size();
219 uint page = _menu.
size() - 1;
226 using namespace pyrodactyl::input;
228 if (_currentPage > 0 && _prev.handleEvents(event) == BUAC_LCLICK) {
232 if ((
int)_currentPage < 0)
236 if (_currentPage < _menu.
size() - 1 && _next.handleEvents(event) == BUAC_LCLICK) {
240 if (_currentPage >= _menu.
size())
241 _currentPage = _menu.
size() - 1;
244 return _menu[_currentPage].handleEvents(event);
249 _menu[_currentPage].draw();
251 if (_currentPage > 0)
254 if (_currentPage < _menu.
size() - 1)
265 #endif // CRAB_PAGEMENU_H
void clear()
Definition: array.h:320
void push_back(const T &element)
Definition: array.h:180
Definition: TextData.h:41
void pop_back()
Definition: array.h:199
size_type size() const
Definition: array.h:315
Definition: moveeffect.h:37
void resize(size_type newSize)
Definition: array.h:411