Added display of the date for addons (should we perhaps make the

strftime format translatable?).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8645 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2011-05-19 13:09:53 +00:00
parent f6bc7a0a71
commit 8d760b11cd
3 changed files with 28 additions and 4 deletions

@ -21,7 +21,7 @@
#include "addons/addon.hpp" #include "addons/addon.hpp"
#include <fstream> #include <fstream>
//#include <iostream> #include <time.h>
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "io/xml_node.hpp" #include "io/xml_node.hpp"
@ -42,6 +42,7 @@ Addon::Addon(const XMLNode &xml)
m_icon_basename = ""; m_icon_basename = "";
m_icon_revision = 0; m_icon_revision = 0;
m_size = 0; m_size = 0;
m_date = 0;
m_icon_ready = false; m_icon_ready = false;
m_type = xml.getName(); m_type = xml.getName();
@ -50,6 +51,7 @@ Addon::Addon(const XMLNode &xml)
xml.get("id", &m_id ); xml.get("id", &m_id );
xml.get("designer", &m_designer ); xml.get("designer", &m_designer );
xml.get("status", &m_status ); xml.get("status", &m_status );
xml.get("date", &m_date );
xml.get("installed", &m_installed ); xml.get("installed", &m_installed );
xml.get("installed-revision", &m_installed_revision); xml.get("installed-revision", &m_installed_revision);
xml.get("revision", &m_revision ); xml.get("revision", &m_revision );
@ -78,6 +80,7 @@ void Addon::copyInstallData(const Addon &addon)
m_icon_revision = addon.m_revision; m_icon_revision = addon.m_revision;
m_designer = addon.m_designer; m_designer = addon.m_designer;
m_status = addon.m_status; m_status = addon.m_status;
m_date = addon.m_date;
} // copyInstallData } // copyInstallData
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -92,6 +95,7 @@ void Addon::writeXML(std::ofstream *out_stream)
<< "\" id=\"" << m_id << "\" id=\"" << m_id
<< "\" designer=\"" << m_designer << "\" designer=\"" << m_designer
<< "\" status=\"" << m_status << "\" status=\"" << m_status
<< "\" date=\"" << m_date
<< "\" installed=\"" << "\" installed=\""
<< (m_installed ? "true" : "false" ) << (m_installed ? "true" : "false" )
<< "\" installed-revision=\"" << m_installed_revision << "\" installed-revision=\"" << m_installed_revision
@ -100,3 +104,11 @@ void Addon::writeXML(std::ofstream *out_stream)
<< "\"/>\n"; << "\"/>\n";
} // writeXML } // writeXML
// ----------------------------------------------------------------------------
std::string Addon::getDateAsString() const
{
const struct tm *t = gmtime((time_t*)&m_date);
char s[16];
strftime(s, 128, "%d.%m.%Y", t);
return s;
} // getDateAsString

@ -24,6 +24,8 @@
#include <string> #include <string>
#include "io/file_manager.hpp" #include "io/file_manager.hpp"
#include "utils/time.hpp"
class XMLNode; class XMLNode;
class Addon class Addon
@ -56,6 +58,8 @@ public:
int m_icon_revision; int m_icon_revision;
/** The status flags of this addon. */ /** The status flags of this addon. */
int m_status; int m_status;
/** Date when the addon was added. */
Time::TimeType m_date;
/** A description of this addon. */ /** A description of this addon. */
std::string m_description; std::string m_description;
/** The URL of the icon (relative to the server) */ /** The URL of the icon (relative to the server) */
@ -99,6 +103,13 @@ public:
/** Returns the name of the addon. */ /** Returns the name of the addon. */
const std::string& getDescription() const { return m_description; } const std::string& getDescription() const { return m_description; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns the date (in seconds since epoch) when the addon was
* uploaded. */
Time::TimeType getDate() const { return m_date; }
// ------------------------------------------------------------------------
/** Returns a user readable date as a string. */
std::string getDateAsString() const;
// ------------------------------------------------------------------------
/** Returns if the addon is installed. */ /** Returns if the addon is installed. */
bool isInstalled() const { return m_installed; } bool isInstalled() const { return m_installed; }
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------

@ -111,10 +111,11 @@ void AddonsScreen::loadList()
core::stringw s; core::stringw s;
if(addon.getDesigner().size()==0) if(addon.getDesigner().size()==0)
s = addon.getName().c_str(); s = (addon.getName()+"\t"+addon.getDateAsString()).c_str();
else else
s = _("%s by %s", addon.getName().c_str(), s = _("%s by %s\t%d", addon.getName().c_str(),
addon.getDesigner().c_str()); addon.getDesigner().c_str(),
addon.getDateAsString().c_str());
w_list->addItem(addon.getId(), s.c_str(), icon); w_list->addItem(addon.getId(), s.c_str(), icon);
} }