SuperTuxKart
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
Addon Class Reference

Public Types

enum  AddonStatus {
  AS_APPROVED = 0x0001, AS_ALPHA = 0x0002, AS_BETA = 0x0004, AS_RC = 0x0008,
  AS_INVISIBLE = 0x0010, AS_DFSG = 0x0040, AS_FEATURED = 0x0080, AS_LATEST = 0X0100,
  AS_BAD_DIM = 0x0200
}
 AddonStatus flags - a bit pattern. More...
 
enum  SortOrder { SO_DEFAULT, SO_NAME, SO_DATE }
 Set the sort order used in the comparison function. More...
 

Public Member Functions

 Addon (const XMLNode &xml)
 Initialises the object from an XML node. More...
 
void deleteInvalidIconFile ()
 Deletes the icon file of this addon, and marks it to be re-downloaded (next time AddonsManager::downloadIcons() is called.
 
void writeXML (std::ofstream *out_stram)
 Writes information about an installed addon (it is only called for installed addons). More...
 
void copyInstallData (const Addon &addon)
 Copies the installation data (like description, revision, icon) from the downloaded online list to this entry.
 
const core::stringw & getName () const
 Returns the name of the addon. More...
 
const std::string & getMinIncludeVer () const
 Returns the minimum version the addon was included with. More...
 
const std::string & getMaxIncludeVer () const
 Returns the maximum version the addon was included with. More...
 
const float getRating () const
 Returns the rating of an addon. More...
 
void setRating (const float rating) const
 Sets the rating of an addon. More...
 
const std::string & getType () const
 Returns the type of the addon. More...
 
const std::string & getZipFileName () const
 Returns the filename of the zip file with the addon. More...
 
const std::string & getIconURL () const
 Returns the name of the icon of this addon. More...
 
const std::string & getIconBasename () const
 Returns the name of the icon (i.e. More...
 
const core::stringw & getDescription () const
 Returns the name of the addon. More...
 
StkTime::TimeType getDate () const
 Returns the date (in seconds since epoch) when the addon was uploaded. More...
 
std::string getDateAsString () const
 Returns a user readable date as a string. More...
 
bool isInstalled () const
 Returns if the addon is installed. More...
 
int getInstalledRevision () const
 Returns the installed revision number of an addon. More...
 
int getRevision () const
 Returns the latest revision number of this addon. More...
 
const std::string & getId () const
 Returns the ID of this addon. More...
 
const core::stringw & getDesigner () const
 Returns the designer of the addon. More...
 
bool getStillExists () const
 Returns if this addon still exists on the server. More...
 
void setStillExists ()
 Marks that this addon still exists on the server. More...
 
bool needsUpdate () const
 True if this addon needs to be updated. More...
 
bool iconNeedsUpdate () const
 Returns true if the (cached) icon needs to be updated. More...
 
void setInstalled (bool state)
 Marks this addon to be installed. More...
 
bool iconReady () const
 Returns true if the icon of this addon was downloaded and is ready to be displayed. More...
 
void setIconReady ()
 Marks that the icon for this addon can be displayed. More...
 
int getSize () const
 Returns the size of the compressed package. More...
 
std::string getTypeDirectory () const
 Returns the directory in which this type of addons is stored (in a separate subdirectory). More...
 
bool testIncluded (const std::string &min_ver, const std::string &max_ver)
 Returns if the current version is between min and max versions.
 
bool testStatus (AddonStatus n) const
 Returns if a certain status flag is set. More...
 
std::string getDataDir () const
 Returns the directory in which this addon is installed. More...
 
bool filterByWords (const core::stringw words) const
 Filter the add-on with a list of words. More...
 
bool operator< (const Addon &a) const
 Compares two addons according to the sort order currently defined. More...
 
const std::string & getDirName () const
 

Static Public Member Functions

static bool isAddon (const std::string &directory)
 A static function that checks if the given ID is an addon. More...
 
static std::string createAddonId (const std::string &id)
 Create an addon id by adding a 'addon_' prefix to the given id. More...
 
static void setSortOrder (SortOrder so)
 Sets the sort order used in the comparison function. More...
 

Private Attributes

core::stringw m_name
 The name to be displayed. More...
 
std::string m_id
 Internal id for this addon, which is the name in lower case. More...
 
std::string m_dir_name
 The directory name (i.d. More...
 
core::stringw m_designer
 The name of the designer of the addon. More...
 
int m_revision
 The (highest) revision number available online. More...
 
int m_installed_revision
 The currently installed revision. More...
 
int m_icon_revision
 The version of the icon that was downloaded. More...
 
int m_status
 The status flags of this addon. More...
 
bool m_still_exists
 True if this addon still exists on the server, i.e. More...
 
StkTime::TimeType m_date
 Date when the addon was added. More...
 
core::stringw m_description
 A description of this addon. More...
 
std::string m_icon_url
 The URL of the icon (relative to the server)
 
std::string m_icon_basename
 Name of the icon to use. More...
 
bool m_icon_ready
 True if the icon is cached/loaded and can be displayed. More...
 
std::string m_zip_file
 The name of the zip file on the addon server. More...
 
bool m_installed
 True if the addon is installed. More...
 
int m_size
 Compressed size of the addon package. More...
 
float m_rating
 Rating for thsi addon package. More...
 
std::string m_min_include_ver
 Minimum version addon is included with. More...
 
std::string m_max_include_ver
 Maximum version addon is included with. More...
 
std::string m_type
 Type, must be 'kart' or 'track'. More...
 

Static Private Attributes

static SortOrder m_sort_order =Addon::SO_DEFAULT
 The sort order to be used in the comparison. More...
 

Member Enumeration Documentation

◆ AddonStatus

AddonStatus flags - a bit pattern.

◆ SortOrder

Set the sort order used in the comparison function.

Constructor & Destructor Documentation

◆ Addon()

Addon::Addon ( const XMLNode xml)

Initialises the object from an XML node.

Member Function Documentation

◆ createAddonId()

static std::string Addon::createAddonId ( const std::string &  id)
inlinestatic

Create an addon id by adding a 'addon_' prefix to the given id.

◆ filterByWords()

bool Addon::filterByWords ( const core::stringw  words) const

Filter the add-on with a list of words.

Parameters
wordsA list of words separated by ' '.
Returns
true if the add-on contains one of the words, otherwise false.

◆ getDataDir()

std::string Addon::getDataDir ( ) const

Returns the directory in which this addon is installed.

◆ getDate()

StkTime::TimeType Addon::getDate ( ) const
inline

Returns the date (in seconds since epoch) when the addon was uploaded.

◆ getDateAsString()

std::string Addon::getDateAsString ( ) const

Returns a user readable date as a string.

◆ getDescription()

const core::stringw& Addon::getDescription ( ) const
inline

Returns the name of the addon.

◆ getDesigner()

const core::stringw& Addon::getDesigner ( ) const
inline

Returns the designer of the addon.

◆ getIconBasename()

const std::string& Addon::getIconBasename ( ) const
inline

Returns the name of the icon (i.e.

the basename of the url).

◆ getIconURL()

const std::string& Addon::getIconURL ( ) const
inline

Returns the name of the icon of this addon.

◆ getId()

const std::string& Addon::getId ( ) const
inline

Returns the ID of this addon.

◆ getInstalledRevision()

int Addon::getInstalledRevision ( ) const
inline

Returns the installed revision number of an addon.

◆ getMaxIncludeVer()

const std::string& Addon::getMaxIncludeVer ( ) const
inline

Returns the maximum version the addon was included with.

◆ getMinIncludeVer()

const std::string& Addon::getMinIncludeVer ( ) const
inline

Returns the minimum version the addon was included with.

◆ getName()

const core::stringw& Addon::getName ( ) const
inline

Returns the name of the addon.

◆ getRating()

const float Addon::getRating ( ) const
inline

Returns the rating of an addon.

◆ getRevision()

int Addon::getRevision ( ) const
inline

Returns the latest revision number of this addon.

m_revision>m_installed_revision if a newer revision is available online.

◆ getSize()

int Addon::getSize ( ) const
inline

Returns the size of the compressed package.

◆ getStillExists()

bool Addon::getStillExists ( ) const
inline

Returns if this addon still exists on the server.

◆ getType()

const std::string& Addon::getType ( ) const
inline

Returns the type of the addon.

◆ getTypeDirectory()

std::string Addon::getTypeDirectory ( ) const
inline

Returns the directory in which this type of addons is stored (in a separate subdirectory).

A kart is stored in .../karts/X and tracks in .../tracks/X. If further types are added here, make sure that the name return ends with a "/".

◆ getZipFileName()

const std::string& Addon::getZipFileName ( ) const
inline

Returns the filename of the zip file with the addon.

◆ iconNeedsUpdate()

bool Addon::iconNeedsUpdate ( ) const
inline

Returns true if the (cached) icon needs to be updated.

This is the case if the addon revision number is higher than the revision number of the icon (this leaves some chance of false positives - i.e. icons that were not changed will still be downloaded).

◆ iconReady()

bool Addon::iconReady ( ) const
inline

Returns true if the icon of this addon was downloaded and is ready to be displayed.

◆ isAddon()

bool Addon::isAddon ( const std::string &  directory)
static

A static function that checks if the given ID is an addon.

This is done by testing if the directory name is in the addons directory.

◆ isInstalled()

bool Addon::isInstalled ( ) const
inline

Returns if the addon is installed.

◆ needsUpdate()

bool Addon::needsUpdate ( ) const
inline

True if this addon needs to be updated.

◆ operator<()

bool Addon::operator< ( const Addon a) const
inline

Compares two addons according to the sort order currently defined.

Parameters
aThe addon to compare this addon to.

◆ setIconReady()

void Addon::setIconReady ( )
inline

Marks that the icon for this addon can be displayed.

◆ setInstalled()

void Addon::setInstalled ( bool  state)
inline

Marks this addon to be installed.

If the addon is marked as being installed, it also updates the installed revision number to be the same as currently available revision number.

◆ setRating()

void Addon::setRating ( const float  rating) const
inline

Sets the rating of an addon.

◆ setSortOrder()

static void Addon::setSortOrder ( SortOrder  so)
inlinestatic

Sets the sort order used in the comparison function.

It is static, so that each instance can access the sort order.

◆ setStillExists()

void Addon::setStillExists ( )
inline

Marks that this addon still exists on the server.

◆ testStatus()

bool Addon::testStatus ( AddonStatus  n) const
inline

Returns if a certain status flag is set.

◆ writeXML()

void Addon::writeXML ( std::ofstream *  out_stream)

Writes information about an installed addon (it is only called for installed addons).

Parameters
out_streamOutput stream to write to.

Member Data Documentation

◆ m_date

StkTime::TimeType Addon::m_date
private

Date when the addon was added.

◆ m_description

core::stringw Addon::m_description
private

A description of this addon.

◆ m_designer

core::stringw Addon::m_designer
private

The name of the designer of the addon.

◆ m_dir_name

std::string Addon::m_dir_name
private

The directory name (i.d.

the internal id without 'addon_' prefix.

◆ m_icon_basename

std::string Addon::m_icon_basename
private

Name of the icon to use.

◆ m_icon_ready

bool Addon::m_icon_ready
private

True if the icon is cached/loaded and can be displayed.

◆ m_icon_revision

int Addon::m_icon_revision
private

The version of the icon that was downloaded.

◆ m_id

std::string Addon::m_id
private

Internal id for this addon, which is the name in lower case.

This is the name of the subdirectory for this addon with an 'addon_' prefix.

◆ m_installed

bool Addon::m_installed
private

True if the addon is installed.

◆ m_installed_revision

int Addon::m_installed_revision
private

The currently installed revision.

◆ m_max_include_ver

std::string Addon::m_max_include_ver
private

Maximum version addon is included with.

◆ m_min_include_ver

std::string Addon::m_min_include_ver
private

Minimum version addon is included with.

◆ m_name

core::stringw Addon::m_name
private

The name to be displayed.

◆ m_rating

float Addon::m_rating
mutableprivate

Rating for thsi addon package.

◆ m_revision

int Addon::m_revision
private

The (highest) revision number available online.

◆ m_size

int Addon::m_size
private

Compressed size of the addon package.

◆ m_sort_order

Addon::SortOrder Addon::m_sort_order =Addon::SO_DEFAULT
staticprivate

The sort order to be used in the comparison.

◆ m_status

int Addon::m_status
private

The status flags of this addon.

◆ m_still_exists

bool Addon::m_still_exists
private

True if this addon still exists on the server, i.e.

is contained in the addons.xml file.

◆ m_type

std::string Addon::m_type
private

Type, must be 'kart' or 'track'.

◆ m_zip_file

std::string Addon::m_zip_file
private

The name of the zip file on the addon server.


The documentation for this class was generated from the following files: