ManaPlus
emoteshortcut.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2009 Aethyra Development Team
4  * Copyright (C) 2011-2019 The ManaPlus Developers
5  * Copyright (C) 2019-2021 Andrei Karas
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_SHORTCUT_EMOTESHORTCUT_H
24 #define GUI_SHORTCUT_EMOTESHORTCUT_H
25 
26 #include "const/emoteshortcut.h"
27 
28 #include "utils/cast.h"
29 
30 #include "localconsts.h"
31 
36 {
37  public:
41  EmoteShortcut();
42 
44 
45 
49 
53  void load();
54 
60  unsigned char getEmote(const size_t index) const A_WARN_UNUSED
61  { return mEmotes[index]; }
62 
66  static unsigned int getEmoteCount() A_WARN_UNUSED
67  { return SHORTCUT_EMOTES; }
68 
73  { return mEmoteSelected; }
74 
80  void setEmote(const size_t index)
81  { mEmotes[index] = mEmoteSelected; }
82 
89  void setEmotes(const size_t index,
90  const unsigned char emoteId)
91  { mEmotes[index] = emoteId; }
92 
98  void setEmoteSelected(const unsigned char emoteId)
99  { mEmoteSelected = emoteId; }
100 
105  { return mEmoteSelected != 0U; }
106 
110  void removeEmote(const size_t index)
111  { if (index < CAST_SIZE(SHORTCUT_EMOTES)) mEmotes[index] = 0; }
112 
118  void useEmote(const size_t index) const;
119 
120  void useEmotePlayer(const size_t index) const;
121 
122  private:
126  void save() const;
127 
128  unsigned char mEmotes[SHORTCUT_EMOTES]; // The emote stored.
129  unsigned char mEmoteSelected; // The emote held by cursor.
130 };
131 
133 
134 #endif // GUI_SHORTCUT_EMOTESHORTCUT_H
#define CAST_SIZE
Definition: cast.h:34
void removeEmote(const size_t index)
void setEmoteSelected(const unsigned char emoteId)
Definition: emoteshortcut.h:98
static unsigned int getEmoteCount()
Definition: emoteshortcut.h:66
bool isEmoteSelected() const
void setEmotes(const size_t index, const unsigned char emoteId)
Definition: emoteshortcut.h:89
unsigned char mEmotes[SHORTCUT_EMOTES]
void useEmotePlayer(const size_t index) const
unsigned char getEmoteSelected() const
Definition: emoteshortcut.h:72
unsigned char getEmote(const size_t index) const
Definition: emoteshortcut.h:60
void setEmote(const size_t index)
Definition: emoteshortcut.h:80
void save() const
unsigned char mEmoteSelected
void useEmote(const size_t index) const
static const int SHORTCUT_EMOTES
Definition: emoteshortcut.h:25
EmoteShortcut * emoteShortcut
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DELETE_COPY(func)
Definition: localconsts.h:53