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/modaldialog.hpp"
25 #include "utils/cpp2011.hpp"
26 #include "utils/synchronised.hpp"
27 
28 namespace GUIEngine { class IconButtonWidget; class ProgressBarWidget; }
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 
56 
57  std::shared_ptr<bool> m_icon_downloaded;
60  std::shared_ptr<Online::HTTPRequest> m_download_request;
61 
62 public:
63  AddonsLoading(const std::string &addon_name);
64 
66 
67  virtual GUIEngine::EventPropagation processEvent(const std::string& event_source) OVERRIDE;
68  virtual void beforeAddingWidgets() OVERRIDE;
69  virtual void init() OVERRIDE;
70 
75  void onUpdate(float delta) OVERRIDE;
76  void voteClicked();
77  void tryInstall();
78  virtual bool onEscapePressed() OVERRIDE;
79 
80 }; // AddonsLoading
81 
82 #endif
Definition: addon.hpp:40
Definition: addons_loading.hpp:35
void onUpdate(float delta) OVERRIDE
This function is called by the GUI, all the frame (or somthing like that).
Definition: addons_loading.cpp:303
virtual void init() OVERRIDE
Optional callback invoked after widgets have been add()ed.
Definition: addons_loading.cpp:196
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:236
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:60
void doInstall()
Called when the asynchronous download of the addon finished.
Definition: addons_loading.cpp:381
Addon m_addon
The addon to load.
Definition: addons_loading.hpp:45
void startDownload()
This function is called when the user click on 'Install', 'Uninstall', or 'Update'.
Definition: addons_loading.cpp:350
virtual void beforeAddingWidgets() OVERRIDE
Optional callback invoked very early, before widgets have been added (contrast with init(),...
Definition: addons_loading.cpp:108
bool m_message_shown
True if the error message has shown once.
Definition: addons_loading.hpp:55
void stopDownload()
This function is called when the user click on 'Back', 'Cancel' or press escape.
Definition: addons_loading.cpp:366
~AddonsLoading()
Destructor.
Definition: addons_loading.cpp:93
bool m_icon_shown
True if the icon is being displayed.
Definition: addons_loading.hpp:53
AddonsLoading(const std::string &addon_name)
Creates a modal dialog with given percentage of screen width and height.
Definition: addons_loading.cpp:59
virtual bool onEscapePressed() OVERRIDE
Override to change what happens on escape pressed.
Definition: addons_loading.cpp:206
A button widget with an icon and optionnaly a label beneath.
Definition: icon_button_widget.hpp:44
Abstract base class representing a modal dialog.
Definition: modaldialog.hpp:56
A progress bar widget.
Definition: progress_bar_widget.hpp:36
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33