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

@ -1,38 +1,45 @@
<stkgui>
<div x="5%" y="5%" width="90%" height="90%" layout="vertical-row">
<div x="5%" y="0%" width="90%" proportion="6" layout="horizontal-row" >
<div width="50%" height="100%" layout="vertical-row" >
<icon id="icon" align="center" proportion="8" width="100%" icon="gui/loading.png"/>
<spacer proportion="1" />
</div>
<spacer proportion="1" />
<div width="50%" height="50%" layout="vertical-row" >
<label id="name" width="100%" text_align="left"/>
<label id="size" width="100%" text=""/>
<label id="revision" width="100%" text=""/>
<spacer height="10"/>
<label id="flags" width="100%" text="" word_wrap="true"/>
</div>
</div>
<bubble word_wrap="true" id="description" height="100%" width="90%" proportion="5" align="center" />
<div width="80%" proportion="5" align="center">
<buttonbar id="actions" x="0" y="0" height="100%" width="100%" align="center">
<icon-button id="install" width="128" height="128"
icon="gui/package-update.png"
I18N="Add-on screen action" text="Install"/>
<icon-button id="uninstall" width="128" height="128"
icon="gui/package-uninstall.png"
I18N="Add-on screen action" text="Uninstall"/>
<icon-button id="back" width="128" height="128"
icon="gui/back.png"
I18N="Add-ons screen action" text="Back"/>
</buttonbar>
<progressbar id="progress" x="0" y="20%" width="100%" height="30%" />
</div>
</div>
</stkgui>
<stkgui>
<div x="5%" y="5%" width="90%" height="90%" layout="vertical-row">
<div x="5%" y="0%" width="90%" proportion="6" layout="horizontal-row" >
<div width="40%" height="100%" layout="vertical-row" >
<icon id="icon" align="center" proportion="8" width="100%" icon="gui/loading.png"/>
<spacer proportion="1" />
</div>
<spacer proportion="1" />
<div width="60%" height="50%" layout="vertical-row" >
<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="revision" width="100%" text=""/>
</div>
<div width="50%" height="100%" layout="vertical-row" >
<label id="rating" width="100%" text=""/>
</div>
</div>
<spacer height="10"/>
<label id="flags" width="100%" text="" word_wrap="true"/>
</div>
</div>
<bubble word_wrap="true" id="description" height="100%" width="90%" proportion="5" align="center" />
<div width="80%" proportion="5" align="center">
<buttonbar id="actions" x="0" y="0" height="100%" width="100%" align="center">
<icon-button id="install" width="128" height="128"
icon="gui/package-update.png"
I18N="Add-on screen action" text="Install"/>
<icon-button id="uninstall" width="128" height="128"
icon="gui/package-uninstall.png"
I18N="Add-on screen action" text="Uninstall"/>
<icon-button id="back" width="128" height="128"
icon="gui/back.png"
I18N="Add-ons screen action" text="Back"/>
</buttonbar>
<progressbar id="progress" x="0" y="20%" width="100%" height="30%" />
</div>
</div>
</stkgui>

View File

@ -46,6 +46,9 @@ Addon::Addon(const XMLNode &xml)
m_icon_revision = 0;
m_size = 0;
m_date = 0;
m_min_include_ver = "";
m_max_include_ver = "";
m_rating = 0.0f;
m_icon_ready = false;
m_still_exists = false;
m_type = xml.getName();
@ -102,6 +105,8 @@ Addon::Addon(const XMLNode &xml)
xml.get("min-include-version",&m_min_include_ver );
xml.get("max-include-version",&m_max_include_ver );
xml.get("rating", &m_rating );
}; // Addon(const XML&)
// ----------------------------------------------------------------------------
@ -121,6 +126,7 @@ void Addon::copyInstallData(const Addon &addon)
m_date = addon.m_date;
m_min_include_ver=addon.m_min_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
// when we introduce 'arena' as type (formerly arenas had type 'track').
m_type = addon.m_type;

View File

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

View File

@ -99,6 +99,11 @@ void AddonsLoading::beforeAddingWidgets()
->setText(m_addon.getDescription().c_str());
core::stringw revision = _("Version: %d", m_addon.getRevision());
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
// ============================