Add rating to add-on info dialog.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11412 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
stephenjust 2012-07-20 22:48:37 +00:00
parent 1fd75915a9
commit f766785302
4 changed files with 61 additions and 38 deletions

View File

@ -4,15 +4,22 @@
<div x="5%" y="0%" width="90%" proportion="6" layout="horizontal-row" > <div x="5%" y="0%" width="90%" proportion="6" layout="horizontal-row" >
<div width="50%" height="100%" layout="vertical-row" > <div width="40%" height="100%" layout="vertical-row" >
<icon id="icon" align="center" proportion="8" width="100%" icon="gui/loading.png"/> <icon id="icon" align="center" proportion="8" width="100%" icon="gui/loading.png"/>
<spacer proportion="1" /> <spacer proportion="1" />
</div> </div>
<spacer proportion="1" /> <spacer proportion="1" />
<div width="50%" height="50%" layout="vertical-row" > <div width="60%" height="50%" layout="vertical-row" >
<label id="name" width="100%" text_align="left"/> <label id="name" width="100%" text_align="left"/>
<div width="100%" height="100%" layout="horizontal-row" >
<div width="50%" height="100%" layout="vertical-row" >
<label id="size" width="100%" text=""/> <label id="size" width="100%" text=""/>
<label id="revision" width="100%" text=""/> <label id="revision" width="100%" text=""/>
</div>
<div width="50%" height="100%" layout="vertical-row" >
<label id="rating" width="100%" text=""/>
</div>
</div>
<spacer height="10"/> <spacer height="10"/>
<label id="flags" width="100%" text="" word_wrap="true"/> <label id="flags" width="100%" text="" word_wrap="true"/>
</div> </div>

View File

@ -46,6 +46,9 @@ Addon::Addon(const XMLNode &xml)
m_icon_revision = 0; m_icon_revision = 0;
m_size = 0; m_size = 0;
m_date = 0; m_date = 0;
m_min_include_ver = "";
m_max_include_ver = "";
m_rating = 0.0f;
m_icon_ready = false; m_icon_ready = false;
m_still_exists = false; m_still_exists = false;
m_type = xml.getName(); m_type = xml.getName();
@ -102,6 +105,8 @@ Addon::Addon(const XMLNode &xml)
xml.get("min-include-version",&m_min_include_ver ); xml.get("min-include-version",&m_min_include_ver );
xml.get("max-include-version",&m_max_include_ver ); xml.get("max-include-version",&m_max_include_ver );
xml.get("rating", &m_rating );
}; // Addon(const XML&) }; // Addon(const XML&)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -121,6 +126,7 @@ void Addon::copyInstallData(const Addon &addon)
m_date = addon.m_date; m_date = addon.m_date;
m_min_include_ver=addon.m_min_include_ver; m_min_include_ver=addon.m_min_include_ver;
m_max_include_ver=addon.m_max_include_ver; m_max_include_ver=addon.m_max_include_ver;
m_rating = addon.m_rating;
// Support if the type of an addon changes, e.g. this ie necessary // Support if the type of an addon changes, e.g. this ie necessary
// when we introduce 'arena' as type (formerly arenas had type 'track'). // when we introduce 'arena' as type (formerly arenas had type 'track').
m_type = addon.m_type; m_type = addon.m_type;

View File

@ -92,6 +92,8 @@ private:
bool m_installed; bool m_installed;
/** Compressed size of the addon package. */ /** Compressed size of the addon package. */
int m_size; int m_size;
/** Rating for thsi addon package. */
float m_rating;
/** Minimum version addon is included with. */ /** Minimum version addon is included with. */
std::string m_min_include_ver; std::string m_min_include_ver;
/** Maximum version addon is included with. */ /** Maximum version addon is included with. */
@ -124,6 +126,9 @@ public:
/** Returns the maximum version the addon was included with. */ /** Returns the maximum version the addon was included with. */
const std::string& getMaxIncludeVer() const {return m_max_include_ver; } const std::string& getMaxIncludeVer() const {return m_max_include_ver; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the rating of an addon. */
const float getRating() const {return m_rating; }
// ------------------------------------------------------------------------
/** Returns the type of the addon. */ /** Returns the type of the addon. */
const std::string& getType() const { return m_type; } const std::string& getType() const { return m_type; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

View File

@ -99,6 +99,11 @@ void AddonsLoading::beforeAddingWidgets()
->setText(m_addon.getDescription().c_str()); ->setText(m_addon.getDescription().c_str());
core::stringw revision = _("Version: %d", m_addon.getRevision()); core::stringw revision = _("Version: %d", m_addon.getRevision());
getWidget<LabelWidget>("revision")->setText(revision, false); getWidget<LabelWidget>("revision")->setText(revision, false);
char rating_val[4];
std::sprintf(rating_val, "%.1f", m_addon.getRating());
//I18N: for add-on rating, "Rating: 1.5/3.0"
core::stringw rating = _("Rating: %s/%s", rating_val, "3.0");
getWidget<LabelWidget>("rating")->setText(rating, false);
// Display flags for this addon // Display flags for this addon
// ============================ // ============================