summaryrefslogtreecommitdiff
path: root/src/resources/hairdb.h
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-01-18 19:20:34 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-02-02 15:31:41 +0100
commitf5de9ae444f1bca1f6ba6969214e9a8cacb15f68 (patch)
treef9b9c699c52d279cdc4d93b09f48dd3b24403f5b /src/resources/hairdb.h
parent7cc504d993fa948ae2e10848993f4552b2d6daaa (diff)
downloadmana-f5de9ae444f1bca1f6ba6969214e9a8cacb15f68.tar.gz
mana-f5de9ae444f1bca1f6ba6969214e9a8cacb15f68.tar.bz2
mana-f5de9ae444f1bca1f6ba6969214e9a8cacb15f68.tar.xz
mana-f5de9ae444f1bca1f6ba6969214e9a8cacb15f68.zip
Fix to the hair colors and styles handling.
- I made the charCreatedialog handle a possible max permitted color Id and a minimum hair style id for tA. - Added a foundation to later load the styles and colors from the same file, to handle the Mana-issue #224 for manaserv. - Support for non-contiguous hair color and style ids has also been added. - I also replaced the < and > arrow signs with images. Reviewed-by: Ben Longbons, Thorbjørn Lindeijer
Diffstat (limited to 'src/resources/hairdb.h')
-rw-r--r--src/resources/hairdb.h66
1 files changed, 59 insertions, 7 deletions
diff --git a/src/resources/hairdb.h b/src/resources/hairdb.h
index c29dbb83..700bd8b7 100644
--- a/src/resources/hairdb.h
+++ b/src/resources/hairdb.h
@@ -1,5 +1,5 @@
/*
- * Color database
+ * Hair database
* Copyright (C) 2008 Aethyra Development Team
* Copyright (C) 2009-2012 The Mana Developers
*
@@ -22,16 +22,26 @@
#ifndef HAIR_MANAGER_H
#define HAIR_MANAGER_H
+#include "iteminfo.h"
+
#include <map>
#include <string>
/**
* Hair information database.
*/
-namespace HairDB
+class HairDB
{
+ public:
+ HairDB():
+ mLoaded(false)
+ {}
+
+ ~HairDB()
+ { unload(); }
+
/**
- * Loads the color data from <code>colors.xml</code>.
+ * Loads the color data from <code>hair.xml</code>.
*/
void load();
@@ -40,13 +50,55 @@ namespace HairDB
*/
void unload();
- std::string &get(int id);
+ const std::string &getHairColor(int id);
+
+ /**
+ * Returns the available hair style ids
+ * @param maxId the max permited id. If not 0, the hairDb won't
+ * return ids > to the parameter.
+ */
+ std::vector<int> getHairStyleIds(int maxId = 0) const;
+
+ /**
+ * Returns the available hair color ids
+ * @param maxId the max permited id. If not 0, the hairDb won't
+ * return ids > to the parameter.
+ */
+ std::vector<int> getHairColorIds(int maxId = 0) const;
+
+ /**
+ * Add a hair style to the database.
+ * @see ItemDB for the itemInfo.
+ */
+ void addHairStyle(int id);
+
+ private:
+ /**
+ * Load the hair colors, contained in a <colors> node.
+ */
+ void loadHairColorsNode(xmlNodePtr colorsNode);
- int size();
+ /**
+ * Load the hair styles, contained in a <styles> node.
+ * Used only by Manaserv. TMW-Athena is considering hairstyles as items.
+ * @see ItemDB
+ */
+ void loadHairStylesNode(xmlNodePtr stylesNode);
- // Hair Color DB
+ // Hair colors Db
typedef std::map<int, std::string> Colors;
typedef Colors::iterator ColorIterator;
-}
+ typedef Colors::const_iterator ColorConstIterator;
+ Colors mHairColors;
+
+ typedef std::set<int> HairStyles;
+ typedef HairStyles::iterator HairStylesIterator;
+ typedef HairStyles::const_iterator HairStylesConstIterator;
+ HairStyles mHairStyles;
+
+ bool mLoaded;
+};
+
+extern HairDB hairDB;
#endif