GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/shortcut/emoteshortcut.h Lines: 0 5 0.0 %
Date: 2017-11-29 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2009  Aethyra Development Team
4
 *  Copyright (C) 2011-2017  The ManaPlus Developers
5
 *
6
 *  This file is part of The ManaPlus Client.
7
 *
8
 *  This program is free software; you can redistribute it and/or modify
9
 *  it under the terms of the GNU General Public License as published by
10
 *  the Free Software Foundation; either version 2 of the License, or
11
 *  any later version.
12
 *
13
 *  This program is distributed in the hope that it will be useful,
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 *  GNU General Public License for more details.
17
 *
18
 *  You should have received a copy of the GNU General Public License
19
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
#ifndef GUI_SHORTCUT_EMOTESHORTCUT_H
23
#define GUI_SHORTCUT_EMOTESHORTCUT_H
24
25
#include "const/emoteshortcut.h"
26
27
#include "utils/cast.h"
28
29
#include "localconsts.h"
30
31
/**
32
 * The class which keeps track of the emote shortcuts.
33
 */
34
class EmoteShortcut final
35
{
36
    public:
37
        /**
38
         * Constructor.
39
         */
40
        EmoteShortcut();
41
42
        A_DELETE_COPY(EmoteShortcut)
43
44
        /**
45
         * Destructor.
46
         */
47
        ~EmoteShortcut();
48
49
        /**
50
         * Load the configuration information.
51
         */
52
        void load();
53
54
        /**
55
         * Returns the shortcut Emote ID specified by the index.
56
         *
57
         * @param index Index of the shortcut Emote.
58
         */
59
        unsigned char getEmote(const size_t index) const A_WARN_UNUSED
60
        { return mEmotes[index]; }
61
62
        /**
63
         * Returns the amount of shortcut Emotes.
64
         */
65
        static unsigned int getEmoteCount() A_WARN_UNUSED
66
        { return SHORTCUT_EMOTES; }
67
68
        /**
69
         * Returns the emote ID that is currently selected.
70
         */
71
        unsigned char getEmoteSelected() const noexcept2 A_WARN_UNUSED
72
        { return mEmoteSelected; }
73
74
        /**
75
         * Adds the selected emote ID to the emotes specified by the index.
76
         *
77
         * @param index Index of the emotes.
78
         */
79
        void setEmote(const size_t index)
80
        { mEmotes[index] = mEmoteSelected; }
81
82
        /**
83
         * Adds a emoticon to the emotes store specified by the index.
84
         *
85
         * @param index Index of the emote.
86
         * @param emoteId ID of the emote.
87
         */
88
        void setEmotes(const size_t index,
89
                       const unsigned char emoteId)
90
        { mEmotes[index] = emoteId; }
91
92
        /**
93
         * Set the Emote that is selected.
94
         *
95
         * @param emoteId The ID of the emote that is to be assigned.
96
         */
97
        void setEmoteSelected(const unsigned char emoteId)
98
        { mEmoteSelected = emoteId; }
99
100
        /**
101
         * A flag to check if the Emote is selected.
102
         */
103
        bool isEmoteSelected() const noexcept2 A_WARN_UNUSED
104
        { return mEmoteSelected != 0u; }
105
106
        /**
107
         * Remove a Emote from the shortcut.
108
         */
109
        void removeEmote(const size_t index)
110
        { if (index < CAST_SIZE(SHORTCUT_EMOTES)) mEmotes[index] = 0; }
111
112
        /**
113
         * Try to use the Emote specified by the index.
114
         *
115
         * @param index Index of the emote shortcut.
116
         */
117
        void useEmote(const size_t index) const;
118
119
        void useEmotePlayer(const size_t index) const;
120
121
    private:
122
        /**
123
         * Save the configuration information.
124
         */
125
        void save() const;
126
127
        unsigned char mEmotes[SHORTCUT_EMOTES];  // The emote stored.
128
        unsigned char mEmoteSelected;            // The emote held by cursor.
129
};
130
131
extern EmoteShortcut *emoteShortcut;
132
133
#endif  // GUI_SHORTCUT_EMOTESHORTCUT_H