GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/playerbox.h Lines: 3 3 100.0 %
Date: 2017-11-29 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2004-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2017  The ManaPlus Developers
6
 *
7
 *  This file is part of The ManaPlus Client.
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#ifndef GUI_WIDGETS_PLAYERBOX_H
24
#define GUI_WIDGETS_PLAYERBOX_H
25
26
#include "gui/widgets/widget.h"
27
28
#include "listeners/mouselistener.h"
29
30
#include "resources/imagerect.h"
31
32
#include "localconsts.h"
33
34
class Being;
35
class Skin;
36
37
/**
38
 * A box showing a player character.
39
 *
40
 * \ingroup GUI
41
 */
42
class PlayerBox final : public Widget,
43
                        public MouseListener
44
{
45
    public:
46
        /**
47
         * Constructor. Takes the initial player character that this box should
48
         * display, which defaults to <code>NULL</code>.
49
         */
50
        PlayerBox(Widget2 *const widget,
51
                  Being *const being,
52
                  const std::string &skin = "",
53
                  const std::string &selectedSkin = "");
54
55
        explicit PlayerBox(Widget2 *const widget,
56
                           const std::string &skin = "",
57
                           const std::string &selectedSkin = "");
58
59
        A_DELETE_COPY(PlayerBox)
60
61
        /**
62
         * Destructor.
63
         */
64
        ~PlayerBox();
65
66
        void init(std::string name, std::string selectedName);
67
68
        /**
69
         * Sets a new player character to be displayed by this box. Setting the
70
         * player to <code>NULL</code> causes the box not to draw any
71
         * character.
72
         */
73
        void setPlayer(Being *being)
74
2
        { mBeing = being; }
75
76
        /**
77
         * Draws the scroll area.
78
         */
79
        void draw(Graphics *const graphics) override final A_NONNULL(2);
80
81
        void safeDraw(Graphics *const graphics) override final A_NONNULL(2);
82
83
        /**
84
         * Draws the background and border of the scroll area.
85
         */
86
        void drawFrame(Graphics *const graphics) override final A_NONNULL(2);
87
88
        void safeDrawFrame(Graphics *const graphics) override final
89
                           A_NONNULL(2);
90
91
        Being *getBeing() A_WARN_UNUSED
92
2
        { return mBeing; }
93
94
        void setSelected(bool b)
95
8
        { mSelected = b; }
96
97
        void mouseReleased(MouseEvent& event) override final;
98
99
    private:
100
        Being *mBeing;
101
        float mAlpha;
102
        ImageRect mBackground;
103
        ImageRect mSelectedBackground;
104
        Skin *mSkin;
105
        Skin *mSelectedSkin;
106
        int mOffsetX;
107
        int mOffsetY;
108
        bool mDrawBackground;
109
        bool mSelected;
110
};
111
112
#endif  // GUI_WIDGETS_PLAYERBOX_H