1 /*
2     Copyright (C) 2002-2005, Jason Katz-Brown <jasonkb@mit.edu>
3     Copyright 2010 Stefan Majewsky <majewsky@gmx.net>
4 
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19 
20 #ifndef KOLF_H
21 #define KOLF_H
22 
23 #include <KXmlGuiWindow>
24 
25 #include "game.h"
26 #include "itemfactory.h"
27 #include <QUrl>
28 class QGridLayout;
29 class QAction;
30 class KSelectAction;
31 class KToggleAction;
32 
33 class Editor;
34 class ScoreBoard;
35 
36 class KolfWindow : public KXmlGuiWindow
37 {
38 	Q_OBJECT
39 
40 public:
41 	KolfWindow();
42 	~KolfWindow() override;
43 
44 	void openUrl(const QUrl &url);
45 
46 public Q_SLOTS:
47 	void closeGame();
48 	void updateModified(bool);
49 
50 protected:
51 	bool queryClose() override;
52 
53 protected Q_SLOTS:
54 	void startNewGame();
55 	void loadGame();
56 	void tutorial();
57 	void newGame();
58 	void save();
59 	void saveAs();
60 	void saveGame();
61 	void saveGameAs();
62 	void newPlayersTurn(Player *);
63 	void gameOver();
64 	void editingStarted();
65 	void editingEnded();
66 	void checkEditing();
setHoleFocus()67 	void setHoleFocus() { game->setFocus(); }
68 	void inPlayStart();
69 	void inPlayEnd();
70 	void maxStrokesReached(const QString &);
71 	void updateHoleMenu(int);
72 	void titleChanged(const QString &);
73 	void newStatusText(const QString &);
74 	void showInfoChanged(bool);
75 	void useMouseChanged(bool);
76 	void useAdvancedPuttingChanged(bool);
77 	void showGuideLineChanged(bool);
78 	void soundChanged(bool);
79 	void showHighScores();
80 	void enableAllMessages();
81 	void createSpacer();
82 
emptySlot()83 	void emptySlot() {}
84 
85 	void setCurrentHole(int);
86 
87 private:
88 	QWidget *dummy;
89 	KolfGame *game;
90 	Editor *editor;
91 	KolfGame *spacer;
92 	void setupActions();
93 	QString filename;
94 	PlayerList players;
95 	PlayerList spacerPlayers;
96 	QGridLayout *layout;
97 	ScoreBoard *scoreboard;
98 	KToggleAction *editingAction;
99 	QAction *newHoleAction;
100 	QAction *resetHoleAction;
101 	QAction *undoShotAction;
102 	//QAction *replayShotAction;
103 	QAction *clearHoleAction;
104 	QAction *tutorialAction;
105 	QAction *newAction;
106 	QAction *endAction;
107 	QAction *saveAction;
108 	QAction *saveAsAction;
109 	QAction *saveGameAction;
110 	QAction *saveGameAsAction;
111 	QAction *loadGameAction;
112 	QAction *aboutAction;
113 	KSelectAction *holeAction;
114 	QAction *highScoreAction;
115 	QAction *nextAction;
116 	QAction *prevAction;
117 	QAction *firstAction;
118 	QAction *lastAction;
119 	QAction *randAction;
120 	KToggleAction *showInfoAction;
121 	KToggleAction *useMouseAction;
122 	KToggleAction *useAdvancedPuttingAction;
123 	KToggleAction *showGuideLineAction;
124 	KToggleAction *soundAction;
125 	void setHoleMovementEnabled(bool);
126 	void setHoleOtherEnabled(bool);
127 	inline void setEditingEnabled(bool);
128 	bool competition;
129 
130 	Kolf::ItemFactory m_itemFactory;
131 
132 	QString loadedGame;
133 
134 	bool isTutorial;
135 	bool courseModified;
136 	QString title;
137 	QString tempStatusBarText;
138 };
139 
140 struct HighScore
141 {
HighScoreHighScore142 	HighScore() {}
HighScoreHighScore143 	HighScore(const QString &name, int score) { this->name = name; this->score = score; }
144 	QString name;
145 	int score;
146 };
147 typedef QList<HighScore> HighScoreList;
148 
149 #endif
150