diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-30 22:51:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-30 22:51:23 +0300 |
commit | ef8ef35d28daa3ea7dd542078ac9c0d3f7a9a5e2 (patch) | |
tree | c3d7c79fca18ac387d0c90512ef3201c92da5890 /src/gui | |
parent | 22b64d16b613c1e5b26632237879b167024788ab (diff) | |
download | mv-ef8ef35d28daa3ea7dd542078ac9c0d3f7a9a5e2.tar.gz mv-ef8ef35d28daa3ea7dd542078ac9c0d3f7a9a5e2.tar.bz2 mv-ef8ef35d28daa3ea7dd542078ac9c0d3f7a9a5e2.tar.xz mv-ef8ef35d28daa3ea7dd542078ac9c0d3f7a9a5e2.zip |
Move some variables to better scope.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.cpp | 2 | ||||
-rw-r--r-- | src/gui/shortcut/itemshortcut.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chat/whispertab.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 16 | ||||
-rw-r--r-- | src/gui/windows/skilldialog.cpp | 8 |
7 files changed, 22 insertions, 21 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 67735e2a6..706a5f0b8 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -1257,7 +1257,7 @@ Widget* Gui::getWidgetAt(const int x, const int y) const parent->getAbsolutePosition(parentX, parentY); child = parent->getWidgetAt(x - parentX, y - parentY); parent = swap; - if ((parent != nullptr) && parent->isSelectable()) + if (parent->isSelectable()) selectable = parent; } diff --git a/src/gui/shortcut/itemshortcut.cpp b/src/gui/shortcut/itemshortcut.cpp index 8c091f8c1..f47bfd296 100644 --- a/src/gui/shortcut/itemshortcut.cpp +++ b/src/gui/shortcut/itemshortcut.cpp @@ -121,9 +121,9 @@ void ItemShortcut::save() const { const int itemId = mItems[i] != 0 ? mItems[i] : -1; const int itemColor = toInt(mItemColors[i], int); - const std::string itemData = mItemData[i]; if (itemId != -1) { + const std::string itemData = mItemData[i]; serverConfig.setValue(name + toString(i), itemId); serverConfig.setValue(color + toString(i), itemColor); serverConfig.setValue(data + toString(i), itemData); diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 630f7e9bf..b67ea756a 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -953,7 +953,7 @@ Rect ScrollArea::getVerticalBarDimension() const if (!mVBarVisible) return Rect(0, 0, 0, 0); - const int height = (mVBarVisible && mShowButtons) ? mScrollbarWidth : 0; + const int height = mShowButtons ? mScrollbarWidth : 0; if (mHBarVisible) { return Rect(mDimension.width - mScrollbarWidth, @@ -1122,10 +1122,10 @@ Rect ScrollArea::getDownButtonDimension() const if (!mVBarVisible || !mShowButtons) return Rect(0, 0, 0, 0); - if (mVBarVisible && mHBarVisible) + if (mHBarVisible) { return Rect(mDimension.width - mScrollbarWidth, - mDimension.height - mScrollbarWidth*2, + mDimension.height - mScrollbarWidth * 2, mScrollbarWidth, mScrollbarWidth); } @@ -1150,7 +1150,7 @@ Rect ScrollArea::getRightButtonDimension() const if (!mHBarVisible || !mShowButtons) return Rect(0, 0, 0, 0); - if (mVBarVisible && mHBarVisible) + if (mVBarVisible) { return Rect(mDimension.width - mScrollbarWidth*2, mDimension.height - mScrollbarWidth, diff --git a/src/gui/widgets/tabs/chat/whispertab.cpp b/src/gui/widgets/tabs/chat/whispertab.cpp index d8672b22d..73b73a17c 100644 --- a/src/gui/widgets/tabs/chat/whispertab.cpp +++ b/src/gui/widgets/tabs/chat/whispertab.cpp @@ -71,11 +71,11 @@ void WhisperTab::handleCommandStr(const std::string &msg) const size_t pos = msg.find(' '); const std::string type(msg, 0, pos); - const std::string args(msg, pos == std::string::npos - ? msg.size() : pos + 1); if (type == "me") { + const std::string args(msg, pos == std::string::npos + ? msg.size() : pos + 1); std::string str = textToMe(args); chatHandler->privateMessage(mNick, str); if (localPlayer != nullptr) diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 9d9385f8d..b192bad35 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -642,8 +642,6 @@ void Window::setResizable(const bool r) void Window::widgetResized(const Event &event A_UNUSED) { - const Rect area = getChildrenArea(); - if (mGrip != nullptr) { mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding; @@ -652,6 +650,7 @@ void Window::widgetResized(const Event &event A_UNUSED) if (mLayout != nullptr) { + const Rect area = getChildrenArea(); int w = area.width; int h = area.height; mLayout->reflow(w, h); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index e29212063..25c85638a 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -702,13 +702,15 @@ void ChatWindow::doPresent() const } } - const std::string log = strprintf( - // TRANSLATORS: chat message - _("Present: %s; %d players are present."), - response.c_str(), playercount); - - if (getFocused() != nullptr) - getFocused()->chatLog(log, ChatMsgType::BY_SERVER); + ChatTab *const tab = getFocused(); + if (tab != nullptr) + { + const std::string log = strprintf( + // TRANSLATORS: chat message + _("Present: %s; %d players are present."), + response.c_str(), playercount); + tab->chatLog(log, ChatMsgType::BY_SERVER); + } } void ChatWindow::scroll(const int amount) const diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index b5a49b0ca..20d95a055 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -474,13 +474,13 @@ SkillInfo *SkillDialog::loadSkill(XmlNodeConstPtr node, id += SKILL_VAR_MIN_ID; } - std::string name = XML::langProperty(node, "name", - // TRANSLATORS: skills dialog. skill id - strprintf(_("Skill %d"), id)); - SkillInfo *skill = getSkill(id); if (skill == nullptr) { + std::string name = XML::langProperty(node, "name", + // TRANSLATORS: skills dialog. skill id + strprintf(_("Skill %d"), id)); + skill = new SkillInfo; skill->id = CAST_U32(id); skill->modifiable = Modifiable_false; |