From ff152bfeedabab096435c34d8963e4ea241b6ecf Mon Sep 17 00:00:00 2001 From: hikerstk Date: Fri, 25 Mar 2011 03:20:21 +0000 Subject: [PATCH] Save number of times a message is displayed to the config file. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8057 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/addons/network_http.cpp | 18 ++++++++++++++++++ src/addons/network_http.hpp | 5 +++++ src/config/user_config.hpp | 5 +++++ src/guiengine/widgets/label_widget.cpp | 15 +++++++-------- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/addons/network_http.cpp b/src/addons/network_http.cpp index 07d368851..8dfe106cd 100644 --- a/src/addons/network_http.cpp +++ b/src/addons/network_http.cpp @@ -320,6 +320,7 @@ const core::stringw NetworkHttp::getNextNewsMessage() // Now we have a message that was finished being // displayed --> increase display count. m_news.getData()[m_current_news_message].increaseDisplayCount(); + updateUserConfigFile(); } m_current_news_message++; if(m_current_news_message >= (int)m_news.getData().size()) @@ -331,6 +332,23 @@ const core::stringw NetworkHttp::getNextNewsMessage() return m; } // getNextNewsMessage +// ---------------------------------------------------------------------------- +/** Saves the information about which message was being displayed how often + * to the user config file. + * Note that this function assumes that m_news is already locked! + */ +void NetworkHttp::updateUserConfigFile() const +{ + std::ostringstream o; + for(unsigned int i=0; i > m_news; @@ -108,6 +112,7 @@ private: void updateNews(const XMLNode *xml, const std::string &filename); + void updateUserConfigFile() const; void loadAddonsList(const XMLNode *xml, const std::string &filename); std::string downloadToStrInternal(std::string url); diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index 09d6da7ec..0418bd7e3 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -432,6 +432,11 @@ namespace UserConfigParams &m_addon_group, "How often news should be updated.") ); + PARAM_PREFIX StringUserConfigParam m_display_count + PARAM_DEFAULT( StringUserConfigParam("", "news_display_count", + &m_addon_group, + "How often all news messages have been displayed") ); + PARAM_PREFIX TimeUserConfigParam m_addons_last_updated PARAM_DEFAULT( TimeUserConfigParam(0, "addon_last_updated", &m_addon_group, diff --git a/src/guiengine/widgets/label_widget.cpp b/src/guiengine/widgets/label_widget.cpp index d0ddd8174..27c3a54c3 100644 --- a/src/guiengine/widgets/label_widget.cpp +++ b/src/guiengine/widgets/label_widget.cpp @@ -107,7 +107,7 @@ void LabelWidget::add() IGUIFont* font = m_title_font ? GUIEngine::getTitleFont() : GUIEngine::getFont(); core::dimension2du r = font->getDimension(getText().c_str()); - m_scroll_offset = r.Width; + m_scroll_offset = (float)r.Width; } } // add @@ -128,7 +128,7 @@ void LabelWidget::setText(const wchar_t *text) if (m_scroll_speed > 0) { - m_scroll_offset = m_element->getAbsolutePosition().getWidth(); + m_scroll_offset = (float)m_element->getAbsolutePosition().getWidth(); } Widget::setText(text); @@ -142,11 +142,9 @@ void LabelWidget::update(float dt) { if (m_scroll_speed != 0) { - m_scroll_offset -= dt*m_scroll_speed*5.0f; - - //printf("m_scroll_offset = %f; x = %f\n", m_scroll_offset, m_x + m_scroll_offset); - - m_element->setRelativePosition( core::position2di( /*m_x +*/ m_scroll_offset, /*m_y*/ 0 ) ); + m_scroll_offset -= dt*m_scroll_speed*5.0f; + m_element->setRelativePosition( core::position2di( /*m_x +*/ (int)m_scroll_offset, + /*m_y*/ 0 ) ); } } // update // ---------------------------------------------------------------------------- @@ -162,7 +160,8 @@ bool LabelWidget::scrolledOff() const /** Sets horizontal scroll speed. */ void LabelWidget::setScrollSpeed(float speed) { - m_scroll_offset = -m_element->getAbsolutePosition().getWidth() - 10; // start scrolled off + // start scrolled off + m_scroll_offset = (float)(-m_element->getAbsolutePosition().getWidth()-10); m_scroll_speed = speed; } // setScrollSpeed