From 48646db55005a0da079bd2c945875dc8225e2f86 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 14:21:27 +0300 Subject: Move color into gui dir. --- src/CMakeLists.txt | 4 +- src/Makefile.am | 8 +- src/being/being.cpp | 2 +- src/being/being.h | 10 +- src/client.cpp | 2 +- src/flooritem.cpp | 8 +- src/gui/base/color.cpp | 168 --------------------------- src/gui/base/color.hpp | 195 -------------------------------- src/gui/base/widget.hpp | 3 +- src/gui/color.cpp | 165 +++++++++++++++++++++++++++ src/gui/color.h | 192 +++++++++++++++++++++++++++++++ src/gui/font.cpp | 16 +-- src/gui/font.h | 18 +-- src/gui/gui.h | 7 +- src/gui/palette.cpp | 30 ++--- src/gui/palette.h | 29 +++-- src/gui/popups/speechbubble.cpp | 4 +- src/gui/popups/speechbubble.h | 4 +- src/gui/theme.cpp | 10 +- src/gui/theme.h | 14 +-- src/gui/userpalette.cpp | 8 +- src/gui/userpalette.h | 9 +- src/gui/viewport.cpp | 4 +- src/gui/viewport.h | 2 +- src/gui/widgets/avatarlistbox.cpp | 5 +- src/gui/widgets/browserbox.cpp | 12 +- src/gui/widgets/browserbox.h | 22 ++-- src/gui/widgets/button.h | 16 +-- src/gui/widgets/colormodel.cpp | 4 +- src/gui/widgets/colormodel.h | 16 +-- src/gui/widgets/desktop.h | 4 +- src/gui/widgets/dropdown.h | 4 +- src/gui/widgets/dropshortcutcontainer.h | 8 +- src/gui/widgets/guitable.h | 2 +- src/gui/widgets/itemcontainer.h | 8 +- src/gui/widgets/itemshortcutcontainer.h | 8 +- src/gui/widgets/label.cpp | 6 +- src/gui/widgets/label.h | 6 +- src/gui/widgets/listbox.h | 8 +- src/gui/widgets/progressbar.cpp | 6 +- src/gui/widgets/progressbar.h | 8 +- src/gui/widgets/shoplistbox.cpp | 4 +- src/gui/widgets/shoplistbox.h | 4 +- src/gui/widgets/skillinfo.h | 4 +- src/gui/widgets/tabs/setup_colors.cpp | 6 +- src/gui/widgets/tabs/tab.h | 40 +++---- src/gui/widgets/textbox.cpp | 6 +- src/gui/widgets/textbox.h | 6 +- src/gui/widgets/textfield.h | 2 +- src/gui/widgets/textpreview.cpp | 8 +- src/gui/widgets/textpreview.h | 16 +-- src/gui/widgets/widget2.h | 16 +-- src/gui/windows/equipmentwindow.h | 8 +- src/gui/windows/outfitwindow.h | 4 +- src/gui/windows/serverdialog.cpp | 4 +- src/gui/windows/skilldialog.cpp | 4 +- src/particle/particle.cpp | 4 +- src/particle/particle.h | 13 +-- src/particle/textparticle.cpp | 6 +- src/particle/textparticle.h | 4 +- src/render/graphics.h | 17 +-- src/render/mobileopenglgraphics.h | 2 +- src/render/normalopenglgraphics.h | 2 +- src/render/nullopenglgraphics.h | 2 +- src/render/openglgraphicsdef.hpp | 4 +- src/render/safeopenglgraphics.h | 2 +- src/text.cpp | 6 +- src/text.h | 12 +- src/utils/sdlpixel.h | 7 +- 69 files changed, 625 insertions(+), 643 deletions(-) delete mode 100644 src/gui/base/color.cpp delete mode 100644 src/gui/base/color.hpp create mode 100644 src/gui/color.cpp create mode 100644 src/gui/color.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cdc61aa91..cf8a905f2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -767,7 +767,7 @@ SET(SRCS listeners/actionlistener.h gui/base/basiccontainer.hpp gui/base/cliprectangle.hpp - gui/base/color.hpp + gui/color.h listeners/deathlistener.h events/event.h listeners/focuslistener.h @@ -798,7 +798,7 @@ SET(SRCS gui/base/widgets/window.hpp gui/base/basiccontainer.cpp gui/base/cliprectangle.cpp - gui/base/color.cpp + gui/color.cpp gui/base/gui.cpp input/key.cpp gui/base/rectangle.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 246da6073..5a2fa34d7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,11 +27,11 @@ endif dyecmd_CXXFLAGS = dyecmd_SOURCES = gui/base/cliprectangle.cpp \ - gui/base/color.cpp \ + gui/color.cpp \ gui/base/rectangle.cpp \ events/actionevent.h \ gui/base/cliprectangle.hpp \ - gui/base/color.hpp \ + gui/color.h \ events/event.h \ gui/base/rectangle.hpp @@ -152,7 +152,7 @@ manaplus_SOURCES += events/actionevent.h \ listeners/actionlistener.h \ gui/base/basiccontainer.hpp \ gui/base/cliprectangle.hpp \ - gui/base/color.hpp \ + gui/color.h \ listeners/deathlistener.h \ events/event.h \ listeners/focuslistener.h \ @@ -184,7 +184,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/widgets/window.hpp \ gui/base/basiccontainer.cpp \ gui/base/cliprectangle.cpp \ - gui/base/color.cpp \ + gui/color.cpp \ gui/base/gui.cpp \ input/key.cpp \ gui/base/rectangle.cpp \ diff --git a/src/being/being.cpp b/src/being/being.cpp index 76af509d3..485b439af 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -542,7 +542,7 @@ void Being::takeDamage(Being *const attacker, const int amount, // TRANSLATORS: hit or miss message in attacks const std::string damage = amount ? toString(amount) : type == FLEE ? _("dodge") : _("miss"); - const gcn::Color *color; + const Color *color; if (gui) font = gui->getInfoParticleFont(); diff --git a/src/being/being.h b/src/being/being.h index 4ef40d9fd..e427612f0 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -41,6 +41,7 @@ static const int DEFAULT_BEING_HEIGHT = 32; class AnimatedSprite; class BeingCacheEntry; +class Color; class Equipment; class FlashText; class Guild; @@ -52,11 +53,6 @@ class Text; struct ParticleInfo; -namespace gcn -{ - class Color; -} - extern volatile int cur_time; enum Gender @@ -969,7 +965,7 @@ class Being : public ActorSprite, public ConfigListener * Holds a text object when the being displays it's name, 0 otherwise */ FlashText *mDispName; - const gcn::Color *mNameColor; + const Color *mNameColor; /** Engine-related infos about weapon. */ const ItemInfo *mEquippedWeapon; @@ -979,7 +975,7 @@ class Being : public ActorSprite, public ConfigListener Path mPath; Text *mText; - const gcn::Color *mTextColor; + const Color *mTextColor; Vector mDest; /**< destination coordinates. */ diff --git a/src/client.cpp b/src/client.cpp index a08406d10..4aa5d4cd4 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -614,7 +614,7 @@ static void updateProgress(int cnt) { const int progress = cnt + loadingProgressCounter; const int h = mainGraphics->mHeight; - mainGraphics->setColor(gcn::Color(255, 255, 255)); + mainGraphics->setColor(Color(255, 255, 255)); const int maxSize = mainGraphics->mWidth - 100; const int width = maxSize * progress / 450; mainGraphics->fillRectangle(gcn::Rectangle(50, h - 100, width, 50)); diff --git a/src/flooritem.cpp b/src/flooritem.cpp index 2592e6feb..6780b10fa 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -122,21 +122,21 @@ void FloorItem::draw(Graphics *const graphics, if (curTime > mDropTime + 28 && curTime < mDropTime + 50) { - graphics->setColor(gcn::Color(80, 200, 20, 200)); + graphics->setColor(Color(80, 200, 20, 200)); graphics->fillRectangle(gcn::Rectangle( x, y, dx, dy)); } else if (curTime > mDropTime + 19 && curTime < mDropTime + 28) { - graphics->setColor(gcn::Color(200, 80, 20, + graphics->setColor(Color(200, 80, 20, 80 + 10 * (curTime - mDropTime - 18))); graphics->fillRectangle(gcn::Rectangle( x, y, dx, dy)); } else if (curTime > mDropTime && curTime < mDropTime + 20) { - graphics->setColor(gcn::Color(20, 20, 255, + graphics->setColor(Color(20, 20, 255, 7 * (curTime - mDropTime))); graphics->fillRectangle(gcn::Rectangle( x, y, dx, dy)); @@ -153,7 +153,7 @@ void FloorItem::draw(Graphics *const graphics, { if (font && mAmount > 1) { -// graphics->setColor(gcn::Color(255, 255, 255, 100)); +// graphics->setColor(Color(255, 255, 255, 100)); graphics->setColor(userPalette->getColor( UserPalette::FLOOR_ITEM_TEXT)); font->drawString(graphics, toString(mAmount), x, y); diff --git a/src/gui/base/color.cpp b/src/gui/base/color.cpp deleted file mode 100644 index 485367e6d..000000000 --- a/src/gui/base/color.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/color.hpp" - -#include "debug.h" - -namespace gcn -{ - Color::Color() : - r(0U), - g(0U), - b(0U), - a(255U) - { - } - - Color::Color(const unsigned int color) : - r((color >> 16) & 0xFF), - g((color >> 8) & 0xFF), - b(color & 0xFF), - a(255U) - { - } - - Color::Color(const unsigned int ar, - const unsigned int ag, - const unsigned int ab, - const unsigned int aa) : - r(ar), - g(ag), - b(ab), - a(aa) - { - } - - Color Color::operator+(const Color& color) const - { - Color result(r + color.r, - g + color.g, - b + color.b, - 255U); - - result.r = (result.r > 255U ? 255U : result.r); - result.g = (result.g > 255U ? 255U : result.g); - result.b = (result.b > 255U ? 255U : result.b); - - return result; - } - - Color Color::operator-(const Color& color) const - { - Color result(r - color.r, - g - color.g, - b - color.b, - 255U); - - result.r = (result.r > 255U ? 255U : result.r); - result.g = (result.g > 255U ? 255U : result.g); - result.b = (result.b > 255U ? 255U : result.b); - - return result; - } - - Color Color::operator*(const float value) const - { - Color result(static_cast(static_cast(r) * value), - static_cast(static_cast(g) * value), - static_cast(static_cast(b) * value), - a); - - result.r = (result.r > 255U ? 255U : result.r); - result.g = (result.g > 255U ? 255U : result.g); - result.b = (result.b > 255U ? 255U : result.b); - - return result; - } - - bool Color::operator==(const Color& color) const - { - return r == color.r && g == color.g && b == color.b && a == color.a; - } - - bool Color::operator!=(const Color& color) const - { - return !(r == color.r && g == color.g && b == color.b && a == color.a); - } - - std::ostream& operator<<(std::ostream& out, - const Color& color) - { - out << "Color [r = " - << color.r - << ", g = " - << color.g - << ", b = " - << color.b - << ", a = " - << color.a - << "]"; - - return out; - } -} // namespace gcn diff --git a/src/gui/base/color.hpp b/src/gui/base/color.hpp deleted file mode 100644 index 781b2cb60..000000000 --- a/src/gui/base/color.hpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * 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 GCN_COLOR_HPP -#define GCN_COLOR_HPP - -#include - -#include "localconsts.h" - -namespace gcn -{ - /** - * Represents a color with red, green, blue and alpha components. - */ - class Color final - { - public: - /** - * Constructor. Initializes the color to black. - */ - Color(); - - /** - * Constructor. Constructs a color from the bytes in an integer. - * Call it with a hexadecimal constant for HTML-style color representation. - * The alpha component is 255 by default. - * - * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color. - * - * NOTE: Because of this constructor, integers will be automatically - * casted to a color by your compiler. - * - * @param color The color to initialise the object with. - */ - explicit Color(const unsigned int color); - - /** - * Constructor. The default alpha value is 255. - * - * @param r Red color component (range 0-255). - * @param g Green color component (range 0-255). - * @param b Blue color component (range 0-255). - * @param a Alpha, used for transparency. A value of 0 means - * totaly transparent, 255 is totaly opaque. - */ - Color(const unsigned int r, - const unsigned int g, - const unsigned int b, - const unsigned int a = 255); - - /** - * Adds the RGB values of two colors together. The values will be - * clamped if they go out of range. - * - * WARNING: This function will reset the alpha value of the - * returned color to 255. - * - * @param color A color to add to this color. - * @return The added colors with an alpha value set to 255. - */ - Color operator+(const Color& color) const; - - /** - * Subtracts the RGB values of one color from another. - * The values will be clamped if they go out of range. - * - * WARNING: This function will reset the alpha value of the - * returned color to 255. - * - * @param color A color to subtract from this color. - * @return The subtracted colors with an alpha value set to 255. - */ - Color operator-(const Color& color) const; - - /** - * Multiplies the RGB values of a color with a float value. - * The values will be clamped if they go out of range. - * - * @param value The value to multiply the color with. - * @return The multiplied colors. The alpha value will, unlike - * the add and subtract operations, be multiplied as - * well. - */ - Color operator*(const float value) const; - - /** - * Compares two colors. - * - * @return True if the two colors have the same RGBA components - * false otherwise. - */ - bool operator==(const Color& color) const; - - /** - * Compares two colors. - * - * @return True if the two colors have different RGBA components, - * false otherwise. - */ - bool operator!=(const Color& color) const; - - /** - * Output operator for output. - * - * @param out The stream to output to. - * @param color The color to output. - */ - friend std::ostream& operator<<(std::ostream& out, - const Color& Color); - - /** - * Holds the red color component (range 0-255). - */ - unsigned int r; - - /** - * Holds the green color component (range 0-255). - */ - unsigned int g; - - /** - * Holds the blue color component (range 0-255). - */ - unsigned int b; - - /** - * Holds the alpha color component. A value of 0 means totally - * transparent while a value of 255 is considered opaque. - */ - unsigned int a; - }; -} // namespace gcn - -#endif // end GCN_COLOR_HPP diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index dd872d9a1..31d61312e 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -68,7 +68,8 @@ #include #include -#include "gui/base/color.hpp" +#include "gui/color.h" + #include "gui/base/rectangle.hpp" #include "gui/widgets/widget2.h" diff --git a/src/gui/color.cpp b/src/gui/color.cpp new file mode 100644 index 000000000..9a0034257 --- /dev/null +++ b/src/gui/color.cpp @@ -0,0 +1,165 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/color.h" + +#include "debug.h" + +Color::Color() : + r(0U), + g(0U), + b(0U), + a(255U) +{ +} + +Color::Color(const unsigned int color) : + r((color >> 16) & 0xFF), + g((color >> 8) & 0xFF), + b(color & 0xFF), + a(255U) +{ +} + +Color::Color(const unsigned int ar, + const unsigned int ag, + const unsigned int ab, + const unsigned int aa) : + r(ar), + g(ag), + b(ab), + a(aa) +{ +} + +Color Color::operator+(const Color& color) const +{ + Color result(r + color.r, + g + color.g, + b + color.b, + 255U); + + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); + + return result; +} + +Color Color::operator-(const Color& color) const +{ + Color result(r - color.r, + g - color.g, + b - color.b, + 255U); + + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); + + return result; +} + +Color Color::operator*(const float value) const +{ + Color result(static_cast(static_cast(r) * value), + static_cast(static_cast(g) * value), + static_cast(static_cast(b) * value), + a); + + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); + + return result; +} + +bool Color::operator==(const Color& color) const +{ + return r == color.r && g == color.g && b == color.b && a == color.a; +} + +bool Color::operator!=(const Color& color) const +{ + return !(r == color.r && g == color.g && b == color.b && a == color.a); +} + +std::ostream& operator<<(std::ostream& out, + const Color& color) +{ + out << "Color [r = " + << color.r + << ", g = " + << color.g + << ", b = " + << color.b + << ", a = " + << color.a + << "]"; + + return out; +} diff --git a/src/gui/color.h b/src/gui/color.h new file mode 100644 index 000000000..646680d96 --- /dev/null +++ b/src/gui/color.h @@ -0,0 +1,192 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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_COLOR_H +#define GUI_COLOR_H + +#include + +#include "localconsts.h" + +/** + * Represents a color with red, green, blue and alpha components. + */ +class Color final +{ + public: + /** + * Constructor. Initializes the color to black. + */ + Color(); + + /** + * Constructor. Constructs a color from the bytes in an integer. + * Call it with a hexadecimal constant for HTML-style color representation. + * The alpha component is 255 by default. + * + * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color. + * + * NOTE: Because of this constructor, integers will be automatically + * casted to a color by your compiler. + * + * @param color The color to initialise the object with. + */ + explicit Color(const unsigned int color); + + /** + * Constructor. The default alpha value is 255. + * + * @param r Red color component (range 0-255). + * @param g Green color component (range 0-255). + * @param b Blue color component (range 0-255). + * @param a Alpha, used for transparency. A value of 0 means + * totaly transparent, 255 is totaly opaque. + */ + Color(const unsigned int r, + const unsigned int g, + const unsigned int b, + const unsigned int a = 255); + + /** + * Adds the RGB values of two colors together. The values will be + * clamped if they go out of range. + * + * WARNING: This function will reset the alpha value of the + * returned color to 255. + * + * @param color A color to add to this color. + * @return The added colors with an alpha value set to 255. + */ + Color operator+(const Color& color) const; + + /** + * Subtracts the RGB values of one color from another. + * The values will be clamped if they go out of range. + * + * WARNING: This function will reset the alpha value of the + * returned color to 255. + * + * @param color A color to subtract from this color. + * @return The subtracted colors with an alpha value set to 255. + */ + Color operator-(const Color& color) const; + + /** + * Multiplies the RGB values of a color with a float value. + * The values will be clamped if they go out of range. + * + * @param value The value to multiply the color with. + * @return The multiplied colors. The alpha value will, unlike + * the add and subtract operations, be multiplied as + * well. + */ + Color operator*(const float value) const; + + /** + * Compares two colors. + * + * @return True if the two colors have the same RGBA components + * false otherwise. + */ + bool operator==(const Color& color) const; + + /** + * Compares two colors. + * + * @return True if the two colors have different RGBA components, + * false otherwise. + */ + bool operator!=(const Color& color) const; + + /** + * Output operator for output. + * + * @param out The stream to output to. + * @param color The color to output. + */ + friend std::ostream& operator<<(std::ostream& out, + const Color& Color); + + /** + * Holds the red color component (range 0-255). + */ + unsigned int r; + + /** + * Holds the green color component (range 0-255). + */ + unsigned int g; + + /** + * Holds the blue color component (range 0-255). + */ + unsigned int b; + + /** + * Holds the alpha color component. A value of 0 means totally + * transparent while a value of 255 is considered opaque. + */ + unsigned int a; +}; + +#endif // GUI_COLOR_H diff --git a/src/gui/font.cpp b/src/gui/font.cpp index fcc8e8344..e1d793ce1 100644 --- a/src/gui/font.cpp +++ b/src/gui/font.cpp @@ -99,8 +99,8 @@ int sdlTextChunkCnt = 0; #endif SDLTextChunkSmall::SDLTextChunkSmall(const std::string &text0, - const gcn::Color &color0, - const gcn::Color &color1) : + const Color &color0, + const Color &color1) : text(text0), color(color0), color2(color1) @@ -125,7 +125,7 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const if (chunk.text != text) return chunk.text > text; - const gcn::Color &c = chunk.color; + const Color &c = chunk.color; if (c.r != color.r) return c.r > color.r; if (c.g != color.g) @@ -133,7 +133,7 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const if (c.b != color.b) return c.b > color.b; - const gcn::Color &c2 = chunk.color2; + const Color &c2 = chunk.color2; if (c2.r != color2.r) return c2.r > color2.r; if (c2.g != color2.g) @@ -147,8 +147,8 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const return false; } -SDLTextChunk::SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1) : +SDLTextChunk::SDLTextChunk(const std::string &text0, const Color &color0, + const Color &color1) : img(nullptr), text(text0), color(color0), @@ -499,8 +499,8 @@ void Font::drawString(Graphics *const graphics, if (!g) return; - gcn::Color col = g->getColor(); - const gcn::Color &col2 = g->getColor2(); + Color col = g->getColor(); + const Color &col2 = g->getColor2(); const float alpha = static_cast(col.a) / 255.0F; /* The alpha value is ignored at string generation so avoid caching the diff --git a/src/gui/font.h b/src/gui/font.h index 8740b4f3b..bdf81dadc 100644 --- a/src/gui/font.h +++ b/src/gui/font.h @@ -67,7 +67,7 @@ #ifndef GUI_FONT_H #define GUI_FONT_H -#include "gui/base/color.hpp" +#include "gui/color.h" #include @@ -84,8 +84,8 @@ const unsigned int CACHES_NUMBER = 256; class SDLTextChunkSmall { public: - SDLTextChunkSmall(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); + SDLTextChunkSmall(const std::string &text0, const Color &color0, + const Color &color1); SDLTextChunkSmall(const SDLTextChunkSmall &old); @@ -93,15 +93,15 @@ class SDLTextChunkSmall bool operator<(const SDLTextChunkSmall &chunk) const; std::string text; - gcn::Color color; - gcn::Color color2; + Color color; + Color color2; }; class SDLTextChunk final { public: - SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); + SDLTextChunk(const std::string &text0, const Color &color0, + const Color &color1); A_DELETE_COPY(SDLTextChunk) @@ -113,8 +113,8 @@ class SDLTextChunk final Image *img; std::string text; - gcn::Color color; - gcn::Color color2; + Color color; + Color color2; SDLTextChunk *prev; SDLTextChunk *next; }; diff --git a/src/gui/gui.h b/src/gui/gui.h index f6b4fbbf6..232d47a22 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -23,7 +23,8 @@ #ifndef GUI_GUI_H #define GUI_GUI_H -#include "gui/base/color.hpp" +#include "gui/color.h" + #include "gui/base/gui.hpp" #include "localconsts.h" @@ -198,8 +199,8 @@ class Gui final : public gcn::Gui typedef std::list FocusListenerList; typedef FocusListenerList::iterator FocusListenerIterator; FocusListenerList mFocusListeners; - gcn::Color mForegroundColor; - gcn::Color mForegroundColor2; + Color mForegroundColor; + Color mForegroundColor2; int mTime; bool mCustomCursor; /**< Show custom cursor */ bool mDoubleClick; diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index 9d6c19095..21e027d82 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -29,18 +29,18 @@ #include "debug.h" -const gcn::Color Palette::BLACK = gcn::Color(0, 0, 0); +const Color Palette::BLACK = Color(0, 0, 0); Palette::Palettes Palette::mInstances; -const gcn::Color Palette::RAINBOW_COLORS[7] = +const Color Palette::RAINBOW_COLORS[7] = { - gcn::Color(255, 0, 0), - gcn::Color(255, 153, 0), - gcn::Color(255, 255, 0), - gcn::Color(0, 153, 0), - gcn::Color(0, 204, 204), - gcn::Color(51, 0, 153), - gcn::Color(153, 0, 153) + Color(255, 0, 0), + Color(255, 153, 0), + Color(255, 255, 0), + Color(0, 153, 0), + Color(0, 204, 204), + Color(51, 0, 153), + Color(153, 0, 153) }; const int Palette::RAINBOW_COLOR_COUNT = 7; @@ -59,7 +59,7 @@ Palette::~Palette() mInstances.erase(this); } -const gcn::Color& Palette::getCharColor(const signed char c, bool &valid) const +const Color& Palette::getCharColor(const signed char c, bool &valid) const { const CharColors::const_iterator it = mCharColors.find(c); if (it != mCharColors.end()) @@ -128,7 +128,7 @@ void Palette::advanceGradient() else colIndex = gradIndex; - gcn::Color &color = elem->color; + Color &color = elem->color; int colVal; if (grad == PULSE) @@ -136,7 +136,7 @@ void Palette::advanceGradient() colVal = static_cast(255.0 * sin(M_PI * colIndex / numOfColors)); - const gcn::Color &col = elem->testColor; + const Color &col = elem->testColor; color.r = ((colVal * col.r) / 255) % (col.r + 1); color.g = ((colVal * col.g) / 255) % (col.g + 1); @@ -180,9 +180,9 @@ void Palette::advanceGradient() } else if (elem->grad == RAINBOW) { - const gcn::Color &startCol = RAINBOW_COLORS[colIndex]; - const gcn::Color &destCol = - RAINBOW_COLORS[(colIndex + 1) % numOfColors]; + const Color &startCol = RAINBOW_COLORS[colIndex]; + const Color &destCol + = RAINBOW_COLORS[(colIndex + 1) % numOfColors]; double startColVal; double destColVal; diff --git a/src/gui/palette.h b/src/gui/palette.h index 1377822ca..0dbb5d3ad 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -26,7 +26,7 @@ #include "logger.h" -#include "gui/base/color.hpp" +#include "gui/color.h" #if defined __native_client__ #include @@ -49,7 +49,7 @@ class Palette { public: /** Black Color Constant */ - static const gcn::Color BLACK; + static const Color BLACK; /** Colors can be static or can alter over time. */ enum GradientType @@ -71,8 +71,8 @@ class Palette * * @return the requested color or Palette::BLACK */ - const gcn::Color &getCharColor(const signed char c, - bool &valid) const A_WARN_UNUSED; + const Color &getCharColor(const signed char c, + bool &valid) const A_WARN_UNUSED; int getIdByChar(const signed char c, bool &valid) const A_WARN_UNUSED; @@ -85,8 +85,8 @@ class Palette * * @return the requested color */ - inline const gcn::Color &getColor(int type, - const int alpha = 255) A_WARN_UNUSED + inline const Color &getColor(int type, + const int alpha = 255) A_WARN_UNUSED { if (type >= static_cast(mColors.size()) || type < 0) { @@ -94,15 +94,14 @@ class Palette type, static_cast(mColors.size())); type = 0; } - gcn::Color* col = &mColors[type].color; + Color* col = &mColors[type].color; col->a = alpha; return *col; } - inline const gcn::Color &getColorWithAlpha(const int type) - A_WARN_UNUSED + inline const Color &getColorWithAlpha(const int type) A_WARN_UNUSED { - gcn::Color* col = &mColors[type].color; + Color* col = &mColors[type].color; col->a = mColors[type].delay; return *col; } @@ -144,7 +143,7 @@ class Palette protected: /** Colors used for the rainbow gradient */ - static const gcn::Color RAINBOW_COLORS[7]; + static const Color RAINBOW_COLORS[7]; static const int RAINBOW_COLOR_COUNT; /** Time tick, that gradient-type colors were updated the last time. */ @@ -183,9 +182,9 @@ class Palette } int type; - gcn::Color color; - gcn::Color testColor; - gcn::Color committedColor; + Color color; + Color testColor; + Color committedColor; std::string text; signed char ch; GradientType grad; @@ -194,7 +193,7 @@ class Palette int delay; int committedDelay; - void set(const int type0, const gcn::Color &color0, + void set(const int type0, const Color &color0, const GradientType grad0, const int delay0) { type = type0; diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp index 9bb6157bc..3d0250a78 100644 --- a/src/gui/popups/speechbubble.cpp +++ b/src/gui/popups/speechbubble.cpp @@ -57,8 +57,8 @@ void SpeechBubble::postInit() } void SpeechBubble::setCaption(const std::string &name, - const gcn::Color *const color1, - const gcn::Color *const color2) + const Color *const color1, + const Color *const color2) { mCaption->setCaption(name); mCaption->adjustSize(); diff --git a/src/gui/popups/speechbubble.h b/src/gui/popups/speechbubble.h index 62da9b146..1bc5385a4 100644 --- a/src/gui/popups/speechbubble.h +++ b/src/gui/popups/speechbubble.h @@ -47,9 +47,9 @@ class SpeechBubble final : public Popup * Sets the name displayed for the speech bubble, and in what color. */ void setCaption(const std::string &name, - const gcn::Color *const color1 = + const Color *const color1 = &Theme::getThemeColor(Theme::BUBBLE_NAME), - const gcn::Color *const color2 = + const Color *const color2 = &Theme::getThemeColor(Theme::BUBBLE_NAME_OUTLINE)); /** diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 2a1b0d624..1a504f680 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -259,7 +259,7 @@ void Theme::deleteInstance() mInstance = nullptr; } -gcn::Color Theme::getProgressColor(const int type, const float progress) +Color Theme::getProgressColor(const int type, const float progress) { int color[3] = {0, 0, 0}; @@ -273,7 +273,7 @@ gcn::Color Theme::getProgressColor(const int type, const float progress) logger->log("color not found: " + toString(type)); } - return gcn::Color(color[0], color[1], color[2]); + return Color(color[0], color[1], color[2]); } Skin *Theme::load(const std::string &filename, const std::string &filename2, @@ -972,7 +972,7 @@ static int readColorType(const std::string &type) return -1; } -static gcn::Color readColor(const std::string &description) +static Color readColor(const std::string &description) { const int size = static_cast(description.length()); if (size < 7 || description[0] != '#') @@ -1010,7 +1010,7 @@ static gcn::Color readColor(const std::string &description) v = (v << 4) | n; } - return gcn::Color(v); + return Color(v); } static Palette::GradientType readColorGradient(const std::string &grad) @@ -1084,7 +1084,7 @@ void Theme::loadColors(std::string file) int type; std::string temp; - gcn::Color color; + Color color; GradientType grad; for_each_xml_child_node(paletteNode, root) diff --git a/src/gui/theme.h b/src/gui/theme.h index 826902004..86543ea64 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -450,21 +450,21 @@ class Theme final : public Palette, public ConfigListener * * @return the requested color */ - inline static const gcn::Color &getThemeColor(const int type, - const int alpha = 255) - A_WARN_UNUSED + inline static const Color &getThemeColor(const int type, + const int alpha = 255) + A_WARN_UNUSED { return mInstance->getColor(type, alpha); } - static const gcn::Color &getThemeCharColor(const signed char c, - bool &valid) A_WARN_UNUSED + static const Color &getThemeCharColor(const signed char c, + bool &valid) A_WARN_UNUSED { return mInstance->getCharColor(c, valid); } static int getThemeIdByChar(const signed char c, bool &valid) A_WARN_UNUSED { return mInstance->getIdByChar(c, valid); } - static gcn::Color getProgressColor(const int type, - const float progress) A_WARN_UNUSED; + static Color getProgressColor(const int type, + const float progress) A_WARN_UNUSED; /** * Loads a skin. diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index 69125f8e2..74d47203f 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -237,7 +237,7 @@ UserPalette::~UserPalette() void UserPalette::setColor(const int type, const int r, const int g, const int b) { - gcn::Color &color = mColors[type].color; + Color &color = mColors[type].color; color.r = r; color.g = g; color.b = b; @@ -296,14 +296,14 @@ void UserPalette::rollback() if (i->grad != i->committedGrad) setGradient(i->type, i->committedGrad); - const gcn::Color &committedColor = i->committedColor; + const Color &committedColor = i->committedColor; setGradientDelay(i->type, i->committedDelay); setColor(i->type, committedColor.r, committedColor.g, committedColor.b); if (i->grad == PULSE) { - gcn::Color &testColor = i->testColor; + Color &testColor = i->testColor; testColor.r = committedColor.r; testColor.g = committedColor.g; testColor.b = committedColor.b; @@ -342,7 +342,7 @@ void UserPalette::addColor(const unsigned type, const unsigned rgb, rgbValue = atox(rgbString); else rgbValue = atoi(rgbString.c_str()); - const gcn::Color &trueCol = gcn::Color(rgbValue); + const Color &trueCol = Color(rgbValue); grad = static_cast(config.getValue(configName + "Gradient", static_cast(grad))); delay = config.getValueInt(configName + "Delay", delay); diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index fbba415b8..e37eee0ca 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -100,8 +100,8 @@ class UserPalette final : public Palette, public gcn::ListModel * * @return the requested committed color */ - inline const gcn::Color &getCommittedColor(const int type) - const A_WARN_UNUSED + inline const Color &getCommittedColor(const int type) + const A_WARN_UNUSED { return mColors[type].committedColor; } @@ -113,8 +113,7 @@ class UserPalette final : public Palette, public gcn::ListModel * * @return the requested test color */ - inline const gcn::Color &getTestColor(const int type) - const A_WARN_UNUSED + inline const Color &getTestColor(const int type) const A_WARN_UNUSED { return mColors[type].testColor; } /** @@ -123,7 +122,7 @@ class UserPalette final : public Palette, public gcn::ListModel * @param type the color type requested * @param color the color that should be tested */ - inline void setTestColor(const int type, const gcn::Color &color) + inline void setTestColor(const int type, const Color &color) { mColors[type].testColor = color; } /** diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index ee64736eb..54619c3e6 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -121,7 +121,7 @@ void Viewport::draw(Graphics *graphics) if (!mMap || !player_node) { - graphics->setColor(gcn::Color(64, 64, 64)); + graphics->setColor(Color(64, 64, 64)); graphics->fillRectangle( gcn::Rectangle(0, 0, getWidth(), getHeight())); BLOCK_END("Viewport::draw 1") @@ -338,7 +338,7 @@ void Viewport::_drawDebugPath(Graphics *const graphics) } void Viewport::_drawPath(Graphics *const graphics, const Path &path, - const gcn::Color &color) const + const Color &color) const { graphics->setColor(color); Font *const font = getFont(); diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 2b297de37..16d0e4e34 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -298,7 +298,7 @@ class Viewport final : public WindowContainer, * Draws the given path. */ void _drawPath(Graphics *const graphics, const Path &path, - const gcn::Color &color = gcn::Color(255, 0, 0)) const; + const Color &color = Color(255, 0, 0)) const; /** * Make the player go to the mouse position. diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 298ab657a..a71051b5d 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -154,7 +154,7 @@ void AvatarListBox::draw(Graphics *graphics) } if (parent && a->getMaxHp()) { - gcn::Color color = Theme::getProgressColor( + Color color = Theme::getProgressColor( Theme::PROG_HP, static_cast(a->getHp()) / static_cast(a->getMaxHp())); color.a = 80; @@ -180,8 +180,7 @@ void AvatarListBox::draw(Graphics *graphics) if (parent) { - gcn::Color color = Theme::getProgressColor(Theme::PROG_HP, - 1); + Color color = Theme::getProgressColor(Theme::PROG_HP, 1); color.a = 80; graphics->setColor(color); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index cc83d2b83..b6644cbc1 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -534,8 +534,8 @@ int BrowserBox::calcHeight() const char *const hyphen = "~"; const int hyphenWidth = font->getWidth(hyphen); - gcn::Color selColor[2] = {mForegroundColor, mForegroundColor2}; - const gcn::Color textColor[2] = {mForegroundColor, mForegroundColor2}; + Color selColor[2] = {mForegroundColor, mForegroundColor2}; + const Color textColor[2] = {mForegroundColor, mForegroundColor2}; ResourceManager *const resman = ResourceManager::getInstance(); mLineParts.clear(); @@ -581,7 +581,7 @@ int BrowserBox::calcHeight() continue; } - gcn::Color prevColor[2]; + Color prevColor[2]; prevColor[0] = selColor[0]; prevColor[1] = selColor[1]; bold = false; @@ -621,7 +621,7 @@ int BrowserBox::calcHeight() const signed char c = row.at(start + 2); bool valid(false); - const gcn::Color col[2] = + const Color col[2] = { getThemeCharColor(c, valid), getThemeCharColor(c | 0x80, valid) @@ -897,8 +897,8 @@ std::string BrowserBox::getTextAtPos(const int x, const int y) const return str; } -void BrowserBox::setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2) +void BrowserBox::setForegroundColorAll(const Color &color1, + const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 1f09dd0b1..a33c69698 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -58,8 +58,8 @@ struct BrowserLink final class LinePart final { public: - LinePart(const int x, const int y, const gcn::Color &color, - const gcn::Color &color2, const std::string &text, + LinePart(const int x, const int y, const Color &color, + const Color &color2, const std::string &text, const bool bold) : mX(x), mY(y), @@ -72,8 +72,8 @@ class LinePart final { } - LinePart(const int x, const int y, const gcn::Color &color, - const gcn::Color &color2, Image *const image) : + LinePart(const int x, const int y, const Color &color, + const Color &color2, Image *const image) : mX(x), mY(y), mColor(color), @@ -88,8 +88,8 @@ class LinePart final ~LinePart(); int mX, mY; - gcn::Color mColor; - gcn::Color mColor2; + Color mColor; + Color mColor2; std::string mText; unsigned char mType; Image *mImage; @@ -228,8 +228,8 @@ class BrowserBox final : public gcn::Widget, int getPadding() const A_WARN_UNUSED { return mPadding; } - void setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2); + void setForegroundColorAll(const Color &color1, + const Color &color2); int getDataWidth() const { return mDataWidth; } @@ -266,9 +266,9 @@ class BrowserBox final : public gcn::Widget, int mItemPadding; unsigned int mDataWidth; - gcn::Color mHighlightColor; - gcn::Color mHyperLinkColor; - gcn::Color mColors[2][COLORS_MAX]; + Color mHighlightColor; + Color mHyperLinkColor; + Color mColors[2][COLORS_MAX]; bool mOpaque; bool mUseLinksAndUserColors; diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 4f2e9fd89..039475150 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -165,14 +165,14 @@ class Button final : public gcn::Button, std::string mDescription; ImageCollection *mVertexes2; - gcn::Color mEnabledColor; - gcn::Color mEnabledColor2; - gcn::Color mDisabledColor; - gcn::Color mDisabledColor2; - gcn::Color mHighlightedColor; - gcn::Color mHighlightedColor2; - gcn::Color mPressedColor; - gcn::Color mPressedColor2; + Color mEnabledColor; + Color mEnabledColor2; + Color mDisabledColor; + Color mDisabledColor2; + Color mHighlightedColor; + Color mHighlightedColor2; + Color mPressedColor; + Color mPressedColor2; Image **mImages; ImageSet *mImageSet; unsigned mClickCount; diff --git a/src/gui/widgets/colormodel.cpp b/src/gui/widgets/colormodel.cpp index 7e59553e3..3a71a93cc 100644 --- a/src/gui/widgets/colormodel.cpp +++ b/src/gui/widgets/colormodel.cpp @@ -56,8 +56,8 @@ const ColorPair *ColorModel::getColorAt(const int i) const return &mColors[i]; } -void ColorModel::add(const std::string &name, const gcn::Color *const color1, - const gcn::Color *const color2) +void ColorModel::add(const std::string &name, const Color *const color1, + const Color *const color2) { mNames.push_back(name); mColors.push_back(ColorPair(color1, color2)); diff --git a/src/gui/widgets/colormodel.h b/src/gui/widgets/colormodel.h index c019d9aac..7386a856b 100644 --- a/src/gui/widgets/colormodel.h +++ b/src/gui/widgets/colormodel.h @@ -27,23 +27,19 @@ #include "localconsts.h" +class Color; class Widget2; -namespace gcn -{ - class Color; -} - struct ColorPair { - ColorPair(const gcn::Color* c1, const gcn::Color* c2) : + ColorPair(const Color* c1, const Color* c2) : color1(c1), color2(c2) { } - const gcn::Color* color1; - const gcn::Color* color2; + const Color* color1; + const Color* color2; }; class ColorModel : public gcn::ListModel @@ -67,8 +63,8 @@ class ColorModel : public gcn::ListModel size_t size() A_WARN_UNUSED { return mNames.size(); } - void add(const std::string &name, const gcn::Color *const color1, - const gcn::Color *const color2); + void add(const std::string &name, const Color *const color1, + const Color *const color2); static ColorModel *createDefault(const Widget2 *const widget); diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index ad07b0ff8..f0fd500ea 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -72,8 +72,8 @@ class Desktop final : public Container, Image *mWallpaper; Label *mVersionLabel; Skin *mSkin; - gcn::Color mBackgroundColor; - gcn::Color mBackgroundGrayColor; + Color mBackgroundColor; + Color mBackgroundGrayColor; bool mShowBackground; }; diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 9bb459d45..815e4a85d 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -144,8 +144,8 @@ class DropDown final : public ActionListener, void drawButton(Graphics *graphics); PopupList *mPopup; - gcn::Color mShadowColor; - gcn::Color mHighlightColor; + Color mShadowColor; + Color mHighlightColor; int mPadding; int mImagePadding; int mSpacing; diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 236415b32..1888292de 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -79,10 +79,10 @@ class DropShortcutContainer final : public ShortcutContainer bool mItemClicked; ItemPopup *mItemPopup; - gcn::Color mEquipedColor; - gcn::Color mEquipedColor2; - gcn::Color mUnEquipedColor; - gcn::Color mUnEquipedColor2; + Color mEquipedColor; + Color mEquipedColor2; + Color mUnEquipedColor; + Color mUnEquipedColor2; }; #endif // GUI_WIDGETS_DROPSHORTCUTCONTAINER_H diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 96f2a9532..b2c7c5620 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -188,7 +188,7 @@ private: /** * Holds the background color of the table. */ - gcn::Color mHighlightColor; + Color mHighlightColor; int mSelectedRow; int mSelectedColumn; diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index ab813b08f..32daa459b 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -181,10 +181,10 @@ class ItemContainer final : public gcn::Widget, ItemPopup *mItemPopup; int *mShowMatrix; Skin *mSkin; - gcn::Color mEquipedColor; - gcn::Color mEquipedColor2; - gcn::Color mUnEquipedColor; - gcn::Color mUnEquipedColor2; + Color mEquipedColor; + Color mEquipedColor2; + Color mUnEquipedColor; + Color mUnEquipedColor2; typedef std::list SelectionListenerList; typedef SelectionListenerList::iterator SelectionListenerIterator; SelectionListenerList mSelectionListeners; diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index dd95851a6..07c3ef822 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -83,10 +83,10 @@ class ItemShortcutContainer final : public ShortcutContainer ItemPopup *mItemPopup; SpellPopup *mSpellPopup; - gcn::Color mEquipedColor; - gcn::Color mEquipedColor2; - gcn::Color mUnEquipedColor; - gcn::Color mUnEquipedColor2; + Color mEquipedColor; + Color mEquipedColor2; + Color mUnEquipedColor; + Color mUnEquipedColor2; }; #endif // GUI_WIDGETS_ITEMSHORTCUTCONTAINER_H diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 0c19d03c3..c02f37adb 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -114,14 +114,14 @@ void Label::adjustSize() setHeight(font->getHeight() + pad2); } -void Label::setForegroundColor(const gcn::Color &color) +void Label::setForegroundColor(const Color &color) { mForegroundColor = color; mForegroundColor2 = color; } -void Label::setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2) +void Label::setForegroundColorAll(const Color &color1, + const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index b63c9b10e..616f6cc79 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -62,10 +62,10 @@ class Label final : public gcn::Label void adjustSize(); - void setForegroundColor(const gcn::Color &color); + void setForegroundColor(const Color &color); - void setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2); + void setForegroundColorAll(const Color &color1, + const Color &color2); void resizeTo(const int maxSize, const int minSize); diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 625f21085..61e1596f7 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_LISTBOX_H #define GUI_WIDGETS_LISTBOX_H -#include "gui/base/color.hpp" +#include "gui/color.h" #include "gui/base/widgets/listbox.hpp" @@ -115,9 +115,9 @@ class ListBox : public gcn::ListBox { mRowHeight = n; } protected: - gcn::Color mHighlightColor; - gcn::Color mForegroundSelectedColor; - gcn::Color mForegroundSelectedColor2; + Color mHighlightColor; + Color mForegroundSelectedColor; + Color mForegroundSelectedColor2; int mOldSelected; int mPadding; int mPressedIndex; diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index b44b6a1a0..7d2d00ad4 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -184,7 +184,7 @@ void ProgressBar::setProgressPalette(const int progressPalette) } } -void ProgressBar::setBackgroundColor(const gcn::Color &color) +void ProgressBar::setBackgroundColor(const Color &color) { mRedraw = true; mBackgroundColorToGo = color; @@ -193,7 +193,7 @@ void ProgressBar::setBackgroundColor(const gcn::Color &color) mBackgroundColor = color; } -void ProgressBar::setColor(const gcn::Color &color1, const gcn::Color &color2) +void ProgressBar::setColor(const Color &color1, const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; @@ -269,7 +269,7 @@ void ProgressBar::render(Graphics *graphics) // The label if (!mText.empty()) { - const gcn::Color oldColor = graphics->getColor(); + const Color oldColor = graphics->getColor(); Font *const font = gui->getFont(); const int textX = mDimension.width / 2; diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index a2c55e077..a4862882e 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -93,14 +93,14 @@ class ProgressBar final : public gcn::Widget, /** * Change the color of the progress bar. */ - void setBackgroundColor(const gcn::Color &color); + void setBackgroundColor(const Color &color); - void setColor(const gcn::Color &color1, const gcn::Color &color2); + void setColor(const Color &color1, const Color &color2); /** * Returns the color of the progress bar. */ - const gcn::Color &getBackgroundColor() const A_WARN_UNUSED + const Color &getBackgroundColor() const A_WARN_UNUSED { return mBackgroundColor; } /** @@ -145,7 +145,7 @@ class ProgressBar final : public gcn::Widget, float mProgress; float mProgressToGo; - gcn::Color mBackgroundColorToGo; + Color mBackgroundColorToGo; std::string mText; ImageCollection *mVertexes; diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 85ff90261..59ae1059e 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -106,8 +106,8 @@ void ShopListBox::draw(Graphics *graphics) ++i, y += mRowHeight) { bool needDraw(false); - gcn::Color temp; - gcn::Color* backgroundColor = &mBackgroundColor; + Color temp; + Color* backgroundColor = &mBackgroundColor; ShopItem *const item = mShopItems->at(i); if (item && ((mShopItems && mPlayerMoney < item->getPrice() diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 1cf628cca..38e209c33 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -94,8 +94,8 @@ class ShopListBox final : public ListBox ItemPopup *mItemPopup; - gcn::Color mBackgroundColor; - gcn::Color mWarningColor; + Color mBackgroundColor; + Color mWarningColor; bool mPriceCheck; bool mProtectItems; diff --git a/src/gui/widgets/skillinfo.h b/src/gui/widgets/skillinfo.h index a201f3274..f9baec6cc 100644 --- a/src/gui/widgets/skillinfo.h +++ b/src/gui/widgets/skillinfo.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_SKILLINFO_H #define GUI_WIDGETS_SKILLINFO_H -#include "gui/base/color.hpp" +#include "gui/color.h" #include #include @@ -43,7 +43,7 @@ struct SkillInfo final std::string skillLevel; std::string skillExp; float progress; - gcn::Color color; + Color color; SkillDataMap dataMap; SkillModel *model; SkillData *data; diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 9e78133f5..61219fa98 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -253,7 +253,7 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED) mSelected = mColorBox->getSelected(); const int type = userPalette->getColorTypeAt(mSelected); - const gcn::Color *col = &userPalette->getColor(type); + const Color *col = &userPalette->getColor(type); const Palette::GradientType grad = userPalette->getGradientType(type); const int delay = userPalette->getGradientDelay(type); @@ -383,7 +383,7 @@ void Setup_Colors::cancel() userPalette->rollback(); const int type = userPalette->getColorTypeAt(mSelected); - const gcn::Color *const col = &userPalette->getColor(type); + const Color *const col = &userPalette->getColor(type); mGradTypeSlider->setValue2(userPalette->getGradientType(type)); const int delay = userPalette->getGradientDelay(type); setEntry(mGradDelaySlider, mGradDelayText, delay); @@ -444,7 +444,7 @@ void Setup_Colors::updateColor() } else if (grad == Palette::PULSE) { - userPalette->setTestColor(type, gcn::Color( + userPalette->setTestColor(type, Color( static_cast(mRedSlider->getValue()), static_cast(mGreenSlider->getValue()), static_cast(mBlueSlider->getValue()))); diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index 463a6b668..1f52cde88 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -114,8 +114,8 @@ class Tab : public gcn::BasicContainer, /** * Set the normal color for the tab's text. */ - void setTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setTabColor(const Color *const color1, + const Color *const color2) { mTabColor = color1; mTabOutlineColor = color2; @@ -124,8 +124,8 @@ class Tab : public gcn::BasicContainer, /** * Set the highlighted color for the tab's text. */ - void setHighlightedTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setHighlightedTabColor(const Color *const color1, + const Color *const color2) { mTabHighlightedColor = color1; mTabHighlightedOutlineColor = color2; @@ -134,8 +134,8 @@ class Tab : public gcn::BasicContainer, /** * Set the selected color for the tab's text. */ - void setSelectedTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setSelectedTabColor(const Color *const color1, + const Color *const color2) { mTabSelectedColor = color1; mTabSelectedOutlineColor = color2; @@ -144,8 +144,8 @@ class Tab : public gcn::BasicContainer, /** * Set the flash color for the tab's text. */ - void setFlashTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setFlashTabColor(const Color *const color1, + const Color *const color2) { mFlashColor = color1; mFlashOutlineColor = color2; @@ -154,8 +154,8 @@ class Tab : public gcn::BasicContainer, /** * Set the player flash color for the tab's text. */ - void setPlayerFlashTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setPlayerFlashTabColor(const Color *const color1, + const Color *const color2) { mPlayerFlashColor = color1; mPlayerFlashOutlineColor = color2; @@ -214,16 +214,16 @@ class Tab : public gcn::BasicContainer, static int mInstances; /**< Number of tab instances */ static float mAlpha; - const gcn::Color *mTabColor; - const gcn::Color *mTabOutlineColor; - const gcn::Color *mTabHighlightedColor; - const gcn::Color *mTabHighlightedOutlineColor; - const gcn::Color *mTabSelectedColor; - const gcn::Color *mTabSelectedOutlineColor; - const gcn::Color *mFlashColor; - const gcn::Color *mFlashOutlineColor; - const gcn::Color *mPlayerFlashColor; - const gcn::Color *mPlayerFlashOutlineColor; + const Color *mTabColor; + const Color *mTabOutlineColor; + const Color *mTabHighlightedColor; + const Color *mTabHighlightedOutlineColor; + const Color *mTabSelectedColor; + const Color *mTabSelectedOutlineColor; + const Color *mFlashColor; + const Color *mFlashOutlineColor; + const Color *mPlayerFlashColor; + const Color *mPlayerFlashOutlineColor; int mFlash; ImageCollection *mVertexes; Image *mImage; diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index ec0d09a26..e0327e670 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -379,14 +379,14 @@ void TextBox::draw(Graphics* graphics) BLOCK_END("TextBox::draw") } -void TextBox::setForegroundColor(const gcn::Color &color) +void TextBox::setForegroundColor(const Color &color) { mForegroundColor = color; mForegroundColor2 = color; } -void TextBox::setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2) +void TextBox::setForegroundColorAll(const Color &color1, + const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index 24dd57adb..3f78fd247 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -61,10 +61,10 @@ class TextBox final : public gcn::TextBox void draw(Graphics* graphics) override final; - void setForegroundColor(const gcn::Color &color); + void setForegroundColor(const Color &color); - void setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2); + void setForegroundColorAll(const Color &color1, + const Color &color2); private: int mMinWidth; diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index b05a498dc..ccc1b16d6 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -159,7 +159,7 @@ class TextField : public gcn::TextField, static Skin *mSkin; private: - const gcn::Color *mCaretColor; + const Color *mCaretColor; PopupMenu *mPopupMenu; static int instances; static float mAlpha; diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 1344c647a..462ba17d9 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -89,7 +89,7 @@ void TextPreview::draw(Graphics* graphics) if (mOpaque) { - graphics->setColor(gcn::Color(static_cast(mBGColor->r), + graphics->setColor(Color(static_cast(mBGColor->r), static_cast(mBGColor->g), static_cast(mBGColor->b), static_cast(mAlpha * 255.0F))); @@ -105,7 +105,7 @@ void TextPreview::draw(Graphics* graphics) + 2 * ((mOutline || mShadow) ? 1 :0); const int y = mFont->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); - graphics->setColor(gcn::Color(static_cast(mTextBGColor->r), + graphics->setColor(Color(static_cast(mTextBGColor->r), static_cast(mTextBGColor->g), static_cast(mTextBGColor->b), intAlpha)); @@ -113,9 +113,9 @@ void TextPreview::draw(Graphics* graphics) } } - graphics->setColorAll(gcn::Color(mTextColor->r, + graphics->setColorAll(Color(mTextColor->r, mTextColor->g, mTextColor->b, alpha), - gcn::Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha)); + Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha)); if (mOutline && mTextColor != mTextColor2) graphics->setColor2(Theme::getThemeColor(Theme::OUTLINE)); diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index 31f64f545..31768fa66 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -40,10 +40,10 @@ class TextPreview final : public gcn::Widget ~TextPreview(); - inline void setTextColor(const gcn::Color *color) + inline void setTextColor(const Color *color) { mTextColor = color; adjustSize(); } - inline void setTextColor2(const gcn::Color *color) + inline void setTextColor2(const Color *color) { mTextColor2 = color; adjustSize(); } /** @@ -60,7 +60,7 @@ class TextPreview final : public gcn::Widget * * @param color the color to set */ - inline void setTextBGColor(const gcn::Color *color) + inline void setTextBGColor(const Color *color) { mTextBGColor = color; } /** @@ -68,7 +68,7 @@ class TextPreview final : public gcn::Widget * * @param color the color to set */ - inline void setBGColor(const gcn::Color *color) + inline void setBGColor(const Color *color) { mBGColor = color; } /** @@ -123,10 +123,10 @@ class TextPreview final : public gcn::Widget private: Font *mFont; std::string mText; - const gcn::Color *mTextColor; - const gcn::Color *mTextColor2; - const gcn::Color *mBGColor; - const gcn::Color *mTextBGColor; + const Color *mTextColor; + const Color *mTextColor2; + const Color *mBGColor; + const Color *mTextBGColor; int mPadding; static int instances; static float mAlpha; diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h index c6317702f..ff565815f 100644 --- a/src/gui/widgets/widget2.h +++ b/src/gui/widgets/widget2.h @@ -32,16 +32,16 @@ class Widget2 { } - inline const gcn::Color &getThemeColor(const int type, - const int alpha = 255) - const A_WARN_UNUSED + inline const Color &getThemeColor(const int type, + const int alpha = 255) + const A_WARN_UNUSED { return Theme::getThemeColor(mPaletteOffset + type, alpha); } - inline const gcn::Color &getThemeCharColor(const signed char c, - bool &valid) - const A_WARN_UNUSED + inline const Color &getThemeCharColor(const signed char c, + bool &valid) + const A_WARN_UNUSED { const int colorId = Theme::getThemeIdByChar(c, valid); if (valid) @@ -71,7 +71,7 @@ class Widget2 } } - void setForegroundColor2(const gcn::Color &color) + void setForegroundColor2(const Color &color) { mForegroundColor2 = color; } @@ -85,7 +85,7 @@ class Widget2 } int mPaletteOffset; - gcn::Color mForegroundColor2; + Color mForegroundColor2; }; extern RenderType openGLMode; diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h index c9ca12bbd..0ab4ca462 100644 --- a/src/gui/windows/equipmentwindow.h +++ b/src/gui/windows/equipmentwindow.h @@ -136,10 +136,10 @@ class EquipmentWindow final : public Window, ImageSet *mImageSet; Being *mBeing; std::vector mBoxes; - gcn::Color mHighlightColor; - gcn::Color mBorderColor; - gcn::Color mLabelsColor; - gcn::Color mLabelsColor2; + Color mHighlightColor; + Color mBorderColor; + Color mLabelsColor; + Color mLabelsColor2; Image *mSlotBackground; Image *mSlotHighlightedBackground; ImageCollection *mVertexes; diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h index 909b84a41..55948f834 100644 --- a/src/gui/windows/outfitwindow.h +++ b/src/gui/windows/outfitwindow.h @@ -115,8 +115,8 @@ class OutfitWindow final : public Window, int mItems[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT]; int mAwayOutfit; - gcn::Color mBorderColor; - gcn::Color mBackgroundColor; + Color mBorderColor; + Color mBackgroundColor; unsigned char mItemColors[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT]; bool mItemClicked; bool mItemsUnequip[OUTFITS_COUNT]; diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index a06257b10..cbab4710d 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -236,8 +236,8 @@ public: return 2 * getFont()->getHeight() + 5; } private: - gcn::Color mNotSupportedColor; - gcn::Color mNotSupportedColor2; + Color mNotSupportedColor; + Color mNotSupportedColor2; }; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 9cc952ec6..2e9a8be10 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -231,8 +231,8 @@ class SkillListBox final : public ListBox private: SkillModel *mModel; TextPopup *mPopup; - gcn::Color mTextColor; - gcn::Color mTextColor2; + Color mTextColor; + Color mTextColor2; int mTextPadding; int mSpacing; bool mSkillClicked; diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index 83ec97521..c446fa177 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -414,7 +414,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, Particle *Particle::addTextSplashEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline) { @@ -438,7 +438,7 @@ Particle *Particle::addTextSplashEffect(const std::string &text, Particle *Particle::addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline) { diff --git a/src/particle/particle.h b/src/particle/particle.h index f69770513..491232b17 100644 --- a/src/particle/particle.h +++ b/src/particle/particle.h @@ -30,16 +30,11 @@ #include #include +class Color; +class Font; class Particle; class ParticleEmitter; -namespace gcn -{ - class Color; -} - -class Font; - typedef std::list Particles; typedef Particles::iterator ParticleIterator; typedef Particles::const_iterator ParticleConstIterator; @@ -136,7 +131,7 @@ class Particle : public Actor */ Particle *addTextSplashEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline = false); @@ -145,7 +140,7 @@ class Particle : public Actor */ Particle *addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline = false); diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp index 1ac6ac6c2..41ea683f6 100644 --- a/src/particle/textparticle.cpp +++ b/src/particle/textparticle.cpp @@ -26,13 +26,13 @@ #include "gui/theme.h" -#include "gui/base/color.hpp" +#include "gui/color.h" #include "gui/font.h" #include "debug.h" TextParticle::TextParticle(const std::string &text, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline) : Particle(), mText(text), @@ -74,7 +74,7 @@ void TextParticle::draw(Graphics *const graphics, / static_cast(mFadeIn); } - gcn::Color color = *mColor; + Color color = *mColor; color.a = static_cast(alpha); graphics->setColor(color); diff --git a/src/particle/textparticle.h b/src/particle/textparticle.h index 0d598508d..ec586c3a9 100644 --- a/src/particle/textparticle.h +++ b/src/particle/textparticle.h @@ -32,7 +32,7 @@ class TextParticle final : public Particle * Constructor. */ TextParticle(const std::string &text, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline = false); A_DELETE_COPY(TextParticle) @@ -54,7 +54,7 @@ class TextParticle final : public Particle private: std::string mText; /**< Text of the particle. */ Font *mTextFont; /**< Font used for drawing the text. */ - const gcn::Color *mColor; /**< Color used for drawing the text. */ + const Color *mColor; /**< Color used for drawing the text. */ int mTextWidth; bool mOutline; /**< Make the text better readable */ }; diff --git a/src/render/graphics.h b/src/render/graphics.h index 53eb4af12..2356d2d31 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -70,10 +70,11 @@ #include "sdlshared.h" +#include "gui/color.h" + #include "render/renderers.h" #include "gui/base/cliprectangle.hpp" -#include "gui/base/color.hpp" #ifdef USE_SDL2 #include @@ -331,27 +332,27 @@ class Graphics virtual void initArrays() { } - virtual void setColor(const gcn::Color &color) + virtual void setColor(const Color &color) { mColor = color; mColor2 = color; mAlpha = (color.a != 255); } - void setColor2(const gcn::Color &color) + void setColor2(const Color &color) { mColor2 = color; } - void setColorAll(const gcn::Color &color, const gcn::Color &color2) + void setColorAll(const Color &color, const Color &color2) { mColor = color; mColor2 = color2; mAlpha = (color.a != 255); } - const gcn::Color &getColor() const + const Color &getColor() const { return mColor; } - const gcn::Color &getColor2() const + const Color &getColor2() const { return mColor2; } #ifdef DEBUG_DRAW_CALLS @@ -534,8 +535,8 @@ class Graphics int mStartFreeMem; bool mSync; int mScale; - gcn::Color mColor; - gcn::Color mColor2; + Color mColor; + Color mColor2; }; extern Graphics *mainGraphics; diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h index f665f743b..0b9cd83e2 100644 --- a/src/render/mobileopenglgraphics.h +++ b/src/render/mobileopenglgraphics.h @@ -127,7 +127,7 @@ class MobileOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; GLuint mImageCached; float mFloatColor; int mMaxVertices; diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h index 882ff5ed8..214954e3c 100644 --- a/src/render/normalopenglgraphics.h +++ b/src/render/normalopenglgraphics.h @@ -143,7 +143,7 @@ class NormalOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; GLuint mImageCached; float mFloatColor; int mMaxVertices; diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h index cbab0614d..ee2a5d189 100644 --- a/src/render/nullopenglgraphics.h +++ b/src/render/nullopenglgraphics.h @@ -130,7 +130,7 @@ class NullOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; float mFloatColor; int mMaxVertices; bool mColorAlpha; diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp index 89f8e63a9..99bf8e82a 100644 --- a/src/render/openglgraphicsdef.hpp +++ b/src/render/openglgraphicsdef.hpp @@ -92,14 +92,14 @@ void popClipArea() override final; - void setColor(const gcn::Color &color) override final + void setColor(const Color &color) override final { mColor = color; mColor2 = color; mColorAlpha = (color.a != 255); } - void setColorAll(const gcn::Color &color, const gcn::Color &color2) + void setColorAll(const Color &color, const Color &color2) { mColor = color; mColor2 = color2; diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h index 28d61b59a..fbb156c6c 100644 --- a/src/render/safeopenglgraphics.h +++ b/src/render/safeopenglgraphics.h @@ -90,7 +90,7 @@ class SafeOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; float mFloatColor; bool mColorAlpha; FBOInfo mFbo; diff --git a/src/text.cpp b/src/text.cpp index dfc127598..27d794d33 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -39,7 +39,7 @@ ImageRect Text::mBubble; Text::Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, const bool isSpeech, + const Color *const color, const bool isSpeech, Font *const font) : mFont(font ? font : (gui ? gui->getFont() : nullptr)), mX(x), @@ -112,7 +112,7 @@ Text::~Text() } } -void Text::setColor(const gcn::Color *const color) +void Text::setColor(const Color *const color) { mColor = color; } @@ -152,7 +152,7 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff) FlashText::FlashText(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, Font *const font) : + const Color *const color, Font *const font) : Text(text, x, y, alignment, color, false, font), mTime(0) { diff --git a/src/text.h b/src/text.h index cade9db18..497792091 100644 --- a/src/text.h +++ b/src/text.h @@ -26,7 +26,7 @@ #include "render/graphics.h" -#include "gui/base/color.hpp" +#include "gui/color.h" #include "localconsts.h" @@ -42,7 +42,7 @@ class Text */ Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, const bool isSpeech = false, + const Color *const color, const bool isSpeech = false, Font *const font = nullptr); A_DELETE_COPY(Text) @@ -52,7 +52,7 @@ class Text */ virtual ~Text(); - void setColor(const gcn::Color *const color); + void setColor(const Color *const color); int getWidth() const A_WARN_UNUSED { return mWidth; } @@ -80,8 +80,8 @@ class Text int mXOffset; /**< The offset of mX from the desired x. */ static int mInstances; /**< Instances of text. */ std::string mText; /**< The text to display. */ - const gcn::Color *mColor; /**< The color of the text. */ - const gcn::Color mOutlineColor; + const Color *mColor; /**< The color of the text. */ + const Color mOutlineColor; bool mIsSpeech; /**< Is this text a speech bubble? */ protected: @@ -93,7 +93,7 @@ class FlashText final : public Text public: FlashText(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, + const Color *const color, Font *const font = nullptr); A_DELETE_COPY(FlashText) diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h index a01858831..282b90afb 100644 --- a/src/utils/sdlpixel.h +++ b/src/utils/sdlpixel.h @@ -64,8 +64,9 @@ #ifndef UTILS_SDLPIXEL_H #define UTILS_SDLPIXEL_H +#include "gui/color.h" + #include "SDL.h" -#include "gui/base/color.hpp" /** * Puts a pixel on an SDL_Surface. @@ -75,7 +76,7 @@ * @param color the color the pixel should be in. */ inline void SDLputPixel(SDL_Surface* surface, int x, int y, - const gcn::Color& color) + const Color& color) { if (!surface) return; @@ -175,7 +176,7 @@ inline unsigned short SDLAlpha16(const unsigned short src, * @param color the color the pixel should be in. */ inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, - const gcn::Color& color) + const Color& color) { const int bpp = surface->format->BytesPerPixel; -- cgit v1.2.3-60-g2f50