SuperTuxKart
Loading...
Searching...
No Matches
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.
 
enum  SortOrder { SO_DEFAULT , SO_NAME , SO_DATE }
 Set the sort order used in the comparison function.
 

Public Member Functions

 Addon (const XMLNode &xml)
 Initialises the object from an XML node.
 
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).
 
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.
 
const std::string & getMinIncludeVer () const
 Returns the minimum version the addon was included with.
 
const std::string & getMaxIncludeVer () const
 Returns the maximum version the addon was included with.
 
const float getRating () const
 Returns the rating of an addon.
 
void setRating (const float rating) const
 Sets the rating of an addon.
 
const std::string & getType () const
 Returns the type of the addon.
 
const std::string & getZipFileName () const
 Returns the filename of the zip file with the addon.
 
const std::string & getIconURL () const
 Returns the name of the icon of this addon.
 
const std::string & getIconBasename () const
 Returns the name of the icon (i.e.
 
const core::stringw & getDescription () const
 Returns the name of the addon.
 
StkTime::TimeType getDate () const
 Returns the date (in seconds since epoch) when the addon was uploaded.
 
std::string getDateAsString () const
 Returns a user readable date as a string.
 
bool isInstalled () const
 Returns if the addon is installed.
 
int getInstalledRevision () const
 Returns the installed revision number of an addon.
 
int getRevision () const
 Returns the latest revision number of this addon.
 
const std::string & getId () const
 Returns the ID of this addon.
 
const core::stringw & getDesigner () const
 Returns the designer of the addon.
 
bool getStillExists () const
 Returns if this addon still exists on the server.
 
void setStillExists ()
 Marks that this addon still exists on the server.
 
bool needsUpdate () const
 True if this addon needs to be updated.
 
bool iconNeedsUpdate () const
 Returns true if the (cached) icon needs to be updated.
 
void setInstalled (bool state)
 Marks this addon to be installed.
 
bool iconReady () const
 Returns true if the icon of this addon was downloaded and is ready to be displayed.
 
void setIconReady ()
 Marks that the icon for this addon can be displayed.
 
int getSize () const
 Returns the size of the compressed package.
 
std::string getTypeDirectory () const
 Returns the directory in which this type of addons is stored (in a separate subdirectory).
 
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.
 
std::string getDataDir () const
 Returns the directory in which this addon is installed.
 
bool filterByWords (const core::stringw words) const
 Filter the add-on with a list of words.
 
bool operator< (const Addon &a) const
 Compares two addons according to the sort order currently defined.
 
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.
 
static std::string createAddonId (const std::string &id)
 Create an addon id by adding a 'addon_' prefix to the given id.
 
static void setSortOrder (SortOrder so)
 Sets the sort order used in the comparison function.
 

Private Attributes

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

Static Private Attributes

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

Member Function Documentation

◆ 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.

◆ getIconBasename()

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

Returns the name of the icon (i.e.

the basename of the url).

◆ 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.

◆ 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 "/".

◆ 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).

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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_dir_name

std::string Addon::m_dir_name
private

The directory name (i.d.

the internal id without 'addon_' prefix.

◆ 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_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.


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