summaryrefslogtreecommitdiffstats
path: root/knetwalk/src/mainwindow.h
blob: 11118e0e08ec4564bc75b29bb1b4b7bd53c6f93b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/***************************************************************************
 *   Copyright (C) 2004, 2005 Andi Peredri                                 *
 *   [email protected]                                                          *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License version 2        *
 *   as published by the Free Software Foundation (see COPYING)            *
 *                                                                         *
 *   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.                          *
 ***************************************************************************/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <kapplication.h>
#include <kmainwindow.h>

class Cell;
class TQAction;
class TQSound;
class TQLCDNumber;
class KSelectAction;

class MainWindow : public KMainWindow
{
	Q_OBJECT
  TQ_OBJECT
	public:
		MainWindow(TQWidget *parent=0, const char* name=0, WFlags fl=0);
	protected:
		virtual void closeEvent(TQCloseEvent*);
	private:
		//enum Skill { Novice, Normal, Expert, Master };
		enum BoardSize
		{
			NoviceBoardSize = 5,
			NormalBoardSize = 7,
			ExpertBoardSize = 9,
			MasterBoardSize = 9
		};
		enum
		{
			NumHighscores   = 10,
			MinimumNumCells = 20
		};
		typedef TQValueList<Cell*> CellList;
	public slots:
		void  slotNewGame();
		void  newGame(int);
		
		void  lClicked(int index);
		void  rClicked(int index);
		void  mClicked(int index);
		
		void  showHighscores();
		void  configureHighscores();
		void  configureNotifications();
		
	private:
		Cell* uCell(Cell* cell) const;
		Cell* dCell(Cell* cell) const;
		Cell* lCell(Cell* cell) const;
		Cell* rCell(Cell* cell) const;
		bool  isGameOver();
		bool  startBrowser(const TQString& url);
		bool  updateConnections();
		void  blink(int index);
		void  rotate(int index, bool toleft);
		void  addRandomDir(CellList& list);
		void  dialog(const TQString& caption, const TQString& text);
	private:
		bool        wrapped;
		Cell*       root;
		Cell*       board[MasterBoardSize * MasterBoardSize];
		
		TQSound*     clicksound;
		TQSound*     connectsound;
		TQSound*     startsound;
		TQSound*     turnsound;
		TQSound*     winsound;
		
		TQString     username;
		TQString     soundpath;
		TQAction*    soundaction;
		TQStringList highscores;
		TQLCDNumber* lcd;
		TQPopupMenu* gamemenu;
		TQPopupMenu* skillmenu;

		int m_clickcount;
		KSelectAction* m_levels;
};

#endif // MAINWINDOW_H