1 /*************************************************************************** 2 skinSpritesData.h - description 3 ------------------- 4 begin : 2005 5 copyright : (C) 2005-2007 by Gael de Chalendar (aka kleag) 6 email : kleag@free.fr 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either either version 2 14 of the License, or (at your option) any later version.of the License, or * 15 * (at your option) any later version. * 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., 51 Franklin Street, Fifth Floor, Boston, MA 20 * 02110-1301, USA 21 ***************************************************************************/ 22 23 #ifndef KSIRK_SPRITES_SKINSPRITESDATA_H 24 #define KSIRK_SPRITES_SKINSPRITESDATA_H 25 26 #include <QPoint> 27 #include <QString> 28 #include <QStringList> 29 #include <QMap> 30 31 namespace Ksirk { 32 namespace Sprites { 33 34 /** 35 * This class holds named values related to the current skin. It is a singleton 36 * to be easily accessible from any game object. 37 * @author Gael de Chalendar (aka Kleag) 38 */ 39 class SkinSpritesData 40 { 41 public: 42 43 /** 44 * Initializes the sprites data by clearing its internal storage. Should be 45 * used each time a new skin is loaded 46 */ 47 void init(); 48 49 /** 50 * return the sole instance of this singleton class as const 51 */ 52 static const SkinSpritesData& single(); 53 54 /** 55 * return the sole instance of this singleton class as changeable. Used only 56 * at the time of skin loading for initialization purpose 57 */ 58 static SkinSpritesData& changeable(); 59 60 /** 61 * Gets the skin name 62 */ 63 const QString& skin() const; 64 65 /** 66 * Sets the skin name 67 */ 68 void skin(const QString& newSkin); 69 70 71 /** 72 * Gets the integer data named @ref name 73 * @param name the name of the integer data to retrieve 74 * @return the value of the integer data whose name is given 75 */ 76 int intData(const QString& name) const; 77 78 /** 79 * Gets the string data named @ref name 80 * @param name the name of the string data to retrieve 81 * @return the value of the string data whose name is given 82 */ 83 const QString& strData(const QString& name) const; 84 85 /** 86 * Sets the string data named @ref name with the value @ref data 87 * @param name the name of the string data to initialize 88 * @param data the value of the string data to initialize 89 */ 90 void strData(const QString& name, const QString& data); 91 92 /** 93 * Sets the integer data named @ref name with the value @ref data 94 * @param name the name of the integer data to initialize 95 * @param data the value of the integer data to initialize 96 */ 97 void intData(const QString& name, int data); 98 99 private: 100 SkinSpritesData(); 101 SkinSpritesData(const SkinSpritesData &)102 SkinSpritesData(const SkinSpritesData& /*ga*/) {}; 103 104 virtual ~SkinSpritesData(); 105 106 static SkinSpritesData* m_singleton ; 107 108 QString m_skin; 109 110 QMap<QString, int> m_intDatas; 111 QMap<QString, QString> m_strDatas; 112 }; 113 114 } // closing namespace Sprites 115 } // closing namespace Ksirk 116 117 #endif // KSIRK_SPRITES_SKINSPRITESDATA_H 118