diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-04-13 22:54:28 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-04-13 22:54:28 +0300 |
commit | bcdf34645ff3067d3b4110120b6191af2b0b2e99 (patch) | |
tree | 428493a138f0fdaebd4c915153f0dcdcbaedf76d /src/gui | |
parent | a93d1e06f928f6e4e1c7f3c58ddb7ae3676c1c63 (diff) | |
parent | b64a1f46b930516927b1290c1d6771b491b84958 (diff) | |
download | mv-bcdf34645ff3067d3b4110120b6191af2b0b2e99.tar.gz mv-bcdf34645ff3067d3b4110120b6191af2b0b2e99.tar.bz2 mv-bcdf34645ff3067d3b4110120b6191af2b0b2e99.tar.xz mv-bcdf34645ff3067d3b4110120b6191af2b0b2e99.zip |
Merge branch 'master' into stable
Diffstat (limited to 'src/gui')
57 files changed, 249 insertions, 213 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 9a50583b9..4ad1138eb 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -535,6 +535,8 @@ void Gui::videoResized() const top->setSize(mainGraphics->mWidth, mainGraphics->mHeight); top->adjustAfterResize(oldWidth, oldHeight); } + + Widget::distributeWindowResizeEvent(); } void Gui::setUseCustomCursor(const bool customCursor) @@ -1301,6 +1303,7 @@ void Gui::distributeKeyEvent(KeyEvent &event) const void Gui::distributeKeyEventToGlobalKeyListeners(KeyEvent& event) { + BLOCK_START("Gui::distributeKeyEventToGlobalKeyListeners") const unsigned int eventType = event.getType(); FOR_EACH (KeyListenerListIterator, it, mKeyListeners) { @@ -1319,6 +1322,7 @@ void Gui::distributeKeyEventToGlobalKeyListeners(KeyEvent& event) if (event.isConsumed()) break; } + BLOCK_END("Gui::distributeKeyEventToGlobalKeyListeners") } void Gui::handleModalMouseInputFocus() diff --git a/src/gui/models/iconsmodel.h b/src/gui/models/iconsmodel.h index c3031169c..b462f8a23 100644 --- a/src/gui/models/iconsmodel.h +++ b/src/gui/models/iconsmodel.h @@ -48,7 +48,7 @@ class IconsModel final : public ListModel continue; const ItemInfo &info = (*i->second); - const std::string name = info.getName(); + const std::string &name = info.getName(); if (name != "unnamed" && !info.getName().empty() && info.getName() != "unnamed") { diff --git a/src/gui/models/itemsmodel.h b/src/gui/models/itemsmodel.h index 808ae0f04..83d9f0776 100644 --- a/src/gui/models/itemsmodel.h +++ b/src/gui/models/itemsmodel.h @@ -50,7 +50,7 @@ class ItemsModal final : public ListModel continue; const ItemInfo &info = *i->second; - const std::string name = info.getName(); + const std::string &name = info.getName(); if (name != "unnamed" && !info.getName().empty() && info.getName() != "unnamed") { diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 330df1a6c..c8416f66d 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -814,7 +814,7 @@ void PopupMenu::showChangePos(const int x, const int y) const Guild *const guild = player_node->getGuild(); if (guild) { - const PositionsMap map = guild->getPositions(); + const PositionsMap &map = guild->getPositions(); FOR_EACH (PositionsMap::const_iterator, itr, map) { mBrowserBox->addRow(strprintf("@@guild-pos-%u|%s@@", @@ -2164,7 +2164,7 @@ void PopupMenu::showPopup(const int x, const int y, Button *const button) if (!btn || btn->getActionEventId() == "SET") continue; - if (btn->isVisible()) + if (btn->isVisibleLocal()) { mBrowserBox->addRow(strprintf("@@hide button_%s|%s %s (%s)@@", // TRANSLATORS: popup menu item @@ -2209,7 +2209,7 @@ void PopupMenu::showPopup(const int x, const int y, const ProgressBar *const b) if (!bar) continue; - if (bar->isVisible()) + if (bar->isVisibleLocal()) { cnt ++; onlyBar = bar; @@ -2225,7 +2225,7 @@ void PopupMenu::showPopup(const int x, const int y, const ProgressBar *const b) if (!bar || bar == onlyBar) continue; - if (bar->isVisible()) + if (bar->isVisibleLocal()) { mBrowserBox->addRow(strprintf("@@hide bar_%s|%s %s@@", // TRANSLATORS: popup menu item diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 6fa007e06..1b1955647 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -1126,6 +1126,19 @@ void Theme::loadColors(std::string file) } } +#define loadGrid() \ + { \ + const ImageRect &rect = skin->getBorder(); \ + for (int f = start; f <= end; f ++) \ + { \ + if (rect.grid[f]) \ + { \ + image.grid[f] = rect.grid[f]; \ + image.grid[f]->incRef(); \ + } \ + } \ + } + void Theme::loadRect(ImageRect &image, const std::string &name, const std::string &name2, @@ -1135,15 +1148,7 @@ void Theme::loadRect(ImageRect &image, Skin *const skin = load(name, name2, false); if (skin) { - const ImageRect &rect = skin->getBorder(); - for (int f = start; f <= end; f ++) - { - if (rect.grid[f]) - { - image.grid[f] = rect.grid[f]; - image.grid[f]->incRef(); - } - } + loadGrid(); unload(skin); } } @@ -1156,17 +1161,7 @@ Skin *Theme::loadSkinRect(ImageRect &image, { Skin *const skin = load(name, name2); if (skin) - { - const ImageRect &rect = skin->getBorder(); - for (int f = start; f <= end; f ++) - { - if (rect.grid[f]) - { - image.grid[f] = rect.grid[f]; - image.grid[f]->incRef(); - } - } - } + loadGrid(); return skin; } diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index df97a5673..46d47ab4a 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -276,6 +276,7 @@ void Viewport::logic() void Viewport::followMouse() { + return; if (!gui) return; const uint8_t button = Gui::getMouseState(&mMouseX, &mMouseY); @@ -667,7 +668,10 @@ void Viewport::walkByMouse(const MouseEvent &event) void Viewport::mouseDragged(MouseEvent &event) { if (event.getSource() != this || event.isConsumed()) + { + mPlayerFollowMouse = false; return; + } if (mMouseClicked) { if (abs(event.getX() - mMousePressX) > 32 @@ -879,13 +883,16 @@ void Viewport::mouseMoved(MouseEvent &event A_UNUSED) if (!mMap || !player_node || !actorManager) return; + if (mMouseDirectionMove) + mPlayerFollowMouse = false; + const int x = mMouseX + mPixelViewX; const int y = mMouseY + mPixelViewY; ActorSprite::Type type = ActorSprite::UNKNOWN; + mHoverBeing = actorManager->findBeingByPixel(x, y, true); if (mHoverBeing) type = mHoverBeing->getType(); - mHoverBeing = actorManager->findBeingByPixel(x, y, true); if (mHoverBeing && (type == Being::PLAYER || type == Being::NPC diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 9411c2249..ecb92f876 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -99,13 +99,16 @@ void AvatarListBox::draw(Graphics *graphics) return; } + const Widget *const parent = mParent; + if (!parent) + return; + AvatarListModel *const model = static_cast<AvatarListModel *const>( mListModel); updateAlpha(); Font *const font = getFont(); const int fontHeight = getFont()->getHeight(); - const Widget *const parent = mParent; const std::string name = player_node->getName(); // Draw the list elements @@ -155,7 +158,7 @@ void AvatarListBox::draw(Graphics *graphics) a->getHp(), a->getMaxHp()); } const bool isPoison = a->getPoison(); - if (a->getMaxHp() && (isPoison || parent)) + if (a->getMaxHp()) { const int themeColor = (isPoison ? Theme::PROG_HP_POISON : Theme::PROG_HP); @@ -182,28 +185,25 @@ void AvatarListBox::draw(Graphics *graphics) a->getDamageHp()); } - if (parent) - { - const int themeColor = (a->getPoison() - ? Theme::PROG_HP_POISON : Theme::PROG_HP); - Color color = Theme::getProgressColor(themeColor, 1); - color.a = 80; - graphics->setColor(color); - graphics->fillRectangle(Rect(mPadding, y + mPadding, - parent->getWidth() * a->getDamageHp() / 1024 - - 2 * mPadding, fontHeight)); + const int themeColor = (a->getPoison() + ? Theme::PROG_HP_POISON : Theme::PROG_HP); + Color color = Theme::getProgressColor(themeColor, 1); + color.a = 80; + graphics->setColor(color); + graphics->fillRectangle(Rect(mPadding, y + mPadding, + parent->getWidth() * a->getDamageHp() / 1024 + - 2 * mPadding, fontHeight)); - if (a->getLevel() > 1) - { - graphics->setColor(mForegroundColor); - int minHp = 40 + ((a->getLevel() - 1) * 5); - if (minHp < 0) - minHp = 40; - - graphics->drawLine(parent->getWidth()*minHp / 1024 - + mPadding, y + mPadding, - parent->getWidth() * minHp / 1024, y + fontHeight); - } + if (a->getLevel() > 1) + { + graphics->setColor(mForegroundColor); + int minHp = 40 + ((a->getLevel() - 1) * 5); + if (minHp < 0) + minHp = 40; + + graphics->drawLine(parent->getWidth()*minHp / 1024 + + mPadding, y + mPadding, + parent->getWidth() * minHp / 1024, y + fontHeight); } } else @@ -307,8 +307,7 @@ void AvatarListBox::draw(Graphics *graphics) if (useCaching) graphics->drawTileCollection(&vertexes); - if (parent) - setWidth(parent->getWidth() - 10); + setWidth(parent->getWidth() - 10); BLOCK_END("AvatarListBox::draw") } diff --git a/src/gui/widgets/basiccontainer.cpp b/src/gui/widgets/basiccontainer.cpp index 00386a725..4803373f2 100644 --- a/src/gui/widgets/basiccontainer.cpp +++ b/src/gui/widgets/basiccontainer.cpp @@ -298,7 +298,7 @@ void BasicContainer::drawChildren(Graphics* graphics) FOR_EACH (WidgetListConstIterator, iter, mWidgets) { Widget *const widget = *iter; - if (widget->isVisible()) + if (widget->isVisibleLocal()) { // If the widget has a frame, // draw it before drawing the widget diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 054a338aa..b1f41e23e 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -127,7 +127,6 @@ Button::Button(const Widget2 *const widget) : mYOffset(0), mImageWidth(0), mImageHeight(0), - mRedraw(true), mStick(false), mPressed(false) { @@ -169,7 +168,6 @@ Button::Button(const Widget2 *const widget, mYOffset(0), mImageWidth(0), mImageHeight(0), - mRedraw(true), mStick(false), mPressed(false) { @@ -217,7 +215,6 @@ Button::Button(const Widget2 *const widget, mYOffset(0), mImageWidth(imageWidth), mImageHeight(imageHeight), - mRedraw(true), mStick(false), mPressed(false) { @@ -265,7 +262,6 @@ Button::Button(const Widget2 *const widget, mYOffset(0), mImageWidth(imageWidth), mImageHeight(imageHeight), - mRedraw(true), mStick(false), mPressed(false) { @@ -313,7 +309,6 @@ Button::Button(const Widget2 *const widget, mYOffset(0), mImageWidth(0), mImageHeight(0), - mRedraw(true), mStick(false), mPressed(false) { diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 57a024195..015faf009 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -335,7 +335,6 @@ class Button final : public Widget, int mYOffset; int mImageWidth; int mImageHeight; - bool mRedraw; bool mStick; bool mPressed; }; diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 06dcecab0..765ff13ec 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -189,7 +189,7 @@ void CheckBox::drawBox(Graphics *const graphics) const ImageRect &rect = mSkin->getBorder(); int index = 0; - if (mEnabled && isVisible()) + if (mEnabled && mVisible) { if (mSelected) { diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 6ae892c81..3e77a65a5 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -28,6 +28,8 @@ #include "input/inputmanager.h" +#include "render/opengldebug.h" + #include "resources/image.h" #include "resources/imagehelper.h" #include "resources/resourcemanager.h" @@ -111,6 +113,7 @@ void Desktop::widgetResized(const Event &event A_UNUSED) void Desktop::draw(Graphics *graphics) { BLOCK_START("Desktop::draw") + GLDEBUG_START("Desktop::draw") const Rect &rect = mDimension; const int width = rect.width; @@ -144,6 +147,7 @@ void Desktop::draw(Graphics *graphics) } Container::draw(graphics); + GLDEBUG_END() BLOCK_END("Desktop::draw") } diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 789d3e1aa..cbdd50cab 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -42,8 +42,7 @@ EmotePage::EmotePage(const Widget2 *const widget) : mEmotes(ResourceManager::getInstance()->getImageSet( "graphics/sprites/chatemotes.png", emoteWidth, emoteHeight)), mVertexes(new ImageCollection), - mSelectedIndex(-1), - mRedraw(true) + mSelectedIndex(-1) { addMouseListener(this); addWidgetListener(this); diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index 769e004bc..6aca546ca 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -58,7 +58,6 @@ class EmotePage final : public Widget, ImageSet *mEmotes; ImageCollection *mVertexes; int mSelectedIndex; - bool mRedraw; }; #endif // GUI_WIDGETS_EMOTEPAGE_H diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index c41e32854..341204505 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -275,7 +275,7 @@ void ListBox::mouseWheelMovedDown(MouseEvent &event A_UNUSED) void ListBox::mousePressed(MouseEvent &event) { mPressedIndex = getSelectionByMouse(event.getY()); - if (mPressedIndex != -1) + if (mMouseConsume && mPressedIndex != -1) event.consume(); } diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 2116de113..3c10a721f 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -43,8 +43,7 @@ Popup::Popup(const std::string &name, mMinHeight(40), mMaxWidth(mainGraphics->mWidth), mMaxHeight(mainGraphics->mHeight), - mVertexes(new ImageCollection), - mRedraw(true) + mVertexes(new ImageCollection) { logger->log("Popup::Popup(\"%s\")", name.c_str()); diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 01247cf61..5067b4658 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -187,7 +187,6 @@ class Popup : public Container, int mMaxHeight; /**< Maximum popup height */ ImageCollection *mVertexes; - bool mRedraw; }; #endif // GUI_WIDGETS_POPUP_H diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index fa0616fd2..c203f59c6 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -43,6 +43,8 @@ PopupList::PopupList(DropDown *const widget, mModal(modal) { mListBox->postInit(); + mListBox->setMouseConsume(false); + mScrollArea->setMouseConsume(false); mAllowLogic = false; setFocusable(true); diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index ea4ef11bd..4c82fe20c 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -56,8 +56,7 @@ ProgressBar::ProgressBar(const Widget2 *const widget, mFillPadding(3), mFillImage(false), mSmoothProgress(true), - mSmoothColorChange(true), - mRedraw(true) + mSmoothColorChange(true) { mBackgroundColor = Theme::getProgressColor(backColor >= 0 ? backColor : 0, mProgress); diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index fef9bf11d..e45bc4abb 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -159,7 +159,6 @@ class ProgressBar final : public Widget, bool mFillImage; bool mSmoothProgress; bool mSmoothColorChange; - bool mRedraw; }; #endif // GUI_WIDGETS_PROGRESSBAR_H diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 643517f77..27be9434b 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -176,7 +176,7 @@ void RadioButton::drawBox(Graphics* graphics) const ImageRect &rect = mSkin->getBorder(); int index = 0; - if (mEnabled && isVisible()) + if (mEnabled && mVisible) { if (mSelected) { diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 2efa144c9..b748e30a1 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -131,8 +131,7 @@ ScrollArea::ScrollArea(Widget2 *const widget2, mIsVerticalMarkerDragged(false), mIsHorizontalMarkerDragged(false), mOpaque(true), - mHasMouse(false), - mRedraw(true) + mHasMouse(false) { setContent(widget); addMouseListener(this); @@ -866,7 +865,7 @@ void ScrollArea::mouseReleased(MouseEvent& event) } mClickX = 0; mClickY = 0; - if (dx || dy) + if (mMouseConsume && (dx || dy)) event.consume(); } } @@ -876,7 +875,8 @@ void ScrollArea::mouseReleased(MouseEvent& event) mRightButtonPressed = false; mIsHorizontalMarkerDragged = false; mIsVerticalMarkerDragged = false; - event.consume(); + if (mMouseConsume) + event.consume(); mRedraw = true; } diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index d3d71b65a..0d540c399 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -586,7 +586,6 @@ class ScrollArea final : public BasicContainer, bool mOpaque; bool mHasMouse; - bool mRedraw; }; #endif // GUI_WIDGETS_SCROLLAREA_H diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 4c32b0572..87bc2baa5 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -713,8 +713,11 @@ SetupItemSlider::SetupItemSlider(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const double min, const double max, - const int width, const bool onTheFly, + const double min, + const double max, + const double step, + const int width, + const bool onTheFly, const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), mHorizont(nullptr), @@ -722,6 +725,7 @@ SetupItemSlider::SetupItemSlider(const std::string &restrict text, mSlider(nullptr), mMin(min), mMax(max), + mStep(step), mWidth(width), mOnTheFly(onTheFly) { @@ -734,7 +738,9 @@ SetupItemSlider::SetupItemSlider(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const double min, const double max, + const double min, + const double max, + const double step, const std::string &restrict def, const int width, const bool onTheFly, @@ -745,6 +751,7 @@ SetupItemSlider::SetupItemSlider(const std::string &restrict text, mSlider(nullptr), mMin(min), mMax(max), + mStep(step), mWidth(width), mOnTheFly(onTheFly) { @@ -766,7 +773,7 @@ void SetupItemSlider::createControls() mHorizont = new HorizontContainer(this, 32, 2); mLabel = new Label(this, mText); - mSlider = new Slider(this, mMin, mMax); + mSlider = new Slider(this, mMin, mMax, mStep); mSlider->setActionEventId(mEventName); mSlider->addActionListener(mParent); mSlider->setValue(atof(mValue.c_str())); @@ -823,7 +830,9 @@ SetupItemSlider2::SetupItemSlider2(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const int min, const int max, + const int min, + const int max, + const int step, SetupItemNames *restrict const values, const bool onTheFly, const bool mainConfig, @@ -836,6 +845,7 @@ SetupItemSlider2::SetupItemSlider2(const std::string &restrict text, mValues(values), mMin(min), mMax(max), + mStep(step), mInvertValue(0), mInvert(false), mOnTheFly(onTheFly), @@ -850,10 +860,13 @@ SetupItemSlider2::SetupItemSlider2(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const int min, const int max, + const int min, + const int max, + const int step, SetupItemNames *restrict const values, const std::string &restrict def, - const bool onTheFly, const bool mainConfig, + const bool onTheFly, + const bool mainConfig, const bool doNotAlign) : SetupItem(text, description, keyName, parent, eventName, def, mainConfig), mHorizont(nullptr), @@ -863,6 +876,7 @@ SetupItemSlider2::SetupItemSlider2(const std::string &restrict text, mValues(values), mMin(min), mMax(max), + mStep(step), mInvertValue(0), mInvert(false), mOnTheFly(onTheFly), @@ -890,7 +904,7 @@ void SetupItemSlider2::createControls() mLabel = new Label(this, mText); mLabel2 = new Label(this, ""); mLabel2->setWidth(width); - mSlider = new Slider(this, mMin, mMax); + mSlider = new Slider(this, mMin, mMax, mStep); mSlider->setActionEventId(mEventName); mSlider->addActionListener(mParent); mSlider->setValue(atof(mValue.c_str())); diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 7dee860be..03681ad90 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -350,19 +350,25 @@ class SetupItemSlider final : public SetupItem const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const double min, const double max, - const int width = 150, const bool onTheFly = false, - const bool mainConfig = true); + const double min, + const double max, + const double step, + const int width, + const bool onTheFly, + const bool mainConfig); SetupItemSlider(const std::string &restrict text, const std::string &restrict description, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const double min, const double max, - const std::string &restrict def, const int width = 150, - const bool onTheFly = false, - const bool mainConfig = true); + const double min, + const double max, + const double step, + const std::string &restrict def, + const int width, + const bool onTheFly, + const bool mainConfig); A_DELETE_COPY(SetupItemSlider) @@ -386,6 +392,7 @@ class SetupItemSlider final : public SetupItem Slider *mSlider; double mMin; double mMax; + double mStep; int mWidth; bool mOnTheFly; }; @@ -402,23 +409,23 @@ class SetupItemSlider2 final : public SetupItem const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const int min, const int max, + const int min, const int max, const int step, SetupItemNames *restrict const values, - const bool onTheFly = false, - const bool mainConfig = true, - const bool doNotAlign = false); + const bool onTheFly, + const bool mainConfig, + const bool doNotAlign); SetupItemSlider2(const std::string &restrict text, const std::string &restrict description, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - const int min, const int max, + const int min, const int max, const int step, SetupItemNames *restrict const values, const std::string &restrict def, - const bool onTheFly = false, - const bool mainConfig = true, - const bool doNotAlign = false); + const bool onTheFly, + const bool mainConfig, + const bool doNotAlign); A_DELETE_COPY(SetupItemSlider2) @@ -448,6 +455,7 @@ class SetupItemSlider2 final : public SetupItem SetupItemNames *mValues; int mMin; int mMax; + int mStep; int mInvertValue; bool mInvert; bool mOnTheFly; diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 49be84b88..e789c863d 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -42,8 +42,7 @@ ShortcutContainer::ShortcutContainer(Widget2 *const widget) : mBoxHeight(1), mGridWidth(1), mGridHeight(1), - mVertexes(new ImageCollection), - mRedraw(true) + mVertexes(new ImageCollection) { mAllowLogic = false; } diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 81392097b..d4d4ac4bf 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -93,9 +93,6 @@ class ShortcutContainer : public Widget, void drawBackground(Graphics *g); - void setRedraw(bool b) - { mRedraw = b; } - protected: /** * Constructor. Initializes the shortcut container. @@ -121,7 +118,6 @@ class ShortcutContainer : public Widget, int mGridWidth; int mGridHeight; ImageCollection *mVertexes; - bool mRedraw; }; #endif // GUI_WIDGETS_SHORTCUTCONTAINER_H diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index e440631ad..a08d94440 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -91,38 +91,38 @@ static std::string const data[2] = }; Slider::Slider(Widget2 *const widget, - const double scaleEnd) : + const double scaleEnd, + const double stepLength) : Widget(widget), MouseListener(), KeyListener(), mValue(0), - mStepLength(scaleEnd / 10), + mStepLength(stepLength), mScaleStart(0), mScaleEnd(scaleEnd), mOrientation(HORIZONTAL), mVertexes(new ImageCollection), mMarkerLength(10), - mHasMouse(false), - mRedraw(true) + mHasMouse(false) { init(); } Slider::Slider(Widget2 *const widget, const double scaleStart, - const double scaleEnd) : + const double scaleEnd, + const double stepLength) : Widget(widget), MouseListener(), KeyListener(), mValue(scaleStart), - mStepLength((scaleEnd - scaleStart) / 10), + mStepLength(stepLength), mScaleStart(scaleStart), mScaleEnd(scaleEnd), mOrientation(HORIZONTAL), mVertexes(new ImageCollection), mMarkerLength(10), - mHasMouse(false), - mRedraw(true) + mHasMouse(false) { init(); } @@ -368,7 +368,6 @@ void Slider::mousePressed(MouseEvent &event) setValue(markerPositionToValue(x - mMarkerLength / 2)); else setValue(markerPositionToValue(height - y - mMarkerLength / 2)); - distributeActionEvent(); } } @@ -450,18 +449,13 @@ void Slider::setValue(const double value) { mRedraw = true; if (value > mScaleEnd) - { mValue = mScaleEnd; - return; - } - - if (value < mScaleStart) - { + else if (value < mScaleStart) mValue = mScaleStart; - return; - } - - mValue = value; + else + mValue = value; + mValue = static_cast<int>((mValue - mScaleStart) / mStepLength) + * mStepLength + mScaleStart; } double Slider::markerPositionToValue(const int v) const diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 164048020..3cd43493e 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -98,15 +98,17 @@ class Slider final : public Widget, /** * Constructor with scale start equal to 0. */ - explicit Slider(Widget2 *const widget, - const double scaleEnd = 1.0); + Slider(Widget2 *const widget, + const double scaleEnd, + const double stepLength); /** * Constructor. */ Slider(Widget2 *const widget, const double scaleStart, - const double scaleEnd); + const double scaleEnd, + const double stepLength); A_DELETE_COPY(Slider) @@ -349,7 +351,6 @@ class Slider final : public Widget, int mMarkerLength; bool mHasMouse; - bool mRedraw; }; #endif // GUI_WIDGETS_SLIDER_H diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index cf55fa10b..cd439a95a 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -570,7 +570,7 @@ void TabbedArea::adjustTabPositions() maxTabHeight = tab->getHeight(); } - int x = (mEnableScrollButtons && mArrowButton[0]->isVisible()) + int x = (mEnableScrollButtons && mArrowButton[0]->isVisibleLocal()) ? mArrowButton[0]->getWidth() : 0; for (size_t i = mTabScrollIndex; i < sz; ++i) { diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp index 89a9594c1..707a4f2b9 100644 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ b/src/gui/widgets/tabs/setup_audio.cpp @@ -73,11 +73,13 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) : // TRANSLATORS: settings option new SetupItemSlider(_("Sfx volume"), "", "sfxVolume", - this, "sfxVolumeEvent", 0, soundManager.getMaxVolume(), 150, true); + this, "sfxVolumeEvent", 0, soundManager.getMaxVolume(), 1, + 150, true, true); // TRANSLATORS: settings option new SetupItemSlider(_("Music volume"), "", "musicVolume", - this, "musicVolumeEvent", 0, soundManager.getMaxVolume(), 150, true); + this, "musicVolumeEvent", 0, soundManager.getMaxVolume(), 1, + 150, true, true); // TRANSLATORS: settings option new SetupItemCheckBox(_("Enable music fade out"), "", @@ -97,7 +99,7 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) : mChannelsList->push_back(_("surround+center+lfe")); // TRANSLATORS: settings option new SetupItemSlider2(_("Audio channels"), "", "audioChannels", this, - "audioChannels", 1, 4, mChannelsList); + "audioChannels", 1, 4, 1, mChannelsList, false, true, false); // TRANSLATORS: settings group diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 00537ad05..53260ff01 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -61,23 +61,23 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mSelected(-1), // TRANSLATORS: colors tab. label. mGradTypeLabel(new Label(this, _("Type:"))), - mGradTypeSlider(new Slider(this, 0, 3)), + mGradTypeSlider(new Slider(this, 0.0, 3.0, 1.0)), mGradTypeText(new Label(this)), // TRANSLATORS: colors tab. label. mGradDelayLabel(new Label(this, _("Delay:"))), - mGradDelaySlider(new Slider(this, 20, 100)), + mGradDelaySlider(new Slider(this, 20.0, 100.0, 1.0)), mGradDelayText(new TextField(this)), // TRANSLATORS: colors tab. label. mRedLabel(new Label(this, _("Red:"))), - mRedSlider(new Slider(this, 0, 255)), + mRedSlider(new Slider(this, 0.0, 255.0, 1.0)), mRedText(new TextField(this)), // TRANSLATORS: colors tab. label. mGreenLabel(new Label(this, _("Green:"))), - mGreenSlider(new Slider(this, 0, 255)), + mGreenSlider(new Slider(this, 0.0, 255.0, 1.0)), mGreenText(new TextField(this)), // TRANSLATORS: colors tab. label. mBlueLabel(new Label(this, _("Blue:"))), - mBlueSlider(new Slider(this, 0, 255)), + mBlueSlider(new Slider(this, 0.0, 255.0, 1.0)), mBlueText(new TextField(this)) { mColorBox->postInit(); diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index a29e0d797..74ee7a3dc 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -212,7 +212,7 @@ void Setup_Input::cancel() void Setup_Input::action(const ActionEvent &event) { - const std::string id = event.getId(); + const std::string &id = event.getId(); if (event.getSource() == mKeyList) { diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index dfe14fa2c..7d6ac9fc3 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -192,9 +192,9 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : mOpenGLDropDown(new DropDown(widget, mOpenGLListModel)), // TRANSLATORS: video settings checkbox mFpsCheckBox(new CheckBox(this, _("FPS limit:"))), - mFpsSlider(new Slider(this, 2, 160)), + mFpsSlider(new Slider(this, 2.0, 160.0, 1.0)), mFpsLabel(new Label(this)), - mAltFpsSlider(new Slider(this, 2, 160)), + mAltFpsSlider(new Slider(this, 2.0, 160.0, 1.0)), // TRANSLATORS: video settings label mAltFpsLabel(new Label(this, _("Alt FPS limit: "))), #if !defined(ANDROID) && !defined(__APPLE__) diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp index eb6591f9f..fa4e2f4ef 100644 --- a/src/gui/widgets/tabs/setup_visual.cpp +++ b/src/gui/widgets/tabs/setup_visual.cpp @@ -139,7 +139,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : // TRANSLATORS: settings option new SetupItemSlider(_("Gui opacity"), "", "guialpha", - this, "guialphaEvent", 0.1, 1.0, 150, true); + this, "guialphaEvent", 0.1, 1.0, 0.1, 150, true, true); mSpeachList->fillFromArray(&speachList[0], speachListSize); // TRANSLATORS: settings option @@ -164,8 +164,8 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : // TRANSLATORS: particle details mParticleList->push_back(_("max")); (new SetupItemSlider2(_("Particle detail"), "", "particleEmitterSkip", - this, "particleEmitterSkipEvent", 0, 3, - mParticleList, true))->setInvertValue(3); + this, "particleEmitterSkipEvent", 0, 3, 1, + mParticleList, true, true, false))->setInvertValue(3); mParticleTypeList->fillFromArray(&particleTypeList[0], particleTypeListSize); @@ -183,7 +183,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : // TRANSLATORS: settings option new SetupItemSlider(_("Gamma"), "", "gamma", - this, "gammeEvent", 1, 20, 350, true); + this, "gammeEvent", 1, 20, 1, 350, true, true); // TRANSLATORS: settings group diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index c2a6c0207..e31bc9ef1 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -113,7 +113,6 @@ Tab::Tab(const Widget2 *const widget) : mVertexes(new ImageCollection), mImage(nullptr), mMode(0), - mRedraw(true), mHasMouse(false) { init(); diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index a0afa6fcd..4a88a5400 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -228,7 +228,6 @@ class Tab : public BasicContainer, ImageCollection *mVertexes; Image *mImage; int mMode; - bool mRedraw; protected: bool mHasMouse; diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index aa3e6254b..43c8df92f 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -107,7 +107,9 @@ Widget::Widget(const Widget2 *const widget) : mTabIn(true), mTabOut(true), mEnabled(true), - mAllowLogic(true) + mAllowLogic(true), + mMouseConsume(true), + mRedraw(true) { mWidgets.push_back(this); mWidgetsSet.insert(this); @@ -349,6 +351,12 @@ void Widget::setFont(Font *const font) fontChanged(); } +void Widget::distributeWindowResizeEvent() +{ + FOR_EACH (std::list<Widget*>::const_iterator, iter, mWidgets) + (*iter)->windowResized(); +} + bool Widget::widgetExists(const Widget* widget) { return mWidgetsSet.find(const_cast<Widget*>(widget)) @@ -504,3 +512,8 @@ void Widget::showPart(const Rect &rectangle) if (mParent) mParent->showWidgetPart(this, rectangle); } + +void Widget::windowResized() +{ + mRedraw = true; +} diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index de5a79502..f3e2fdb66 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -399,6 +399,9 @@ class Widget : public Widget2 bool isVisible() const A_WARN_UNUSED { return mVisible && (!mParent || mParent->isVisible()); } + bool isVisibleLocal() const A_WARN_UNUSED + { return mVisible; } + /** * Sets the base color of the widget. * @@ -1006,9 +1009,22 @@ class Widget : public Widget2 */ virtual void showPart(const Rect &rectangle); - bool isAllowLogic() const + bool isAllowLogic() const A_WARN_UNUSED { return mAllowLogic; } + void setMouseConsume(const bool b) + { mMouseConsume = b; } + + bool isMouseConsume() const A_WARN_UNUSED + { return mMouseConsume; } + + void setRedraw(const bool b) + { mRedraw = b; } + + static void distributeWindowResizeEvent(); + + void windowResized(); + protected: /** * Distributes an action event to all action listeners @@ -1219,6 +1235,10 @@ class Widget : public Widget2 bool mAllowLogic; + bool mMouseConsume; + + bool mRedraw; + /** * Holds the global font used by the widget. */ diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 9e032f75b..c7212314d 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -109,7 +109,6 @@ Window::Window(const std::string &caption, const bool modal, mDefaultY(0), mDefaultWidth(0), mDefaultHeight(0), - mRedraw(true), mLastRedraw(true), mGrip(nullptr), mParent(parent), @@ -1218,13 +1217,6 @@ bool Window::isResizeAllowed(const MouseEvent &event) const return false; } -int Window::getGuiAlpha() const -{ - const float alpha = std::max(client->getGuiAlpha(), - theme->getMinimumOpacity()); - return static_cast<int>(alpha * 255.0F); -} - Layout &Window::getLayout() { if (!mLayout) diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index dfd1f63b7..1795f2843 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -448,11 +448,6 @@ class Window : public BasicContainer2, */ void setModal(const bool modal); - /** - * Gets the alpha value used by the window, in a GUIChan usable format. - */ - int getGuiAlpha() const A_WARN_UNUSED; - Rect getWindowArea() const A_WARN_UNUSED; bool isResizeAllowed(const MouseEvent &event) const A_WARN_UNUSED; @@ -633,7 +628,6 @@ class Window : public BasicContainer2, int mDefaultY; /**< Default window Y position */ int mDefaultWidth; /**< Default window width */ int mDefaultHeight; /**< Default window height */ - bool mRedraw; bool mLastRedraw; private: diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 910bba705..c3b52ed59 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -185,7 +185,7 @@ WindowMenu::~WindowMenu() Button *const btn = dynamic_cast<Button*>(*it); if (!btn) continue; - if (!btn->isVisible()) + if (!btn->isVisibleLocal()) delete btn; } delete_all(mButtonTexts); @@ -328,7 +328,7 @@ void WindowMenu::updateButtons() Button *const btn = dynamic_cast<Button *const>(*it); if (!btn) continue; - if (btn->isVisible()) + if (btn->isVisibleLocal()) { btn->setPosition(x, mPadding); add(btn); @@ -396,7 +396,7 @@ void WindowMenu::saveButtons() const FOR_EACH (std::vector <Button*>::const_iterator, it, mButtons) { const Button *const btn = dynamic_cast<const Button *const>(*it); - if (btn && !btn->isVisible()) + if (btn && !btn->isVisibleLocal()) { config.setValue("windowmenu" + toString(i), btn->getActionEventId()); diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index 8bece77ef..e86bf344e 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -224,7 +224,7 @@ void BuyDialog::init() getOptionBool("showbackground"), "buy_background.xml"); mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); - mSlider = new Slider(this, 1.0); + mSlider = new Slider(this, 1.0, 1.0); mQuantityLabel = new Label(this, strprintf( "%d / %d", mAmountItems, mMaxItems)); mQuantityLabel->setAlignment(Graphics::CENTER); diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp index ce9ec84e8..0f4086a0b 100644 --- a/src/gui/windows/changeemaildialog.cpp +++ b/src/gui/windows/changeemaildialog.cpp @@ -119,8 +119,8 @@ void ChangeEmailDialog::action(const ActionEvent &event) else if (eventId == "change_email") { const std::string username = mLoginData->username.c_str(); - const std::string newFirstEmail = mFirstEmailField->getText(); - const std::string newSecondEmail = mSecondEmailField->getText(); + const std::string &newFirstEmail = mFirstEmailField->getText(); + const std::string &newSecondEmail = mSecondEmailField->getText(); logger->log("ChangeEmailDialog::Email change, Username is %s", username.c_str()); diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp index 051fa6434..eb7380f20 100644 --- a/src/gui/windows/changepassworddialog.cpp +++ b/src/gui/windows/changepassworddialog.cpp @@ -98,9 +98,9 @@ void ChangePasswordDialog::action(const ActionEvent &event) else if (eventId == "change_password") { const std::string username = mLoginData->username.c_str(); - const std::string oldPassword = mOldPassField->getText(); - const std::string newFirstPass = mFirstPassField->getText(); - const std::string newSecondPass = mSecondPassField->getText(); + const std::string &oldPassword = mOldPassField->getText(); + const std::string &newFirstPass = mFirstPassField->getText(); + const std::string &newSecondPass = mSecondPassField->getText(); logger->log("ChangePasswordDialog::Password change, Username is %s", username.c_str()); diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 42bbb4b88..0fe412e5c 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -321,7 +321,7 @@ CharCreateDialog::~CharCreateDialog() void CharCreateDialog::action(const ActionEvent &event) { - const std::string id = event.getId(); + const std::string &id = event.getId(); if (id == "create") { if (getName().length() >= 4) @@ -514,9 +514,8 @@ void CharCreateDialog::setAttributes(const StringVect &labels, mAttributeLabel[i]->adjustSize(); add(mAttributeLabel[i]); - mAttributeSlider[i] = new Slider(this, min, max); - mAttributeSlider[i]->setDimension(Rect(140, y + i * 24, - 150, 12)); + mAttributeSlider[i] = new Slider(this, min, max, 1.0); + mAttributeSlider[i]->setDimension(Rect(140, y + i * 24, 150, 12)); mAttributeSlider[i]->setActionEventId("statslider"); mAttributeSlider[i]->addActionListener(this); add(mAttributeSlider[i]); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 8d1d3e046..be2daf6a9 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -62,6 +62,8 @@ #include "gui/widgets/tabs/tradetab.h" #include "gui/widgets/tabs/whispertab.h" +#include "render/opengldebug.h" + #include "net/chathandler.h" #include "net/playerhandler.h" #include "net/net.h" @@ -314,14 +316,10 @@ void ChatWindow::loadGMCommands() void ChatWindow::updateTabsMargin() { - if (mColorPicker->isVisible()) - { + if (mColorPicker->isVisibleLocal()) mChatTabs->setRightMargin(mColorPicker->getWidth() + 16 + 8); - } else - { mChatTabs->setRightMargin(8); - } } void ChatWindow::adjustTabSize() @@ -339,7 +337,7 @@ void ChatWindow::adjustTabSize() mChatInput->setPosition(frame, y); mChatTabs->setWidth(awFrame2); const int height = ah - frame2 - (inputHeight + frame2); - if (mChatInput->isVisible() || !config.getBoolValue("hideChatInput")) + if (mChatInput->isVisibleLocal() || !config.getBoolValue("hideChatInput")) mChatTabs->setHeight(height); else mChatTabs->setHeight(height + inputHeight); @@ -362,7 +360,7 @@ void ChatWindow::adjustTabSize() y -= 2; } mChatInput->setWidth(w); - mChatButton->setVisible(mChatInput->isVisible()); + mChatButton->setVisible(mChatInput->isVisibleLocal()); mChatButton->setPosition(x, y); } else @@ -514,7 +512,7 @@ void ChatWindow::action(const ActionEvent &event) { if (emoteWindow) { - if (emoteWindow->isVisible()) + if (emoteWindow->isVisibleLocal()) emoteWindow->hide(); else emoteWindow->show(); @@ -553,7 +551,7 @@ void ChatWindow::action(const ActionEvent &event) } } - if (mColorPicker && mColorPicker->isVisible() + if (mColorPicker && mColorPicker->isVisibleLocal() != config.getBoolValue("showChatColorsList")) { mColorPicker->setVisible(config.getBoolValue( @@ -839,12 +837,12 @@ void ChatWindow::keyPressed(KeyEvent &event) return; } else if (actionId == static_cast<int>(Input::KEY_GUI_CANCEL) && - mChatInput->isVisible()) + mChatInput->isVisibleLocal()) { mChatInput->processVisible(false); } else if (actionId == static_cast<int>(Input::KEY_CHAT_PREV_HISTORY) && - mChatInput->isVisible()) + mChatInput->isVisibleLocal()) { const ChatTab *const tab = getFocused(); if (tab && tab->hasRows()) @@ -876,7 +874,7 @@ void ChatWindow::keyPressed(KeyEvent &event) } } else if (actionId == static_cast<int>(Input::KEY_CHAT_NEXT_HISTORY) && - mChatInput->isVisible()) + mChatInput->isVisibleLocal()) { const ChatTab *const tab = getFocused(); if (tab && tab->hasRows()) @@ -915,7 +913,7 @@ void ChatWindow::keyPressed(KeyEvent &event) { if (emoteWindow) { - if (emoteWindow->isVisible()) + if (emoteWindow->isVisibleLocal()) emoteWindow->hide(); else emoteWindow->show(); @@ -1023,7 +1021,7 @@ void ChatWindow::processEvent(const Channels channel, void ChatWindow::addInputText(const std::string &text, const bool space) { const int caretPos = mChatInput->getCaretPosition(); - const std::string inputText = mChatInput->getText(); + const std::string &inputText = mChatInput->getText(); std::ostringstream ss; ss << inputText.substr(0, caretPos) << text; @@ -1277,7 +1275,7 @@ void ChatWindow::autoComplete() { const int caretPos = mChatInput->getCaretPosition(); int startName = 0; - const std::string inputText = mChatInput->getText(); + const std::string &inputText = mChatInput->getText(); std::string name = inputText.substr(0, caretPos); for (int f = caretPos - 1; f > -1; f --) @@ -1645,7 +1643,7 @@ void ChatWindow::updateOnline(std::set<std::string> &onlinePlayers) const } else { - const std::string nick = tab->getNick(); + const std::string &nick = tab->getNick(); if (actorManager) { const Being *const being = actorManager->findBeingByName( @@ -1871,7 +1869,11 @@ void ChatWindow::draw(Graphics* graphics) { BLOCK_START("ChatWindow::draw") if (!mAutoHide || mHaveMouse) + { + GLDEBUG_START("ChatWindow::draw"); Window::draw(graphics); + GLDEBUG_END(); + } BLOCK_END("ChatWindow::draw") } diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 472057060..9c2e039f9 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -100,7 +100,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent, mItem(item), mItemIcon(new Icon(this, item ? item->getImage() : nullptr)), mItemPopup(new ItemPopup), - mItemAmountSlide(new Slider(this, 1.0, maxRange)), + mItemAmountSlide(new Slider(this, 1.0, maxRange, 1.0)), mItemPriceSlide(nullptr), mItemDropDown(nullptr), mItemsModal(nullptr), @@ -136,7 +136,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent, mItemPriceTextField->setWidth(35); mItemPriceTextField->addKeyListener(this); - mItemPriceSlide = new Slider(this, 1.0, 10000000); + mItemPriceSlide = new Slider(this, 1.0, 10000000, 1.0); mItemPriceSlide->setHeight(10); mItemPriceSlide->setActionEventId("slidePrice"); mItemPriceSlide->addActionListener(this); diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 9be6d7304..70a2361cd 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -89,7 +89,12 @@ Minimap::~Minimap() config.setValue(getWindowName() + "Show", mShow); config.removeListeners(this); CHECKLISTENERS + deleteMapImage(); + delete2(mTextPopup); +} +void Minimap::deleteMapImage() +{ if (mMapImage) { if (mCustomMapImage) @@ -98,7 +103,6 @@ Minimap::~Minimap() mMapImage->decRef(); mMapImage = nullptr; } - delete2(mTextPopup); } void Minimap::setMap(const Map *const map) @@ -115,16 +119,7 @@ void Minimap::setMap(const Map *const map) } setCaption(caption); - - // Adapt the image - if (mMapImage) - { - if (mCustomMapImage) - delete mMapImage; - else - mMapImage->decRef(); - mMapImage = nullptr; - } + deleteMapImage(); if (map) { diff --git a/src/gui/windows/minimap.h b/src/gui/windows/minimap.h index e8fff5144..18a8a0a8b 100644 --- a/src/gui/windows/minimap.h +++ b/src/gui/windows/minimap.h @@ -73,6 +73,8 @@ class Minimap final : public Window, public ConfigListener void optionChanged(const std::string &name); private: + void deleteMapImage(); + float mWidthProportion; float mHeightProportion; Image *mMapImage; diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index 885ea619b..93a6a6a10 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -162,7 +162,7 @@ MiniStatusWindow::~MiniStatusWindow() ProgressBar *bar = *it; if (!bar) continue; - if (!bar->isVisible()) + if (!bar->isVisibleLocal()) delete bar; } mBars.clear(); @@ -200,7 +200,7 @@ void MiniStatusWindow::updateBars() ProgressBar *const bar = *it; if (!bar) continue; - if (bar->isVisible()) + if (bar->isVisibleLocal()) { bar->setPosition(x, 0); add(bar); @@ -507,7 +507,7 @@ void MiniStatusWindow::saveBars() const FOR_EACH (ProgressBarVectorCIter, it, mBars) { const ProgressBar *const bar = *it; - if (!bar->isVisible()) + if (!bar->isVisibleLocal()) { config.setValue("ministatus" + toString(i), bar->getActionEventId()); diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index b1355ba46..601101bef 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -227,7 +227,7 @@ void OutfitWindow::save() const void OutfitWindow::action(const ActionEvent &event) { - const std::string eventId = event.getId(); + const std::string &eventId = event.getId(); if (eventId == "next") { next(); diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index 55a328fa8..6d3cf9d9f 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -182,7 +182,7 @@ void RegisterDialog::action(const ActionEvent &event) } else if (eventId == "register" && canSubmit()) { - const std::string user = mUserField->getText(); + const std::string &user = mUserField->getText(); logger->log("RegisterDialog::register Username is %s", user.c_str()); std::string errorMsg; diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 604caa72e..1b9f1ec85 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -100,7 +100,7 @@ void SellDialog::init() getOptionBool("showbackground"), "sell_background.xml"); mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); - mSlider = new Slider(this, 1.0); + mSlider = new Slider(this, 1.0, 1.0); mQuantityLabel = new Label(this, strprintf( "%d / %d", mAmountItems, mMaxItems)); diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp index bb309c6f1..3d8627add 100644 --- a/src/gui/windows/unregisterdialog.cpp +++ b/src/gui/windows/unregisterdialog.cpp @@ -111,7 +111,7 @@ void UnRegisterDialog::action(const ActionEvent &event) else if (eventId == "unregister") { const std::string username = mLoginData->username.c_str(); - const std::string password = mPasswordField->getText(); + const std::string &password = mPasswordField->getText(); logger->log("UnregisterDialog::unregistered, Username is %s", username.c_str()); diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index cd0e7e0d8..824d8e0f6 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -407,6 +407,14 @@ void UpdaterWindow::loadPatch() "##6ManaPlus %s##0", line), true); } } + if (!serverVersion && config.getIntValue("runcount") > 10) + { + mBrowserBox->addRow("", true); + mBrowserBox->addRow("", true); + mBrowserBox->addRow(" ##1[@@http://steamcommunity.com/" + "sharedfiles/filedetails/?id=232178669|" + "Vote for us on Steam Green Light@@]", true); + } if (version > CHECK_VERSION) { #if defined(ANDROID) @@ -1064,7 +1072,7 @@ void UpdaterWindow::loadDirMods(const std::string &dir) const ModInfo *const mod = (*modIt).second; if (mod) { - const std::string localDir = mod->getLocalDir(); + const std::string &localDir = mod->getLocalDir(); if (!localDir.empty()) resman->addToSearchPath(dir + "/" + localDir, false); } @@ -1087,7 +1095,7 @@ void UpdaterWindow::unloadMods(const std::string &dir) const ModInfo *const mod = (*modIt).second; if (mod) { - const std::string localDir = mod->getLocalDir(); + const std::string &localDir = mod->getLocalDir(); if (!localDir.empty()) resman->removeFromSearchPath(dir + "/" + localDir); } diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index a1683ffc8..b7616eb72 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -519,6 +519,7 @@ int WhoIsOnline::downloadThread(void *ptr) curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 7); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30); + Net::Download::addHeaders(curl); Net::Download::addProxy(curl); Net::Download::secureCurl(curl); |