Some general dialog improvements

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13415 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
unitraxx 2013-08-04 13:33:14 +00:00
parent 63e927b277
commit 757d9e3683
11 changed files with 47 additions and 9 deletions

View File

@ -151,6 +151,9 @@ public:
/** Returns the rating of an addon. */
const float getRating() const {return m_rating; }
// ------------------------------------------------------------------------
/** Sets the rating of an addon. */
void setRating(const float rating) {m_rating = rating; }
// ------------------------------------------------------------------------
/** Returns the type of the addon. */
const std::string& getType() const { return m_type; }
// ------------------------------------------------------------------------

View File

@ -345,7 +345,7 @@ void AddonsManager::loadInstalledAddons()
* found!
* \param id The id to search for.
*/
const Addon* AddonsManager::getAddon(const std::string &id) const
Addon* AddonsManager::getAddon(const std::string &id)
{
int i = getAddonIndex(id);
return (i<0) ? NULL : &(m_addons_list.getData()[i]);

View File

@ -62,7 +62,7 @@ public:
~AddonsManager();
void initOnline(const XMLNode *xml);
void checkInstalledAddons();
const Addon* getAddon(const std::string &id) const;
Addon* getAddon(const std::string &id);
int getAddonIndex(const std::string &id) const;
bool install(const Addon &addon);
bool uninstall(const Addon &addon);

View File

@ -19,6 +19,7 @@
#include "online/current_user.hpp"
#include "addons/addons_manager.hpp"
#include "config/user_config.hpp"
#include "online/servers_manager.hpp"
#include "utils/log.hpp"
@ -261,10 +262,10 @@ namespace Online{
// ============================================================================
const XMLRequest * CurrentUser::requestSetAddonVote( const std::string & addon_id, float rating) const
const CurrentUser::setAddonVoteRequest * CurrentUser::requestSetAddonVote( const std::string & addon_id, float rating) const
{
assert(isRegisteredUser());
XMLRequest * request = new XMLRequest();
CurrentUser::setAddonVoteRequest * request = new CurrentUser::setAddonVoteRequest();
request->setURL((std::string)UserConfigParams::m_server_multiplayer + "client-user.php");
request->setParameter("action", std::string("set-addon-vote"));
request->setParameter("token", getToken());
@ -275,6 +276,18 @@ namespace Online{
return request;
}
void CurrentUser::setAddonVoteRequest::callback()
{
if(isSuccess())
{
std::string addon_id;
getResult()->get("addon-id", &addon_id);
float average;
getResult()->get("new-average", &average);
addons_manager->getAddon(addon_id)->setRating(average);
}
}
// ============================================================================
const irr::core::stringw CurrentUser::getUserName() const

View File

@ -86,6 +86,12 @@ namespace Online{
ServerJoinRequest() : XMLRequest(RT_SERVER_JOIN) {}
};
class setAddonVoteRequest : public XMLRequest {
virtual void callback ();
public:
setAddonVoteRequest() : XMLRequest() {}
};
private:
Synchronised<std::string> m_token;
@ -130,7 +136,7 @@ namespace Online{
const irr::core::stringw &email);
const XMLRequest * requestGetAddonVote(const std::string & addon_id) const;
const XMLRequest * requestSetAddonVote(const std::string & addon_id, float rating) const;
const setAddonVoteRequest * requestSetAddonVote(const std::string & addon_id, float rating) const;
/** Returns the username if signed in. */
const irr::core::stringw getUserName() const;

View File

@ -220,7 +220,7 @@ void AddonsScreen::loadList()
PtrVector<const Addon, REF> sorted_list;
for(unsigned int i=0; i<addons_manager->getNumAddons(); i++)
{
const Addon &addon = addons_manager->getAddon(i);
const Addon & addon = addons_manager->getAddon(i);
// Ignore addons of a different type
if(addon.getType()!=m_type) continue;
// Ignore invisible addons

View File

@ -171,9 +171,13 @@ void LoginDialog::onEnterPressedInternal()
bool LoginDialog::onEscapePressed()
{
return m_cancel_widget->isActivated();
if (m_cancel_widget->isActivated())
m_self_destroy = true;
return false;
}
// -----------------------------------------------------------------------------
void LoginDialog::onUpdate(float dt)
{
if(m_sign_in_request != NULL)

View File

@ -123,6 +123,15 @@ void ServerInfoDialog::onEnterPressedInternal()
// -----------------------------------------------------------------------------
bool ServerInfoDialog::onEscapePressed()
{
if (m_cancel_widget->isActivated())
m_self_destroy = true;
return false;
}
// -----------------------------------------------------------------------------
void ServerInfoDialog::onUpdate(float dt)
{
if(m_server_join_request != NULL)

View File

@ -63,6 +63,7 @@ public:
void onEnterPressedInternal();
GUIEngine::EventPropagation processEvent(const std::string& eventSource);
virtual bool onEscapePressed();
virtual void onUpdate(float dt);
};

View File

@ -77,7 +77,9 @@ VoteDialog::~VoteDialog()
bool VoteDialog::onEscapePressed()
{
return m_cancel_widget->isActivated();
if (m_cancel_widget->isActivated())
m_self_destroy = true;
return false;
}
// -----------------------------------------------------------------------------

View File

@ -46,7 +46,7 @@ private:
const std::string m_addon_id;
bool m_self_destroy;
const Online::XMLRequest * m_fetch_vote_request;
const Online::XMLRequest * m_perform_vote_request;
const Online::CurrentUser::setAddonVoteRequest * m_perform_vote_request;
GUIEngine::LabelWidget * m_info_widget;