/*************************************************************************** * Copyright (C) 2005 by Tavarez Arnaud Bakoula * * tbakoula@yahoo.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef KMASTERMIND_H #define KMASTERMIND_H #ifdef HAVE_CONFIG_H #include #endif #include // for inheritance // KDE headers #include #include #include #include #include #include #include #include #include #include "utilities.h" class KToggleAction; class KActionCollection; class Combinaison; class Notification; class DataDlg; class ModeDlg; class LevelDlg; class AppearanceDlg; class BoardWidget; /** * @short Application Main Window * @author Tavarez Arnaud Bakoula * @version 1.1 */ class KMasterMind : public KMainWindow { Q_OBJECT public: /** * Default Constructor */ KMasterMind(); /** * Default Destructor */ virtual ~KMasterMind(); /*! Sets the game mode */ void setMode( uint md ) { mode = static_cast( md ); } /*! Sets the game level */ void setLevel( uint lvl ) { level = static_cast( lvl ); } /*! Sets the number of pieces used */ void setNbPions( uint nb ) { nb_pions = nb; } /*! Sets the number of tries to find the solution */ void setNbTries( uint nb ) { nb_tries = nb; } private slots: void slotFileNew(); void slotFileQuit(); void slotFileScore(); void slotOptionsData(); void slotOptionsMode(); void slotOptionsLevel(); void slotOptionsAppearance(); void slotHelpPlay(); void slotSuggest(); void slotOptionsShowToolbar(); void slotOptionsShowStatusbar(); void recordSolution(); void recordNotification(); void submitCombinaison(); protected: void closeEvent( QCloseEvent* e ); /** * This function is called when it is time for the app to save its * properties for session management purposes. */ void saveProperties(KConfig *); /** * This function is called when this app is restored. The KConfig * object points to the session management config file that was saved * with @ref saveProperties */ void readProperties(KConfig *); private: void initialize(); void loadSettings(); void saveSettings(); void loadGame(); void resetAll(); void initParams(); void generateHidden(); void changeDataSize( int sz ); void prepareStandardMode(); void prepareHumanMode(); void prepareCpuMode(); void prepareFirstTry(); void prepareNextTry(); void prepareNotification(); void updateNotification(); /* set and unset methods */ // -- user interface void setupActions(); void setupMenuBar(); void setupToolBar(); void setupStatusBar(); void setupDialogs(); void setupDefaults(); void setupBoard(); void setupDatas(); bool checkComb(); void computeScore(); void revealHidden(); void showVictory(); void showDefeat(); bool isItFinished(); /* Interface Members */ private: KMenuBar* MenuBar; /* Dialogs */ DataDlg *dataDlg; ModeDlg *modeDlg; LevelDlg *levelDlg; AppearanceDlg *appearanceDlg; KStatusBarLabel* lblLevel; KStatusBarLabel* lblPions; KStatusBarLabel* lblTries; KStatusBarLabel* lblSuggest; /* Actions */ KAction* fileNew; KAction* fileScore; KAction* fileQuit; KAction* optionsAppearance; KAction* optionsLevel; KAction* optionsMode; KAction* optionsData; KAction* submitAction; KAction* recordAction; KAction* suggestAction; KToggleAction *m_toolbarAction; KToggleAction *m_statusbarAction; KActionCollection *m_actions; /* datas */ private: Mode mode; Level level; int nb_pions; int nb_tries; int nb_colors; uint tries_ctr; uint absent_ctr; uint placed_ctr; uint misplaced_ctr; uint suggestion; uint max_suggestion; bool playing; Combinaison *hidden_cmb; Combinaison *propos_cmb; Notification *notify_ntf; QString appKey; QString site_bg; QString tick_bg; Score theScores[3][10]; BoardWidget* theBoard; }; #endif // KMASTERMIND_H