File indexing completed on 2024-05-05 08:08:30

0001 /***************************************************************************
0002                           skinSpritesData.h  -  description
0003                              -------------------
0004     begin                : 2005
0005     copyright            : (C) 2005-2007 by Gael de Chalendar (aka kleag)
0006     email                : kleag@free.fr
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either either version 2
0014    of the License, or (at your option) any later version.of the License, or     *
0015  *   (at your option) any later version.                                   *
0016  *                                                                         *
0017  *   You should have received a copy of the GNU General Public License
0018  *   along with this program; if not, write to the Free Software
0019  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0020  *   02110-1301, USA
0021  ***************************************************************************/
0022 
0023 #ifndef KSIRK_SPRITES_SKINSPRITESDATA_H
0024 #define KSIRK_SPRITES_SKINSPRITESDATA_H
0025 
0026 #include <QPoint>
0027 #include <QString>
0028 #include <QStringList>
0029 #include <QMap>
0030 
0031 namespace Ksirk {
0032 namespace Sprites {
0033 
0034 /**
0035  * This class holds named values related to the current skin. It is a singleton
0036  * to be easily accessible from any game object.
0037  * @author Gael de Chalendar (aka Kleag)
0038  */
0039 class SkinSpritesData
0040 {
0041 public:
0042 
0043   /**
0044    * Initializes the sprites data by clearing its internal storage. Should be 
0045    * used each time a new skin is loaded
0046    */
0047   void init();
0048   
0049   /**
0050    * return the sole instance of this singleton class as const 
0051    */
0052   static const SkinSpritesData& single();
0053 
0054   /**
0055    * return the sole instance of this singleton class as changeable. Used only
0056    * at the time of skin loading for initialization purpose
0057    */
0058   static SkinSpritesData& changeable();
0059 
0060   /**
0061    * Gets the skin name
0062    */
0063   const QString& skin() const;
0064   
0065   /**
0066    * Sets the skin name
0067    */
0068   void skin(const QString& newSkin);
0069   
0070 
0071   /**
0072    * Gets the integer data named @ref name
0073    * @param name the name of the integer data to retrieve
0074    * @return the value of the integer data whose name is given
0075    */
0076   int intData(const QString& name) const;
0077 
0078   /**
0079    * Gets the string data named @ref name
0080    * @param name the name of the string data to retrieve
0081    * @return the value of the string data whose name is given
0082    */
0083   const QString& strData(const QString& name) const;
0084       
0085   /**
0086    * Sets the string data named @ref name with the value @ref data
0087    * @param name the name of the string data to initialize
0088    * @param data the value of the string data to initialize
0089    */
0090   void strData(const QString& name, const QString& data);
0091 
0092   /**
0093    * Sets the integer data named @ref name with the value @ref data
0094    * @param name the name of the integer data to initialize
0095    * @param data the value of the integer data to initialize
0096    */
0097   void intData(const QString& name, int data);
0098         
0099 private:
0100   SkinSpritesData();
0101     
0102   SkinSpritesData(const SkinSpritesData& /*ga*/) {};
0103 
0104   virtual ~SkinSpritesData();
0105 
0106   static SkinSpritesData* m_singleton ;
0107   
0108   QString m_skin;
0109   
0110   QMap<QString, int> m_intDatas;
0111   QMap<QString, QString> m_strDatas;
0112 };
0113 
0114 } // closing namespace Sprites
0115 } // closing namespace Ksirk
0116 
0117 #endif // KSIRK_SPRITES_SKINSPRITESDATA_H