Mana
Loading...
Searching...
No Matches
shopitems.h
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana 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#pragma once
23
24#include <guichan/listmodel.hpp>
25
26#include <string>
27#include <vector>
28
29class ShopItem;
30
40class ShopItems : public gcn::ListModel
41{
42 public:
49 ShopItems(bool mergeDuplicates = false);
50
51 ~ShopItems() override;
52
56 void addItem(int id, int amount, int price);
57
67 void addItem(int inventoryIndex, int id, int amount, int price);
68
72 int getNumberOfElements() override;
73
79 std::string getElementAt(int i) override;
80
84 ShopItem *at(int i) const;
85
91 void erase(int i);
92
96 void clear();
97
98 private:
105 ShopItem *findItem(int id);
106
108 std::vector<ShopItem*> mShopItems;
109
112};
Represents an item in a shop inventory.
Definition shopitem.h:33
This class handles the list of items available in a shop.
Definition shopitems.h:41
std::string getElementAt(int i) override
Returns the name of item number i in the shop.
Definition shopitems.cpp:43
bool mMergeDuplicates
Look for duplicate entries on addition.
Definition shopitems.h:111
void addItem(int id, int amount, int price)
Adds an item to the list.
Definition shopitems.cpp:48
ShopItem * at(int i) const
Returns the item number i in the shop.
Definition shopitems.cpp:72
int getNumberOfElements() override
Returns the number of items in the shop.
Definition shopitems.cpp:38
void erase(int i)
Removes an element from the shop.
Definition shopitems.cpp:77
std::vector< ShopItem * > mShopItems
The list of items in the shop.
Definition shopitems.h:108
ShopItem * findItem(int id)
Searches the current items in the shop for the specified id and returns the item if found,...
Definition shopitems.cpp:88
~ShopItems() override
Definition shopitems.cpp:33
void clear()
Clears the list of items in the shop.
Definition shopitems.cpp:82