SuperTuxKart
addons_pack.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2019 SuperTuxKart-Team
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 3
7 // of the License, or (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, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 
18 #ifndef HEADER_ADDONS_PACK_HPP
19 #define HEADER_ADDONS_PACK_HPP
20 
21 #include "guiengine/widgets.hpp"
22 #include "guiengine/modaldialog.hpp"
23 #include "utils/cpp2011.hpp"
24 
25 class AddonsPackRequest;
26 
31 {
32 private:
33  GUIEngine::ProgressBarWidget* m_progress;
34 
35  GUIEngine::LabelWidget* m_size;
36 
37  void stopDownload();
38  void doInstall();
39 
42  std::shared_ptr<AddonsPackRequest> m_download_request;
43  AddonsPack(const std::string& url);
44  ~AddonsPack();
45 public:
46  virtual GUIEngine::EventPropagation processEvent(const std::string& event_source) OVERRIDE;
47  virtual void beforeAddingWidgets() OVERRIDE;
48  virtual void init() OVERRIDE;
49  void onUpdate(float delta) OVERRIDE;
50  virtual bool onEscapePressed() OVERRIDE;
51  static void install(const std::string& name);
52  static void uninstall(const std::string& name, bool force_remove_skin = false);
53  static void uninstallByName(const std::string& name, bool force_clear = false);
54 }; // DownloadAssets
55 
56 #endif
Definition: addons_pack.hpp:30
virtual GUIEngine::EventPropagation processEvent(const std::string &event_source) OVERRIDE
Returns whether to block event propagation (usually, you will want to block events you processed)
Definition: addons_pack.cpp:145
std::shared_ptr< AddonsPackRequest > m_download_request
A pointer to the download request, which gives access to the progress of a download.
Definition: addons_pack.hpp:42
virtual bool onEscapePressed() OVERRIDE
Override to change what happens on escape pressed.
Definition: addons_pack.cpp:138
Definition: addons_pack.cpp:46
void onUpdate(float delta) OVERRIDE
Override to be notified of updates.
Definition: addons_pack.cpp:164
void stopDownload()
This function is called when the user click on 'Back', 'Cancel' or press escape.
Definition: addons_pack.cpp:202
void doInstall()
Called when the asynchronous download of the addon finished.
Definition: addons_pack.cpp:217
virtual void beforeAddingWidgets() OVERRIDE
Optional callback invoked very early, before widgets have been added (contrast with init(),...
Definition: addons_pack.cpp:126
A simple label widget.
Definition: label_widget.hpp:35
AddonsPack(const std::string &url)
Creates a modal dialog with given percentage of screen width and height.
Definition: addons_pack.cpp:96
virtual void init() OVERRIDE
Optional callback invoked after widgets have been add()ed.
Definition: addons_pack.cpp:132
Abstract base class representing a modal dialog.
Definition: modaldialog.hpp:55
A progress bar widget.
Definition: progress_bar_widget.hpp:35