1
/*
2
 *  The Mana World
3
 *  Copyright (C) 2007  The Mana World Development Team
4
 *
5
 *  This file is part of The Mana World.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 */
21
22
#ifndef ITEMSHORTCUT_H
23
#define ITEMSHORTCUT_H
24
25
#define SHORTCUT_ITEMS 12
26
27
class Item;
28
29
/**
30
 * The class which keeps track of the item shortcuts.
31
 */
32
class ItemShortcut
33
{
34
    public:
35
        /**
36
         * Constructor.
37
         */
38
        ItemShortcut();
39
40
        /**
41
         * Destructor.
42
         */
43
        ~ItemShortcut();
44
45
        /**
46
         * Load the configuration information.
47
         */
48
        void load();
49
50
        /**
51
         * Returns the shortcut item ID specified by the index.
52
         *
53
         * @param index Index of the shortcut item.
54
         */
55
        int getItem(int index) const
56
        { return mItems[index]; }
57
58
        /**
59
         * Returns the amount of shortcut items.
60
         */
61
        int getItemCount() const
62
        { return SHORTCUT_ITEMS; }
63
64
        /**
65
         * Returns the item ID that is currently selected.
66
         */
67
        int getItemSelected() const
68
        { return mItemSelected; }
69
70
        /**
71
         * Adds the selected item ID to the items specified by the index.
72
         *
73
         * @param index Index of the items.
74
         */
75
        void setItem(int index)
76
        { mItems[index] = mItemSelected; }
77
78
        /**
79
         * Adds an item to the items store specified by the index.
80
         *
81
         * @param index Index of the item.
82
         * @param itemId ID of the item.
83
         */
84
        void setItems(int index, int itemId)
85
        { mItems[index] = itemId; }
86
87
        /**
88
         * Set the item that is selected.
89
         *
90
         * @param itemId The ID of the item that is to be assigned.
91
         */
92
        void setItemSelected(int itemId)
93
        { mItemSelected = itemId; }
94
95
        /**
96
         * A flag to check if the item is selected.
97
         */
98
        bool isItemSelected()
99
        { return mItemSelected > -1; }
100
101
        /**
102
         * Remove a item from the shortcut.
103
         */
104
        void removeItem(int index)
105
        { mItems[index] = -1; }
106
107
        /**
108
         * Try to use the item specified by the index.
109
         *
110
         * @param index Index of the item shortcut.
111
         */
112
        void useItem(int index);
113
114
    private:
115
        /**
116
         * Save the configuration information.
117
         */
118
        void save();
119
120
        int mItems[SHORTCUT_ITEMS];     /**< The items stored. */
121
        int mItemSelected;              /**< The item held by cursor. */
122
123
};
124
125
extern ItemShortcut *itemShortcut;
126
127
#endif