From b3f70d8d46199524edc590269a73c262899763c7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 8 Sep 2011 00:07:56 +0300 Subject: Replace most iterator to const_iterator. Some other minor changes. --- src/gui/buydialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui/buydialog.cpp') diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 8c1ad62ce..4a03370a8 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -317,8 +317,8 @@ void BuyDialog::setVisible(bool visible) void BuyDialog::closeAll() { - DialogList::iterator it = instances.begin(); - DialogList::iterator it_end = instances.end(); + DialogList::const_iterator it = instances.begin(); + DialogList::const_iterator it_end = instances.end(); for (; it != it_end; ++it) { -- cgit v1.2.3-60-g2f50 From e3dabb7f0a22c6442dde5f261d3414f9e7369592 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 23:11:23 +0300 Subject: Last fix part of shadow variables/methods errors. --- src/actorsprite.cpp | 19 ++++++++------- src/being.cpp | 39 +++++++++++++++--------------- src/gui/buydialog.cpp | 24 +++++++++---------- src/gui/charselectdialog.cpp | 34 +++++++++++++------------- src/gui/itemamountwindow.cpp | 36 ++++++++++++++-------------- src/gui/quitdialog.cpp | 20 ++++++++-------- src/gui/quitdialog.h | 2 +- src/gui/register.cpp | 30 +++++++++++------------ src/gui/selldialog.cpp | 24 +++++++++---------- src/gui/setup_video.cpp | 14 +++++------ src/gui/shopwindow.cpp | 34 +++++++++++++------------- src/gui/textcommandeditor.cpp | 56 +++++++++++++++++++++---------------------- src/gui/tradewindow.cpp | 16 ++++++------- src/gui/updaterwindow.cpp | 16 ++++++------- src/guild.cpp | 4 ++-- src/net/messagein.cpp | 16 ++++++------- src/particleemitter.cpp | 14 +++++------ src/resources/beinginfo.cpp | 4 ++-- src/resources/image.cpp | 6 ++--- src/resources/itemdb.cpp | 2 +- 20 files changed, 203 insertions(+), 207 deletions(-) (limited to 'src/gui/buydialog.cpp') diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 2cc138047..082ceda14 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -68,7 +68,7 @@ ActorSprite::~ActorSprite() // Notify listeners of the destruction. for (ActorSpriteListenerIterator iter = mActorSpriteListeners.begin(), - end = mActorSpriteListeners.end(); iter != end; ++iter) + e = mActorSpriteListeners.end(); iter != e; ++iter) { (*iter)->actorSpriteDestroyed(*this); } @@ -366,11 +366,12 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display, //setup particle effects if (Particle::enabled && particleEngine) { - std::vector::const_iterator it, it_end; - for (it = display.particles.begin(), it_end = display.particles.end(); - it != it_end; ++it) + std::vector::const_iterator itr, itr_end; + for (itr = display.particles.begin(), + itr_end = display.particles.end(); + itr != itr_end; ++itr) { - Particle *p = particleEngine->addEffect(*it, 0, 0); + Particle *p = particleEngine->addEffect(*itr, 0, 0); controlParticle(p); } } @@ -435,7 +436,7 @@ static const char *cursorSize(int size) void ActorSprite::initTargetCursor() { - static std::string targetCursor = "graphics/target-cursor-%s-%s.png"; + static std::string targetCursorFile = "graphics/target-cursor-%s-%s.png"; static int targetWidths[NUM_TC] = {44, 62, 82}; static int targetHeights[NUM_TC] = {35, 44, 60}; @@ -444,9 +445,9 @@ void ActorSprite::initTargetCursor() { for (int type = TCT_NORMAL; type < NUM_TCT; type++) { - loadTargetCursor(strprintf(targetCursor.c_str(), cursorType(type), - cursorSize(size)), targetWidths[size], - targetHeights[size], type, size); + loadTargetCursor(strprintf(targetCursorFile.c_str(), + cursorType(type), cursorSize(size)), targetWidths[size], + targetHeights[size], type, size); } } } diff --git a/src/being.cpp b/src/being.cpp index eafc647fc..5381c5924 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -496,13 +496,13 @@ void Being::setSpeech(const std::string &text, int time) // Check for links std::string::size_type start = mSpeech.find('['); - std::string::size_type end = mSpeech.find(']', start); + std::string::size_type e = mSpeech.find(']', start); - while (start != std::string::npos && end != std::string::npos) + while (start != std::string::npos && e != std::string::npos) { // Catch multiple embeds and ignore them so it doesn't crash the client. while ((mSpeech.find('[', start + 1) != std::string::npos) && - (mSpeech.find('[', start + 1) < end)) + (mSpeech.find('[', start + 1) < e)) { start = mSpeech.find('[', start + 1); } @@ -510,7 +510,7 @@ void Being::setSpeech(const std::string &text, int time) std::string::size_type position = mSpeech.find('|'); if (mSpeech[start + 1] == '@' && mSpeech[start + 2] == '@') { - mSpeech.erase(end, 1); + mSpeech.erase(e, 1); mSpeech.erase(start, (position - start) + 1); } position = mSpeech.find('@'); @@ -522,7 +522,7 @@ void Being::setSpeech(const std::string &text, int time) } start = mSpeech.find('[', start + 1); - end = mSpeech.find(']', start); + e = mSpeech.find(']', start); } if (!mSpeech.empty()) @@ -1393,17 +1393,16 @@ void Being::drawSpeech(int offsetX, int offsetY) else if (mSpeechTime > 0 && (speech == NAME_IN_BUBBLE || speech == NO_NAME_IN_BUBBLE)) { - const bool showName = (speech == NAME_IN_BUBBLE); + const bool isShowName = (speech == NAME_IN_BUBBLE); delete mText; mText = 0; - mSpeechBubble->setCaption(showName ? mName : "", mTextColor); + mSpeechBubble->setCaption(isShowName ? mName : "", mTextColor); - mSpeechBubble->setText(mSpeech, showName); + mSpeechBubble->setText(mSpeech, isShowName); mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2), - py - getHeight() - - (mSpeechBubble->getHeight())); + py - getHeight() - (mSpeechBubble->getHeight())); mSpeechBubble->setVisible(true); } else if (mSpeechTime > 0 && speech == TEXT_OVERHEAD) @@ -2157,28 +2156,28 @@ void Being::recalcSpritesOrder() if (spriteToItems) { - SpriteToItemMap::const_iterator it; + SpriteToItemMap::const_iterator itr; - for (it = spriteToItems->begin(); - it != spriteToItems->end(); ++it) + for (itr = spriteToItems->begin(); + itr != spriteToItems->end(); ++it) { - int removeSprite = it->first; - const std::map &itemReplacer = it->second; + int remSprite = itr->first; + const std::map &itemReplacer = itr->second; if (itemReplacer.empty()) { - mSpriteHide[removeSprite] = 1; + mSpriteHide[remSprite] = 1; } else { std::map::const_iterator repIt - = itemReplacer.find(mSpriteIDs[removeSprite]); + = itemReplacer.find(mSpriteIDs[remSprite]); if (repIt != itemReplacer.end()) { - mSpriteHide[removeSprite] = repIt->second; + mSpriteHide[remSprite] = repIt->second; if (repIt->second != 1) { - setSprite(removeSprite, repIt->second, - mSpriteColors[removeSprite], + setSprite(remSprite, repIt->second, + mSpriteColors[remSprite], 1, false, true); } } diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 4a03370a8..94c2b88ff 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -111,18 +111,18 @@ void BuyDialog::init() mSlider->addActionListener(this); mShopItemList->addSelectionListener(this); - ContainerPlacer place; - place = getPlacer(0, 0); - - place(0, 0, mScrollArea, 8, 5).setPadding(3); - place(0, 5, mDecreaseButton); - place(1, 5, mSlider, 3); - place(4, 5, mIncreaseButton); - place(5, 5, mQuantityLabel, 2); - place(7, 5, mAddMaxButton); - place(0, 6, mMoneyLabel, 8); - place(6, 7, mBuyButton); - place(7, 7, mQuitButton); + ContainerPlacer placer; + placer = getPlacer(0, 0); + + placer(0, 0, mScrollArea, 8, 5).setPadding(3); + placer(0, 5, mDecreaseButton); + placer(1, 5, mSlider, 3); + placer(4, 5, mIncreaseButton); + placer(5, 5, mQuantityLabel, 2); + placer(7, 5, mAddMaxButton); + placer(0, 6, mMoneyLabel, 8); + placer(6, 7, mBuyButton); + placer(7, 7, mQuitButton); Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index f926a90aa..e39b5ecfc 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -141,34 +141,34 @@ CharSelectDialog::CharSelectDialog(LoginData *data): int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); - ContainerPlacer place; - place = getPlacer(0, 0); + ContainerPlacer placer; + placer = getPlacer(0, 0); - place(0, 0, mAccountNameLabel, 2); - place(0, 1, mSwitchLoginButton); + placer(0, 0, mAccountNameLabel, 2); + placer(0, 1, mSwitchLoginButton); if (optionalActions & Net::LoginHandler::Unregister) { mUnregisterButton = new Button(_("Unregister"), "unregister", this); - place(3, 1, mUnregisterButton); + placer(3, 1, mUnregisterButton); } - place(0, 2, mChangePasswordButton); + placer(0, 2, mChangePasswordButton); if (optionalActions & Net::LoginHandler::ChangeEmail) { mChangeEmailButton = new Button(_("Change Email"), "change_email", this); - place(3, 2, mChangeEmailButton); + placer(3, 2, mChangeEmailButton); } - place = getPlacer(0, 1); + placer = getPlacer(0, 1); for (int i = 0; i < static_cast(mLoginData->characterSlots); i++) { mCharacterEntries.push_back(new CharacterDisplay(this)); - place(i % SLOTS_PER_ROW, static_cast(i) / SLOTS_PER_ROW, + placer(i % SLOTS_PER_ROW, static_cast(i) / SLOTS_PER_ROW, mCharacterEntries[i]); } @@ -410,14 +410,14 @@ CharacterDisplay::CharacterDisplay(CharSelectDialog *charSelectDialog): mDelete = new Button(_("Delete"), "delete", charSelectDialog); LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - - place(0, 0, mPlayerBox, 3, 5); - place(0, 5, mName, 3); - place(0, 6, mLevel, 3); - place(0, 7, mMoney, 3); - place(0, 8, mButton, 3); - place(0, 9, mDelete, 3); + ContainerPlacer placer = h.getPlacer(0, 0); + + placer(0, 0, mPlayerBox, 3, 5); + placer(0, 5, mName, 3); + placer(0, 6, mLevel, 3); + placer(0, 7, mMoney, 3); + placer(0, 8, mButton, 3); + placer(0, 9, mDelete, 3); update(); diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index 9bd3f3ab3..d85b38ccb 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -213,21 +213,21 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, minusAmountButton->setWidth(plusAmountButton->getWidth()); // Set positions - ContainerPlacer place; - place = getPlacer(0, 0); + ContainerPlacer placer; + placer = getPlacer(0, 0); int n = 0; if (mUsage == ShopBuyAdd) { - place(0, n, mItemDropDown, 8); + placer(0, n, mItemDropDown, 8); n++; } - place(1, n, minusAmountButton); - place(2, n, mItemAmountTextField, 3); - place(5, n, plusAmountButton); - place(6, n, addAllButton); + placer(1, n, minusAmountButton); + placer(2, n, mItemAmountTextField, 3); + placer(5, n, plusAmountButton); + placer(6, n, addAllButton); - place(0, n, mItemIcon, 1, 3); - place(1, n + 1, mItemAmountSlide, 7); + placer(0, n, mItemIcon, 1, 3); + placer(1, n + 1, mItemAmountSlide, 7); if (mUsage == ShopBuyAdd || mUsage == ShopSellAdd) { @@ -236,19 +236,19 @@ ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, minusPriceButton->adjustSize(); minusPriceButton->setWidth(plusPriceButton->getWidth()); - place(1, n + 2, minusPriceButton); - place(2, n + 2, mItemPriceTextField, 3); - place(5, n + 2, plusPriceButton); - place(6, n + 2, mGPLabel); + placer(1, n + 2, minusPriceButton); + placer(2, n + 2, mItemPriceTextField, 3); + placer(5, n + 2, plusPriceButton); + placer(6, n + 2, mGPLabel); - place(1, n + 3, mItemPriceSlide, 7); - place(4, n + 5, cancelButton); - place(5, n + 5, okButton); + placer(1, n + 3, mItemPriceSlide, 7); + placer(4, n + 5, cancelButton); + placer(5, n + 5, okButton); } else { - place(4, n + 2, cancelButton); - place(5, n + 2, okButton); + placer(4, n + 2, cancelButton); + placer(5, n + 2, okButton); } reflowLayout(225, 0); diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 96848f645..e71e291d1 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -55,7 +55,7 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe): addKeyListener(this); - ContainerPlacer place = getPlacer(0, 0); + ContainerPlacer placer = getPlacer(0, 0); const State state = Client::getState(); @@ -67,25 +67,25 @@ QuitDialog::QuitDialog(QuitDialog** pointerToMe): state == STATE_UPDATE || state == STATE_LOAD_DATA) { - placeOption(place, mForceQuit); + placeOption(placer, mForceQuit); } else { // Only added if we are connected to an accountserver or gameserver - placeOption(place, mLogoutQuit); - placeOption(place, mSwitchAccountServer); + placeOption(placer, mLogoutQuit); + placeOption(placer, mSwitchAccountServer); // Only added if we are connected to a gameserver if (state == STATE_GAME) - placeOption(place, mSwitchCharacter); + placeOption(placer, mSwitchCharacter); } mOptions[0]->setSelected(true); - place = getPlacer(0, 1); + placer = getPlacer(0, 1); - place(1, 0, mOkButton, 1); - place(2, 0, mCancelButton, 1); + placer(1, 0, mOkButton, 1); + placer(2, 0, mCancelButton, 1); reflowLayout(200, 0); setLocationRelativeTo(getParent()); @@ -109,9 +109,9 @@ QuitDialog::~QuitDialog() mSwitchCharacter = 0; } -void QuitDialog::placeOption(ContainerPlacer &place, gcn::RadioButton *option) +void QuitDialog::placeOption(ContainerPlacer &placer, gcn::RadioButton *option) { - place(0, static_cast(mOptions.size()), option, 3); + placer(0, static_cast(mOptions.size()), option, 3); mOptions.push_back(option); } diff --git a/src/gui/quitdialog.h b/src/gui/quitdialog.h index 380a85528..5456be26b 100644 --- a/src/gui/quitdialog.h +++ b/src/gui/quitdialog.h @@ -61,7 +61,7 @@ class QuitDialog : public Window, public gcn::ActionListener, void keyPressed(gcn::KeyEvent &keyEvent); private: - void placeOption(ContainerPlacer &place, gcn::RadioButton *option); + void placeOption(ContainerPlacer &placer, gcn::RadioButton *option); std::vector mOptions; gcn::RadioButton *mLogoutQuit; diff --git a/src/gui/register.cpp b/src/gui/register.cpp index e2c718359..603810a0b 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -81,15 +81,15 @@ RegisterDialog::RegisterDialog(LoginData *data): mRegisterButton = new Button(_("Register"), "register", this); mCancelButton = new Button(_("Cancel"), "cancel", this); - ContainerPlacer place; - place = getPlacer(0, 0); - place(0, 0, userLabel); - place(0, 1, passwordLabel); - place(0, 2, confirmLabel); + ContainerPlacer placer; + placer = getPlacer(0, 0); + placer(0, 0, userLabel); + placer(0, 1, passwordLabel); + placer(0, 2, confirmLabel); - place(1, 0, mUserField, 3).setPadding(2); - place(1, 1, mPasswordField, 3).setPadding(2); - place(1, 2, mConfirmField, 3).setPadding(2); + placer(1, 0, mUserField, 3).setPadding(2); + placer(1, 1, mPasswordField, 3).setPadding(2); + placer(1, 2, mConfirmField, 3).setPadding(2); int row = 3; @@ -97,8 +97,8 @@ RegisterDialog::RegisterDialog(LoginData *data): { mMaleButton = new RadioButton(_("Male"), "sex", true); mFemaleButton = new RadioButton(_("Female"), "sex", false); - place(1, row, mMaleButton); - place(2, row, mFemaleButton); + placer(1, row, mMaleButton); + placer(2, row, mFemaleButton); row++; } @@ -107,15 +107,15 @@ RegisterDialog::RegisterDialog(LoginData *data): { gcn::Label *emailLabel = new Label(_("Email:")); mEmailField = new TextField; - place(0, row, emailLabel); - place(1, row, mEmailField, 3).setPadding(2); + placer(0, row, emailLabel); + placer(1, row, mEmailField, 3).setPadding(2); row++; } - place = getPlacer(0, 2); - place(1, 0, mRegisterButton); - place(2, 0, mCancelButton); + placer = getPlacer(0, 2); + placer(1, 0, mRegisterButton); + placer(2, 0, mCancelButton); reflowLayout(250, 0); mUserField->addKeyListener(this); diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index 5cbb4167e..82b4a1829 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -107,18 +107,18 @@ void SellDialog::init() mSlider->setActionEventId("slider"); mSlider->addActionListener(this); - ContainerPlacer place; - place = getPlacer(0, 0); - - place(0, 0, mScrollArea, 8, 5).setPadding(3); - place(0, 5, mDecreaseButton); - place(1, 5, mSlider, 3); - place(4, 5, mIncreaseButton); - place(5, 5, mQuantityLabel, 2); - place(7, 5, mAddMaxButton); - place(0, 6, mMoneyLabel, 8); - place(6, 7, mSellButton); - place(7, 7, mQuitButton); + ContainerPlacer placer; + placer = getPlacer(0, 0); + + placer(0, 0, mScrollArea, 8, 5).setPadding(3); + placer(0, 5, mDecreaseButton); + placer(1, 5, mSlider, 3); + placer(4, 5, mIncreaseButton); + placer(5, 5, mQuantityLabel, 2); + placer(7, 5, mAddMaxButton); + placer(0, 6, mMoneyLabel, 8); + placer(6, 7, mSellButton); + placer(7, 7, mQuitButton); Layout &layout = getLayout(); layout.setRowHeight(0, Layout::AUTO_SET); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index bc210075a..e0f03ec60 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -687,12 +687,12 @@ void Setup_Video::action(const gcn::ActionEvent &event) } else if (id == "fpslimitcheckbox" || id == "fpslimitslider") { - int fps = static_cast(mFpsSlider->getValue()); + int tempFps = static_cast(mFpsSlider->getValue()); if (id == "fpslimitcheckbox" && !mFpsSlider->isEnabled()) - fps = 60; + tempFps = 60; else - fps = fps > 0 ? fps : 60; - mFps = mFpsCheckBox->isSelected() ? fps : 0; + tempFps = tempFps > 0 ? tempFps : 60; + mFps = mFpsCheckBox->isSelected() ? tempFps : 0; const std::string text = mFps > 0 ? toString(mFps) : _("None"); mFpsLabel->setCaption(text); @@ -701,9 +701,9 @@ void Setup_Video::action(const gcn::ActionEvent &event) } else if (id == "altfpslimitslider") { - int fps = static_cast(mAltFpsSlider->getValue()); - fps = fps > 0 ? fps : static_cast(mAltFpsSlider->getScaleStart()); - mAltFps = fps; + int tempFps = static_cast(mAltFpsSlider->getValue()); + tempFps = tempFps > 0 ? tempFps : static_cast(mAltFpsSlider->getScaleStart()); + mAltFps = tempFps; const std::string text = mAltFps > 0 ? toString(mAltFps) : _("None"); mAltFpsLabel->setCaption(_("Alt FPS limit: ") + text); diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index c62c3254c..ccfed3efc 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -127,28 +127,28 @@ ShopWindow::ShopWindow(): mAnnounceLinks = new CheckBox(_("Show links in announce"), false, this, "link announce"); - ContainerPlacer place; - place = getPlacer(0, 0); - - place(0, 0, mBuyLabel, 8).setPadding(3); - place(8, 0, mSellLabel, 8).setPadding(3); - place(0, 1, mBuyScrollArea, 8, 5).setPadding(3); - place(8, 1, mSellScrollArea, 8, 5).setPadding(3); - place(0, 6, mBuyAddButton); - place(1, 6, mBuyDeleteButton); - place(3, 6, mBuyAnnounceButton); - place(8, 6, mSellAddButton); - place(9, 6, mSellDeleteButton); - place(11, 6, mSellAnnounceButton); - place(0, 7, mAnnounceLinks, 8); - place(15, 7, mCloseButton); + ContainerPlacer placer; + placer = getPlacer(0, 0); + + placer(0, 0, mBuyLabel, 8).setPadding(3); + placer(8, 0, mSellLabel, 8).setPadding(3); + placer(0, 1, mBuyScrollArea, 8, 5).setPadding(3); + placer(8, 1, mSellScrollArea, 8, 5).setPadding(3); + placer(0, 6, mBuyAddButton); + placer(1, 6, mBuyDeleteButton); + placer(3, 6, mBuyAnnounceButton); + placer(8, 6, mSellAddButton); + placer(9, 6, mSellDeleteButton); + placer(11, 6, mSellAnnounceButton); + placer(0, 7, mAnnounceLinks, 8); + placer(15, 7, mCloseButton); if (auctionManager && auctionManager->getEnableAuctionBot()) { mBuyAuctionButton = new Button(_("Auction"), "auction buy", this); mSellAuctionButton = new Button(_("Auction"), "auction sell", this); - place(4, 6, mBuyAuctionButton); - place(12, 6, mSellAuctionButton); + placer(4, 6, mBuyAuctionButton); + placer(12, 6, mSellAuctionButton); } else { diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 1e18da57a..214cbff76 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -254,34 +254,34 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): mSchoolDropDown->setSelected(command->getSchool() - MAGIC_START_ID); mSchoolLvlField->setValue(command->getSchoolLvl()); - ContainerPlacer place; - place = getPlacer(0, 0); - - place(0, 0, mIsMagic, 1); - place(2, 0, mIsOther, 1); - place(0, 1, mSymbolLabel, 2).setPadding(3); - place(2, 1, mSymbolTextField, 3).setPadding(3); - place(0, 2, mCommandLabel, 2).setPadding(3); - place(2, 2, mCommandTextField, 4).setPadding(3); - place(0, 3, mTypeLabel, 2).setPadding(3); - place(2, 3, mTypeDropDown, 3).setPadding(3); - - place(0, 4, mIconLabel, 2).setPadding(3); - place(2, 4, mIconDropDown, 3).setPadding(3); - - place(0, 5, mManaLabel, 2).setPadding(3); - place(2, 5, mManaField, 3).setPadding(3); - place(0, 6, mMagicLvlLabel, 2).setPadding(3); - place(2, 6, mMagicLvlField, 3).setPadding(3); - - place(0, 7, mSchoolLabel, 2).setPadding(3); - place(2, 7, mSchoolDropDown, 3).setPadding(3); - place(0, 8, mSchoolLvlLabel, 2).setPadding(3); - place(2, 8, mSchoolLvlField, 3).setPadding(3); - - place(0, 9, mSaveButton, 2).setPadding(3); - place(2, 9, mCancelButton, 2).setPadding(3); - place(4, 9, mDeleteButton, 2).setPadding(3); + ContainerPlacer placer; + placer = getPlacer(0, 0); + + placer(0, 0, mIsMagic, 1); + placer(2, 0, mIsOther, 1); + placer(0, 1, mSymbolLabel, 2).setPadding(3); + placer(2, 1, mSymbolTextField, 3).setPadding(3); + placer(0, 2, mCommandLabel, 2).setPadding(3); + placer(2, 2, mCommandTextField, 4).setPadding(3); + placer(0, 3, mTypeLabel, 2).setPadding(3); + placer(2, 3, mTypeDropDown, 3).setPadding(3); + + placer(0, 4, mIconLabel, 2).setPadding(3); + placer(2, 4, mIconDropDown, 3).setPadding(3); + + placer(0, 5, mManaLabel, 2).setPadding(3); + placer(2, 5, mManaField, 3).setPadding(3); + placer(0, 6, mMagicLvlLabel, 2).setPadding(3); + placer(2, 6, mMagicLvlField, 3).setPadding(3); + + placer(0, 7, mSchoolLabel, 2).setPadding(3); + placer(2, 7, mSchoolDropDown, 3).setPadding(3); + placer(0, 8, mSchoolLvlLabel, 2).setPadding(3); + placer(2, 8, mSchoolLvlField, 3).setPadding(3); + + placer(0, 9, mSaveButton, 2).setPadding(3); + placer(2, 9, mCancelButton, 2).setPadding(3); + placer(4, 9, mDeleteButton, 2).setPadding(3); setWidth(w); setHeight(h); diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index d0ae67746..3874a8301 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -118,14 +118,14 @@ TradeWindow::TradeWindow(): place(1, 0, mMoneyLabel); place(0, 1, myScroll).setPadding(3); place(1, 1, partnerScroll).setPadding(3); - ContainerPlacer place; - place = getPlacer(0, 0); - place(0, 0, mMoneyLabel2); - place(1, 0, mMoneyField, 2); - place(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT); - place = getPlacer(0, 2); - place(0, 0, mAddButton); - place(1, 0, mOkButton); + ContainerPlacer placer; + placer = getPlacer(0, 0); + placer(0, 0, mMoneyLabel2); + placer(1, 0, mMoneyField, 2); + placer(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT); + placer = getPlacer(0, 2); + placer(0, 0, mAddButton); + placer(1, 0, mOkButton); Layout &layout = getLayout(); layout.extend(0, 2, 2, 1); layout.setRowHeight(1, Layout::AUTO_SET); diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 4ba1c9179..d6c74cc79 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -165,14 +165,14 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, mBrowserBox->setOpaque(false); mPlayButton->setEnabled(false); - ContainerPlacer place; - place = getPlacer(0, 0); - - place(0, 0, mScrollArea, 5, 3).setPadding(3); - place(0, 3, mLabel, 5); - place(0, 4, mProgressBar, 5); - place(3, 5, mCancelButton); - place(4, 5, mPlayButton); + ContainerPlacer placer; + placer = getPlacer(0, 0); + + placer(0, 0, mScrollArea, 5, 3).setPadding(3); + placer(0, 3, mLabel, 5); + placer(0, 4, mProgressBar, 5); + placer(3, 5, mCancelButton); + placer(4, 5, mPlayButton); reflowLayout(450, 400); diff --git a/src/guild.cpp b/src/guild.cpp index 234c7d32f..a2d9149eb 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -170,9 +170,9 @@ void Guild::removeMember(GuildMember *member) (*itr)->mCharId == member->mCharId && (*itr)->getName() == member->getName()) { - GuildMember *member = *itr; + GuildMember *m = *itr; mMembers.erase(itr); - delete member; + delete m; return; } ++itr; diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 5bfeefdb6..8f177f906 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -190,12 +190,11 @@ std::string MessageIn::readString(int length) char const *stringEnd = static_cast(memchr(stringBeg, '\0', length)); - std::string readString(stringBeg, - stringEnd ? stringEnd - stringBeg : length); + std::string str(stringBeg, stringEnd ? stringEnd - stringBeg : length); mPos += length; PacketCounters::incInBytes(length); - DEBUGLOG("readString: " + readString); - return readString; + DEBUGLOG("readString: " + str); + return str; } std::string MessageIn::readRawString(int length) @@ -215,12 +214,11 @@ std::string MessageIn::readRawString(int length) char const *stringBeg = mData + mPos; char const *stringEnd = static_cast(memchr(stringBeg, '\0', length)); - std::string readString(stringBeg, - stringEnd ? stringEnd - stringBeg : length); + std::string str(stringBeg, stringEnd ? stringEnd - stringBeg : length); mPos += length; PacketCounters::incInBytes(length); - DEBUGLOG("readString: " + readString); + DEBUGLOG("readString: " + str); if (stringEnd) { @@ -234,11 +232,11 @@ std::string MessageIn::readRawString(int length) { DEBUGLOG("readString2: " + hiddenPart); - return readString + "|" + hiddenPart; + return str + "|" + hiddenPart; } } - return readString; + return str; } } diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index fd1f07e16..9cad0864f 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -566,9 +566,9 @@ std::list ParticleEmitter::createParticles(int tick) newParticle->setFollow(mParticleFollow); newParticle->setDestination(mParticleTarget, - mParticleAcceleration.value(tick), - mParticleMomentum.value(tick) - ); + mParticleAcceleration.value(tick), + mParticleMomentum.value(tick)); + newParticle->setDieDistance(mParticleDieDistance.value(tick)); newParticle->setLifetime(mParticleLifetime.value(tick)); @@ -577,16 +577,14 @@ std::list ParticleEmitter::createParticles(int tick) newParticle->setAlpha(mParticleAlpha.value(tick)); for (std::list::const_iterator - i = mParticleChildEmitters.begin(); - i != mParticleChildEmitters.end(); ++i) + it = mParticleChildEmitters.begin(); + it != mParticleChildEmitters.end(); ++it) { - newParticle->addEmitter(new ParticleEmitter(*i)); + newParticle->addEmitter(new ParticleEmitter(*it)); } if (!mDeathEffect.empty()) - { newParticle->setDeathEffect(mDeathEffect, mDeathEffectConditions); - } newParticles.push_back(newParticle); } diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp index 8beea420d..4aa7515b1 100644 --- a/src/resources/beinginfo.cpp +++ b/src/resources/beinginfo.cpp @@ -94,10 +94,10 @@ void BeingInfo::addSound(SoundEvent event, const std::string &filename) const std::string &BeingInfo::getSound(SoundEvent event) const { - static std::string empty(""); + static std::string emptySound(""); SoundEvents::const_iterator i = mSounds.find(event); - return (i == mSounds.end() || !i->second) ? empty : + return (i == mSounds.end() || !i->second) ? emptySound : i->second->at(rand() % i->second->size()); } diff --git a/src/resources/image.cpp b/src/resources/image.cpp index e28cb2bc5..8f5ee1d2d 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -49,12 +49,12 @@ int Image::mTextureSize = 0; bool Image::mEnableAlphaCache = false; bool Image::mEnableAlpha = true; -Image::Image(SDL_Surface *image, bool hasAlphaChannel, Uint8 *alphaChannel): +Image::Image(SDL_Surface *image, bool hasAlphaChannel0, Uint8 *alphaChannel): mAlpha(1.0f), - mHasAlphaChannel(hasAlphaChannel), + mHasAlphaChannel(hasAlphaChannel0), mSDLSurface(image), mAlphaChannel(alphaChannel), - mIsAlphaVisible(hasAlphaChannel), + mIsAlphaVisible(hasAlphaChannel0), mIsAlphaCalculated(false) { #ifdef USE_OPENGL diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 89df407a6..9ff80de22 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -361,7 +361,7 @@ void ItemDB::load() mItemInfos[id] = itemInfo; if (!name.empty()) { - std::string temp = normalize(name); + temp = normalize(name); NamedItemInfos::const_iterator itr = mNamedItemInfos.find(temp); if (itr == mNamedItemInfos.end()) -- cgit v1.2.3-60-g2f50 From ee39f800bd1809b25cc7c05238e2fa7abccd8ab3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 10 Sep 2011 23:09:21 +0300 Subject: Allow load for each window own xml theme file. --- src/gui/botcheckerwindow.cpp | 2 +- src/gui/buydialog.cpp | 4 ++-- src/gui/buyselldialog.cpp | 4 ++-- src/gui/changeemaildialog.cpp | 2 +- src/gui/changepassworddialog.cpp | 2 +- src/gui/charcreatedialog.cpp | 2 +- src/gui/charselectdialog.cpp | 2 +- src/gui/chatwindow.cpp | 2 +- src/gui/debugwindow.cpp | 2 +- src/gui/didyouknowwindow.cpp | 2 +- src/gui/equipmentwindow.cpp | 2 +- src/gui/helpwindow.cpp | 2 +- src/gui/killstats.cpp | 3 ++- src/gui/logindialog.cpp | 2 +- src/gui/minimap.cpp | 2 +- src/gui/npcdialog.cpp | 2 +- src/gui/npcpostdialog.cpp | 2 +- src/gui/outfitwindow.cpp | 2 +- src/gui/quitdialog.cpp | 3 ++- src/gui/register.cpp | 2 +- src/gui/selldialog.cpp | 4 ++-- src/gui/serverdialog.cpp | 2 +- src/gui/setup.cpp | 2 +- src/gui/shopwindow.cpp | 2 +- src/gui/skilldialog.cpp | 2 +- src/gui/socialwindow.cpp | 2 +- src/gui/specialswindow.cpp | 2 +- src/gui/textcommandeditor.cpp | 2 +- src/gui/theme.cpp | 28 ++++++++++++++++++++++++++++ src/gui/theme.h | 2 ++ src/gui/tradewindow.cpp | 2 +- src/gui/unregisterdialog.cpp | 2 +- src/gui/updaterwindow.cpp | 2 +- src/gui/whoisonline.cpp | 2 +- src/gui/widgets/window.cpp | 26 +++++++++++++++++++------- src/gui/widgets/window.h | 2 +- src/gui/worldselectdialog.cpp | 2 +- 37 files changed, 88 insertions(+), 44 deletions(-) (limited to 'src/gui/buydialog.cpp') diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 8bc0d892e..34293e59d 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -263,7 +263,7 @@ protected: BotCheckerWindow::BotCheckerWindow(): - Window(_("Bot Checker")), + Window(_("Bot Checker"), false, 0, "botchecker.xml"), mEnabled(false) { int w = 500; diff --git a/src/gui/buydialog.cpp b/src/gui/buydialog.cpp index 94c2b88ff..8628afc6e 100644 --- a/src/gui/buydialog.cpp +++ b/src/gui/buydialog.cpp @@ -53,14 +53,14 @@ BuyDialog::DialogList BuyDialog::instances; BuyDialog::BuyDialog(int npcId): - Window(_("Buy")), + Window(_("Buy"), false, 0, "buy.xml"), mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick("") { init(); } BuyDialog::BuyDialog(std::string nick): - Window(_("Buy")), + Window(_("Buy"), false, 0, "buy.xml"), mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick) { init(); diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp index dfe7a422a..e1063192a 100644 --- a/src/gui/buyselldialog.cpp +++ b/src/gui/buyselldialog.cpp @@ -37,7 +37,7 @@ BuySellDialog::DialogList BuySellDialog::instances; BuySellDialog::BuySellDialog(int npcId): - Window(_("Shop")), + Window(_("Shop"), false, 0, "buysell.xml"), mNpcId(npcId), mNick(""), mBuyButton(0) @@ -46,7 +46,7 @@ BuySellDialog::BuySellDialog(int npcId): } BuySellDialog::BuySellDialog(std::string nick): - Window(_("Shop")), + Window(_("Shop"), false, 0, "buysell.xml"), mNpcId(-1), mNick(nick), mBuyButton(0) diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index 69af649e2..384ebf07f 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -45,7 +45,7 @@ #include "debug.h" ChangeEmailDialog::ChangeEmailDialog(LoginData *data): - Window(_("Change Email Address"), true), + Window(_("Change Email Address"), true, 0, "changeemail.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 56db37ebb..7a67279b6 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -47,7 +47,7 @@ #include "debug.h" ChangePasswordDialog::ChangePasswordDialog(LoginData *data): - Window(_("Change Password"), true), + Window(_("Change Password"), true, 0, "changepassword.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index d1773e7f3..efe7e804f 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -55,7 +55,7 @@ #include "debug.h" CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): - Window(_("Create Character"), true, parent), + Window(_("Create Character"), true, parent, "charcreate.xml"), mCharSelectDialog(parent), mRace(0), mSlot(slot) diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index e39b5ecfc..00cae41e6 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -122,7 +122,7 @@ class CharacterDisplay : public Container }; CharSelectDialog::CharSelectDialog(LoginData *data): - Window(_("Account and Character Management")), + Window(_("Account and Character Management"), false, 0, "char.xml"), mLocked(false), mUnregisterButton(0), mChangeEmailButton(0), diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 2bada256c..82d6c2ff5 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -149,7 +149,7 @@ public: ChatWindow::ChatWindow(): - Window(_("Chat")), + Window(_("Chat"), false, 0, "chat.xml"), mTmpVisible(false), mChatHistoryIndex(0) { diff --git a/src/gui/debugwindow.cpp b/src/gui/debugwindow.cpp index dc540a782..83e9791ef 100644 --- a/src/gui/debugwindow.cpp +++ b/src/gui/debugwindow.cpp @@ -51,7 +51,7 @@ #include "debug.h" DebugWindow::DebugWindow(): - Window(_("Debug")) + Window(_("Debug"), false, 0, "debug.xml") { setWindowName("Debug"); if (setupWindow) diff --git a/src/gui/didyouknowwindow.cpp b/src/gui/didyouknowwindow.cpp index d62417fc4..df15e6ebd 100644 --- a/src/gui/didyouknowwindow.cpp +++ b/src/gui/didyouknowwindow.cpp @@ -44,7 +44,7 @@ static const int minTip = 1; static const int maxTip = 14; DidYouKnowWindow::DidYouKnowWindow(): - Window(_("Did You Know?")) + Window(_("Did You Know?"), false, 0, "didyouknow.xml") { setMinWidth(300); setMinHeight(250); diff --git a/src/gui/equipmentwindow.cpp b/src/gui/equipmentwindow.cpp index 0375d096f..f423cddf0 100644 --- a/src/gui/equipmentwindow.cpp +++ b/src/gui/equipmentwindow.cpp @@ -58,7 +58,7 @@ static const int BOX_HEIGHT = 36; EquipmentWindow::EquipmentWindow(Equipment *equipment, Being *being, bool foring): - Window(_("Equipment")), + Window(_("Equipment"), false, 0, "equipment.xml"), mEquipment(equipment), mSelected(-1), mForing(foring) diff --git a/src/gui/helpwindow.cpp b/src/gui/helpwindow.cpp index b772ea36a..019baf503 100644 --- a/src/gui/helpwindow.cpp +++ b/src/gui/helpwindow.cpp @@ -40,7 +40,7 @@ #include "debug.h" HelpWindow::HelpWindow(): - Window(_("Help")) + Window(_("Help"), false, 0, "help.xml") { setMinWidth(300); setMinHeight(250); diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 0cadc765b..4bcab0a09 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -43,7 +43,8 @@ #include "debug.h" KillStats::KillStats(): - Window(_("Kill stats")), mKillCounter(0), mExpCounter(0), + Window(_("Kill stats"), false, 0, "killstats.xml"), + mKillCounter(0), mExpCounter(0), mKillTCounter(0), mExpTCounter(0), mKillTimer(0), m1minExpTime(0), m1minExpNum(0), m1minSpeed(0), m5minExpTime(0), m5minExpNum(0), m5minSpeed(0), diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index 26248059c..136a01b37 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -83,7 +83,7 @@ public: LoginDialog::LoginDialog(LoginData *data, std::string serverName, std::string *updateHost): - Window(_("Login")), + Window(_("Login"), false, 0, "login.xml"), mLoginData(data), mUpdateHost(updateHost), mServerName(serverName) diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index 70bbc1dad..e42f12336 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -47,7 +47,7 @@ bool Minimap::mShow = true; Minimap::Minimap(): - Window(_("Map")), + Window(_("Map"), false, 0, "map.xml"), mMapImage(0), mWidthProportion(0.5), mHeightProportion(0.5), diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 3956b47ac..3e1ee46d8 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -56,7 +56,7 @@ NpcDialog::DialogList NpcDialog::instances; NpcDialog::NpcDialog(int npcId) - : Window(_("NPC")), + : Window(_("NPC"), false, 0, "npc.xml"), mNpcId(npcId), mLogInteraction(config.getBoolValue("logNpcInGui")), mDefaultInt(0), diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 72dd76aa3..67fc57ba9 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -39,7 +39,7 @@ NpcPostDialog::DialogList NpcPostDialog::instances; NpcPostDialog::NpcPostDialog(int npcId): - Window(_("NPC")), + Window(_("NPC"), false, 0, "npcpost.xml"), mNpcId(npcId) { setContentSize(400, 180); diff --git a/src/gui/outfitwindow.cpp b/src/gui/outfitwindow.cpp index 9601e3ca5..8e0791af1 100644 --- a/src/gui/outfitwindow.cpp +++ b/src/gui/outfitwindow.cpp @@ -57,7 +57,7 @@ float OutfitWindow::mAlpha = 1.0; OutfitWindow::OutfitWindow(): - Window(_("Outfits")), + Window(_("Outfits"), false, 0, "outfits.xml"), mBoxWidth(33), mBoxHeight(33), mGridWidth(4), diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index e71e291d1..05691c2d2 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -44,7 +44,8 @@ #include "debug.h" QuitDialog::QuitDialog(QuitDialog** pointerToMe): - Window(_("Quit"), true, NULL), mMyPointer(pointerToMe) + Window(_("Quit"), true, 0, "quit.xml"), + mMyPointer(pointerToMe) { mForceQuit = new RadioButton(_("Quit"), "quitdialog"); mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 603810a0b..062275b80 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -63,7 +63,7 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) } RegisterDialog::RegisterDialog(LoginData *data): - Window(_("Register")), + Window(_("Register"), false, 0, "register.xml"), mEmailField(0), mMaleButton(0), mFemaleButton(0), diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index 82b4a1829..bbd0a71c1 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -50,14 +50,14 @@ SellDialog::DialogList SellDialog::instances; SellDialog::SellDialog(int npcId): - Window(_("Sell")), + Window(_("Sell"), false, 0, "sell.xml"), mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("") { init(); } SellDialog::SellDialog(std::string nick): - Window(_("Sell")), + Window(_("Sell"), false, 0, "sell.xml"), mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick) { init(); diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index f9d6ebfd0..1b0dd22aa 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -234,7 +234,7 @@ private: ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): - Window(_("Choose Your Server")), + Window(_("Choose Your Server"), false, 0, "server.xml"), mDir(dir), // mDownloadStatus(DOWNLOADING_PREPARING), mDownloadStatus(DOWNLOADING_UNKNOWN), diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 113dd9081..33f379743 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -51,7 +51,7 @@ extern Window *statusWindow; Setup::Setup(): - Window(_("Setup")) + Window(_("Setup"), false, 0, "setup.xml") { setCloseButton(true); setResizable(true); diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index ccfed3efc..2215ce699 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -72,7 +72,7 @@ extern std::string tradePartnerName; ShopWindow::DialogList ShopWindow::instances; ShopWindow::ShopWindow(): - Window(_("Personal Shop")), + Window(_("Personal Shop"), false, 0, "shop.xml"), mSelectedItem(-1), mAnnonceTime(0), mLastRequestTimeList(0), diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index c2685b476..28dbca939 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -273,7 +273,7 @@ private: }; SkillDialog::SkillDialog(): - Window(_("Skills")) + Window(_("Skills"), false, 0, "skills.xml") { setWindowName("Skills"); setCloseButton(true); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 886894564..a8d15f36c 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -1114,7 +1114,7 @@ private: }; SocialWindow::SocialWindow() : - Window(_("Social")), + Window(_("Social"), false, 0, "social.xml"), mGuildInvited(0), mGuildAcceptDialog(0), mPartyAcceptDialog(0), diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index 64f61e3c3..c464b83b5 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -76,7 +76,7 @@ class SpecialEntry : public Container }; SpecialsWindow::SpecialsWindow(): - Window(_("Specials")) + Window(_("Specials"), false, 0, "specials.xml") { setWindowName("Specials"); setCloseButton(true); diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 214cbff76..282f23ee1 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -165,7 +165,7 @@ public: TextCommandEditor::TextCommandEditor(TextCommand *command): - Window(_("Command Editor")) + Window(_("Command Editor"), false, 0, "commandeditor.xml") { int w = 350; int h = 350; diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 0607564f9..12e7736c0 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -215,6 +215,9 @@ Skin *Theme::load(const std::string &filename, const std::string &defaultPath) Skin *skin = readSkin(filename); + if (!skin) + skin = readSkin("window.xml"); + if (!skin) { // Try falling back on the defaultPath if this makes sense @@ -240,6 +243,31 @@ Skin *Theme::load(const std::string &filename, const std::string &defaultPath) return skin; } +void Theme::unload(Skin *skin) +{ + if (!skin) + return; + skin->instances --; +/* + // unload theme if no instances + if (!skin->instances) + { + SkinIterator it = mSkins.begin(); + SkinIterator it_end = mSkins.end(); + while (it != it_end) + { + if (it->second == skin) + { + mSkins.erase(it); + break; + } + ++ it; + } + delete skin; + } +*/ +} + void Theme::setMinimumOpacity(float minimumOpacity) { if (minimumOpacity > 1.0f) diff --git a/src/gui/theme.h b/src/gui/theme.h index fbc6f13da..46d2eee2d 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -238,6 +238,8 @@ class Theme : public Palette, public ConfigListener Skin *load(const std::string &filename, const std::string &defaultPath = getThemePath()); + void unload(Skin *skin); + /** * Updates the alpha values of all of the skins. */ diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index 3874a8301..bd7e9bb1e 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -63,7 +63,7 @@ #define CAPTION_ACCEPTED _("Agreed. Waiting...") TradeWindow::TradeWindow(): - Window(_("Trade: You")), + Window(_("Trade: You"), false, 0, "trade.xml"), mMyInventory(new Inventory(Inventory::TRADE)), mPartnerInventory(new Inventory(Inventory::TRADE)), mStatus(PROPOSING), diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index e875000c4..cc5caca60 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -47,7 +47,7 @@ #include "debug.h" UnRegisterDialog::UnRegisterDialog(LoginData *data): - Window(_("Unregister"), true), + Window(_("Unregister"), true, 0, "unregister.xml"), mWrongDataNoticeListener(new WrongDataNoticeListener), mLoginData(data) { diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index d6c74cc79..2efe82199 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -135,7 +135,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost, const std::string &updatesDir, bool applyUpdates, int updateType): - Window(_("Updating...")), + Window(_("Updating..."), false, 0, "update.xml"), mDownloadStatus(UPDATE_NEWS), mUpdateHost(updateHost), mUpdatesDir(updatesDir), diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index ff855ed05..e1f69c2d7 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -78,7 +78,7 @@ bool stringCompare(const std::string &left, const std::string &right ) } WhoIsOnline::WhoIsOnline(): - Window(_("Who Is Online - Updating")), + Window(_("Who Is Online - Updating"), false, 0, "whoisonline.xml"), mThread(NULL), mDownloadStatus(UPDATE_LIST), mDownloadComplete(true), diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 05509ab39..1ffbac31e 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -47,7 +47,7 @@ int Window::instances = 0; int Window::mouseResize = 0; Window::Window(const std::string &caption, bool modal, Window *parent, - const std::string &skin): + std::string skin): gcn::Window(caption), mGrip(0), mParent(parent), @@ -79,8 +79,18 @@ Window::Window(const std::string &caption, bool modal, Window *parent, setPadding(3); setTitleBarHeight(20); + if (skin == "") + skin = "window.xml"; + // Loads the skin - mSkin = Theme::instance()->load(skin); + if (Theme::instance()) + { + mSkin = Theme::instance()->load(skin); + } + else + { + mSkin = 0; + } // Add this window to the window container windowContainer->add(this); @@ -113,8 +123,6 @@ Window::~Window() mWidgets.clear(); -// need mWidgets.clean ? - removeWidgetListener(this); delete mVertexes; mVertexes = 0; @@ -122,7 +130,11 @@ Window::~Window() instances--; if (mSkin) - mSkin->instances--; + { + if (Theme::instance()) + Theme::instance()->unload(mSkin); + mSkin = 0; + } } void Window::setWindowContainer(WindowContainer *wc) @@ -443,7 +455,7 @@ void Window::mousePressed(gcn::MouseEvent &event) const int y = event.getY(); // Handle close button - if (mCloseButton) + if (mCloseButton && mSkin) { Image *img = mSkin->getCloseImage(); if (img) @@ -464,7 +476,7 @@ void Window::mousePressed(gcn::MouseEvent &event) } // Handle sticky button - if (mStickyButton) + if (mStickyButton && mSkin) { Image *button = mSkin->getStickyImage(mSticky); if (button) diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index b9f65dceb..510a68323 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -65,7 +65,7 @@ class Window : public gcn::Window, gcn::WidgetListener * @param skin The location where the window's skin XML can be found. */ Window(const std::string &caption = "Window", bool modal = false, - Window *parent = NULL, const std::string &skin = "window.xml"); + Window *parent = NULL, std::string skin = ""); /** * Destructor. Deletes all the added widgets. diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index 7e2afbaa3..b4f697ba3 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -74,7 +74,7 @@ class WorldListModel : public gcn::ListModel }; WorldSelectDialog::WorldSelectDialog(Worlds worlds): - Window(_("Select World")) + Window(_("Select World"), false, 0, "world.xml") { mWorldListModel = new WorldListModel(worlds); mWorldList = new ListBox(mWorldListModel); -- cgit v1.2.3-60-g2f50