31 #ifndef CRAB_FILEMENU_H 32 #define CRAB_FILEMENU_H 34 #include "common/savefile.h" 35 #include "crab/crab.h" 36 #include "crab/ui/FileData.h" 37 #include "crab/ui/ImageData.h" 38 #include "crab/ui/PageMenu.h" 39 #include "crab/ui/TextData.h" 43 namespace pyrodactyl {
46 template<
typename FileType>
64 TextData tdB[DATA_BUTTON_TOTAL];
67 HoverInfo hov[DATA_HOVER_TOTAL];
68 TextData tdH[DATA_HOVER_TOTAL];
73 pyrodactyl::image::Image _preview;
100 _img._preview.deleteImage();
104 _img._preview.deleteImage();
105 _img._loaded =
false;
119 res +=
g_engine->_filePath->_saveExt;
125 uint countSlot = 0, countMenu = 0;
128 _menu.add(countSlot, countMenu);
134 void load(rapidxml::xml_node<char> *node) {
135 if (nodeValid(
"bg", node))
136 _bg.load(node->first_node(
"bg"));
138 if (nodeValid(
"menu", node))
139 _menu.load(node->first_node(
"menu"));
141 if (nodeValid(
"preview", node)) {
142 auto prnode = node->first_node(
"preview");
143 _img._pos.load(prnode);
144 loadPath(_img._noPreviewPath,
"path", prnode);
147 if (nodeValid(
"offset", node)) {
148 rapidxml::xml_node<char> *offnode = node->first_node(
"offset");
151 tdB[DATA_SAVENAME].load(offnode->first_node(
"save_name"));
152 tdB[DATA_LASTMODIFIED].load(offnode->first_node(
"last_modified"));
155 tdH[DATA_LOCNAME].load(offnode->first_node(
"loc_name"));
156 tdH[DATA_DIFFICULTY].load(offnode->first_node(
"difficulty"));
157 tdH[DATA_TIMEPLAYED].load(offnode->first_node(
"time_played"));
158 tdH[DATA_PLAYERNAME].load(offnode->first_node(
"player_name"));
161 hov[DATA_LOCNAME].load(offnode->first_node(
"loc_name_title"));
162 hov[DATA_DIFFICULTY].load(offnode->first_node(
"difficulty_title"));
163 hov[DATA_TIMEPLAYED].load(offnode->first_node(
"time_played_title"));
164 hov[DATA_PLAYERNAME].load(offnode->first_node(
"player_name_title"));
167 _extension =
g_engine->_filePath->_saveExt;
168 _directory =
g_engine->_filePath->_appdata.join(
g_engine->_filePath->_saveDir);
173 int choice = _menu.handleEvents(event);
176 _selected = _slotInfo[_menu.index() + choice]._path;
187 for (
auto i = _menu.index(), count = 0u; i < _menu.indexPlusOne() && i < _slotInfo.
size(); i++, count++) {
188 auto base_x = _menu.baseX(count), base_y = _menu.baseY(count);
189 tdB[DATA_SAVENAME].draw(_slotInfo[i]._name, base_x, base_y);
190 tdB[DATA_LASTMODIFIED].draw(_slotInfo[i]._lastModified, base_x, base_y);
197 if (_menu.hoverIndex() >= 0) {
198 int i = _menu.hoverIndex();
200 if (!_img._loaded || _prevHover != i) {
203 if (!_img._preview.load(
Common::Path(_slotInfo[i]._preview)))
208 _img._preview.draw(_img._pos.x, _img._pos.y);
210 tdH[DATA_LOCNAME].draw(_slotInfo[i]._locName);
211 tdH[DATA_DIFFICULTY].draw(_slotInfo[i]._diff);
212 tdH[DATA_TIMEPLAYED].draw(_slotInfo[i]._time);
213 tdH[DATA_PLAYERNAME].draw(_slotInfo[i]._charName);
215 for (
int num = 0; num < DATA_HOVER_TOTAL; ++num)
223 return _slotInfo.
empty();
226 bool selectNewestFile() {
227 if (_slotInfo.
size() > 0) {
228 _selected = _slotInfo[0]._path;
241 for (
int i = 0; i < DATA_BUTTON_TOTAL; ++i)
244 for (
int i = 0; i < DATA_HOVER_TOTAL; ++i) {
256 #endif // CRAB_FILEMENU_H
void clear()
Definition: array.h:320
bool empty() const
Definition: array.h:351
void push_back(const T &element)
Definition: array.h:180
size_type size() const
Definition: array.h:315
Definition: moveeffect.h:37
Common::SaveFileManager * getSaveFileManager()
Definition: engine.h:625
virtual StringArray listSavefiles(const String &pattern)=0