SuperTuxKart
addons_loading.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2010-2015 Lucas Baudin
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 
19 #ifndef HEADER_ADDONS_LOADING_HPP
20 #define HEADER_ADDONS_LOADING_HPP
21 
22 #include "addons/addon.hpp"
23 #include "addons/addons_manager.hpp"
24 #include "guiengine/widgets.hpp"
25 #include "guiengine/modaldialog.hpp"
26 #include "utils/cpp2011.hpp"
27 #include "utils/synchronised.hpp"
28 
29 namespace Online { class HTTPRequest; }
30 
35 {
36 private:
37  GUIEngine::ProgressBarWidget *m_progress;
38  GUIEngine::IconButtonWidget *m_back_button;
39  GUIEngine::IconButtonWidget *m_install_button;
40 
42 
44 #ifndef SERVER_ONLY
46 #endif
47  void startDownload();
48  void stopDownload();
49  void doInstall();
50  void doUninstall();
51 
54 
57  std::shared_ptr<Online::HTTPRequest> m_download_request;
58 
59 public:
60  AddonsLoading(const std::string &addon_name);
61 
63 
64  virtual GUIEngine::EventPropagation processEvent(const std::string& event_source) OVERRIDE;
65  virtual void beforeAddingWidgets() OVERRIDE;
66  virtual void init() OVERRIDE;
67 
72  void onUpdate(float delta) OVERRIDE;
73  void voteClicked();
74  void tryInstall();
75  virtual bool onEscapePressed() OVERRIDE;
76 
77 }; // AddonsLoading
78 
79 #endif
void startDownload()
This function is called when the user click on 'Install', 'Uninstall', or 'Update'.
Definition: addons_loading.cpp:323
Addon m_addon
The addon to load.
Definition: addons_loading.hpp:45
~AddonsLoading()
Destructor.
Definition: addons_loading.cpp:80
void stopDownload()
This function is called when the user click on 'Back', 'Cancel' or press escape.
Definition: addons_loading.cpp:339
void doInstall()
Called when the asynchronous download of the addon finished.
Definition: addons_loading.cpp:354
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:43
void onUpdate(float delta) OVERRIDE
This function is called by the GUI, all the frame (or somthing like that).
Definition: addons_loading.cpp:276
Definition: addons_loading.hpp:34
virtual bool onEscapePressed() OVERRIDE
Override to change what happens on escape pressed.
Definition: addons_loading.cpp:193
Definition: addon.hpp:39
virtual void beforeAddingWidgets() OVERRIDE
Optional callback invoked very early, before widgets have been added (contrast with init(),...
Definition: addons_loading.cpp:95
AddonsLoading(const std::string &addon_name)
Creates a modal dialog with given percentage of screen width and height.
Definition: addons_loading.cpp:52
bool m_icon_shown
True if the icon is being displayed.
Definition: addons_loading.hpp:53
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_loading.cpp:219
std::shared_ptr< Online::HTTPRequest > m_download_request
A pointer to the download request, which gives access to the progress of a download.
Definition: addons_loading.hpp:57
virtual void init() OVERRIDE
Optional callback invoked after widgets have been add()ed.
Definition: addons_loading.cpp:183
Abstract base class representing a modal dialog.
Definition: modaldialog.hpp:55
A progress bar widget.
Definition: progress_bar_widget.hpp:35