From 5e75167f64473d645e40d7f6eb58eb1ef8f6cdea Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Sun, 25 Apr 2010 20:06:53 -0600 Subject: Fix some button issues in SocialWindow The invite and leave buttons are now only enabled when there are tabs. Also, the code to handle them will do nothing if no tab is selected (backup logic). Reviewed-by: Chuck Miller --- src/gui/socialwindow.cpp | 21 +++++++++++++++++++-- src/gui/socialwindow.h | 2 ++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 10ed680e..468a94c4 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -328,6 +328,8 @@ SocialWindow::SocialWindow() : { addTab(player_node->getParty()); } + else + updateButtons(); } SocialWindow::~SocialWindow() @@ -362,6 +364,8 @@ bool SocialWindow::addTab(Guild *guild) mTabs->addTab(tab, tab->mScroll); + updateButtons(); + return true; } @@ -375,6 +379,8 @@ bool SocialWindow::removeTab(Guild *guild) delete it->second; mGuilds.erase(it); + updateButtons(); + return true; } @@ -388,6 +394,8 @@ bool SocialWindow::addTab(Party *party) mTabs->addTab(tab, tab->mScroll); + updateButtons(); + return true; } @@ -401,6 +409,8 @@ bool SocialWindow::removeTab(Party *party) delete it->second; mParties.erase(it); + updateButtons(); + return true; } @@ -453,11 +463,11 @@ void SocialWindow::action(const gcn::ActionEvent &event) else showPartyCreate(); } - else if (event.getId() == "invite") + else if (event.getId() == "invite" && mTabs->getSelectedTabIndex() > -1) { static_cast(mTabs->getSelectedTab())->invite(); } - else if (event.getId() == "leave") + else if (event.getId() == "leave" && mTabs->getSelectedTabIndex() > -1) { static_cast(mTabs->getSelectedTab())->leave(); } @@ -596,3 +606,10 @@ void SocialWindow::showPartyCreate() mPartyCreateDialog->setActionEventId("create party"); mPartyCreateDialog->addActionListener(this); } + +void SocialWindow::updateButtons() +{ + bool hasTabs = mTabs->getNumberOfTabs() > 0; + mInviteButton->setEnabled(hasTabs); + mLeaveButton->setEnabled(hasTabs); +} diff --git a/src/gui/socialwindow.h b/src/gui/socialwindow.h index d3e69cc5..885c0e54 100644 --- a/src/gui/socialwindow.h +++ b/src/gui/socialwindow.h @@ -77,6 +77,8 @@ public: protected: friend class SocialTab; + void updateButtons(); + int mGuildInvited; ConfirmDialog *mGuildAcceptDialog; TextDialog *mGuildCreateDialog; -- cgit v1.2.3-70-g09d2