From 7ec8cec84e27c3460c6d51b3c58e0644de247102 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 5 Sep 2011 16:47:19 +0300 Subject: Restore visible state for some windows after restart. --- src/gui/botcheckerwindow.cpp | 1 + src/gui/killstats.cpp | 1 + src/gui/whoisonline.cpp | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/botcheckerwindow.cpp b/src/gui/botcheckerwindow.cpp index 7c0339ead..8bc0d892e 100644 --- a/src/gui/botcheckerwindow.cpp +++ b/src/gui/botcheckerwindow.cpp @@ -269,6 +269,7 @@ BotCheckerWindow::BotCheckerWindow(): int w = 500; int h = 250; + setSaveVisible(true); mLastUpdateTime = 0; mNeedUpdate = false; diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index b9ce7c2a7..7d0a9fe11 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -55,6 +55,7 @@ KillStats::KillStats(): setWindowName("Kill stats"); setCloseButton(true); setResizable(true); + setSaveVisible(true); setStickyButtonLock(true); setDefaultSize(250, 250, 350, 300); diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 1e9f686e4..ff855ed05 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -95,9 +95,11 @@ WhoIsOnline::WhoIsOnline(): const int w = 200; setDefaultSize(w, h, ImageRect::CENTER); // setContentSize(w, h); + setVisible(false); setCloseButton(true); setResizable(true); setStickyButtonLock(true); + setSaveVisible(true); mUpdateButton = new Button(_("Update"), "update", this); mUpdateButton->setEnabled(false); @@ -563,4 +565,4 @@ void WhoIsOnline::optionChanged(const std::string &name) { if (name == "updateOnlineList") mUpdateOnlineList = config.getBoolValue("updateOnlineList"); -} \ No newline at end of file +} -- cgit v1.2.3-60-g2f50 From 83117a93393329cc61a76614e4ca5686efa56154 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 5 Sep 2011 17:56:24 +0300 Subject: Add option to enable/disable lazy scrolling. --- src/defaults.cpp | 1 + src/gui/setup_other.cpp | 3 ++ src/gui/viewport.cpp | 106 ++++++++++++++++++++++++++++-------------------- src/gui/viewport.h | 1 + 4 files changed, 67 insertions(+), 44 deletions(-) (limited to 'src/gui') diff --git a/src/defaults.cpp b/src/defaults.cpp index 7c0d8148c..4a82a83a9 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -217,6 +217,7 @@ DefaultsData* getConfigDefaults() AddDEF(configData, "enableReorderSprites", true); AddDEF(configData, "showip", false); AddDEF(configData, "seflMouseHeal", true); + AddDEF(configData, "enableLazyScrolling", true); return configData; } diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp index 1cad4c594..36c6f0436 100644 --- a/src/gui/setup_other.cpp +++ b/src/gui/setup_other.cpp @@ -84,6 +84,9 @@ Setup_Other::Setup_Other() new SetupItemCheckBox(_("Draw hotkeys on map"), "", "drawHotKeys", this, "drawHotKeysEvent"); + new SetupItemCheckBox(_("Enable lazy scrolling"), "", "enableLazyScrolling", + this, "enableLazyScrollingEvent"); + new SetupItemLabel(_("Moving"), "", this); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index b6e09c011..073697459 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -80,11 +80,13 @@ Viewport::Viewport(): mScrollCenterOffsetY = config.getIntValue("ScrollCenterOffsetY"); mShowBeingPopup = config.getBoolValue("showBeingPopup"); mSelfMouseHeal = config.getBoolValue("selfMouseHeal"); + mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling"); config.addListener("ScrollLaziness", this); config.addListener("ScrollRadius", this); config.addListener("showBeingPopup", this); config.addListener("selfMouseHeal", this); + config.addListener("enableLazyScrolling", this); mPopupMenu = new PopupMenu; mBeingPopup = new BeingPopup; @@ -99,6 +101,7 @@ Viewport::~Viewport() config.removeListener("ScrollRadius", this); config.removeListener("showBeingPopup", this); config.removeListener("selfMouseHeal", this); + config.removeListener("enableLazyScrolling", this); delete mPopupMenu; mPopupMenu = 0; @@ -150,59 +153,67 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) int cnt = 0; - // Apply lazy scrolling - while (lastTick < tick_time && cnt < 32) + if (mEnableLazyScrolling) { - if (player_x > static_cast(mPixelViewX) + mScrollRadius) + // Apply lazy scrolling + while (lastTick < tick_time && cnt < 32) { - mPixelViewX += static_cast(player_x - - static_cast(mPixelViewX) - mScrollRadius) / + if (player_x > static_cast(mPixelViewX) + mScrollRadius) + { + mPixelViewX += static_cast(player_x + - static_cast(mPixelViewX) - mScrollRadius) / + static_cast(mScrollLaziness); + } + if (player_x < static_cast(mPixelViewX) - mScrollRadius) + { + mPixelViewX += static_cast(player_x + - static_cast(mPixelViewX) + mScrollRadius) / + static_cast(mScrollLaziness); + } + if (player_y > static_cast(mPixelViewY) + mScrollRadius) + { + mPixelViewY += static_cast(player_y + - static_cast(mPixelViewY) - mScrollRadius) / static_cast(mScrollLaziness); - } - if (player_x < static_cast(mPixelViewX) - mScrollRadius) - { - mPixelViewX += static_cast(player_x - - static_cast(mPixelViewX) + mScrollRadius) / + } + if (player_y < static_cast(mPixelViewY) - mScrollRadius) + { + mPixelViewY += static_cast(player_y + - static_cast(mPixelViewY) + mScrollRadius) / static_cast(mScrollLaziness); + } + lastTick ++; + cnt ++; } - if (player_y > static_cast(mPixelViewY) + mScrollRadius) - { - mPixelViewY += static_cast(player_y - - static_cast(mPixelViewY) - mScrollRadius) / - static_cast(mScrollLaziness); - } - if (player_y < static_cast(mPixelViewY) - mScrollRadius) - { - mPixelViewY += static_cast(player_y - - static_cast(mPixelViewY) + mScrollRadius) / - static_cast(mScrollLaziness); - } - lastTick ++; - cnt ++; - } - // Auto center when player is off screen - if (cnt > 30 || player_x - static_cast(mPixelViewX) - > graphics->mWidth / 2 || static_cast(mPixelViewX) - - player_x > graphics->mWidth / 2 || static_cast(mPixelViewY) - - player_y > graphics->getHeight() / 2 || player_y - - static_cast(mPixelViewY) > graphics->getHeight() / 2) - { - if (player_x <= 0 || player_y <= 0) + // Auto center when player is off screen + if (cnt > 30 || player_x - static_cast(mPixelViewX) + > graphics->mWidth / 2 || static_cast(mPixelViewX) + - player_x > graphics->mWidth / 2 || static_cast(mPixelViewY) + - player_y > graphics->getHeight() / 2 || player_y + - static_cast(mPixelViewY) > graphics->getHeight() / 2) { - if (debugChatTab) - debugChatTab->chatLog("incorrect player position!"); - logger->log("incorrect player position: %d, %d, %d, %d", - player_x, player_y, (int)mPixelViewX, (int)mPixelViewY); - if (player_node) + if (player_x <= 0 || player_y <= 0) { - logger->log("tile position: %d, %d", - player_node->getTileX(), player_node->getTileY()); + if (debugChatTab) + debugChatTab->chatLog("incorrect player position!"); + logger->log("incorrect player position: %d, %d, %d, %d", + player_x, player_y, (int)mPixelViewX, (int)mPixelViewY); + if (player_node) + { + logger->log("tile position: %d, %d", + player_node->getTileX(), player_node->getTileY()); + } } + mPixelViewX = static_cast(player_x); + mPixelViewY = static_cast(player_y); } + } + else + { mPixelViewX = static_cast(player_x); mPixelViewY = static_cast(player_y); - }; + } // Don't move camera so that the end of the map is on screen const int viewXmax = @@ -693,9 +704,16 @@ void Viewport::closePopupMenu() void Viewport::optionChanged(const std::string &name A_UNUSED) { - mScrollLaziness = config.getIntValue("ScrollLaziness"); - mScrollRadius = config.getIntValue("ScrollRadius"); - mShowBeingPopup = config.getBoolValue("showBeingPopup"); + if (name == "ScrollLaziness") + mScrollLaziness = config.getIntValue("ScrollLaziness"); + else if (name == "ScrollRadius") + mScrollRadius = config.getIntValue("ScrollRadius"); + else if (name == "showBeingPopup") + mShowBeingPopup = config.getBoolValue("showBeingPopup"); + else if (name == "selfMouseHeal") + mSelfMouseHeal = config.getBoolValue("selfMouseHeal"); + else if (name == "enableLazyScrolling") + mEnableLazyScrolling = config.getBoolValue("enableLazyScrolling"); } void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED) diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 50c81aff4..8823928a3 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -286,6 +286,7 @@ class Viewport : public WindowContainer, public gcn::MouseListener, int mScrollLaziness; bool mShowBeingPopup; bool mSelfMouseHeal; + bool mEnableLazyScrolling; int mScrollCenterOffsetX; int mScrollCenterOffsetY; int mMouseX; /**< Current mouse position in pixels. */ -- cgit v1.2.3-60-g2f50 From 0c0ba36a78c155a120ed4b4ad7791341d93d5dd8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 5 Sep 2011 19:06:48 +0300 Subject: Add scroll laziness configuration parameters to misc setup tab. --- src/gui/setup_other.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_other.cpp b/src/gui/setup_other.cpp index 36c6f0436..23fb5c086 100644 --- a/src/gui/setup_other.cpp +++ b/src/gui/setup_other.cpp @@ -84,8 +84,14 @@ Setup_Other::Setup_Other() new SetupItemCheckBox(_("Draw hotkeys on map"), "", "drawHotKeys", this, "drawHotKeysEvent"); - new SetupItemCheckBox(_("Enable lazy scrolling"), "", "enableLazyScrolling", - this, "enableLazyScrollingEvent"); + new SetupItemCheckBox(_("Enable lazy scrolling"), "", + "enableLazyScrolling", this, "enableLazyScrollingEvent"); + + new SetupItemIntTextField(_("Scroll laziness"), "", "ScrollLaziness", + this, "ScrollLazinessEvent", 1, 160); + + new SetupItemIntTextField(_("Scroll radius"), "", "ScrollRadius", + this, "ScrollRadiusEvent", 0, 32); new SetupItemLabel(_("Moving"), "", this); -- cgit v1.2.3-60-g2f50 From 675d59fd09991ccadd3becdda86ec72833fc3db7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 6 Sep 2011 02:34:45 +0300 Subject: Move setup option "show being transparency" to correct group. --- src/gui/setup_perfomance.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_perfomance.cpp b/src/gui/setup_perfomance.cpp index dfb119b91..dd634d1f3 100644 --- a/src/gui/setup_perfomance.cpp +++ b/src/gui/setup_perfomance.cpp @@ -58,9 +58,6 @@ Setup_Perfomance::Setup_Perfomance() new SetupItemCheckBox(_("Auto adjust perfomance"), "", "adjustPerfomance", this, "adjustPerfomanceEvent"); - new SetupItemCheckBox(_("Show beings transparency"), "", - "beingopacity", this, "beingopacityEvent"); - new SetupItemCheckBox(_("Hw acceleration"), "", "hwaccel", this, "hwaccelEvent"); @@ -77,6 +74,9 @@ Setup_Perfomance::Setup_Perfomance() "be very slow)"), "Can slow down drawing", "enableAlphaFix", this, "enableAlphaFixEvent"); + new SetupItemCheckBox(_("Show beings transparency"), "", + "beingopacity", this, "beingopacityEvent"); + new SetupItemCheckBox(_("Enable reorder sprites."), "", "enableReorderSprites", this, "enableReorderSpritesEvent"); -- cgit v1.2.3-60-g2f50 From 64f4e1132355eaac4f5594bee516b56adb2ad083 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 6 Sep 2011 19:54:39 +0300 Subject: Add ability to move by clicking on minimap. --- src/gui/minimap.cpp | 67 +++++++++++++++++++++++++++++++++++------------------ src/gui/minimap.h | 4 ++++ 2 files changed, 48 insertions(+), 23 deletions(-) (limited to 'src/gui') diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index c3a4417f6..a16da2b65 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -51,7 +51,9 @@ Minimap::Minimap(): mMapImage(0), mWidthProportion(0.5), mHeightProportion(0.5), - mCustomMapImage(false) + mCustomMapImage(false), + mMapOriginX(0), + mMapOriginY(0) { setWindowName("Minimap"); mShow = config.getValueBool(getWindowName() + "Show", true); @@ -215,8 +217,11 @@ void Minimap::draw(gcn::Graphics *graphics) graphics->pushClipArea(a); - int mapOriginX = 0; - int mapOriginY = 0; + if (!actorSpriteManager) + return; + + mMapOriginX = 0; + mMapOriginY = 0; if (mMapImage) { @@ -224,33 +229,30 @@ void Minimap::draw(gcn::Graphics *graphics) mMapImage->mBounds.h > a.height) { const Vector &p = player_node->getPosition(); - mapOriginX = ((a.width) / 2) - static_cast((p.x + mMapOriginX = ((a.width) / 2) - static_cast((p.x + viewport->getCameraRelativeX()) * static_cast( mWidthProportion)) / 32; - mapOriginY = ((a.height) / 2) - static_cast((p.y + mMapOriginY = ((a.height) / 2) - static_cast((p.y + viewport->getCameraRelativeX()) * static_cast( mHeightProportion)) / 32; const int minOriginX = a.width - mMapImage->mBounds.w; const int minOriginY = a.height - mMapImage->mBounds.h; - if (mapOriginX < minOriginX) - mapOriginX = minOriginX; - if (mapOriginY < minOriginY) - mapOriginY = minOriginY; - if (mapOriginX > 0) - mapOriginX = 0; - if (mapOriginY > 0) - mapOriginY = 0; + if (mMapOriginX < minOriginX) + mMapOriginX = minOriginX; + if (mMapOriginY < minOriginY) + mMapOriginY = minOriginY; + if (mMapOriginX > 0) + mMapOriginX = 0; + if (mMapOriginY > 0) + mMapOriginY = 0; } - graph->drawImage(mMapImage, mapOriginX, mapOriginY); + graph->drawImage(mMapImage, mMapOriginX, mMapOriginY); } - if (!actorSpriteManager) - return; - const ActorSprites &actors = actorSpriteManager->getAll(); for (ActorSpritesConstIterator it = actors.begin(), it_end = actors.end(); @@ -313,9 +315,9 @@ void Minimap::draw(gcn::Graphics *graphics) graphics->fillRectangle(gcn::Rectangle( static_cast(pos.x * mWidthProportion) / 32 - + mapOriginX - offsetWidth, + + mMapOriginX - offsetWidth, static_cast(pos.y * mHeightProportion) / 32 - + mapOriginY - offsetHeight, + + mMapOriginY - offsetHeight, dotSize, dotSize)); } @@ -351,9 +353,9 @@ void Minimap::draw(gcn::Graphics *graphics) graphics->fillRectangle(gcn::Rectangle( static_cast(member->getX() - * mWidthProportion) + mapOriginX - offsetWidth, + * mWidthProportion) + mMapOriginX - offsetWidth, static_cast(member->getY() - * mHeightProportion) + mapOriginY - offsetHeight, + * mHeightProportion) + mMapOriginY - offsetHeight, 2, 2)); } ++ it; @@ -367,10 +369,10 @@ void Minimap::draw(gcn::Graphics *graphics) int x = static_cast((pos.x - (graph->getWidth() / 2) + viewport->getCameraRelativeX()) - * mWidthProportion) / 32 + mapOriginX; + * mWidthProportion) / 32 + mMapOriginX; int y = static_cast((pos.y - (graph->getHeight() / 2) + viewport->getCameraRelativeY()) - * mHeightProportion) / 32 + mapOriginY; + * mHeightProportion) / 32 + mMapOriginY; const int w = static_cast(static_cast( graph->getWidth()) * mWidthProportion / 32); @@ -396,3 +398,22 @@ void Minimap::draw(gcn::Graphics *graphics) graphics->drawRectangle(gcn::Rectangle(x, y, w, h)); graphics->popClipArea(); } + +void Minimap::mouseReleased(gcn::MouseEvent &event) +{ + gcn::Window::mouseReleased(event); + + if (!player_node) + return; + + if (event.getButton() == gcn::MouseEvent::LEFT) + { + const gcn::Rectangle a = getChildrenArea(); + const int x = event.getX() - a.x; + const int y = event.getY() - a.y; + + player_node->navigateTo((x - mMapOriginX + mWidthProportion) + / mWidthProportion, (y - mMapOriginY + mHeightProportion) + / mHeightProportion); + } +} diff --git a/src/gui/minimap.h b/src/gui/minimap.h index 33e0f14ee..86996f51c 100644 --- a/src/gui/minimap.h +++ b/src/gui/minimap.h @@ -58,12 +58,16 @@ class Minimap : public Window */ void draw(gcn::Graphics *graphics); + void mouseReleased(gcn::MouseEvent &event); + private: Image *mMapImage; float mWidthProportion; float mHeightProportion; static bool mShow; bool mCustomMapImage; + int mMapOriginX; + int mMapOriginY; }; extern Minimap *minimap; -- cgit v1.2.3-60-g2f50 From 3f84fc198131ff706e18c56f612e38ff147b0005 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 24 Aug 2011 20:13:14 +0300 Subject: Add support for copy text to clipboard (Ctrl+C). In X enviroments used xsel to copy string to clipboard. In windows used native clipboard api. MacOSX not supported. --- src/gui/widgets/textfield.cpp | 10 +++++ src/gui/widgets/textfield.h | 2 + src/utils/copynpaste.cpp | 87 +++++++++++++++++++++++++++++++++++++++++++ src/utils/copynpaste.h | 1 + 4 files changed, 100 insertions(+) (limited to 'src/gui') diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 2729e5407..d9f5bed9a 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -309,6 +309,10 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) } break; + case 3: + handleCopy(); + break; + case 22: // Control code 22, SYNCHRONOUS IDLE, sent on Ctrl+v // hack to prevent paste key sticking if (mLastEventPaste && mLastEventPaste > cur_time) @@ -348,3 +352,9 @@ void TextField::handlePaste() setCaretPosition(static_cast(caretPos)); } } + +void TextField::handleCopy() +{ + std::string text = getText(); + sendBuffer(text); +} diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 79197bb7a..79790d83a 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -99,6 +99,8 @@ class TextField : public gcn::TextField private: void handlePaste(); + void handleCopy(); + static int instances; static float mAlpha; static ImageRect skin; diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index 5b1ccb5bc..6d1c675d3 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -1,6 +1,7 @@ /* * Retrieve string pasted depending on OS mechanisms. * Copyright (C) 2001-2010 Wormux Team + * Copyright (C) 2011 ManaPlus Developers * * This file is part of The ManaPlus Client. * @@ -90,6 +91,40 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) CloseClipboard(); return ret; } + +bool sendBuffer(std::string& text) +{ + int wCharsLen = MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, NULL, 0); + if (!wCharsLen) + return false; + + HANDLE h; + WCHAR *out; + h = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, wCharsLen * sizeof(WCHAR)); + out = (WCHAR*)GlobalLock(h); + + MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, out, wCharsLen); + + if (!OpenClipboard(0)) + { + GlobalUnlock(h); + GlobalFree(h); + return false; + } + GlobalUnlock(h); + EmptyClipboard(); + if (!SetClipboardData(CF_UNICODETEXT, out)) + { + GlobalFree(h); + CloseClipboard(); + return false; + } + GlobalFree(h); + CloseClipboard(); + + return true; +} + #elif defined(__APPLE__) #ifdef Status @@ -243,6 +278,11 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) } } +bool sendBuffer(std::string& text) +{ + return false; +} + #elif USE_X11 static char* getSelection2(Display *dpy, Window us, Atom selection, Atom request_target) @@ -362,9 +402,56 @@ bool retrieveBuffer(std::string& text, std::string::size_type& pos) } return false; } + +bool sendBuffer(std::string& text) +{ + pid_t pid; + int fd[2]; + + if (pipe(fd)) + return false; + + if ((pid = fork()) == -1) + { // fork error + return false; + } + else if (!pid) + { // child + close(fd[1]); + + if (fd[0] != STDIN_FILENO) + { + if (dup2(fd[0], STDIN_FILENO) != STDIN_FILENO) + { + close(fd[0]); + exit(1); + } + close(fd[0]); + } + execl("/usr/bin/xsel", "xsel", "-i", (char *)0); + exit(1); + } + + // parent + close(fd[0]); + const int len = strlen(text.c_str()); + if (write(fd[1], text.c_str(), len) != len) + { + close(fd[1]); + return false; + } + close(fd[1]); + return true; +} + #else bool retrieveBuffer(std::string&, std::string::size_type&) { return false; } + +bool sendBuffer(std::string& text) +{ + return false; +} #endif diff --git a/src/utils/copynpaste.h b/src/utils/copynpaste.h index d09105139..03596d5d1 100644 --- a/src/utils/copynpaste.h +++ b/src/utils/copynpaste.h @@ -31,3 +31,4 @@ */ bool retrieveBuffer(std::string& text, std::string::size_type& pos); +bool sendBuffer(std::string& text); -- cgit v1.2.3-60-g2f50 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/actorsprite.cpp | 2 +- src/actorspritemanager.cpp | 34 +++++++++++++++---------------- src/being.cpp | 12 +++++------ src/compoundsprite.cpp | 6 +++--- src/effectmanager.cpp | 4 ++-- src/event.cpp | 7 ++++--- src/graphics.cpp | 6 +++--- src/gui/buydialog.cpp | 4 ++-- src/gui/buyselldialog.cpp | 4 ++-- src/gui/charselectdialog.cpp | 4 +++- src/gui/chatwindow.cpp | 14 ++++++------- src/gui/gui.cpp | 2 +- src/gui/ministatuswindow.cpp | 6 +++--- src/gui/npcdialog.cpp | 16 +++++++-------- src/gui/npcpostdialog.cpp | 4 ++-- src/gui/palette.cpp | 4 ++-- src/gui/popupmenu.cpp | 10 +++++----- src/gui/quitdialog.cpp | 2 +- src/gui/selldialog.cpp | 4 ++-- src/gui/setup.cpp | 13 +++++++----- src/gui/setup_video.cpp | 4 ++-- src/gui/shopwindow.cpp | 10 +++++----- src/gui/skilldialog.cpp | 12 +++++++---- src/gui/socialwindow.cpp | 14 ++++++------- src/gui/specialswindow.cpp | 5 +++-- src/gui/statuswindow.cpp | 12 +++++------ src/gui/userpalette.cpp | 2 +- src/gui/widgets/chattab.cpp | 2 +- src/gui/widgets/flowcontainer.cpp | 2 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/layout.cpp | 10 ++++++---- src/gui/widgets/setuptabscroll.cpp | 18 +++++++++++------ src/gui/widgets/vertcontainer.cpp | 5 +++-- src/gui/widgets/window.cpp | 2 +- src/gui/windowmenu.cpp | 2 +- src/guichan/focushandler.cpp | 6 ++++-- src/guichan/gui.cpp | 8 ++++---- src/guichan/widget.cpp | 2 +- src/guichan/widgets/window.cpp | 2 +- src/guild.cpp | 6 +++--- src/guildmanager.cpp | 4 ++-- src/localplayer.cpp | 14 ++++++------- src/map.cpp | 41 ++++++++++++++++++++------------------ src/net/ea/inventoryhandler.cpp | 4 ++-- src/net/manaserv/network.cpp | 6 +----- src/net/manaserv/npchandler.cpp | 4 +--- src/net/tmwa/npchandler.cpp | 2 +- src/openglgraphics.cpp | 8 ++++---- src/particlecontainer.cpp | 2 +- src/particleemitter.cpp | 6 +++--- src/party.cpp | 7 ++++--- src/playerinfo.cpp | 5 ++++- src/resources/image.cpp | 4 ++-- src/resources/itemdb.cpp | 2 +- src/resources/iteminfo.cpp | 6 ++++-- src/resources/mapreader.cpp | 2 +- src/resources/specialdb.cpp | 2 +- src/resources/spritedef.cpp | 2 +- src/resources/wallpaper.cpp | 2 +- src/spellmanager.cpp | 4 ++-- src/textmanager.cpp | 7 ++++--- src/utils/stringutils.cpp | 11 +++++----- 62 files changed, 228 insertions(+), 201 deletions(-) (limited to 'src/gui') diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index 2b133eca5..2cc138047 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -113,7 +113,7 @@ void ActorSprite::logic() if (mMustResetParticles) { mMustResetParticles = false; - for (std::set::iterator it = mStatusEffects.begin(); + for (std::set::const_iterator it = mStatusEffects.begin(); it != mStatusEffects.end(); ++it) { const StatusEffect *effect diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 5f28f237c..edd1db2aa 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -105,9 +105,9 @@ class SortBeingFunctor { int w1 = defaultPriorityIndex; int w2 = defaultPriorityIndex; - std::map::iterator it1 + std::map::const_iterator it1 = priorityBeings->find(being1->getName()); - std::map::iterator it2 + std::map::const_iterator it2 = priorityBeings->find(being2->getName()); if (it1 != priorityBeings->end()) w1 = (*it1).second; @@ -144,9 +144,9 @@ class SortBeingFunctor { int w1 = defaultAttackIndex; int w2 = defaultAttackIndex; - std::map::iterator it1 + std::map::const_iterator it1 = attackBeings->find(being1->getName()); - std::map::iterator it2 + std::map::const_iterator it2 = attackBeings->find(being2->getName()); if (it1 != attackBeings->end()) w1 = (*it1).second; @@ -327,9 +327,9 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y, return being; } else if (!noBeing && (being->getPixelX() - 32 <= x) && - (being->getPixelX() + 32 > x) && - (being->getPixelY() - 64 <= y) && - (being->getPixelY() + 16 > y)) + (being->getPixelX() + 32 > x) && + (being->getPixelY() - 64 <= y) && + (being->getPixelY() + 16 > y)) { if (tempBeing) noBeing = true; @@ -705,7 +705,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, beingSorter.priorityBeings = &priorityMobsMap; if (ignoreAttackMobs.find("") != ignoreAttackMobs.end()) ignoreDefault = true; - std::map::iterator itr = attackMobsMap.find(""); + std::map::const_iterator itr = attackMobsMap.find(""); if (itr != attackMobsMap.end()) defaultAttackIndex = (*itr).second; itr = priorityMobsMap.find(""); @@ -855,7 +855,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, int w2 = defaultPriorityIndex; if (closestBeing) { - std::map::iterator it2 + std::map::const_iterator it2 = priorityMobsMap.find(being->getName()); if (it2 != priorityMobsMap.end()) w2 = (*it2).second; @@ -880,7 +880,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, { dist = d; closestBeing = being; - std::map::iterator it1 + std::map::const_iterator it1 = priorityMobsMap.find(being->getName()); if (it1 != priorityMobsMap.end()) index = (*it1).second; @@ -1054,7 +1054,7 @@ void ActorSpriteManager::printBeingsToChat(ActorSprites beings, debugChatTab->chatLog("---------------------------------------"); debugChatTab->chatLog(header); - std::set::iterator it; + std::set::const_iterator it; for (it = beings.begin(); it != beings.end(); ++it) { if ((*it)->getType() == ActorSprite::FLOOR_ITEM) @@ -1079,7 +1079,7 @@ void ActorSpriteManager::printBeingsToChat(std::vector beings, debugChatTab->chatLog("---------------------------------------"); debugChatTab->chatLog(header); - std::vector::iterator i; + std::vector::const_iterator i; for (i = beings.begin(); i != beings.end(); ++i) { const Being *being = *i; @@ -1298,7 +1298,7 @@ void ActorSpriteManager::addIgnoreAttackMob(std::string name) void ActorSpriteManager::rebuildPriorityAttackMobs() { mPriorityAttackMobsMap.clear(); - std::list::iterator i = mPriorityAttackMobs.begin(); + std::list::const_iterator i = mPriorityAttackMobs.begin(); int cnt = 0; while (i != mPriorityAttackMobs.end()) { @@ -1311,7 +1311,7 @@ void ActorSpriteManager::rebuildPriorityAttackMobs() void ActorSpriteManager::rebuildAttackMobs() { mAttackMobsMap.clear(); - std::list::iterator i = mAttackMobs.begin(); + std::list::const_iterator i = mAttackMobs.begin(); int cnt = 0; while (i != mAttackMobs.end()) { @@ -1323,7 +1323,7 @@ void ActorSpriteManager::rebuildAttackMobs() int ActorSpriteManager::getPriorityAttackMobIndex(std::string name) { - std::map::iterator i = mPriorityAttackMobsMap.find(name); + std::map::const_iterator i = mPriorityAttackMobsMap.find(name); if (i == mPriorityAttackMobsMap.end()) return -1; @@ -1332,7 +1332,7 @@ int ActorSpriteManager::getPriorityAttackMobIndex(std::string name) int ActorSpriteManager::getAttackMobIndex(std::string name) { - std::map::iterator i = mAttackMobsMap.find(name); + std::map::const_iterator i = mAttackMobsMap.find(name); if (i == mAttackMobsMap.end()) return -1; @@ -1344,7 +1344,7 @@ void ActorSpriteManager::loadAttackList() bool empty = false; std::list list = unpackList( serverConfig.getValue("attackPriorityMobs", "")); - std::list::iterator i = list.begin(); + std::list::const_iterator i = list.begin(); while (i != list.end()) { if (*i == "") diff --git a/src/being.cpp b/src/being.cpp index 5a4bcd737..090e7d10d 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -2155,20 +2155,20 @@ void Being::recalcSpritesOrder() if (spriteToItems) { - SpriteToItemMap::iterator it; + SpriteToItemMap::const_iterator it; for (it = spriteToItems->begin(); it != spriteToItems->end(); ++it) { int removeSprite = it->first; - std::map &itemReplacer = it->second; + const std::map &itemReplacer = it->second; if (itemReplacer.empty()) { mSpriteHide[removeSprite] = 1; } else { - std::map::iterator repIt + std::map::const_iterator repIt = itemReplacer.find(mSpriteIDs[removeSprite]); if (repIt != itemReplacer.end()) { @@ -2188,7 +2188,7 @@ void Being::recalcSpritesOrder() if (info.mDrawBefore[dir] > 0) { int id2 = mSpriteIDs[info.mDrawBefore[dir]]; - std::map::iterator orderIt = itemSlotRemap.find(id2); + std::map::const_iterator orderIt = itemSlotRemap.find(id2); if (orderIt != itemSlotRemap.end()) { // logger->log("found duplicate (before)"); @@ -2211,7 +2211,7 @@ void Being::recalcSpritesOrder() else if (info.mDrawAfter[dir] > 0) { int id2 = mSpriteIDs[info.mDrawAfter[dir]]; - std::map::iterator orderIt = itemSlotRemap.find(id2); + std::map::const_iterator orderIt = itemSlotRemap.find(id2); if (orderIt != itemSlotRemap.end()) { // logger->log("found duplicate (after)"); @@ -2256,7 +2256,7 @@ void Being::recalcSpritesOrder() int idx1 = -1; // logger->log("item %d, id=%d", slot, id); int reorder = 0; - std::map::iterator orderIt = itemSlotRemap.find(id); + std::map::const_iterator orderIt = itemSlotRemap.find(id); if (orderIt != itemSlotRemap.end()) reorder = orderIt->second; diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index c6921b2e8..ceab9a149 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -461,7 +461,7 @@ void CompoundSprite::updateImages() const bool CompoundSprite::updateFromCache() const { ImagesCache::iterator it = imagesCache.begin(); - ImagesCache::iterator it_end = imagesCache.end(); + ImagesCache::const_iterator it_end = imagesCache.end(); // static int hits = 0; // static int miss = 0; @@ -491,8 +491,8 @@ bool CompoundSprite::updateFromCache() const bool fail(false); SpriteConstIterator it1 = begin(); SpriteConstIterator it1_end = end(); - VectorPointers::iterator it2 = ic->data.begin(); - VectorPointers::iterator it2_end = ic->data.end(); + VectorPointers::const_iterator it2 = ic->data.begin(); + VectorPointers::const_iterator it2_end = ic->data.end(); for (; it1 != it1_end && it2 != it2_end; ++ it1, ++ it2) { diff --git a/src/effectmanager.cpp b/src/effectmanager.cpp index 36e7aac16..55bf692cd 100644 --- a/src/effectmanager.cpp +++ b/src/effectmanager.cpp @@ -67,7 +67,7 @@ bool EffectManager::trigger(int id, Being* being) return false; bool rValue = false; - for (std::vector::iterator i = mEffects.begin(); + for (std::vector::const_iterator i = mEffects.begin(); i != mEffects.end(); ++i) { if ((*i).id == id) @@ -92,7 +92,7 @@ bool EffectManager::trigger(int id, int x, int y) return false; bool rValue = false; - for (std::vector::iterator i = mEffects.begin(); + for (std::vector::const_iterator i = mEffects.begin(); i != mEffects.end(); ++i) { if ((*i).id == id) diff --git a/src/event.cpp b/src/event.cpp index 8660f6b94..8ac9be189 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -107,17 +107,18 @@ double Event::getFloat(const std::string &key) const throw (BadEvent) void Event::trigger(Channels channel, const Event &event) { - ListenMap::iterator it = mBindings.find(channel); + ListenMap::const_iterator it = mBindings.find(channel); // Make sure something is listening if (it == mBindings.end()) return; // Loop though all listeners - ListenerSet::iterator lit = it->second.begin(); + ListenerSet::const_iterator lit = it->second.begin(); while (lit != it->second.end()) { - (*lit)->event(channel, event); + if (*lit) + (*lit)->event(channel, event); ++lit; } } diff --git a/src/graphics.cpp b/src/graphics.cpp index abd7341e2..0da8c1bd4 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -453,7 +453,7 @@ void Graphics::drawImagePattern2(GraphicsVertexes *vert, Image *img) // here not checking input parameters std::vector *arr = vert->getRectsSDL(); - std::vector::iterator it; + std::vector::const_iterator it; for (it = arr->begin(); it != arr->end(); ++it) SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mTarget, &(*it)->dst); @@ -603,8 +603,8 @@ void Graphics::drawTile(ImageVertexes *vert) { Image *img = vert->image; DoubleRects *rects = &vert->sdl; - DoubleRects::iterator it = rects->begin(); - DoubleRects::iterator it_end = rects->end(); + DoubleRects::const_iterator it = rects->begin(); + DoubleRects::const_iterator it_end = rects->end(); while (it != it_end) { SDL_LowerBlit(img->mSDLSurface, &(*it)->src, mTarget, &(*it)->dst); 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) { diff --git a/src/gui/buyselldialog.cpp b/src/gui/buyselldialog.cpp index 14dcb0bc1..dfe7a422a 100644 --- a/src/gui/buyselldialog.cpp +++ b/src/gui/buyselldialog.cpp @@ -129,8 +129,8 @@ void BuySellDialog::action(const gcn::ActionEvent &event) void BuySellDialog::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) { diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 1942ebaeb..75468d1ab 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -309,10 +309,12 @@ void CharSelectDialog::attemptCharacterSelect(int index) void CharSelectDialog::setCharacters(const Net::Characters &characters) { // Reset previous characters - std::vector::iterator iter, iter_end; + std::vector::const_iterator iter, iter_end; for (iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end(); iter != iter_end; ++iter) + { (*iter)->setCharacter(0); + } Net::Characters::const_iterator i, i_end = characters.end(); for (i = characters.begin(); i != i_end; ++i) diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 784fb812a..0f42fb1b6 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -754,7 +754,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) mChatHistoryIndex --; } - std::list::iterator it; + std::list::const_iterator it; unsigned int f = 0; for (it = tab->getRows().begin(); it != tab->getRows().end(); ++it, f++) @@ -788,7 +788,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) mChatHistoryIndex = 0; } - std::list::iterator it; + std::list::const_iterator it; unsigned int f = 0; for (it = tab->getRows().begin(); it != tab->getRows().end(); ++it, f++) @@ -1179,7 +1179,7 @@ void ChatWindow::autoComplete() std::string ChatWindow::autoComplete(std::vector &names, std::string partName) const { - std::vector::iterator i = names.begin(); + std::vector::const_iterator i = names.begin(); toLower(partName); std::string newName(""); @@ -1215,7 +1215,7 @@ std::string ChatWindow::autoComplete(std::string partName, History *words) if (!words) return ""; - Commands::iterator i = words->begin(); + Commands::const_iterator i = words->begin(); std::vector nameList; while (i != words->end()) @@ -1243,7 +1243,7 @@ void ChatWindow::moveTabRight(ChatTab *tab) std::string ChatWindow::autoCompleteHistory(std::string partName) { - History::iterator i = mHistory.begin(); + History::const_iterator i = mHistory.begin(); std::vector nameList; while (i != mHistory.end()) @@ -1344,7 +1344,7 @@ void ChatWindow::initTradeFilter() void ChatWindow::updateOnline(std::set &onlinePlayers) { - TabMap::iterator iter; + TabMap::const_iterator iter; const Party *party = 0; const Guild *guild = 0; if (player_node) @@ -1429,7 +1429,7 @@ void ChatWindow::loadState() void ChatWindow::saveState() { int num = 0; - TabMap::iterator iter; + TabMap::const_iterator iter; for (iter = mWhispers.begin(); iter != mWhispers.end() && num < 50; ++iter) { if (!iter->second) diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 7d38b1025..658d65769 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -394,7 +394,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, = widget->_getMouseListeners(); // Send the event to all mouse listeners of the widget. - for (std::list::iterator + for (std::list::const_iterator it = mouseListeners.begin(); it != mouseListeners.end(); ++ it) { diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index 08e3d0053..da39eb24c 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -134,7 +134,7 @@ MiniStatusWindow::~MiniStatusWindow() if (inv) inv->removeInventoyListener(this); - std::vector ::iterator it, it_end; + std::vector ::const_iterator it, it_end; for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) { ProgressBar *bar = *it; @@ -160,7 +160,7 @@ ProgressBar *MiniStatusWindow::createBar(float progress, int width, int height, void MiniStatusWindow::updateBars() { int x = 0; - std::vector ::iterator it, it_end; + std::vector ::const_iterator it, it_end; ProgressBar* lastBar = 0; for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) safeRemove(*it); @@ -439,7 +439,7 @@ void MiniStatusWindow::loadBars() void MiniStatusWindow::saveBars() { - std::vector ::iterator it, it_end; + std::vector ::const_iterator it, it_end; int i = 0; for (it = mBars.begin(), it_end = mBars.end(); it != it_end; ++it) diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 0db618d69..d941153b7 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -362,12 +362,12 @@ bool NpcDialog::isInputFocused() const bool NpcDialog::isAnyInputFocused() { - 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) { - if ((*it)->isInputFocused()) + if ((*it) && (*it)->isInputFocused()) return true; } @@ -430,12 +430,12 @@ NpcDialog *NpcDialog::getActive() if (instances.size() == 1) return instances.front(); - 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) { - if ((*it)->isFocused()) + if ((*it) && (*it)->isFocused()) return (*it); } @@ -444,8 +444,8 @@ NpcDialog *NpcDialog::getActive() void NpcDialog::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) { diff --git a/src/gui/npcpostdialog.cpp b/src/gui/npcpostdialog.cpp index 0ba4e44b6..72dd76aa3 100644 --- a/src/gui/npcpostdialog.cpp +++ b/src/gui/npcpostdialog.cpp @@ -123,8 +123,8 @@ void NpcPostDialog::setVisible(bool visible) void NpcPostDialog::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) (*it)->close(); diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index f5c074f6c..f3046264f 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -80,8 +80,8 @@ const gcn::Color& Palette::getColor(char c, bool &valid) void Palette::advanceGradients() { - Palettes::iterator it = mInstances.begin(); - Palettes::iterator it_end = mInstances.end(); + Palettes::const_iterator it = mInstances.begin(); + Palettes::const_iterator it_end = mInstances.end(); for (; it != it_end; ++it) (*it)->advanceGradient(); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 0eac0a4f9..a329488ce 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -360,7 +360,7 @@ void PopupMenu::showPopup(int x, int y, std::vector &beings) { mBrowserBox->clearRows(); mBrowserBox->addRow("Players"); - std::vector::iterator it, it_end; + std::vector::const_iterator it, it_end; for (it = beings.begin(), it_end = beings.end(); it != it_end; ++it) { Being *being = *it; @@ -804,8 +804,8 @@ void PopupMenu::showChangePos(int x, int y) if (guild) { PositionsMap map = guild->getPositions(); - PositionsMap::iterator itr = map.begin(); - PositionsMap::iterator itr_end = map.end(); + PositionsMap::const_iterator itr = map.begin(); + PositionsMap::const_iterator itr_end = map.end(); for (; itr != itr_end; ++itr) { mBrowserBox->addRow(strprintf("@@guild-pos-%d|%s@@", @@ -1872,7 +1872,7 @@ void PopupMenu::showPopup(int x, int y, Button *button) mBrowserBox->clearRows(); std::vector names = windowMenu->getButtons(); - std::vector ::iterator it, it_end; + std::vector ::const_iterator it, it_end; for (it = names.begin(), it_end = names.end(); it != it_end; ++ it) { Button *btn = dynamic_cast(*it); @@ -1907,7 +1907,7 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b) mBrowserBox->clearRows(); std::vector bars = miniStatusWindow->getBars(); - std::vector ::iterator it, it_end; + std::vector ::const_iterator it, it_end; for (it = bars.begin(), it_end = bars.end(); it != it_end; ++it) { ProgressBar *bar = *it; diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index 04f43fb88..96848f645 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -178,7 +178,7 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) if (dir != 0) { - std::vector::iterator it = mOptions.begin(); + std::vector::const_iterator it = mOptions.begin(); for (; it < mOptions.end(); ++it) { diff --git a/src/gui/selldialog.cpp b/src/gui/selldialog.cpp index d9030e3fb..5cbb4167e 100644 --- a/src/gui/selldialog.cpp +++ b/src/gui/selldialog.cpp @@ -346,8 +346,8 @@ void SellDialog::setVisible(bool visible) void SellDialog::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) (*it)->close(); diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 76e3936c2..113dd9081 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -103,7 +103,8 @@ Setup::Setup(): mTabs.push_back(new Setup_Theme); mTabs.push_back(new Setup_Other); - for (std::list::iterator i = mTabs.begin(), i_end = mTabs.end(); + for (std::list::const_iterator i = mTabs.begin(), + i_end = mTabs.end(); i != i_end; ++i) { SetupTab *tab = *i; @@ -162,10 +163,11 @@ void Setup::action(const gcn::ActionEvent &event) if (!statusWindow) return; - for (std::list::iterator it = mWindowsToReset.begin(); + for (std::list::const_iterator it = mWindowsToReset.begin(); it != mWindowsToReset.end(); ++it) { - (*it)->resetToDefaultSize(); + if (*it) + (*it)->resetToDefaultSize(); } } } @@ -177,10 +179,11 @@ void Setup::setInGame(bool inGame) void Setup::externalUpdate() { - for (std::list::iterator it = mTabs.begin(); + for (std::list::const_iterator it = mTabs.begin(); it != mTabs.end(); ++it) { - (*it)->externalUpdated(); + if (*it) + (*it)->externalUpdated(); } } diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 03b485097..0bfab1438 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -166,8 +166,8 @@ ModeListModel::ModeListModel() void ModeListModel::addCustomMode(std::string mode) { - std::vector::iterator it = mVideoModes.begin(); - std::vector::iterator it_end = mVideoModes.end(); + std::vector::const_iterator it = mVideoModes.begin(); + std::vector::const_iterator it_end = mVideoModes.end(); while (it != it_end) { if (*it == mode) diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 9aaf88bf3..5cf1573bb 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -395,7 +395,7 @@ void ShopWindow::saveList() } std::vector items = mBuyShopItems->items(); - std::vector::iterator it; + std::vector::const_iterator it; for (it = items.begin(); it != items.end(); ++it) { ShopItem *item = *(it); @@ -428,7 +428,7 @@ void ShopWindow::saveList() } } - std::map::iterator mapIt; + std::map::const_iterator mapIt; for (mapIt = mapItems.begin(); mapIt != mapItems.end(); ++mapIt) { ShopItem *buyItem = (*mapIt).second; @@ -468,7 +468,7 @@ void ShopWindow::announce(ShopItems *list, int mode) mSellAnnounceButton->setEnabled(false); std::vector items = list->items(); - std::vector::iterator it; + std::vector::const_iterator it; for (it = items.begin(); it != items.end(); ++it) { @@ -534,7 +534,7 @@ void ShopWindow::giveList(const std::string &nick, int mode) return; std::vector items = list->items(); - std::vector::iterator it; + std::vector::const_iterator it; for (it = items.begin(); it != items.end(); ++it) { @@ -780,7 +780,7 @@ bool ShopWindow::findShopItem(ShopItem *shopItem, int mode) return false; std::vector items; - std::vector::iterator it; + std::vector::const_iterator it; if (mode == SELL) { if (!mSellShopItems) diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index bf87e804d..c2685b476 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -321,7 +321,7 @@ void SkillDialog::action(const gcn::ActionEvent &event) std::string SkillDialog::update(int id) { - SkillMap::iterator i = mSkills.find(id); + SkillMap::const_iterator i = mSkills.find(id); if (i != mSkills.end()) { @@ -342,7 +342,9 @@ void SkillDialog::update() PlayerInfo::getAttribute(SKILL_POINTS))); mPointsLabel->adjustSize(); - for (SkillMap::iterator it = mSkills.begin(); it != mSkills.end(); ++it) + for (SkillMap::const_iterator it = mSkills.begin(); + it != mSkills.end(); + ++ it) { if ((*it).second && (*it).second->modifiable) (*it).second->update(); @@ -467,7 +469,7 @@ void SkillDialog::loadSkills(const std::string &file) bool SkillDialog::setModifiable(int id, bool modifiable) { - SkillMap::iterator it = mSkills.find(id); + SkillMap::const_iterator it = mSkills.find(id); if (it != mSkills.end()) { @@ -508,7 +510,9 @@ void SkillModel::updateVisibilities() { mVisibleSkills.clear(); - for (SkillList::iterator it = mSkills.begin(); it != mSkills.end(); ++it) + for (SkillList::const_iterator it = mSkills.begin(); + it != mSkills.end(); + ++ it) { if ((*it)->visible) mVisibleSkills.push_back((*it)); diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 749f26f85..7feca8bf4 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -232,7 +232,7 @@ public: mScroll = 0; } - void action(const gcn::ActionEvent &event) + void action(const gcn::ActionEvent &event A_UNUSED) { /* if (event.getId() == "do invite") @@ -528,7 +528,7 @@ public: return 0; Avatar *ava = 0; - std::vector::iterator i = avatars->begin(); + std::vector::const_iterator i = avatars->begin(); while (i != avatars->end()) { ava = (*i); @@ -562,7 +562,7 @@ public: if (!ava) break; - std::vector::iterator i = names.begin(); + std::vector::const_iterator i = names.begin(); while (i != names.end()) { if (ava->getName() == (*i) && (*i) != "") @@ -584,7 +584,7 @@ public: } } - std::vector::iterator i = names.begin(); + std::vector::const_iterator i = names.begin(); while (i != names.end()) { @@ -659,7 +659,7 @@ public: std::vector *avatars = mBeings->getMembers(); std::vector portals = map->getPortals(); - std::vector::iterator i = portals.begin(); + std::vector::const_iterator i = portals.begin(); SpecialLayer *specialLayer = map->getSpecialLayer(); std::vector::iterator ia = avatars->begin(); @@ -752,7 +752,7 @@ public: return; Avatar *ava = 0; - std::vector::iterator i = avatars->begin(); + std::vector::const_iterator i = avatars->begin(); while (i != avatars->end()) { ava = (*i); @@ -786,7 +786,7 @@ public: return 01; Avatar *ava = 0; - std::vector::iterator i = avatars->begin(); + std::vector::const_iterator i = avatars->begin(); unsigned num = 0; while (i != avatars->end()) { diff --git a/src/gui/specialswindow.cpp b/src/gui/specialswindow.cpp index 702c31718..64f61e3c3 100644 --- a/src/gui/specialswindow.cpp +++ b/src/gui/specialswindow.cpp @@ -134,10 +134,11 @@ void SpecialsWindow::draw(gcn::Graphics *graphics) unsigned int found = 0; // number of entries in specialData // which match mEntries - for (std::map::iterator i = specialData.begin(); + for (std::map::const_iterator i = specialData.begin(); i != specialData.end(); ++i) { - std::map::iterator e = mEntries.find(i->first); + std::map::const_iterator + e = mEntries.find(i->first); if (e == mEntries.end()) { // found a new special - abort update and rebuild from scratch diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index d1fde2dd1..a85f60133 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -311,7 +311,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, mCharacterPointsLabel->adjustSize(); // Update all attributes - for (Attrs::iterator it = mAttrs.begin(); + for (Attrs::const_iterator it = mAttrs.begin(); it != mAttrs.end(); ++it) { if (it->second) @@ -324,7 +324,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, _("Correction points: %d"), event.getInt("newValue"))); mCorrectionPointsLabel->adjustSize(); // Update all attributes - for (Attrs::iterator it = mAttrs.begin(); + for (Attrs::const_iterator it = mAttrs.begin(); it != mAttrs.end(); ++it) { if (it->second) @@ -392,7 +392,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, else { updateMPBar(mMpBar, true); - Attrs::iterator it = mAttrs.find(id); + Attrs::const_iterator it = mAttrs.find(id); if (it != mAttrs.end() && it->second) { if (it->second) @@ -404,7 +404,7 @@ void StatusWindow::event(Mana::Channels channel A_UNUSED, void StatusWindow::setPointsNeeded(int id, int needed) { - Attrs::iterator it = mAttrs.find(id); + Attrs::const_iterator it = mAttrs.find(id); if (it != mAttrs.end()) { @@ -909,8 +909,8 @@ void StatusWindow::action(const gcn::ActionEvent &event) if (event.getId() == "copy") { - Attrs::iterator it = mAttrs.begin(); - Attrs::iterator it_end = mAttrs.end(); + Attrs::const_iterator it = mAttrs.begin(); + Attrs::const_iterator it_end = mAttrs.end(); std::string str; while (it != it_end) { diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index eac9559ef..62fd03c70 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -172,7 +172,7 @@ UserPalette::UserPalette(): UserPalette::~UserPalette() { - for (Colors::iterator col = mColors.begin(), + for (Colors::const_iterator col = mColors.begin(), colEnd = mColors.end(); col != colEnd; ++col) { const std::string &configName = ColorTypeNames[col->type]; diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 81c0d277f..4f358c8e7 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -439,7 +439,7 @@ void ChatTab::loadFromLogFile(std::string name) { std::list list; chatLogger->loadLast(name, list, 5); - std::list::iterator i = list.begin(); + std::list::const_iterator i = list.begin(); while (i != list.end()) { std::string line = "##9" + *i; diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index 33e3790a0..0a64a7142 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -67,7 +67,7 @@ void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED) int i = 0; height = 0; - for (WidgetList::iterator it = mWidgets.begin(); + for (WidgetList::const_iterator it = mWidgets.begin(); it != mWidgets.end(); ++it) { int x = i % mGridWidth * mBoxWidth; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 91b674018..3d6d24868 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -479,7 +479,7 @@ void ItemContainer::updateMatrix() break; } - std::vector::iterator iter; + std::vector::const_iterator iter; for (iter = sortedItems.begin(); iter != sortedItems.end(); ++iter) { if (j >= mGridRows) diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index a14b416ce..52b92d0bc 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -86,12 +86,12 @@ void LayoutCell::computeSizes() if (mType != ARRAY) return; - std::vector< std::vector< LayoutCell * > >::iterator + std::vector >::const_iterator i = mArray->mCells.begin(); while (i != mArray->mCells.end()) { - std::vector< LayoutCell * >::iterator j = i->begin(); + std::vector ::const_iterator j = i->begin(); while (j != i->end()) { LayoutCell *cell = *j; @@ -113,7 +113,8 @@ LayoutArray::LayoutArray(): mSpacing(4) LayoutArray::~LayoutArray() { - std::vector< std::vector< LayoutCell * > >::iterator i = mCells.begin(); + std::vector >::iterator + i = mCells.begin(); while (i != mCells.end()) { std::vector< LayoutCell * >::iterator j = i->begin(); @@ -154,7 +155,8 @@ void LayoutArray::resizeGrid(int w, int h) if (extW) mSizes[0].resize(w, Layout::AUTO_DEF); - std::vector< std::vector< LayoutCell * > >::iterator i = mCells.begin(); + std::vector >::iterator + i = mCells.begin(); while (i != mCells.end()) { i->resize(w, 0); diff --git a/src/gui/widgets/setuptabscroll.cpp b/src/gui/widgets/setuptabscroll.cpp index 30bb66469..e9917b090 100644 --- a/src/gui/widgets/setuptabscroll.cpp +++ b/src/gui/widgets/setuptabscroll.cpp @@ -90,25 +90,31 @@ void SetupTabScroll::addControl(SetupItem *widget, std::string event) void SetupTabScroll::apply() { - std::map::iterator iter; + std::map::const_iterator iter; for (iter = mItems.begin(); iter != mItems.end(); ++ iter) - (*iter).second->apply((*iter).first); + { + if ((*iter).second) + (*iter).second->apply((*iter).first); + } } void SetupTabScroll::cancel() { - std::map::iterator iter; + std::map::const_iterator iter; for (iter = mItems.begin(); iter != mItems.end(); ++ iter) - (*iter).second->cancel((*iter).first); + { + if ((*iter).second) + (*iter).second->cancel((*iter).first); + } } void SetupTabScroll::externalUpdated() { - std::map::iterator iter; + std::map::const_iterator iter; for (iter = mItems.begin(); iter != mItems.end(); ++ iter) { SetupItem *widget = (*iter).second; - if (!widget->isMainConfig()) + if (widget && !widget->isMainConfig()) (*iter).second->externalUpdated((*iter).first); } } diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index ea6b4d520..5e79b7c19 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -73,8 +73,9 @@ void VertContainer::clear() void VertContainer::widgetResized(const gcn::Event &event A_UNUSED) { - for (std::vector::iterator it = mResizableWidgets.begin(); - it != mResizableWidgets.end(); ++ it) + for (std::vector::const_iterator + it = mResizableWidgets.begin(); + it != mResizableWidgets.end(); ++ it) { (*it)->setWidth(getWidth()); } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 4435496a7..9709f4c8a 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -373,7 +373,7 @@ void Window::widgetHidden(const gcn::Event &event A_UNUSED) if (!mFocusHandler) return; - for (it = mWidgets.begin(); it != mWidgets.end(); it++) + for (it = mWidgets.begin(); it != mWidgets.end(); ++ it) { if (mFocusHandler->isFocused(*it)) mFocusHandler->focusNone(); diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 0d81ba3a9..8431cece1 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -329,7 +329,7 @@ void WindowMenu::showButton(std::string name, bool isVisible) void WindowMenu::updateButtons() { int x = 0, h = 0; - std::vector ::iterator it, it_end; + std::vector ::const_iterator it, it_end; for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it) safeRemove(*it); for (it = mButtons.begin(), it_end = mButtons.end(); it != it_end; ++it) diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp index bb0378f59..367eed6b1 100644 --- a/src/guichan/focushandler.cpp +++ b/src/guichan/focushandler.cpp @@ -479,7 +479,8 @@ namespace gcn = sourceWidget->_getFocusListeners(); // Send the event to all focus listeners of the widget. - for (std::list::iterator it = focusListeners.begin(); + for (std::list::const_iterator + it = focusListeners.begin(); it != focusListeners.end(); ++ it) { @@ -495,7 +496,8 @@ namespace gcn = sourceWidget->_getFocusListeners(); // Send the event to all focus listeners of the widget. - for (std::list::iterator it = focusListeners.begin(); + for (std::list::const_iterator + it = focusListeners.begin(); it != focusListeners.end(); ++ it) { diff --git a/src/guichan/gui.cpp b/src/guichan/gui.cpp index bec4c875f..0c81182ea 100644 --- a/src/guichan/gui.cpp +++ b/src/guichan/gui.cpp @@ -421,7 +421,7 @@ namespace gcn // Check if the widget is present in the "widget with mouse" queue. bool widgetIsPresentInQueue = false; - std::deque::iterator iter; + std::deque::const_iterator iter; for (iter = mWidgetWithMouseQueue.begin(); iter != mWidgetWithMouseQueue.end(); ++ iter) @@ -697,7 +697,7 @@ namespace gcn = widget->_getMouseListeners(); // Send the event to all mouse listeners of the widget. - for (std::list::iterator + for (std::list::const_iterator it = mouseListeners.begin(); it != mouseListeners.end(); ++it) @@ -796,7 +796,7 @@ namespace gcn = widget->_getKeyListeners(); // Send the event to all key listeners of the source widget. - for (std::list::iterator + for (std::list::const_iterator it = keyListeners.begin(); it != keyListeners.end(); ++it) @@ -936,7 +936,7 @@ namespace gcn // Check if the widget is present in the "widget with mouse" queue. bool widgetIsPresentInQueue = false; - std::deque::iterator iter; + std::deque::const_iterator iter; for (iter = mWidgetWithMouseQueue.begin(); iter != mWidgetWithMouseQueue.end(); ++ iter) diff --git a/src/guichan/widget.cpp b/src/guichan/widget.cpp index e2ed26508..1b2b3295b 100644 --- a/src/guichan/widget.cpp +++ b/src/guichan/widget.cpp @@ -470,7 +470,7 @@ namespace gcn { mGlobalFont = font; - std::list::iterator iter; + std::list::const_iterator iter; for (iter = mWidgets.begin(); iter != mWidgets.end(); ++iter) { if ((*iter)->mCurrentFont == NULL) diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp index 7b04981c2..d0ba32f47 100644 --- a/src/guichan/widgets/window.cpp +++ b/src/guichan/widgets/window.cpp @@ -282,7 +282,7 @@ namespace gcn WidgetListConstIterator it; int w = 0, h = 0; - for (it = mWidgets.begin(); it != mWidgets.end(); it++) + for (it = mWidgets.begin(); it != mWidgets.end(); ++ it) { if ((*it)->getX() + (*it)->getWidth() > w) w = (*it)->getX() + (*it)->getWidth(); diff --git a/src/guild.cpp b/src/guild.cpp index 98e5bb519..234c7d32f 100644 --- a/src/guild.cpp +++ b/src/guild.cpp @@ -230,8 +230,8 @@ void Guild::removeFromMembers() if (!actorSpriteManager) return; - MemberList::iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + MemberList::const_iterator itr_end = mMembers.end(); while (itr != itr_end) { Being *b = actorSpriteManager->findBeing((*itr)->getID()); @@ -321,7 +321,7 @@ void Guild::addPos(int id, std::string name) Guild *Guild::getGuild(short id) { - GuildMap::iterator it = guilds.find(id); + GuildMap::const_iterator it = guilds.find(id); if (it != guilds.end()) return it->second; diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 1a8d5b433..13a837dfb 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -135,8 +135,8 @@ void GuildManager::updateList() if (guild) { guild->setServerGuild(false); - std::vector::iterator it = mTempList.begin(); - std::vector::iterator it_end = mTempList.end(); + std::vector::const_iterator it = mTempList.begin(); + std::vector::const_iterator it_end = mTempList.end(); int i = 0; while (it != it_end) { diff --git a/src/localplayer.cpp b/src/localplayer.cpp index c91532227..a68cd5ee8 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -902,11 +902,11 @@ void LocalPlayer::inviteToGuild(Being *being) // TODO: Allow user to choose which guild to invite being to // For now, just invite to the first guild you have permissions to invite with - std::map::iterator itr = mGuilds.begin(); - std::map::iterator itr_end = mGuilds.end(); + std::map::const_iterator itr = mGuilds.begin(); + std::map::const_iterator itr_end = mGuilds.end(); for (; itr != itr_end; ++itr) { - if (checkInviteRights(itr->second->getName())) + if (itr->second && checkInviteRights(itr->second->getName())) { Net::getGuildHandler()->invite(itr->second->getId(), being); return; @@ -1813,7 +1813,7 @@ void LocalPlayer::moveToHome() } else { - std::map::iterator iter = + std::map::const_iterator iter = mHomes.find(mMap->getProperty("_realfilename")); if (iter != mHomes.end()) @@ -2996,7 +2996,7 @@ void LocalPlayer::setHome() if (mAction == SIT) { - std::map::iterator iter = mHomes.find(key); + std::map::const_iterator iter = mHomes.find(key); if (iter != mHomes.end()) { @@ -3102,7 +3102,7 @@ void LocalPlayer::saveHomes() std::string homeStr; std::stringstream ss(homeStr); - for (std::map::iterator iter = mHomes.begin(); + for (std::map::const_iterator iter = mHomes.begin(); iter != mHomes.end(); ++iter ) { Vector pos = (*iter).second; @@ -3802,7 +3802,7 @@ void LocalPlayer::updateNavigateList() { if (mMap) { - std::map::iterator iter = + std::map::const_iterator iter = mHomes.find(mMap->getProperty("_realfilename")); if (iter != mHomes.end()) diff --git a/src/map.cpp b/src/map.cpp index 947bb8f09..e5b3632b6 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -104,10 +104,11 @@ void TileAnimation::update(int ticks) Image *img = mAnimation->getCurrentImage(); if (img != mLastImage) { - for (std::vector >::iterator i = + for (std::vector >::const_iterator i = mAffected.begin(); i != mAffected.end(); ++i) { - i->first->setTile(i->second, img); + if (i->first) + i->first->setTile(i->second, img); } mLastImage = img; } @@ -284,13 +285,13 @@ void MapLayer::updateSDL(Graphics *graphics, int startX, int startY, void MapLayer::drawSDL(Graphics *graphics) { - MapRows::iterator rit = mTempRows.begin(); - MapRows::iterator rit_end = mTempRows.end(); + MapRows::const_iterator rit = mTempRows.begin(); + MapRows::const_iterator rit_end = mTempRows.end(); while (rit != rit_end) { MepRowImages *images = &(*rit)->images; - MepRowImages::iterator iit = images->begin(); - MepRowImages::iterator iit_end = images->end(); + MepRowImages::const_iterator iit = images->begin(); + MepRowImages::const_iterator iit_end = images->end(); while (iit != iit_end) { graphics->drawTile(*iit); @@ -375,13 +376,13 @@ void MapLayer::updateOGL(Graphics *graphics, int startX, int startY, void MapLayer::drawOGL(Graphics *graphics) { - MapRows::iterator rit = mTempRows.begin(); - MapRows::iterator rit_end = mTempRows.end(); + MapRows::const_iterator rit = mTempRows.begin(); + MapRows::const_iterator rit_end = mTempRows.end(); while (rit != rit_end) { MepRowImages *images = &(*rit)->images; - MepRowImages::iterator iit = images->begin(); - MepRowImages::iterator iit_end = images->end(); + MepRowImages::const_iterator iit = images->begin(); + MepRowImages::const_iterator iit_end = images->end(); while (iit != iit_end) { graphics->drawTile(*iit); @@ -789,11 +790,12 @@ bool actorCompare(const Actor *a, const Actor *b) void Map::update(int ticks) { // Update animated tiles - for (std::map::iterator + for (std::map::const_iterator iAni = mTileAnimations.begin(); iAni != mTileAnimations.end(); ++iAni) { - iAni->second->update(ticks); + if (iAni->second) + iAni->second->update(ticks); } } @@ -1079,7 +1081,7 @@ void Map::updateAmbientLayers(float scrollX, float scrollY) float dy = scrollY - mLastAScrollY; int timePassed = get_elapsed_time(lastTick); - std::vector::iterator i; + std::vector::const_iterator i; for (i = mBackgrounds.begin(); i != mBackgrounds.end(); ++i) (*i)->update(timePassed, dx, dy); @@ -1116,10 +1118,11 @@ void Map::drawAmbientLayers(Graphics *graphics, LayerType type, } // Draw overlays - for (std::vector::iterator i = layers->begin(); + for (std::vector::const_iterator i = layers->begin(); i != layers->end(); ++i) { - (*i)->draw(graphics, graphics->mWidth, graphics->mHeight); + if (*i) + (*i)->draw(graphics, graphics->mWidth, graphics->mHeight); // Detail 1: only one overlay, higher: all overlays if (detail == 1) @@ -1598,7 +1601,7 @@ void Map::initializeParticleEffects(Particle *particleEngine) if (config.getBoolValue("particleeffects")) { - for (std::vector::iterator + for (std::vector::const_iterator i = particleEffects.begin(); i != particleEffects.end(); ++i) { @@ -1785,8 +1788,8 @@ void Map::updatePortalTile(const std::string &name, int type, MapItem *Map::findPortalXY(int x, int y) { - std::vector::iterator it; - std::vector::iterator it_end; + std::vector::const_iterator it; + std::vector::const_iterator it_end; for (it = mMapPortals.begin(), it_end = mMapPortals.end(); it != it_end; ++it) @@ -1849,7 +1852,7 @@ std::string Map::getObjectData(unsigned x, unsigned y, int type) if (!list) return ""; - std::vector::iterator it = list->objects.begin(); + std::vector::const_iterator it = list->objects.begin(); while (it != list->objects.end()) { if ((*it).type == type) diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 01000f8f1..1de681007 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -434,8 +434,8 @@ void InventoryHandler::processPlayerStorageStatus(Net::MessageIn &msg) if (!mStorage) mStorage = new Inventory(Inventory::STORAGE, size); - Ea::InventoryItems::iterator it = mInventoryItems.begin(); - Ea::InventoryItems::iterator it_end = mInventoryItems.end(); + Ea::InventoryItems::const_iterator it = mInventoryItems.begin(); + Ea::InventoryItems::const_iterator it_end = mInventoryItems.end(); for (; it != it_end; ++it) { mStorage->setItem((*it).slot, (*it).id, (*it).quantity, diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp index 53e83e4ec..b83bc5748 100644 --- a/src/net/manaserv/network.cpp +++ b/src/net/manaserv/network.cpp @@ -45,7 +45,7 @@ namespace ManaServ { typedef std::map MessageHandlers; -typedef MessageHandlers::iterator MessageHandlerIterator; +typedef MessageHandlers::const_iterator MessageHandlerIterator; static MessageHandlers mMessageHandlers; void initialize() @@ -96,17 +96,13 @@ Connection *getConnection() void registerHandler(MessageHandler *handler) { for (const Uint16 *i = handler->handledMessages; *i; i++) - { mMessageHandlers[*i] = handler; - } } void unregisterHandler(MessageHandler *handler) { for (const Uint16 *i = handler->handledMessages; *i; i++) - { mMessageHandlers.erase(*i); - } } void clearNetworkHandlers() diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp index efd2ab2bc..8c14f3dfc 100644 --- a/src/net/manaserv/npchandler.cpp +++ b/src/net/manaserv/npchandler.cpp @@ -60,12 +60,10 @@ void NpcHandler::handleMessage(Net::MessageIn &msg) { Being *being = actorSpriteManager->findBeing(msg.readInt16()); if (!being || being->getType() != ActorSprite::NPC) - { return; - } int npcId = being->getId(); - NpcDialogs::iterator diag = mNpcDialogs.find(npcId); + NpcDialogs::const_iterator diag = mNpcDialogs.find(npcId); NpcDialog *dialog; if (diag == mNpcDialogs.end()) diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp index 43271671e..f80dd6e69 100644 --- a/src/net/tmwa/npchandler.cpp +++ b/src/net/tmwa/npchandler.cpp @@ -194,7 +194,7 @@ int NpcHandler::getNpc(Net::MessageIn &msg, bool haveLength) const int npcId = msg.readInt32(); - NpcDialogs::iterator diag = mNpcDialogs.find(npcId); + NpcDialogs::const_iterator diag = mNpcDialogs.find(npcId); mDialog = 0; if (diag == mNpcDialogs.end()) diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index f918a5c0d..046c5fd30 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -631,15 +631,15 @@ void OpenGLGraphics::drawImagePattern2(GraphicsVertexes *vert, Image *image) setTexturingAndBlending(true); std::vector *intVertPool = ogl->getIntVertPool(); - std::vector::iterator iv; + std::vector::const_iterator iv; std::vector *vp = ogl->getVp(); - std::vector::iterator ivp; + std::vector::const_iterator ivp; // Draw a set of textured rectangles if (image->mTextureType == GL_TEXTURE_2D) { std::vector *floatTexPool = ogl->getFloatTexPool(); - std::vector::iterator ft; + std::vector::const_iterator ft; for (iv = intVertPool->begin(), ft = floatTexPool->begin(), ivp = vp->begin(); @@ -653,7 +653,7 @@ void OpenGLGraphics::drawImagePattern2(GraphicsVertexes *vert, Image *image) else { std::vector *intTexPool = ogl->getIntTexPool(); - std::vector::iterator it; + std::vector::const_iterator it; for (iv = intVertPool->begin(), it = intTexPool->begin(), ivp = vp->begin(); diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index 70b1e2c84..686390474 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -93,7 +93,7 @@ void ParticleList::removeLocally(Particle *particle) void ParticleList::clearLocally() { - for (std::list::iterator it = mElements.begin(); + for (std::list::const_iterator it = mElements.begin(); it != mElements.end(); ++it) { (*it)->kill(); diff --git a/src/particleemitter.cpp b/src/particleemitter.cpp index caa48a795..fd1f07e16 100644 --- a/src/particleemitter.cpp +++ b/src/particleemitter.cpp @@ -435,7 +435,7 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o) mDeathEffect = o.mDeathEffect; mTempSets = o.mTempSets; - for (std::vector::iterator + for (std::vector::const_iterator i = mTempSets.begin(); i != mTempSets.end(); ++i) { @@ -453,7 +453,7 @@ ParticleEmitter & ParticleEmitter::operator=(const ParticleEmitter &o) ParticleEmitter::~ParticleEmitter() { - for (std::vector::iterator + for (std::vector::const_iterator i = mTempSets.begin(); i != mTempSets.end(); ++i) { @@ -576,7 +576,7 @@ std::list ParticleEmitter::createParticles(int tick) newParticle->setFadeIn(mParticleFadeIn.value(tick)); newParticle->setAlpha(mParticleAlpha.value(tick)); - for (std::list::iterator + for (std::list::const_iterator i = mParticleChildEmitters.begin(); i != mParticleChildEmitters.end(); ++i) { diff --git a/src/party.cpp b/src/party.cpp index f3f787807..9becee1cd 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -181,8 +181,9 @@ void Party::removeFromMembers() if (!actorSpriteManager) return; - MemberList::iterator itr = mMembers.begin(), - itr_end = mMembers.end(); + MemberList::const_iterator itr = mMembers.begin(); + MemberList::const_iterator itr_end = mMembers.end(); + while (itr != itr_end) { Being *b = actorSpriteManager->findBeing((*itr)->getID()); @@ -281,7 +282,7 @@ void Party::getNamesSet(std::set &names) const Party *Party::getParty(short id) { - PartyMap::iterator it = parties.find(id); + PartyMap::const_iterator it = parties.find(id); if (it != parties.end()) return it->second; Party *party = new Party(id); diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index 769d24a16..562795563 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -68,7 +68,10 @@ void triggerAttr(int id, int old) void triggerStat(int id, const std::string &changed, int old1, int old2) { - StatMap::iterator it = mData.mStats.find(id); + StatMap::const_iterator it = mData.mStats.find(id); + if (it == mData.mStats.end()) + return; + Mana::Event event(Mana::EVENT_UPDATESTAT); event.setInt("id", id); event.setInt("base", it->second.base); diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 802f2ee12..e28cb2bc5 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -336,7 +336,7 @@ bool Image::hasAlphaChannel() SDL_Surface *Image::getByAlpha(float alpha) { - std::map::iterator it = mAlphaCache.find(alpha); + std::map::const_iterator it = mAlphaCache.find(alpha); if (it != mAlphaCache.end()) return (*it).second; return 0; @@ -361,7 +361,7 @@ void Image::setAlpha(float alpha) { #ifdef DEBUG_ALPHA_CACHE logger->log("cleanCache"); - for (std::map::iterator + for (std::map::const_iterator i = mAlphaCache.begin(), i_end = mAlphaCache.end(); i != i_end; ++i) { diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 733c12958..89df407a6 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -308,7 +308,7 @@ void ItemDB::load() effect += " / "; effect += strprintf(gettext(fields[i][1]), value); } - for (std::vector::iterator it = extraStats.begin(); + for (std::vector::const_iterator it = extraStats.begin(); it != extraStats.end(); ++it) { int value = XML::getProperty(node, it->tag.c_str(), 0); diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index fb4b8ed5e..75e6e1d8c 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -185,7 +185,8 @@ std::string ItemInfo::getDyeColorsString(int color) const if (!mColors || mColorList.empty()) return ""; - std::map ::iterator it = mColors->find(color); + std::map ::const_iterator + it = mColors->find(color); if (it == mColors->end()) return ""; @@ -208,7 +209,8 @@ const std::string ItemInfo::replaceColors(std::string str, std::string name; if (mColors && !mColorList.empty()) { - std::map ::iterator it = mColors->find(color); + std::map ::const_iterator + it = mColors->find(color); if (it == mColors->end()) name = "unknown"; else diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index 685d415ff..f702864ea 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -734,7 +734,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path, Animation *ani = new Animation; for (int i = 0; ; i++) { - std::map::iterator iFrame, iDelay; + std::map::const_iterator iFrame, iDelay; iFrame = tileProperties.find( "animation-frame" + toString(i)); iDelay = tileProperties.find( diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp index 573ffb2a3..2463da06a 100644 --- a/src/resources/specialdb.cpp +++ b/src/resources/specialdb.cpp @@ -123,7 +123,7 @@ void SpecialDB::unload() SpecialInfo *SpecialDB::get(int id) { - SpecialInfos::iterator i = mSpecialInfos.find(id); + SpecialInfos::const_iterator i = mSpecialInfos.find(id); if (i == mSpecialInfos.end()) return NULL; diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp index dee93e1e7..2e32f6c5f 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -86,7 +86,7 @@ void SpriteDef::substituteAction(std::string complete, std::string with) { if (mActions.find(complete) == mActions.end()) { - Actions::iterator i = mActions.find(with); + Actions::const_iterator i = mActions.find(with); if (i != mActions.end()) mActions[complete] = i->second; } diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 09c9f2a04..5cfec3b84 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -137,7 +137,7 @@ void Wallpaper::loadWallpapers() std::string Wallpaper::getWallpaper(int width, int height) { - std::vector::iterator iter; + std::vector::const_iterator iter; WallpaperData wp; // Wallpaper filename container diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index a79388350..fcdf94039 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -104,7 +104,7 @@ bool SpellManager::addSpell(TextCommand *spell) if (!spell) return false; - std::map::iterator + std::map::const_iterator i = mSpells.find(spell->getId()); if (i == mSpells.end()) { @@ -342,7 +342,7 @@ void SpellManager::save() std::string SpellManager::autoComplete(std::string partName) { - std::vector::iterator i = mSpellsVector.begin(); + std::vector::const_iterator i = mSpellsVector.begin(); std::string newName = ""; TextCommand *newCommand = NULL; diff --git a/src/textmanager.cpp b/src/textmanager.cpp index c9da12e92..7c1be58cf 100644 --- a/src/textmanager.cpp +++ b/src/textmanager.cpp @@ -48,7 +48,7 @@ void TextManager::moveText(Text *text, int x, int y) void TextManager::removeText(const Text *text) { for (TextList::iterator ptr = mTextList.begin(), - pEnd = mTextList.end(); ptr != pEnd; ++ptr) + pEnd = mTextList.end(); ptr != pEnd; ++ptr) { if (*ptr == text) { @@ -64,8 +64,9 @@ TextManager::~TextManager() void TextManager::draw(gcn::Graphics *graphics, int xOff, int yOff) { - for (TextList::iterator bPtr = mTextList.begin(), ePtr = mTextList.end(); - bPtr != ePtr; ++bPtr) + for (TextList::const_iterator bPtr = mTextList.begin(), + ePtr = mTextList.end(); + bPtr != ePtr; ++ bPtr) { (*bPtr)->draw(graphics, xOff, yOff); } diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 176c5499c..f3aed5276 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -185,10 +185,11 @@ unsigned long findI(std::string text, std::vector &list) { std::string str = toLower(text); unsigned long idx; - for (std::vector::iterator i = list.begin(); + for (std::vector::const_iterator i = list.begin(); i != list.end(); ++i) { - std::string subStr = toLower(*i); + std::string subStr = *i; + subStr = toLower(subStr); idx = str.find(subStr); if (idx != std::string::npos) return idx; @@ -450,8 +451,8 @@ std::string combineDye2(std::string file, std::string dye) file = file.substr(0, pos); std::list list1 = splitToStringList(dye1, ';'); std::list list2 = splitToStringList(dye, ';'); - std::list::iterator it1, it1_end = list1.end(); - std::list::iterator it2, it2_end = list2.end(); + std::list::const_iterator it1, it1_end = list1.end(); + std::list::const_iterator it2, it2_end = list2.end(); for (it1 = list1.begin(), it2 = list2.begin(); it1 != it1_end && it2 != it2_end; ++it1, ++it2) { @@ -485,7 +486,7 @@ std::vector getLang() std::string packList(std::list &list) { - std::list::iterator i = list.begin(); + std::list::const_iterator i = list.begin(); std::string str = ""; while (i != list.end()) { -- cgit v1.2.3-60-g2f50 From f0f4b00290c3ae4b2b80bdef22d4ac56a863d35a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 8 Sep 2011 01:01:44 +0300 Subject: Fix register in some auto complete strings. --- src/gui/chatwindow.cpp | 3 +-- src/utils/stringutils.cpp | 18 ++++++++++++++++++ src/utils/stringutils.h | 3 +++ 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 0f42fb1b6..639125739 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -1195,8 +1195,7 @@ std::string ChatWindow::autoComplete(std::vector &names, { if (newName != "") { - toLower(newName); - newName = findSameSubstring(name, newName); + newName = findSameSubstringI(*i, newName); } else { diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index f3aed5276..62564e0e0 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -174,6 +174,24 @@ const std::string findSameSubstring(const std::string &str1, return str1.substr(0, minLength); } +const std::string findSameSubstringI(const std::string &s1, + const std::string &s2) +{ + std::string str1 = s1; + std::string str2 = s2; + toLower(str1); + toLower(str2); + + int minLength = str1.length() > str2.length() + ? static_cast(str2.length()) : static_cast(str1.length()); + for (int f = 0; f < minLength; f ++) + { + if (str1.at(f) != str2.at(f)) + return s1.substr(0, f); + } + return s1.substr(0, minLength); +} + unsigned long findI(std::string str, std::string subStr) { str = toLower(str); diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 25fe11e2d..273fa0c8c 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -116,6 +116,9 @@ std::string removeColors(std::string msg); const std::string findSameSubstring(const std::string &str1, const std::string &str2); +const std::string findSameSubstringI(const std::string &str1, + const std::string &str2); + /** * Compares the two strings case-insensitively. * -- cgit v1.2.3-60-g2f50 From f1c17766c66394ce875854430f8f028c0fa5b3a5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 8 Sep 2011 03:15:52 +0300 Subject: Add additional sorting methods to inventory: by weight, by amount, by type. --- src/gui/inventorywindow.cpp | 53 ++++++++++++++++++++++++------- src/gui/inventorywindow.h | 5 ++- src/gui/widgets/dropdown.cpp | 9 +++++- src/gui/widgets/dropdown.h | 4 ++- src/gui/widgets/itemcontainer.cpp | 67 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 123 insertions(+), 15 deletions(-) (limited to 'src/gui') diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index d0454c4e1..a8c003019 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -38,6 +38,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/container.h" +#include "gui/widgets/dropdown.h" #include "gui/widgets/inventoryfilter.h" #include "gui/widgets/itemcontainer.h" #include "gui/widgets/label.h" @@ -62,6 +63,34 @@ #include "debug.h" +const char *SORT_NAME[6] = +{ + N_("default"), + N_("by name"), + N_("by id"), + N_("by weight"), + N_("by amount"), + N_("by type") +}; + +class SortListModel : public gcn::ListModel +{ +public: + virtual ~SortListModel() + { } + + virtual int getNumberOfElements() + { return 6; } + + virtual std::string getElementAt(int i) + { + if (i >= getNumberOfElements() || i < 0) + return _("???"); + + return gettext(SORT_NAME[i]); + } +}; + InventoryWindow::WindowList InventoryWindow::instances; InventoryWindow::InventoryWindow(Inventory *inventory): @@ -109,9 +138,9 @@ InventoryWindow::InventoryWindow(Inventory *inventory): mFilter->addActionListener(this); mFilter->setActionEventId("tag_"); - mSorter = new InventoryFilter("sorter_" + getWindowName(), 20, 0); - mSorter->addActionListener(this); - mSorter->setActionEventId("sort_"); + mSortModel = new SortListModel(); + mSortDropDown = new DropDown(mSortModel, this, "sort"); + mSortDropDown->setSelected(0); mFilterLabel = new Label(_("Filter:")); mSorterLabel = new Label(_("Sort:")); @@ -120,10 +149,6 @@ InventoryWindow::InventoryWindow(Inventory *inventory): for (unsigned f = 0; f < tags.size(); f ++) mFilter->addButton(tags[f]); - mSorter->addButton(_("na"), "na"); - mSorter->addButton(_("az"), "az"); - mSorter->addButton(_("id"), "id"); - if (isMainInventory()) { std::string equip = _("Equip"); @@ -154,7 +179,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory): place(4, 0, mSlotsLabel, 1).setPadding(3); place(5, 0, mSlotsBar, 2); place(7, 0, mSorterLabel, 1); - place(8, 0, mSorter, 3); + place(8, 0, mSortDropDown, 3); place(0, 1, mFilterLabel, 1).setPadding(3); place(1, 1, mFilter, 10).setPadding(3); @@ -176,9 +201,9 @@ InventoryWindow::InventoryWindow(Inventory *inventory): mCloseButton = new Button(_("Close"), "close", this); place(0, 0, mSlotsLabel).setPadding(3); - place(1, 0, mSlotsBar, 3); - place(4, 0, mSorterLabel, 1); - place(5, 0, mSorter, 2); + place(1, 0, mSlotsBar, 4); + place(5, 0, mSorterLabel, 1); + place(6, 0, mSortDropDown, 1); place(0, 1, mFilterLabel, 1).setPadding(3); place(1, 1, mFilter, 6).setPadding(3); @@ -219,6 +244,8 @@ InventoryWindow::~InventoryWindow() mInventory->removeInventoyListener(this); if (!instances.empty()) instances.front()->updateDropButton(); + delete mSortModel; + mSortModel = 0; } void InventoryWindow::action(const gcn::ActionEvent &event) @@ -258,6 +285,10 @@ void InventoryWindow::action(const gcn::ActionEvent &event) ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd, this, item); } + else if (event.getId() == "sort") + { + mItems->setSortType(mSortDropDown->getSelected()); + } else if (!event.getId().find("tag_") && mItems) { std::string tagName = event.getId().substr(4); diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 503423ad3..c07b5b0e1 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -41,10 +41,12 @@ #define A_UNUSED #endif +class DropDown; class Item; class ItemContainer; class InventoryFilter; class ProgressBar; +class SortListModel; class TextBox; /** @@ -151,7 +153,8 @@ class InventoryWindow : public Window, ProgressBar *mWeightBar, *mSlotsBar; InventoryFilter *mFilter; - InventoryFilter *mSorter; + DropDown *mSortDropDown; + SortListModel *mSortModel; bool mSplit; }; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index f01d3fb55..687d7dc6d 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -46,7 +46,8 @@ Image *DropDown::buttons[2][2]; ImageRect DropDown::skin; float DropDown::mAlpha = 1.0; -DropDown::DropDown(gcn::ListModel *listModel): +DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener, + std::string eventId): gcn::DropDown::DropDown(listModel, new ScrollArea, new ListBox(listModel)) @@ -105,6 +106,12 @@ DropDown::DropDown(gcn::ListModel *listModel): mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); mShadowColor = Theme::getThemeColor(Theme::DROPDOWN_SHADOW); setForegroundColor(Theme::getThemeColor(Theme::TEXT)); + + if (!eventId.empty()) + setActionEventId(eventId); + + if (listener) + addActionListener(listener); } DropDown::~DropDown() diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 6a22ba497..4cbd23314 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -46,7 +46,9 @@ class DropDown : public gcn::DropDown * @param listBox the listBox to use. * @see ListModel, ScrollArea, ListBox. */ - DropDown(gcn::ListModel *listModel = 0); + DropDown(gcn::ListModel *listModel = 0, + gcn::ActionListener* listener = NULL, + std::string eventId = ""); ~DropDown(); diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 3d6d24868..75968d668 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -96,6 +96,63 @@ class SortItemIdFunctor } } itemIdSorter; +class SortItemWeightFunctor +{ + public: + bool operator() (ItemIdPair* pair1, ItemIdPair* pair2) + { + if (!pair1 || !pair2) + return false; + + const int w1 = pair1->mItem->getInfo().getWeight(); + const int w2 = pair2->mItem->getInfo().getWeight(); + if (w1 == w2) + { + return (pair1->mItem->getInfo().getName() + < pair2->mItem->getInfo().getName()); + } + return w1 < w2; + } +} itemWeightSorter; + +class SortItemAmountFunctor +{ + public: + bool operator() (ItemIdPair* pair1, ItemIdPair* pair2) + { + if (!pair1 || !pair2) + return false; + + const int c1 = pair1->mItem->getQuantity(); + const int c2 = pair2->mItem->getQuantity(); + if (c1 == c2) + { + return (pair1->mItem->getInfo().getName() + < pair2->mItem->getInfo().getName()); + } + return c1 < c2;; + } +} itemAmountSorter; + +class SortItemTypeFunctor +{ + public: + bool operator() (ItemIdPair* pair1, ItemIdPair* pair2) + { + if (!pair1 || !pair2) + return false; + + const int t1 = pair1->mItem->getInfo().getType(); + const int t2 = pair2->mItem->getInfo().getType(); + if (t1 == t2) + { + return (pair1->mItem->getInfo().getName() + < pair2->mItem->getInfo().getName()); + } + return t1 < t2;; + } +} itemTypeSorter; + ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): mInventory(inventory), mGridColumns(1), @@ -477,6 +534,15 @@ void ItemContainer::updateMatrix() case 2: sort(sortedItems.begin(), sortedItems.end(), itemIdSorter); break; + case 3: + sort(sortedItems.begin(), sortedItems.end(), itemWeightSorter); + break; + case 4: + sort(sortedItems.begin(), sortedItems.end(), itemAmountSorter); + break; + case 5: + sort(sortedItems.begin(), sortedItems.end(), itemTypeSorter); + break; } std::vector::const_iterator iter; @@ -608,6 +674,5 @@ void ItemContainer::setFilter (int tag) void ItemContainer::setSortType (int sortType) { mSortType = sortType; - logger->log("setSortType: %d", sortType); updateMatrix(); } -- cgit v1.2.3-60-g2f50 From e72f26151bca6c5a73d0377e385c0f7dd7cab3aa Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 00:47:31 +0300 Subject: Add to inventory filter by letters from item names. --- src/game.cpp | 19 ++++++++++----- src/gui/inventorywindow.cpp | 49 +++++++++++++++++++++++++++------------ src/gui/inventorywindow.h | 8 ++++++- src/gui/widgets/itemcontainer.cpp | 13 ++++++++++- src/gui/widgets/itemcontainer.h | 4 ++++ src/gui/widgets/textfield.cpp | 13 ++++++++--- src/gui/widgets/textfield.h | 3 ++- 7 files changed, 82 insertions(+), 27 deletions(-) (limited to 'src/gui') diff --git a/src/game.cpp b/src/game.cpp index 5a372a6bd..aaa9694bf 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -785,7 +785,8 @@ void Game::handleInput() && !chatWindow->isInputFocused() && !setupWindow->isVisible() && !player_node->getAwayMode() - && !NpcDialog::isAnyInputFocused()) + && !NpcDialog::isAnyInputFocused() + && !InventoryWindow::isAnyInputFocused()) { bool wearOutfit = false; bool copyOutfit = false; @@ -848,8 +849,11 @@ void Game::handleInput() } if (keyboard.isKeyActive(keyboard.KEY_TOGGLE_CHAT)) { - if (chatWindow->requestChatFocus()) - used = true; + if (!InventoryWindow::isAnyInputFocused()) + { + if (chatWindow->requestChatFocus()) + used = true; + } } if (dialog) { @@ -861,7 +865,8 @@ void Game::handleInput() } if ((!chatWindow->isInputFocused() && - !NpcDialog::isAnyInputFocused()) + !NpcDialog::isAnyInputFocused() && + !InventoryWindow::isAnyInputFocused()) || (event.key.keysym.mod & KMOD_ALT)) { if (keyboard.isKeyActive(keyboard.KEY_PREV_CHAT_TAB)) @@ -948,7 +953,8 @@ void Game::handleInput() && mValidSpeed && !setupWindow->isVisible() && !player_node->getAwayMode() - && !NpcDialog::isAnyInputFocused()) + && !NpcDialog::isAnyInputFocused() + && !InventoryWindow::isAnyInputFocused()) { switch (tKey) { @@ -1085,7 +1091,8 @@ void Game::handleInput() && !chatWindow->isInputFocused() && !NpcDialog::isAnyInputFocused() && !player_node->getAwayMode() - && !keyboard.isKeyActive(keyboard.KEY_TARGET)) + && !keyboard.isKeyActive(keyboard.KEY_TARGET) + && !InventoryWindow::isAnyInputFocused()) { const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index a8c003019..7a70135fd 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -22,6 +22,7 @@ #include "gui/inventorywindow.h" +#include "configuration.h" #include "inventory.h" #include "item.h" #include "units.h" @@ -46,6 +47,7 @@ #include "gui/widgets/progressbar.h" #include "gui/widgets/radiobutton.h" #include "gui/widgets/scrollarea.h" +#include "gui/widgets/textfield.h" #include "net/inventoryhandler.h" #include "net/net.h" @@ -134,7 +136,8 @@ InventoryWindow::InventoryWindow(Inventory *inventory): mSlotsLabel = new Label(_("Slots:")); mSlotsBar = new ProgressBar(0.0f, 100, 20, Theme::PROG_INVY_SLOTS); - mFilter = new InventoryFilter("filter_" + getWindowName(), 20, 5); + int size = config.getIntValue("fontSize"); + mFilter = new InventoryFilter("filter_" + getWindowName(), size, 0); mFilter->addActionListener(this); mFilter->setActionEventId("tag_"); @@ -144,6 +147,7 @@ InventoryWindow::InventoryWindow(Inventory *inventory): mFilterLabel = new Label(_("Filter:")); mSorterLabel = new Label(_("Sort:")); + mNameFilter = new TextField("", true, this, "namefilter", true); std::vector tags = ItemDB::getTags(); for (unsigned f = 0; f < tags.size(); f ++) @@ -182,7 +186,8 @@ InventoryWindow::InventoryWindow(Inventory *inventory): place(8, 0, mSortDropDown, 3); place(0, 1, mFilterLabel, 1).setPadding(3); - place(1, 1, mFilter, 10).setPadding(3); + place(1, 1, mFilter, 7).setPadding(3); + place(8, 1, mNameFilter, 3); place(0, 2, invenScroll, 11).setPadding(3); place(0, 3, mUseButton); @@ -206,7 +211,8 @@ InventoryWindow::InventoryWindow(Inventory *inventory): place(6, 0, mSortDropDown, 1); place(0, 1, mFilterLabel, 1).setPadding(3); - place(1, 1, mFilter, 6).setPadding(3); + place(1, 1, mFilter, 5).setPadding(3); + place(6, 1, mNameFilter, 1); place(0, 2, invenScroll, 7, 4); place(0, 6, mStoreButton); @@ -288,23 +294,18 @@ void InventoryWindow::action(const gcn::ActionEvent &event) else if (event.getId() == "sort") { mItems->setSortType(mSortDropDown->getSelected()); + return; + } + else if (event.getId() == "namefilter") + { + mItems->setName(mNameFilter->getText()); + mItems->updateMatrix(); } else if (!event.getId().find("tag_") && mItems) { std::string tagName = event.getId().substr(4); mItems->setFilter(ItemDB::getTagId(tagName)); - } - else if (!event.getId().find("sort_") && mItems) - { - int sortType = 0; - std::string str = event.getId().substr(5).c_str(); - if (str == "na") - sortType = 0; - else if (str == "az") - sortType = 1; - else if (str == "id") - sortType = 2; - mItems->setSortType(sortType); + return; } Item *item = mItems->getSelectedItem(); @@ -653,3 +654,21 @@ void InventoryWindow::updateDropButton() mDropButton->setCaption(_("Drop")); } } + +bool InventoryWindow::isInputFocused() const +{ + return mNameFilter && mNameFilter->isFocused(); +} + +bool InventoryWindow::isAnyInputFocused() +{ + WindowList::const_iterator it = instances.begin(); + WindowList::const_iterator it_end = instances.end(); + + for (; it != it_end; ++it) + { + if ((*it) && (*it)->isInputFocused()) + return true; + } + return false; +} diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index c07b5b0e1..14a53a179 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -47,7 +47,8 @@ class ItemContainer; class InventoryFilter; class ProgressBar; class SortListModel; -class TextBox; +//class TextBox; +class TextField; /** * Inventory dialog. @@ -130,6 +131,10 @@ class InventoryWindow : public Window, void updateButtons(Item *item = 0); + bool isInputFocused() const; + + static bool isAnyInputFocused(); + private: /** * Updates the weight bar. @@ -155,6 +160,7 @@ class InventoryWindow : public Window, InventoryFilter *mFilter; DropDown *mSortDropDown; SortListModel *mSortModel; + TextField *mNameFilter; bool mSplit; }; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 75968d668..84313d64f 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -513,6 +513,9 @@ void ItemContainer::updateMatrix() int i = 0; int j = 0; + std::string temp = mName; + toLower(temp); + for (unsigned idx = 0; idx < mInventory->getSize(); idx ++) { Item *item = mInventory->getItem(idx); @@ -520,7 +523,15 @@ void ItemContainer::updateMatrix() if (!item || item->getId() == 0 || !item->isHaveTag(mTag)) continue; - sortedItems.push_back(new ItemIdPair(idx, item)); + if (mName.empty()) + { + sortedItems.push_back(new ItemIdPair(idx, item)); + continue; + } + std::string name = item->getInfo().getName(); + toLower(name); + if (name.find(temp) != std::string::npos) + sortedItems.push_back(new ItemIdPair(idx, item)); } switch (mSortType) diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index df7de63ee..845bfb3a9 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -125,6 +125,9 @@ class ItemContainer : public gcn::Widget, void setSortType (int sortType); + void setName(std::string str) + { mName = str; } + void updateMatrix(); private: @@ -194,6 +197,7 @@ class ItemContainer : public gcn::Widget, int mDragPosX, mDragPosY; int mTag; int mSortType; + std::string mName; ItemPopup *mItemPopup; int *mShowMatrix; diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index d9f5bed9a..5d4fbc0b4 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -48,12 +48,14 @@ float TextField::mAlpha = 1.0; ImageRect TextField::skin; TextField::TextField(const std::string &text, bool loseFocusOnTab, - gcn::ActionListener* listener, std::string eventId): + gcn::ActionListener* listener, std::string eventId, + bool sendAlwaysEvents): gcn::TextField(text), mNumeric(false), mMinimum(0), mMaximum(0), - mLastEventPaste(false) + mLastEventPaste(false), + mSendAlwaysEvents(sendAlwaysEvents) { setFrameSize(2); @@ -276,7 +278,9 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) case Key::ENTER: distributeActionEvent(); - break; + keyEvent.consume(); + fixScroll(); + return; case Key::HOME: mCaretPosition = 0; @@ -337,6 +341,9 @@ void TextField::keyPressed(gcn::KeyEvent &keyEvent) break; } + if (mSendAlwaysEvents) + distributeActionEvent(); + keyEvent.consume(); fixScroll(); } diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 79790d83a..7e19099e8 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -41,7 +41,7 @@ class TextField : public gcn::TextField */ TextField(const std::string &text = "", bool loseFocusOnTab = true, gcn::ActionListener* listener = NULL, - std::string eventId = ""); + std::string eventId = "", bool sendAlwaysEvents = false); ~TextField(); @@ -109,6 +109,7 @@ class TextField : public gcn::TextField int mMaximum; bool mLoseFocusOnTab; int mLastEventPaste; + bool mSendAlwaysEvents; }; #endif -- cgit v1.2.3-60-g2f50 From 4484b433abc8f07bcf7d4d22fd946e00b66b078d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 19:43:40 +0300 Subject: Fix first part of shadow variables/methods errors. --- src/client.cpp | 30 +++++----- src/game.cpp | 12 ++-- src/graphics.h | 2 +- src/gui/changeemaildialog.cpp | 18 +++--- src/gui/changeemaildialog.h | 2 +- src/gui/changepassworddialog.cpp | 20 +++---- src/gui/changepassworddialog.h | 2 +- src/gui/charselectdialog.cpp | 10 ++-- src/gui/charselectdialog.h | 2 +- src/gui/chatwindow.cpp | 4 +- src/gui/palette.h | 13 +++-- src/gui/popupmenu.cpp | 8 +-- src/gui/setup_video.cpp | 30 +++++----- src/gui/spellpopup.cpp | 8 +-- src/gui/statuspopup.cpp | 6 +- src/gui/textpopup.cpp | 6 +- src/gui/widgets/avatarlistbox.cpp | 3 +- src/gui/widgets/browserbox.cpp | 14 ++--- src/gui/widgets/popup.cpp | 10 ++-- src/gui/widgets/progressbar.h | 4 +- src/gui/widgets/window.cpp | 84 +++++++++++++-------------- src/gui/windowmenu.cpp | 8 +-- src/guichan/cliprectangle.cpp | 16 ++--- src/guichan/include/guichan/cliprectangle.hpp | 32 +++++----- src/guichan/include/guichan/inputevent.hpp | 8 +-- src/guichan/include/guichan/keyevent.hpp | 20 +++---- src/guichan/include/guichan/mouseevent.hpp | 16 ++--- src/guichan/inputevent.cpp | 16 ++--- src/guichan/keyevent.cpp | 20 +++---- src/guichan/mouseevent.cpp | 16 ++--- src/map.h | 6 +- src/position.h | 4 +- src/resources/ambientlayer.cpp | 8 +-- src/resources/colordb.h | 8 +-- src/resources/itemdb.h | 8 +-- src/resources/spritedef.h | 6 +- src/vector.h | 8 +-- 37 files changed, 242 insertions(+), 246 deletions(-) (limited to 'src/gui') diff --git a/src/client.cpp b/src/client.cpp index 472c862e6..b9e9735c9 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -140,11 +140,11 @@ Configuration config; /**< XML file configuration reader */ Configuration serverConfig; /**< XML file server configuration reader */ Configuration branding; /**< XML branding information reader */ Configuration paths; /**< XML default paths information reader */ -Logger *logger; /**< Log object */ -ChatLogger *chatLogger; /**< Chat log object */ +Logger *logger = 0; /**< Log object */ +ChatLogger *chatLogger = 0; /**< Chat log object */ KeyboardConfig keyboard; -UserPalette *userPalette; -Graphics *graphics; +UserPalette *userPalette = 0; +Graphics *mainGraphics = 0; Sound sound; @@ -440,20 +440,20 @@ Client::Client(const Options &options): switch(useOpenGL) { case 0: - graphics = new Graphics; + mainGraphics = new Graphics; break; case 1: default: - graphics = new OpenGLGraphics; + mainGraphics = new OpenGLGraphics; break; case 2: - graphics = new OpenGL1Graphics; + mainGraphics = new OpenGL1Graphics; break; }; #else // Create the graphics context - graphics = new Graphics; + mainGraphics = new Graphics; #endif runCounters = config.getBoolValue("packetcounters"); @@ -465,7 +465,7 @@ Client::Client(const Options &options): const bool hwaccel = config.getBoolValue("hwaccel"); // Try to set the desired video mode - if (!graphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) + if (!mainGraphics->setVideoMode(width, height, bpp, fullscreen, hwaccel)) { logger->log(strprintf("Couldn't set %dx%dx%d video mode: %s", width, height, bpp, SDL_GetError())); @@ -482,7 +482,7 @@ Client::Client(const Options &options): config.setValueInt("screenwidth", oldWidth); config.setValueInt("screenheight", oldHeight); config.setValue("screen", oldFullscreen); - if (!graphics->setVideoMode(oldWidth, oldHeight, bpp, + if (!mainGraphics->setVideoMode(oldWidth, oldHeight, bpp, oldFullscreen, hwaccel)) { logger->error(strprintf("Couldn't restore %dx%dx%d " @@ -493,7 +493,7 @@ Client::Client(const Options &options): } // Initialize for drawing - graphics->_beginDraw(); + mainGraphics->_beginDraw(); Theme::selectSkin(); // Theme::prepareThemePath(); @@ -507,7 +507,7 @@ Client::Client(const Options &options): // Initialize the drop shortcuts. dropShortcut = new DropShortcut; - gui = new Gui(graphics); + gui = new Gui(mainGraphics); // Initialize sound engine try @@ -645,8 +645,8 @@ Client::~Client() logger->log1("Quitting3"); - delete graphics; - graphics = 0; + delete mainGraphics; + mainGraphics = 0; logger->log1("Quitting4"); @@ -760,7 +760,7 @@ int Client::exec() frame_count++; if (gui) gui->draw(); - graphics->updateScreen(); + mainGraphics->updateScreen(); // logger->log("active"); } else diff --git a/src/game.cpp b/src/game.cpp index aaa9694bf..a0635f42f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -371,8 +371,8 @@ Game::Game(): // Create the viewport viewport = new Viewport; - viewport->setDimension(gcn::Rectangle(0, 0, graphics->mWidth, - graphics->mHeight)); + viewport->setDimension(gcn::Rectangle(0, 0, mainGraphics->mWidth, + mainGraphics->mHeight)); gcn::Container *top = static_cast(gui->getTop()); top->add(viewport); @@ -459,14 +459,14 @@ static bool saveScreenshot() if (!config.getBoolValue("showip")) { - graphics->setSecure(true); + mainGraphics->setSecure(true); gui->draw(); - screenshot = graphics->getScreenshot(); - graphics->setSecure(false); + screenshot = mainGraphics->getScreenshot(); + mainGraphics->setSecure(false); } else { - screenshot = graphics->getScreenshot(); + screenshot = mainGraphics->getScreenshot(); } if (!screenshot) diff --git a/src/graphics.h b/src/graphics.h index 53b4b7c72..f3e0bd05d 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -292,6 +292,6 @@ class Graphics : public gcn::SDLGraphics bool mSecure; }; -extern Graphics *graphics; +extern Graphics *mainGraphics; #endif diff --git a/src/gui/changeemaildialog.cpp b/src/gui/changeemaildialog.cpp index c24624bc2..69af649e2 100644 --- a/src/gui/changeemaildialog.cpp +++ b/src/gui/changeemaildialog.cpp @@ -44,10 +44,10 @@ #include "debug.h" -ChangeEmailDialog::ChangeEmailDialog(LoginData *loginData): +ChangeEmailDialog::ChangeEmailDialog(LoginData *data): Window(_("Change Email Address"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { gcn::Label *accountLabel = new Label(strprintf(_("Account: %s"), mLoginData->username.c_str())); @@ -120,7 +120,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) logger->log("ChangeEmailDialog::Email change, Username is %s", username.c_str()); - std::stringstream errorMessage; + std::stringstream errorMsg; int error = 0; unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); @@ -129,21 +129,21 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) if (newFirstEmail.length() < min) { // First email address too short - errorMessage << strprintf(_("The new email address needs to be at " - "least %d characters long."), min); + errorMsg << strprintf(_("The new email address needs to be at " + "least %d characters long."), min); error = 1; } else if (newFirstEmail.length() > max - 1 ) { // First email address too long - errorMessage << strprintf(_("The new email address needs to be " - "less than %d characters long."), max); + errorMsg << strprintf(_("The new email address needs to be " + "less than %d characters long."), max); error = 1; } else if (newFirstEmail != newSecondEmail) { // Second Pass mismatch - errorMessage << _("The email address entries mismatch."); + errorMsg << _("The email address entries mismatch."); error = 2; } @@ -154,7 +154,7 @@ void ChangeEmailDialog::action(const gcn::ActionEvent &event) else if (error == 2) mWrongDataNoticeListener->setTarget(this->mSecondEmailField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); if (dlg) dlg->addActionListener(mWrongDataNoticeListener); } diff --git a/src/gui/changeemaildialog.h b/src/gui/changeemaildialog.h index e130a9074..fccb5cb1c 100644 --- a/src/gui/changeemaildialog.h +++ b/src/gui/changeemaildialog.h @@ -46,7 +46,7 @@ class ChangeEmailDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - ChangeEmailDialog(LoginData *loginData); + ChangeEmailDialog(LoginData *data); /** * Destructor. diff --git a/src/gui/changepassworddialog.cpp b/src/gui/changepassworddialog.cpp index 30012ae52..56db37ebb 100644 --- a/src/gui/changepassworddialog.cpp +++ b/src/gui/changepassworddialog.cpp @@ -46,10 +46,10 @@ #include "debug.h" -ChangePasswordDialog::ChangePasswordDialog(LoginData *loginData): +ChangePasswordDialog::ChangePasswordDialog(LoginData *data): Window(_("Change Password"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { gcn::Label *accountLabel = new Label( strprintf(_("Account: %s"), mLoginData->username.c_str())); @@ -101,7 +101,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) logger->log("ChangePasswordDialog::Password change, Username is %s", username.c_str()); - std::stringstream errorMessage; + std::stringstream errorMsg; int error = 0; unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); @@ -111,27 +111,27 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) if (oldPassword.empty()) { // No old password - errorMessage << _("Enter the old password first."); + errorMsg << _("Enter the old password first."); error = 1; } else if (newFirstPass.length() < min) { // First password too short - errorMessage << strprintf(_("The new password needs to be at least" - " %d characters long."), min); + errorMsg << strprintf(_("The new password needs to be at least" + " %d characters long."), min); error = 2; } else if (newFirstPass.length() > max - 1 ) { // First password too long - errorMessage << strprintf(_("The new password needs to be less " - "than %d characters long."), max); + errorMsg << strprintf(_("The new password needs to be less " + "than %d characters long."), max); error = 2; } else if (newFirstPass != newSecondPass) { // Second Pass mismatch - errorMessage << _("The new password entries mismatch."); + errorMsg << _("The new password entries mismatch."); error = 3; } @@ -144,7 +144,7 @@ void ChangePasswordDialog::action(const gcn::ActionEvent &event) else if (error == 3) mWrongDataNoticeListener->setTarget(this->mSecondPassField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/changepassworddialog.h b/src/gui/changepassworddialog.h index 3b0626922..fca8b4946 100644 --- a/src/gui/changepassworddialog.h +++ b/src/gui/changepassworddialog.h @@ -46,7 +46,7 @@ class ChangePasswordDialog : public Window, public gcn::ActionListener * * @see Window::Window */ - ChangePasswordDialog(LoginData *loginData); + ChangePasswordDialog(LoginData *data); /** * Destructor diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 75468d1ab..f926a90aa 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -121,20 +121,20 @@ class CharacterDisplay : public Container Button *mDelete; }; -CharSelectDialog::CharSelectDialog(LoginData *loginData): +CharSelectDialog::CharSelectDialog(LoginData *data): Window(_("Account and Character Management")), mLocked(false), mUnregisterButton(0), mChangeEmailButton(0), mCharacterEntries(0), - mLoginData(loginData), + mLoginData(data), mCharHandler(Net::getCharHandler()), mDeleteDialog(0), mDeleteIndex(-1) { setCloseButton(false); - mAccountNameLabel = new Label(loginData->username); + mAccountNameLabel = new Label(mLoginData->username); mSwitchLoginButton = new Button(_("Switch Login"), "switch", this); mChangePasswordButton = new Button(_("Change Password"), "change_password", this); @@ -373,7 +373,7 @@ void CharSelectDialog::setLocked(bool locked) } bool CharSelectDialog::selectByName(const std::string &name, - SelectAction action) + SelectAction selAction) { if (mLocked) return false; @@ -387,7 +387,7 @@ bool CharSelectDialog::selectByName(const std::string &name, { if (mCharacterEntries[i]) mCharacterEntries[i]->requestFocus(); - if (action == Choose) + if (selAction == Choose) attemptCharacterSelect(i); return true; } diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h index bcbbb7679..0dfe90733 100644 --- a/src/gui/charselectdialog.h +++ b/src/gui/charselectdialog.h @@ -60,7 +60,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener, /** * Constructor. */ - CharSelectDialog(LoginData *loginData); + CharSelectDialog(LoginData *data); ~CharSelectDialog(); diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 639125739..1b9877363 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -666,8 +666,8 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event) { int newX = std::max(0, getX() + event.getX() - mDragOffsetX); int newY = std::max(0, getY() + event.getY() - mDragOffsetY); - newX = std::min(graphics->mWidth - getWidth(), newX); - newY = std::min(graphics->mHeight - getHeight(), newY); + newX = std::min(mainGraphics->mWidth - getWidth(), newX); + newY = std::min(mainGraphics->mHeight - getHeight(), newY); setPosition(newX, newY); } } diff --git a/src/gui/palette.h b/src/gui/palette.h index 1cebe236f..645260280 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -182,13 +182,14 @@ class Palette int delay; int committedDelay; - void set(int type, gcn::Color& color, GradientType grad, int delay) + void set(int type0, gcn::Color& color0, GradientType grad0, + int delay0) { - ColorElem::type = type; - ColorElem::color = color; - ColorElem::testColor = color; - ColorElem::grad = grad; - ColorElem::delay = delay; + ColorElem::type = type0; + ColorElem::color = color0; + ColorElem::testColor = color0; + ColorElem::grad = grad0; + ColorElem::delay = delay0; ColorElem::gradientIndex = rand(); } diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index a329488ce..7e43c9954 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -2029,10 +2029,10 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item) void PopupMenu::showPopup(int x, int y) { setContentSize(mBrowserBox->getWidth() + 8, mBrowserBox->getHeight() + 8); - if (graphics->mWidth < (x + getWidth() + 5)) - x = graphics->mWidth - getWidth(); - if (graphics->mHeight < (y + getHeight() + 5)) - y = graphics->mHeight - getHeight(); + if (mainGraphics->mWidth < (x + getWidth() + 5)) + x = mainGraphics->mWidth - getWidth(); + if (mainGraphics->mHeight < (y + getHeight() + 5)) + y = mainGraphics->mHeight - getHeight(); setPosition(x, y); setVisible(true); requestMoveToTop(); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 0bfab1438..7bbcd9a2c 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -59,7 +59,7 @@ #include "debug.h" -extern Graphics *graphics; +extern Graphics *mainGraphics; /** * The list model for mode list. @@ -157,8 +157,8 @@ ModeListModel::ModeListModel() addCustomMode("1280x1024"); addCustomMode("1400x900"); addCustomMode("1500x990"); - addCustomMode(toString(graphics->mWidth) + "x" - + toString(graphics->mHeight)); + addCustomMode(toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight)); std::sort(mVideoModes.begin(), mVideoModes.end(), modeSorter); mVideoModes.push_back("custom"); @@ -348,8 +348,8 @@ Setup_Video::Setup_Video(): mFpsCheckBox->setSelected(mFps > 0); // Pre-select the current video mode. - std::string videoMode = toString(graphics->mWidth) + "x" - + toString(graphics->mHeight); + std::string videoMode = toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); mModeList->setActionEventId("videomode"); @@ -473,10 +473,10 @@ void Setup_Video::apply() if (!config.getIntValue("opengl")) { #endif - if (!graphics->setFullscreen(fullscreen)) + if (!mainGraphics->setFullscreen(fullscreen)) { fullscreen = !fullscreen; - if (!graphics->setFullscreen(fullscreen)) + if (!mainGraphics->setFullscreen(fullscreen)) { std::stringstream errorMessage; if (fullscreen) @@ -564,11 +564,11 @@ void Setup_Video::cancel() config.setValue("screen", mFullScreenEnabled); // Set back to the current video mode. - std::string videoMode = toString(graphics->mWidth) + "x" - + toString(graphics->mHeight); + std::string videoMode = toString(mainGraphics->mWidth) + "x" + + toString(mainGraphics->mHeight); mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); - config.setValue("screenwidth", graphics->mWidth); - config.setValue("screenheight", graphics->mHeight); + config.setValue("screenwidth", mainGraphics->mWidth); + config.setValue("screenheight", mainGraphics->mHeight); config.setValue("customcursor", mCustomCursorEnabled); config.setValue("particleeffects", mParticleEffectsEnabled); @@ -612,9 +612,9 @@ void Setup_Video::action(const gcn::ActionEvent &event) return; // TODO: Find out why the drawing area doesn't resize without a restart. - if (width != graphics->mWidth || height != graphics->mHeight) + if (width != mainGraphics->mWidth || height != mainGraphics->mHeight) { - if (width < graphics->mWidth || height < graphics->mHeight) + if (width < mainGraphics->mWidth || height < mainGraphics->mHeight) new OkDialog(_("Screen Resolution Changed"), _("Restart your client for the change to take effect.") + std::string("\n") + @@ -625,8 +625,8 @@ void Setup_Video::action(const gcn::ActionEvent &event) } config.setValue("oldscreen", config.getBoolValue("screen")); - config.setValue("oldscreenwidth", graphics->mWidth); - config.setValue("oldscreenheight", graphics->mHeight); + config.setValue("oldscreenwidth", mainGraphics->mWidth); + config.setValue("oldscreenheight", mainGraphics->mHeight); config.setValue("screenwidth", width); config.setValue("screenheight", height); } diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index a918e037d..f87e691de 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -80,14 +80,14 @@ void SpellPopup::view(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) + if (posX + getWidth() > mainGraphics->mWidth) { - if (graphics->mWidth > getWidth()) - posX = graphics->mWidth - getWidth(); + if (mainGraphics->mWidth > getWidth()) + posX = mainGraphics->mWidth - getWidth(); else posX = 0; } - if (posY + getHeight() > graphics->mHeight) + if (posY + getHeight() > mainGraphics->mHeight) { if (y > getHeight() + distance) posY = y - getHeight() - distance; diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index bb7a295ab..9214f1406 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -169,9 +169,9 @@ void StatusPopup::view(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; update(); diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 1ff601154..65c712461 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -96,9 +96,9 @@ void TextPopup::show(int x, int y, const std::string &str1, int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index d4764cba5..29fca7662 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -373,7 +373,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) default: { Map *map = viewport->getMap(); - Avatar *ava = model->getAvatarAt(selected); + ava = model->getAvatarAt(selected); if (map && ava) { MapItem *mapItem = map->findPortalXY( @@ -384,7 +384,6 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) } } } - else if (event.getButton() == gcn::MouseEvent::MIDDLE) { if (ava->getType() == AVATAR_PLAYER && chatWindow) diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 65a25363d..c20eb4622 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -210,23 +210,23 @@ void BrowserBox::addRow(const std::string &row, bool atTop) for (TextRowIterator i = mTextRows.begin(); i != mTextRows.end(); ++i) { - std::string row = *i; - for (unsigned int j = 0; j < row.size(); j++) + std::string tempRow = *i; + for (unsigned int j = 0; j < tempRow.size(); j++) { - std::string character = row.substr(j, 1); + std::string character = tempRow.substr(j, 1); x += font->getWidth(character); nextChar = j + 1; // Wraping between words (at blank spaces) - if ((nextChar < row.size()) && (row.at(nextChar) == ' ')) + if (nextChar < tempRow.size() && tempRow.at(nextChar) == ' ') { int nextSpacePos = static_cast( - row.find(" ", (nextChar + 1))); + tempRow.find(" ", (nextChar + 1))); if (nextSpacePos <= 0) - nextSpacePos = static_cast(row.size()) - 1; + nextSpacePos = static_cast(tempRow.size()) - 1; unsigned nextWordWidth = font->getWidth( - row.substr(nextChar, + tempRow.substr(nextChar, (nextSpacePos - nextChar))); if ((x + nextWordWidth + 10) > (unsigned)getWidth()) diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 38088770b..ebfdbe303 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -44,8 +44,8 @@ Popup::Popup(const std::string &name, const std::string &skin): mPopupName(name), mMinWidth(100), mMinHeight(40), - mMaxWidth(graphics->mWidth), - mMaxHeight(graphics->mHeight), + mMaxWidth(mainGraphics->mWidth), + mMaxHeight(mainGraphics->mHeight), mVertexes(new GraphicsVertexes()), mRedraw(true) { @@ -190,9 +190,9 @@ void Popup::position(int x, int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - if (posX + getWidth() > graphics->mWidth) - posX = graphics->mWidth - getWidth(); - if (posY + getHeight() > graphics->mHeight) + if (posX + getWidth() > mainGraphics->mWidth) + posX = mainGraphics->mWidth - getWidth(); + if (posY + getHeight() > mainGraphics->mHeight) posY = y - getHeight() - distance; setPosition(posX, posY); diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 52a26ddac..36ed96bd2 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -94,8 +94,8 @@ class ProgressBar : public gcn::Widget, public gcn::WidgetListener /** * Sets the text shown on the progress bar. */ - void setText(const std::string &text) - { mText = text; } + void setText(const std::string &str) + { mText = str; } /** * Returns the text shown on the progress bar. diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 9709f4c8a..05509ab39 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -63,8 +63,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent, mStickyButtonLock(false), mMinWinWidth(100), mMinWinHeight(40), - mMaxWinWidth(graphics->mWidth), - mMaxWinHeight(graphics->mHeight), + mMaxWinWidth(mainGraphics->mWidth), + mMaxWinHeight(mainGraphics->mHeight), mVertexes(new GraphicsVertexes()), mRedraw(true) { @@ -244,39 +244,39 @@ void Window::setLocationRelativeTo(ImageRect::ImagePosition position, } else if (position == ImageRect::UPPER_CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; + offsetX += (mainGraphics->mWidth - getWidth()) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - offsetX += graphics->mWidth - getWidth(); + offsetX += mainGraphics->mWidth - getWidth(); } else if (position == ImageRect::LEFT) { - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetX += (mainGraphics->mWidth - getWidth()) / 2; + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::RIGHT) { - offsetX += graphics->mWidth - getWidth(); - offsetY += (graphics->mHeight - getHeight()) / 2; + offsetX += mainGraphics->mWidth - getWidth(); + offsetY += (mainGraphics->mHeight - getHeight()) / 2; } else if (position == ImageRect::LOWER_LEFT) { - offsetY += graphics->mHeight - getHeight(); + offsetY += mainGraphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_CENTER) { - offsetX += (graphics->mWidth - getWidth()) / 2; - offsetY += graphics->mHeight - getHeight(); + offsetX += (mainGraphics->mWidth - getWidth()) / 2; + offsetY += mainGraphics->mHeight - getHeight(); } else if (position == ImageRect::LOWER_RIGHT) { - offsetX += graphics->mWidth - getWidth(); - offsetY += graphics->mHeight - getHeight(); + offsetX += mainGraphics->mWidth - getWidth(); + offsetY += mainGraphics->mHeight - getHeight(); } setPosition(offsetX, offsetY); @@ -579,8 +579,8 @@ void Window::mouseDragged(gcn::MouseEvent &event) { int newX = std::max(0, getX()); int newY = std::max(0, getY()); - newX = std::min(graphics->mWidth - getWidth(), newX); - newY = std::min(graphics->mHeight - getHeight(), newY); + newX = std::min(mainGraphics->mWidth - getWidth(), newX); + newY = std::min(mainGraphics->mHeight - getHeight(), newY); setPosition(newX, newY); } @@ -621,14 +621,10 @@ void Window::mouseDragged(gcn::MouseEvent &event) newDim.height += newDim.y; newDim.y = 0; } - if (newDim.x + newDim.width > graphics->mWidth) - { - newDim.width = graphics->mWidth - newDim.x; - } - if (newDim.y + newDim.height > graphics->mHeight) - { - newDim.height = graphics->mHeight - newDim.y; - } + if (newDim.x + newDim.width > mainGraphics->mWidth) + newDim.width = mainGraphics->mWidth - newDim.x; + if (newDim.y + newDim.height > mainGraphics->mHeight) + newDim.height = mainGraphics->mHeight - newDim.y; // Update mouse offset when dragging bottom or right border if (mouseResize & BOTTOM) @@ -790,39 +786,39 @@ void Window::setDefaultSize(int defaultWidth, int defaultHeight, } else if (position == ImageRect::UPPER_CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; + x = (mainGraphics->mWidth - defaultWidth) / 2; } else if (position == ImageRect::UPPER_RIGHT) { - x = graphics->mWidth - defaultWidth; + x = mainGraphics->mWidth - defaultWidth; } else if (position == ImageRect::LEFT) { - y = (graphics->mHeight - defaultHeight) / 2; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; - y = (graphics->mHeight - defaultHeight) / 2; + x = (mainGraphics->mWidth - defaultWidth) / 2; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::RIGHT) { - x = graphics->mWidth - defaultWidth; - y = (graphics->mHeight - defaultHeight) / 2; + x = mainGraphics->mWidth - defaultWidth; + y = (mainGraphics->mHeight - defaultHeight) / 2; } else if (position == ImageRect::LOWER_LEFT) { - y = graphics->mHeight - defaultHeight; + y = mainGraphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_CENTER) { - x = (graphics->mWidth - defaultWidth) / 2; - y = graphics->mHeight - defaultHeight; + x = (mainGraphics->mWidth - defaultWidth) / 2; + y = mainGraphics->mHeight - defaultHeight; } else if (position == ImageRect::LOWER_RIGHT) { - x = graphics->mWidth - defaultWidth; - y = graphics->mHeight - defaultHeight; + x = mainGraphics->mWidth - defaultWidth; + y = mainGraphics->mHeight - defaultHeight; } mDefaultX = x - offsetX; @@ -994,11 +990,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) // Look if the window is partially off-screen limits... if (partially) { - if (winDimension.x + winDimension.width > graphics->mWidth) - winDimension.x = graphics->mWidth - winDimension.width; + if (winDimension.x + winDimension.width > mainGraphics->mWidth) + winDimension.x = mainGraphics->mWidth - winDimension.width; - if (winDimension.y + winDimension.height > graphics->mHeight) - winDimension.y = graphics->mHeight - winDimension.height; + if (winDimension.y + winDimension.height > mainGraphics->mHeight) + winDimension.y = mainGraphics->mHeight - winDimension.height; setDimension(winDimension); return; @@ -1006,11 +1002,11 @@ void Window::checkIfIsOffScreen(bool partially, bool entirely) if (entirely) { - if (winDimension.x > graphics->mWidth) - winDimension.x = graphics->mWidth - winDimension.width; + if (winDimension.x > mainGraphics->mWidth) + winDimension.x = mainGraphics->mWidth - winDimension.width; - if (winDimension.y > graphics->mHeight) - winDimension.y = graphics->mHeight - winDimension.height; + if (winDimension.y > mainGraphics->mHeight) + winDimension.y = mainGraphics->mHeight - winDimension.height; } setDimension(winDimension); } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 8431cece1..eaec791ee 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -99,9 +99,9 @@ WindowMenu::WindowMenu(): KeyboardConfig::KEY_WINDOW_DIDYOUKNOW); addButton(N_("SET"), _("Setup"), x, h, KeyboardConfig::KEY_WINDOW_SETUP); - if (graphics) + if (mainGraphics) { - setDimension(gcn::Rectangle(graphics->mWidth - x - 3, + setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3, 3, x - 3, h)); } @@ -345,9 +345,9 @@ void WindowMenu::updateButtons() h = btn->getHeight(); } } - if (graphics) + if (mainGraphics) { - setDimension(gcn::Rectangle(graphics->mWidth - x - 3, + setDimension(gcn::Rectangle(mainGraphics->mWidth - x - 3, 3, x - 3, h)); } } diff --git a/src/guichan/cliprectangle.cpp b/src/guichan/cliprectangle.cpp index feaa47729..6effb48c8 100644 --- a/src/guichan/cliprectangle.cpp +++ b/src/guichan/cliprectangle.cpp @@ -61,15 +61,15 @@ namespace gcn yOffset = 0; } - ClipRectangle::ClipRectangle(int x, int y, int width, int height, - int xOffset, int yOffset) + ClipRectangle::ClipRectangle(int x0, int y0, int width0, int height0, + int xOffset0, int yOffset0) { - this->x = x; - this->y = y; - this->width = width; - this->height = height; - this->xOffset = xOffset; - this->yOffset = yOffset; + x = x0; + y = y0; + width = width0; + height = height0; + xOffset = xOffset0; + yOffset = yOffset0; } const ClipRectangle& ClipRectangle::operator=(const Rectangle& other) diff --git a/src/guichan/include/guichan/cliprectangle.hpp b/src/guichan/include/guichan/cliprectangle.hpp index 792c40bb9..b5aa5e4af 100644 --- a/src/guichan/include/guichan/cliprectangle.hpp +++ b/src/guichan/include/guichan/cliprectangle.hpp @@ -67,23 +67,23 @@ namespace gcn /** * Constructor. * - * @param x The rectangle x coordinate. - * @param y The rectangle y coordinate. - * @param width The rectangle width. - * @param height The rectangle height. - * @param xOffset The offset of the x coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. - * @param yOffset The offset of the y coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. + * @param x0 The rectangle x coordinate. + * @param y0 The rectangle y coordinate. + * @param width0 The rectangle width. + * @param height0 The rectangle height. + * @param xOffset0 The offset of the x coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. + * @param yOffset0 The offset of the y coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. */ - ClipRectangle(int x, - int y, - int width, - int height, - int xOffset, - int yOffset); + ClipRectangle(int x0, + int y0, + int width0, + int height0, + int xOffset0, + int yOffset0); /** * Copy constructor. Copies x, y, width and height diff --git a/src/guichan/include/guichan/inputevent.hpp b/src/guichan/include/guichan/inputevent.hpp index 8594d3dae..f252341cf 100644 --- a/src/guichan/include/guichan/inputevent.hpp +++ b/src/guichan/include/guichan/inputevent.hpp @@ -69,10 +69,10 @@ namespace gcn * @param isMetaPressed True if meta is pressed, false otherwise. */ InputEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed); + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed); /** * Checks if shift is pressed. diff --git a/src/guichan/include/guichan/keyevent.hpp b/src/guichan/include/guichan/keyevent.hpp index f42601235..5c10238c5 100644 --- a/src/guichan/include/guichan/keyevent.hpp +++ b/src/guichan/include/guichan/keyevent.hpp @@ -71,22 +71,22 @@ namespace gcn * Constructor. * * @param source The source widget of the event. - * @param isShiftPressed True if shift is pressed, false otherwise. - * @param isControlPressed True if control is pressed, false otherwise. - * @param isAltPressed True if alt is pressed, false otherwise. - * @param isMetaPressed True if meta is pressed, false otherwise. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. * @param type The type of the event. A value from KeyEventType. - * @param isNumericPad True if the event occured on the numeric pad, + * @param numericPad True if the event occured on the numeric pad, * false otherwise. * @param key The key of the event. */ KeyEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, - bool isNumericPad, + bool numericPad, const Key& key); /** diff --git a/src/guichan/include/guichan/mouseevent.hpp b/src/guichan/include/guichan/mouseevent.hpp index 280d373e6..6f6dc828c 100644 --- a/src/guichan/include/guichan/mouseevent.hpp +++ b/src/guichan/include/guichan/mouseevent.hpp @@ -66,10 +66,10 @@ namespace gcn * Constructor. * * @param source The source widget of the mouse event. - * @param isShiftPressed True if shift is pressed, false otherwise. - * @param isControlPressed True if control is pressed, false otherwise. - * @param isAltPressed True if alt is pressed, false otherwise. - * @param isMetaPressed True if meta is pressed, false otherwise. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. * @param type The type of the mouse event. * @param button The button of the mouse event. * @param x The x coordinate of the event relative to the source widget. @@ -78,10 +78,10 @@ namespace gcn * It's set to zero if another button is used. */ MouseEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, unsigned int button, int x, diff --git a/src/guichan/inputevent.cpp b/src/guichan/inputevent.cpp index 7a3bdb06d..a135b15b8 100644 --- a/src/guichan/inputevent.cpp +++ b/src/guichan/inputevent.cpp @@ -52,15 +52,15 @@ namespace gcn { InputEvent::InputEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed) + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed) :Event(source), - mShiftPressed(isShiftPressed), - mControlPressed(isControlPressed), - mAltPressed(isAltPressed), - mMetaPressed(isMetaPressed), + mShiftPressed(shiftPressed), + mControlPressed(controlPressed), + mAltPressed(altPressed), + mMetaPressed(metaPressed), mIsConsumed(false) { diff --git a/src/guichan/keyevent.cpp b/src/guichan/keyevent.cpp index 1bc8fe9d2..f9c14bb59 100644 --- a/src/guichan/keyevent.cpp +++ b/src/guichan/keyevent.cpp @@ -52,20 +52,20 @@ namespace gcn { KeyEvent::KeyEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, - bool isNumericPad, + bool numericPad, const Key& key) :InputEvent(source, - isShiftPressed, - isControlPressed, - isAltPressed, - isMetaPressed), + shiftPressed, + controlPressed, + altPressed, + metaPressed), mType(type), - mIsNumericPad(isNumericPad), + mIsNumericPad(numericPad), mKey(key) { diff --git a/src/guichan/mouseevent.cpp b/src/guichan/mouseevent.cpp index e5046ed15..5ff544a04 100644 --- a/src/guichan/mouseevent.cpp +++ b/src/guichan/mouseevent.cpp @@ -52,20 +52,20 @@ namespace gcn { MouseEvent::MouseEvent(Widget* source, - bool isShiftPressed, - bool isControlPressed, - bool isAltPressed, - bool isMetaPressed, + bool shiftPressed, + bool controlPressed, + bool altPressed, + bool metaPressed, unsigned int type, unsigned int button, int x, int y, int clickCount) :InputEvent(source, - isShiftPressed, - isControlPressed, - isAltPressed, - isMetaPressed), + shiftPressed, + controlPressed, + altPressed, + metaPressed), mType(type), mButton(button), mX(x), diff --git a/src/map.h b/src/map.h index c92a3c60f..e9a9df593 100644 --- a/src/map.h +++ b/src/map.h @@ -96,10 +96,10 @@ struct MetaTile class MapObject { public: - MapObject(int type, std::string data) + MapObject(int type0, std::string data0) { - this->type = type; - this->data = data; + type = type0; + data = data0; } int type; diff --git a/src/position.h b/src/position.h index 1d3070e1b..973a774f0 100644 --- a/src/position.h +++ b/src/position.h @@ -31,8 +31,8 @@ */ struct Position { - Position(int x, int y): - x(x), y(y) + Position(int x0, int y0): + x(x0), y(y0) { } int x; diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp index 10d70c2c7..319bc5b8c 100644 --- a/src/resources/ambientlayer.cpp +++ b/src/resources/ambientlayer.cpp @@ -41,16 +41,16 @@ AmbientLayer::AmbientLayer(Image *img, float parallax, if (keepRatio && !mImage->useOpenGL() /*&& defaultScreenWidth != 0 && defaultScreenHeight != 0*/ - && graphics->mWidth != defaultScreenWidth - && graphics->mHeight != defaultScreenHeight) + && mainGraphics->mWidth != defaultScreenWidth + && mainGraphics->mHeight != defaultScreenHeight) { // Rescale the overlay to keep the ratio as if we were on // the default resolution... Image *rescaledOverlay = ResourceManager::getInstance()-> getRescaled(mImage, static_cast(mImage->mBounds.w) - / defaultScreenWidth * graphics->mWidth, + / defaultScreenWidth * mainGraphics->mWidth, static_cast(mImage->mBounds.h) - / defaultScreenHeight * graphics->mHeight); + / defaultScreenHeight * mainGraphics->mHeight); if (rescaledOverlay) mImage = rescaledOverlay; diff --git a/src/resources/colordb.h b/src/resources/colordb.h index ce128578e..83bff57da 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -38,11 +38,11 @@ namespace ColorDB color("") { } - ItemColor(int id, std::string name, std::string color) + ItemColor(int id0, std::string name0, std::string color0) { - this->id = id; - this->name = name; - this->color = color; + this->id = id0; + this->name = name0; + this->color = color0; } int id; diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h index 267f60eef..c20961eff 100644 --- a/src/resources/itemdb.h +++ b/src/resources/itemdb.h @@ -68,10 +68,10 @@ namespace ItemDB struct Stat { - Stat(const std::string &tag, - const std::string &format): - tag(tag), - format(format) + Stat(const std::string &tag0, + const std::string &format0) : + tag(tag0), + format(format0) {} std::string tag; diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 8fa64e7b9..ccad62b1b 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -43,10 +43,10 @@ struct SpriteReference sprite(""), variant(0) {} - SpriteReference(std::string sprite, int variant) + SpriteReference(std::string sprite0, int variant0) { - this->sprite = sprite; - this->variant = variant; + sprite = sprite0; + variant = variant0; } std::string sprite; diff --git a/src/vector.h b/src/vector.h index 87e9c647a..0f10bae96 100644 --- a/src/vector.h +++ b/src/vector.h @@ -46,10 +46,10 @@ class Vector /** * Constructor. */ - Vector(float x, float y, float z = 0.0f): - x(x), - y(y), - z(z) + Vector(float x0, float y0, float z0 = 0.0f): + x(x0), + y(y0), + z(z0) {} /** -- cgit v1.2.3-60-g2f50 From 3a875a0026936d4bcb3bd1c2b6e8ac547cd5e27e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 19:59:09 +0300 Subject: Rename in listner class method from event to processEvent. --- src/event.cpp | 2 +- src/gui/chatwindow.cpp | 2 +- src/gui/chatwindow.h | 2 +- src/gui/inventorywindow.cpp | 5 ++--- src/gui/inventorywindow.h | 2 +- src/gui/killstats.cpp | 4 ++-- src/gui/killstats.h | 4 ++-- src/gui/ministatuswindow.cpp | 4 ++-- src/gui/ministatuswindow.h | 2 +- src/gui/statuswindow.cpp | 4 ++-- src/gui/statuswindow.h | 2 +- src/listener.h | 2 +- src/localplayer.cpp | 3 ++- src/localplayer.h | 2 +- src/net/ea/gamehandler.cpp | 3 ++- src/net/ea/gamehandler.h | 3 ++- src/net/manaserv/generalhandler.cpp | 4 ++-- src/net/manaserv/generalhandler.h | 2 +- src/net/tmwa/generalhandler.cpp | 4 ++-- src/net/tmwa/generalhandler.h | 2 +- src/playerinfo.cpp | 2 +- 21 files changed, 31 insertions(+), 29 deletions(-) (limited to 'src/gui') diff --git a/src/event.cpp b/src/event.cpp index 8ac9be189..5a1d673b2 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -118,7 +118,7 @@ void Event::trigger(Channels channel, const Event &event) while (lit != it->second.end()) { if (*lit) - (*lit)->event(channel, event); + (*lit)->processEvent(channel, event); ++lit; } } diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 1b9877363..c52511189 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -822,7 +822,7 @@ void ChatWindow::keyPressed(gcn::KeyEvent &event) addInputText(Temp, false); } -void ChatWindow::event(Mana::Channels channel, const Mana::Event &event) +void ChatWindow::processEvent(Mana::Channels channel, const Mana::Event &event) { if (channel == Mana::CHANNEL_NOTICES) { diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index 6e1d548a3..97e366701 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -196,7 +196,7 @@ class ChatWindow : public Window, */ void mousePressed(gcn::MouseEvent &event); - void event(Mana::Channels channel, const Mana::Event &event); + void processEvent(Mana::Channels channel, const Mana::Event &event); /** * Scrolls the chat window diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 7a70135fd..da1c45782 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -564,7 +564,6 @@ void InventoryWindow::updateButtons(Item *item) else mSplitButton->setEnabled(false); } - } void InventoryWindow::setSplitAllowed(bool allowed) @@ -585,8 +584,8 @@ void InventoryWindow::close() } } -void InventoryWindow::event(Mana::Channels channel A_UNUSED, - const Mana::Event &event) +void InventoryWindow::processEvent(Mana::Channels channel A_UNUSED, + const Mana::Event &event) { if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE) { diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index 14a53a179..c32fd8905 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -127,7 +127,7 @@ class InventoryWindow : public Window, void updateDropButton(); - void event(Mana::Channels channel, const Mana::Event &event); + void processEvent(Mana::Channels channel, const Mana::Event &event); void updateButtons(Item *item = 0); diff --git a/src/gui/killstats.cpp b/src/gui/killstats.cpp index 7d0a9fe11..0cadc765b 100644 --- a/src/gui/killstats.cpp +++ b/src/gui/killstats.cpp @@ -437,8 +437,8 @@ void KillStats::validateJacko() } } -void KillStats::event(Mana::Channels channel A_UNUSED, - const Mana::Event &event) +void KillStats::processEvent(Mana::Channels channel A_UNUSED, + const Mana::Event &event) { if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE) { diff --git a/src/gui/killstats.h b/src/gui/killstats.h index ff2a8f010..8562e67a4 100644 --- a/src/gui/killstats.h +++ b/src/gui/killstats.h @@ -78,8 +78,8 @@ class KillStats : public Window, gcn::ActionListener, public Mana::Listener void addLog(std::string str); - void event(Mana::Channels channel A_UNUSED, - const Mana::Event &event); + void processEvent(Mana::Channels channel A_UNUSED, + const Mana::Event &event); private: void validateJacko(); diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index da39eb24c..b325bcef6 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -218,8 +218,8 @@ void MiniStatusWindow::drawIcons(Graphics *graphics) } } -void MiniStatusWindow::event(Mana::Channels channel A_UNUSED, - const Mana::Event &event) +void MiniStatusWindow::processEvent(Mana::Channels channel A_UNUSED, + const Mana::Event &event) { if (event.getName() == Mana::EVENT_UPDATEATTRIBUTE) { diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index 19517326b..91aebcfac 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -66,7 +66,7 @@ class MiniStatusWindow : public Popup, void drawIcons(Graphics *graphics); - void event(Mana::Channels channel, const Mana::Event &event); + void processEvent(Mana::Channels channel, const Mana::Event &event); void updateStatus(); diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index a85f60133..97130b103 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -276,8 +276,8 @@ StatusWindow::StatusWindow(): mLvlLabel->adjustSize(); } -void StatusWindow::event(Mana::Channels channel A_UNUSED, - const Mana::Event &event) +void StatusWindow::processEvent(Mana::Channels channel A_UNUSED, + const Mana::Event &event) { static bool blocked = false; if (blocked) diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index 44d052004..fa957d059 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -58,7 +58,7 @@ class StatusWindow : public Window, */ StatusWindow(); - void event(Mana::Channels channel, const Mana::Event &event); + void processEvent(Mana::Channels channel, const Mana::Event &event); void setPointsNeeded(int id, int needed); diff --git a/src/listener.h b/src/listener.h index f5efa8a53..8993c31af 100644 --- a/src/listener.h +++ b/src/listener.h @@ -38,7 +38,7 @@ class Listener void ignore(Channels channel); - virtual void event(Channels channel, const Event &event) = 0; + virtual void processEvent(Channels channel, const Event &event) = 0; }; } // namespace Mana diff --git a/src/localplayer.cpp b/src/localplayer.cpp index a68cd5ee8..fdbc4b0b7 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -1633,7 +1633,8 @@ void LocalPlayer::optionChanged(const std::string &value) mTradebot = config.getBoolValue("tradebot"); } -void LocalPlayer::event(Mana::Channels channel, const Mana::Event &event) +void LocalPlayer::processEvent(Mana::Channels channel, + const Mana::Event &event) { if (channel == Mana::CHANNEL_ATTRIBUTES) { diff --git a/src/localplayer.h b/src/localplayer.h index 1f2790e88..cb23d855e 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -386,7 +386,7 @@ class LocalPlayer : public Being, public ActorSpriteListener, */ void optionChanged(const std::string &value); - void event(Mana::Channels channel, const Mana::Event &event); + void processEvent(Mana::Channels channel, const Mana::Event &event); /** * set a following player. diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index 04c13572f..a202cbc86 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -46,7 +46,8 @@ GameHandler::GameHandler() listen(Mana::CHANNEL_GAME); } -void GameHandler::event(Mana::Channels channel, const Mana::Event &event) +void GameHandler::processEvent(Mana::Channels channel, + const Mana::Event &event) { if (channel == Mana::CHANNEL_GAME) { diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h index abfaaa6b4..6d8b88bd4 100644 --- a/src/net/ea/gamehandler.h +++ b/src/net/ea/gamehandler.h @@ -43,7 +43,8 @@ class GameHandler : public Net::GameHandler, public Mana::Listener public: GameHandler(); - virtual void event(Mana::Channels channel, const Mana::Event &event); + virtual void processEvent(Mana::Channels channel, + const Mana::Event &event); virtual void who(); diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp index 7c95033a8..9e32f139d 100644 --- a/src/net/manaserv/generalhandler.cpp +++ b/src/net/manaserv/generalhandler.cpp @@ -176,8 +176,8 @@ void GeneralHandler::clearHandlers() clearNetworkHandlers(); } -void GeneralHandler::event(Mana::Channels channel, - const Mana::Event &event) +void GeneralHandler::processEvent(Mana::Channels channel, + const Mana::Event &event) { if (channel == Mana::CHANNEL_CLIENT) { diff --git a/src/net/manaserv/generalhandler.h b/src/net/manaserv/generalhandler.h index 90587eeb3..ccdddbbe6 100644 --- a/src/net/manaserv/generalhandler.h +++ b/src/net/manaserv/generalhandler.h @@ -56,7 +56,7 @@ class GeneralHandler : public Net::GeneralHandler, public Mana::Listener void clearHandlers(); - void event(Mana::Channels channel, const Mana::Event &event); + void processEvent(Mana::Channels channel, const Mana::Event &event); protected: MessageHandlerPtr mBeingHandler; diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index e1b565399..c6ebc000c 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -240,8 +240,8 @@ void GeneralHandler::clearHandlers() mNetwork->clearHandlers(); } -void GeneralHandler::event(Mana::Channels channel, - const Mana::Event &event) +void GeneralHandler::processEvent(Mana::Channels channel, + const Mana::Event &event) { if (channel == Mana::CHANNEL_GAME) { diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h index 27186fcc8..5e6c9f18f 100644 --- a/src/net/tmwa/generalhandler.h +++ b/src/net/tmwa/generalhandler.h @@ -59,7 +59,7 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler, void clearHandlers(); - void event(Mana::Channels channel, const Mana::Event &event); + void processEvent(Mana::Channels channel, const Mana::Event &event); void reloadPartially(); diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index 562795563..e0f8aa494 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -312,7 +312,7 @@ public: listen(Mana::CHANNEL_GAME); } - void event(Mana::Channels channel, const Mana::Event &event) + void processEvent(Mana::Channels channel, const Mana::Event &event) { if (channel == Mana::CHANNEL_CLIENT) { -- cgit v1.2.3-60-g2f50 From 703a3c4df3732e3e88559147001260f3355d42d6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 22:10:53 +0300 Subject: Continue fix for shadow variables/methods errors. --- src/actorspritemanager.cpp | 7 +++--- src/actorspritemanager.h | 4 +-- src/client.cpp | 52 +++++++++++++++++++-------------------- src/client.h | 4 +-- src/commandhandler.cpp | 6 ++--- src/game.cpp | 4 +-- src/gui/chatwindow.cpp | 8 +++--- src/gui/chatwindow.h | 4 +-- src/gui/inventorywindow.cpp | 11 +++------ src/gui/itemamountwindow.cpp | 4 +-- src/gui/logindialog.cpp | 8 +++--- src/gui/logindialog.h | 2 +- src/gui/ministatuswindow.cpp | 4 +-- src/gui/ministatuswindow.h | 2 +- src/gui/popupmenu.cpp | 15 ++++++----- src/gui/register.cpp | 22 ++++++++--------- src/gui/sdlfont.cpp | 4 +-- src/gui/serverdialog.cpp | 10 ++++---- src/gui/setup_video.cpp | 16 ++++++------ src/gui/shopwindow.cpp | 2 +- src/gui/socialwindow.cpp | 6 ++--- src/gui/textcommandeditor.cpp | 4 +-- src/gui/tradewindow.cpp | 4 +-- src/gui/unregisterdialog.cpp | 16 ++++++------ src/gui/viewport.cpp | 2 +- src/gui/widgets/avatarlistbox.cpp | 2 +- src/gui/widgets/mouseevent.h | 10 ++++---- src/gui/windowmenu.cpp | 4 +-- src/gui/windowmenu.h | 2 +- src/localplayer.cpp | 6 ++--- src/map.cpp | 10 ++++---- src/net/ea/buysellhandler.cpp | 12 ++++----- src/net/ea/chathandler.cpp | 20 +++++++-------- src/net/ea/inventoryhandler.h | 16 ++++++------ src/net/manaserv/chathandler.cpp | 2 +- src/net/tmwa/adminhandler.cpp | 2 +- src/net/tmwa/adminhandler.h | 2 +- src/net/tmwa/beinghandler.cpp | 12 ++++----- src/party.cpp | 4 +-- src/resources/beinginfo.h | 10 ++++---- 40 files changed, 166 insertions(+), 169 deletions(-) (limited to 'src/gui') diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 1104f034a..3acb63dc3 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -257,7 +257,6 @@ void ActorSpriteManager::undelete(ActorSprite *actor) for (it = mDeleteActors.begin(), it_end = mDeleteActors.end(); it != it_end; ++it) { - ActorSprite *actor = *it; if (*it == actor) { mDeleteActors.erase(*it); @@ -906,15 +905,15 @@ bool ActorSpriteManager::validateBeing(Being *aroundBeing, Being* being, || player_node->isReachable(being, maxCost)); } -void ActorSpriteManager::healTarget(LocalPlayer* player_node) +void ActorSpriteManager::healTarget() { if (!player_node) return; - heal(player_node, player_node->getTarget()); + heal(player_node->getTarget()); } -void ActorSpriteManager::heal(LocalPlayer* player_node, Being* target) +void ActorSpriteManager::heal(Being* target) { if (!player_node || !chatWindow || !player_node->isAlive() || !Net::getPlayerHandler()->canUseMagic()) diff --git a/src/actorspritemanager.h b/src/actorspritemanager.h index 91503e1c3..bd2ae79fb 100644 --- a/src/actorspritemanager.h +++ b/src/actorspritemanager.h @@ -164,9 +164,9 @@ class ActorSpriteManager: public ConfigListener // void HealAllTargets(Being *aroundBeing, int maxdist, // Being::Type type) const; - void healTarget(LocalPlayer* player_node); + void healTarget(); - void heal(LocalPlayer* player_node, Being* target); + void heal(Being* target); void itenplz(); diff --git a/src/client.cpp b/src/client.cpp index b9e9735c9..be1c00197 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -196,16 +196,16 @@ Uint32 nextSecond(Uint32 interval, void *param A_UNUSED) * @return the elapsed time in milliseconds * between two tick values. */ -int get_elapsed_time(int start_time) +int get_elapsed_time(int startTime) { - if (start_time <= tick_time) + if (startTime <= tick_time) { - return (tick_time - start_time) * MILLISECONDS_IN_A_TICK; + return (tick_time - startTime) * MILLISECONDS_IN_A_TICK; } else { - return (tick_time + (MAX_TICK_VALUE - start_time)) - * MILLISECONDS_IN_A_TICK; + return (tick_time + (MAX_TICK_VALUE - startTime)) + * MILLISECONDS_IN_A_TICK; } } @@ -845,10 +845,10 @@ int Client::exec() if (mState != mOldState) { { - Mana::Event event(EVENT_STATECHANGE); - event.setInt("oldState", mOldState); - event.setInt("newState", mState); - Mana::Event::trigger(CHANNEL_CLIENT, event); + Mana::Event evt(EVENT_STATECHANGE); + evt.setInt("oldState", mOldState); + evt.setInt("newState", mState); + Mana::Event::trigger(CHANNEL_CLIENT, evt); } if (mOldState == STATE_GAME) @@ -1046,10 +1046,10 @@ int Client::exec() if (!BeingInfo::unknown) BeingInfo::unknown = new BeingInfo; - Mana::Event event(EVENT_STATECHANGE); - event.setInt("newState", STATE_LOAD_DATA); - event.setInt("oldState", mOldState); - Mana::Event::trigger(CHANNEL_CLIENT, event); + Mana::Event evt(EVENT_STATECHANGE); + evt.setInt("newState", STATE_LOAD_DATA); + evt.setInt("oldState", mOldState); + Mana::Event::trigger(CHANNEL_CLIENT, evt); // Load XML databases ColorDB::load(); @@ -1733,27 +1733,27 @@ void Client::initScreenshotDir() } } -void Client::accountLogin(LoginData *loginData) +void Client::accountLogin(LoginData *data) { - if (!loginData) + if (!data) return; - logger->log("Username is %s", loginData->username.c_str()); + logger->log("Username is %s", data->username.c_str()); // Send login infos - if (loginData->registerLogin) - Net::getLoginHandler()->registerAccount(loginData); + if (data->registerLogin) + Net::getLoginHandler()->registerAccount(data); else - Net::getLoginHandler()->loginAccount(loginData); + Net::getLoginHandler()->loginAccount(data); // Clear the password, avoids auto login when returning to login - loginData->password = ""; + data->password = ""; // TODO This is not the best place to save the config, but at least better // than the login gui window - if (loginData->remember) - serverConfig.setValue("username", loginData->username); - serverConfig.setValue("remember", loginData->remember); + if (data->remember) + serverConfig.setValue("username", data->username); + serverConfig.setValue("remember", data->remember); } bool Client::copyFile(std::string &configPath, std::string &oldConfigPath) @@ -1805,7 +1805,7 @@ void Client::storeSafeParameters() int width; int height; std::string font; - std::string boldFont; + std::string bFont; std::string particleFont; std::string helpFont; std::string secureFont; @@ -1833,7 +1833,7 @@ void Client::storeSafeParameters() height = config.getIntValue("screenheight"); font = config.getStringValue("font"); - boldFont = config.getStringValue("boldFont"); + bFont = config.getStringValue("boldFont"); particleFont = config.getStringValue("particleFont"); helpFont = config.getStringValue("helpFont"); secureFont = config.getStringValue("secureFont"); @@ -1878,7 +1878,7 @@ void Client::storeSafeParameters() config.setValue("screenwidth", width); config.setValue("screenheight", height); config.setValue("font", font); - config.setValue("boldFont", boldFont); + config.setValue("boldFont", bFont); config.setValue("particleFont", particleFont); config.setValue("helpFont", helpFont); config.setValue("secureFont", secureFont); diff --git a/src/client.h b/src/client.h index 3edf12674..4409cf8db 100644 --- a/src/client.h +++ b/src/client.h @@ -78,7 +78,7 @@ extern LoginData loginData; /** * Returns elapsed time. (Warning: supposes the delay is always < 100 seconds) */ -int get_elapsed_time(int start_time); +int get_elapsed_time(int startTime); /** * All client states. @@ -291,7 +291,7 @@ private: bool copyFile(std::string &configPath, std::string &oldConfigPath); bool createConfig(std::string &configPath); - void accountLogin(LoginData *loginData); + void accountLogin(LoginData *data); void storeSafeParameters(); diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index dc962a17d..d16a7db27 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -397,7 +397,7 @@ void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) if (tempNick.compare(playerName) == 0 || args.empty()) return; - chatWindow->whisper(recvnick, msg, BY_PLAYER); + chatWindow->addWhisper(recvnick, msg, BY_PLAYER); } else tab->chatLog(_("Cannot send empty whispers!"), BY_SERVER); @@ -851,11 +851,11 @@ void CommandHandler::handleHeal(const std::string &args, ChatTab *tab A_UNUSED) Being *being = actorSpriteManager->findBeingByName( args, Being::PLAYER); if (being) - actorSpriteManager->heal(player_node, being); + actorSpriteManager->heal(being); } else { - actorSpriteManager->heal(player_node, player_node); + actorSpriteManager->heal(player_node); } } diff --git a/src/game.cpp b/src/game.cpp index a0635f42f..3c7579d78 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -972,7 +972,7 @@ void Game::handleInput() break; case KeyboardConfig::KEY_MAGIC_INMA1: - actorSpriteManager->healTarget(player_node); + actorSpriteManager->healTarget(); setValidSpeed(); break; @@ -1094,7 +1094,7 @@ void Game::handleInput() && !keyboard.isKeyActive(keyboard.KEY_TARGET) && !InventoryWindow::isAnyInputFocused()) { - const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); +// const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); if (setupWindow->isVisible()) { diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index c52511189..f3e4b88b8 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -907,9 +907,9 @@ void ChatWindow::addItemText(const std::string &item) addInputText(text.str()); } -void ChatWindow::setVisible(bool isVisible) +void ChatWindow::setVisible(bool visible) { - Window::setVisible(isVisible); + Window::setVisible(visible); /* * For whatever reason, if setVisible is called, the mTmpVisible effect @@ -918,8 +918,8 @@ void ChatWindow::setVisible(bool isVisible) mTmpVisible = false; } -void ChatWindow::whisper(const std::string &nick, - const std::string &mes, Own own) +void ChatWindow::addWhisper(const std::string &nick, + const std::string &mes, Own own) { if (mes.empty() || !player_node) return; diff --git a/src/gui/chatwindow.h b/src/gui/chatwindow.h index 97e366701..1ad468a3b 100644 --- a/src/gui/chatwindow.h +++ b/src/gui/chatwindow.h @@ -222,8 +222,8 @@ class ChatWindow : public Window, void doPresent(); - void whisper(const std::string &nick, const std::string &mes, - Own own = BY_OTHER); + void addWhisper(const std::string &nick, const std::string &mes, + Own own = BY_OTHER); ChatTab *addWhisperTab(const std::string &nick, bool switchTo = false); diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index da1c45782..c6afaaf1d 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -362,17 +362,12 @@ void InventoryWindow::action(const gcn::ActionEvent &event) else if (event.getId() == "split") { ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, this, item, - (item->getQuantity() - 1)); + (item->getQuantity() - 1)); } else if (event.getId() == "retrieve") { - Item *item = mItems->getSelectedItem(); - - if (!item) - return; - - ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, this, - item); + ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, + this, item); } } diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index 059f3d785..9bd3f3ab3 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -53,11 +53,11 @@ class ItemsModal : public gcn::ListModel public: ItemsModal() { - std::map info = ItemDB::getItemInfos(); + std::map items = ItemDB::getItemInfos(); std::list tempStrings; for (std::map::const_iterator - i = info.begin(), i_end = info.end(); + i = items.begin(), i_end = items.end(); i != i_end; ++i) { if (i->first < 0) diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index ab5dc7401..adf499f75 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -81,10 +81,10 @@ public: } }; -LoginDialog::LoginDialog(LoginData *loginData, std::string serverName, +LoginDialog::LoginDialog(LoginData *data, std::string serverName, std::string *updateHost): Window(_("Login")), - mLoginData(loginData), + mLoginData(data), mUpdateHost(updateHost), mServerName(serverName) { @@ -94,7 +94,7 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName, gcn::Label *userLabel = new Label(_("Name:")); gcn::Label *passLabel = new Label(_("Password:")); mCustomUpdateHost = new CheckBox(_("Custom update host"), - loginData->updateType & LoginData::Upd_Custom, this, "customhost"); + mLoginData->updateType & LoginData::Upd_Custom, this, "customhost"); mUpdateHostText = new TextField(serverConfig.getValue( "customUpdateHost", "")); @@ -112,7 +112,7 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName, mUpdateTypeModel = new UpdateTypeModel(); mUpdateTypeDropDown = new DropDown(mUpdateTypeModel); mUpdateTypeDropDown->setActionEventId("updatetype"); - mUpdateTypeDropDown->setSelected((loginData->updateType + mUpdateTypeDropDown->setSelected((mLoginData->updateType | LoginData::Upd_Custom) ^ LoginData::Upd_Custom); if (!mCustomUpdateHost->isSelected()) diff --git a/src/gui/logindialog.h b/src/gui/logindialog.h index e464c6f24..0696bc680 100644 --- a/src/gui/logindialog.h +++ b/src/gui/logindialog.h @@ -49,7 +49,7 @@ class LoginDialog : public Window, public gcn::ActionListener, * * @see Window::Window */ - LoginDialog(LoginData *loginData, std::string serverName, + LoginDialog(LoginData *data, std::string serverName, std::string *updateHost); ~LoginDialog(); diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index b325bcef6..e3f441b60 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -400,12 +400,12 @@ void MiniStatusWindow::mouseExited(gcn::MouseEvent &event) mStatusPopup->hide(); } -void MiniStatusWindow::showBar(std::string name, bool isVisible) +void MiniStatusWindow::showBar(std::string name, bool visible) { ProgressBar *bar = mBarNames[name]; if (!bar) return; - bar->setVisible(isVisible); + bar->setVisible(visible); updateBars(); saveBars(); } diff --git a/src/gui/ministatuswindow.h b/src/gui/ministatuswindow.h index 91aebcfac..5e1b442dc 100644 --- a/src/gui/ministatuswindow.h +++ b/src/gui/ministatuswindow.h @@ -80,7 +80,7 @@ class MiniStatusWindow : public Popup, void mouseExited(gcn::MouseEvent &event); - void showBar(std::string name, bool isVisible); + void showBar(std::string name, bool visible); void updateBars(); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 7e43c9954..e43ab35bc 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -879,7 +879,7 @@ void PopupMenu::handleLink(const std::string &link, } else if (link == "heal" && being && being->getType() != Being::MONSTER) { - actorSpriteManager->heal(player_node, being); + actorSpriteManager->heal(being); } else if (link == "unignore" && being && being->getType() == ActorSprite::PLAYER) @@ -1591,12 +1591,15 @@ void PopupMenu::handleLink(const std::string &link, } else if (!link.compare(0, 7, "player_")) { - mBeingId = atoi(link.substr(7).c_str()); - Being *being = actorSpriteManager->findBeing(mBeingId); - if (being) + if (actorSpriteManager) { - showPopup(getX(), getY(), being); - return; + mBeingId = atoi(link.substr(7).c_str()); + being = actorSpriteManager->findBeing(mBeingId); + if (being) + { + showPopup(getX(), getY(), being); + return; + } } } else if (!link.compare(0, 12, "hide button_")) diff --git a/src/gui/register.cpp b/src/gui/register.cpp index 913c958f2..e2c718359 100644 --- a/src/gui/register.cpp +++ b/src/gui/register.cpp @@ -62,21 +62,21 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) mTarget->requestFocus(); } -RegisterDialog::RegisterDialog(LoginData *loginData): +RegisterDialog::RegisterDialog(LoginData *data): Window(_("Register")), mEmailField(0), mMaleButton(0), mFemaleButton(0), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { int optionalActions = Net::getLoginHandler()->supportedOptionalActions(); gcn::Label *userLabel = new Label(_("Name:")); gcn::Label *passwordLabel = new Label(_("Password:")); gcn::Label *confirmLabel = new Label(_("Confirm:")); - mUserField = new TextField(loginData->username); - mPasswordField = new PasswordField(loginData->password); + mUserField = new TextField(mLoginData->username); + mPasswordField = new PasswordField(mLoginData->password); mConfirmField = new PasswordField; mRegisterButton = new Button(_("Register"), "register", this); mCancelButton = new Button(_("Cancel"), "cancel", this); @@ -161,7 +161,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) const std::string user = mUserField->getText(); logger->log("RegisterDialog::register Username is %s", user.c_str()); - std::string errorMessage; + std::string errorMsg; int error = 0; unsigned int minUser = Net::getLoginHandler()->getMinUserNameLength(); @@ -172,7 +172,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) if (user.length() < minUser) { // Name too short - errorMessage = strprintf + errorMsg = strprintf (_("The username needs to be at least %d characters long."), minUser); error = 1; @@ -180,7 +180,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (user.length() > maxUser - 1 ) { // Name too long - errorMessage = strprintf + errorMsg = strprintf (_("The username needs to be less than %d characters long."), maxUser); error = 1; @@ -188,7 +188,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (mPasswordField->getText().length() < minPass) { // Pass too short - errorMessage = strprintf + errorMsg = strprintf (_("The password needs to be at least %d characters long."), minPass); error = 2; @@ -196,7 +196,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (mPasswordField->getText().length() > maxPass - 1 ) { // Pass too long - errorMessage = strprintf + errorMsg = strprintf (_("The password needs to be less than %d characters long."), maxPass); error = 2; @@ -204,7 +204,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) else if (mPasswordField->getText() != mConfirmField->getText()) { // Password does not match with the confirmation one - errorMessage = _("Passwords do not match."); + errorMsg = _("Passwords do not match."); error = 2; } @@ -225,7 +225,7 @@ void RegisterDialog::action(const gcn::ActionEvent &event) mWrongDataNoticeListener->setTarget(this->mPasswordField); } - OkDialog *dlg = new OkDialog(_("Error"), errorMessage); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 8dd7f929d..b196ae4e4 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -48,8 +48,8 @@ char *strBuf; class SDLTextChunk { public: - SDLTextChunk(const std::string &text, const gcn::Color &color) : - img(0), text(text), color(color) + SDLTextChunk(const std::string &text0, const gcn::Color &color0) : + img(0), text(text0), color(color0) { } diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 763c190d6..f9d6ebfd0 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -548,7 +548,7 @@ void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent) void ServerDialog::logic() { { - MutexLocker lock(&mMutex); + MutexLocker tempLock(&mMutex); if (mDownloadStatus == DOWNLOADING_COMPLETE) { mDownloadStatus = DOWNLOADING_OVER; @@ -636,11 +636,11 @@ void ServerDialog::loadServers(bool addNew) return; } - int version = XML::getProperty(rootNode, "version", 0); - if (version != 1) + int ver = XML::getProperty(rootNode, "version", 0); + if (ver != 1) { logger->log("Error: unsupported online server list version: %d", - version); + ver); return; } @@ -703,7 +703,7 @@ void ServerDialog::loadServers(bool addNew) server.version.first = gui->getFont()->getWidth(version); server.version.second = version; - MutexLocker lock(&mMutex); + MutexLocker tempLock(&mMutex); // Add the server to the local list if it's not already present bool found = false; for (unsigned int i = 0; i < mServers.size(); i++) diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 7bbcd9a2c..bc210075a 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -478,20 +478,20 @@ void Setup_Video::apply() fullscreen = !fullscreen; if (!mainGraphics->setFullscreen(fullscreen)) { - std::stringstream errorMessage; + std::stringstream errorMsg; if (fullscreen) { - errorMessage << _("Failed to switch to windowed mode " - "and restoration of old mode also " - "failed!") << std::endl; + errorMsg << _("Failed to switch to windowed mode " + "and restoration of old mode also " + "failed!") << std::endl; } else { - errorMessage << _("Failed to switch to fullscreen mode" - " and restoration of old mode also " - "failed!") << std::endl; + errorMsg << _("Failed to switch to fullscreen mode" + " and restoration of old mode also " + "failed!") << std::endl; } - logger->error(errorMessage.str()); + logger->error(errorMsg.str()); } } #if defined(WIN32) || defined(__APPLE__) diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index 5cf1573bb..c62c3254c 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -596,7 +596,7 @@ void ShopWindow::sendMessage(const std::string &nick, if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else if (chatWindow) - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); //here was true } diff --git a/src/gui/socialwindow.cpp b/src/gui/socialwindow.cpp index 7feca8bf4..886894564 100644 --- a/src/gui/socialwindow.cpp +++ b/src/gui/socialwindow.cpp @@ -962,7 +962,7 @@ public: { name = *i; } - Avatar *ava = new Avatar(name); + ava = new Avatar(name); ava->setOnline(true); ava->setLevel(level); ava->setType(MapItem::PRIORITY); @@ -997,7 +997,7 @@ public: { name = *i; } - Avatar *ava = new Avatar(name); + ava = new Avatar(name); ava->setOnline(true); ava->setLevel(level); ava->setType(MapItem::ATTACK); @@ -1032,7 +1032,7 @@ public: { name = *i; } - Avatar *ava = new Avatar(name); + ava = new Avatar(name); ava->setOnline(false); ava->setLevel(level); ava->setType(MapItem::IGNORE_); diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 9d759c4a2..1e18da57a 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -61,11 +61,11 @@ class IconsModal : public gcn::ListModel public: IconsModal() { - std::map info = ItemDB::getItemInfos(); + std::map items = ItemDB::getItemInfos(); std::list tempStrings; for (std::map::const_iterator - i = info.begin(), i_end = info.end(); + i = items.begin(), i_end = items.end(); i != i_end; ++i) { if (i->first < 0) diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp index 3c19ee9c2..d0ae67746 100644 --- a/src/gui/tradewindow.cpp +++ b/src/gui/tradewindow.cpp @@ -443,10 +443,10 @@ void TradeWindow::initTrade(std::string nick) bool TradeWindow::checkItem(Item *item) { - Item *tradeItem = mMyInventory->findItem( + Item *tItem = mMyInventory->findItem( item->getId(), item->getColor()); - if (tradeItem && (tradeItem->getQuantity() > 1 + if (tItem && (tItem->getQuantity() > 1 || item->getQuantity() > 1)) { if (localChatTab) diff --git a/src/gui/unregisterdialog.cpp b/src/gui/unregisterdialog.cpp index 568e0613e..e875000c4 100644 --- a/src/gui/unregisterdialog.cpp +++ b/src/gui/unregisterdialog.cpp @@ -46,10 +46,10 @@ #include "debug.h" -UnRegisterDialog::UnRegisterDialog(LoginData *loginData): +UnRegisterDialog::UnRegisterDialog(LoginData *data): Window(_("Unregister"), true), mWrongDataNoticeListener(new WrongDataNoticeListener), - mLoginData(loginData) + mLoginData(data) { gcn::Label *userLabel = new Label(strprintf(_("Name: %s"), mLoginData-> username.c_str())); @@ -108,7 +108,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) logger->log("UnregisterDialog::unregistered, Username is %s", username.c_str()); - std::stringstream errorMessage; + std::stringstream errorMsg; bool error = false; unsigned int min = Net::getLoginHandler()->getMinPasswordLength(); @@ -118,15 +118,15 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) if (password.length() < min) { // Pass too short - errorMessage << strprintf(_("The password needs to be at least %d " - "characters long."), min); + errorMsg << strprintf(_("The password needs to be at least %d " + "characters long."), min); error = true; } else if (password.length() > max - 1) { // Pass too long - errorMessage << strprintf(_("The password needs to be less than " - "%d characters long."), max); + errorMsg << strprintf(_("The password needs to be less than " + "%d characters long."), max); error = true; } @@ -134,7 +134,7 @@ void UnRegisterDialog::action(const gcn::ActionEvent &event) { mWrongDataNoticeListener->setTarget(this->mPasswordField); - OkDialog *dlg = new OkDialog(_("Error"), errorMessage.str()); + OkDialog *dlg = new OkDialog(_("Error"), errorMsg.str()); dlg->addActionListener(mWrongDataNoticeListener); } else diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 073697459..461dd581d 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -489,7 +489,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) if (actorSpriteManager) { if (player_node != mHoverBeing || mSelfMouseHeal) - actorSpriteManager->heal(player_node, mHoverBeing); + actorSpriteManager->heal(mHoverBeing); } } else if (player_node->withinAttackRange(mHoverBeing) || diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 29fca7662..18dc48417 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -330,7 +330,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) Being* being = actorSpriteManager->findBeingByName(ava->getName(), Being::PLAYER); if (being) - actorSpriteManager->heal(player_node, being); + actorSpriteManager->heal(being); } else { diff --git a/src/gui/widgets/mouseevent.h b/src/gui/widgets/mouseevent.h index 5e9a46cfd..9484be0a5 100644 --- a/src/gui/widgets/mouseevent.h +++ b/src/gui/widgets/mouseevent.h @@ -28,12 +28,12 @@ class MouseEvent : public gcn::MouseEvent { public: - MouseEvent(gcn::Widget* source, bool isShiftPressed, - bool isControlPressed, bool isAltPressed, - bool isMetaPressed, unsigned int type, unsigned int button, + MouseEvent(gcn::Widget* source, bool shiftPressed, + bool controlPressed, bool altPressed, + bool metaPressed, unsigned int type, unsigned int button, int x, int y, int clickCount) : - gcn::MouseEvent(source, isShiftPressed, isControlPressed, - isAltPressed, isMetaPressed, type, button, x, y, + gcn::MouseEvent(source, shiftPressed, controlPressed, + altPressed, metaPressed, type, button, x, y, clickCount) { } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index eaec791ee..487035350 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -315,13 +315,13 @@ void WindowMenu::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) mTextPopup->hide(); } -void WindowMenu::showButton(std::string name, bool isVisible) +void WindowMenu::showButton(std::string name, bool visible) { Button *btn = dynamic_cast(mButtonNames[name]); if (!btn) return; - btn->setVisible(isVisible); + btn->setVisible(visible); updateButtons(); saveButtons(); } diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 6572fe470..739a302ba 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -72,7 +72,7 @@ class WindowMenu : public Container, std::vector &getButtons() { return mButtons; } - void showButton(std::string name, bool isVisible); + void showButton(std::string name, bool visible); void loadButtons(); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index fdbc4b0b7..b19b1b9af 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -3674,9 +3674,9 @@ void LocalPlayer::followMoveTo(Being *being, int x1, int y1, int x2, int y2) { if (actorSpriteManager) { - Being *being = actorSpriteManager->findBeingByName( - mPlayerFollowed, Being::PLAYER); - setTarget(being); + Being *b = actorSpriteManager->findBeingByName( + mPlayerFollowed, Being::PLAYER); + setTarget(b); } } moveToTarget(); diff --git a/src/map.cpp b/src/map.cpp index e5b3632b6..86d1171f0 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -114,10 +114,10 @@ void TileAnimation::update(int ticks) } } -MapLayer::MapLayer(int x, int y, int width, int height, bool isFringeLayer): +MapLayer::MapLayer(int x, int y, int width, int height, bool fringeLayer): mX(x), mY(y), mWidth(width), mHeight(height), - mIsFringeLayer(isFringeLayer), + mIsFringeLayer(fringeLayer), mHighlightAttackRange(config.getBoolValue("highlightAttackRange")) { const int size = mWidth * mHeight; @@ -1592,9 +1592,9 @@ void Map::addParticleEffect(const std::string &effectFile, particleEffects.push_back(newEffect); } -void Map::initializeParticleEffects(Particle *particleEngine) +void Map::initializeParticleEffects(Particle *engine) { - if (!particleEngine) + if (!engine) return; Particle *p; @@ -1605,7 +1605,7 @@ void Map::initializeParticleEffects(Particle *particleEngine) i = particleEffects.begin(); i != particleEffects.end(); ++i) { - p = particleEngine->addEffect(i->file, i->x, i->y); + p = engine->addEffect(i->file, i->x, i->y); if (p && i->w > 0 && i->h > 0) p->adjustEmitterSize(i->w, i->h); } diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index 685562d6f..f38d17a59 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -70,7 +70,7 @@ void BuySellHandler::requestSellList(std::string nick) else { if (chatWindow) - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } } @@ -89,7 +89,7 @@ void BuySellHandler::requestBuyList(std::string nick) else { if (chatWindow) - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } } @@ -102,12 +102,12 @@ void BuySellHandler::sendBuyRequest(std::string nick, ShopItem* item, return; } std::string data = strprintf("!buyitem %d %d %d", - item->getId(), item->getPrice(), amount); + item->getId(), item->getPrice(), amount); if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } void BuySellHandler::sendSellRequest(std::string nick, ShopItem* item, @@ -120,12 +120,12 @@ void BuySellHandler::sendSellRequest(std::string nick, ShopItem* item, } std::string data = strprintf("!sellitem %d %d %d", - item->getId(), item->getPrice(), amount); + item->getId(), item->getPrice(), amount); if (config.getBoolValue("hideShopMessages")) Net::getChatHandler()->privateMessage(nick, data); else - chatWindow->whisper(nick, data, BY_PLAYER); + chatWindow->addWhisper(nick, data, BY_PLAYER); } void BuySellHandler::processNpcBuySellChoice(Net::MessageIn &msg) diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 5737cc2b2..c18b1bb9a 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -125,7 +125,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg) case 0x01: if (chatWindow) { - chatWindow->whisper(nick, + chatWindow->addWhisper(nick, strprintf(_("Whisper could not be " "sent, %s is offline."), nick.c_str()), BY_SERVER); } @@ -133,7 +133,7 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg) case 0x02: if (chatWindow) { - chatWindow->whisper(nick, + chatWindow->addWhisper(nick, strprintf(_("Whisper could not " "be sent, ignored by %s."), nick.c_str()), BY_SERVER); @@ -183,7 +183,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) if (tradeBot) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); shopWindow->giveList(nick, ShopWindow::SELL); } @@ -193,7 +193,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) if (tradeBot) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); shopWindow->giveList(nick, ShopWindow::BUY); } @@ -201,7 +201,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) else if (chatMsg.find("!buyitem ") == 0) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); if (tradeBot) { shopWindow->processRequest(nick, chatMsg, @@ -211,7 +211,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) else if (chatMsg.find("!sellitem ") == 0) { if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); if (tradeBot) { shopWindow->processRequest(nick, chatMsg, @@ -223,7 +223,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) { chatMsg = chatMsg.erase(0, 2); if (showMsg && chatWindow) - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); if (chatMsg.find("B1") == 0 || chatMsg.find("S1") == 0) { @@ -232,12 +232,12 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) } else if (chatWindow) { - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); } } else if (chatWindow) { - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); } } else @@ -246,7 +246,7 @@ void ChatHandler::processWhisper(Net::MessageIn &msg) || (chatMsg.find("!selllist") != 0 && chatMsg.find("!buylist") != 0))) { - chatWindow->whisper(nick, chatMsg); + chatWindow->addWhisper(nick, chatMsg); } } } diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 4be4ddaa6..cb1e84673 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -114,15 +114,15 @@ class InventoryItem int refine; bool equip; - InventoryItem(int slot, int id, int quantity, int refine, - unsigned char color, bool equip) + InventoryItem(int slot0, int id0, int quantity0, int refine0, + unsigned char color0, bool equip0) { - this->slot = slot; - this->id = id; - this->quantity = quantity; - this->refine = refine; - this->color = color; - this->equip = equip; + slot = slot0; + id = id0; + quantity = quantity0; + refine = refine0; + color = color0; + equip = equip0; } }; diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp index 85323b11a..16552018e 100644 --- a/src/net/manaserv/chathandler.cpp +++ b/src/net/manaserv/chathandler.cpp @@ -231,7 +231,7 @@ void ChatHandler::handlePrivateMessage(Net::MessageIn &msg) std::string userNick = msg.readString(); std::string chatMsg = msg.readString(); - chatWindow->whisper(userNick, chatMsg); + chatWindow->addWhisper(userNick, chatMsg); } void ChatHandler::handleAnnouncement(Net::MessageIn &msg) diff --git a/src/net/tmwa/adminhandler.cpp b/src/net/tmwa/adminhandler.cpp index a332b04fa..5d5034938 100644 --- a/src/net/tmwa/adminhandler.cpp +++ b/src/net/tmwa/adminhandler.cpp @@ -89,7 +89,7 @@ void AdminHandler::localAnnounce(const std::string &text) outMsg.writeString(text, static_cast(text.length())); } -void AdminHandler::hide(bool hide A_UNUSED) +void AdminHandler::hide(bool h A_UNUSED) { MessageOut outMsg(CMSG_ADMIN_HIDE); outMsg.writeInt32(0); //unused diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h index 79f41dece..53fd4831f 100644 --- a/src/net/tmwa/adminhandler.h +++ b/src/net/tmwa/adminhandler.h @@ -50,7 +50,7 @@ class AdminHandler : public MessageHandler, public Ea::AdminHandler void localAnnounce(const std::string &text); - void hide(bool hide); + void hide(bool h); void kick(int playerId); }; diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp index c087ab43d..845c30f19 100644 --- a/src/net/tmwa/beinghandler.cpp +++ b/src/net/tmwa/beinghandler.cpp @@ -445,7 +445,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) Being *dstBeing; int hairStyle, hairColor; unsigned char colors[9]; - Uint8 dir; + // An update about a player, potentially including movement. int id = msg.readInt32(); @@ -469,7 +469,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) return; } - dir = dstBeing->getDirectionDelayed(); + Uint8 dir = dstBeing->getDirectionDelayed(); if (dir) { if (dir != dstBeing->getDirection()) @@ -568,10 +568,10 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) if (srcX != dstX || srcY != dstY) { - int dir = dstBeing->calcDirection(dstX, dstY); + int d = dstBeing->calcDirection(dstX, dstY); - if (dir && dstBeing->getDirection() != dir) - dstBeing->setDirectionDelayed(static_cast(dir)); + if (d && dstBeing->getDirection() != d) + dstBeing->setDirectionDelayed(static_cast(d)); } if (player_node->getCurrentAction() != Being::STAND) @@ -584,7 +584,7 @@ void BeingHandler::processPlayerMoveUpdate(Net::MessageIn &msg, int msgType) } else { - Uint8 dir; +// Uint8 dir; Uint16 x, y; msg.readCoordinates(x, y, dir); dstBeing->setTileCoords(x, y); diff --git a/src/party.cpp b/src/party.cpp index 9becee1cd..9da1a235d 100644 --- a/src/party.cpp +++ b/src/party.cpp @@ -119,9 +119,9 @@ void Party::removeMember(PartyMember *member) if ((*itr)->mId == member->mId && (*itr)->getName() == member->getName()) { - PartyMember *member = (*itr); + PartyMember *m = (*itr); mMembers.erase(itr); - delete member; + delete m; deleted = true; break; } diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index a61483940..b93c11ba6 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -38,12 +38,12 @@ struct Attack std::string particleEffect; std::string missileParticle; - Attack(std::string action, std::string particleEffect, - std::string missileParticle) + Attack(std::string action0, std::string particleEffect0, + std::string missileParticle0) { - this->action = action; - this->particleEffect = particleEffect; - this->missileParticle = missileParticle; + action = action0; + particleEffect = particleEffect0; + missileParticle = missileParticle0; } }; -- 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') 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 22a66542b07a4238ef55e0a4aace09a62f416103 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 9 Sep 2011 23:30:36 +0300 Subject: Fix code style. --- src/gui/setup_video.cpp | 3 ++- src/localplayer.cpp | 5 +++-- src/utils/sha256.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index e0f03ec60..e9811a920 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -702,7 +702,8 @@ void Setup_Video::action(const gcn::ActionEvent &event) else if (id == "altfpslimitslider") { int tempFps = static_cast(mAltFpsSlider->getValue()); - tempFps = tempFps > 0 ? tempFps : static_cast(mAltFpsSlider->getScaleStart()); + tempFps = tempFps > 0 ? tempFps : static_cast( + mAltFpsSlider->getScaleStart()); mAltFps = tempFps; const std::string text = mAltFps > 0 ? toString(mAltFps) : _("None"); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index b19b1b9af..ff93cdbf1 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -2445,8 +2445,6 @@ void LocalPlayer::crazyMoveA() // direction command else if (mMoveProgram[mCrazyMoveState] == 'd') { - Uint8 dir = 0; - mCrazyMoveState ++; if (mCrazyMoveState < mMoveProgram.length()) @@ -2492,6 +2490,7 @@ void LocalPlayer::crazyMoveA() case 'L': if (Client::limitPackets(PACKET_DIRECTION)) { + Uint8 dir = 0; switch (getDirection()) { case UP : dir = Being::LEFT; break; @@ -2507,6 +2506,7 @@ void LocalPlayer::crazyMoveA() case 'R': if (Client::limitPackets(PACKET_DIRECTION)) { + Uint8 dir = 0; switch (getDirection()) { case UP : dir = Being::RIGHT; break; @@ -2522,6 +2522,7 @@ void LocalPlayer::crazyMoveA() case 'b': if (Client::limitPackets(PACKET_DIRECTION)) { + Uint8 dir = 0; switch (getDirection()) { case UP : dir = Being::DOWN; break; diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp index dab01a1ea..5d3e4c1d2 100644 --- a/src/utils/sha256.cpp +++ b/src/utils/sha256.cpp @@ -254,7 +254,7 @@ void SHA256Update(SHA256Context *ctx, SHA256Transform(ctx, ctx->block, 1); SHA256Transform(ctx, shifted_message, block_nb); rem_len = new_len % SHA256_BLOCK_SIZE; - memcpy(ctx->block, &shifted_message[block_nb << 6],rem_len); + memcpy(ctx->block, &shifted_message[block_nb << 6], rem_len); ctx->len = rem_len; ctx->tot_len += (block_nb + 1) << 6; } -- cgit v1.2.3-60-g2f50 From 13670eefeb4b256c20b603a845eb89f5221a32e5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 10 Sep 2011 15:48:22 +0300 Subject: Change empty strings initializations. --- src/being.cpp | 2 +- src/commandhandler.cpp | 4 +-- src/configuration.cpp | 2 +- src/gui/chatwindow.cpp | 2 +- src/gui/logindialog.cpp | 4 +-- src/gui/minimap.cpp | 2 +- src/gui/npcdialog.cpp | 4 +-- src/gui/setup_video.cpp | 2 +- src/gui/widgets/chattab.cpp | 2 +- src/map.cpp | 2 +- src/net/ea/gui/guildtab.cpp | 2 +- src/net/ea/partyhandler.cpp | 2 +- src/net/manaserv/charhandler.cpp | 4 +-- src/net/manaserv/generalhandler.cpp | 2 +- src/resources/iteminfo.cpp | 2 +- src/resources/spritedef.h | 2 +- src/spellmanager.cpp | 4 +-- src/textcommand.cpp | 62 ++++++++++++++++++------------------- src/utils/sha256.cpp | 2 +- src/utils/stringutils.cpp | 4 +-- 20 files changed, 55 insertions(+), 57 deletions(-) (limited to 'src/gui') diff --git a/src/being.cpp b/src/being.cpp index 883bde321..da83f1f73 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -1277,7 +1277,7 @@ void Being::logic() case ATTACK: { - std::string particleEffect = ""; + std::string particleEffect(""); if (!mActionTime) break; diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index d16a7db27..5de5eb2cf 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -355,8 +355,8 @@ void CommandHandler::handleWho(const std::string &args A_UNUSED, void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) { - std::string recvnick = ""; - std::string msg = ""; + std::string recvnick(""); + std::string msg(""); if (args.substr(0, 1) == "\"") { diff --git a/src/configuration.cpp b/src/configuration.cpp index a6ef27815..94c0dce37 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -262,7 +262,7 @@ int Configuration::resetIntValue(const std::string &key) std::string Configuration::getStringValue(const std::string &key) const { GETLOG(); - std::string defaultValue = ""; + std::string defaultValue(""); Options::const_iterator iter = mOptions.find(key); if (iter == mOptions.end()) { diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index f3e4b88b8..2bada256c 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -1074,7 +1074,7 @@ std::string ChatWindow::addColors(std::string &msg) return msg; } - std::string newMsg = ""; + std::string newMsg(""); int cMap[] = {1, 4, 5, 2, 3, 6, 7, 9, 0, 8}; // rainbow diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index adf499f75..26248059c 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -50,8 +50,8 @@ static const int LOGIN_DIALOG_WIDTH = 300; static const int LOGIN_DIALOG_HEIGHT = 140; static const int FIELD_WIDTH = LOGIN_DIALOG_WIDTH - 70; -std::string LoginDialog::savedPassword = ""; -std::string LoginDialog::savedPasswordKey = ""; +std::string LoginDialog::savedPassword(""); +std::string LoginDialog::savedPasswordKey(""); const char *UPDATE_TYPE_TEXT[3] = diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index a16da2b65..70bbc1dad 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -89,7 +89,7 @@ Minimap::~Minimap() void Minimap::setMap(Map *map) { - std::string caption = ""; + std::string caption(""); std::string minimapName; if (map) diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index d941153b7..3956b47ac 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -228,8 +228,8 @@ void NpcDialog::action(const gcn::ActionEvent &event) } else if (mActionState == NPC_ACTION_INPUT) { - std::string printText = ""; // Text that will get printed - // in the textbox + std::string printText(""); // Text that will get printed + // in the textbox if (mInputState == NPC_INPUT_LIST) { diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index e9811a920..d3c1163dc 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -179,7 +179,7 @@ void ModeListModel::addCustomMode(std::string mode) int ModeListModel::getIndexOf(const std::string &widthXHeightMode) { - std::string currentMode = ""; + std::string currentMode(""); for (int i = 0; i < getNumberOfElements(); i++) { currentMode = getElementAt(i); diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 4f358c8e7..485e96e74 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -337,7 +337,7 @@ void ChatTab::chatInput(const std::string &message) start = msg.find('[', start + 1); } - std::string temp = ""; + std::string temp(""); if (start + 1 < msg.length() && end < msg.length() && end > start + 1) { diff --git a/src/map.cpp b/src/map.cpp index 86d1171f0..3e83f2e6c 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2217,7 +2217,7 @@ MapItem::~MapItem() void MapItem::setType(int type) { - std::string name = ""; + std::string name(""); mType = type; if (mImage) mImage->decRef(); diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index ab030be83..9836f5fa9 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -101,7 +101,7 @@ bool GuildTab::handleCommand(const std::string &type, const std::string &args) else if (type == "notice" && taGuild) { std::string str1 = args.substr(0, 60); - std::string str2 = ""; + std::string str2(""); if (args.size() > 60) str2 = args.substr(60); Net::getGuildHandler()->changeNotice(taGuild->getId(), str1, str2); diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index bd6f19d97..e006b9c71 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -203,7 +203,7 @@ void PartyHandler::processPartyInvited(Net::MessageIn &msg) { int id = msg.readInt32(); std::string partyName = msg.readString(24); - std::string nick = ""; + std::string nick(""); Being *being; if (actorSpriteManager) diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index 3b2306feb..42db6e621 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -138,7 +138,7 @@ void CharHandler::handleCharacterCreateResponse(Net::MessageIn &msg) if (errMsg != ERRMSG_OK) { // Character creation failed - std::string errorMessage = ""; + std::string errorMessage(""); switch (errMsg) { case ERRMSG_NO_LOGIN: @@ -212,7 +212,7 @@ void CharHandler::handleCharacterDeleteResponse(Net::MessageIn &msg) else { // Character deletion failed - std::string errorMessage = ""; + std::string errorMessage(""); switch (errMsg) { case ERRMSG_NO_LOGIN: diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp index 9e32f139d..2eea6cdf6 100644 --- a/src/net/manaserv/generalhandler.cpp +++ b/src/net/manaserv/generalhandler.cpp @@ -64,7 +64,7 @@ namespace ManaServ Connection *accountServerConnection = 0; Connection *chatServerConnection = 0; Connection *gameServerConnection = 0; -std::string netToken = ""; +std::string netToken(""); ServerInfo gameServer; ServerInfo chatServer; diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 75e6e1d8c..a5b81081c 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -108,7 +108,7 @@ const std::string &ItemInfo::getSprite(Gender gender) const } else { - static const std::string empty = ""; + static const std::string empty(""); std::map::const_iterator i = mAnimationFiles.find(gender); diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index ccad62b1b..b2939fca1 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -86,7 +86,7 @@ namespace SpriteAction static const std::string CAST_MAGIC = "magic"; static const std::string USE_ITEM = "item"; static const std::string SPAWN = "spawn"; - static const std::string INVALID = ""; + static const std::string INVALID(""); } enum SpriteDirection diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index fcdf94039..9f777f9e4 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -184,8 +184,8 @@ std::string SpellManager::parseCommand(std::string command, if (!player_node) return command; - std::string name = ""; - std::string id = ""; + std::string name(""); + std::string id(""); std::string name2; if (target) diff --git a/src/textcommand.cpp b/src/textcommand.cpp index 665668c7e..33dff85aa 100644 --- a/src/textcommand.cpp +++ b/src/textcommand.cpp @@ -35,18 +35,18 @@ TextCommand::TextCommand(unsigned int id, std::string symbol, std::string icon, unsigned int basicLvl, MagicSchool school, unsigned int schoolLvl, int mana) : + mCommand(command), + mSymbol(symbol), + mTargetType(type), + mIcon(icon), + mId(id), + mMana(mana), + mSchool(school), + mBaseLvl(basicLvl), + mSchoolLvl(schoolLvl), + mCommandType(TEXT_COMMAND_MAGIC), mImage(0) { - mId = id; - mCommand = command; - mSymbol = symbol; - mTargetType = type; - mIcon = icon; - mBaseLvl = basicLvl; - mSchool = school; - mSchoolLvl = schoolLvl; - mMana = mana; - mCommandType = TEXT_COMMAND_MAGIC; loadImage(); } @@ -54,36 +54,34 @@ TextCommand::TextCommand(unsigned int id, std::string symbol, TextCommand::TextCommand(unsigned int id, std::string symbol, std::string command, SpellTarget type, std::string icon) : + mCommand(command), + mSymbol(symbol), + mTargetType(type), + mIcon(icon), + mId(id), + mMana(0), + mSchool(SKILL_MAGIC), + mBaseLvl(0), + mSchoolLvl(0), + mCommandType(TEXT_COMMAND_TEXT), mImage(0) { - mId = id; - mCommand = command; - mSymbol = symbol; - mTargetType = type; - mIcon = icon; - mCommandType = TEXT_COMMAND_TEXT; - mBaseLvl = 0; - mSchool = SKILL_MAGIC; - mSchoolLvl = 0; - mMana = 0; - mCommandType = TEXT_COMMAND_TEXT; loadImage(); } TextCommand::TextCommand(unsigned int id) : + mCommand(""), + mSymbol(""), + mTargetType(NOTARGET), + mIcon(""), + mId(id), + mMana(0), + mSchool(SKILL_MAGIC), + mBaseLvl(0), + mSchoolLvl(0), + mCommandType(TEXT_COMMAND_TEXT), mImage(0) { - mId = id; - mCommand = ""; - mSymbol = ""; - mTargetType = NOTARGET; - mIcon = ""; - mCommandType = TEXT_COMMAND_TEXT; - mBaseLvl = 0; - mSchool = SKILL_MAGIC; - mSchoolLvl = 0; - mMana = 0; - mCommandType = TEXT_COMMAND_TEXT; loadImage(); } diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp index 5d3e4c1d2..1e7143300 100644 --- a/src/utils/sha256.cpp +++ b/src/utils/sha256.cpp @@ -283,7 +283,7 @@ std::string SHA256Hash(const char *src, int len) SHA256Final(&ctx, bytehash); // Convert it to hex const char* hxc = "0123456789abcdef"; - std::string hash = ""; + std::string hash(""); for (int i = 0; i < SHA256_DIGEST_SIZE; i++) { hash += hxc[bytehash[i] / 16]; diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index efe5f9efb..6c50d4019 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -465,7 +465,7 @@ std::string combineDye2(std::string file, std::string dye) if (pos != std::string::npos) { std::string dye1 = file.substr(pos + 1); - std::string str = ""; + std::string str(""); file = file.substr(0, pos); std::list list1 = splitToStringList(dye1, ';'); std::list list2 = splitToStringList(dye, ';'); @@ -505,7 +505,7 @@ std::vector getLang() std::string packList(std::list &list) { std::list::const_iterator i = list.begin(); - std::string str = ""; + std::string str(""); while (i != list.end()) { str = str + (*i) + "|"; -- cgit v1.2.3-60-g2f50 From dba5ec4c1f249599a5f718fe4e532c66e917ffa9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 10 Sep 2011 20:24:23 +0300 Subject: Remove some push/pop clip areas. --- src/graphics.cpp | 24 ++++++++++++------------ src/gui/widgets/radiobutton.cpp | 10 +--------- 2 files changed, 13 insertions(+), 21 deletions(-) (limited to 'src/gui') diff --git a/src/graphics.cpp b/src/graphics.cpp index 61f98b2a7..37fd72c08 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -346,7 +346,7 @@ void Graphics::drawImageRect(int x, int y, int w, int h, Image *bottom, Image *left, Image *center) { - pushClipArea(gcn::Rectangle(x, y, w, h)); +// pushClipArea(gcn::Rectangle(x, y, w, h)); const bool drawMain = center && topLeft && topRight && bottomLeft && bottomRight; @@ -355,7 +355,7 @@ void Graphics::drawImageRect(int x, int y, int w, int h, if (center && drawMain) { drawImagePattern(center, - topLeft->getWidth(), topLeft->getHeight(), + topLeft->getWidth() + x, topLeft->getHeight() + y, w - topLeft->getWidth() - topRight->getWidth(), h - topLeft->getHeight() - bottomLeft->getHeight()); } @@ -364,18 +364,18 @@ void Graphics::drawImageRect(int x, int y, int w, int h, if (top && left && bottom && right) { drawImagePattern(top, - left->getWidth(), 0, + x + left->getWidth(), y, w - left->getWidth() - right->getWidth(), top->getHeight()); drawImagePattern(bottom, - left->getWidth(), h - bottom->getHeight(), + x + left->getWidth(), h - bottom->getHeight() + y, w - left->getWidth() - right->getWidth(), bottom->getHeight()); drawImagePattern(left, - 0, top->getHeight(), + x, y + top->getHeight(), left->getWidth(), h - top->getHeight() - bottom->getHeight()); drawImagePattern(right, - w - right->getWidth(), top->getHeight(), + x + w - right->getWidth(), top->getHeight() + y, right->getWidth(), h - top->getHeight() - bottom->getHeight()); } @@ -383,15 +383,15 @@ void Graphics::drawImageRect(int x, int y, int w, int h, // Draw the corners if (drawMain) { - drawImage(topLeft, 0, 0); - drawImage(topRight, w - topRight->getWidth(), 0); - drawImage(bottomLeft, 0, h - bottomLeft->getHeight()); + drawImage(topLeft, x, y); + drawImage(topRight, x + w - topRight->getWidth(), y); + drawImage(bottomLeft, x, h - bottomLeft->getHeight() + y); drawImage(bottomRight, - w - bottomRight->getWidth(), - h - bottomRight->getHeight()); + x + w - bottomRight->getWidth(), + y + h - bottomRight->getHeight()); } - popClipArea(); +// popClipArea(); } void Graphics::drawImageRect(int x, int y, int w, int h, diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index e641be323..feedeae7b 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -136,23 +136,16 @@ void RadioButton::drawBox(gcn::Graphics* graphics) } if (box) - static_cast(graphics)->drawImage(box, 2, 2); + static_cast(graphics)->drawImage(box, 3, 3); } void RadioButton::draw(gcn::Graphics* graphics) { - graphics->pushClipArea(gcn::Rectangle(1, 1, getWidth() - 1, - getHeight() - 1)); - drawBox(graphics); - graphics->popClipArea(); - graphics->setFont(getFont()); graphics->setColor(getForegroundColor()); -// int h = getHeight() + getHeight() / 2; -// graphics->drawText(getCaption(), h - 2, 0); graphics->drawText(getCaption(), 16, 0); } @@ -165,4 +158,3 @@ void RadioButton::mouseExited(gcn::MouseEvent& event A_UNUSED) { mHasMouse = false; } - -- 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') 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 From 632c1797013d8b0a987ab68341b50354afdb1f9d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 11 Sep 2011 00:46:34 +0300 Subject: Add support for padding in theme configuration files. --- src/gui/theme.cpp | 223 +++++++++++++++++++++++---------------------- src/gui/theme.h | 8 +- src/gui/widgets/window.cpp | 2 + 3 files changed, 122 insertions(+), 111 deletions(-) (limited to 'src/gui') diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 12e7736c0..15dafa997 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -65,14 +65,15 @@ static void initDefaultThemePath() Skin::Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, const std::string &filePath, - const std::string &name): + const std::string &name, int padding): instances(0), mFilePath(filePath), mName(name), mBorder(skin), mCloseImage(close), mStickyImageUp(stickyUp), - mStickyImageDown(stickyDown) + mStickyImageDown(stickyDown), + mPadding(padding) {} Skin::~Skin() @@ -321,6 +322,7 @@ Skin *Theme::readSkin(const std::string &filename) Image *dBorders = Theme::getImageFromTheme(skinSetImage); ImageRect border; memset(&border, 0, sizeof(ImageRect)); + int padding = 3; // iterate 's for_each_xml_child_node(widgetNode, rootNode) @@ -332,140 +334,143 @@ Skin *Theme::readSkin(const std::string &filename) XML::getProperty(widgetNode, "type", "unknown"); if (widgetType == "Window") { - // Iterate through 's - // LEEOR / TODO: - // We need to make provisions to load in a CloseButton image. For - // now it can just be hard-coded. for_each_xml_child_node(partNode, widgetNode) { - if (!xmlStrEqual(partNode->name, BAD_CAST "part")) - continue; - - const std::string partType = - XML::getProperty(partNode, "type", "unknown"); - // TOP ROW - const int xPos = XML::getProperty(partNode, "xpos", 0); - const int yPos = XML::getProperty(partNode, "ypos", 0); - const int width = XML::getProperty(partNode, "width", 1); - const int height = XML::getProperty(partNode, "height", 1); - - if (partType == "top-left-corner") + if (xmlStrEqual(partNode->name, BAD_CAST "part")) { - if (dBorders) + const std::string partType = + XML::getProperty(partNode, "type", "unknown"); + // TOP ROW + const int xPos = XML::getProperty(partNode, "xpos", 0); + const int yPos = XML::getProperty(partNode, "ypos", 0); + const int width = XML::getProperty(partNode, "width", 1); + const int height = XML::getProperty(partNode, "height", 1); + + if (partType == "top-left-corner") { - border.grid[0] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[0] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[0] = 0; + } } - else - { - border.grid[0] = 0; - } - } - else if (partType == "top-edge") - { - if (dBorders) + else if (partType == "top-edge") { - border.grid[1] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[1] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[1] = 0; + } } - else + else if (partType == "top-right-corner") { - border.grid[1] = 0; + if (dBorders) + { + border.grid[2] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[2] = 0; + } } - } - else if (partType == "top-right-corner") - { - if (dBorders) - { - border.grid[2] = dBorders->getSubImage( - xPos, yPos, width, height); - } - else - { - border.grid[2] = 0; - } - } - // MIDDLE ROW - else if (partType == "left-edge") - { - if (dBorders) - { - border.grid[3] = dBorders->getSubImage( - xPos, yPos, width, height); - } - else - { - border.grid[3] = 0; - } - } - else if (partType == "bg-quad") - { - if (dBorders) + // MIDDLE ROW + else if (partType == "left-edge") { - border.grid[4] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[3] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[3] = 0; + } } - else + else if (partType == "bg-quad") { - border.grid[4] = 0; + if (dBorders) + { + border.grid[4] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[4] = 0; + } } - } - else if (partType == "right-edge") - { - if (dBorders) + else if (partType == "right-edge") { - border.grid[5] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[5] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[5] = 0; + } } - else - { - border.grid[5] = 0; - } - } - // BOTTOM ROW - else if (partType == "bottom-left-corner") - { - if (dBorders) + // BOTTOM ROW + else if (partType == "bottom-left-corner") { - border.grid[6] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[6] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[6] = 0; + } } - else + else if (partType == "bottom-edge") { - border.grid[6] = 0; + if (dBorders) + { + border.grid[7] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[7] = 0; + } } - } - else if (partType == "bottom-edge") - { - if (dBorders) - { - border.grid[7] = dBorders->getSubImage( - xPos, yPos, width, height); - } - else - { - border.grid[7] = 0; - } - } - else if (partType == "bottom-right-corner") - { - if (dBorders) + else if (partType == "bottom-right-corner") { - border.grid[8] = dBorders->getSubImage( - xPos, yPos, width, height); + if (dBorders) + { + border.grid[8] = dBorders->getSubImage( + xPos, yPos, width, height); + } + else + { + border.grid[8] = 0; + } } + else { - border.grid[8] = 0; + logger->log("Theme::readSkin(): Unknown part type '%s'", + partType.c_str()); } } - - else + else if (xmlStrEqual(partNode->name, BAD_CAST "option")) { - logger->log("Theme::readSkin(): Unknown part type '%s'", - partType.c_str()); + const std::string name = XML::getProperty( + partNode, "name", ""); + if (name == "padding") + padding = XML::getProperty(partNode, "value", 3); } } } @@ -495,7 +500,7 @@ Skin *Theme::readSkin(const std::string &filename) } Skin *skin = new Skin(border, closeImage, stickyImageUp, stickyImageDown, - filename); + filename, "", padding); skin->updateAlpha(mMinimumOpacity); return skin; } diff --git a/src/gui/theme.h b/src/gui/theme.h index 46d2eee2d..92b2c8878 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -43,8 +43,8 @@ class Skin { public: Skin(ImageRect skin, Image *close, Image *stickyUp, Image *stickyDown, - const std::string &filePath, - const std::string &name = ""); + const std::string &filePath, const std::string &name = "", + int padding = 3); ~Skin(); @@ -95,6 +95,9 @@ class Skin */ void updateAlpha(float minimumOpacityAllowed = 0.0f); + int getPadding() + { return mPadding; } + int instances; private: @@ -104,6 +107,7 @@ class Skin Image *mCloseImage; /**< Close Button Image */ Image *mStickyImageUp; /**< Sticky Button Image */ Image *mStickyImageDown; /**< Sticky Button Image */ + int mPadding; }; class Theme : public Palette, public ConfigListener diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 1ffbac31e..2d4c443c6 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -86,6 +86,8 @@ Window::Window(const std::string &caption, bool modal, Window *parent, if (Theme::instance()) { mSkin = Theme::instance()->load(skin); + if (mSkin) + setPadding(mSkin->getPadding()); } else { -- cgit v1.2.3-60-g2f50 From db4361d9f7652104e818cf9a2a0f326e1c607fb8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 11 Sep 2011 04:24:30 +0300 Subject: Add own xml configuration for missing windows. --- src/gui/beingpopup.cpp | 4 ++-- src/gui/confirmdialog.cpp | 2 +- src/gui/editdialog.cpp | 2 +- src/gui/emotepopup.cpp | 3 ++- src/gui/inventorywindow.cpp | 2 +- src/gui/itemamountwindow.cpp | 2 +- src/gui/itempopup.cpp | 2 +- src/gui/ministatuswindow.cpp | 2 +- src/gui/okdialog.cpp | 2 +- src/gui/popupmenu.cpp | 2 +- src/gui/shortcutwindow.cpp | 3 ++- src/gui/spellpopup.cpp | 2 +- src/gui/statuspopup.cpp | 2 +- src/gui/statuswindow.cpp | 2 +- src/gui/textdialog.cpp | 2 +- src/gui/textpopup.cpp | 2 +- src/gui/widgets/popup.cpp | 22 +++++++++++++++++++--- src/gui/widgets/popup.h | 3 +-- 18 files changed, 39 insertions(+), 22 deletions(-) (limited to 'src/gui') diff --git a/src/gui/beingpopup.cpp b/src/gui/beingpopup.cpp index 8d7b26c1b..98df1ca9a 100644 --- a/src/gui/beingpopup.cpp +++ b/src/gui/beingpopup.cpp @@ -39,8 +39,8 @@ #include "debug.h" -BeingPopup::BeingPopup(): - Popup("BeingPopup") +BeingPopup::BeingPopup() : + Popup("BeingPopup", "beingpopup.xml") { // Being Name mBeingName = new Label("A"); diff --git a/src/gui/confirmdialog.cpp b/src/gui/confirmdialog.cpp index 661168dd9..f7f81bd2f 100644 --- a/src/gui/confirmdialog.cpp +++ b/src/gui/confirmdialog.cpp @@ -37,7 +37,7 @@ ConfirmDialog::ConfirmDialog(const std::string &title, const std::string &msg, bool ignore, bool modal, Window *parent): - Window(title, modal, parent) + Window(title, modal, parent, "confirm.xml") { mTextBox = new TextBox; mTextBox->setEditable(false); diff --git a/src/gui/editdialog.cpp b/src/gui/editdialog.cpp index da1d98e81..84f4f6ddf 100644 --- a/src/gui/editdialog.cpp +++ b/src/gui/editdialog.cpp @@ -37,7 +37,7 @@ EditDialog::EditDialog(const std::string &title, const std::string &msg, std::string eventOk, int width, Window *parent, bool modal): - Window(title, modal, parent) + Window(title, modal, parent, "edit.xml") { mTextField = new TextField; mTextField->setText(msg); diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp index 348a97952..6d2bf7be2 100644 --- a/src/gui/emotepopup.cpp +++ b/src/gui/emotepopup.cpp @@ -48,7 +48,8 @@ const int EmotePopup::gridHeight = 36; // emote icon height + 4 static const int MAX_COLUMNS = 6; -EmotePopup::EmotePopup(): +EmotePopup::EmotePopup() : + Popup("EmotePopup", "emotepopup.xml"), mSelectedEmoteIndex(-1), mHoveredEmoteIndex(-1), mRowCount(1), diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index c6afaaf1d..cd02a6732 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -96,7 +96,7 @@ public: InventoryWindow::WindowList InventoryWindow::instances; InventoryWindow::InventoryWindow(Inventory *inventory): - Window(), + Window("Inventory", false, 0, "inventory.xml"), mInventory(inventory), mDropButton(0), mSplit(false) diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index d85b38ccb..7c5b19415 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -137,7 +137,7 @@ void ItemAmountWindow::finish(Item *item, int amount, int price, Usage usage) ItemAmountWindow::ItemAmountWindow(Usage usage, Window *parent, Item *item, int maxRange): - Window("", true, parent), + Window("", true, parent, "amount.xml"), mItemPriceTextField(0), mGPLabel(0), mItem(item), diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index 4d401a627..b05d7fe28 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -49,7 +49,7 @@ #include "debug.h" ItemPopup::ItemPopup(): - Popup("ItemPopup"), + Popup("ItemPopup", "itempopup.xml"), mIcon(0), mLastName(""), mLastColor(1) diff --git a/src/gui/ministatuswindow.cpp b/src/gui/ministatuswindow.cpp index e3f441b60..3e66f42cb 100644 --- a/src/gui/ministatuswindow.cpp +++ b/src/gui/ministatuswindow.cpp @@ -52,7 +52,7 @@ extern volatile int tick_time; MiniStatusWindow::MiniStatusWindow(): - Popup("MiniStatus") + Popup("MiniStatus", "ministatus.xml") { listen(Mana::CHANNEL_ATTRIBUTES); diff --git a/src/gui/okdialog.cpp b/src/gui/okdialog.cpp index 122d7176f..5a6ee4846 100644 --- a/src/gui/okdialog.cpp +++ b/src/gui/okdialog.cpp @@ -35,7 +35,7 @@ OkDialog::OkDialog(const std::string &title, const std::string &msg, bool modal, bool showCenter, Window *parent): - Window(title, modal, parent) + Window(title, modal, parent, "ok.xml") { mTextBox = new TextBox; mTextBox->setEditable(false); diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index e43ab35bc..daf1757c3 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -83,7 +83,7 @@ std::string tradePartnerName(""); PopupMenu::PopupMenu(): - Popup("PopupMenu"), + Popup("PopupMenu", "popupmenu.xml"), mBeingId(0), mFloorItem(0), mItem(0), diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index 0492afce0..cf491c9f0 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -52,7 +52,8 @@ class ShortcutTab : public Tab ShortcutWindow::ShortcutWindow(const std::string &title, ShortcutContainer *content, - int width, int height) + int width, int height) : + Window("Window", false, 0, "shortcuts.xml") { setWindowName(title); // no title presented, title bar is padding so window can be moved. diff --git a/src/gui/spellpopup.cpp b/src/gui/spellpopup.cpp index f87e691de..c7d25e257 100644 --- a/src/gui/spellpopup.cpp +++ b/src/gui/spellpopup.cpp @@ -42,7 +42,7 @@ #include "debug.h" SpellPopup::SpellPopup(): - Popup("SpellPopup") + Popup("SpellPopup", "spellpopup.xml") { // Item Name mItemName = new Label; diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index 9214f1406..5c28641dc 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -46,7 +46,7 @@ #include "debug.h" StatusPopup::StatusPopup(): - Popup("StatusPopup") + Popup("StatusPopup", "statuspopup.xml") { const int fontHeight = getFont()->getHeight(); diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index 97130b103..0cad8732a 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -123,7 +123,7 @@ class ChangeDisplay : public AttrDisplay, gcn::ActionListener }; StatusWindow::StatusWindow(): - Window(player_node ? player_node->getName() : "?") + Window(player_node ? player_node->getName() : "?", false, 0, "status.xml") { listen(Mana::CHANNEL_ATTRIBUTES); diff --git a/src/gui/textdialog.cpp b/src/gui/textdialog.cpp index a80e25260..c1539684c 100644 --- a/src/gui/textdialog.cpp +++ b/src/gui/textdialog.cpp @@ -39,7 +39,7 @@ int TextDialog::instances = 0; TextDialog::TextDialog(const std::string &title, const std::string &msg, Window *parent, bool isPassword): - Window(title, true, parent), + Window(title, true, parent, "textdialog.xml"), mTextField(0), mPasswordField(0) { diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp index 65c712461..15b2618da 100644 --- a/src/gui/textpopup.cpp +++ b/src/gui/textpopup.cpp @@ -41,7 +41,7 @@ #include "debug.h" TextPopup::TextPopup(): - Popup("TextPopup") + Popup("TextPopup", "textpopup.xml") { const int fontHeight = getFont()->getHeight(); diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index ebfdbe303..ac282b088 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -40,7 +40,7 @@ #include "debug.h" -Popup::Popup(const std::string &name, const std::string &skin): +Popup::Popup(const std::string &name, std::string skin): mPopupName(name), mMinWidth(100), mMinHeight(40), @@ -58,8 +58,20 @@ Popup::Popup(const std::string &name, const std::string &skin): setPadding(3); + if (skin == "") + skin = "popup.xml"; + // Loads the skin - mSkin = Theme::instance()->load(skin); + if (Theme::instance()) + { + mSkin = Theme::instance()->load(skin); + if (mSkin) + setPadding(mSkin->getPadding()); + } + else + { + mSkin = 0; + } // Add this window to the window container windowContainer->add(this); @@ -76,7 +88,11 @@ Popup::~Popup() mVertexes = 0; if (mSkin) - mSkin->instances--; + { + if (Theme::instance()) + Theme::instance()->unload(mSkin); + mSkin = 0; + } } void Popup::setWindowContainer(WindowContainer *wc) diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 0ac50f69e..9d4343ba3 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -66,8 +66,7 @@ class Popup : public Container, public gcn::MouseListener, * debugging purposes. * @param skin The location where the Popup's skin XML can be found. */ - Popup(const std::string &name = "", - const std::string &skin = "window.xml"); + Popup(const std::string &name = "", std::string skin = ""); /** * Destructor. Deletes all the added widgets. -- cgit v1.2.3-60-g2f50 From aabbfa8483a13958d27a24c9b1e4fcad288fad8c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 11 Sep 2011 04:52:48 +0300 Subject: Add own theme image for progressbar. If no own image it fallback to vscroll image. --- src/gui/widgets/progressbar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index c1d6a9531..7324fc9ad 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -70,7 +70,9 @@ ProgressBar::ProgressBar(float progress, if (mInstances == 0) { - Image *dBorders = Theme::getImageFromTheme("vscroll_grey.png"); + Image *dBorders = Theme::getImageFromTheme("progress.png"); + if (!dBorders) + dBorders = Theme::getImageFromTheme("vscroll_grey.png"); if (dBorders) { mBorder.grid[0] = dBorders->getSubImage(0, 0, 4, 4); -- cgit v1.2.3-60-g2f50 From c38e43cee40cfd7cad2a92ea704aa26c23523b67 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 11 Sep 2011 16:07:26 +0300 Subject: Add own theme xml configuration for each shortcuts based window. --- src/game.cpp | 8 ++++---- src/gui/shortcutwindow.cpp | 7 +++++-- src/gui/shortcutwindow.h | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/game.cpp b/src/game.cpp index 3c7579d78..6eda01640 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -216,7 +216,7 @@ static void createGuiWindows() minimap = new Minimap; helpWindow = new HelpWindow; debugWindow = new DebugWindow; - itemShortcutWindow = new ShortcutWindow("ItemShortcut"); + itemShortcutWindow = new ShortcutWindow("ItemShortcut", "items.xml"); for (int f = 0; f < SHORTCUT_TABS; f ++) { itemShortcutWindow->addTab(toString(f + 1), @@ -230,13 +230,13 @@ static void createGuiWindows() } emoteShortcutWindow = new ShortcutWindow("EmoteShortcut", - new EmoteShortcutContainer); + new EmoteShortcutContainer, "emotes.xml"); outfitWindow = new OutfitWindow(); specialsWindow = new SpecialsWindow(); dropShortcutWindow = new ShortcutWindow("DropShortcut", - new DropShortcutContainer); + new DropShortcutContainer, "drops.xml"); - spellShortcutWindow = new ShortcutWindow("SpellShortcut", + spellShortcutWindow = new ShortcutWindow("SpellShortcut", "spells.xml", 265, 328); for (int f = 0; f < SPELL_SHORTCUT_TABS; f ++) { diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index cf491c9f0..df21488a5 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -52,8 +52,9 @@ class ShortcutTab : public Tab ShortcutWindow::ShortcutWindow(const std::string &title, ShortcutContainer *content, + std::string skinFile, int width, int height) : - Window("Window", false, 0, "shortcuts.xml") + Window("Window", false, 0, skinFile) { setWindowName(title); // no title presented, title bar is padding so window can be moved. @@ -97,7 +98,9 @@ ShortcutWindow::ShortcutWindow(const std::string &title, loadWindowState(); } -ShortcutWindow::ShortcutWindow(const std::string &title, int width, int height) +ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile, + int width, int height) : + Window("Window", false, 0, skinFile) { setWindowName(title); // no title presented, title bar is padding so window can be moved. diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h index 4301b72d1..1c91835e8 100644 --- a/src/gui/shortcutwindow.h +++ b/src/gui/shortcutwindow.h @@ -41,9 +41,10 @@ class ShortcutWindow : public Window * Constructor. */ ShortcutWindow(const std::string &title, ShortcutContainer *content, + std::string skinFile = "", int width = 0, int height = 0); - ShortcutWindow(const std::string &title, + ShortcutWindow(const std::string &title, std::string skinFile = "", int width = 0, int height = 0); /** -- cgit v1.2.3-60-g2f50 From c6a0486425aafdf766105da53e4304b42a417498 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 11 Sep 2011 16:29:32 +0300 Subject: Fix code style. --- src/gui/theme.cpp | 4 ++-- src/gui/widgets/itemcontainer.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 15dafa997..0a1a930a9 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -461,8 +461,8 @@ Skin *Theme::readSkin(const std::string &filename) else { - logger->log("Theme::readSkin(): Unknown part type '%s'", - partType.c_str()); + logger->log("Theme::readSkin(): Unknown part type " + "'%s'", partType.c_str()); } } else if (xmlStrEqual(partNode->name, BAD_CAST "option")) diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 84313d64f..2cc80ee8b 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -130,7 +130,7 @@ class SortItemAmountFunctor return (pair1->mItem->getInfo().getName() < pair2->mItem->getInfo().getName()); } - return c1 < c2;; + return c1 < c2; } } itemAmountSorter; @@ -149,7 +149,7 @@ class SortItemTypeFunctor return (pair1->mItem->getInfo().getName() < pair2->mItem->getInfo().getName()); } - return t1 < t2;; + return t1 < t2; } } itemTypeSorter; -- cgit v1.2.3-60-g2f50 From 0abd36c63a6ffd16e998fe1552f822ca351ef2b2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 14 Sep 2011 15:36:47 +0300 Subject: Replace some size() calls to empty(). --- src/actorsprite.cpp | 2 +- src/compoundsprite.h | 3 +++ src/gui/serverdialog.cpp | 2 +- src/resources/iteminfo.cpp | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/gui') diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index e90536b2d..6155bb7af 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -331,7 +331,7 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display, } // Ensure that something is shown, if desired - if (size() == 0 && forceDisplay) + if (empty() && forceDisplay) { if (display.image.empty()) { diff --git a/src/compoundsprite.h b/src/compoundsprite.h index 2211cb80c..d1b019057 100644 --- a/src/compoundsprite.h +++ b/src/compoundsprite.h @@ -85,6 +85,9 @@ public: size_t size() const { return std::vector::size(); } + bool empty() const + { return std::vector::empty(); } + void addSprite(Sprite* sprite); void setSprite(int layer, Sprite* sprite); diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index 1b0dd22aa..5a00d4a76 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -367,7 +367,7 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir): loadServers(false); - if (mServers.size() == 0) + if (mServers.empty()) downloadServerList(); } diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index a5b81081c..5b07724a1 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -139,7 +139,7 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const if (i == mSounds.end()) return empty; - return i->second.size() > 0 ? i->second[rand() % i->second.size()] : empty; + return (!i->second.empty()) ? i->second[rand() % i->second.size()] : empty; } std::map *ItemInfo::addReplaceSprite(int sprite, int direction) @@ -222,7 +222,7 @@ const std::string ItemInfo::replaceColors(std::string str, } str = replaceAll(str, "%color%", name); - if (name.size() > 0) + if (!name.empty()) name[0] = static_cast(toupper(name[0])); return replaceAll(str, "%Color%", name); -- cgit v1.2.3-60-g2f50 From b6dae23ca33ee0032260080819a59ec6363f72f6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 14 Sep 2011 22:12:35 +0300 Subject: Show in context menu some missing items. Add "move" item for party members. --- src/gui/popupmenu.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 8 deletions(-) (limited to 'src/gui') diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index daf1757c3..711a0e250 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -437,14 +437,24 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation"))); mBrowserBox->addRow(strprintf("@@addcomment|%s@@", _("Add comment"))); - if (player_node->isInParty() && player_node->getParty()) + if (player_node->isInParty()) { - PartyMember *member = player_node->getParty()->getMember(mNick); - if (member) + Party *party = player_node->getParty(); + if (party) { - mBrowserBox->addRow(strprintf( - "@@kick party|%s@@", _("Kick from party"))); - mBrowserBox->addRow("##3---"); + PartyMember *member = party->getMember(mNick); + if (member) + { + mBrowserBox->addRow(strprintf( + "@@kick party|%s@@", _("Kick from party"))); + mBrowserBox->addRow("##3---"); + PartyMember *o = party->getMember(player_node->getName()); + if (o && member->getMap() == o->getMap()) + { + mBrowserBox->addRow(strprintf( + "@@move|%s@@", _("Move"))); + } + } } } @@ -782,8 +792,48 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) { mNick = name; mType = Being::PLAYER; + + mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow"))); + mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation"))); + + if (player_node->isInParty()) + { + Party *party = player_node->getParty(); + if (party) + { + PartyMember *m = party->getMember(mNick); + if (m) + { + mBrowserBox->addRow(strprintf( + "@@move|%s@@", _("Move"))); + } + } + } + mBrowserBox->addRow(strprintf("@@items|%s@@", _("Show Items"))); + mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress"))); mBrowserBox->addRow(strprintf( "@@addcomment|%s@@", _("Add comment"))); + + if (player_relations.getDefault() & PlayerRelation::TRADE) + { + mBrowserBox->addRow("##3---"); + if (being->isAdvanced()) + { + if (being->isShopEnabled()) + { + mBrowserBox->addRow(strprintf( + "@@buy|%s@@", _("Buy"))); + mBrowserBox->addRow(strprintf( + "@@sell|%s@@", _("Sell"))); + } + } + else + { + mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy (?)"))); + mBrowserBox->addRow(strprintf( + "@@sell|%s@@", _("Sell (?)"))); + } + } mBrowserBox->addRow("##3---"); } } @@ -1054,10 +1104,26 @@ void PopupMenu::handleLink(const std::string &link, chatWindow->addInputText("/w \"" + mNick + "\" "); } } - else if (link == "move" && being) + else if (link == "move" && !mNick.empty()) { if (player_node) - player_node->navigateTo(being->getTileX(), being->getTileY()); + { + if (being) + { + player_node->navigateTo(being->getTileX(), being->getTileY()); + } + else if (player_node->isInParty()) + { + Party *party = player_node->getParty(); + if (party) + { + PartyMember *m = party->getMember(mNick); + PartyMember *o = party->getMember(player_node->getName()); + if (m && o && m->getMap() == o->getMap()) + player_node->navigateTo(m->getX(), m->getY()); + } + } + } } else if (link == "split" && mItem) { -- cgit v1.2.3-60-g2f50 From 255b1c29f47ef3b1e7a9b058c56ef72bfa10c5e3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 15 Sep 2011 00:50:47 +0300 Subject: Add buttons Themes, Video, Perfomance in select server screen. --- src/client.cpp | 64 ++++++++++++++++++++++++++++++++++++------ src/client.h | 3 ++ src/gui/setup.cpp | 22 +++++++++++++++ src/gui/setup.h | 2 ++ src/gui/widgets/tabbedarea.cpp | 13 +++++++++ src/gui/widgets/tabbedarea.h | 2 ++ 6 files changed, 98 insertions(+), 8 deletions(-) (limited to 'src/gui') diff --git a/src/client.cpp b/src/client.cpp index 47d0e9a21..608bb5c8b 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -247,6 +247,9 @@ Client::Client(const Options &options): mQuitDialog(0), mDesktop(0), mSetupButton(0), + mVideoButton(0), + mThemesButton(0), + mPerfomanceButton(0), mState(STATE_CHOOSE_SERVER), mOldState(STATE_START), mIcon(0), @@ -828,11 +831,28 @@ int Client::exec() mDesktop = new Desktop; top->add(mDesktop); + int x = top->getWidth(); mSetupButton = new Button(_("Setup"), "Setup", this); - mSetupButton->setPosition(top->getWidth() - - mSetupButton->getWidth() - 3, 3); + x -= mSetupButton->getWidth() + 3; + mSetupButton->setPosition(x, 3); top->add(mSetupButton); + mPerfomanceButton = new Button( + _("Perfomance"), "Perfomance", this); + x -= mPerfomanceButton->getWidth() + 6; + mPerfomanceButton->setPosition(x, 3); + top->add(mPerfomanceButton); + + mVideoButton = new Button(_("Video"), "Video", this); + x -= mVideoButton->getWidth() + 6; + mVideoButton->setPosition(x, 3); + top->add(mVideoButton); + + mThemesButton = new Button(_("Themes"), "Themes", this); + x -= mThemesButton->getWidth() + 6; + mThemesButton->setPosition(x, 3); + top->add(mThemesButton); + int screenWidth = config.getIntValue("screenwidth"); int screenHeight = config.getIntValue("screenheight"); @@ -1138,6 +1158,12 @@ int Client::exec() delete mSetupButton; mSetupButton = 0; + delete mVideoButton; + mVideoButton = 0; + delete mThemesButton; + mThemesButton = 0; + delete mPerfomanceButton; + mPerfomanceButton = 0; delete mDesktop; mDesktop = 0; @@ -1329,16 +1355,38 @@ void Client::optionChanged(const std::string &name) void Client::action(const gcn::ActionEvent &event) { - Window *window = 0; + bool show(false); + std::string tab = ""; if (event.getId() == "Setup") - window = setupWindow; + { + show = true; + } + else if (event.getId() == "Video") + { + show = true; + tab = "Video"; + } + else if (event.getId() == "Themes") + { + show = true; + tab = "Theme"; + } + else if (event.getId() == "Perfomance") + { + show = true; + tab = "Perfomance"; + } - if (window) + if (setupWindow) { - window->setVisible(!window->isVisible()); - if (window->isVisible()) - window->requestMoveToTop(); + setupWindow->setVisible(!setupWindow->isVisible()); + if (setupWindow->isVisible()) + { + if (!tab.empty()) + setupWindow->activateTab(tab); + setupWindow->requestMoveToTop(); + } } } diff --git a/src/client.h b/src/client.h index 4409cf8db..08bc1ecbf 100644 --- a/src/client.h +++ b/src/client.h @@ -317,6 +317,9 @@ private: QuitDialog *mQuitDialog; Desktop *mDesktop; Button *mSetupButton; + Button *mVideoButton; + Button *mThemesButton; + Button *mPerfomanceButton; State mState; State mOldState; diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 33f379743..ae7a3109c 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -198,4 +198,26 @@ void Setup::doCancel() for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel)); } +void Setup::activateTab(const std::string &name) +{ + std::string tmp = gettext(name.c_str()); + mPanel->setSelectedTab(tmp); +/* + for (std::list::const_iterator it = mTabs.begin(); + it != mTabs.end(); ++it) + { + if (*it) + { + SetupTab *tab = *it; + logger->log("check tab: " + tab->getName()); + if (tab->getName() == tmp) + { + mPanel->setSelectedTab(name); + return; + } + } + } +*/ +} + Setup *setupWindow; diff --git a/src/gui/setup.h b/src/gui/setup.h index cdaf7db99..b499da4ee 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -73,6 +73,8 @@ class Setup : public Window, public gcn::ActionListener void doCancel(); + void activateTab(const std::string &name); + private: std::list mTabs; std::list mWindowsToReset; diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 940dad12a..47b02c925 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -241,6 +241,19 @@ void TabbedArea::setSelectedTab(gcn::Tab *tab) widgetResized(NULL); } +void TabbedArea::setSelectedTab(const std::string &name) +{ + for (TabContainer::const_iterator itr = mTabs.begin(), + itr_end = mTabs.end(); itr != itr_end; ++itr) + { + if ((*itr).first && (*itr).first->getCaption() == name) + { + setSelectedTab((*itr).first); + return; + } + } +} + void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED) { int width = getWidth() - 2 * getFrameSize() diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index a91b4c199..3ad113b4c 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -122,6 +122,8 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener void setSelectedTab(gcn::Tab *tab); + void setSelectedTab(const std::string &name); + void widgetResized(const gcn::Event &event); /* -- cgit v1.2.3-60-g2f50 From c91bc5201596eda73f9df2222d76d9f413426a85 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 15 Sep 2011 04:22:11 +0300 Subject: Remove some diplicated code from embeded guichan. --- src/gui/widgets/window.cpp | 2 +- src/guichan/include/guichan/widgets/button.hpp | 8 -- src/guichan/include/guichan/widgets/checkbox.hpp | 14 -- src/guichan/include/guichan/widgets/dropdown.hpp | 6 +- .../include/guichan/widgets/radiobutton.hpp | 7 +- src/guichan/include/guichan/widgets/slider.hpp | 12 -- src/guichan/include/guichan/widgets/tab.hpp | 3 - src/guichan/include/guichan/widgets/tabbedarea.hpp | 18 +-- src/guichan/include/guichan/widgets/textfield.hpp | 8 -- src/guichan/include/guichan/widgets/window.hpp | 7 - src/guichan/widgets/button.cpp | 19 +-- src/guichan/widgets/checkbox.cpp | 51 ------- src/guichan/widgets/dropdown.cpp | 150 --------------------- src/guichan/widgets/radiobutton.cpp | 81 ----------- src/guichan/widgets/slider.cpp | 68 ---------- src/guichan/widgets/tab.cpp | 63 --------- src/guichan/widgets/tabbedarea.cpp | 99 -------------- src/guichan/widgets/textfield.cpp | 96 ------------- src/guichan/widgets/window.cpp | 91 ------------- 19 files changed, 7 insertions(+), 796 deletions(-) (limited to 'src/gui') diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 2d4c443c6..c52bf744e 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -1031,4 +1031,4 @@ gcn::Rectangle Window::getWindowArea() getPadding(), getWidth() - getPadding() * 2, getHeight() - getPadding() * 2); -} \ No newline at end of file +} diff --git a/src/guichan/include/guichan/widgets/button.hpp b/src/guichan/include/guichan/widgets/button.hpp index c0d0a237d..e3b8b98de 100644 --- a/src/guichan/include/guichan/widgets/button.hpp +++ b/src/guichan/include/guichan/widgets/button.hpp @@ -147,22 +147,14 @@ namespace gcn void adjustSize(); - //Inherited from Widget - - virtual void draw(Graphics* graphics); - - // Inherited from FocusListener virtual void focusLost(const Event& event); - // Inherited from MouseListener virtual void mousePressed(MouseEvent& mouseEvent); - virtual void mouseReleased(MouseEvent& mouseEvent); - virtual void mouseEntered(MouseEvent& mouseEvent); virtual void mouseExited(MouseEvent& mouseEvent); diff --git a/src/guichan/include/guichan/widgets/checkbox.hpp b/src/guichan/include/guichan/widgets/checkbox.hpp index ad43e2896..0ff328d72 100644 --- a/src/guichan/include/guichan/widgets/checkbox.hpp +++ b/src/guichan/include/guichan/widgets/checkbox.hpp @@ -126,17 +126,10 @@ namespace gcn */ void adjustSize(); - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - // Inherited from KeyListener virtual void keyPressed(KeyEvent& keyEvent); - // Inherited from MouseListener virtual void mouseClicked(MouseEvent& mouseEvent); @@ -145,13 +138,6 @@ namespace gcn protected: - /** - * Draws the box of the check box. - * - * @param graphics A Graphics object to draw with. - */ - virtual void drawBox(Graphics *graphics); - /** * Toggles the check box between being selected and * not being selected. diff --git a/src/guichan/include/guichan/widgets/dropdown.hpp b/src/guichan/include/guichan/widgets/dropdown.hpp index c096bb03f..600558d67 100644 --- a/src/guichan/include/guichan/widgets/dropdown.hpp +++ b/src/guichan/include/guichan/widgets/dropdown.hpp @@ -171,8 +171,6 @@ namespace gcn // Inherited from Widget - virtual void draw(Graphics* graphics); - void setBaseColor(const Color& color); void setBackgroundColor(const Color& color); @@ -206,7 +204,7 @@ namespace gcn // Inherited from KeyListener - virtual void keyPressed(KeyEvent& keyEvent); + virtual void keyPressed(KeyEvent& keyEvent) = 0; // Inherited from MouseListener @@ -232,7 +230,7 @@ namespace gcn * * @param graphics a Graphics object to draw with. */ - virtual void drawButton(Graphics *graphics); + virtual void drawButton(Graphics *graphics) = 0; /** * Sets the drop down to be dropped down. diff --git a/src/guichan/include/guichan/widgets/radiobutton.hpp b/src/guichan/include/guichan/widgets/radiobutton.hpp index 0fb5b4123..e15bf86b3 100644 --- a/src/guichan/include/guichan/widgets/radiobutton.hpp +++ b/src/guichan/include/guichan/widgets/radiobutton.hpp @@ -152,11 +152,6 @@ namespace gcn void adjustSize(); - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - // Inherited from KeyListener virtual void keyPressed(KeyEvent& keyEvent); @@ -174,7 +169,7 @@ namespace gcn * * @param graphics a Graphics object to draw with. */ - virtual void drawBox(Graphics *graphics); + virtual void drawBox(Graphics *graphics) = 0; /** * True if the radio button is selected, false otherwise. diff --git a/src/guichan/include/guichan/widgets/slider.hpp b/src/guichan/include/guichan/widgets/slider.hpp index eddf02c50..ec6b82e1e 100644 --- a/src/guichan/include/guichan/widgets/slider.hpp +++ b/src/guichan/include/guichan/widgets/slider.hpp @@ -204,12 +204,6 @@ namespace gcn */ double getStepLength() const; - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - // Inherited from MouseListener. virtual void mousePressed(MouseEvent& mouseEvent); @@ -226,12 +220,6 @@ namespace gcn virtual void keyPressed(KeyEvent& keyEvent); protected: - /** - * Draws the marker. - * - * @param graphics A graphics object to draw with. - */ - virtual void drawMarker(gcn::Graphics* graphics); /** * Converts a marker position to a value in the scale. diff --git a/src/guichan/include/guichan/widgets/tab.hpp b/src/guichan/include/guichan/widgets/tab.hpp index 91c09e270..55845c771 100644 --- a/src/guichan/include/guichan/widgets/tab.hpp +++ b/src/guichan/include/guichan/widgets/tab.hpp @@ -127,9 +127,6 @@ namespace gcn // Inherited from Widget - virtual void draw(Graphics *graphics); - - // Inherited from MouseListener virtual void mouseEntered(MouseEvent& mouseEvent); diff --git a/src/guichan/include/guichan/widgets/tabbedarea.hpp b/src/guichan/include/guichan/widgets/tabbedarea.hpp index 843bbde81..7be3b91e2 100644 --- a/src/guichan/include/guichan/widgets/tabbedarea.hpp +++ b/src/guichan/include/guichan/widgets/tabbedarea.hpp @@ -108,16 +108,6 @@ namespace gcn */ bool isOpaque() const; - /** - * Adds a tab to the tabbed area. The newly created tab will be - * automatically deleted by the tabbed area when it is removed. - * - * @param caption The caption of the tab to add. - * @param widget The widget to view when the tab is selected. - * @see removeTab, removeTabWithIndex - */ - virtual void addTab(const std::string& caption, Widget* widget); - /** * Adds a tab to the tabbed area. The tab will not be deleted by the * tabbed area when it is removed. @@ -142,7 +132,7 @@ namespace gcn * @param index The tab to remove. * @see addTab */ - virtual void removeTab(Tab* tab); + virtual void removeTab(Tab* tab) = 0; /** * Checks if a tab given an index is selected or not. @@ -195,13 +185,10 @@ namespace gcn */ Tab* getSelectedTab(); - // Inherited from Widget virtual void draw(Graphics *graphics); - virtual void logic(); - void setWidth(int width); void setHeight(int height); @@ -228,9 +215,6 @@ namespace gcn // Inherited from MouseListener - virtual void mousePressed(MouseEvent& mouseEvent); - - protected: /** * Adjusts the size of the tab container and the widget container. diff --git a/src/guichan/include/guichan/widgets/textfield.hpp b/src/guichan/include/guichan/widgets/textfield.hpp index 486660a8a..638b6e715 100644 --- a/src/guichan/include/guichan/widgets/textfield.hpp +++ b/src/guichan/include/guichan/widgets/textfield.hpp @@ -124,19 +124,11 @@ namespace gcn virtual void fontChanged(); - virtual void draw(Graphics* graphics); - - // Inherited from MouseListener virtual void mousePressed(MouseEvent& mouseEvent); virtual void mouseDragged(MouseEvent& mouseEvent); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent); protected: /** diff --git a/src/guichan/include/guichan/widgets/window.hpp b/src/guichan/include/guichan/widgets/window.hpp index 3b9c62160..12e669f9d 100644 --- a/src/guichan/include/guichan/widgets/window.hpp +++ b/src/guichan/include/guichan/widgets/window.hpp @@ -187,17 +187,10 @@ namespace gcn */ virtual void resizeToContent(); - // Inherited from BasicContainer virtual Rectangle getChildrenArea(); - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - // Inherited from MouseListener virtual void mousePressed(MouseEvent& mouseEvent); diff --git a/src/guichan/widgets/button.cpp b/src/guichan/widgets/button.cpp index 184b6235c..c27d0c8dd 100644 --- a/src/guichan/widgets/button.cpp +++ b/src/guichan/widgets/button.cpp @@ -121,6 +121,7 @@ namespace gcn return mSpacing; } +/* void Button::draw(Graphics* graphics) { Color faceColor = getBaseColor(); @@ -195,6 +196,7 @@ namespace gcn } } } +*/ void Button::adjustSize() { @@ -233,23 +235,6 @@ namespace gcn mHasMouse = true; } - void Button::mouseReleased(MouseEvent& mouseEvent) - { - if (mouseEvent.getButton() == MouseEvent::LEFT - && mMousePressed - && mHasMouse) - { - mMousePressed = false; - distributeActionEvent(); - mouseEvent.consume(); - } - else if (mouseEvent.getButton() == MouseEvent::LEFT) - { - mMousePressed = false; - mouseEvent.consume(); - } - } - void Button::mouseDragged(MouseEvent& mouseEvent) { mouseEvent.consume(); diff --git a/src/guichan/widgets/checkbox.cpp b/src/guichan/widgets/checkbox.cpp index 04423a6e9..89fee153e 100644 --- a/src/guichan/widgets/checkbox.cpp +++ b/src/guichan/widgets/checkbox.cpp @@ -78,57 +78,6 @@ namespace gcn adjustSize(); } - void CheckBox::draw(Graphics* graphics) - { - drawBox(graphics); - - graphics->setFont(getFont()); - graphics->setColor(getForegroundColor()); - - const int h = getHeight() + getHeight() / 2; - - graphics->drawText(getCaption(), h - 2, 0); - } - - void CheckBox::drawBox(Graphics *graphics) - { - const int h = getHeight() - 2; - const int alpha = getBaseColor().a; - Color faceColor = getBaseColor(); - faceColor.a = alpha; - Color highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - Color shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - graphics->setColor(shadowColor); - graphics->drawLine(1, 1, h, 1); - graphics->drawLine(1, 1, 1, h); - - graphics->setColor(highlightColor); - graphics->drawLine(h, 1, h, h); - graphics->drawLine(1, h, h - 1, h); - - graphics->setColor(getBackgroundColor()); - graphics->fillRectangle(Rectangle(2, 2, h - 2, h - 2)); - - graphics->setColor(getForegroundColor()); - - if (isFocused()) - { - graphics->drawRectangle(Rectangle(0, 0, h + 2, h + 2)); - } - - if (mSelected) - { - graphics->drawLine(3, 5, 3, h - 2); - graphics->drawLine(4, 5, 4, h - 2); - - graphics->drawLine(5, h - 3, h - 2, 4); - graphics->drawLine(5, h - 4, h - 4, 5); - } - } - bool CheckBox::isSelected() const { return mSelected; diff --git a/src/guichan/widgets/dropdown.cpp b/src/guichan/widgets/dropdown.cpp index 7af01e703..3ecbd75d8 100644 --- a/src/guichan/widgets/dropdown.cpp +++ b/src/guichan/widgets/dropdown.cpp @@ -122,131 +122,6 @@ namespace gcn setInternalFocusHandler(NULL); } - void DropDown::draw(Graphics* graphics) - { - int h; - - if (mDroppedDown) - h = mFoldedUpHeight; - else - h = getHeight(); - - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - // Draw a border. - graphics->setColor(shadowColor); - graphics->drawLine(0, 0, getWidth() - 1, 0); - graphics->drawLine(0, 1, 0, h - 2); - graphics->setColor(highlightColor); - graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, h - 1); - graphics->drawLine(0, h - 1, getWidth() - 1, h - 1); - - // Push a clip area so the other drawings don't need to worry - // about the border. - graphics->pushClipArea(Rectangle(1, 1, getWidth() - 2, h - 2)); - const Rectangle currentClipArea = graphics->getCurrentClipArea(); - - graphics->setColor(getBackgroundColor()); - graphics->fillRectangle(Rectangle(0, 0, - currentClipArea.width, currentClipArea.height)); - - if (isFocused()) - { - graphics->setColor(getSelectionColor()); - graphics->fillRectangle(Rectangle(0, 0, - currentClipArea.width - currentClipArea.height, - currentClipArea.height)); - graphics->setColor(getForegroundColor()); - } - - if (mListBox->getListModel() - && mListBox->getSelected() >= 0) - { - graphics->setColor(getForegroundColor()); - graphics->setFont(getFont()); - - graphics->drawText(mListBox->getListModel()->getElementAt( - mListBox->getSelected()), 1, 0); - } - - // Push a clip area before drawing the button. - graphics->pushClipArea(Rectangle( - currentClipArea.width - currentClipArea.height, - 0, currentClipArea.height, currentClipArea.height)); - drawButton(graphics); - graphics->popClipArea(); - graphics->popClipArea(); - - if (mDroppedDown) - { - // Draw a border around the children. - graphics->setColor(shadowColor); - graphics->drawRectangle(Rectangle(0, mFoldedUpHeight, - getWidth(), getHeight() - mFoldedUpHeight)); - drawChildren(graphics); - } - } - - void DropDown::drawButton(Graphics *graphics) - { - Color faceColor, highlightColor, shadowColor; - int offset; - int alpha = getBaseColor().a; - - if (mPushed) - { - faceColor = getBaseColor() - 0x303030; - faceColor.a = alpha; - highlightColor = faceColor - 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor + 0x303030; - shadowColor.a = alpha; - offset = 1; - } - else - { - faceColor = getBaseColor(); - faceColor.a = alpha; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - offset = 0; - } - - const Rectangle currentClipArea = graphics->getCurrentClipArea(); - graphics->setColor(highlightColor); - graphics->drawLine(0, 0, currentClipArea.width - 1, 0); - graphics->drawLine(0, 1, 0, currentClipArea.height - 1); - graphics->setColor(shadowColor); - graphics->drawLine(currentClipArea.width - 1, 1, - currentClipArea.width - 1, currentClipArea.height - 1); - graphics->drawLine(1, currentClipArea.height - 1, - currentClipArea.width - 2, currentClipArea.height - 1); - - graphics->setColor(faceColor); - graphics->fillRectangle(Rectangle(1, 1, - currentClipArea.width - 2, currentClipArea.height - 2)); - - graphics->setColor(getForegroundColor()); - - int i; - int n = currentClipArea.height / 3; - int dx = currentClipArea.height / 2; - int dy = (currentClipArea.height * 2) / 3; - for (i = 0; i < n; i++) - { - graphics->drawLine(dx - i + offset, dy - i + offset, - dx + i + offset, dy - i + offset); - } - } - int DropDown::getSelected() const { return mListBox->getSelected(); @@ -258,31 +133,6 @@ namespace gcn mListBox->setSelected(selected); } - void DropDown::keyPressed(KeyEvent& keyEvent) - { - if (keyEvent.isConsumed()) - return; - - Key key = keyEvent.getKey(); - - if ((key.getValue() == Key::ENTER || key.getValue() == Key::SPACE) - && !mDroppedDown) - { - dropDown(); - keyEvent.consume(); - } - else if (key.getValue() == Key::UP) - { - setSelected(getSelected() - 1); - keyEvent.consume(); - } - else if (key.getValue() == Key::DOWN) - { - setSelected(getSelected() + 1); - keyEvent.consume(); - } - } - void DropDown::mousePressed(MouseEvent& mouseEvent) { // If we have a mouse press on the widget. diff --git a/src/guichan/widgets/radiobutton.cpp b/src/guichan/widgets/radiobutton.cpp index 37fd4a0f0..48a690767 100644 --- a/src/guichan/widgets/radiobutton.cpp +++ b/src/guichan/widgets/radiobutton.cpp @@ -93,87 +93,6 @@ namespace gcn setGroup(""); } - void RadioButton::draw(Graphics* graphics) - { - graphics->pushClipArea(Rectangle(1, 1, - getWidth() - 1, getHeight() - 1)); - - drawBox(graphics); - graphics->popClipArea(); - - graphics->setFont(getFont()); - graphics->setColor(getForegroundColor()); - - if (isFocused()) - { - int fh; - - if (getHeight() % 2 == 0) - fh = getHeight() - 4; - else - fh = getHeight() - 3; - - int hh = (fh + 1) / 2; - - graphics->drawLine(0, hh + 1, hh + 1, 0); - graphics->drawLine(hh + 2, 1, fh + 2, hh + 1); - graphics->drawLine(fh + 1, hh + 2, hh + 1, fh + 2); - graphics->drawLine(hh + 1, fh + 2, 1, hh + 2); - } - - int h = getHeight() + getHeight() / 2; - - graphics->drawText(getCaption(), h - 2, 0); - } - - void RadioButton::drawBox(Graphics *graphics) - { - int h; - - if (getHeight() % 2 == 0) - h = getHeight() - 4; - else - h = getHeight() - 3; - - int alpha = getBaseColor().a; - Color faceColor = getBaseColor(); - faceColor.a = alpha; - Color highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - Color shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - graphics->setColor(getBackgroundColor()); - - int i; - int hh = (h + 1) / 2; - - for (i = 1; i <= hh; ++i) - graphics->drawLine(hh - i + 1, i, hh + i - 1, i); - - for (i = 1; i < hh; ++i) - graphics->drawLine(hh - i + 1, h - i, hh + i - 1, h - i); - - graphics->setColor(shadowColor); - graphics->drawLine(hh, 0, 0, hh); - graphics->drawLine(hh + 1, 1, h - 1, hh - 1); - - graphics->setColor(highlightColor); - graphics->drawLine(1, hh + 1, hh, h); - graphics->drawLine(hh + 1, h - 1, h, hh); - - graphics->setColor(getForegroundColor()); - - int hhh = hh - 3; - if (mSelected) - { - for (i = 0; i < hhh; ++i) - graphics->drawLine(hh - i, 4 + i, hh + i, 4 + i); - for (i = 0; i < hhh; ++i) - graphics->drawLine(hh - i, h - 4 - i, hh + i, h - 4 - i); - } - } - bool RadioButton::isSelected() const { return mSelected; diff --git a/src/guichan/widgets/slider.cpp b/src/guichan/widgets/slider.cpp index eba88382c..f0eabd627 100644 --- a/src/guichan/widgets/slider.cpp +++ b/src/guichan/widgets/slider.cpp @@ -117,74 +117,6 @@ namespace gcn mScaleEnd = scaleEnd; } - void Slider::draw(gcn::Graphics* graphics) - { - Color shadowColor = getBaseColor() - 0x101010; - int alpha = getBaseColor().a; - shadowColor.a = alpha; - - graphics->setColor(shadowColor); - graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); - - drawMarker(graphics); - } - - void Slider::drawMarker(gcn::Graphics* graphics) - { - gcn::Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - graphics->setColor(faceColor); - - if (getOrientation() == HORIZONTAL) - { - int v = getMarkerPosition(); - graphics->fillRectangle(gcn::Rectangle(v + 1, 1, - getMarkerLength() - 2, getHeight() - 2)); - graphics->setColor(highlightColor); - graphics->drawLine(v, 0, v + getMarkerLength() - 1, 0); - graphics->drawLine(v, 0, v, getHeight() - 1); - graphics->setColor(shadowColor); - graphics->drawLine(v + getMarkerLength() - 1, 1, - v + getMarkerLength() - 1, getHeight() - 1); - graphics->drawLine(v + 1, getHeight() - 1, - v + getMarkerLength() - 1, getHeight() - 1); - - if (isFocused()) - { - graphics->setColor(getForegroundColor()); - graphics->drawRectangle(Rectangle(v + 2, 2, - getMarkerLength() - 4, getHeight() - 4)); - } - } - else - { - int v = (getHeight() - getMarkerLength()) - getMarkerPosition(); - graphics->fillRectangle(gcn::Rectangle(1, v + 1, getWidth() - 2, - getMarkerLength() - 2)); - graphics->setColor(highlightColor); - graphics->drawLine(0, v, 0, v + getMarkerLength() - 1); - graphics->drawLine(0, v, getWidth() - 1, v); - graphics->setColor(shadowColor); - graphics->drawLine(1, v + getMarkerLength() - 1, getWidth() - 1, - v + getMarkerLength() - 1); - graphics->drawLine(getWidth() - 1, v + 1, getWidth() - 1, - v + getMarkerLength() - 1); - - if (isFocused()) - { - graphics->setColor(getForegroundColor()); - graphics->drawRectangle(Rectangle(2, v + 2, getWidth() - 4, - getMarkerLength() - 4)); - } - } - } - void Slider::mousePressed(MouseEvent& mouseEvent) { if (mouseEvent.getButton() == gcn::MouseEvent::LEFT diff --git a/src/guichan/widgets/tab.cpp b/src/guichan/widgets/tab.cpp index 1a3df3ede..9b7424748 100644 --- a/src/guichan/widgets/tab.cpp +++ b/src/guichan/widgets/tab.cpp @@ -105,69 +105,6 @@ namespace gcn return mLabel->getCaption(); } - void Tab::draw(Graphics *graphics) - { - const Color &faceColor = getBaseColor(); - const int alpha = getBaseColor().a; - Color highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - Color shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - Color borderColor; - Color baseColor; - - if ((mTabbedArea != NULL && mTabbedArea->isTabSelected(this)) - || mHasMouse) - { - // Draw a border. - graphics->setColor(highlightColor); - graphics->drawLine(0, 0, getWidth() - 1, 0); - graphics->drawLine(0, 1, 0, getHeight() - 1); - graphics->setColor(shadowColor); - graphics->drawLine(getWidth() - 1, 1, - getWidth() - 1, getHeight() - 1); - - borderColor = highlightColor; - baseColor = getBaseColor(); - } - else - { - // Draw a border. - graphics->setColor(shadowColor); - graphics->drawLine(0, 0, getWidth() - 1, 0); - graphics->drawLine(0, 1, 0, getHeight() - 1); - graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, - getHeight() - 1); - - baseColor = getBaseColor() - 0x151515; - baseColor.a = alpha; - } - - // Push a clip area so the other drawings don't need to worry - // about the border. - graphics->pushClipArea(Rectangle(1, 1, - getWidth() - 2, getHeight() - 1)); - const Rectangle currentClipArea = graphics->getCurrentClipArea(); - - graphics->setColor(baseColor); - graphics->fillRectangle(Rectangle(0, 0, - currentClipArea.width, currentClipArea.height)); - - drawChildren(graphics); - - if (mTabbedArea != NULL - && mTabbedArea->isFocused() - && mTabbedArea->isTabSelected(this)) - { - graphics->setColor(Color(0x000000)); - graphics->drawRectangle(Rectangle(2, 2, - currentClipArea.width - 4, currentClipArea.height - 4)); - } - - graphics->popClipArea(); - } - void Tab::mouseEntered(MouseEvent& mouseEvent A_UNUSED) { mHasMouse = true; diff --git a/src/guichan/widgets/tabbedarea.cpp b/src/guichan/widgets/tabbedarea.cpp index b22d615e9..3c556eeca 100644 --- a/src/guichan/widgets/tabbedarea.cpp +++ b/src/guichan/widgets/tabbedarea.cpp @@ -94,15 +94,6 @@ namespace gcn } } - void TabbedArea::addTab(const std::string& caption, Widget* widget) - { - Tab* tab = new Tab(); - tab->setCaption(caption); - mTabsToDelete.push_back(tab); - - addTab(tab, widget); - } - void TabbedArea::addTab(Tab* tab, Widget* widget) { tab->setTabbedArea(this); @@ -126,69 +117,6 @@ namespace gcn removeTab(mTabs[index].first); } - void TabbedArea::removeTab(Tab* tab) - { - int tabIndexToBeSelected = - 1; - - if (tab == mSelectedTab) - { - int index = getSelectedTabIndex(); - - if (index == (int)mTabs.size() - 1 - && mTabs.size() >= 2) - { - tabIndexToBeSelected = index--; - } - else if (index == (int)mTabs.size() - 1 - && mTabs.size() == 1) - { - tabIndexToBeSelected = -1; - } - else - { - tabIndexToBeSelected = index; - } - } - - std::vector >::iterator iter; - for (iter = mTabs.begin(); iter != mTabs.end(); ++ iter) - { - if (iter->first == tab) - { - mTabContainer->remove(tab); - mTabs.erase(iter); - break; - } - } - - std::vector::iterator iter2; - for (iter2 = mTabsToDelete.begin(); - iter2 != mTabsToDelete.end(); - ++ iter2) - { - if (*iter2 == tab) - { - mTabsToDelete.erase(iter2); - delete tab; - tab = 0; - break; - } - } - - if (tabIndexToBeSelected == -1) - { - mSelectedTab = NULL; - mWidgetContainer->clear(); - } - else - { - setSelectedTab(tabIndexToBeSelected); - } - - adjustSize(); - adjustTabPositions(); - } - bool TabbedArea::isTabSelected(unsigned int index) const { if (index >= mTabs.size()) @@ -309,10 +237,6 @@ namespace gcn drawChildren(graphics); } - void TabbedArea::logic() - { - } - void TabbedArea::adjustSize() { int maxTabHeight = 0; @@ -404,29 +328,6 @@ namespace gcn } } - - void TabbedArea::mousePressed(MouseEvent& mouseEvent) - { - if (mouseEvent.isConsumed()) - return; - - if (mouseEvent.getButton() == MouseEvent::LEFT) - { - Widget* widget = mTabContainer->getWidgetAt( - mouseEvent.getX(), mouseEvent.getY()); - Tab* tab = dynamic_cast(widget); - - if (tab != NULL) - setSelectedTab(tab); - } - - // Request focus only if the source of the event - // is not focusble. If the source of the event - // is focused we don't want to steal the focus. - if (!mouseEvent.getSource()->isFocusable()) - requestFocus(); - } - void TabbedArea::death(const Event& event) { Tab* tab = dynamic_cast(event.getSource()); diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp index af2b9582f..d224e483f 100644 --- a/src/guichan/widgets/textfield.cpp +++ b/src/guichan/widgets/textfield.cpp @@ -89,55 +89,6 @@ namespace gcn mText = text; } - void TextField::draw(Graphics* graphics) - { - Color faceColor = getBaseColor(); - Color highlightColor, shadowColor; - int alpha = getBaseColor().a; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - // Draw a border. - graphics->setColor(shadowColor); - graphics->drawLine(0, 0, getWidth() - 1, 0); - graphics->drawLine(0, 1, 0, getHeight() - 2); - graphics->setColor(highlightColor); - graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, getHeight() - 1); - graphics->drawLine(0, getHeight() - 1, - getWidth() - 1, getHeight() - 1); - - // Push a clip area so the other drawings don't need to worry - // about the border. - graphics->pushClipArea(Rectangle(1, 1, - getWidth() - 2, getHeight() - 2)); - - graphics->setColor(getBackgroundColor()); - graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); - - if (isFocused()) - { - graphics->setColor(getSelectionColor()); - graphics->drawRectangle(Rectangle(0, 0, - getWidth() - 2, getHeight() - 2)); - graphics->drawRectangle(Rectangle(1, 1, - getWidth() - 4, getHeight() - 4)); - } - - if (isFocused()) - { - drawCaret(graphics, getFont()->getWidth( - mText.substr(0, mCaretPosition)) - mXScroll); - } - - graphics->setColor(getForegroundColor()); - graphics->setFont(getFont()); - graphics->drawText(mText, 3 - mXScroll, 1); - - graphics->popClipArea(); - } - void TextField::drawCaret(Graphics* graphics, int x) { // Check the current clip area as a clip area with a different @@ -164,53 +115,6 @@ namespace gcn { mouseEvent.consume(); } - - void TextField::keyPressed(KeyEvent& keyEvent) - { - Key key = keyEvent.getKey(); - - if (key.getValue() == Key::LEFT && mCaretPosition > 0) - { - --mCaretPosition; - } - else if (key.getValue() == Key::RIGHT && mCaretPosition < mText.size()) - { - ++mCaretPosition; - } - else if (key.getValue() == Key::DELETE - && mCaretPosition < mText.size()) - { - mText.erase(mCaretPosition, 1); - } - else if (key.getValue() == Key::BACKSPACE && mCaretPosition > 0) - { - mText.erase(mCaretPosition - 1, 1); - --mCaretPosition; - } - else if (key.getValue() == Key::ENTER) - { - distributeActionEvent(); - } - else if (key.getValue() == Key::HOME) - { - mCaretPosition = 0; - } - else if (key.getValue() == Key::END) - { - mCaretPosition = mText.size(); - } - else if (key.isCharacter() - && key.getValue() != Key::TAB) - { - mText.insert(mCaretPosition, std::string(1, (char)key.getValue())); - ++mCaretPosition; - } - - if (key.getValue() != Key::TAB) - keyEvent.consume(); - - fixScroll(); - } void TextField::adjustSize() { diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp index d0ba32f47..550b23749 100644 --- a/src/guichan/widgets/window.cpp +++ b/src/guichan/widgets/window.cpp @@ -125,97 +125,6 @@ namespace gcn return mAlignment; } - void Window::draw(Graphics* graphics) - { - const Color &faceColor = getBaseColor(); - Color highlightColor, shadowColor; - const int alpha = getBaseColor().a; - highlightColor = faceColor + 0x303030; - highlightColor.a = alpha; - shadowColor = faceColor - 0x303030; - shadowColor.a = alpha; - - Rectangle d = getChildrenArea(); - - // Fill the background around the content - graphics->setColor(faceColor); - // Fill top - graphics->fillRectangle(Rectangle(0, 0, getWidth(), d.y - 1)); - // Fill left - graphics->fillRectangle(Rectangle(0, d.y - 1, d.x - 1, - getHeight() - d.y + 1)); - // Fill right - graphics->fillRectangle(Rectangle(d.x + d.width + 1, d.y - 1, - getWidth() - d.x - d.width - 1, getHeight() - d.y + 1)); - // Fill bottom - graphics->fillRectangle(Rectangle(d.x - 1, d.y + d.height + 1, - d.width + 2, getHeight() - d.height - d.y - 1)); - - if (isOpaque()) - graphics->fillRectangle(d); - - // Construct a rectangle one pixel bigger than the content - d.x -= 1; - d.y -= 1; - d.width += 2; - d.height += 2; - - // Draw a border around the content - graphics->setColor(shadowColor); - // Top line - graphics->drawLine(d.x, - d.y, - d.x + d.width - 2, - d.y); - - // Left line - graphics->drawLine(d.x, - d.y + 1, - d.x, - d.y + d.height - 1); - - graphics->setColor(highlightColor); - // Right line - graphics->drawLine(d.x + d.width - 1, - d.y, - d.x + d.width - 1, - d.y + d.height - 2); - // Bottom line - graphics->drawLine(d.x + 1, - d.y + d.height - 1, - d.x + d.width - 1, - d.y + d.height - 1); - - drawChildren(graphics); - - int textX; - int textY; - - textY = ((int)getTitleBarHeight() - getFont()->getHeight()) / 2; - - switch (getAlignment()) - { - case Graphics::LEFT: - textX = 4; - break; - case Graphics::CENTER: - textX = getWidth() / 2; - break; - case Graphics::RIGHT: - textX = getWidth() - 4; - break; - default: - throw GCN_EXCEPTION("Unknown alignment."); - } - - graphics->setColor(getForegroundColor()); - graphics->setFont(getFont()); - graphics->pushClipArea(Rectangle(0, 0, getWidth(), - getTitleBarHeight() - 1)); - graphics->drawText(getCaption(), textX, textY, getAlignment()); - graphics->popClipArea(); - } - void Window::mousePressed(MouseEvent& mouseEvent) { if (mouseEvent.getSource() != this) -- cgit v1.2.3-60-g2f50 From ae9577c6a52a1e4eb1ff647905672ca840ad3e44 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 16 Sep 2011 00:57:59 +0300 Subject: Simplify menu creation in popupmenu class. --- src/gui/popupmenu.cpp | 546 ++++++++++++++++------------------------- src/gui/widgets/browserbox.cpp | 5 + src/gui/widgets/browserbox.h | 5 + 3 files changed, 227 insertions(+), 329 deletions(-) (limited to 'src/gui') diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 711a0e250..715b1d983 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -129,60 +129,45 @@ void PopupMenu::showPopup(int x, int y, Being *being) { case ActorSprite::PLAYER: { - mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade"))); - mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack"))); - mBrowserBox->addRow(strprintf("@@whisper|%s@@", _("Whisper"))); + mBrowserBox->addRow("trade", _("Trade")); + mBrowserBox->addRow("attack", _("Attack")); + mBrowserBox->addRow("whisper", _("Whisper")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@heal|%s@@", _("Heal"))); + mBrowserBox->addRow("heal", _("Heal")); mBrowserBox->addRow("##3---"); switch (player_relations.getRelation(name)) { case PlayerRelation::NEUTRAL: - mBrowserBox->addRow(strprintf( - "@@friend|%s@@", _("Be friend"))); - mBrowserBox->addRow(strprintf( - "@@disregard|%s@@", _("Disregard"))); - mBrowserBox->addRow(strprintf( - "@@ignore|%s@@", _("Ignore"))); - mBrowserBox->addRow(strprintf( - "@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("friend", _("Be friend")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::FRIEND: - mBrowserBox->addRow(strprintf( - "@@disregard|%s@@", _("Disregard"))); - mBrowserBox->addRow(strprintf( - "@@ignore|%s@@", _("Ignore"))); - mBrowserBox->addRow(strprintf( - "@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::DISREGARDED: - mBrowserBox->addRow(strprintf( - "@@unignore|%s@@", _("Unignore"))); - mBrowserBox->addRow(strprintf( - "@@ignore|%s@@", _("Completely ignore"))); - mBrowserBox->addRow(strprintf( - "@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("ignore", _("Completely ignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::IGNORED: - mBrowserBox->addRow(strprintf( - "@@unignore|%s@@", _("Unignore"))); - mBrowserBox->addRow(strprintf( - "@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::ERASED: - mBrowserBox->addRow(strprintf( - "@@unignore|%s@@", _("Unignore"))); - mBrowserBox->addRow(strprintf( - "@@disregard|%s@@", _("Disregard"))); - mBrowserBox->addRow(strprintf( - "@@ignore|%s@@", _("Completely ignore"))); + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Completely ignore")); break; default: @@ -190,9 +175,8 @@ void PopupMenu::showPopup(int x, int y, Being *being) } mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow"))); - mBrowserBox->addRow(strprintf( - "@@imitation|%s@@", _("Imitation"))); + mBrowserBox->addRow("follow", _("Follow")); + mBrowserBox->addRow("imitation", _("Imitation")); if (player_node->isInParty()) { @@ -201,13 +185,12 @@ void PopupMenu::showPopup(int x, int y, Being *being) if (player_node->getParty()->getName() != being->getPartyName()) { - mBrowserBox->addRow(strprintf( - "@@party|%s@@", _("Invite to party"))); + mBrowserBox->addRow("party", _("Invite to party")); } else { - mBrowserBox->addRow(strprintf( - "@@kick party|%s@@", _("Kick from party"))); + mBrowserBox->addRow("kick party", + _("Kick from party")); } mBrowserBox->addRow("##3---"); } @@ -221,8 +204,8 @@ void PopupMenu::showPopup(int x, int y, Being *being) { if (guild1->getId() == guild2->getId()) { - mBrowserBox->addRow(strprintf( - "@@guild-kick|%s@@", _("Kick from guild"))); + mBrowserBox->addRow("guild-kick", + _("Kick from guild")); if (guild2->getServerGuild()) { mBrowserBox->addRow(strprintf( @@ -233,8 +216,8 @@ void PopupMenu::showPopup(int x, int y, Being *being) } else if (guild2->getMember(mNick)) { - mBrowserBox->addRow(strprintf( - "@@guild-kick|%s@@", _("Kick from guild"))); + mBrowserBox->addRow("guild-kick", + _("Kick from guild")); if (guild2->getServerGuild()) { mBrowserBox->addRow(strprintf( @@ -247,8 +230,7 @@ void PopupMenu::showPopup(int x, int y, Being *being) if (guild2->getServerGuild() || (guildManager && guildManager->havePower())) { - mBrowserBox->addRow(strprintf( - "@@guild|%s@@", _("Invite to guild"))); + mBrowserBox->addRow("guild", _("Invite to guild")); } } } @@ -256,16 +238,13 @@ void PopupMenu::showPopup(int x, int y, Being *being) if (player_node->isGM()) { mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf( - "@@admin-kick|%s@@", _("Kick player"))); + mBrowserBox->addRow("admin-kick", _("Kick player")); } - mBrowserBox->addRow(strprintf("@@nuke|%s@@", _("Nuke"))); - mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move"))); - mBrowserBox->addRow(strprintf("@@items|%s@@", - _("Show Items"))); - mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress"))); - mBrowserBox->addRow(strprintf( - "@@addcomment|%s@@", _("Add comment"))); + mBrowserBox->addRow("nuke", _("Nuke")); + mBrowserBox->addRow("move", _("Move")); + mBrowserBox->addRow("items", _("Show Items")); + mBrowserBox->addRow("undress", _("Undress")); + mBrowserBox->addRow("addcomment", _("Add comment")); if (player_relations.getDefault() & PlayerRelation::TRADE) { @@ -274,18 +253,14 @@ void PopupMenu::showPopup(int x, int y, Being *being) { if (being->isShopEnabled()) { - mBrowserBox->addRow(strprintf( - "@@buy|%s@@", _("Buy"))); - mBrowserBox->addRow(strprintf( - "@@sell|%s@@", _("Sell"))); + mBrowserBox->addRow("buy", _("Buy")); + mBrowserBox->addRow("sell", _("Sell")); } } else { - mBrowserBox->addRow(strprintf( - "@@buy|%s@@", _("Buy (?)"))); - mBrowserBox->addRow(strprintf( - "@@sell|%s@@", _("Sell (?)"))); + mBrowserBox->addRow("buy", _("Buy (?)")); + mBrowserBox->addRow("sell", _("Sell (?)")); } } } @@ -294,26 +269,23 @@ void PopupMenu::showPopup(int x, int y, Being *being) case ActorSprite::NPC: // NPCs can be talked to (single option, candidate for removal // unless more options would be added) - mBrowserBox->addRow(strprintf("@@talk|%s@@", _("Talk"))); - - mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy"))); - mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell"))); + mBrowserBox->addRow("talk", _("Talk")); + mBrowserBox->addRow("buy", _("Buy")); + mBrowserBox->addRow("sell", _("Sell")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move"))); - mBrowserBox->addRow(strprintf("@@addcomment|%s@@", - _("Add comment"))); + mBrowserBox->addRow("move", _("Move")); + mBrowserBox->addRow("addcomment", _("Add comment")); break; case ActorSprite::MONSTER: { // Monsters can be attacked - mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack"))); + mBrowserBox->addRow("attack", _("Attack")); if (player_node->isGM()) { mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf( - "@@admin-kick|%s@@", _("Kick"))); + mBrowserBox->addRow("admin-kick", _("Kick")); } if (config.getBoolValue("enableAttackFilter")) @@ -323,19 +295,17 @@ void PopupMenu::showPopup(int x, int y, Being *being) || actorSpriteManager->isInIgnoreAttackList(name) || actorSpriteManager->isInPriorityAttackList(name)) { - mBrowserBox->addRow(strprintf("@@remove attack|%s@@", - _("Remove from attack list"))); + mBrowserBox->addRow("remove attack", + _("Remove from attack list")); } else { - mBrowserBox->addRow(strprintf( - "@@add attack priority|%s@@", - _("Add to priority attack list"))); - mBrowserBox->addRow(strprintf( - "@@add attack|%s@@", _("Add to attack list"))); - mBrowserBox->addRow(strprintf( - "@@add attack ignore|%s@@", - _("Add to ignore list"))); + mBrowserBox->addRow("add attack priority", + _("Add to priority attack list")); + mBrowserBox->addRow("add attack", + _("Add to attack list")); + mBrowserBox->addRow("add attack ignore", + _("Add to ignore list")); } } } @@ -348,10 +318,10 @@ void PopupMenu::showPopup(int x, int y, Being *being) /* Other beings aren't interesting... */ return; } - mBrowserBox->addRow(strprintf("@@name|%s@@", _("Add name to chat"))); + mBrowserBox->addRow("name", _("Add name to chat")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -372,7 +342,7 @@ void PopupMenu::showPopup(int x, int y, std::vector &beings) } } mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -390,42 +360,39 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) mBrowserBox->addRow(name); - mBrowserBox->addRow(strprintf("@@whisper|%s@@", _("Whisper"))); + mBrowserBox->addRow("whisper", _("Whisper")); mBrowserBox->addRow("##3---"); switch (player_relations.getRelation(name)) { case PlayerRelation::NEUTRAL: - mBrowserBox->addRow(strprintf("@@friend|%s@@", _("Be friend"))); - mBrowserBox->addRow(strprintf( - "@@disregard|%s@@", _("Disregard"))); - mBrowserBox->addRow(strprintf("@@ignore|%s@@", _("Ignore"))); - mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("friend", _("Be friend")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::FRIEND: - mBrowserBox->addRow(strprintf("@@disregard|%s@@", _("Disregard"))); - mBrowserBox->addRow(strprintf("@@ignore|%s@@", _("Ignore"))); - mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::DISREGARDED: - mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore"))); - mBrowserBox->addRow(strprintf( - "@@ignore|%s@@", _("Completely ignore"))); - mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("ignore", _("Completely ignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::IGNORED: - mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore"))); - mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::ERASED: - mBrowserBox->addRow(strprintf("@@unignore|%s@@", _("Unignore"))); - mBrowserBox->addRow(strprintf("@@disregard|%s@@", _("Disregard"))); - mBrowserBox->addRow(strprintf( - "@@ignore|%s@@", _("Completely ignore"))); + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Completely ignore")); break; default: @@ -433,9 +400,9 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) } mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow"))); - mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation"))); - mBrowserBox->addRow(strprintf("@@addcomment|%s@@", _("Add comment"))); + mBrowserBox->addRow("follow", _("Follow")); + mBrowserBox->addRow("imitation", _("Imitation")); + mBrowserBox->addRow("addcomment", _("Add comment")); if (player_node->isInParty()) { @@ -445,15 +412,11 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) PartyMember *member = party->getMember(mNick); if (member) { - mBrowserBox->addRow(strprintf( - "@@kick party|%s@@", _("Kick from party"))); + mBrowserBox->addRow("kick party", _("Kick from party")); mBrowserBox->addRow("##3---"); PartyMember *o = party->getMember(player_node->getName()); if (o && member->getMap() == o->getMap()) - { - mBrowserBox->addRow(strprintf( - "@@move|%s@@", _("Move"))); - } + mBrowserBox->addRow("move", _("Move")); } } } @@ -466,8 +429,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) if (guild2->getServerGuild() || (guildManager && guildManager->havePower())) { - mBrowserBox->addRow(strprintf( - "@@guild-kick|%s@@", _("Kick from guild"))); + mBrowserBox->addRow("guild-kick", _("Kick from guild")); } if (guild2->getServerGuild()) { @@ -480,8 +442,7 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) if (guild2->getServerGuild() || (guildManager && guildManager->havePower())) { - mBrowserBox->addRow(strprintf( - "@@guild|%s@@", _("Invite to guild"))); + mBrowserBox->addRow("guild", _("Invite to guild")); } } } @@ -489,17 +450,16 @@ void PopupMenu::showPlayerPopup(int x, int y, std::string nick) mBrowserBox->addRow("##3---"); if (player_relations.getDefault() & PlayerRelation::TRADE) { - mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy (?)"))); - mBrowserBox->addRow(strprintf("@@sell|%s@@", _("Sell (?)"))); + mBrowserBox->addRow("buy", _("Buy (?)")); + mBrowserBox->addRow("sell", _("Sell (?)")); } - mBrowserBox->addRow(strprintf("@@name|%s@@", _("Add name to chat"))); + mBrowserBox->addRow("name", _("Add name to chat")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); - } void PopupMenu::showPopup(int x, int y, FloorItem *floorItem) @@ -519,11 +479,11 @@ void PopupMenu::showPopup(int x, int y, FloorItem *floorItem) name = info.getName(); mBrowserBox->addRow(name); - mBrowserBox->addRow(strprintf("@@pickup|%s@@", _("Pick up"))); - mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat"))); + mBrowserBox->addRow("pickup", _("Pick up")); + mBrowserBox->addRow("chat", _("Add to chat")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -538,16 +498,16 @@ void PopupMenu::showPopup(int x, int y, MapItem *mapItem) mBrowserBox->clearRows(); mBrowserBox->addRow(_("Map Item")); - mBrowserBox->addRow(strprintf("@@rename map|%s@@", _("Rename"))); - mBrowserBox->addRow(strprintf("@@remove map|%s@@", _("Remove"))); + mBrowserBox->addRow("rename map", _("Rename")); + mBrowserBox->addRow("remove map", _("Remove")); if (player_node && player_node->isGM()) { mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@warp map|%s@@", _("Warp"))); + mBrowserBox->addRow("warp map", _("Warp")); } mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -557,11 +517,10 @@ void PopupMenu::showOutfitsPopup(int x, int y) mBrowserBox->clearRows(); mBrowserBox->addRow(_("Outfits")); - mBrowserBox->addRow(strprintf( - "@@load old outfits|%s@@", _("Load old outfits"))); + mBrowserBox->addRow("load old outfits", _("Load old outfits")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -575,12 +534,11 @@ void PopupMenu::showSpellPopup(int x, int y, TextCommand *cmd) mSpell = cmd; mBrowserBox->addRow(_("Spells")); - mBrowserBox->addRow(strprintf( - "@@load old spells|%s@@", _("Load old spells"))); - mBrowserBox->addRow(strprintf("@@edit spell|%s@@", _("Edit spell"))); + mBrowserBox->addRow("load old spells", _("Load old spells")); + mBrowserBox->addRow("edit spell", _("Edit spell")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -595,46 +553,28 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) mBrowserBox->clearRows(); if (tab->getType() == ChatTab::TAB_WHISPER) - mBrowserBox->addRow(strprintf("@@chat close|%s@@", _("Close"))); + mBrowserBox->addRow("chat close", _("Close")); - mBrowserBox->addRow(strprintf("@@chat clear|%s@@", _("Clear"))); + mBrowserBox->addRow("chat clear", _("Clear")); mBrowserBox->addRow("##3---"); if (tab->getAllowHighlight()) - { - mBrowserBox->addRow(strprintf("@@disable highlight|%s@@", - _("Disable highlight"))); - } + mBrowserBox->addRow("disable highlight", _("Disable highlight")); else - { - mBrowserBox->addRow(strprintf("@@enable highlight|%s@@", - _("Enable highlight"))); - } + mBrowserBox->addRow("enable highlight", _("Enable highlight")); if (tab->getRemoveNames()) - { - mBrowserBox->addRow(strprintf("@@dont remove name|%s@@", - _("Don't remove name"))); - } + mBrowserBox->addRow("dont remove name", _("Don't remove name")); else - { - mBrowserBox->addRow(strprintf("@@remove name|%s@@", - _("Remove name"))); - } + mBrowserBox->addRow("remove name", _("Remove name")); if (tab->getNoAway()) - { - mBrowserBox->addRow(strprintf("@@enable away|%s@@", - _("Enable away"))); - } + mBrowserBox->addRow("enable away", _("Enable away")); else - { - mBrowserBox->addRow(strprintf("@@disable away|%s@@", - _("Disable away"))); - } + mBrowserBox->addRow("disable away", _("Disable away")); mBrowserBox->addRow("##3---"); if (tab->getType() == ChatTab::TAB_PARTY) { - mBrowserBox->addRow(strprintf("@@leave party|%s@@", _("Leave"))); + mBrowserBox->addRow("leave party", _("Leave")); mBrowserBox->addRow("##3---"); } @@ -652,55 +592,44 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) mNick = being->getName(); mType = being->getType(); - mBrowserBox->addRow(strprintf("@@trade|%s@@", _("Trade"))); - mBrowserBox->addRow(strprintf("@@attack|%s@@", _("Attack"))); + mBrowserBox->addRow("trade", _("Trade")); + mBrowserBox->addRow("attack", _("Attack")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@heal|%s@@", _("Heal"))); + mBrowserBox->addRow("heal", _("Heal")); mBrowserBox->addRow("##3---"); switch (player_relations.getRelation(name)) { case PlayerRelation::NEUTRAL: - mBrowserBox->addRow(strprintf( - "@@friend|%s@@", _("Be friend"))); - mBrowserBox->addRow(strprintf( - "@@disregard|%s@@", _("Disregard"))); - mBrowserBox->addRow(strprintf( - "@@ignore|%s@@", _("Ignore"))); - mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("friend", _("Be friend")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::FRIEND: - mBrowserBox->addRow(strprintf( - "@@disregard|%s@@", _("Disregard"))); - mBrowserBox->addRow(strprintf( - "@@ignore|%s@@", _("Ignore"))); - mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Ignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::DISREGARDED: - mBrowserBox->addRow(strprintf( - "@@unignore|%s@@", _("Unignore"))); - mBrowserBox->addRow(strprintf( - "@@ignore|%s@@", _("Completely ignore"))); - mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("ignore", _("Completely ignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::IGNORED: - mBrowserBox->addRow(strprintf( - "@@unignore|%s@@", _("Unignore"))); - mBrowserBox->addRow(strprintf("@@erase|%s@@", _("Erase"))); + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("erase", _("Erase")); break; case PlayerRelation::ERASED: - mBrowserBox->addRow(strprintf( - "@@unignore|%s@@", _("Unignore"))); - mBrowserBox->addRow(strprintf( - "@@disregard|%s@@", _("Disregard"))); - mBrowserBox->addRow(strprintf( - "@@ignore|%s@@", _("Completely ignore"))); + mBrowserBox->addRow("unignore", _("Unignore")); + mBrowserBox->addRow("disregard", _("Disregard")); + mBrowserBox->addRow("ignore", _("Completely ignore")); break; default: @@ -708,13 +637,12 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) } mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow"))); - mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation"))); - mBrowserBox->addRow(strprintf("@@move|%s@@", _("Move"))); - mBrowserBox->addRow(strprintf("@@items|%s@@", _("Show Items"))); - mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress"))); - mBrowserBox->addRow(strprintf( - "@@addcomment|%s@@", _("Add comment"))); + mBrowserBox->addRow("follow", _("Follow")); + mBrowserBox->addRow("imitation", _("Imitation")); + mBrowserBox->addRow("move", _("Move")); + mBrowserBox->addRow("items", _("Show Items")); + mBrowserBox->addRow("undress", _("Undress")); + mBrowserBox->addRow("addcomment", _("Add comment")); if (player_relations.getDefault() & PlayerRelation::TRADE) { @@ -723,17 +651,14 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) { if (being->isShopEnabled()) { - mBrowserBox->addRow(strprintf( - "@@buy|%s@@", _("Buy"))); - mBrowserBox->addRow(strprintf( - "@@sell|%s@@", _("Sell"))); + mBrowserBox->addRow("buy", _("Buy")); + mBrowserBox->addRow("sell", _("Sell")); } } else { - mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy (?)"))); - mBrowserBox->addRow(strprintf( - "@@sell|%s@@", _("Sell (?)"))); + mBrowserBox->addRow("buy", _("Buy (?)")); + mBrowserBox->addRow("sell", _("Sell (?)")); } } @@ -745,13 +670,12 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) { if (!player_node->getParty()->isMember(wTab->getNick())) { - mBrowserBox->addRow( - strprintf("@@party|%s@@", _("Invite to party"))); + mBrowserBox->addRow("party", _("Invite to party")); } else { - mBrowserBox->addRow(strprintf( - "@@kick party|%s@@", _("Kick from party"))); + mBrowserBox->addRow("kick party", + _("Kick from party")); } mBrowserBox->addRow("##3---"); } @@ -782,8 +706,7 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) if (guild2->getServerGuild() || (guildManager && guildManager->havePower())) { - mBrowserBox->addRow(strprintf( - "@@guild|%s@@", _("Invite to guild"))); + mBrowserBox->addRow("guild", _("Invite to guild")); } } } @@ -793,8 +716,8 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) mNick = name; mType = Being::PLAYER; - mBrowserBox->addRow(strprintf("@@follow|%s@@", _("Follow"))); - mBrowserBox->addRow(strprintf("@@imitation|%s@@", _("Imitation"))); + mBrowserBox->addRow("follow", _("Follow")); + mBrowserBox->addRow("imitation", _("Imitation")); if (player_node->isInParty()) { @@ -803,16 +726,12 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) { PartyMember *m = party->getMember(mNick); if (m) - { - mBrowserBox->addRow(strprintf( - "@@move|%s@@", _("Move"))); - } + mBrowserBox->addRow("move", _("Move")); } } - mBrowserBox->addRow(strprintf("@@items|%s@@", _("Show Items"))); - mBrowserBox->addRow(strprintf("@@undress|%s@@", _("Undress"))); - mBrowserBox->addRow(strprintf( - "@@addcomment|%s@@", _("Add comment"))); + mBrowserBox->addRow("items", _("Show Items")); + mBrowserBox->addRow("undress", _("Undress")); + mBrowserBox->addRow("addcomment", _("Add comment")); if (player_relations.getDefault() & PlayerRelation::TRADE) { @@ -821,23 +740,20 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) { if (being->isShopEnabled()) { - mBrowserBox->addRow(strprintf( - "@@buy|%s@@", _("Buy"))); - mBrowserBox->addRow(strprintf( - "@@sell|%s@@", _("Sell"))); + mBrowserBox->addRow("buy", _("Buy")); + mBrowserBox->addRow("sell", _("Sell")); } } else { - mBrowserBox->addRow(strprintf("@@buy|%s@@", _("Buy (?)"))); - mBrowserBox->addRow(strprintf( - "@@sell|%s@@", _("Sell (?)"))); + mBrowserBox->addRow("buy", _("Buy (?)")); + mBrowserBox->addRow("sell", _("Sell (?)")); } } mBrowserBox->addRow("##3---"); } } - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -861,7 +777,7 @@ void PopupMenu::showChangePos(int x, int y) mBrowserBox->addRow(strprintf("@@guild-pos-%d|%s@@", itr->first, itr->second.c_str())); } - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -1722,36 +1638,25 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item, { if (tradeWindow && tradeWindow->isVisible()) { - mBrowserBox->addRow(strprintf("@@addtrade|%s@@", - _("Add to trade"))); + mBrowserBox->addRow("addtrade", _("Add to trade")); if (cnt > 1) { if (cnt > 10) - { - mBrowserBox->addRow(strprintf("@@addtrade 10|%s@@", - _("Add to trade 10"))); - } - mBrowserBox->addRow(strprintf("@@addtrade half|%s@@", - _("Add to trade half"))); - mBrowserBox->addRow(strprintf("@@addtrade all|%s@@", - _("Add to trade all"))); + mBrowserBox->addRow("addtrade 10", _("Add to trade 10")); + mBrowserBox->addRow("addtrade half", _("Add to trade half")); + mBrowserBox->addRow("addtrade all", _("Add to trade all")); } mBrowserBox->addRow("##3---"); } if (InventoryWindow::isStorageActive()) { - mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store"))); + mBrowserBox->addRow("store", _("Store")); if (cnt > 1) { if (cnt > 10) - { - mBrowserBox->addRow(strprintf("@@store 10|%s@@", - _("Store 10"))); - } - mBrowserBox->addRow(strprintf("@@store half|%s@@", - _("Store half"))); - mBrowserBox->addRow(strprintf("@@store all|%s@@", - _("Store all"))); + mBrowserBox->addRow("store 10", _("Store 10")); + mBrowserBox->addRow("store half", _("Store half")); + mBrowserBox->addRow("store all", _("Store all")); } mBrowserBox->addRow("##3---"); } @@ -1759,48 +1664,45 @@ void PopupMenu::showPopup(Window *parent, int x, int y, Item *item, if (item->isEquipment()) { if (item->isEquipped()) - mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip"))); + mBrowserBox->addRow("use", _("Unequip")); else - mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip"))); + mBrowserBox->addRow("use", _("Equip")); } else - mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use"))); + { + mBrowserBox->addRow("use", _("Use")); + } if (cnt > 1) { - mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop..."))); - mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all"))); + mBrowserBox->addRow("drop", _("Drop...")); + mBrowserBox->addRow("drop all", _("Drop all")); } else { - mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop"))); + mBrowserBox->addRow("drop", _("Drop")); } if (Net::getInventoryHandler()->canSplit(item)) - mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split"))); + mBrowserBox->addRow("split", _("Split")); } // Assume in storage for now // TODO: make this whole system more flexible, if needed else { - mBrowserBox->addRow(strprintf("@@retrieve|%s@@", _("Retrieve"))); + mBrowserBox->addRow("retrieve", _("Retrieve")); if (cnt > 1) { if (cnt > 10) - { - mBrowserBox->addRow(strprintf("@@retrieve 10|%s@@", - _("Retrieve 10"))); - } - mBrowserBox->addRow(strprintf("@@retrieve half|%s@@", - _("Retrieve half"))); - mBrowserBox->addRow(strprintf("@@retrieve all|%s@@", - _("Retrieve all"))); + mBrowserBox->addRow("retrieve 10", _("Retrieve 10")); + mBrowserBox->addRow("retrieve half", _("Retrieve half")); + mBrowserBox->addRow("retrieve all", _("Retrieve all")); } } - mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat"))); + mBrowserBox->addRow("chat", _("Add to chat")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -1823,12 +1725,12 @@ void PopupMenu::showItemPopup(int x, int y, int itemId, unsigned char color) mItemColor = color; mBrowserBox->clearRows(); - mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use"))); + mBrowserBox->addRow("use", _("Use")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@load old item shortcuts|%s@@", - _("Load old item shortcuts"))); + mBrowserBox->addRow("load old item shortcuts", + _("Load old item shortcuts")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -1854,37 +1756,37 @@ void PopupMenu::showItemPopup(int x, int y, Item *item) if (item->isEquipment()) { if (item->isEquipped()) - mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip"))); + mBrowserBox->addRow("use", _("Unequip")); else - mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip"))); + mBrowserBox->addRow("use", _("Equip")); } else { - mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use"))); + mBrowserBox->addRow("use", _("Use")); } if (item->getQuantity() > 1) { - mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop..."))); - mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all"))); + mBrowserBox->addRow("drop", _("Drop...")); + mBrowserBox->addRow("drop all", _("Drop all")); } else { - mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop"))); + mBrowserBox->addRow("drop", _("Drop")); } if (Net::getInventoryHandler()->canSplit(item)) - mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split"))); + mBrowserBox->addRow("split", _("Split")); if (InventoryWindow::isStorageActive()) - mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store"))); - mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat"))); + mBrowserBox->addRow("store", _("Store")); + mBrowserBox->addRow("chat", _("Add to chat")); mBrowserBox->addRow("##3---"); } - mBrowserBox->addRow(strprintf("@@load old item shortcuts|%s@@", - _("Load old item shortcuts"))); + mBrowserBox->addRow("load old item shortcuts", + _("Load old item shortcuts")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -1899,35 +1801,37 @@ void PopupMenu::showDropPopup(int x, int y, Item *item) if (item->isEquipment()) { if (item->isEquipped()) - mBrowserBox->addRow(strprintf("@@use|%s@@", _("Unequip"))); + mBrowserBox->addRow("use", _("Unequip")); else - mBrowserBox->addRow(strprintf("@@use|%s@@", _("Equip"))); + mBrowserBox->addRow("use", _("Equip")); } else - mBrowserBox->addRow(strprintf("@@use|%s@@", _("Use"))); + { + mBrowserBox->addRow("use", _("Use")); + } if (item->getQuantity() > 1) { - mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop..."))); - mBrowserBox->addRow(strprintf("@@drop all|%s@@", _("Drop all"))); + mBrowserBox->addRow("drop", _("Drop...")); + mBrowserBox->addRow("drop all", _("Drop all")); } else { - mBrowserBox->addRow(strprintf("@@drop|%s@@", _("Drop"))); + mBrowserBox->addRow("drop", _("Drop")); } if (Net::getInventoryHandler()->canSplit(item)) - mBrowserBox->addRow(strprintf("@@split|%s@@", _("Split"))); + mBrowserBox->addRow("split", _("Split")); if (InventoryWindow::isStorageActive()) - mBrowserBox->addRow(strprintf("@@store|%s@@", _("Store"))); - mBrowserBox->addRow(strprintf("@@chat|%s@@", _("Add to chat"))); + mBrowserBox->addRow("store", _("Store")); + mBrowserBox->addRow("chat", _("Add to chat")); mBrowserBox->addRow("##3---"); } - mBrowserBox->addRow(strprintf("@@load old drop shortcuts|%s@@", - _("Load old drop shortcuts"))); + mBrowserBox->addRow("load old drop shortcuts", + _("Load old drop shortcuts")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -1962,7 +1866,7 @@ void PopupMenu::showPopup(int x, int y, Button *button) } } mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -1998,11 +1902,10 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b) } mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@reset yellow|%s@@", - _("Reset yellow bar"))); + mBrowserBox->addRow("reset yellow", _("Reset yellow bar")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@bar to chat|%s@@", _("Copy to chat"))); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("bar to chat", _("Copy to chat")); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -2010,7 +1913,7 @@ void PopupMenu::showPopup(int x, int y, ProgressBar *b) void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name, int type) { - if (!player_node) + if (!player_node || !actorSpriteManager) return; mNick = name; @@ -2029,17 +1932,10 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name, int idx = actorSpriteManager->getAttackMobIndex(name); int size = actorSpriteManager->getAttackMobsSize(); if (idx > 0) - { - mBrowserBox->addRow(strprintf( - "@@attack moveup|%s@@", _("Move up"))); - } + mBrowserBox->addRow("attack moveup", _("Move up")); if (idx + 1 < size) - { - mBrowserBox->addRow(strprintf( - "@@attack movedown|%s@@", _("Move down"))); - } - mBrowserBox->addRow(strprintf( - "@@attack remove|%s@@", _("Remove"))); + mBrowserBox->addRow("attack movedown", _("Move down")); + mBrowserBox->addRow("attack remove", _("Remove")); break; } case MapItem::PRIORITY: @@ -2047,29 +1943,21 @@ void PopupMenu::showAttackMonsterPopup(int x, int y, std::string name, int idx = actorSpriteManager->getPriorityAttackMobIndex(name); int size = actorSpriteManager->getPriorityAttackMobsSize(); if (idx > 0) - { - mBrowserBox->addRow(strprintf( - "@@priority moveup|%s@@", _("Move up"))); - } + mBrowserBox->addRow("priority moveup", _("Move up")); if (idx + 1 < size) - { - mBrowserBox->addRow(strprintf( - "@@priority movedown|%s@@", _("Move down"))); - } - mBrowserBox->addRow(strprintf( - "@@attack remove|%s@@", _("Remove"))); + mBrowserBox->addRow("priority movedown", _("Move down")); + mBrowserBox->addRow("attack remove", _("Remove")); break; } case MapItem::IGNORE_: - mBrowserBox->addRow(strprintf( - "@@attack remove|%s@@", _("Remove"))); + mBrowserBox->addRow("attack remove", _("Remove")); break; default: break; } mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); } @@ -2086,10 +1974,10 @@ void PopupMenu::showUndressPopup(int x, int y, Being *being, Item *item) mBrowserBox->clearRows(); - mBrowserBox->addRow(strprintf("@@undress item|%s@@", _("Undress"))); + mBrowserBox->addRow("undress item", _("Undress")); mBrowserBox->addRow("##3---"); - mBrowserBox->addRow(strprintf("@@cancel|%s@@", _("Cancel"))); + mBrowserBox->addRow("cancel", _("Cancel")); showPopup(x, y); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index c20eb4622..1419e213c 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -256,6 +256,11 @@ void BrowserBox::addRow(const std::string &row, bool atTop) updateHeight(); } +void BrowserBox::addRow(const std::string &cmd, char *text) +{ + addRow(strprintf("@@%s|%s@@", cmd.c_str(), text)); +} + void BrowserBox::addImage(const std::string &path) { if (!mEnableImages) diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index cd69ce56f..e86f0288e 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -112,6 +112,11 @@ class BrowserBox : public gcn::Widget, */ void addRow(const std::string &row, bool atTop = false); + /** + * Adds a menu line to the browser. + */ + void addRow(const std::string &cmd, char *text); + void addImage(const std::string &path); /** -- cgit v1.2.3-60-g2f50 From 6ac937583f9589e7049f2eb51eca62f2249ba7d6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 16 Sep 2011 03:13:32 +0300 Subject: Fix status popup height. --- src/gui/statuspopup.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index 5c28641dc..13b5d575e 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -159,7 +159,8 @@ void StatusPopup::update() const int fontHeight = getFont()->getHeight(); - setHeight(24 + 8 + 14 * fontHeight + getPadding()); + setHeight(mDisableGameModifiers->getY() + + mDisableGameModifiers->getHeight() + 2 * getPadding()); } void StatusPopup::view(int x, int y) -- cgit v1.2.3-60-g2f50 From 2af5e3f72aef14b5b541b7c47878e0a13a343b85 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 16 Sep 2011 03:19:47 +0300 Subject: Fix code style. --- src/being.cpp | 4 ++-- src/gui/statuspopup.cpp | 2 -- src/localplayer.cpp | 5 +---- src/openglgraphics.cpp | 6 ++++-- 4 files changed, 7 insertions(+), 10 deletions(-) (limited to 'src/gui') diff --git a/src/being.cpp b/src/being.cpp index 73e1819a0..86695ee61 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -1409,8 +1409,8 @@ void Being::drawSpeech(int offsetX, int offsetY) if (!mText && userPalette) { mText = new Text(mSpeech, getPixelX(), getPixelY() - getHeight(), - gcn::Graphics::CENTER, &userPalette->getColor(UserPalette::PARTICLE), - true); + gcn::Graphics::CENTER, &userPalette->getColor( + UserPalette::PARTICLE), true); } } else if (speech == NO_SPEECH) diff --git a/src/gui/statuspopup.cpp b/src/gui/statuspopup.cpp index 13b5d575e..fee6450df 100644 --- a/src/gui/statuspopup.cpp +++ b/src/gui/statuspopup.cpp @@ -157,8 +157,6 @@ void StatusPopup::update() minWidth += 16 + 2 * getPadding(); setWidth(minWidth); - const int fontHeight = getFont()->getHeight(); - setHeight(mDisableGameModifiers->getY() + mDisableGameModifiers->getHeight() + 2 * getPadding()); } diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 8105f3291..e17cf09c4 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -350,11 +350,8 @@ void LocalPlayer::logic() if (mEnableAdvert && !mBlockAdvert && mAdvertTime < cur_time) { Uint8 smile = FLAG_SPECIAL; - if (mTradebot && shopWindow && shopWindow - && !shopWindow->isShopEmpty()) - { + if (mTradebot && shopWindow && !shopWindow->isShopEmpty()) smile += FLAG_SHOP; - } if (mAwayMode) smile += FLAG_AWAY; diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp index b67d4b2be..2ec5db490 100644 --- a/src/openglgraphics.cpp +++ b/src/openglgraphics.cpp @@ -529,7 +529,8 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, for (int py = 0; py < h; py += scaledHeight) { - const int height = (py + scaledHeight >= h) ? h - py : scaledHeight; + const int height = (py + scaledHeight >= h) + ? h - py : scaledHeight; const int dstY = y + py; for (int px = 0; px < w; px += scaledWidth) { @@ -583,7 +584,8 @@ void OpenGLGraphics::drawRescaledImagePattern(Image *image, for (int py = 0; py < h; py += scaledHeight) { - const int height = (py + scaledHeight >= h) ? h - py : scaledHeight; + const int height = (py + scaledHeight >= h) + ? h - py : scaledHeight; const int dstY = y + py; for (int px = 0; px < w; px += scaledWidth) { -- cgit v1.2.3-60-g2f50 From 0680f936ce4be3cbd0cba338d3793d4a7782db60 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 16 Sep 2011 13:43:33 +0300 Subject: Fix crash in context menu. --- src/gui/popupmenu.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'src/gui') diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 715b1d983..16e3d9ec7 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -736,19 +736,8 @@ void PopupMenu::showChatPopup(int x, int y, ChatTab *tab) if (player_relations.getDefault() & PlayerRelation::TRADE) { mBrowserBox->addRow("##3---"); - if (being->isAdvanced()) - { - if (being->isShopEnabled()) - { - mBrowserBox->addRow("buy", _("Buy")); - mBrowserBox->addRow("sell", _("Sell")); - } - } - else - { - mBrowserBox->addRow("buy", _("Buy (?)")); - mBrowserBox->addRow("sell", _("Sell (?)")); - } + mBrowserBox->addRow("buy", _("Buy (?)")); + mBrowserBox->addRow("sell", _("Sell (?)")); } mBrowserBox->addRow("##3---"); } -- cgit v1.2.3-60-g2f50