File indexing completed on 2021-12-21 12:50:21

0001 /*
0002  *  ksokoban - a Sokoban game by KDE
0003  *  Copyright (C) 1998,1999  Anders Widell  <d95-awi@nada.kth.se>
0004  *
0005  *  This program is free software; you can redistribute it and/or modify
0006  *  it under the terms of the GNU General Public License as published by
0007  *  the Free Software Foundation; either version 2 of the License, or
0008  *  (at your option) any later version.
0009  *
0010  *  This program is distributed in the hope that it will be useful,
0011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  *  GNU General Public License for more details.
0014  *
0015  *  You should have received a copy of the GNU General Public License
0016  *  along with this program; if not, write to the Free Software
0017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0018  */
0019 
0020 #ifndef LEVELCOLLECTION_H
0021 #define LEVELCOLLECTION_H
0022 
0023 #include <QString>
0024 #include <QByteArray>
0025 #include <QVector>
0026 
0027 class Map;
0028 
0029 class LevelCollection {
0030 public:
0031   LevelCollection(const char *_def, int _len, const QString &_name, int _id=-1);
0032   LevelCollection(const QString &_path, const QString &_name, int _id=-1);
0033   ~LevelCollection();
0034 
0035   const QString &name() const { return name_; }
0036   int id() const { return id_; }
0037   int level() const { return level_; }
0038   void level(int _level);
0039   void levelCompleted();
0040   int completedLevels() const { return completedLevels_; }
0041   int noOfLevels() const { return noOfLevels_; }
0042   bool loadLevel(Map *_map);
0043 
0044 protected:
0045   void indexTextCollection();
0046   void loadPrefs();
0047 
0048 
0049 private:
0050   void addLevel(const char* _level);
0051   void addData(const char* _data, unsigned _len);
0052   void addSeparator();
0053 
0054   QVector<const char*> index_;
0055   QByteArray    data_;
0056   //int    dataLen_;
0057 
0058   int      level_;
0059   int      completedLevels_;
0060   int      noOfLevels_;
0061   QString  name_;
0062   QString  path_;
0063   int      id_;
0064 };
0065 
0066 #endif  /* LEVELCOLLECTION_H */