summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-09 18:17:50 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-09 18:17:50 +0300
commit4aeceabb5d4f00e2555234951a2f5db24b008265 (patch)
tree16e970611e7cc05352f18a9385b9e26c72d498d8
parentdd4d44a07d3a63ced0eec51c30b75887792c4a36 (diff)
downloadManaVerse-4aeceabb5d4f00e2555234951a2f5db24b008265.tar.gz
ManaVerse-4aeceabb5d4f00e2555234951a2f5db24b008265.tar.bz2
ManaVerse-4aeceabb5d4f00e2555234951a2f5db24b008265.tar.xz
ManaVerse-4aeceabb5d4f00e2555234951a2f5db24b008265.zip
Improve perfomance in windows and popups visibility checks.
-rw-r--r--src/actionmanager.cpp16
-rw-r--r--src/client.cpp4
-rw-r--r--src/game.cpp2
-rw-r--r--src/gui/chatwindow.cpp4
-rw-r--r--src/gui/debugwindow.cpp2
-rw-r--r--src/gui/didyouknowwindow.cpp2
-rw-r--r--src/gui/helpwindow.cpp4
-rw-r--r--src/gui/inventorywindow.cpp18
-rw-r--r--src/gui/minimap.cpp4
-rw-r--r--src/gui/ministatuswindow.cpp2
-rw-r--r--src/gui/popupmenu.cpp4
-rw-r--r--src/gui/tradewindow.cpp2
-rw-r--r--src/gui/viewport.cpp8
-rw-r--r--src/gui/whoisonline.cpp2
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp3
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp2
-rw-r--r--src/gui/widgets/itemshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/popup.h3
-rw-r--r--src/gui/widgets/window.cpp4
-rw-r--r--src/gui/widgets/window.h3
-rw-r--r--src/inputmanager.cpp4
21 files changed, 52 insertions, 45 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index fbdca92b1..3516a1909 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -205,13 +205,13 @@ impHandler0(mouseClick)
impHandler0(ok)
{
// Close the Browser if opened
- if (helpWindow && helpWindow->isVisible())
+ if (helpWindow && helpWindow->isWindowVisible())
{
helpWindow->setVisible(false);
return true;
}
// Close the config window, cancelling changes if opened
- else if (setupWindow && setupWindow->isVisible())
+ else if (setupWindow && setupWindow->isWindowVisible())
{
setupWindow->action(gcn::ActionEvent(nullptr, "cancel"));
return true;
@@ -299,7 +299,7 @@ impHandler0(nextSocialTab)
impHandler0(scrollChatUp)
{
- if (chatWindow && chatWindow->isVisible())
+ if (chatWindow && chatWindow->isWindowVisible())
{
chatWindow->scroll(-DEFAULT_CHAT_WINDOW_SCROLL);
return true;
@@ -309,7 +309,7 @@ impHandler0(scrollChatUp)
impHandler0(scrollChatDown)
{
- if (chatWindow && chatWindow->isVisible())
+ if (chatWindow && chatWindow->isWindowVisible())
{
chatWindow->scroll(DEFAULT_CHAT_WINDOW_SCROLL);
return true;
@@ -598,7 +598,7 @@ impHandler0(setupWindowShow)
{
if (setupWindow)
{
- if (setupWindow->isVisible())
+ if (setupWindow->isWindowVisible())
{
setupWindow->doCancel();
}
@@ -672,7 +672,7 @@ impHandler0(helpWindowShow)
{
if (helpWindow)
{
- if (helpWindow->isVisible())
+ if (helpWindow->isWindowVisible())
{
helpWindow->setVisible(false);
}
@@ -690,8 +690,8 @@ static void showHideWindow(Window *const window)
{
if (window)
{
- window->setVisible(!window->isVisible());
- if (window->isVisible())
+ window->setVisible(!window->isWindowVisible());
+ if (window->isWindowVisible())
window->requestMoveToTop();
}
}
diff --git a/src/client.cpp b/src/client.cpp
index 4ba96ff22..9e6e3885b 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1754,8 +1754,8 @@ void Client::action(const gcn::ActionEvent &event)
if (setupWindow)
{
- setupWindow->setVisible(!setupWindow->isVisible());
- if (setupWindow->isVisible())
+ setupWindow->setVisible(!setupWindow->isWindowVisible());
+ if (setupWindow->isWindowVisible())
{
if (!tab.empty())
setupWindow->activateTab(tab);
diff --git a/src/game.cpp b/src/game.cpp
index 7effc2e53..0fc4c36b1 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -983,7 +983,7 @@ void Game::handleInput()
// If pressed outfits keys, stop processing keys.
if (inputManager.isActionActive(Input::KEY_WEAR_OUTFIT)
|| inputManager.isActionActive(Input::KEY_COPY_OUTFIT)
- || (setupWindow && setupWindow->isVisible()))
+ || (setupWindow && setupWindow->isWindowVisible()))
{
BLOCK_END("Game::handleInput 1")
return;
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp
index 88c9936fe..c375b6748 100644
--- a/src/gui/chatwindow.cpp
+++ b/src/gui/chatwindow.cpp
@@ -575,7 +575,7 @@ void ChatWindow::action(const gcn::ActionEvent &event)
bool ChatWindow::requestChatFocus()
{
// Make sure chatWindow is visible
- if (!isVisible())
+ if (!isWindowVisible())
{
setVisible(true);
@@ -721,7 +721,7 @@ void ChatWindow::doPresent() const
void ChatWindow::scroll(const int amount) const
{
- if (!isVisible())
+ if (!isWindowVisible())
return;
ChatTab *const tab = getFocused();
diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp
index 781068c6c..726167a49 100644
--- a/src/gui/debugwindow.cpp
+++ b/src/gui/debugwindow.cpp
@@ -91,7 +91,7 @@ DebugWindow::~DebugWindow()
void DebugWindow::slowLogic()
{
BLOCK_START("DebugWindow::slowLogic")
- if (!isVisible() || !mTabs)
+ if (!isWindowVisible() || !mTabs)
{
BLOCK_END("DebugWindow::slowLogic")
return;
diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp
index 9928cb8fb..58a07dff4 100644
--- a/src/gui/didyouknowwindow.cpp
+++ b/src/gui/didyouknowwindow.cpp
@@ -165,6 +165,6 @@ void DidYouKnowWindow::setVisible(bool visible)
{
Window::setVisible(visible);
- if (visible || isVisible())
+ if (visible || isWindowVisible())
loadData();
}
diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp
index eeda8c907..3c091ce65 100644
--- a/src/gui/helpwindow.cpp
+++ b/src/gui/helpwindow.cpp
@@ -88,8 +88,8 @@ void HelpWindow::action(const gcn::ActionEvent &event)
{
if (didYouKnowWindow)
{
- didYouKnowWindow->setVisible(!didYouKnowWindow->isVisible());
- if (didYouKnowWindow->isVisible())
+ didYouKnowWindow->setVisible(!didYouKnowWindow->isWindowVisible());
+ if (didYouKnowWindow->isWindowVisible())
didYouKnowWindow->requestMoveToTop();
}
}
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index 22fea71c7..dfbe8b8b8 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -262,8 +262,8 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
{
if (outfitWindow)
{
- outfitWindow->setVisible(!outfitWindow->isVisible());
- if (outfitWindow->isVisible())
+ outfitWindow->setVisible(!outfitWindow->isWindowVisible());
+ if (outfitWindow->isWindowVisible())
outfitWindow->requestMoveToTop();
}
}
@@ -271,8 +271,8 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
{
if (shopWindow)
{
- shopWindow->setVisible(!shopWindow->isVisible());
- if (shopWindow->isVisible())
+ shopWindow->setVisible(!shopWindow->isWindowVisible());
+ if (shopWindow->isWindowVisible())
shopWindow->requestMoveToTop();
}
}
@@ -280,8 +280,8 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
{
if (equipmentWindow)
{
- equipmentWindow->setVisible(!equipmentWindow->isVisible());
- if (equipmentWindow->isVisible())
+ equipmentWindow->setVisible(!equipmentWindow->isWindowVisible());
+ if (equipmentWindow->isWindowVisible())
equipmentWindow->requestMoveToTop();
}
}
@@ -291,7 +291,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event)
}
else if (eventId == "store")
{
- if (!inventoryWindow || !inventoryWindow->isVisible())
+ if (!inventoryWindow || !inventoryWindow->isWindowVisible())
return;
Item *const item = inventoryWindow->getSelectedItem();
@@ -413,7 +413,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
const bool mod = (isStorageActive() && inputManager.isActionActive(
static_cast<int>(Input::KEY_MOD)));
- const bool mod2 = (tradeWindow && tradeWindow->isVisible()
+ const bool mod2 = (tradeWindow && tradeWindow->isWindowVisible()
&& inputManager.isActionActive(static_cast<int>(Input::KEY_MOD)));
if (!mod && !mod2 && event.getButton() == gcn::MouseEvent::RIGHT)
@@ -497,7 +497,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event)
ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd,
inventoryWindow, item);
}
- else if (tradeWindow && tradeWindow->isVisible())
+ else if (tradeWindow && tradeWindow->isWindowVisible())
{
ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd,
tradeWindow, item);
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
index 8394af227..d9ec8c52b 100644
--- a/src/gui/minimap.cpp
+++ b/src/gui/minimap.cpp
@@ -223,8 +223,8 @@ void Minimap::setMap(const Map *const map)
void Minimap::toggle()
{
- setVisible(!isVisible(), isSticky());
- mShow = isVisible();
+ setVisible(!isWindowVisible(), isSticky());
+ mShow = isWindowVisible();
}
void Minimap::draw(gcn::Graphics *graphics)
diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp
index f1421af3e..f9c1a28ea 100644
--- a/src/gui/ministatuswindow.cpp
+++ b/src/gui/ministatuswindow.cpp
@@ -252,7 +252,7 @@ void MiniStatusWindow::processEvent(Channels channel A_UNUSED,
void MiniStatusWindow::updateStatus()
{
StatusWindow::updateStatusBar(mStatusBar);
- if (mStatusPopup && mStatusPopup->isVisible())
+ if (mStatusPopup && mStatusPopup->isPopupVisible())
mStatusPopup->update();
}
diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp
index 264cda9d5..b6e4598ac 100644
--- a/src/gui/popupmenu.cpp
+++ b/src/gui/popupmenu.cpp
@@ -1521,7 +1521,7 @@ void PopupMenu::handleLink(const std::string &link,
{
if (being == player_node)
{
- if (equipmentWindow && !equipmentWindow->isVisible())
+ if (equipmentWindow && !equipmentWindow->isWindowVisible())
equipmentWindow->setVisible(true);
}
else
@@ -1679,7 +1679,7 @@ void PopupMenu::showPopup(Window *const parent, const int x, const int y,
if (isInventory)
{
- if (tradeWindow && tradeWindow->isVisible())
+ if (tradeWindow && tradeWindow->isWindowVisible())
{
mBrowserBox->addRow("addtrade", _("Add to trade"));
if (cnt > 1)
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index c5dcfd21f..48dbf1d27 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -325,7 +325,7 @@ void TradeWindow::action(const gcn::ActionEvent &event)
if (mStatus != PREPARING)
return;
- if (!inventoryWindow->isVisible())
+ if (!inventoryWindow->isWindowVisible())
{
inventoryWindow->setVisible(true);
return;
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index e7e0a2766..c8b0a0c8b 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -468,7 +468,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
}
// If a popup is active, just remove it
- if (mPopupMenu->isVisible())
+ if (mPopupMenu->isPopupVisible())
{
mPlayerFollowMouse = false;
mPopupMenu->setVisible(false);
@@ -895,7 +895,7 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
}
else
{
- if (mTextPopup->isVisible())
+ if (mTextPopup->isPopupVisible())
mTextPopup->setVisible(false);
}
gui->setCursorType(Cursor::CURSOR_UP);
@@ -903,7 +903,7 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
}
}
}
- if (mTextPopup->isVisible())
+ if (mTextPopup->isPopupVisible())
mTextPopup->setVisible(false);
if (mHoverBeing)
@@ -998,7 +998,7 @@ void Viewport::moveCamera(const int dx, const int dy)
bool Viewport::isPopupMenuVisible() const
{
- return mPopupMenu ? mPopupMenu->isVisible() : false;
+ return mPopupMenu ? mPopupMenu->isPopupVisible() : false;
}
void Viewport::moveCameraToActor(const int actorId, const int x, const int y)
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index 6a5ae8f70..b280ae4f8 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -607,7 +607,7 @@ void WhoIsOnline::slowLogic()
mUpdateTimer = cur_time;
double timeDiff = difftime(cur_time, mUpdateTimer);
- int timeLimit = isVisible() ? 20 : 120;
+ int timeLimit = isWindowVisible() ? 20 : 120;
if (mUpdateOnlineList && timeDiff >= timeLimit
&& mDownloadStatus != UPDATE_LIST)
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index 9fb20b041..bc6b3d878 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -222,7 +222,8 @@ void DropShortcutContainer::mousePressed(gcn::MouseEvent &event)
if (event.getButton() == gcn::MouseEvent::LEFT)
{
// Stores the selected item if theirs one.
- if (dropShortcut->isItemSelected() && inventoryWindow->isVisible())
+ if (dropShortcut->isItemSelected()
+ && inventoryWindow->isWindowVisible())
{
dropShortcut->setItem(index);
dropShortcut->setItemSelected(-1);
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index e708eb507..e2999c8ad 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -117,7 +117,7 @@ void ItemLinkHandler::handleLink(const std::string &link,
//+++ need add color to links?
mItemPopup->setItem(itemInfo, 1, true);
- if (mItemPopup->isVisible())
+ if (mItemPopup->isPopupVisible())
{
mItemPopup->setVisible(false);
}
diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp
index 12bc52f74..560374271 100644
--- a/src/gui/widgets/itemshortcutcontainer.cpp
+++ b/src/gui/widgets/itemshortcutcontainer.cpp
@@ -306,8 +306,8 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event)
{
// Stores the selected item if theirs one.
if (selShortcut->isItemSelected() && inventoryWindow &&
- (inventoryWindow->isVisible() || selShortcut->getSelectedItem()
- >= SPELL_MIN_ID))
+ (inventoryWindow->isWindowVisible()
+ || selShortcut->getSelectedItem() >= SPELL_MIN_ID))
{
selShortcut->setItem(index);
selShortcut->setItemSelected(-1);
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 23bce3d5f..57772f642 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -168,6 +168,9 @@ class Popup : public Container, public gcn::MouseListener,
void widgetMoved(const gcn::Event &event) override;
+ bool isPopupVisible() const
+ { return mVisible; }
+
protected:
int mPadding; /**< Holds the padding of the popup. */
Skin *mSkin; /**< Skin in use by this popup */
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 63c5b6629..7d80464d9 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -558,7 +558,7 @@ void Window::setVisible(bool visible)
void Window::setVisible(bool visible, bool forceSticky)
{
- if (visible == isVisible())
+ if (visible == isWindowVisible())
return; // Nothing to do
// Check if the window is off screen...
@@ -886,7 +886,7 @@ void Window::saveWindowState()
config.setValue(mWindowName + "WinY", mDimension.y);
if (mSaveVisible)
- config.setValue(mWindowName + "Visible", isVisible());
+ config.setValue(mWindowName + "Visible", isWindowVisible());
if (mStickyButton)
config.setValue(mWindowName + "Sticky", isSticky());
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 02f58d2a8..bf9bd935f 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -414,6 +414,9 @@ class Window : public gcn::Window,
void enableVisibleSound(bool b)
{ mPlayVisibleSound = b; }
+ bool isWindowVisible() const A_WARN_UNUSED
+ { return mVisible; }
+
protected:
bool canMove() const A_WARN_UNUSED;
diff --git a/src/inputmanager.cpp b/src/inputmanager.cpp
index eb3613640..416e003eb 100644
--- a/src/inputmanager.cpp
+++ b/src/inputmanager.cpp
@@ -443,7 +443,7 @@ void InputManager::unassignKey()
bool InputManager::handleAssignKey(const SDL_Event &event, const int type)
{
- if (setupWindow && setupWindow->isVisible() &&
+ if (setupWindow && setupWindow->isWindowVisible() &&
getNewKeyIndex() > Input::KEY_NO_VALUE)
{
setNewKey(event, type);
@@ -583,7 +583,7 @@ void InputManager::updateConditionMask()
if (!player_node || !player_node->getAway())
mMask |= COND_NOAWAY;
- if (!setupWindow || !setupWindow->isVisible())
+ if (!setupWindow || !setupWindow->isWindowVisible())
mMask |= COND_NOSETUP;
if (Game::instance() && Game::instance()->getValidSpeed())