The addons icons are now downloaded in a thread, we don't wait anymore that this download end
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6292 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
e06e190862
commit
2fa3c6bf43
@ -3,7 +3,7 @@
|
|||||||
<div x="5%" y="0%" width="90%" height="80%" layout="horizontal-row" >
|
<div x="5%" y="0%" width="90%" height="80%" layout="horizontal-row" >
|
||||||
<div width="50%" height="90%" layout="vertical-row" >
|
<div width="50%" height="90%" layout="vertical-row" >
|
||||||
<spacer height="22%" />
|
<spacer height="22%" />
|
||||||
<icon id="icon" align="center" proportion="8" width="100%" icon="gui/logo.png"/>
|
<icon id="icon" align="center" proportion="8" width="100%" icon="gui/loading.png"/>
|
||||||
</div>
|
</div>
|
||||||
<div width="50%" height="90%" layout="vertical-row" >
|
<div width="50%" height="90%" layout="vertical-row" >
|
||||||
<label id="name" width="100%" text="Name:" proportion="1" />
|
<label id="name" width="100%" text="Name:" proportion="1" />
|
||||||
|
@ -43,6 +43,7 @@ AddonsLoading::AddonsLoading(Addons * id, const float w, const float h) :
|
|||||||
loadFromFile("addons_view_dialog.stkgui");
|
loadFromFile("addons_view_dialog.stkgui");
|
||||||
this->addons = id;
|
this->addons = id;
|
||||||
m_can_install = false;
|
m_can_install = false;
|
||||||
|
m_can_load_icon = false;
|
||||||
m_percent_update = false;
|
m_percent_update = false;
|
||||||
pthread_mutex_init(&m_mutex_can_install, NULL);
|
pthread_mutex_init(&m_mutex_can_install, NULL);
|
||||||
|
|
||||||
@ -70,18 +71,31 @@ void AddonsLoading::loadInfo()
|
|||||||
|
|
||||||
|
|
||||||
/*I think we can wait a little to have the icon ?*/
|
/*I think we can wait a little to have the icon ?*/
|
||||||
download("icon/" + this->addons->GetIcon(), this->addons->GetName() + ".png");
|
|
||||||
icon->setImage(std::string(file_manager->getConfigDir() + "/" + this->addons->GetName() + ".png").c_str(), IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
name->setText(StringUtils::insertValues(_("Name: %i"), this->addons->GetName().c_str()));
|
name->setText(StringUtils::insertValues(_("Name: %i"), this->addons->GetName().c_str()));
|
||||||
description->setText(StringUtils::insertValues(_("Description: %i"), this->addons->GetDescription().c_str()));
|
description->setText(StringUtils::insertValues(_("Description: %i"), this->addons->GetDescription().c_str()));
|
||||||
version->setText(StringUtils::insertValues(_("Version: %i"), this->addons->GetVersionAsStr().c_str()));
|
version->setText(StringUtils::insertValues(_("Version: %i"), this->addons->GetVersionAsStr().c_str()));
|
||||||
|
pthread_t thread;
|
||||||
|
pthread_create(&thread, NULL, &AddonsLoading::downloadIcon, this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
void * AddonsLoading::downloadIcon( void * pthis)
|
||||||
|
{
|
||||||
|
AddonsLoading * pt = (AddonsLoading*)pthis;
|
||||||
|
download("icon/" + pt->addons->GetIcon(), pt->addons->GetName() + ".png");
|
||||||
|
pthread_mutex_lock(&(pt->m_mutex_can_install));
|
||||||
|
pt->m_can_load_icon = true;
|
||||||
|
pthread_mutex_unlock(&(pt->m_mutex_can_install));
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& eventSource)
|
GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& eventSource)
|
||||||
@ -154,6 +168,10 @@ void AddonsLoading::onUpdate(float delta)
|
|||||||
m_progress->setValue(addons->getDownloadState());
|
m_progress->setValue(addons->getDownloadState());
|
||||||
m_state->setText(addons->getDownloadStateAsStr().c_str());
|
m_state->setText(addons->getDownloadStateAsStr().c_str());
|
||||||
}
|
}
|
||||||
|
if(m_can_load_icon)
|
||||||
|
{
|
||||||
|
icon->setImage(std::string(file_manager->getConfigDir() + "/" + this->addons->GetName() + ".png").c_str(), IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
||||||
|
}
|
||||||
pthread_mutex_unlock(&(m_mutex_can_install));
|
pthread_mutex_unlock(&(m_mutex_can_install));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,22 +204,4 @@ void * AddonsLoading::startInstall(void* pthis)
|
|||||||
pthread_mutex_unlock(&(obj->m_mutex_can_install));
|
pthread_mutex_unlock(&(obj->m_mutex_can_install));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void * AddonsLoading::downloadIcon(void* pthis)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
AddonsLoading * obj = (AddonsLoading*)pthis;
|
|
||||||
download("icon/" + obj->addons->GetIcon(), obj->addons->GetName() + ".png");
|
|
||||||
obj->icon->setImage(std::string(file_manager->getConfigDir() + "/" + obj->addons->GetName() + ".png").c_str(), IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
|
||||||
obj->icon->setImage(std::string(file_manager->getConfigDir() + "/" + obj->addons->GetName() + ".png").c_str(), IconButtonWidget::ICON_PATH_TYPE_ABSOLUTE);
|
|
||||||
obj->icon->x = 0;
|
|
||||||
obj->icon->y = 0;
|
|
||||||
obj->icon->w = obj->m_area.getWidth()/2;
|
|
||||||
obj->icon->h = obj->m_area.getHeight();
|
|
||||||
obj->icon->setParent(obj->m_irrlicht_window);
|
|
||||||
obj->m_children.push_back(obj->icon);
|
|
||||||
obj->icon->add();*/
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,6 +46,7 @@ private:
|
|||||||
void loadInfo();
|
void loadInfo();
|
||||||
bool m_can_install;
|
bool m_can_install;
|
||||||
bool m_percent_update;
|
bool m_percent_update;
|
||||||
|
bool m_can_load_icon;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Creates a modal dialog with given percentage of screen width and height
|
* Creates a modal dialog with given percentage of screen width and height
|
||||||
|
Loading…
x
Reference in New Issue
Block a user