Some code cleanups, mostly for addons_loading.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7190 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-12-30 05:40:33 +00:00
parent 809558f1cc
commit cdc1591a11
5 changed files with 17 additions and 28 deletions

View File

@ -22,7 +22,7 @@
#ifndef HEADER_ADDON_HPP
#define HEADER_ADDON_HPP
#include <sstream>
#include <string>
class XMLNode;
@ -68,14 +68,6 @@ public:
* online. */
int getVersion() const {return m_version; }
// ------------------------------------------------------------------------
/** Returns the version as string. */
std::string getVersionAsStr() const
{
std::ostringstream os;
os << m_version;
return os.str();
} // getVersionAsStr
// ------------------------------------------------------------------------
/** Returns the ID of this addon. */
const std::string& getId() const {return m_id; }
// ------------------------------------------------------------------------

View File

@ -61,9 +61,6 @@ public:
const Addon* getAddon(const std::string &id) const;
int getAddonIndex(const std::string &id) const;
/** Get all the selected addon parameters. */
const Addon &getAddons() const;
/** Install or upgrade the selected addon. */
void install(const Addon &addon);

View File

@ -133,9 +133,9 @@ void AddonsScreen::eventCallback(GUIEngine::Widget* widget,
{
GUIEngine::ListWidget* list =
getWidget<GUIEngine::ListWidget>("list_addons");
std::string addons = list->getSelectionInternalName();
std::string id = list->getSelectionInternalName();
new AddonsLoading(0.8f, 0.8f, addons);
new AddonsLoading(0.8f, 0.8f, id);
}
if (name == "category")
{

View File

@ -37,10 +37,10 @@ using namespace irr::gui;
// ----------------------------------------------------------------------------
AddonsLoading::AddonsLoading(const float w, const float h,
const std::string &addon_name)
const std::string &id)
: ModalDialog(w, h)
{
m_addon = *(addons_manager->getAddon(addon_name));
m_addon = *(addons_manager->getAddon(id));
loadFromFile("addons_view_dialog.stkgui");
m_can_install = false;
@ -50,9 +50,6 @@ AddonsLoading::AddonsLoading(const float w, const float h,
/*Init the icon here to be able to load a single image*/
m_icon = getWidget<IconButtonWidget>("icon");
m_name = getWidget<LabelWidget>("name");
m_description = getWidget<LabelWidget>("description");
m_version = getWidget<LabelWidget>("version");
if(m_addon.isInstalled())
{
@ -68,12 +65,18 @@ AddonsLoading::AddonsLoading(const float w, const float h,
// ----------------------------------------------------------------------------
void AddonsLoading::loadInfo()
{
m_name->setText(StringUtils::insertValues(_("Name: %i"),
m_addon.getName().c_str()));
m_description->setText(StringUtils::insertValues(_("Description: %i"),
m_addon.getDescription().c_str()));
m_version->setText(StringUtils::insertValues(_("Version: %i"),
m_addon.getVersionAsStr().c_str()));
core::stringw name = StringUtils::insertValues(_("Name: %i"),
m_addon.getName().c_str() );
getWidget<LabelWidget>("name")->setText(name);
core::stringw desc = StringUtils::insertValues(_("Description: %i"),
m_addon.getDescription().c_str());
getWidget<LabelWidget>("description")->setText(desc);
core::stringw version = StringUtils::insertValues(_("Version: %d"),
m_addon.getVersion());
getWidget<LabelWidget>("version")->setText(version);
pthread_t thread;
pthread_create(&thread, NULL, &AddonsLoading::downloadIcon, this);
}

View File

@ -31,9 +31,6 @@ class AddonsLoading : public GUIEngine::ModalDialog
{
//virtual void escapePressed() {};
private:
GUIEngine::LabelWidget *m_name;
GUIEngine::LabelWidget *m_description;
GUIEngine::LabelWidget *m_version;
GUIEngine::LabelWidget *m_author;
GUIEngine::LabelWidget *m_state;
GUIEngine::ProgressBarWidget *m_progress;