File indexing completed on 2024-04-28 04:04:38

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 KSIRKSKINEDITORSKINSPRITESDATA_H
0024 #define KSIRKSKINEDITORSKINSPRITESDATA_H
0025 
0026 #include <QPoint>
0027 #include <QString>
0028 #include <QStringList>
0029 #include <QMap>
0030 
0031 namespace KsirkSkinEditor
0032 {
0033 /**
0034  * This class holds named values related to the current skin. It is a singleton
0035  * to be easily accessible from any game object.
0036  * @author Gael de Chalendar (aka Kleag)
0037  */
0038 class SkinSpritesData
0039 {
0040 public:
0041 
0042   /**
0043    * Initializes the sprites data by clearing its internal storage. Should be 
0044    * used each time a new skin is loaded
0045    */
0046   void init();
0047   
0048   /**
0049    * return the sole instance of this singleton class as const 
0050    */
0051   static const SkinSpritesData& single();
0052 
0053   /**
0054    * return the sole instance of this singleton class as changeable. Used only
0055    * at the time of skin loading for initialization purpose
0056    */
0057   static SkinSpritesData& changeable();
0058 
0059   /**
0060    * Gets the skin name
0061    */
0062   const QString& skin() const;
0063   
0064   /**
0065    * Sets the skin name
0066    */
0067   void skin(const QString& newSkin);
0068   
0069 
0070   /**
0071    * Gets the integer data named @ref name
0072    * @param name the name of the integer data to retrieve
0073    * @return the value of the integer data whose name is given
0074    */
0075   int intData(const QString& name) const;
0076 
0077   /**
0078    * Gets the string data named @ref name
0079    * @param name the name of the string data to retrieve
0080    * @return the value of the string data whose name is given
0081    */
0082   const QString& strData(const QString& name) const;
0083       
0084   /**
0085    * Sets the string data named @ref name with the value @ref data
0086    * @param name the name of the string data to initialize
0087    * @param data the value of the string data to initialize
0088    */
0089   void strData(const QString& name, const QString& data);
0090 
0091   /**
0092    * Sets the integer data named @ref name with the value @ref data
0093    * @param name the name of the integer data to initialize
0094    * @param data the value of the integer data to initialize
0095    */
0096   void intData(const QString& name, int data);
0097         
0098 private:
0099   SkinSpritesData();
0100     
0101   SkinSpritesData(const SkinSpritesData& /*ga*/) {};
0102 
0103   virtual ~SkinSpritesData();
0104 
0105   static SkinSpritesData* m_singleton ;
0106   
0107   QString m_skin;
0108   
0109   QMap<QString, int> m_intDatas;
0110   QMap<QString, QString> m_strDatas;
0111 };
0112 
0113 }
0114 
0115 #endif