diff options
author | Andrei Karas <akaras@inbox.ru> | 2010-01-10 17:19:24 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-01-10 17:20:33 +0100 |
commit | f5a394a5051384a930d635da22ccafc6beb1cb84 (patch) | |
tree | d28fc14408a6bb91170e05880b4d2af6a17fcc14 /src/gui/outfitwindow.cpp | |
parent | 5757066312cab082378dbc5d8df97dea3fe40af0 (diff) | |
download | mana-f5a394a5051384a930d635da22ccafc6beb1cb84.tar.gz mana-f5a394a5051384a930d635da22ccafc6beb1cb84.tar.bz2 mana-f5a394a5051384a930d635da22ccafc6beb1cb84.tar.xz mana-f5a394a5051384a930d635da22ccafc6beb1cb84.zip |
Change code style
Diffstat (limited to 'src/gui/outfitwindow.cpp')
-rw-r--r-- | src/gui/outfitwindow.cpp | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 6cb23286..ba060504 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -102,9 +102,8 @@ void OutfitWindow::load() std::vector<int> tokens; - while (ss >> buf) { + while (ss >> buf) tokens.push_back(atoi(buf.c_str())); - } for (int i = 0; i < (int)tokens.size(); i++) { @@ -134,19 +133,21 @@ void OutfitWindow::action(const gcn::ActionEvent &event) { if (event.getId() == "next") { - if (mCurrentOutfit < (OUTFITS_COUNT - 1)) { + if (mCurrentOutfit < (OUTFITS_COUNT - 1)) mCurrentOutfit++; - } else { + else mCurrentOutfit = 0; - } mCurrentLabel->setCaption(strprintf(_("Outfit: %d"), mCurrentOutfit + 1)); mUnequipCheck->setSelected(mItemsUnequip[mCurrentOutfit]); } else if (event.getId() == "previous") { - if (mCurrentOutfit > 0) { + if (mCurrentOutfit > 0) + { mCurrentOutfit--; - } else { + } + else + { mCurrentOutfit = OUTFITS_COUNT - 1; } mCurrentLabel->setCaption(strprintf(_("Outfit: %d"), mCurrentOutfit + 1)); @@ -166,9 +167,8 @@ void OutfitWindow::wearOutfit(int outfit) item = player_node->getInventory()->findItem(mItems[outfit][i]); if (item && !item->isEquipped() && item->getQuantity()) { - if (item->isEquipment()) { + if (item->isEquipment()) Net::getInventoryHandler()->equipItem(item); - } } } @@ -236,12 +236,13 @@ void OutfitWindow::draw(gcn::Graphics *graphics) void OutfitWindow::mouseDragged(gcn::MouseEvent &event) { Window::mouseDragged(event); - if (event.getButton() == gcn::MouseEvent::LEFT) { - if (!mItemMoved && mItemClicked) { + if (event.getButton() == gcn::MouseEvent::LEFT) + { + if (!mItemMoved && mItemClicked) + { const int index = getIndexFromGrid(event.getX(), event.getY()); - if (index == -1) { + if (index == -1) return; - } const int itemId = mItems[mCurrentOutfit][index]; if (itemId < 0) return; @@ -252,7 +253,8 @@ void OutfitWindow::mouseDragged(gcn::MouseEvent &event) mItems[mCurrentOutfit][index] = -1; } } - if (mItemMoved) { + if (mItemMoved) + { mCursorPosX = event.getX(); mCursorPosY = event.getY(); } @@ -263,16 +265,17 @@ void OutfitWindow::mousePressed(gcn::MouseEvent &event) { Window::mousePressed(event); const int index = getIndexFromGrid(event.getX(), event.getY()); - if (index == -1) { + if (index == -1) return; - } // Stores the selected item if there is one. - if (isItemSelected()) { + if (isItemSelected()) + { mItems[mCurrentOutfit][index] = mItemSelected; mItemSelected = -1; } - else if (mItems[mCurrentOutfit][index]) { + else if (mItems[mCurrentOutfit][index]) + { mItemClicked = true; } } @@ -287,17 +290,18 @@ void OutfitWindow::mouseReleased(gcn::MouseEvent &event) mItemSelected = -1; } const int index = getIndexFromGrid(event.getX(), event.getY()); - if (index == -1) { + if (index == -1) + { mItemMoved = NULL; return; } - if (mItemMoved) { + if (mItemMoved) + { mItems[mCurrentOutfit][index] = mItemMoved->getId(); mItemMoved = NULL; } - if (mItemClicked) { + if (mItemClicked) mItemClicked = false; - } } } @@ -305,15 +309,12 @@ int OutfitWindow::getIndexFromGrid(int pointX, int pointY) const { const gcn::Rectangle tRect = gcn::Rectangle( 10, 25, 10 + mGridWidth * mBoxWidth, 25 + mGridHeight * mBoxHeight); - if (!tRect.isPointInRect(pointX, pointY)) { + if (!tRect.isPointInRect(pointX, pointY)) return -1; - } const int index = (((pointY - 25) / mBoxHeight) * mGridWidth) + (pointX - 10) / mBoxWidth; if (index >= OUTFIT_ITEM_COUNT) - { return -1; - } return index; } |