SuperTuxKart
|
Public Member Functions | |
AddonsManager () | |
Initialises the non-online component of the addons manager (i.e. | |
~AddonsManager () | |
The destructor saves the installed addons file again. | |
void | init (const XMLNode *xml, bool force_refresh) |
This init function is called from a separate thread (started in news_manager, since the news.xml file contains the address of the addons.xml URL). | |
void | initAddons (const XMLNode *xml) |
This initialises the online portion of the addons manager. | |
void | checkInstalledAddons () |
This function checks if the information in the installed addons file is consistent with what is actually available. | |
Addon * | getAddon (const std::string &id) |
Returns an addon with a given id. | |
int | getAddonIndex (const std::string &id) const |
Returns the index of the addon with the given id, or -1 if no such addon exist. | |
bool | install (const Addon &addon) |
Installs or updates (i.e. | |
bool | uninstall (const Addon &addon) |
Removes all files froma login. | |
void | reInit () |
Reinitialises the addon manager, which happens when the user selects 'reload' in the addon manager. | |
bool | anyAddonsInstalled () const |
void | downloadIconForAddon (const std::string &addon_id, std::weak_ptr< bool > result) |
Download icon for specific addon. | |
bool | onlineReady () const |
Returns true if the list of online addons has been downloaded. | |
bool | wasError () const |
bool | isLoading () const |
void | setErrorState () |
Marks addon as not being available. | |
void | saveInstalled () |
Saves the information about installed addons and cached icons to addons_installed.xml. | |
unsigned int | getNumAddons () const |
Returns the list of addons (installed and uninstalled). | |
const Addon & | getAddon (unsigned int i) |
Returns the i-th addons. | |
bool | hasDownloadedIcons () const |
bool | hasNewAddons () const |
Private Types | |
enum | STATE_TYPE { STATE_INIT , STATE_READY , STATE_ERROR } |
Which state the addons manager is: INIT: Waiting to download the list of addons. More... | |
Private Member Functions | |
void | loadInstalledAddons () |
Loads the installed addons from .../addons/addons_installed.xml. | |
Private Attributes | |
Synchronised< std::vector< Addon > > | m_addons_list |
The list of all addons - installed or uninstalled. | |
std::string | m_file_installed |
Full filename of the addons_installed.xml file. | |
std::vector< std::string > | m_icon_list |
List of loaded icons. | |
Synchronised< STATE_TYPE > | m_state |
bool | m_downloaded_icons |
std::atomic_bool | m_has_new_addons |
|
private |
Which state the addons manager is: INIT: Waiting to download the list of addons.
READY: List is downloaded, manager is ready. ERROR: Error downloading the list, no addons available.
AddonsManager::AddonsManager | ( | ) |
Initialises the non-online component of the addons manager (i.e.
handling the list of already installed addons). The online component is initialised later from a separate thread started from the news manager (see NewsManager::init() ).
AddonsManager::~AddonsManager | ( | ) |
The destructor saves the installed addons file again.
This is necessary so that information about downloaded icons is saved for the next run.
void AddonsManager::checkInstalledAddons | ( | ) |
This function checks if the information in the installed addons file is consistent with what is actually available.
This avoids e.g. that an addon is installed, but not marked here (and therefore shows up as not installed in the addons GUI), see bug #455.
Addon * AddonsManager::getAddon | ( | const std::string & | id | ) |
Returns an addon with a given id.
Raises an assertion if the id is not found!
id | The id to search for. |
int AddonsManager::getAddonIndex | ( | const std::string & | id | ) | const |
Returns the index of the addon with the given id, or -1 if no such addon exist.
id | The (unique) identifier of the addon. |
void AddonsManager::init | ( | const XMLNode * | xml, |
bool | force_refresh | ||
) |
This init function is called from a separate thread (started in news_manager, since the news.xml file contains the address of the addons.xml URL).
xml | The news.xml file, which inclues the data about the addons.xml file (in the 'include' node). |
force_refresh | Download addons.xml, even if the usual waiting period between downloads hasn't passed yet. |
void AddonsManager::initAddons | ( | const XMLNode * | xml | ) |
This initialises the online portion of the addons manager.
It uses the downloaded list of available addons. It is called from init(), which is called from a separate thread, so blocking download requests can be used without blocking the GUI. This function will update the state variable.
xml | The xml tree of addons.xml with information about all available addons. |
bool AddonsManager::install | ( | const Addon & | addon | ) |
Installs or updates (i.e.
remove old and then install a new) an addon. It checks for the directories and then unzips the file (which must already have been downloaded).
addon | Addon data for the addon to install. |
|
inline |
Returns true if the list of online addons has been downloaded.
This is used to grey out the 'addons' entry till a network connections could be established.
void AddonsManager::saveInstalled | ( | ) |
Saves the information about installed addons and cached icons to addons_installed.xml.
If this is not called, information about downloaded icons is lost (and will trigger a complete redownload when STK is started next time).
bool AddonsManager::uninstall | ( | const Addon & | addon | ) |
Removes all files froma login.
addon | The addon to be removed. |
|
private |
The list of all addons - installed or uninstalled.
The list is combined from the addons_installed.xml file first, then information from the downloaded list of items is merged/added to that.