From 078ba48e63ed685f8aa97a936ea7f159f08f8424 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Tue, 17 May 2011 12:01:03 +0000 Subject: [PATCH] Store designer and status flag for addons. Designer is now shown in table view of all addons. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8629 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/addons/addon.cpp | 15 +++++++++++---- src/addons/addon.hpp | 22 ++++++++++++++++++++++ src/states_screens/addons_screen.cpp | 9 +++++++-- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/addons/addon.cpp b/src/addons/addon.cpp index ad5dfedf3..2fbbbae3d 100644 --- a/src/addons/addon.cpp +++ b/src/addons/addon.cpp @@ -31,6 +31,8 @@ Addon::Addon(const XMLNode &xml) { m_name = ""; m_id = ""; + m_designer = ""; + m_status = 0; m_installed = false; m_installed_revision = 0; m_revision = 0 ; @@ -44,8 +46,10 @@ Addon::Addon(const XMLNode &xml) m_type = xml.getName(); xml.get("name", &m_name ); - m_id = StringUtils::toLowerCase(m_name); - xml.get("id", &m_id); + m_id = StringUtils::toLowerCase(m_name); + xml.get("id", &m_id ); + xml.get("designer", &m_designer ); + xml.get("status", &m_status ); xml.get("installed", &m_installed ); xml.get("installed-revision", &m_installed_revision); xml.get("revision", &m_revision ); @@ -72,6 +76,8 @@ void Addon::copyInstallData(const Addon &addon) m_icon_url = addon.m_icon_url; m_icon_basename = addon.m_icon_basename; m_icon_revision = addon.m_revision; + m_designer = addon.m_designer; + m_status = addon.m_status; } // copyInstallData // ---------------------------------------------------------------------------- @@ -84,12 +90,13 @@ void Addon::writeXML(std::ofstream *out_stream) (*out_stream) << " <" << m_type << " name=\"" << m_name << "\" id=\"" << m_id + << "\" designer=\"" << m_designer + << "\" status=\"" << m_status << "\" installed=\"" << (m_installed ? "true" : "false" ) - << "\" installed-revision=\"" << m_installed_revision + << "\" installed-revision=\"" << m_installed_revision << "\" size=\"" << m_size << "\" icon-revision=\"" << m_icon_revision << "\"/>\n"; } // writeXML - diff --git a/src/addons/addon.hpp b/src/addons/addon.hpp index 2f094554a..51f919b49 100644 --- a/src/addons/addon.hpp +++ b/src/addons/addon.hpp @@ -29,17 +29,33 @@ class XMLNode; class Addon { public: + /** AddonStatus flags - a bit pattern. */ + enum AddonStatus {AS_APPROVED = 0x0001, + AS_ALPHA = 0x0002, + AS_BETA = 0x0004, + AS_RC = 0x0008, + AS_FAN = 0x0010, + AS_HQ = 0x0020, + AS_DFSG = 0x0040, + AS_FEATURED = 0x0080, + AS_LATEST = 0X0100, + AS_BAD_DIM = 0x0200 + }; /** The name to be displayed. */ std::string m_name; /** Internal id for this addon, which is the name in lower case. * This is used to create a subdirectory for this addon. */ std::string m_id; + /** The name of the designer of the addon. */ + std::string m_designer; /** The (highest) revision number available online. */ int m_revision; /** The currently installed revision. */ int m_installed_revision; /** The version of the icon that was downloaded. */ int m_icon_revision; + /** The status flags of this addon. */ + int m_status; /** A description of this addon. */ std::string m_description; /** The URL of the icon (relative to the server) */ @@ -97,6 +113,9 @@ public: /** Returns the ID of this addon. */ const std::string& getId() const { return m_id; } // ------------------------------------------------------------------------ + /** Returns the designer of the addon. */ + const std::string &getDesigner() const { return m_designer; } + // ------------------------------------------------------------------------ /** True if this addon needs to be updated. */ bool needsUpdate() const { @@ -152,6 +171,9 @@ public: return ""; // Ignore compiler warning } // getTypeDirectory + // ------------------------------------------------------------------------ + /** Returns if a certain status flag is set. */ + bool testStatus(AddonStatus n) const {return (m_status & n) !=0; } // ------------------------------------------------------------------------ /** Returns the directory in which this addon is installed. */ std::string getDataDir() const diff --git a/src/states_screens/addons_screen.cpp b/src/states_screens/addons_screen.cpp index 96e51d969..5ed684ed5 100644 --- a/src/states_screens/addons_screen.cpp +++ b/src/states_screens/addons_screen.cpp @@ -105,8 +105,13 @@ void AddonsScreen::loadList() else icon = m_icon_not_installed; - w_list->addItem(addon.getId(), addon.getName().c_str(), - icon); + core::stringw s; + if(addon.getDesigner().size()==0) + s = addon.getName().c_str(); + else + s = _("%s by %s", addon.getName().c_str(), + addon.getDesigner().c_str()); + w_list->addItem(addon.getId(), s.c_str(), icon); } getWidget("category")->setActivated();