Mana
Loading...
Searching...
No Matches
hairdb.h
Go to the documentation of this file.
1/*
2 * Hair database
3 * Copyright (C) 2008 Aethyra Development Team
4 * Copyright (C) 2009-2013 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 <map>
25#include <set>
26#include <string>
27#include <vector>
28#include "utils/xml.h"
29
33class HairDB
34{
35public:
36 HairDB() = default;
37
39 { unload(); }
40
41 void init();
42
43 void readHairColorNode(XML::Node node, const std::string &filename);
44
45 void checkStatus();
46
50 void unload();
51
52 const std::string &getHairColor(int id) const;
53
59 std::vector<int> getHairStyleIds(int maxId) const;
60
66 std::vector<int> getHairColorIds(int minId, int maxId) const;
67
72 void addHairStyle(int id);
73
74private:
78 void loadHairColorsNode(XML::Node colorsNode);
79
85 void loadHairStylesNode(XML::Node stylesNode);
86
87 // Hair colors Db
88 std::map<int, std::string> mHairColors;
89 std::set<int> mHairStyles;
90
91 bool mLoaded = false;
92};
93
94extern HairDB hairDB;
Hair information database.
Definition hairdb.h:34
void loadHairStylesNode(XML::Node stylesNode)
Load the hair styles, contained in a <styles> node.
std::vector< int > getHairStyleIds(int maxId) const
Returns the available hair style ids.
Definition hairdb.cpp:94
void checkStatus()
Definition hairdb.cpp:48
~HairDB()
Definition hairdb.h:38
HairDB()=default
void init()
Definition hairdb.cpp:29
const std::string & getHairColor(int id) const
Definition hairdb.cpp:79
std::set< int > mHairStyles
Definition hairdb.h:89
std::map< int, std::string > mHairColors
Definition hairdb.h:88
void addHairStyle(int id)
Add a hair style to the database.
Definition hairdb.cpp:66
void readHairColorNode(XML::Node node, const std::string &filename)
Definition hairdb.cpp:38
void unload()
Clear the color data.
Definition hairdb.cpp:53
std::vector< int > getHairColorIds(int minId, int maxId) const
Returns the available hair color ids.
Definition hairdb.cpp:107
bool mLoaded
Definition hairdb.h:91
void loadHairColorsNode(XML::Node colorsNode)
Load the hair colors, contained in a <colors> node.
HairDB hairDB
Hair styles and colors info database.
Definition client.cpp:107