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

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  Andrei Karas
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_SHORTCUT_SPELLSHORTCUT_H
24
#define GUI_SHORTCUT_SPELLSHORTCUT_H
25
26
#include "const/spells.h"
27
28
/**
29
 * The class which keeps track of the item shortcuts.
30
 */
31
class SpellShortcut final
32
{
33
    public:
34
        /**
35
         * Constructor.
36
         */
37
        SpellShortcut();
38
39
        A_DELETE_COPY(SpellShortcut)
40
41
        /**
42
         * Destructor.
43
         */
44
        ~SpellShortcut() A_CONST;
45
46
        /**
47
         * Load the configuration information.
48
         */
49
        void load();
50
51
        unsigned int getSpellsCount() const A_CONST A_WARN_UNUSED;
52
53
        /**
54
         * Set the item that is selected.
55
         *
56
         * @param itemId The ID of the item that is to be assigned.
57
         */
58
        void setItemSelected(const int itemId) noexcept2
59
        { mItemSelected = itemId; }
60
61
        /**
62
         * A flag to check if the item is selected.
63
         */
64
        bool isItemSelected() const noexcept2 A_WARN_UNUSED
65
        { return mItemSelected > -1; }
66
67
        /**
68
         * Returns selected shortcut item ID.
69
         */
70
        int getSelectedItem() const noexcept2 A_WARN_UNUSED
71
        { return mItemSelected; }
72
73
        /**
74
         * Returns the shortcut item ID specified by the index.
75
         *
76
         * @param index Index of the shortcut item.
77
         */
78
        int getItem(const size_t index) const
79
        { return mItems[index]; }
80
81
    private:
82
        int mItems[SPELLS_SIZE];
83
        int mItemSelected;              /**< The item held by cursor. */
84
};
85
86
extern SpellShortcut *spellShortcut;
87
88
#endif  // GUI_SHORTCUT_SPELLSHORTCUT_H