Changed layout of addons loading screen: made screen shot

smaller (since esp. icons are small anyway and look ugly
when scaled up), removed 'state' label.
The flags are now shown as well (not sure if they should
be all translated), and only approved addons are shown
for people without artist-debug mode set.
Added callback to header list (which don't do anything atm).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8638 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2011-05-18 23:10:04 +00:00
parent 0a2c9fc318
commit af710f70d8
4 changed files with 77 additions and 24 deletions

View File

@ -2,7 +2,6 @@
<div x="5%" y="5%" width="90%" height="90%" layout="vertical-row"> <div x="5%" y="5%" width="90%" height="90%" layout="vertical-row">
<label width="100%" id="name" text_align="center"/>
<div x="5%" y="0%" width="90%" proportion="6" layout="horizontal-row" > <div x="5%" y="0%" width="90%" proportion="6" layout="horizontal-row" >
<div width="50%" height="100%" layout="vertical-row" > <div width="50%" height="100%" layout="vertical-row" >
@ -10,22 +9,24 @@
<spacer proportion="1" /> <spacer proportion="1" />
</div> </div>
<spacer proportion="1" /> <spacer proportion="1" />
<div width="50%" height="100%" layout="vertical-row" > <div width="50%" height="50%" layout="vertical-row" >
<bubble word_wrap="true" id="description" height="100%" width="100%" proportion="1" /> <label id="name" width="100%" text_align="left"/>
<label id="size" width="100%" text=""/> <label id="size" width="100%" text=""/>
<label id="revision" width="100%" text=""/> <label id="revision" width="100%" text=""/>
<label id="flags1" width="100%" text=""/>
<label id="flags2" width="100%" text=""/>
</div> </div>
</div> </div>
<div width="70%" proportion="1" align="center"> <bubble word_wrap="true" id="description" height="100%" x="5%" width="90%" proportion="6" />
<div width="90%" proportion="2" align="center">
<button id="install" x="0" y="0" width="100%" height="100%" I18N="Addons" text="Install"/> <button id="install" x="0" y="0" width="100%" height="100%" I18N="Addons" text="Install"/>
<progressbar id="progress" x="0" y="20%" width="100%" height="60%" /> <progressbar id="progress" x="0" y="20%" width="100%" height="60%" />
</div> </div>
<spacer height="10" /> <spacer height="10" />
<button id="cancel" proportion="1" x="5%" width="70%" I18N="Addons" text="Back" align="center"/> <button id="cancel" proportion="2" x="5%" width="90%" I18N="Addons" text="Back" align="center"/>
<label id="state" proportion="1" width="100%" text="" text_align="center" />
</div> </div>
</stkgui> </stkgui>

View File

@ -60,6 +60,7 @@ void AddonsScreen::loadedFromFile()
getWidget<GUIEngine::ListWidget>("list_addons"); getWidget<GUIEngine::ListWidget>("list_addons");
w_list->addColumn( L"Add-on name" ); w_list->addColumn( L"Add-on name" );
w_list->addColumn( L"Updated date" ); w_list->addColumn( L"Updated date" );
w_list->setColumnListener(this);
} // loadedFromFile } // loadedFromFile
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -96,6 +97,9 @@ void AddonsScreen::loadList()
const Addon &addon = addons_manager->getAddon(i); const Addon &addon = addons_manager->getAddon(i);
// Ignore addons of a different type // Ignore addons of a different type
if(addon.getType()!=m_type) continue; if(addon.getType()!=m_type) continue;
if(!UserConfigParams::m_artist_debug_mode &&
!addon.testStatus(Addon::AS_APPROVED) )
continue;
// Get the right icon to display // Get the right icon to display
int icon; int icon;
@ -126,6 +130,11 @@ void AddonsScreen::loadList()
PLAYER_ID_GAME_MASTER); PLAYER_ID_GAME_MASTER);
} // loadList } // loadList
// ----------------------------------------------------------------------------
void AddonsScreen::onColumnClicked(int columnId)
{
printf("Clicked on column %d.\n", columnId);
} // onColumnClicked
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void AddonsScreen::eventCallback(GUIEngine::Widget* widget, void AddonsScreen::eventCallback(GUIEngine::Widget* widget,
const std::string& name, const int playerID) const std::string& name, const int playerID)

View File

@ -37,7 +37,8 @@ namespace GUIEngine { class Widget; }
* \ingroup states_screens * \ingroup states_screens
*/ */
class AddonsScreen : public GUIEngine::Screen, class AddonsScreen : public GUIEngine::Screen,
public GUIEngine::ScreenSingleton<AddonsScreen> public GUIEngine::ScreenSingleton<AddonsScreen>,
public GUIEngine::IListWidgetHeaderListener
{ {
friend class GUIEngine::ScreenSingleton<AddonsScreen>; friend class GUIEngine::ScreenSingleton<AddonsScreen>;
private: private:
@ -69,6 +70,8 @@ public:
/** \brief implement callback from parent class GUIEngine::Screen */ /** \brief implement callback from parent class GUIEngine::Screen */
virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID); virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID);
virtual void onColumnClicked(int columnId);
virtual void init(); virtual void init();
friend void *startInstall(void *); friend void *startInstall(void *);

View File

