Apply patch by Uni_ to fix error reporting when downloading an addon fails. Thanks\!

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12716 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2013-04-30 23:17:46 +00:00
parent 09173c479a
commit 0ace825d5f
3 changed files with 49 additions and 26 deletions

View File

@@ -44,14 +44,7 @@ void BubbleWidget::add()
{
m_shrinked_size = rect<s32>(m_x, m_y, m_x + m_w - BUBBLE_MARGIN_ON_RIGHT, m_y + m_h);
stringw message = getText();
EGUI_ALIGNMENT align = EGUIA_UPPERLEFT;
if (m_properties[PROP_TEXT_ALIGN] == "center") align = EGUIA_CENTER;
else if (m_properties[PROP_TEXT_ALIGN] == "right") align = EGUIA_LOWERRIGHT;
else if (translations->isRTLLanguage()) align = EGUIA_LOWERRIGHT;
EGUI_ALIGNMENT valign = EGUIA_CENTER ; //TODO: make label v-align configurable through XML file?
m_shrinked_size.LowerRightCorner.Y -= BOTTOM_MARGIN;
IGUIStaticText* irrwidget;
@@ -64,6 +57,30 @@ void BubbleWidget::add()
irrwidget->setRightToLeft( translations->isRTLLanguage() );
#endif
m_element = irrwidget;
replaceText();
m_id = m_element->getID();
m_element->setTabOrder(m_id);
m_element->setTabStop(true);
m_element->setNotClipped(true);
irrwidget->setDrawBorder(true);
}
void BubbleWidget::replaceText()
{
IGUIStaticText* irrwidget = (IGUIStaticText*) m_element;
stringw message = getText();
EGUI_ALIGNMENT align = EGUIA_UPPERLEFT;
if (m_properties[PROP_TEXT_ALIGN] == "center") align = EGUIA_CENTER;
else if (m_properties[PROP_TEXT_ALIGN] == "right") align = EGUIA_LOWERRIGHT;
else if (translations->isRTLLanguage()) align = EGUIA_LOWERRIGHT;
EGUI_ALIGNMENT valign = EGUIA_CENTER ; //TODO: make label v-align configurable through XML file?
// find expanded bubble size
int text_height = irrwidget->getTextHeight();
@@ -96,17 +113,16 @@ void BubbleWidget::add()
}
}
m_shrinked_text = message;
m_element = irrwidget;
irrwidget->setTextAlignment( align, valign );
m_id = m_element->getID();
m_element->setTabOrder(m_id);
m_element->setTabStop(true);
m_element->setNotClipped(true);
irrwidget->setDrawBorder(true);
}
void BubbleWidget::setText(const irr::core::stringw &s)
{
Widget::setText(s);
//If add() has already been called (and thus m_element is set) we need to replace the text.
if(m_element != NULL){
replaceText();
}
}
void BubbleWidget::updateSize()

View File

@@ -52,6 +52,9 @@ namespace GUIEngine
/** For the skin to create the zooming effect */
float m_zoom;
/** Will add/replace text in the bubble. If it doesn't fit, the text will get shrinked. **/
void replaceText();
public:
LEAK_CHECK()
@@ -63,6 +66,10 @@ namespace GUIEngine
virtual EventPropagation focused(const int playerID);
void updateSize();
void setText(const irr::core::stringw &s);
};
}

View File

@@ -83,7 +83,7 @@ void AddonsLoading::beforeAddingWidgets()
RibbonWidget* r = getWidget<RibbonWidget>("actions");
if (m_addon.isInstalled())
{
/* only keep the button as "update" if allowed to access the net
@@ -91,7 +91,7 @@ void AddonsLoading::beforeAddingWidgets()
*/
if (m_addon.needsUpdate() && !addons_manager->wasError()
&& UserConfigParams::m_internet_status==INetworkHttp::IPERM_ALLOWED)
getWidget<IconButtonWidget> ("install")->setText( _("Update") );
getWidget<IconButtonWidget> ("install")->setLabel( _("Update") );
else
r->removeChildNamed("install");
}
@@ -227,7 +227,7 @@ GUIEngine::EventPropagation
m_progress->setValue(0);
m_progress->setVisible(true);
// Change the 'back' button into a 'cancel' button.
m_back_button->setText(_("Cancel"));
m_back_button->setLabel(_("Cancel"));
RibbonWidget* r = getWidget<RibbonWidget>("actions");
r->setVisible(false);
@@ -261,7 +261,7 @@ void AddonsLoading::onUpdate(float delta)
}
else if(progress>=1.0f)
{
m_back_button->setText(_("Back"));
m_back_button->setLabel(_("Back"));
// No sense to update state text, since it all
// happens before the GUI is refrehsed.
doInstall();
@@ -309,7 +309,7 @@ void AddonsLoading::doInstall()
core::stringw msg = StringUtils::insertValues(
_("Problems installing the addon '%s'."),
core::stringw(m_addon.getName().c_str()));
m_back_button->setText(msg.c_str());
getWidget<BubbleWidget>("description")->setText(msg.c_str());
}
if(error)
@@ -319,7 +319,7 @@ void AddonsLoading::doInstall()
RibbonWidget* r = getWidget<RibbonWidget>("actions");
r->setVisible(true);
m_install_button->setText(_("Try again"));
m_install_button->setLabel(_("Try again"));
}
else
{
@@ -349,7 +349,7 @@ void AddonsLoading::doUninstall()
core::stringw msg = StringUtils::insertValues(
_("Problems removing the addon '%s'."),
core::stringw(m_addon.getName().c_str()));
m_back_button->setText(msg.c_str());
getWidget<BubbleWidget>("description")->setText(msg.c_str());
}
if(error)
@@ -359,7 +359,7 @@ void AddonsLoading::doUninstall()
RibbonWidget* r = getWidget<RibbonWidget>("actions");
r->setVisible(true);
m_install_button->setText(_("Try again"));
m_install_button->setLabel(_("Try again"));
}
else
{