Adding chinese language in gen-mo (not added yet), tab system in the addons menu and some others very little things
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5709 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a68a70003c
commit
57b5c788ea
@ -6,14 +6,16 @@
|
||||
<spacer height="15" width="10"/>
|
||||
|
||||
<tabs id="category" height="10%" max_height="110" width="100%" align="center">
|
||||
<icon-button id="tab_addons" width="128" height="128" icon="gui/package.png"
|
||||
I18N="Section in the addons menu" text="Addons"/>
|
||||
<icon-button id="tab_update" width="128" height="128" icon="gui/no-package.png"
|
||||
<icon-button id="tab_kart" width="128" height="128" icon="gui/karts.png"
|
||||
I18N="Section in the addons menu" text="Karts"/>
|
||||
<icon-button id="tab_track" width="128" height="128" icon="gui/mode_normal.png"
|
||||
I18N="Section in the addons menu" text="Tracks"/>
|
||||
<icon-button id="tab_update" width="128" height="128" icon="gui/package.png"
|
||||
I18N="Section in the addons menu" text="Update"/>
|
||||
</tabs>
|
||||
<box proportion="1" width="100%" layout="vertical-row">
|
||||
|
||||
<label id="update_status" width="100%" height="10%" text_align="left" text="Updating the list..." />
|
||||
<label id="update_status" width="100%" height="10%" text_align="left" text="" />
|
||||
<spacer height="5%" width="100%"/>
|
||||
<list id="list_addons" height="50%" proportion="5" width="100%" align="center"/>
|
||||
<spacer height="15%" width="100%"/>
|
||||
|
@ -6,14 +6,16 @@
|
||||
<spacer height="15" width="10"/>
|
||||
|
||||
<tabs id="category" height="10%" max_height="110" width="100%" align="center">
|
||||
<icon-button id="tab_addons" width="128" height="128" icon="gui/package.png"
|
||||
I18N="Section in the addons menu" text="Addons"/>
|
||||
<icon-button id="tab_update" width="128" height="128" icon="gui/no-package.png"
|
||||
<icon-button id="tab_kart" width="128" height="128" icon="gui/karts.png"
|
||||
I18N="Section in the addons menu" text="Karts"/>
|
||||
<icon-button id="tab_track" width="128" height="128" icon="gui/mode_normal.png"
|
||||
I18N="Section in the addons menu" text="Tracks"/>
|
||||
<icon-button id="tab_update" width="128" height="128" icon="gui/package.png"
|
||||
I18N="Section in the addons menu" text="Update"/>
|
||||
</tabs>
|
||||
<box proportion="1" width="100%" layout="vertical-row">
|
||||
|
||||
<label id="update_status" width="100%" height="10%" text_align="left" text="Updating the list..." />
|
||||
<label id="update_status" width="100%" height="10%" text_align="left" text="" />
|
||||
<spacer height="5%" width="100%"/>
|
||||
<list id="list_addons" height="50%" proportion="5" width="100%" align="center"/>
|
||||
<spacer height="15%" width="100%"/>
|
||||
|
@ -22,4 +22,5 @@ msgfmt zh_CN.po -o zh_CN/LC_MESSAGES/supertuxkart.mo
|
||||
msgfmt he.po -o he/LC_MESSAGES/supertuxkart.mo
|
||||
msgfmt ko.po -o ko/LC_MESSAGES/supertuxkart.mo
|
||||
msgfmt sk.po -o sk/LC_MESSAGES/supertuxkart.mo
|
||||
msgfmt zh_TW.po -o zh_TW/LC_MESSAGES/supertuxkart.mo
|
||||
|
||||
|
@ -52,6 +52,8 @@ Addons::Addons()
|
||||
std::cout << "Loading an xml file for addons: ";
|
||||
int download_state = 0;
|
||||
m_download_state = download_state;
|
||||
pthread_mutex_init(&m_str_mutex, NULL);
|
||||
|
||||
download("list");
|
||||
std::string xml_file = file_manager->getConfigDir() + "/" + "list";
|
||||
std::cout << xml_file << std::endl;
|
||||
@ -316,10 +318,12 @@ std::string Addons::GetInstalledVersionAsStr()
|
||||
// ----------------------------------------------------------------------------
|
||||
void Addons::Install()
|
||||
{
|
||||
|
||||
|
||||
|
||||
//download of the addons file
|
||||
|
||||
pthread_mutex_lock(&m_str_mutex);
|
||||
m_str_state = "Downloading...";
|
||||
pthread_mutex_unlock(&m_str_mutex);
|
||||
|
||||
download(std::string("file/" + this->m_addons_list[this->index].file),
|
||||
this->m_addons_list[this->index].name, &m_download_state);
|
||||
file_manager->checkAndCreateDirForAddons(this->m_addons_list[this->index].name,
|
||||
@ -331,6 +335,11 @@ void Addons::Install()
|
||||
this->m_addons_list[this->index].name + "/" ;
|
||||
std::string from = file_manager->getConfigDir() + "/" + this->m_addons_list[this->index].name;
|
||||
std::string to = dest_file;
|
||||
|
||||
pthread_mutex_lock(&m_str_mutex);
|
||||
m_str_state = "Unzip the addons...";
|
||||
pthread_mutex_unlock(&m_str_mutex);
|
||||
|
||||
const bool success = extract_zip(from, to);
|
||||
if (!success)
|
||||
{
|
||||
@ -341,6 +350,10 @@ void Addons::Install()
|
||||
|
||||
this->m_addons_list[this->index].installed = true;
|
||||
this->m_addons_list[this->index].installed_version = this->m_addons_list[this->index].version;
|
||||
|
||||
pthread_mutex_lock(&m_str_mutex);
|
||||
m_str_state = "Writing XML...";
|
||||
pthread_mutex_unlock(&m_str_mutex);
|
||||
this->SaveInstalled();
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -355,7 +368,6 @@ void Addons::SaveInstalled()
|
||||
xml_installed << "<addons xmlns='http://stkaddons.tuxfamily.org/'>"
|
||||
<< std::endl;
|
||||
|
||||
//the unsigned is to remove the compiler warnings, maybe it is a bad idea ?
|
||||
for(unsigned int i = 0; i < this->m_addons_list.size(); i++)
|
||||
{
|
||||
if(this->m_addons_list[i].installed)
|
||||
@ -449,4 +461,11 @@ int Addons::getDownloadState()
|
||||
pthread_mutex_unlock(&download_mutex);
|
||||
return value;
|
||||
}
|
||||
std::string Addons::getDownloadStateAsStr()
|
||||
{
|
||||
pthread_mutex_lock(&m_str_mutex);
|
||||
std::string value = m_str_state;
|
||||
pthread_mutex_unlock(&m_str_mutex);
|
||||
return value;
|
||||
}
|
||||
#endif
|
||||
|
@ -47,6 +47,8 @@ class Addons
|
||||
void GetInstalledAddons();
|
||||
std::string type;
|
||||
int m_download_state;
|
||||
pthread_mutex_t m_str_mutex;
|
||||
std::string m_str_state;
|
||||
public:
|
||||
Addons();
|
||||
|
||||
@ -105,6 +107,8 @@ class Addons
|
||||
bool PreviousType(std::string type);
|
||||
int getDownloadState();
|
||||
|
||||
/** Get the install state (if it is the download, unzip...)*/
|
||||
std::string getDownloadStateAsStr();
|
||||
|
||||
};
|
||||
#endif
|
||||
|
@ -64,8 +64,8 @@ void AddonsScreen::loadList()
|
||||
GUIEngine::ListWidget* w_list = this->getWidget<GUIEngine::ListWidget>("list_addons");
|
||||
w_list->clear();
|
||||
this->addons->resetIndex();
|
||||
w_list->addItem("kart", _("Karts:"), -1 /* no icon */);
|
||||
while(this->addons->NextType("kart"))
|
||||
//w_list->addItem("kart", _("Karts:"), -1 /* no icon */);
|
||||
while(this->addons->NextType(this->type))
|
||||
{
|
||||
std::cout << this->addons->GetName() << std::endl;
|
||||
if(this->addons->IsInstalledAsBool())
|
||||
@ -77,24 +77,13 @@ void AddonsScreen::loadList()
|
||||
this->addons->GetName().c_str(), 1 /* icon unsinstalled*/);
|
||||
}
|
||||
|
||||
//load all tracks...
|
||||
w_list->addItem("track", _("Tracks:"), -1 /* no icon */);
|
||||
this->addons->resetIndex();
|
||||
while(this->addons->NextType("track"))
|
||||
{
|
||||
std::cout << this->addons->GetName() << std::endl;
|
||||
if(this->addons->IsInstalledAsBool())
|
||||
w_list->addItem(this->addons->GetIdAsStr().c_str(),
|
||||
this->addons->GetName().c_str(), 0 /* icon */);
|
||||
|
||||
else
|
||||
w_list->addItem(this->addons->GetIdAsStr().c_str(),
|
||||
this->addons->GetName().c_str(), 1 /* icon */);
|
||||
}
|
||||
|
||||
//remove the text from the widget : "Updating list..."
|
||||
m_update_status->setText("");
|
||||
this->can_load_list = false;
|
||||
this->getWidget<GUIEngine::RibbonWidget>("category")->setActivated();
|
||||
this->getWidget<GUIEngine::LabelWidget>("update_status")->setText("");
|
||||
if(type == "kart")
|
||||
this->getWidget<GUIEngine::RibbonWidget>("category")->select("tab_kart", PLAYER_ID_GAME_MASTER);
|
||||
else if(type == "track")
|
||||
this->getWidget<GUIEngine::RibbonWidget>("category")->select("tab_track", PLAYER_ID_GAME_MASTER);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -119,8 +108,18 @@ void AddonsScreen::eventCallback(GUIEngine::Widget* widget, const std::string& n
|
||||
if (name == "category")
|
||||
{
|
||||
std::string selection = ((GUIEngine::RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();
|
||||
|
||||
std::cout << selection << std::endl;
|
||||
if (selection == "tab_update") StateManager::get()->replaceTopMostScreen(AddonsUpdateScreen::getInstance());
|
||||
else if (selection == "tab_track")
|
||||
{
|
||||
this->type = "track";
|
||||
loadList();
|
||||
}
|
||||
else if (selection == "tab_kart")
|
||||
{
|
||||
this->type = "kart";
|
||||
loadList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,16 +135,18 @@ void AddonsScreen::onUpdate(float delta, irr::video::IVideoDriver* driver)
|
||||
}
|
||||
void AddonsScreen::init()
|
||||
{
|
||||
this->getWidget<GUIEngine::RibbonWidget>("category")->setDeactivated();
|
||||
this->type = "kart";
|
||||
|
||||
pthread_mutex_init(&(this->mutex), NULL);
|
||||
m_update_status = this->getWidget<GUIEngine::LabelWidget>("update_status");
|
||||
std::cout << "Addons dir:" + file_manager->getAddonsDir() << std::endl;
|
||||
this->type = "track";
|
||||
GUIEngine::ListWidget* w_list = this->getWidget<GUIEngine::ListWidget>("list_addons");
|
||||
w_list->setIcons(m_icon_bank);
|
||||
//w_list->clear();
|
||||
std::cout << "icon bank" << std::endl;
|
||||
this->can_load_list = false;
|
||||
m_update_status->setText(_("Updating the list..."));
|
||||
|
||||
this->getWidget<GUIEngine::LabelWidget>("update_status")->setText(_("Updating the list..."));
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, &AddonsScreen::downloadList, this);
|
||||
}
|
||||
@ -161,10 +162,11 @@ void * AddonsScreen::downloadList( void * pthis)
|
||||
AddonsScreen * pt = (AddonsScreen*)pthis;
|
||||
//load all karts...
|
||||
pt->addons = new Addons();
|
||||
|
||||
pthread_mutex_lock(&(pt->mutex));
|
||||
pt->can_load_list = true;
|
||||
pthread_mutex_unlock(&(pt->mutex));
|
||||
//pt->loadList();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -52,7 +52,10 @@ public:
|
||||
bool can_load_list;
|
||||
pthread_mutex_t mutex;
|
||||
std::string type;
|
||||
|
||||
/** Load the addons into the main list.*/
|
||||
void loadList();
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void loadedFromFile();
|
||||
|
||||
@ -65,8 +68,11 @@ public:
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void tearDown();
|
||||
friend void * startInstall(void *);
|
||||
|
||||
/** This function is used to download a text from the server to show the news. */
|
||||
static void * downloadList(void *);
|
||||
|
||||
/** This function is used to handle the thread (load the new list, etc...). */
|
||||
virtual void onUpdate(float delta, irr::video::IVideoDriver*);
|
||||
};
|
||||
|
||||
|
@ -60,7 +60,18 @@ void AddonsUpdateScreen::eventCallback(GUIEngine::Widget* widget, const std::str
|
||||
{
|
||||
std::string selection = ((GUIEngine::RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();
|
||||
|
||||
if (selection == "tab_addons") StateManager::get()->replaceTopMostScreen(AddonsScreen::getInstance());
|
||||
if (selection == "tab_track")
|
||||
{
|
||||
StateManager::get()->replaceTopMostScreen(AddonsScreen::getInstance());
|
||||
AddonsScreen::getInstance()->type = "track";
|
||||
AddonsScreen::getInstance()->loadList();
|
||||
}
|
||||
else if (selection == "tab_kart")
|
||||
{
|
||||
StateManager::get()->replaceTopMostScreen(AddonsScreen::getInstance());
|
||||
AddonsScreen::getInstance()->type = "kart";
|
||||
AddonsScreen::getInstance()->loadList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,6 +79,7 @@ void AddonsUpdateScreen::eventCallback(GUIEngine::Widget* widget, const std::str
|
||||
|
||||
void AddonsUpdateScreen::init()
|
||||
{
|
||||
this->getWidget<GUIEngine::RibbonWidget>("category")->select("tab_update", PLAYER_ID_GAME_MASTER);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
@ -43,7 +43,7 @@ AddonsLoading::AddonsLoading(Addons * id, const float w, const float h) :
|
||||
this->addons = id;
|
||||
m_can_install = false;
|
||||
m_percent_update = false;
|
||||
pthread_mutex_init(&mutex_can_install, NULL);
|
||||
pthread_mutex_init(&m_mutex_can_install, NULL);
|
||||
core::rect< s32 > area_right(10, 0, m_area.getWidth()/2, m_area.getHeight());
|
||||
|
||||
core::rect< s32 > area_left(m_area.getWidth()/2 + 20, 0, m_area.getWidth(), m_area.getHeight());
|
||||
@ -193,6 +193,17 @@ GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event
|
||||
|
||||
m_children.push_back(m_progress);
|
||||
m_progress->add();
|
||||
|
||||
m_state = new LabelWidget();
|
||||
m_state->m_x = 180;
|
||||
m_state->m_y = m_area.getHeight()-95;
|
||||
m_state->m_w = 250;
|
||||
m_state->m_h = 35;
|
||||
m_state->setParent(m_irrlicht_window);
|
||||
|
||||
m_children.push_back(m_state);
|
||||
m_state->add();
|
||||
|
||||
m_back_button->setDeactivated();
|
||||
m_next->setDeactivated();
|
||||
m_previous->setDeactivated();
|
||||
@ -207,7 +218,7 @@ GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event
|
||||
void AddonsLoading::onUpdate(float delta)
|
||||
{
|
||||
|
||||
pthread_mutex_lock(&(this->mutex_can_install));
|
||||
pthread_mutex_lock(&(m_mutex_can_install));
|
||||
if(m_can_install)
|
||||
{
|
||||
this->close();
|
||||
@ -215,8 +226,9 @@ void AddonsLoading::onUpdate(float delta)
|
||||
if(m_percent_update)
|
||||
{
|
||||
m_progress->setValue(addons->getDownloadState());
|
||||
m_state->setText(addons->getDownloadStateAsStr().c_str());
|
||||
}
|
||||
pthread_mutex_unlock(&(mutex_can_install));
|
||||
pthread_mutex_unlock(&(m_mutex_can_install));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
@ -236,17 +248,16 @@ void * AddonsLoading::startInstall(void* pthis)
|
||||
AddonsLoading * obj = (AddonsLoading*)pthis;
|
||||
if(obj->addons->IsInstalled() == "yes")
|
||||
{
|
||||
std::cout << obj->addons->IsInstalled() << std::endl;
|
||||
obj->addons->UnInstall();
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->addons->Install();
|
||||
}
|
||||
pthread_mutex_lock(&(obj->mutex_can_install));
|
||||
pthread_mutex_lock(&(obj->m_mutex_can_install));
|
||||
obj->m_can_install = true;
|
||||
obj->m_percent_update = false;
|
||||
pthread_mutex_unlock(&(obj->mutex_can_install));
|
||||
pthread_mutex_unlock(&(obj->m_mutex_can_install));
|
||||
return NULL;
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
@ -30,16 +30,17 @@ class AddonsLoading : public GUIEngine::ModalDialog
|
||||
{
|
||||
//virtual void escapePressed() {};
|
||||
private:
|
||||
GUIEngine::LabelWidget * name;
|
||||
GUIEngine::LabelWidget * description;
|
||||
GUIEngine::LabelWidget * version;
|
||||
GUIEngine::LabelWidget * author;
|
||||
GUIEngine::ProgressBarWidget * m_progress;
|
||||
GUIEngine::ButtonWidget * m_back_button;
|
||||
GUIEngine::ButtonWidget * install_button;
|
||||
GUIEngine::IconButtonWidget * icon;
|
||||
GUIEngine::IconButtonWidget * m_next;
|
||||
GUIEngine::IconButtonWidget * m_previous;
|
||||
GUIEngine::LabelWidget * name;
|
||||
GUIEngine::LabelWidget * description;
|
||||
GUIEngine::LabelWidget * version;
|
||||
GUIEngine::LabelWidget * author;
|
||||
GUIEngine::LabelWidget * m_state;
|
||||
GUIEngine::ProgressBarWidget * m_progress;
|
||||
GUIEngine::ButtonWidget * m_back_button;
|
||||
GUIEngine::ButtonWidget * install_button;
|
||||
GUIEngine::IconButtonWidget * icon;
|
||||
GUIEngine::IconButtonWidget * m_next;
|
||||
GUIEngine::IconButtonWidget * m_previous;
|
||||
static void * startInstall(void*);
|
||||
static void * downloadIcon(void*);
|
||||
void loadInfo();
|
||||
@ -49,7 +50,7 @@ public:
|
||||
/**
|
||||
* Creates a modal dialog with given percentage of screen width and height
|
||||
*/
|
||||
pthread_mutex_t mutex_can_install;
|
||||
pthread_mutex_t m_mutex_can_install;
|
||||
Addons * addons;
|
||||
AddonsLoading(Addons * id, const float percentWidth, const float percentHeight);
|
||||
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
|
||||
|
Loading…
Reference in New Issue
Block a user