From 96abb55c7da6b67144e709cf054fa7dccd2a5102 Mon Sep 17 00:00:00 2001 From: xapantu Date: Wed, 8 Sep 2010 18:02:48 +0000 Subject: [PATCH] Change the name of the addons screen (from options to addons) Use a single pointer for addons, it is now initialized in main() Working on the update screen, we can now see which addons can be updated git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5925 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/gui/addons.stkgui | 2 +- data/gui/addons_update.stkgui | 2 +- src/addons/addons.cpp | 2 +- src/addons/addons.hpp | 1 + src/main.cpp | 2 ++ src/states_screens/addons_screen.cpp | 25 +++++++++------------ src/states_screens/addons_update_screen.cpp | 14 ++++++++++++ 7 files changed, 31 insertions(+), 17 deletions(-) diff --git a/data/gui/addons.stkgui b/data/gui/addons.stkgui index 99f3286e6..07691ee18 100644 --- a/data/gui/addons.stkgui +++ b/data/gui/addons.stkgui @@ -2,7 +2,7 @@
-
+
diff --git a/data/gui/addons_update.stkgui b/data/gui/addons_update.stkgui index 99f3286e6..07691ee18 100644 --- a/data/gui/addons_update.stkgui +++ b/data/gui/addons_update.stkgui @@ -2,7 +2,7 @@
-
+
diff --git a/src/addons/addons.cpp b/src/addons/addons.cpp index aef107f3c..7ceaa3901 100644 --- a/src/addons/addons.cpp +++ b/src/addons/addons.cpp @@ -38,7 +38,7 @@ using namespace irr; /* irrXML which is used to read (not write) xml file, is located in the namespace irr::io.*/ using namespace io; - +Addons* addons_manager = 0; // ---------------------------------------------------------------------------- Addons::Addons() diff --git a/src/addons/addons.hpp b/src/addons/addons.hpp index 7ba2344d8..b6cdb5e5f 100644 --- a/src/addons/addons.hpp +++ b/src/addons/addons.hpp @@ -110,5 +110,6 @@ class Addons std::string getDownloadStateAsStr(); }; +extern Addons * addons_manager; #endif #endif diff --git a/src/main.cpp b/src/main.cpp index 8b5bc7a57..31c80a0ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -71,6 +71,7 @@ #ifdef ADDONS_MANAGER #include "addons/network.hpp" +#include "addons/addons.hpp" #endif void cmdLineHelp (char* invocation) @@ -543,6 +544,7 @@ void initRest() network_manager = new NetworkManager (); #ifdef ADDONS_MANAGER network_http = new NetworkHttp (); + addons_manager = new Addons (); #endif stk_config->load(file_manager->getConfigFile("stk_config.xml")); diff --git a/src/states_screens/addons_screen.cpp b/src/states_screens/addons_screen.cpp index c352978f8..4af906356 100644 --- a/src/states_screens/addons_screen.cpp +++ b/src/states_screens/addons_screen.cpp @@ -63,18 +63,18 @@ void AddonsScreen::loadList() std::cout << "load list" << std::endl; GUIEngine::ListWidget* w_list = this->getWidget("list_addons"); w_list->clear(); - this->addons->resetIndex(); + addons_manager->resetIndex(); //w_list->addItem("kart", _("Karts:"), -1 /* no icon */); - while(this->addons->NextType(this->type)) + while(addons_manager->NextType(this->type)) { - 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 installed */); + std::cout << addons_manager->GetName() << std::endl; + if(addons_manager->IsInstalledAsBool()) + w_list->addItem(addons_manager->GetIdAsStr().c_str(), + addons_manager->GetName().c_str(), 0 /* icon installed */); else - w_list->addItem(this->addons->GetIdAsStr().c_str(), - this->addons->GetName().c_str(), 1 /* icon unsinstalled*/); + w_list->addItem(addons_manager->GetIdAsStr().c_str(), + addons_manager->GetName().c_str(), 1 /* icon unsinstalled*/); } this->can_load_list = false; @@ -101,8 +101,8 @@ void AddonsScreen::eventCallback(GUIEngine::Widget* widget, const std::string& n if(addons != "track" && addons != "kart") { - this->addons->SelectId(addons); - this->load = new AddonsLoading(this->addons, 0.8f, 0.8f); + addons_manager->SelectId(addons); + this->load = new AddonsLoading(addons_manager, 0.8f, 0.8f); } } if (name == "category") @@ -155,10 +155,7 @@ void AddonsScreen::init() // ------------------------------------------------------------------------------------------------------ void * AddonsScreen::downloadList( void * pthis) { - AddonsScreen * pt = (AddonsScreen*)pthis; - //load all karts... - pt->addons = new Addons(); - + AddonsScreen * pt = (AddonsScreen*)pthis; pthread_mutex_lock(&(pt->mutex)); pt->can_load_list = true; pthread_mutex_unlock(&(pt->mutex)); diff --git a/src/states_screens/addons_update_screen.cpp b/src/states_screens/addons_update_screen.cpp index 0e0a480ca..878e78835 100644 --- a/src/states_screens/addons_update_screen.cpp +++ b/src/states_screens/addons_update_screen.cpp @@ -81,6 +81,20 @@ void AddonsUpdateScreen::init() { Screen::init(); getWidget("category")->select("tab_update", PLAYER_ID_GAME_MASTER); + + GUIEngine::ListWidget* w_list = this->getWidget("list_addons"); + w_list->clear(); + addons_manager->resetIndex(); + //w_list->addItem("kart", _("Karts:"), -1 /* no icon */); + while(addons_manager->Next()) + { + if(addons_manager->IsInstalledAsBool() && addons_manager->GetInstalledVersion() < addons_manager->GetVersion() ) + { + std::cout << addons_manager->GetName() << std::endl; + w_list->addItem(addons_manager->GetIdAsStr().c_str(), + addons_manager->GetName().c_str(), 0); + } + } } #endif