Working on the update screen: remove unneeded function and some code cleanup
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5604 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
5a2de08d45
commit
4669b7075b
@ -5,10 +5,10 @@
|
||||
<header text_align="center" width="100%" text="SuperTuxKart Options"/>
|
||||
<spacer height="15" width="10"/>
|
||||
|
||||
<tabs id="options_choice" height="10%" max_height="110" width="100%" align="center">
|
||||
<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_audio" width="128" height="128" icon="gui/no-package.png"
|
||||
<icon-button id="tab_update" width="128" height="128" icon="gui/no-package.png"
|
||||
I18N="Section in the addons menu" text="Update"/>
|
||||
</tabs>
|
||||
<box proportion="1" width="100%" layout="vertical-row">
|
||||
|
@ -5,34 +5,21 @@
|
||||
<header text_align="center" width="100%" text="SuperTuxKart Options"/>
|
||||
<spacer height="15" width="10"/>
|
||||
|
||||
<tabs id="options_choice" height="10%" max_height="110" width="100%" align="center">
|
||||
<icon-button id="tab_video" width="128" height="128" icon="gui/options_video.png"
|
||||
I18N="Section in the settings menu" text="Karts"/>
|
||||
<icon-button id="tab_audio" width="128" height="128" icon="gui/options_audio.png"
|
||||
I18N="Section in the settings menu" text="Tracks"/>
|
||||
<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"
|
||||
I18N="Section in the addons menu" text="Update"/>
|
||||
</tabs>
|
||||
<!--<label id="info_addons" width="10%" height="10%" text_align="left" text="[none]" />-->
|
||||
<box proportion="1" width="100%" layout="vertical-row">
|
||||
|
||||
<box proportion="1" width="100%" layout="horizontal-row">
|
||||
|
||||
<div height="75%" width="40%" layout="vertical-row">
|
||||
<spacer height="50" width="10"/>
|
||||
<list id="list_karts" proportion="5" width="100%" align="center"/>
|
||||
</div>
|
||||
<spacer height="40" width="10"/>
|
||||
<div height="40%" width="50%" layout="vertical-row">
|
||||
<spacer height="40" width="10"/>
|
||||
<icon id="logo" align="center" height="50%" width="100%" icon="gui/logo.png"/>
|
||||
<label align="center" height="15%" width="100%" id="name_addons" />
|
||||
<label align="center" height="15%" width="100%" id="version_addons" />
|
||||
<label align="center" height="15%" width="100%" id="description_addons" />
|
||||
<label align="center" height="15%" width="100%" id="install_addons" />
|
||||
<button id="install" x="20" y="-40" width="250" height="35" align="left"
|
||||
I18N="In the addons menu" text="Install"/>
|
||||
</div>
|
||||
|
||||
<spacer width="50" height="40" />
|
||||
<label id="update_status" width="100%" height="10%" text_align="left" text="Updating the list..." />
|
||||
<spacer height="5%" width="100%"/>
|
||||
<list id="list_addons" height="50%" proportion="5" width="100%" align="center"/>
|
||||
<spacer height="15%" width="100%"/>
|
||||
</box>
|
||||
|
||||
<spacer width="50" height="45" />
|
||||
</div>
|
||||
|
||||
<button id="back" x="20" y="-40" width="250" height="35" align="left"
|
||||
|
@ -310,6 +310,8 @@ supertuxkart_SOURCES = \
|
||||
states_screens/options_screen_video.hpp \
|
||||
states_screens/addons_screen.cpp \
|
||||
states_screens/addons_screen.hpp \
|
||||
states_screens/addons_update_screen.cpp \
|
||||
states_screens/addons_update_screen.hpp \
|
||||
states_screens/race_gui.cpp \
|
||||
states_screens/race_gui.hpp \
|
||||
states_screens/race_setup_screen.cpp \
|
||||
|
@ -18,6 +18,7 @@
|
||||
#ifdef ADDONS_MANAGER
|
||||
|
||||
#include "states_screens/addons_screen.hpp"
|
||||
#include "states_screens/addons_update_screen.hpp"
|
||||
#include "states_screens/dialogs/addons_loading.hpp"
|
||||
|
||||
#include "guiengine/widget.hpp"
|
||||
@ -115,6 +116,12 @@ void AddonsScreen::eventCallback(GUIEngine::Widget* widget, const std::string& n
|
||||
this->load = new AddonsLoading(this->addons, 0.8f, 0.8f);
|
||||
}
|
||||
}
|
||||
if (name == "category")
|
||||
{
|
||||
std::string selection = ((GUIEngine::RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();
|
||||
|
||||
if (selection == "tab_update") StateManager::get()->replaceTopMostScreen(AddonsUpdateScreen::getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
@ -18,6 +18,7 @@
|
||||
#ifdef ADDONS_MANAGER
|
||||
|
||||
#include "states_screens/addons_screen.hpp"
|
||||
#include "states_screens/addons_update_screen.hpp"
|
||||
|
||||
/*pthread aren't supported natively by windows. Here a port: http://sourceware.org/pthreads-win32/ */
|
||||
# include <pthread.h>
|
||||
@ -48,27 +49,6 @@ void AddonsUpdateScreen::loadedFromFile()
|
||||
{
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
void AddonsUpdateScreen::download_list()
|
||||
{
|
||||
#if 0
|
||||
GUIEngine::ListWidget* w_list = this->getWidget<GUIEngine::ListWidget>("list_karts");
|
||||
|
||||
this->addons = new Addons(std::string(file_manager->getConfigDir() + "/list_text"), std::string(file_manager->getConfigDir() + "/installed.xml"));
|
||||
//to have the name of the first karts and load it informatins later
|
||||
this->addons->Next();
|
||||
std::string first_kart = this->addons->GetName();
|
||||
std::cout << this->addons->GetName() << std::endl;
|
||||
w_list->addItem(std::string("list_karts" + this->addons->GetName()).c_str(), this->addons->GetName().c_str(), 0 /* icon */);
|
||||
while(this->addons->Next())
|
||||
{
|
||||
std::cout << this->addons->GetName() << std::endl;
|
||||
w_list->addItem(std::string("list_karts" + this->addons->GetName()).c_str(), this->addons->GetName().c_str(), 0 /* icon */);
|
||||
}
|
||||
this->addons->Select(first_kart);
|
||||
this->loadInformations();
|
||||
#endif
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
void AddonsUpdateScreen::eventCallback(GUIEngine::Widget* widget, const std::string& name, const int playerID)
|
||||
{
|
||||
@ -76,19 +56,11 @@ void AddonsUpdateScreen::eventCallback(GUIEngine::Widget* widget, const std::str
|
||||
{
|
||||
StateManager::get()->escapePressed();
|
||||
}
|
||||
else if (name == "install")
|
||||
else if (name == "category")
|
||||
{
|
||||
this->load = new AddonsLoading(0.4f, 0.4f);
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, *startInstall, this);
|
||||
//this->addons->Install();
|
||||
}
|
||||
else if (name.find("list_karts") == 0)
|
||||
{
|
||||
GUIEngine::ListWidget* list = this->getWidget<GUIEngine::ListWidget>("list_karts");
|
||||
std::string kart = list->getSelectionInternalName().replace(0, 10, "");
|
||||
this->addons->Select(kart);
|
||||
this->loadInformations();
|
||||
std::string selection = ((GUIEngine::RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str();
|
||||
|
||||
if (selection == "tab_addons") StateManager::get()->replaceTopMostScreen(AddonsScreen::getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,8 +68,6 @@ void AddonsUpdateScreen::eventCallback(GUIEngine::Widget* widget, const std::str
|
||||
|
||||
void AddonsUpdateScreen::init()
|
||||
{
|
||||
pthread_t nThreadID2;
|
||||
pthread_create(&nThreadID2, NULL, *download_l, this);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
@ -105,46 +75,4 @@ void AddonsUpdateScreen::init()
|
||||
void AddonsUpdateScreen::tearDown()
|
||||
{
|
||||
}
|
||||
void AddonsUpdateScreen::loadInformations()
|
||||
{
|
||||
std::cout << this->addons->GetName() << std::endl;
|
||||
GUIEngine::LabelWidget* w = this->getWidget<GUIEngine::LabelWidget>("name_addons");
|
||||
w->setText(std::string("Name: "+ this->addons->GetName()).c_str());
|
||||
w = this->getWidget<GUIEngine::LabelWidget>("description_addons");
|
||||
w->setText(std::string("Description: " + this->addons->GetDescription()).c_str());
|
||||
w = this->getWidget<GUIEngine::LabelWidget>("version_addons");
|
||||
std::ostringstream os;
|
||||
os << this->addons->GetVersion();
|
||||
w->setText(std::string("Version: " + os.str()).c_str());
|
||||
w = this->getWidget<GUIEngine::LabelWidget>("install_addons");
|
||||
w->setText(std::string("Installed: " + this->addons->IsInstalled()).c_str());
|
||||
|
||||
GUIEngine::ButtonWidget* button = this->getWidget<GUIEngine::ButtonWidget>("install");
|
||||
if(this->addons->IsInstalled() == "yes")
|
||||
{
|
||||
button->setLabel(std::string("Uninstall").c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
button->setLabel(std::string("Install").c_str());
|
||||
}
|
||||
}
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
//I dislike this way, it is too dirty but I didn't find another way
|
||||
void * startInstall(void* pthis)
|
||||
{
|
||||
AddonsUpdateScreen * obj = (AddonsUpdateScreen*)pthis;
|
||||
if(obj->addons->IsInstalled() == "yes")
|
||||
{
|
||||
std::cout << obj->addons->IsInstalled() << std::endl;
|
||||
obj->addons->UnInstall();
|
||||
}
|
||||
else
|
||||
{
|
||||
obj->addons->Install();
|
||||
}
|
||||
obj->load->close();
|
||||
obj->loadInformations();
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
@ -33,12 +33,12 @@ class AddonsUpdateScreen : public GUIEngine::Screen, public GUIEngine::ScreenSin
|
||||
friend class GUIEngine::ScreenSingleton<AddonsUpdateScreen>;
|
||||
AddonsUpdateScreen();
|
||||
Addons * addons;
|
||||
/*uneeded*/
|
||||
AddonsLoading * load;
|
||||
void loadInformations();
|
||||
|
||||
public:
|
||||
|
||||
void download_list();
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void loadedFromFile();
|
||||
|
||||
@ -50,9 +50,6 @@ public:
|
||||
|
||||
/** \brief implement callback from parent class GUIEngine::Screen */
|
||||
virtual void tearDown();
|
||||
friend void * startInstall(void *);
|
||||
};
|
||||
|
||||
void * startInstall(void *);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user