File indexing completed on 2024-11-24 03:43:18

0001 /*******************************************************************
0002  *
0003  * Copyright 2007  Aron Boström <c02ab@efd.lth.se>
0004  *
0005  * Bovo 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, or (at your option)
0008  * any later version.
0009  *
0010  * Bovo 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 Bovo; see the file COPYING.  If not, write to
0017  * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  *
0020  ********************************************************************/
0021 
0022 #ifndef BOVO_MAINWINDOW_H
0023 #define BOVO_MAINWINDOW_H
0024 
0025 #include <QString>
0026 #include <QStringList>
0027 
0028 #include <KXmlGuiWindow>
0029 
0030 #include "common.h"
0031 #include "theme.h"
0032 
0033 class QLabel;
0034 
0035 namespace ai
0036 {
0037 class Ai;
0038 class AiFactory;
0039 }
0040 
0041 namespace bovo
0042 {
0043 class Game;
0044 }
0045 
0046 using namespace bovo;
0047 using namespace ai;
0048 
0049 class KSelectAction;
0050 
0051 namespace gui
0052 {
0053 
0054 class Scene;
0055 class View;
0056 
0057 class MainWindow : public KXmlGuiWindow
0058 {
0059     Q_OBJECT
0060 public:
0061     explicit MainWindow(QWidget *parent = nullptr);
0062     ~MainWindow() override;
0063 
0064 public Q_SLOTS:
0065     void hint();
0066     void slotNewGame();
0067     void slotPlayerTurn();
0068     void slotOposerTurn();
0069     void slotGameOver();
0070     void slotNewDemo();
0071     void slotNewDemoWait();
0072     void slotUndo();
0073     void replay();
0074     void changeSkill();
0075     void changeTheme(int);
0076     void reEnableReplay();
0077     void enableUndo();
0078     void disableUndo();
0079     void setupThemes();
0080     void save() const;
0081     void setAnimation(bool enabled);
0082 
0083 private:
0084     Scene *m_scene;
0085     View *m_view;
0086     Game *m_game;
0087     Theme m_theme;
0088     QList<Theme> m_themes;
0089     int m_wins, m_losses;
0090     void setupActions();
0091     void increaseWins();
0092     void decreaseWins();
0093     void updateWins(const int wins);
0094     void increaseLosses();
0095     void decreaseLosses();
0096     void updateLosses(const int losses);
0097     QAction *m_hintAct;
0098     QAction *m_undoAct;
0099     KSelectAction *m_themeAct;
0100     bool m_computerStarts;
0101     Ai *m_demoAi;
0102     AiFactory *m_aiFactory;
0103     void readConfig();
0104     void saveSettings();
0105     int m_playbackSpeed;
0106     QStringList m_lastGame;
0107     bool m_animate;
0108     bool m_demoMode;
0109     QLabel *m_winsLabel;
0110     QLabel *m_lossesLabel;
0111 };
0112 
0113 } /* namespace gui */
0114 
0115 #endif // BOVO_MAINWINDOW_H