From 366ae7009df863ccd9a50a52a9e396d9c804b042 Mon Sep 17 00:00:00 2001 From: unitraxx Date: Tue, 6 Aug 2013 22:45:33 +0000 Subject: [PATCH] Lots of stuff. Mutex optimization. Addon voting. Some profile stuff continued. Progress+++ git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13424 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/gui/online/vote_dialog.stkgui | 4 +- sources.cmake | 4 +- src/online/current_user.cpp | 46 +++++---- src/online/current_user.hpp | 10 +- src/online/http_manager.cpp | 1 + src/online/request.cpp | 72 ++++++-------- src/online/request.hpp | 61 +++++++----- src/states_screens/dialogs/vote_dialog.cpp | 34 ++++--- src/states_screens/dialogs/vote_dialog.hpp | 1 - src/states_screens/online_profile_friends.cpp | 96 +++++++++++++++++++ src/states_screens/online_profile_friends.hpp | 59 ++++++++++++ 11 files changed, 277 insertions(+), 111 deletions(-) create mode 100644 src/states_screens/online_profile_friends.cpp create mode 100644 src/states_screens/online_profile_friends.hpp diff --git a/data/gui/online/vote_dialog.stkgui b/data/gui/online/vote_dialog.stkgui index 9e0d509cd..d61c206d2 100644 --- a/data/gui/online/vote_dialog.stkgui +++ b/data/gui/online/vote_dialog.stkgui @@ -18,10 +18,8 @@ - + I18N="Vote dialog" text="Close" label_location="none"/> diff --git a/sources.cmake b/sources.cmake index 8cd86aa4a..fd079aae3 100644 --- a/sources.cmake +++ b/sources.cmake @@ -1,4 +1,4 @@ -# Generated by /home/gl3nn/repos/gsoc-stk-branch/update_file_list.sh. Do not edit this file manually. +# Generated by ./update_file_list.sh. Do not edit this file manually. set(STK_SOURCES src/addons/addon.cpp src/addons/addons_manager.cpp @@ -229,6 +229,7 @@ src/states_screens/main_menu_screen.cpp src/states_screens/networking_lobby.cpp src/states_screens/network_kart_selection.cpp src/states_screens/offline_kart_selection.cpp +src/states_screens/online_profile_friends.cpp src/states_screens/online_profile_overview.cpp src/states_screens/online_screen.cpp src/states_screens/options_screen_audio.cpp @@ -526,6 +527,7 @@ src/states_screens/main_menu_screen.hpp src/states_screens/networking_lobby.hpp src/states_screens/network_kart_selection.hpp src/states_screens/offline_kart_selection.hpp +src/states_screens/online_profile_friends.hpp src/states_screens/online_profile_overview.hpp src/states_screens/online_screen.hpp src/states_screens/options_screen_audio.hpp diff --git a/src/online/current_user.cpp b/src/online/current_user.cpp index f747f7e94..3d8f7b66b 100644 --- a/src/online/current_user.cpp +++ b/src/online/current_user.cpp @@ -126,18 +126,18 @@ namespace Online{ return request; } - void CurrentUser::signIn(const SignInRequest * input) + void CurrentUser::signIn(bool success, const XMLNode * input) { - if (input->isSuccess()) + if (success) { std::string token(""); - int token_fetched = input->getResult()->get("token", &token); + int token_fetched = input->get("token", &token); setToken(token); irr::core::stringw username(""); - int username_fetched = input->getResult()->get("username", &username); + int username_fetched = input->get("username", &username); setUserName(username); uint32_t userid(0); - int userid_fetched = input->getResult()->get("userid", &userid); + int userid_fetched = input->get("userid", &userid); setUserID(userid); assert(token_fetched && username_fetched && userid_fetched); setUserState (US_SIGNED_IN); @@ -147,6 +147,12 @@ namespace Online{ UserConfigParams::m_saved_token = getToken(); UserConfigParams::m_saved_session = true; } + else + { + UserConfigParams::m_saved_user = 0; + UserConfigParams::m_saved_token = ""; + UserConfigParams::m_saved_session = false; + } } else setUserState (US_SIGNED_OUT); @@ -154,7 +160,7 @@ namespace Online{ void CurrentUser::SignInRequest::callback() { - CurrentUser::get()->signIn(this); + CurrentUser::get()->signIn(m_success, m_result); } // ============================================================================ @@ -176,11 +182,11 @@ namespace Online{ void CurrentUser::ServerCreationRequest::callback() { - if(isSuccess()) + if(m_success) { - Server * server = new Server(*getResult()->getNode("server")); + Server * server = new Server(*m_result->getNode("server")); ServersManager::get()->addServer(server); - m_created_server_id.setAtomic(server->getServerId()); + m_created_server_id = server->getServerId(); } } @@ -197,9 +203,9 @@ namespace Online{ return request; } - void CurrentUser::signOut(const SignOutRequest * input) + void CurrentUser::signOut(bool success, const XMLNode * input) { - if(!input->isSuccess()) + if(!success) { Log::warn("CurrentUser::signOut", "%s", _("There were some connection issues while signing out. Report a bug if this caused issues.")); } @@ -214,7 +220,7 @@ namespace Online{ void CurrentUser::SignOutRequest::callback() { - CurrentUser::get()->signOut(this); + CurrentUser::get()->signOut(m_success, m_result); } // ============================================================================ @@ -239,7 +245,7 @@ namespace Online{ if(isSuccess()) { uint32_t server_id; - getResult()->get("serverid", &server_id); + m_result->get("serverid", &server_id); ServersManager::get()->setJoinedServer(server_id); } //FIXME needs changes for actual valid joining @@ -254,8 +260,8 @@ namespace Online{ request->setURL((std::string)UserConfigParams::m_server_multiplayer + "client-user.php"); request->setParameter("action", std::string("get-addon-vote")); request->setParameter("token", getToken()); - request->setParameter("id", getUserID()); - request->setParameter("addon-id", addon_id); + request->setParameter("userid", getUserID()); + request->setParameter("addonid", addon_id); HTTPManager::get()->addRequest(request); return request; } @@ -269,8 +275,8 @@ namespace Online{ request->setURL((std::string)UserConfigParams::m_server_multiplayer + "client-user.php"); request->setParameter("action", std::string("set-addon-vote")); request->setParameter("token", getToken()); - request->setParameter("id", getUserID()); - request->setParameter("addon-id", addon_id); + request->setParameter("userid", getUserID()); + request->setParameter("addonid", addon_id); request->setParameter("rating", rating); HTTPManager::get()->addRequest(request); return request; @@ -278,12 +284,12 @@ namespace Online{ void CurrentUser::setAddonVoteRequest::callback() { - if(isSuccess()) + if(m_success) { std::string addon_id; - getResult()->get("addon-id", &addon_id); + m_result->get("addon-id", &addon_id); float average; - getResult()->get("new-average", &average); + m_result->get("new-average", &average); addons_manager->getAddon(addon_id)->setRating(average); } } diff --git a/src/online/current_user.hpp b/src/online/current_user.hpp index 2c23f0cac..9a86f9d28 100644 --- a/src/online/current_user.hpp +++ b/src/online/current_user.hpp @@ -28,6 +28,7 @@ #include #include +#include namespace Online{ @@ -74,10 +75,10 @@ namespace Online{ class ServerCreationRequest : public XMLRequest { virtual void callback (); - Synchronised m_created_server_id; + uint32_t m_created_server_id; public: ServerCreationRequest() : XMLRequest(RT_SERVER_CREATION) {} - const uint32_t getCreatedServerID() const {return m_created_server_id.getAtomic();} + const uint32_t getCreatedServerID() const { assert(isDone()); return m_created_server_id;} }; class ServerJoinRequest : public XMLRequest { @@ -106,9 +107,8 @@ namespace Online{ CurrentUser(); - void signIn (const SignInRequest * input); - void signOut (const SignOutRequest * input); - void createServer (const ServerCreationRequest * input); + void signIn (bool success, const XMLNode * input); + void signOut (bool success, const XMLNode * input); public: /**Singleton */ diff --git a/src/online/http_manager.cpp b/src/online/http_manager.cpp index 4fb08a8d2..0ac6fcb15 100644 --- a/src/online/http_manager.cpp +++ b/src/online/http_manager.cpp @@ -149,6 +149,7 @@ namespace Online{ void HTTPManager::addRequest(Request *request) { assert(request->isAllowedToAdd()); + request->setBusy(); m_request_queue.lock(); m_request_queue.getData().push(request); // Wake up the network http thread diff --git a/src/online/request.cpp b/src/online/request.cpp index 41ded10c1..3a889c2bb 100644 --- a/src/online/request.cpp +++ b/src/online/request.cpp @@ -36,7 +36,7 @@ namespace Online{ : m_type(type), m_manage_memory(manage_memory), m_priority(priority) { m_cancel.setAtomic(false); - m_done.setAtomic(false); + m_state.setAtomic(S_PREPARING); } // Request Request::~Request() @@ -45,6 +45,7 @@ namespace Online{ void Request::execute() { + assert(isBusy()); prepareOperation(); operation(); afterOperation(); @@ -52,7 +53,7 @@ namespace Online{ void Request::afterOperation() { - m_done.setAtomic(true); + m_state.setAtomic(S_DONE); } // ========================================================================================= @@ -62,26 +63,21 @@ namespace Online{ { //Negative numbers are reserved for special requests ment for the HTTP Manager assert(type >= 0); - m_url.setAtomic(""); - MutexLocker(m_parameters); - m_parameters.getData() = new Parameters; + m_url = ""; + m_parameters = new Parameters(); m_progress.setAtomic(0); } HTTPRequest::~HTTPRequest() { - MutexLocker(m_parameters); - delete m_parameters.getData(); + delete m_parameters; } bool HTTPRequest::isAllowedToAdd() { - bool ok = true; - m_url.lock(); - if (m_url.getData().size() > 5 && ( m_url.getData().substr(0, 5) != "http:")) - ok = false; - m_url.unlock(); - return ok; + if (!Request::isAllowedToAdd() || m_url.size() < 5 || ( m_url.substr(0, 5) != "http:")) + return false; + return true; } void HTTPRequest::prepareOperation() @@ -92,7 +88,7 @@ namespace Online{ Log::error("HTTPRequest::prepareOperation", "LibCurl session not initialized."); return; } - curl_easy_setopt(m_curl_session, CURLOPT_URL, m_url.getAtomic().c_str()); + curl_easy_setopt(m_curl_session, CURLOPT_URL, m_url.c_str()); curl_easy_setopt(m_curl_session, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(m_curl_session, CURLOPT_WRITEFUNCTION, &HTTPRequest::WriteCallback); curl_easy_setopt(m_curl_session, CURLOPT_NOPROGRESS, 0); @@ -109,10 +105,9 @@ namespace Online{ return; Parameters::iterator iter; std::string postString(""); - m_parameters.lock(); - for (iter = m_parameters.getData()->begin(); iter != m_parameters.getData()->end(); ++iter) + for (iter = m_parameters->begin(); iter != m_parameters->end(); ++iter) { - if(iter != m_parameters.getData()->begin()) + if(iter != m_parameters->begin()) postString.append("&"); char * escaped = curl_easy_escape(m_curl_session , iter->first.c_str(), iter->first.size()); postString.append(escaped); @@ -122,7 +117,6 @@ namespace Online{ postString.append(escaped); curl_free(escaped); } - m_parameters.unlock(); curl_easy_setopt(m_curl_session, CURLOPT_POSTFIELDS, postString.c_str()); std::string uagent( std::string("SuperTuxKart/") + STK_VERSION ); #ifdef WIN32 @@ -209,16 +203,14 @@ namespace Online{ : HTTPRequest(priority, manage_memory, type) { m_string_buffer = ""; - m_info.setAtomic(""); - m_success.setAtomic(false); - MutexLocker(m_result); - m_result.getData() = NULL; + m_info = ""; + m_success = false; + m_result = NULL; } XMLRequest::~XMLRequest() { - MutexLocker(m_result); - delete m_result.getData(); + delete m_result; } void XMLRequest::prepareOperation() @@ -231,8 +223,7 @@ namespace Online{ void XMLRequest::operation() { HTTPRequest::operation(); - MutexLocker(m_result); - m_result.getData() = file_manager->createXMLTreeFromString(m_string_buffer); + m_result = file_manager->createXMLTreeFromString(m_string_buffer); } void XMLRequest::afterOperation() @@ -241,35 +232,34 @@ namespace Online{ Log::error( "XMLRequest::afterOperation", "curl_easy_perform() failed: %s", curl_easy_strerror(m_curl_code)); else Log::info( "XMLRequest::afterOperation", "Received : %s", m_string_buffer.c_str()); - m_result.lock();; bool success = false; - irr::core::stringw info; std::string rec_success; - if(m_result.getData()->get("success", &rec_success)) + if(m_result->get("success", &rec_success)) { if (rec_success =="yes") success = true; - m_result.getData()->get("info", &info); + m_result->get("info", &m_info); } else - info = _("Unable to connect to the server. Check your internet connection or try again later."); - m_result.unlock(); - m_info.lock(); - m_info.getData() = info; - m_info.unlock(); - m_success.setAtomic(success); + m_info = _("Unable to connect to the server. Check your internet connection or try again later."); + m_success = success; HTTPRequest::afterOperation(); } const XMLNode * XMLRequest::getResult() const { - MutexLocker(m_result); - return m_result.getData(); + assert(isDone()); + return m_result; } - const irr::core::stringw & XMLRequest::getInfo() const { - MutexLocker(m_info); - return m_info.getData(); + assert(isDone()); + return m_info; } + bool XMLRequest::isSuccess() const + { + assert(isDone()); + return m_success; + } + } // namespace Online diff --git a/src/online/request.hpp b/src/online/request.hpp index 8a00b9579..664e8dba3 100644 --- a/src/online/request.hpp +++ b/src/online/request.hpp @@ -28,7 +28,7 @@ # include #endif #include - +#include #include namespace Online{ @@ -54,12 +54,19 @@ namespace Online{ important this request is. */ const int m_priority; + enum State + { + S_PREPARING, + S_BUSY, + S_DONE + }; + protected: /** Cancel this request if it is active. */ Synchronised m_cancel; /** Set to though if the reply of the request is in and callbacks are executed */ - Synchronised m_done; + Synchronised m_state; virtual void prepareOperation() {} virtual void operation() {} @@ -92,10 +99,19 @@ namespace Online{ bool isCancelled() const { return m_cancel.getAtomic(); } // ------------------------------------------------------------------------ /** Returns if this request is done. */ - bool isDone() const { return m_done.getAtomic(); } + bool isDone() const { return m_state.getAtomic() == S_DONE; } + // ------------------------------------------------------------------------ + /** Returns if this request is being prepared. */ + bool isPreparing() const { return m_state.getAtomic() == S_PREPARING; } + // ------------------------------------------------------------------------ + /** Returns if this request is busy. */ + bool isBusy() const { return m_state.getAtomic() == S_BUSY; } + // ------------------------------------------------------------------------ + /** Sets the request stqte to busy. */ + void setBusy() { m_state.setAtomic(S_BUSY); } // ------------------------------------------------------------------------ /** Virtual method to check if a request has initialized all needed members to a valid value. */ - virtual bool isAllowedToAdd() const { return true; } + virtual bool isAllowedToAdd() const { return isPreparing(); } /** This class is used by the priority queue to sort requests by priority. */ @@ -126,8 +142,8 @@ namespace Online{ * packet is downloaded. At the end either -1 (error) or 1 * (everything ok) at the end. */ Synchronised m_progress; - Synchronised m_url; - Synchronised m_parameters; + std::string m_url; + Parameters * m_parameters; CURL * m_curl_session; CURLcode m_curl_code; @@ -154,32 +170,27 @@ namespace Online{ virtual ~HTTPRequest(); void setParameter(const std::string & name, const std::string &value){ - MutexLocker(m_parameters); - (*m_parameters.getData())[name] = value; + assert(isPreparing()); + (*m_parameters)[name] = value; }; void setParameter(const std::string & name, const irr::core::stringw &value){ - MutexLocker(m_parameters); - (*m_parameters.getData())[name] = irr::core::stringc(value.c_str()).c_str(); + assert(isPreparing()); + (*m_parameters)[name] = irr::core::stringc(value.c_str()).c_str(); } template void setParameter(const std::string & name, const T& value){ - MutexLocker(m_parameters); - (*m_parameters.getData())[name] = StringUtils::toString(value); + assert(isPreparing()); + (*m_parameters)[name] = StringUtils::toString(value); } /** Returns the current progress. */ - float getProgress() const { return m_progress.getAtomic(); } + float getProgress() const { return m_progress.getAtomic(); } /** Sets the current progress. */ - void setProgress(float f) { m_progress.setAtomic(f); } + void setProgress(float f) { m_progress.setAtomic(f); } - const std::string getURL() { - m_url.lock(); - const std::string url = m_url.getData(); - m_url.unlock(); - return url; - } + const std::string & getURL() { assert(isBusy()); return m_url;} - void setURL(const std::string & url) { m_url.setAtomic(url);} + void setURL(const std::string & url) { assert(isPreparing()); m_url = url;} virtual bool isAllowedToAdd() OVERRIDE; @@ -188,12 +199,12 @@ namespace Online{ class XMLRequest : public HTTPRequest { private: - Synchronised m_result; std::string m_string_buffer; protected : - Synchronised m_info; - Synchronised m_success; + XMLNode * m_result; + irr::core::stringw m_info; + bool m_success; virtual void prepareOperation() OVERRIDE; virtual void operation() OVERRIDE; @@ -205,7 +216,7 @@ namespace Online{ const XMLNode * getResult() const; const irr::core::stringw & getInfo() const; - bool isSuccess() const { return m_success.getAtomic(); } + bool isSuccess() const; }; } //namespace Online diff --git a/src/states_screens/dialogs/vote_dialog.cpp b/src/states_screens/dialogs/vote_dialog.cpp index 40f0bb1e5..8b55b6f21 100644 --- a/src/states_screens/dialogs/vote_dialog.cpp +++ b/src/states_screens/dialogs/vote_dialog.cpp @@ -53,8 +53,6 @@ VoteDialog::VoteDialog(const std::string & addon_id) m_rating_widget->allowVoting(); m_options_widget = getWidget("options"); assert(m_options_widget != NULL); - m_save_widget = getWidget("save"); - assert(m_save_widget != NULL); m_cancel_widget = getWidget("cancel"); assert(m_cancel_widget != NULL); m_options_widget->setFocusForPlayer(PLAYER_ID_GAME_MASTER); @@ -62,7 +60,6 @@ VoteDialog::VoteDialog(const std::string & addon_id) m_fetch_vote_request = CurrentUser::get()->requestGetAddonVote(m_addon_id); m_rating_widget->setDeactivated(); - m_save_widget->setDeactivated(); m_cancel_widget->setDeactivated(); } @@ -88,7 +85,9 @@ GUIEngine::EventPropagation VoteDialog::processEvent(const std::string& eventSou if (eventSource == m_rating_widget->m_properties[PROP_ID]) { - m_self_destroy = true; + m_perform_vote_request = CurrentUser::get()->requestSetAddonVote(m_addon_id, m_rating_widget->getRating()); + m_rating_widget->setDeactivated(); + m_cancel_widget->setDeactivated(); return GUIEngine::EVENT_BLOCK; } @@ -100,14 +99,6 @@ GUIEngine::EventPropagation VoteDialog::processEvent(const std::string& eventSou m_self_destroy = true; return GUIEngine::EVENT_BLOCK; } - else if (selection == m_save_widget->m_properties[PROP_ID]) - { - m_perform_vote_request = CurrentUser::get()->requestSetAddonVote(m_addon_id, m_rating_widget->getRating()); - m_rating_widget->setDeactivated(); - m_save_widget->setDeactivated(); - m_cancel_widget->setDeactivated(); - return GUIEngine::EVENT_BLOCK; - } } return GUIEngine::EVENT_LET; } @@ -124,7 +115,20 @@ void VoteDialog::onUpdate(float dt) { m_info_widget->setDefaultColor(); m_info_widget->setText(_("bla"), false); //FIXME - m_options_widget->setActivated(); + std::string voted; + m_fetch_vote_request->getResult()->get("voted", &voted); + if(voted == "yes") + { + float rating; + m_fetch_vote_request->getResult()->get("rating", &rating); + m_rating_widget->setRating(rating); + m_info_widget->setText(_("You can adapt your previous rating by clicking the stars beneath."), false); + } + else if(voted == "no") + { + m_info_widget->setText(_("You have not yet voted for this addon. Select your desired rating by clicking the stars beneath"), false); + } + m_cancel_widget->setActivated(); m_rating_widget->setActivated(); } else @@ -149,7 +153,7 @@ void VoteDialog::onUpdate(float dt) if(m_perform_vote_request->isSuccess()) { m_info_widget->setDefaultColor(); - m_info_widget->setText(_("Vote cast! You can now close the window."), false); + m_info_widget->setText(_("Vote successful! You can now close the window."), false); m_cancel_widget->setActivated(); } else @@ -157,7 +161,7 @@ void VoteDialog::onUpdate(float dt) sfx_manager->quickSound( "anvil" ); m_info_widget->setErrorColor(); m_info_widget->setText(m_perform_vote_request->getInfo(), false); - m_options_widget->setActivated(); + m_cancel_widget->setActivated(); m_rating_widget->setActivated(); } delete m_perform_vote_request; diff --git a/src/states_screens/dialogs/vote_dialog.hpp b/src/states_screens/dialogs/vote_dialog.hpp index d4c750e13..3d7c801a9 100644 --- a/src/states_screens/dialogs/vote_dialog.hpp +++ b/src/states_screens/dialogs/vote_dialog.hpp @@ -53,7 +53,6 @@ private: GUIEngine::RatingBarWidget * m_rating_widget; GUIEngine::RibbonWidget * m_options_widget; - GUIEngine::IconButtonWidget * m_save_widget; GUIEngine::IconButtonWidget * m_cancel_widget; public: diff --git a/src/states_screens/online_profile_friends.cpp b/src/states_screens/online_profile_friends.cpp new file mode 100644 index 000000000..975e183f9 --- /dev/null +++ b/src/states_screens/online_profile_friends.cpp @@ -0,0 +1,96 @@ +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2010 Glenn De Jonghe +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "states_screens/online_profile_friends.hpp" + +#include "guiengine/engine.hpp" +#include "guiengine/scalable_font.hpp" +#include "guiengine/screen.hpp" +#include "guiengine/widget.hpp" +#include "states_screens/state_manager.hpp" +#include "utils/translation.hpp" + +#include + +#include +#include + +using namespace GUIEngine; +using namespace irr::core; +using namespace irr::gui; +using namespace Online; + +DEFINE_SCREEN_SINGLETON( OnlineProfileFriends ); + +// ----------------------------------------------------------------------------- + +OnlineProfileFriends::OnlineProfileFriends() : Screen("online/profile_overview.stkgui") +{ +} // OnlineProfileFriends + + + + +// ----------------------------------------------------------------------------- + +void OnlineProfileFriends::loadedFromFile() +{ + m_profile_tabs = this->getWidget("profile_tabs"); + assert(m_profile_tabs != NULL); + LabelWidget * header = this->getWidget("title"); + assert(header != NULL); + header->setText(_("Your profile"), false); + +} // loadedFromFile + +// ----------------------------------------------------------------------------- + +void OnlineProfileFriends::init() +{ + Screen::init(); + m_profile_tabs->select( "tab_players", PLAYER_ID_GAME_MASTER ); + + /* + tabBar->getRibbonChildren()[0].setTooltip( _("Graphics") ); + tabBar->getRibbonChildren()[1].setTooltip( _("Audio") ); + tabBar->getRibbonChildren()[2].setTooltip( _("User Interface") ); + tabBar->getRibbonChildren()[4].setTooltip( _("Controls") );*/ +} // init + +// ----------------------------------------------------------------------------- + +void OnlineProfileFriends::tearDown() +{ + Screen::tearDown(); +} // tearDown + +// ----------------------------------------------------------------------------- + +void OnlineProfileFriends::eventCallback(Widget* widget, const std::string& name, const int playerID) +{ + if (name == m_profile_tabs->m_properties[PROP_ID]) + { + std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER).c_str(); + + //if (selection == "tab_audio") StateManager::get()->replaceTopMostScreen(OptionsScreenAudio::getInstance()); + } + else if (name == "back") + { + StateManager::get()->escapePressed(); + } +} // eventCallback + diff --git a/src/states_screens/online_profile_friends.hpp b/src/states_screens/online_profile_friends.hpp new file mode 100644 index 000000000..0a9c522b5 --- /dev/null +++ b/src/states_screens/online_profile_friends.hpp @@ -0,0 +1,59 @@ +// SuperTuxKart - a fun racing game with go-kart +// Copyright (C) 2013 Glenn De Jonghe +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 3 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +#ifndef __HEADER_ONLINE_PROFILE_FRIENDS_HPP__ +#define __HEADER_ONLINE_PROFILE_FRIENDS_HPP__ + +#include +#include + +#include "guiengine/screen.hpp" +#include "guiengine/widgets.hpp" + +namespace GUIEngine { class Widget; } + + +/** + * \brief Online profiel overview screen + * \ingroup states_screens + */ +class OnlineProfileFriends : public GUIEngine::Screen, public GUIEngine::ScreenSingleton +{ +private: + OnlineProfileFriends(); + + GUIEngine::RibbonWidget* m_profile_tabs; + +public: + friend class GUIEngine::ScreenSingleton; + + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void loadedFromFile() OVERRIDE; + + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name, + const int playerID) OVERRIDE; + + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void init() OVERRIDE; + + /** \brief implement callback from parent class GUIEngine::Screen */ + virtual void tearDown() OVERRIDE; +}; + +#endif