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

0001 /*
0002  *  ksokoban - a Sokoban game by KDE
0003  *  Copyright (C) 1998  Anders Widell  <awl@hem.passagen.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 HISTORY_H
0021 #define HISTORY_H
0022 
0023 #include <QList>
0024 #include <QString>
0025 
0026 #include "Move.h"
0027 class MoveSequence;
0028 
0029 /**
0030  * Maintains movement history
0031  *
0032  * @short   Maintains game movement history
0033  * @author  Anders Widell <d95-awi@nada.kth.se>
0034  * @version 0.1
0035  * @see     PlayField
0036  */
0037 
0038 class History {
0039 private:
0040   QList<Move*> past_;
0041   QList<Move*> future_;
0042 
0043 protected:
0044 
0045 public:
0046   History();
0047   ~History();
0048   /**
0049    * Add a move to the history. Deletes all currently undone moves.
0050    */
0051   void add(Move *_m);
0052   /**
0053    * Clear the history and delete all Move objects stored in it.
0054    */
0055   void clear();
0056 
0057   void save(QString &_str);
0058   const char *load(LevelMap *map, const char *_str);
0059   bool redo(LevelMap *map);
0060   MoveSequence *deferRedo(LevelMap *map);
0061   bool undo(LevelMap *map);
0062   MoveSequence *deferUndo(LevelMap *map);
0063 };
0064 
0065 #endif  /* HISTORY_H */