supertux
addon_preview_menu.hpp
1 // SuperTux
2 // Copyright (C) 2022-2023 Vankata453
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_SUPERTUX_MENU_ADDON_PREVIEW_MENU_HPP
18 #define HEADER_SUPERTUX_SUPERTUX_MENU_ADDON_PREVIEW_MENU_HPP
19 
20 #include "gui/menu.hpp"
21 
22 #include <vector>
23 
24 #include "addon/downloader_defines.hpp"
25 
26 class Addon;
27 class AddonManager;
28 
29 class AddonPreviewMenu final : public Menu
30 {
31  enum {
32  MNID_SCREENSHOTS,
33  MNID_SHOW_SCREENSHOTS,
34  MNID_INSTALL,
35  MNID_UNINSTALL,
36  MNID_TOGGLE
37  };
38 
39 private:
40  AddonManager& m_addon_manager;
41  const Addon& m_addon;
42  const bool m_auto_install;
43  const bool m_update;
44 
45  bool m_addon_enabled;
46  bool m_show_screenshots;
47  TransferStatusListPtr m_screenshot_download_status;
48  bool m_screenshot_download_success;
49 
50 public:
51  AddonPreviewMenu(const Addon& addon, bool auto_install = false, bool update = false);
52  ~AddonPreviewMenu() override;
53 
54  void menu_action(MenuItem& item) override;
55 
56 private:
57  void rebuild_menu();
58 
59  void show_screenshots();
60  void install_addon();
61  void uninstall_addon();
62  void toggle_addon();
63 
64 private:
65  AddonPreviewMenu(const AddonPreviewMenu&) = delete;
66  AddonPreviewMenu& operator=(const AddonPreviewMenu&) = delete;
67 };
68 
69 #endif
70 
71 /* EOF */
Definition: menu_item.hpp:23
Checks for, installs and removes Add-ons.
Definition: addon_manager.hpp:36
Definition: addon.hpp:27
Definition: addon_preview_menu.hpp:29
Definition: menu.hpp:55