@ -25,6 +25,7 @@
#include "addons/addons_manager.hpp" #include "addons/addons_manager.hpp"
#include "addons/network_http.hpp" #include "addons/network_http.hpp"
#include "addons/request.hpp" #include "addons/request.hpp"
#include "config/user_config.hpp"
#include "guiengine/engine.hpp" #include "guiengine/engine.hpp"
#include "guiengine/widgets.hpp" #include "guiengine/widgets.hpp"
#include "input/input_manager.hpp" #include "input/input_manager.hpp"
@ -52,7 +53,6 @@ AddonsLoading::AddonsLoading(const float w, const float h,
m_progress = getWidget<ProgressBarWidget>("progress"); m_progress = getWidget<ProgressBarWidget>("progress");
m_install_button = getWidget<ButtonWidget> ("install" ); m_install_button = getWidget<ButtonWidget> ("install" );
m_back_button = getWidget<ButtonWidget> ("cancel" ); m_back_button = getWidget<ButtonWidget> ("cancel" );
m_state = getWidget<LabelWidget> ("state" );
if(m_progress) if(m_progress)
m_progress->setVisible(false); m_progress->setVisible(false);
@ -63,29 +63,69 @@ AddonsLoading::AddonsLoading(const float w, const float h,
getWidget<ButtonWidget>("install")->setLabel(_("Update")); getWidget<ButtonWidget>("install")->setLabel(_("Update"));
else else
getWidget<ButtonWidget>("install")->setLabel(_("Uninstall")); getWidget<ButtonWidget>("install")->setLabel(_("Uninstall"));
} } // if isInstalled
} // AddonsLoading
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void AddonsLoading::beforeAddingWidgets() void AddonsLoading::beforeAddingWidgets()
{ {
/*Init the icon here to be able to load a single image*/ /* Init the icon here to be able to load a single image*/
m_icon = getWidget<IconButtonWidget> ("icon" ); m_icon = getWidget<IconButtonWidget> ("icon" );
m_progress = getWidget<ProgressBarWidget>("progress"); m_progress = getWidget<ProgressBarWidget>("progress");
m_install_button = getWidget<ButtonWidget> ("install" );
m_back_button = getWidget<ButtonWidget> ("cancel" ); m_back_button = getWidget<ButtonWidget> ("cancel" );
m_state = getWidget<LabelWidget> ("state" );
getWidget<LabelWidget>("name")->setText(m_addon.getName().c_str(), false); getWidget<LabelWidget>("name")->setText(m_addon.getName().c_str(), false);
getWidget<BubbleWidget>("description")->setText(m_addon.getDescription().c_str()); getWidget<BubbleWidget>("description")->setText(m_addon.getDescription().c_str());
core::stringw revision = _("Version: %d", m_addon.getRevision()); core::stringw revision = _("Version: %d", m_addon.getRevision());
getWidget<LabelWidget>("revision")->setText(revision, false); getWidget<LabelWidget>("revision")->setText(revision, false);
// Display flags for this addon
// ============================
std::vector<core::stringw> l;
if(UserConfigParams::m_artist_debug_mode)
{
if(m_addon.testStatus(Addon::AS_ALPHA))
l.push_back("alpha");
if(m_addon.testStatus(Addon::AS_BETA))
l.push_back("beta");
if(m_addon.testStatus(Addon::AS_RC))
l.push_back("RC");
if(m_addon.testStatus(Addon::AS_BAD_DIM))
l.push_back("bad-texture");
if(!m_addon.testStatus(Addon::AS_DFSG))
l.push_back("non-DFSG");
}
if(m_addon.testStatus(Addon::AS_FAN))
l.push_back("fan-made");
else
l.push_back("official");
if(m_addon.testStatus(Addon::AS_FEATURED))
l.push_back("featured");
GUIEngine::LabelWidget *flags1 = getWidget<LabelWidget>("flags1");
GUIEngine::LabelWidget *flags2 = getWidget<LabelWidget>("flags2");
core::stringw s1(""), s2("");
for(unsigned int i=0; i<l.size(); i++)
{
if(i%2==0)
{
s1+=l[i];
if(i+2<l.size())
s1+=",";
}
else
{
s2+=l[i];
if(i+2<l.size())
s2+=",";
}
}
if(flags1) flags1->setText(s1, false);
if(flags2) flags2->setText(s2, false);
// Display the size
// ================
int n = m_addon.getSize(); int n = m_addon.getSize();
core::stringw unit=""; core::stringw unit="";
if(n>1024*1024) if(n>1024*1024)
@ -157,10 +197,10 @@ void AddonsLoading::onUpdate(float delta)
m_progress->setValue((int)(progress*100.0f)); m_progress->setValue((int)(progress*100.0f));
if(progress<0) if(progress<0)
{ {
m_state->setText(_("Download failed.\n"), false); m_back_button->setText(_("Download failed.\n"));
// Avoid displaying '-100%' in case of an error. // Avoid displaying '-100%' in case of an error.
m_progress->setVisible(false); m_progress->setVisible(false);
m_back_button->setText(_("Back")); m_back_button->setVisible(false);
return; return;
} }
else if(progress>=1.0f) else if(progress>=1.0f)
@ -211,7 +251,7 @@ void AddonsLoading::doInstall()
core::stringw msg = StringUtils::insertValues( core::stringw msg = StringUtils::insertValues(
_("Problems installing the addon '%s'."), _("Problems installing the addon '%s'."),
core::stringw(m_addon.getName().c_str())); core::stringw(m_addon.getName().c_str()));
m_state->setText(msg.c_str(), false); m_back_button->setText(msg.c_str());
} }
} }
else else
@ -225,7 +265,7 @@ void AddonsLoading::doInstall()
core::stringw msg = StringUtils::insertValues( core::stringw msg = StringUtils::insertValues(
_("Problems removing the addon '%s'."), _("Problems removing the addon '%s'."),
core::stringw(m_addon.getName().c_str())); core::stringw(m_addon.getName().c_str()));
m_state->setText(msg.c_str(), false); m_back_button->setText(msg.c_str());
} }
} }