supertux
menu_filesystem.hpp
1 // SuperTux
2 // Copyright (C) 2016 Hume2 <teratux.mail@gmail.com>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_GUI_MENU_FILESYSTEM_HPP
18 #define HEADER_SUPERTUX_GUI_MENU_FILESYSTEM_HPP
19 
20 #include "gui/menu.hpp"
21 
22 class FileSystemMenu final : public Menu
23 {
24 public:
25  FileSystemMenu(std::string* filename, const std::vector<std::string>& extensions,
26  const std::string& basedir, bool path_relative_to_basedir, const std::function<void(const std::string&)> callback = nullptr,
27  const std::function<void (MenuItem&)>& item_processor = {});
28  ~FileSystemMenu() override;
29 
30  void menu_action(MenuItem& item) override;
31 
32 private:
33  void refresh_items();
34  bool has_right_suffix(const std::string& file) const;
35 
36 private:
37  std::string* m_filename;
38  std::string m_directory;
39  std::vector<std::string> m_extensions;
40  std::string m_basedir;
41  std::vector<std::string> m_directories;
42  std::vector<std::string> m_files;
43  bool m_path_relative_to_basedir;
44  std::function<void(const std::string&)> m_callback;
45  std::function<void (MenuItem&)> m_item_processor;
46 
47 private:
48  FileSystemMenu(const FileSystemMenu&) = delete;
49  FileSystemMenu& operator=(const FileSystemMenu&) = delete;
50 };
51 
52 #endif
53 
54 /* EOF */
Definition: menu_item.hpp:23
Definition: menu.hpp:55
Definition: menu_filesystem.hpp:22