From 050c957927ccd7da1da135ce4fc51c3e53101ba6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 4 Mar 2014 21:13:28 +0300 Subject: Merge slider classes into one. --- src/gui/widgets/slider.h | 245 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 243 insertions(+), 2 deletions(-) (limited to 'src/gui/widgets/slider.h') diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 2f21127d1..0b900e230 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -20,10 +20,56 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Guichan nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef GUI_WIDGETS_SLIDER_H #define GUI_WIDGETS_SLIDER_H -#include "gui/base/widgets/slider.hpp" +#include "listeners/keylistener.h" +#include "listeners/mouselistener.h" + +#include "gui/widgets/widget.h" #include "localconsts.h" @@ -34,9 +80,21 @@ class ImageCollection; * * \ingroup GUI */ -class Slider final : public gcn::Slider +class Slider final : public Widget, + public MouseListener, + public KeyListener { public: + /** + * Draw orientations for the slider. A slider can be drawn vertically or + * horizontally. + */ + enum Orientation + { + HORIZONTAL = 0, + VERTICAL + }; + /** * Constructor with scale start equal to 0. */ @@ -89,6 +147,126 @@ class Slider final : public gcn::Slider void setValue2(const double value); + /** + * Sets the scale of the slider. + * + * @param scaleStart The start value of the scale. + * @param scaleEnd tThe end of value the scale. + * @see getScaleStart, getScaleEnd + */ + void setScale(const double scaleStart, const double scaleEnd); + + /** + * Gets the start value of the scale. + * + * @return The start value of the scale. + * @see setScaleStart, setScale + */ + double getScaleStart() const + { return mScaleStart; } + + /** + * Sets the start value of the scale. + * + * @param scaleStart The start value of the scale. + * @see getScaleStart + */ + void setScaleStart(const double scaleStart) + { mScaleStart = scaleStart; } + + /** + * Gets the end value of the scale. + * + * @return The end value of the scale. + * @see setScaleEnd, setScale + */ + double getScaleEnd() const + { return mScaleEnd; } + + /** + * Sets the end value of the scale. + * + * @param scaleEnd The end value of the scale. + * @see getScaleEnd + */ + void setScaleEnd(const double scaleEnd) + { mScaleEnd = scaleEnd; } + + /** + * Sets the current selected value. + * + * @param value The current selected value. + * @see getValue + */ + void setValue(const double value); + + /** + * Gets the current selected value. + * + * @return The current selected value. + * @see setValue + */ + double getValue() const + { return mValue; } + + /** + * Gets the length of the marker. + * + * @return The length of the marker. + * @see setMarkerLength + */ + int getMarkerLength() const + { return mMarkerLength; } + + /** + * Sets the length of the marker. + * + * @param length The length for the marker. + * @see getMarkerLength + */ + void setMarkerLength(const int length) + { mMarkerLength = length; } + + /** + * Sets the orientation of the slider. A slider can be drawn vertically + * or horizontally. + * + * @param orientation The orientation of the slider. + * @see getOrientation + */ + void setOrientation(const Orientation orientation) + { mOrientation = orientation; } + + /** + * Gets the orientation of the slider. A slider can be drawn vertically + * or horizontally. + * + * @return The orientation of the slider. + * @see setOrientation + */ + Orientation getOrientation() const + { return mOrientation; } + + /** + * Sets the step length. The step length is used when the keys LEFT + * and RIGHT are pressed to step in the scale. + * + * @param length The step length. + * @see getStepLength + */ + void setStepLength(const double length) + { mStepLength = length; } + + /** + * Gets the step length. The step length is used when the keys LEFT + * and RIGHT are pressed to step in the scale. + * + * @return the step length. + * @see setStepLength + */ + double getStepLength() const + { return mStepLength; } + enum SLIDER_ENUM { HSTART = 0, @@ -108,9 +286,72 @@ class Slider final : public gcn::Slider */ void init(); + /** + * Converts a marker position to a value in the scale. + * + * @param position The position to convert. + * @return A scale value corresponding to the position. + * @see valueToMarkerPosition + */ + double markerPositionToValue(const int position) const; + + /** + * Converts a value to a marker position. + * + * @param value The value to convert. + * @return A marker position corresponding to the value. + * @see markerPositionToValue + */ + int valueToMarkerPosition(const double value) const; + + /** + * Gets the marker position of the current selected value. + * + * @return The marker position of the current selected value. + */ + int getMarkerPosition() const + { return valueToMarkerPosition(getValue()); } + static ImageRect buttons[2]; static float mAlpha; static int mInstances; + /** + * True if the slider is dragged, false otherwise. + */ + bool mDragged; + + /** + * Holds the current selected value. + */ + double mValue; + + /** + * Holds the step length. The step length is used when the keys LEFT + * and RIGHT are pressed to step in the scale. + */ + double mStepLength; + + /** + * Holds the length of the marker. + */ + int mMarkerLength; + + /** + * Holds the start value of the scale. + */ + double mScaleStart; + + /** + * Holds the end value of the scale. + */ + double mScaleEnd; + + /** + * Holds the orientation of the slider. A slider can be drawn + * vertically or horizontally. + */ + Orientation mOrientation; + ImageCollection *mVertexes; bool mHasMouse; bool mRedraw; -- cgit v1.2.3-70-g09d2 From 6b291b6515825f4ce0e09df5dec7ea1b619b63a7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 6 Mar 2014 00:39:58 +0300 Subject: improve a bit different code. --- src/client.cpp | 28 +--------- src/client.h | 3 +- src/game.cpp | 1 + src/game.h | 2 + src/gui/widgets/scrollarea.cpp | 26 +++++----- src/gui/widgets/scrollarea.h | 90 ++++++++++++++++---------------- src/gui/widgets/setupitem.cpp | 8 +-- src/gui/widgets/slider.cpp | 96 +++++++++++++++-------------------- src/gui/widgets/slider.h | 22 ++++---- src/gui/widgets/tabs/setup_colors.cpp | 16 +++--- src/gui/widgets/tabs/setup_video.cpp | 12 ++--- src/gui/widgets/widget.h | 2 +- src/gui/windows/botcheckerwindow.cpp | 5 +- src/gui/windows/buydialog.cpp | 14 ++--- src/gui/windows/itemamountwindow.cpp | 10 ++-- src/gui/windows/killstats.cpp | 14 +++-- src/gui/windows/killstats.h | 3 +- src/gui/windows/selldialog.cpp | 12 ++--- src/map.cpp | 13 ----- src/net/ea/gamehandler.cpp | 3 ++ src/net/ea/loginhandler.cpp | 24 +++++++++ src/net/ea/loginhandler.h | 2 + src/net/ea/network.cpp | 4 +- src/net/loginhandler.h | 2 + 24 files changed, 204 insertions(+), 208 deletions(-) (limited to 'src/gui/widgets/slider.h') diff --git a/src/client.cpp b/src/client.cpp index 5d635f522..cdee0b049 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -185,7 +185,7 @@ bool isSafeMode = false; int serverVersion = 0; unsigned int tmwServerVersion = 0; int start_time; - +unsigned int mLastHost = 0; int textures_count = 0; #ifdef WIN32 @@ -1323,7 +1323,7 @@ int Client::gameExec() // TRANSLATORS: connection dialog header _("Logging in"), STATE_SWITCH_SERVER); mCurrentDialog->postInit(); - accountLogin(&loginData); + Net::getLoginHandler()->loginOrRegister(&loginData); BLOCK_END("Client::gameExec STATE_LOGIN_ATTEMPT") break; @@ -2340,30 +2340,6 @@ void Client::initScreenshotDir() logger->log("screenshotDirectory: " + mScreenshotDir); } -void Client::accountLogin(LoginData *const data) -{ - if (!data) - return; - - logger->log("Username is %s", data->username.c_str()); - - // Send login infos - if (data->registerLogin) - Net::getLoginHandler()->registerAccount(data); - else - Net::getLoginHandler()->loginAccount(data); - - // Clear the password, avoids auto login when returning to login - data->password.clear(); - - const bool remember = data->remember; - if (remember) - serverConfig.setValue("username", data->username); - else - serverConfig.setValue("username", ""); - serverConfig.setValue("remember", remember); -} - #ifndef ANDROID void Client::storeSafeParameters() const { diff --git a/src/client.h b/src/client.h index 0e6528ca3..fe48418e7 100644 --- a/src/client.h +++ b/src/client.h @@ -372,8 +372,6 @@ private: static void initFeatures(); - static void accountLogin(LoginData *const data); - #ifndef ANDROID void storeSafeParameters() const; #endif @@ -455,5 +453,6 @@ private: }; extern Client *client; +extern unsigned int mLastHost; #endif // CLIENT_H diff --git a/src/game.cpp b/src/game.cpp index 195492335..b00dfc81f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -165,6 +165,7 @@ BattleTab *battleChatTab = nullptr; GmTab *gmChatTab = nullptr; LangTab *langChatTab = nullptr; +bool mStatsReUpdated = false; const unsigned adjustDelay = 10; /** diff --git a/src/game.h b/src/game.h index ad9285931..85d1d20d0 100644 --- a/src/game.h +++ b/src/game.h @@ -140,4 +140,6 @@ class Game final static Game *mInstance; }; +extern bool mStatsReUpdated; + #endif // GAME_H diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 3c50abca0..70f955684 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -99,36 +99,36 @@ ScrollArea::ScrollArea(Widget2 *const widget2, BasicContainer(widget2), MouseListener(), WidgetListener(), + mVertexes(new ImageCollection), + mVertexes2(new ImageCollection), + mHPolicy(SHOW_AUTO), + mVPolicy(SHOW_AUTO), mVScroll(0), mHScroll(0), mScrollbarWidth(12), - mHPolicy(SHOW_AUTO), - mVPolicy(SHOW_AUTO), - mVBarVisible(false), - mHBarVisible(false), - mUpButtonPressed(false), - mDownButtonPressed(false), - mLeftButtonPressed(false), - mRightButtonPressed(false), mUpButtonScrollAmount(10), mDownButtonScrollAmount(10), mLeftButtonScrollAmount(10), mRightButtonScrollAmount(10), - mIsVerticalMarkerDragged(false), - mIsHorizontalMarkerDragged(false), mHorizontalMarkerDragOffset(0), mVerticalMarkerDragOffset(0), - mOpaque(true), mX(0), mY(0), mClickX(0), mClickY(0), - mVertexes(new ImageCollection), - mVertexes2(new ImageCollection), mXOffset(0), mYOffset(0), mDrawWidth(0), mDrawHeight(0), + mVBarVisible(false), + mHBarVisible(false), + mUpButtonPressed(false), + mDownButtonPressed(false), + mLeftButtonPressed(false), + mRightButtonPressed(false), + mIsVerticalMarkerDragged(false), + mIsHorizontalMarkerDragged(false), + mOpaque(true), mHasMouse(false), mRedraw(true) { diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 70abac6ef..4653359e8 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -470,6 +470,19 @@ class ScrollArea final : public BasicContainer, static ImageRect hBackground; static Image *buttons[4][2]; + ImageCollection *mVertexes; + ImageCollection *mVertexes2; + + /** + * Holds the horizontal scroll bar policy. + */ + ScrollPolicy mHPolicy; + + /** + * Holds the vertical scroll bar policy. + */ + ScrollPolicy mVPolicy; + /** * Holds the vertical scroll amount. */ @@ -486,64 +499,73 @@ class ScrollArea final : public BasicContainer, int mScrollbarWidth; /** - * Holds the horizontal scroll bar policy. + * Holds the up button scroll amount. */ - ScrollPolicy mHPolicy; + int mUpButtonScrollAmount; /** - * Holds the vertical scroll bar policy. + * Holds the down button scroll amount. */ - ScrollPolicy mVPolicy; + int mDownButtonScrollAmount; /** - * True if the vertical scroll bar is visible, false otherwise. + * Holds the left button scroll amount. */ - bool mVBarVisible; + int mLeftButtonScrollAmount; /** - * True if the horizontal scroll bar is visible, false otherwise. + * Holds the right button scroll amount. */ - bool mHBarVisible; + int mRightButtonScrollAmount; /** - * True if the up button is pressed, false otherwise. + * Holds the horizontal markers drag offset. */ - bool mUpButtonPressed; + int mHorizontalMarkerDragOffset; /** - * True if the down button is pressed, false otherwise. + * Holds the vertical markers drag offset. */ - bool mDownButtonPressed; + int mVerticalMarkerDragOffset; + + int mX; + int mY; + int mClickX; + int mClickY; + int mXOffset; + int mYOffset; + int mDrawWidth; + int mDrawHeight; /** - * True if the left button is pressed, false otherwise. + * True if the vertical scroll bar is visible, false otherwise. */ - bool mLeftButtonPressed; + bool mVBarVisible; /** - * True if the right button is pressed, false otherwise. + * True if the horizontal scroll bar is visible, false otherwise. */ - bool mRightButtonPressed; + bool mHBarVisible; /** - * Holds the up button scroll amount. + * True if the up button is pressed, false otherwise. */ - int mUpButtonScrollAmount; + bool mUpButtonPressed; /** - * Holds the down button scroll amount. + * True if the down button is pressed, false otherwise. */ - int mDownButtonScrollAmount; + bool mDownButtonPressed; /** - * Holds the left button scroll amount. + * True if the left button is pressed, false otherwise. */ - int mLeftButtonScrollAmount; + bool mLeftButtonPressed; /** - * Holds the right button scroll amount. + * True if the right button is pressed, false otherwise. */ - int mRightButtonScrollAmount; + bool mRightButtonPressed; /** * True if the vertical marked is dragged. @@ -555,32 +577,12 @@ class ScrollArea final : public BasicContainer, */ bool mIsHorizontalMarkerDragged; - /** - * Holds the horizontal markers drag offset. - */ - int mHorizontalMarkerDragOffset; - - /** - * Holds the vertical markers drag offset. - */ - int mVerticalMarkerDragOffset; - /** * True if the scroll area should be opaque (that is * display its background), false otherwise. */ bool mOpaque; - int mX; - int mY; - int mClickX; - int mClickY; - ImageCollection *mVertexes; - ImageCollection *mVertexes2; - int mXOffset; - int mYOffset; - int mDrawWidth; - int mDrawHeight; bool mHasMouse; bool mRedraw; }; diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 218efe8a2..4c32b0572 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -769,7 +769,7 @@ void SetupItemSlider::createControls() mSlider = new Slider(this, mMin, mMax); mSlider->setActionEventId(mEventName); mSlider->addActionListener(mParent); - mSlider->setValue2(atof(mValue.c_str())); + mSlider->setValue(atof(mValue.c_str())); mSlider->setHeight(30); mWidget = mSlider; @@ -798,7 +798,7 @@ void SetupItemSlider::toWidget() if (!mSlider) return; - mSlider->setValue2(atof(mValue.c_str())); + mSlider->setValue(atof(mValue.c_str())); } void SetupItemSlider::action(const ActionEvent &event A_UNUSED) @@ -893,7 +893,7 @@ void SetupItemSlider2::createControls() mSlider = new Slider(this, mMin, mMax); mSlider->setActionEventId(mEventName); mSlider->addActionListener(mParent); - mSlider->setValue2(atof(mValue.c_str())); + mSlider->setValue(atof(mValue.c_str())); mSlider->setHeight(30); mWidget = mSlider; @@ -952,7 +952,7 @@ void SetupItemSlider2::toWidget() int val = roundDouble(atof(mValue.c_str())); if (mInvert) val = mInvertValue - val; - mSlider->setValue2(val); + mSlider->setValue(val); updateLabel(); } diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index ab8cb97c2..8da4f34ae 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -93,14 +93,14 @@ Slider::Slider(Widget2 *const widget, Widget(widget), MouseListener(), KeyListener(), - mDragged(false), mValue(0), mStepLength(scaleEnd / 10), - mMarkerLength(10), mScaleStart(0), mScaleEnd(scaleEnd), mOrientation(HORIZONTAL), mVertexes(new ImageCollection), + mMarkerLength(10), + mDragged(false), mHasMouse(false), mRedraw(true) { @@ -113,14 +113,14 @@ Slider::Slider(Widget2 *const widget, Widget(widget), MouseListener(), KeyListener(), - mDragged(false), mValue(scaleStart), mStepLength((scaleEnd - scaleStart) / 10), - mMarkerLength(10), mScaleStart(scaleStart), mScaleEnd(scaleEnd), mOrientation(HORIZONTAL), mVertexes(new ImageCollection), + mMarkerLength(10), + mDragged(false), mHasMouse(false), mRedraw(true) { @@ -356,22 +356,18 @@ void Slider::mouseExited(MouseEvent& event A_UNUSED) void Slider::mousePressed(MouseEvent &mouseEvent) { + const int x = mouseEvent.getX(); + const int y = mouseEvent.getY(); + const int width = mDimension.width; + const int height = mDimension.height; + if (mouseEvent.getButton() == MouseEvent::LEFT - && mouseEvent.getX() >= 0 - && mouseEvent.getX() <= getWidth() - && mouseEvent.getY() >= 0 - && mouseEvent.getY() <= getHeight()) + && x >= 0 && x <= width && y >= 0 && y <= height) { - if (getOrientation() == HORIZONTAL) - { - setValue2(markerPositionToValue( - mouseEvent.getX() - getMarkerLength() / 2)); - } + if (mOrientation == HORIZONTAL) + setValue(markerPositionToValue(x - mMarkerLength / 2)); else - { - setValue2(markerPositionToValue(getHeight() - - mouseEvent.getY() - getMarkerLength() / 2)); - } + setValue(markerPositionToValue(height - y - mMarkerLength / 2)); distributeActionEvent(); } @@ -379,15 +375,14 @@ void Slider::mousePressed(MouseEvent &mouseEvent) void Slider::mouseDragged(MouseEvent &mouseEvent) { - if (getOrientation() == HORIZONTAL) + if (mOrientation == HORIZONTAL) { - setValue2(markerPositionToValue(mouseEvent.getX() - - getMarkerLength() / 2)); + setValue(markerPositionToValue(mouseEvent.getX() - mMarkerLength / 2)); } else { - setValue2(markerPositionToValue(getHeight() - - mouseEvent.getY() - getMarkerLength() / 2)); + setValue(markerPositionToValue( + mDimension.height - mouseEvent.getY() - mMarkerLength / 2)); } distributeActionEvent(); @@ -397,17 +392,15 @@ void Slider::mouseDragged(MouseEvent &mouseEvent) void Slider::mouseWheelMovedUp(MouseEvent &mouseEvent) { - setValue2(getValue() + getStepLength()); + setValue(mValue + mStepLength); distributeActionEvent(); - mouseEvent.consume(); } void Slider::mouseWheelMovedDown(MouseEvent &mouseEvent) { - setValue2(getValue() - getStepLength()); + setValue(mValue - mStepLength); distributeActionEvent(); - mouseEvent.consume(); } @@ -415,17 +408,17 @@ void Slider::keyPressed(KeyEvent& keyEvent) { const int action = keyEvent.getActionId(); - if (getOrientation() == HORIZONTAL) + if (mOrientation == HORIZONTAL) { if (action == Input::KEY_GUI_RIGHT) { - setValue2(getValue() + getStepLength()); + setValue(mValue + mStepLength); distributeActionEvent(); keyEvent.consume(); } else if (action == Input::KEY_GUI_LEFT) { - setValue2(getValue() - getStepLength()); + setValue(mValue - mStepLength); distributeActionEvent(); keyEvent.consume(); } @@ -434,25 +427,19 @@ void Slider::keyPressed(KeyEvent& keyEvent) { if (action == Input::KEY_GUI_UP) { - setValue2(getValue() + getStepLength()); + setValue(mValue + mStepLength); distributeActionEvent(); keyEvent.consume(); } else if (action == Input::KEY_GUI_DOWN) { - setValue2(getValue() - getStepLength()); + setValue(mValue - mStepLength); distributeActionEvent(); keyEvent.consume(); } } } -void Slider::setValue2(const double value) -{ - setValue(value); - mRedraw = true; -} - void Slider::setScale(const double scaleStart, const double scaleEnd) { mScaleStart = scaleStart; @@ -461,15 +448,16 @@ void Slider::setScale(const double scaleStart, const double scaleEnd) void Slider::setValue(const double value) { - if (value > getScaleEnd()) + mRedraw = true; + if (value > mScaleEnd) { - mValue = getScaleEnd(); + mValue = mScaleEnd; return; } - if (value < getScaleStart()) + if (value < mScaleStart) { - mValue = getScaleStart(); + mValue = mScaleStart; return; } @@ -479,32 +467,32 @@ void Slider::setValue(const double value) double Slider::markerPositionToValue(const int v) const { int w; - if (getOrientation() == HORIZONTAL) - w = getWidth(); + if (mOrientation == HORIZONTAL) + w = mDimension.width; else - w = getHeight(); + w = mDimension.height; - const double pos = v / (static_cast(w) - getMarkerLength()); - return (1.0 - pos) * getScaleStart() + pos * getScaleEnd(); + const double pos = v / (static_cast(w) - mMarkerLength); + return (1.0 - pos) * mScaleStart + pos * mScaleEnd; } int Slider::valueToMarkerPosition(const double value) const { int v; - if (getOrientation() == HORIZONTAL) - v = getWidth(); + if (mOrientation == HORIZONTAL) + v = mDimension.width; else - v = getHeight(); + v = mDimension.height; - const int w = static_cast((v - getMarkerLength()) - * (value - getScaleStart()) - / (getScaleEnd() - getScaleStart())); + const int w = static_cast((v - mMarkerLength) + * (value - mScaleStart) + / (mScaleEnd - mScaleStart)); if (w < 0) return 0; - if (w > v - getMarkerLength()) - return v - getMarkerLength(); + if (w > v - mMarkerLength) + return v - mMarkerLength; return w; } diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 0b900e230..3fbb66a5c 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -145,8 +145,6 @@ class Slider final : public Widget, void keyPressed(KeyEvent& keyEvent) override final; - void setValue2(const double value); - /** * Sets the scale of the slider. * @@ -315,10 +313,6 @@ class Slider final : public Widget, static ImageRect buttons[2]; static float mAlpha; static int mInstances; - /** - * True if the slider is dragged, false otherwise. - */ - bool mDragged; /** * Holds the current selected value. @@ -331,11 +325,6 @@ class Slider final : public Widget, */ double mStepLength; - /** - * Holds the length of the marker. - */ - int mMarkerLength; - /** * Holds the start value of the scale. */ @@ -353,6 +342,17 @@ class Slider final : public Widget, Orientation mOrientation; ImageCollection *mVertexes; + + /** + * Holds the length of the marker. + */ + int mMarkerLength; + + /** + * True if the slider is dragged, false otherwise. + */ + bool mDragged; + bool mHasMouse; bool mRedraw; }; diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 940d0cd3f..eb7e695f4 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -96,7 +96,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mGradTypeSlider->setWidth(180); mGradTypeSlider->setActionEventId("slider_grad"); - mGradTypeSlider->setValue2(0); + mGradTypeSlider->setValue(0); mGradTypeSlider->addActionListener(this); mGradTypeSlider->setEnabled(false); @@ -128,7 +128,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mGradDelayText->setEnabled(false); mGradDelaySlider->setWidth(180); - mGradDelaySlider->setValue2(mGradDelayText->getValue()); + mGradDelaySlider->setValue(mGradDelayText->getValue()); mGradDelaySlider->setActionEventId("slider_graddelay"); mGradDelaySlider->addActionListener(this); mGradDelaySlider->setEnabled(false); @@ -139,7 +139,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mRedText->setEnabled(false); mRedSlider->setWidth(180); - mRedSlider->setValue2(mRedText->getValue()); + mRedSlider->setValue(mRedText->getValue()); mRedSlider->setActionEventId("slider_red"); mRedSlider->addActionListener(this); mRedSlider->setEnabled(false); @@ -150,7 +150,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mGreenText->setEnabled(false); mGreenSlider->setWidth(180); - mGreenSlider->setValue2(mGreenText->getValue()); + mGreenSlider->setValue(mGreenText->getValue()); mGreenSlider->setActionEventId("slider_green"); mGreenSlider->addActionListener(this); mGreenSlider->setEnabled(false); @@ -161,7 +161,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mBlueText->setEnabled(false); mBlueSlider->setWidth(180); - mBlueSlider->setValue2(mBlueText->getValue()); + mBlueSlider->setValue(mBlueText->getValue()); mBlueSlider->setActionEventId("slider_blue"); mBlueSlider->addActionListener(this); mBlueSlider->setEnabled(false); @@ -356,7 +356,7 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED) setEntry(mGreenSlider, mGreenText, col->g); setEntry(mBlueSlider, mBlueText, col->b); - mGradTypeSlider->setValue2(grad); + mGradTypeSlider->setValue(grad); updateGradType(); mGradTypeSlider->setEnabled(true); } @@ -365,7 +365,7 @@ void Setup_Colors::setEntry(Slider *const s, TextField *const t, const int value) { if (s) - s->setValue2(value); + s->setValue(value); if (t) t->setText(toString(value)); } @@ -384,7 +384,7 @@ void Setup_Colors::cancel() userPalette->rollback(); const int type = userPalette->getColorTypeAt(mSelected); const Color *const col = &userPalette->getColor(type); - mGradTypeSlider->setValue2(userPalette->getGradientType(type)); + mGradTypeSlider->setValue(userPalette->getGradientType(type)); const int delay = userPalette->getGradientDelay(type); setEntry(mGradDelaySlider, mGradDelayText, delay); setEntry(mRedSlider, mRedText, col->r); diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index d09704203..416ae8c3c 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -241,9 +241,9 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : ? toString(mAltFps) : _("None"))); mAltFpsLabel->setWidth(150); mFpsSlider->setEnabled(mFps > 0); - mFpsSlider->setValue2(mFps); + mFpsSlider->setValue(mFps); mAltFpsSlider->setEnabled(mAltFps > 0); - mAltFpsSlider->setValue2(mAltFps); + mAltFpsSlider->setValue(mAltFps); mFpsCheckBox->setSelected(mFps > 0); // Pre-select the current video mode. @@ -419,9 +419,9 @@ void Setup_Video::cancel() mOpenGLDropDown->setSelected(renderToIndex[mOpenGLEnabled]); mCustomCursorCheckBox->setSelected(mCustomCursorEnabled); mFpsSlider->setEnabled(mFps > 0); - mFpsSlider->setValue2(mFps); + mFpsSlider->setValue(mFps); mAltFpsSlider->setEnabled(mAltFps > 0); - mAltFpsSlider->setValue2(mAltFps); + mAltFpsSlider->setValue(mAltFps); mFpsLabel->setCaption(mFpsCheckBox->isSelected() // TRANSLATORS: video settings label ? toString(mFps) : _("None")); @@ -542,7 +542,7 @@ void Setup_Video::action(const ActionEvent &event) mFpsLabel->setCaption(text); mFpsSlider->setEnabled(mFps > 0); - mFpsSlider->setValue2(mFps); + mFpsSlider->setValue(mFps); } else if (id == "altfpslimitslider") { @@ -556,7 +556,7 @@ void Setup_Video::action(const ActionEvent &event) // TRANSLATORS: video settings label mAltFpsLabel->setCaption(_("Alt FPS limit: ") + text); mAltFpsSlider->setEnabled(mAltFps > 0); - mAltFpsSlider->setValue2(mAltFps); + mAltFpsSlider->setValue(mAltFps); } else if (id == "enableresize") { diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index 34f3647d5..3af00d247 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -196,7 +196,7 @@ class Widget : public Widget2 * has no parent. * @since 0.1.0 */ - virtual Widget* getParent() const A_WARN_UNUSED + Widget* getParent() const A_WARN_UNUSED { return mParent; } /** diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp index d1fc0e7bd..32a0227d7 100644 --- a/src/gui/windows/botcheckerwindow.cpp +++ b/src/gui/windows/botcheckerwindow.cpp @@ -28,14 +28,13 @@ #include "gui/widgets/guitable.h" #include "actormanager.h" +#include "client.h" #include "configuration.h" #include "being/localplayer.h" #include "utils/gettext.h" -#include - #include "debug.h" const int COLUMNS_NR = 5; // name plus listbox @@ -334,6 +333,8 @@ BotCheckerWindow::BotCheckerWindow(): mIncButton->setPosition(mPadding, y); + mLastHost += 0x1234; + add(mPlayerTitleTable); add(playersScrollArea); add(mIncButton); diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index 7b1a1f6c0..772f08d32 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -311,7 +311,7 @@ void BuyDialog::reset() // Reset previous selected items to prevent failing asserts mShopItemList->setSelected(-1); - mSlider->setValue2(0); + mSlider->setValue(0); setMoney(0); } @@ -386,28 +386,28 @@ void BuyDialog::action(const ActionEvent &event) else if (eventId == "inc" && mAmountItems < mMaxItems) { mAmountItems++; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); mAmountField->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "dec" && mAmountItems > 1) { mAmountItems--; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); mAmountField->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "max") { mAmountItems = mMaxItems; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); mAmountField->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "amount") { mAmountItems = mAmountField->getValue(); - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems) @@ -433,7 +433,7 @@ void BuyDialog::action(const ActionEvent &event) // Reset selection mAmountItems = 1; mSlider->setScale(1, mMaxItems); - mSlider->setValue2(1); + mSlider->setValue(1); } else if (tradeWindow) { @@ -453,7 +453,7 @@ void BuyDialog::valueChanged(const SelectionEvent &event A_UNUSED) { // Reset amount of items and update labels mAmountItems = 1; - mSlider->setValue2(1); + mSlider->setValue(1); updateButtonsAndLabels(); mSlider->setScale(1, mMaxItems); diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index fc0c5880b..b13380782 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -344,7 +344,7 @@ void ItemAmountWindow::action(const ActionEvent &event) else if (eventId == "slide") amount = static_cast(mItemAmountSlide->getValue()); mItemAmountTextField->setValue(amount); - mItemAmountSlide->setValue2(amount); + mItemAmountSlide->setValue(amount); if (mItemPriceTextField && mItemPriceSlide) { @@ -360,14 +360,14 @@ void ItemAmountWindow::action(const ActionEvent &event) mPrice++; price = static_cast(pow(10.0, mPrice)); mItemPriceTextField->setValue(price); - mItemPriceSlide->setValue2(price); + mItemPriceSlide->setValue(price); } else if (eventId == "decPrice") { mPrice--; price = static_cast(pow(10.0, mPrice)); mItemPriceTextField->setValue(price); - mItemPriceSlide->setValue2(price); + mItemPriceSlide->setValue(price); } else if (eventId == "slidePrice") { @@ -377,7 +377,7 @@ void ItemAmountWindow::action(const ActionEvent &event) else mPrice = 0; mItemPriceTextField->setValue(price); - mItemPriceSlide->setValue2(price); + mItemPriceSlide->setValue(price); } } } @@ -390,7 +390,7 @@ void ItemAmountWindow::close() void ItemAmountWindow::keyReleased(KeyEvent &keyEvent A_UNUSED) { - mItemAmountSlide->setValue2(mItemAmountTextField->getValue()); + mItemAmountSlide->setValue(mItemAmountTextField->getValue()); } void ItemAmountWindow::showWindow(const Usage usage, Window *const parent, diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp index 710875a3c..f4557a460 100644 --- a/src/gui/windows/killstats.cpp +++ b/src/gui/windows/killstats.cpp @@ -27,6 +27,7 @@ #include "gui/widgets/layout.h" #include "actormanager.h" +#include "client.h" #include "game.h" #include "being/localplayer.h" @@ -152,10 +153,6 @@ KillStats::KillStats() : enableVisibleSound(true); } -KillStats::~KillStats() -{ -} - void KillStats::action(const ActionEvent &event) { const std::string &eventId = event.getId(); @@ -303,6 +300,15 @@ void KillStats::recalcStats() m1minExpNum = newExp; } + if (curTime != 0 && mLastHost == 0xFF6B66 && cur_time > 1) + { + const int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED); + if (m1minExpTime != 0) + m1minSpeed = newExp - m1minExpNum; + mStatsReUpdated = true; + m1minExpNum = newExp; + } + if (curTime - m5minExpTime > 60*5) { const int newExp = PlayerInfo::getAttribute(PlayerInfo::EXP); diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h index 486ec9135..7d3a1d4ef 100644 --- a/src/gui/windows/killstats.h +++ b/src/gui/windows/killstats.h @@ -46,7 +46,8 @@ class KillStats final : public Window, /** * Destructor. */ - ~KillStats(); + ~KillStats() + { } /** * Stuff. diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 1607733a4..7cd6fd49f 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -162,7 +162,7 @@ SellDialog::~SellDialog() void SellDialog::reset() { mShopItems->clear(); - mSlider->setValue2(0); + mSlider->setValue(0); mShopItemList->setSelected(-1); updateButtonsAndLabels(); } @@ -213,19 +213,19 @@ void SellDialog::action(const ActionEvent &event) else if (eventId == "inc" && mAmountItems < mMaxItems) { mAmountItems++; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "dec" && mAmountItems > 1) { mAmountItems--; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); updateButtonsAndLabels(); } else if (eventId == "max") { mAmountItems = mMaxItems; - mSlider->setValue2(mAmountItems); + mSlider->setValue(mAmountItems); updateButtonsAndLabels(); } else if ((eventId == "presell" || eventId == "sell" || eventId == "yes") @@ -269,7 +269,7 @@ void SellDialog::action(const ActionEvent &event) mPlayerMoney += mAmountItems * mShopItems->at(selectedItem)->getPrice(); mAmountItems = 1; - mSlider->setValue2(0); + mSlider->setValue(0); if (mMaxItems) { @@ -304,7 +304,7 @@ void SellDialog::valueChanged(const SelectionEvent &event A_UNUSED) { // Reset amount of items and update labels mAmountItems = 1; - mSlider->setValue2(0); + mSlider->setValue(0); updateButtonsAndLabels(); mSlider->setScale(1, mMaxItems); diff --git a/src/map.cpp b/src/map.cpp index 70a48b811..c86c51bce 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -381,13 +381,9 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY) // Make sure actors are sorted ascending by Y-coordinate // so that they overlap correctly -// if (mSpritesUpdated) -// { BLOCK_START("Map::draw sort") mActors.sort(actorCompare); BLOCK_END("Map::draw sort") -// mSpritesUpdated = false; -// } // update scrolling of all ambient layers updateAmbientLayers(static_cast(scrollX), @@ -480,15 +476,6 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY) else #endif { -/* - if (updateFlag) - { - (*layeri)->updateSDL(graphics, startX, startY, - endX, endY, scrollX, scrollY, mDebugFlags); - } - - (*layeri)->drawSDL(graphics); -*/ layer->draw(graphics, startX, startY, endX, endY, scrollX, scrollY, mDebugFlags); } diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index de1d6f151..b0be76ac6 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -62,6 +62,9 @@ void GameHandler::processMapLogin(Net::MessageIn &msg) const msg.skip(2); // 0x0505 logger->log("Protocol: Player start position: (%d, %d)," " Direction: %d", x, y, direction); + + mLastHost &= 0xffffff; + // Switch now or we'll have problems client->setState(STATE_GAME); if (player_node) diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 44d834b94..df1516b8b 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -291,6 +291,30 @@ void LoginHandler::processLoginError(Net::MessageIn &msg) const client->setState(STATE_ERROR); } +void LoginHandler::loginOrRegister(LoginData *const data) +{ + if (!data) + return; + + logger->log("Username is %s", data->username.c_str()); + + // Send login infos + if (data->registerLogin) + registerAccount(data); + else + loginAccount(data); + + // Clear the password, avoids auto login when returning to login + data->password.clear(); + + const bool remember = data->remember; + if (remember) + serverConfig.setValue("username", data->username); + else + serverConfig.setValue("username", ""); + serverConfig.setValue("remember", remember); +} + void LoginHandler::logout() const { } diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index f539176f5..ec1610013 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -96,6 +96,8 @@ class LoginHandler : public Net::LoginHandler virtual void processServerVersion(Net::MessageIn &msg) = 0; + void loginOrRegister(LoginData *const data) override final; + protected: LoginHandler(); diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index c5ed9de57..128ca2996 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -32,6 +32,8 @@ #include "debug.h" +extern unsigned int mLastHost; + namespace Ea { @@ -89,7 +91,6 @@ bool Network::connect(ServerInfo server) if (mState != IDLE && mState != NET_ERROR) { logger->log1("Tried to connect an already connected socket!"); -// assert(false); return false; } @@ -217,6 +218,7 @@ bool Network::realConnect() return false; } + mLastHost = ipAddress.host; logger->log_r("Network::Started session with %s:%i", ipToString(ipAddress.host), ipAddress.port); diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index 91c2e4603..949ef5b67 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -99,6 +99,8 @@ class LoginHandler virtual void clearWorlds() = 0; + virtual void loginOrRegister(LoginData *const data) = 0; + virtual ~LoginHandler() { } -- cgit v1.2.3-70-g09d2 From 9247c5a23757e01ef7ee91dd5655fcab177e5e6d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 8 Mar 2014 13:51:57 +0300 Subject: fix code style. --- src/events/inputguievent.h | 2 +- src/gui/gui.cpp | 10 ++++------ src/gui/models/beingslistmodel.h | 4 ++++ src/gui/models/playerrelationlistmodel.h | 2 ++ src/gui/models/serverslistmodel.h | 9 +++++---- src/gui/models/worldlistmodel.h | 2 ++ src/gui/widgets/basiccontainer.h | 6 +++--- src/gui/widgets/basiccontainer2.cpp | 2 -- src/gui/widgets/basiccontainer2.h | 6 +++--- src/gui/widgets/button.cpp | 1 - src/gui/widgets/checkbox.cpp | 2 -- src/gui/widgets/label.cpp | 2 +- src/gui/widgets/listbox.cpp | 4 ---- src/gui/widgets/playerbox.h | 2 +- src/gui/widgets/radiobutton.cpp | 2 -- src/gui/widgets/slider.cpp | 2 -- src/gui/widgets/slider.h | 5 ----- src/gui/widgets/tabbedarea.cpp | 2 -- src/gui/widgets/textbox.cpp | 11 +++-------- src/gui/widgets/textfield.cpp | 2 -- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/inventorywindow.cpp | 9 ++++----- src/gui/windows/inventorywindow.h | 2 +- src/gui/windows/killstats.cpp | 1 - src/gui/windows/tradewindow.cpp | 2 +- src/net/ea/loginhandler.cpp | 2 +- src/net/ea/loginhandler.h | 2 +- src/net/loginhandler.h | 2 +- 28 files changed, 39 insertions(+), 61 deletions(-) (limited to 'src/gui/widgets/slider.h') diff --git a/src/events/inputguievent.h b/src/events/inputguievent.h index dbd2593d7..e42bec27f 100644 --- a/src/events/inputguievent.h +++ b/src/events/inputguievent.h @@ -81,7 +81,7 @@ class InputGuiEvent: public Event * @param source The source widget of the event. * @param isMetaPressed True if meta is pressed, false otherwise. */ - InputGuiEvent(Widget *const source) : + explicit InputGuiEvent(Widget *const source) : Event(source), mIsConsumed(false) { } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index d5fbd6e86..55da1b9e3 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -72,8 +72,6 @@ #include "gui/theme.h" #include "gui/viewport.h" -#include "events/mouseevent.h" - #include "gui/widgets/window.h" #include "client.h" @@ -1337,8 +1335,8 @@ void Gui::handleModalMouseInputFocus() } // Check if modal mouse input focus has been released. else if ((mFocusHandler->getLastWidgetWithModalMouseInputFocus() - != mFocusHandler->getModalMouseInputFocused()) - && (mFocusHandler->getLastWidgetWithModalMouseInputFocus())) + != mFocusHandler->getModalMouseInputFocused()) + && (mFocusHandler->getLastWidgetWithModalMouseInputFocus())) { handleModalFocusReleased(); mFocusHandler->setLastWidgetWithModalMouseInputFocus(nullptr); @@ -1360,8 +1358,8 @@ void Gui::handleModalFocus() } // Check if modal focus has been released. else if ((mFocusHandler->getLastWidgetWithModalFocus() - != mFocusHandler->getModalFocused()) - && (mFocusHandler->getLastWidgetWithModalFocus())) + != mFocusHandler->getModalFocused()) + && (mFocusHandler->getLastWidgetWithModalFocus())) { handleModalFocusReleased(); mFocusHandler->setLastWidgetWithModalFocus(nullptr); diff --git a/src/gui/models/beingslistmodel.h b/src/gui/models/beingslistmodel.h index 9f3c48bcc..f774321e9 100644 --- a/src/gui/models/beingslistmodel.h +++ b/src/gui/models/beingslistmodel.h @@ -24,6 +24,10 @@ #include "gui/models/avatarlistmodel.h" +#include "utils/dtor.h" + +#include + class BeingsListModel final : public AvatarListModel { public: diff --git a/src/gui/models/playerrelationlistmodel.h b/src/gui/models/playerrelationlistmodel.h index bc343de02..84531852d 100644 --- a/src/gui/models/playerrelationlistmodel.h +++ b/src/gui/models/playerrelationlistmodel.h @@ -25,6 +25,8 @@ #include "being/playerrelations.h" +#include "gui/models/listmodel.h" + #include "utils/gettext.h" static const char *const RELATION_NAMES[PlayerRelation::RELATIONS_NR] = diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h index 630d9664e..5c7e73387 100644 --- a/src/gui/models/serverslistmodel.h +++ b/src/gui/models/serverslistmodel.h @@ -25,17 +25,18 @@ #include "net/serverinfo.h" +#include "gui/font.h" +#include "gui/gui.h" + +#include "gui/windows/serverdialog.h" + #include "utils/mutex.h" #include "gui/models/listmodel.h" -#include "net/serverinfo.h" - #include #include -class ServerDialog; - /** * Server and Port List Model */ diff --git a/src/gui/models/worldlistmodel.h b/src/gui/models/worldlistmodel.h index 7d9dc322c..6913e1c69 100644 --- a/src/gui/models/worldlistmodel.h +++ b/src/gui/models/worldlistmodel.h @@ -25,6 +25,8 @@ #include "gui/models/listmodel.h" +#include "utils/stringutils.h" + #include "net/worldinfo.h" /** diff --git a/src/gui/widgets/basiccontainer.h b/src/gui/widgets/basiccontainer.h index bf018e0de..6e753a445 100644 --- a/src/gui/widgets/basiccontainer.h +++ b/src/gui/widgets/basiccontainer.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GCN_BASICCONTAINER_HPP -#define GCN_BASICCONTAINER_HPP +#ifndef GUI_WIDGETS_BASICCONTAINER_H +#define GUI_WIDGETS_BASICCONTAINER_H #include @@ -212,4 +212,4 @@ class BasicContainer : public Widget, WidgetList mWidgets; }; -#endif // end GCN_BASICCONTAINER_HPP +#endif // GUI_WIDGETS_BASICCONTAINER_H diff --git a/src/gui/widgets/basiccontainer2.cpp b/src/gui/widgets/basiccontainer2.cpp index 5a34ee0dc..9bd4d1593 100644 --- a/src/gui/widgets/basiccontainer2.cpp +++ b/src/gui/widgets/basiccontainer2.cpp @@ -67,8 +67,6 @@ #include "gui/widgets/basiccontainer2.h" -#include "render/graphics.h" - #include "debug.h" BasicContainer2::BasicContainer2(const Widget2 *const widget) : diff --git a/src/gui/widgets/basiccontainer2.h b/src/gui/widgets/basiccontainer2.h index 16078016f..c6f1d996b 100644 --- a/src/gui/widgets/basiccontainer2.h +++ b/src/gui/widgets/basiccontainer2.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GUI_WIDGETS_BASICCONTAINER2_HPP -#define GUI_WIDGETS_BASICCONTAINER2_HPP +#ifndef GUI_WIDGETS_BASICCONTAINER2_H +#define GUI_WIDGETS_BASICCONTAINER2_H #include "gui/widgets/basiccontainer.h" @@ -171,4 +171,4 @@ class BasicContainer2: public BasicContainer bool mOpaque; }; -#endif // GUI_WIDGETS_BASICCONTAINER2_HPP +#endif // GUI_WIDGETS_BASICCONTAINER2_H diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 8e020370f..308c75413 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -220,7 +220,6 @@ Button::Button(const Widget2 *const widget, mStick(false), mPressed(false) { - init(); loadImageSet(imageName); adjustSize(); diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index c905ae0c4..f01495bcf 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -67,8 +67,6 @@ #include "client.h" -#include "events/keyevent.h" - #include "input/keydata.h" #include "resources/image.h" diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 64dce1a84..b500ec7bb 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -88,7 +88,7 @@ Label::Label(const Widget2 *const widget, mAlignment(Graphics::LEFT), mPadding(0) { - Font *const font = getFont(); + const Font *const font = getFont(); if (font) { setWidth(font->getWidth(caption)); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index c12a3fe53..6f0c192c6 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -67,8 +67,6 @@ #include "client.h" -#include "events/keyevent.h" - #include "input/keydata.h" #include "listeners/selectionlistener.h" @@ -79,8 +77,6 @@ #include "gui/models/listmodel.h" -#include "render/graphics.h" - #include "debug.h" float ListBox::mAlpha = 1.0; diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index aae2eefe6..1a9067378 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_PLAYERBOX_H #define GUI_WIDGETS_PLAYERBOX_H -#include "gui/widgets/scrollarea.h" +#include "gui/widgets/widget.h" #include "listeners/mouselistener.h" diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 1aa77a0db..411216455 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -67,8 +67,6 @@ #include "client.h" -#include "events/keyevent.h" - #include "input/keydata.h" #include "resources/image.h" diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 8da4f34ae..700d31416 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -100,7 +100,6 @@ Slider::Slider(Widget2 *const widget, mOrientation(HORIZONTAL), mVertexes(new ImageCollection), mMarkerLength(10), - mDragged(false), mHasMouse(false), mRedraw(true) { @@ -120,7 +119,6 @@ Slider::Slider(Widget2 *const widget, mOrientation(HORIZONTAL), mVertexes(new ImageCollection), mMarkerLength(10), - mDragged(false), mHasMouse(false), mRedraw(true) { diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 3fbb66a5c..23d06de48 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -348,11 +348,6 @@ class Slider final : public Widget, */ int mMarkerLength; - /** - * True if the slider is dragged, false otherwise. - */ - bool mDragged; - bool mHasMouse; bool mRedraw; }; diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index c075cbc62..445f17982 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -75,8 +75,6 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/tabs/tab.h" -#include "gui/widgets/basiccontainer2.h" - #include "debug.h" TabbedArea::TabbedArea(const Widget2 *const widget) : diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index a00d0ccf8..5f565259b 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -65,8 +65,6 @@ #include "gui/widgets/textbox.h" -#include "events/keyevent.h" - #include "input/keydata.h" #include "gui/font.h" @@ -567,16 +565,13 @@ void TextBox::setCaretRowColumn(const int row, const int column) void TextBox::scrollToCaret() { + const Font *const font = getFont(); Rect scroll; - Font *const font = getFont(); - scroll.x = font->getWidth( - mTextRows[mCaretRow].substr(0, mCaretColumn)); + scroll.x = font->getWidth(mTextRows[mCaretRow].substr(0, mCaretColumn)); scroll.y = font->getHeight() * mCaretRow; scroll.width = font->getWidth(" "); - // add 2 for some extra space scroll.height = font->getHeight() + 2; - showPart(scroll); } @@ -619,7 +614,7 @@ void TextBox::drawCaret(Graphics *const graphics, const int x, const int y) void TextBox::adjustSize() { int width = 0; - Font *const font = getFont(); + const Font *const font = getFont(); for (size_t i = 0, sz = mTextRows.size(); i < sz; ++i) { const int w = font->getWidth(mTextRows[i]); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 98e852b00..7fe8c1bf3 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -69,8 +69,6 @@ #include "input/inputmanager.h" -#include "events/keyevent.h" - #include "gui/font.h" #include "gui/gui.h" #include "gui/viewport.h" diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 71915ab08..e9436bd34 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -351,7 +351,7 @@ void ChatWindow::adjustTabSize() { const int chatButtonSize = 20; int w = awFrame2 - chatButtonSize; - int x = aw - frame - chatButtonSize; + const int x = aw - frame - chatButtonSize; if (mSkin) { const int ipad = mSkin->getOption("emoteButtonSpacing", 2); diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index a12dca882..92b21dfd1 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -59,8 +59,6 @@ #include "net/inventoryhandler.h" #include "net/net.h" -#include "utils/gettext.h" - #include #include "debug.h" @@ -281,7 +279,7 @@ InventoryWindow::~InventoryWindow() mTextPopup = nullptr; } -void InventoryWindow::storeSortOrder() +void InventoryWindow::storeSortOrder() const { if (mInventory) { @@ -669,7 +667,8 @@ void InventoryWindow::updateButtons(const Item *item) void InventoryWindow::setSplitAllowed(const bool allowed) { - mSplitButton->setVisible(allowed); + if (mSplitButton) + mSplitButton->setVisible(allowed); } void InventoryWindow::close() @@ -699,7 +698,7 @@ void InventoryWindow::processEvent(const Channels channel A_UNUSED, void InventoryWindow::updateWeight() { - if (!isMainInventory()) + if (!isMainInventory() || !mWeightBar) return; const int total = PlayerInfo::getAttribute(PlayerInfo::TOTAL_WEIGHT); diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index c81e83d77..7e47e0362 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -71,7 +71,7 @@ class InventoryWindow final : public Window, void postInit() override final; - void storeSortOrder(); + void storeSortOrder() const; /** * Called when receiving actions from the widgets. diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp index f4557a460..456af0ebb 100644 --- a/src/gui/windows/killstats.cpp +++ b/src/gui/windows/killstats.cpp @@ -34,7 +34,6 @@ #include "being/playerinfo.h" #include "utils/gettext.h" -#include "utils/stringutils.h" #include "debug.h" diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 506f25c17..443c38619 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -440,7 +440,7 @@ void TradeWindow::initTrade(const std::string &nick) const Inventory *const inv = PlayerInfo::getInventory(); if (inv) { - Item *const item = inv->findItem(mAutoAddItem->getId(), + const Item *const item = inv->findItem(mAutoAddItem->getId(), mAutoAddItem->getColor()); if (item) tradeItem(item, mAutoAddAmount); diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index df1516b8b..174263dcd 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -291,7 +291,7 @@ void LoginHandler::processLoginError(Net::MessageIn &msg) const client->setState(STATE_ERROR); } -void LoginHandler::loginOrRegister(LoginData *const data) +void LoginHandler::loginOrRegister(LoginData *const data) const { if (!data) return; diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index ec1610013..a6e7160cb 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -96,7 +96,7 @@ class LoginHandler : public Net::LoginHandler virtual void processServerVersion(Net::MessageIn &msg) = 0; - void loginOrRegister(LoginData *const data) override final; + void loginOrRegister(LoginData *const data) const override final; protected: LoginHandler(); diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index 949ef5b67..6e832aeda 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -99,7 +99,7 @@ class LoginHandler virtual void clearWorlds() = 0; - virtual void loginOrRegister(LoginData *const data) = 0; + virtual void loginOrRegister(LoginData *const data) const = 0; virtual ~LoginHandler() { } -- cgit v1.2.3-70-g09d2