File indexing completed on 2024-04-21 04:02:35

0001 /*
0002     SPDX-FileCopyrightText: 2012 Christian Krippendorf <Coding@Christian-Krippendorf.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef DEMOANIMATION_H
0008 #define DEMOANIMATION_H
0009 
0010 // Qt
0011 #include <QTimer>
0012 
0013 // KMahjongg
0014 #include "kmtypes.h"
0015 
0016 // Forward declarations...
0017 class GameData;
0018 
0019 /**
0020  * A class for a demo animation with the help of selection.
0021  *
0022  * @author Christian Krippendorf */
0023 class DemoAnimation : public QTimer
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     explicit DemoAnimation(QObject * parent = nullptr);
0029     ~DemoAnimation() override;
0030 
0031     /**
0032      * Set the animation speed in milliseconds.
0033      *
0034      * @param animationSpeed The animation speed in milliseconds. */
0035     void setAnimationSpeed(int animationSpeed);
0036 
0037     /**
0038      * Get the animation speed in milliseconds.
0039      *
0040      * @return Get the animation speed in milliseconds. */
0041     int getAnimationSpeed() const;
0042 
0043     /**
0044      * Override of QTimer.
0045      *
0046      * @param gameData The data object to handle with for this animation process. */
0047     void start(GameData * gameData);
0048 
0049     /**
0050      * Override of QTimer. */
0051     void stop();
0052 
0053 public Q_SLOTS:
0054 
0055 Q_SIGNALS:
0056     /**
0057      * Emits when the game is over.
0058      *
0059      * @param won True if computer won the game, else false. */
0060     void gameOver(bool won);
0061 
0062     /**
0063      * Emit to remove the given item. */
0064     void removeItem(POSITION & stItem);
0065 
0066     /**
0067      * Emit to set the selected state of the given item.
0068      *
0069      * @param stItem The position of the item to change the selected state.
0070      * @param selected THe item should be selected on true, else deselected. */
0071     void changeItemSelectedState(POSITION & stItem, bool selected);
0072 
0073 private Q_SLOTS:
0074     void timeoutOccurred();
0075 
0076 private:
0077     int m_step;
0078     int m_animationSpeed;
0079 
0080     POSITION m_stFirst;
0081     POSITION m_stSecond;
0082 
0083     GameData * m_gameData;
0084 };
0085 
0086 #endif // DEMOANIMATION_H