~neon/kolf/master

983 by Stefan Majewsky
Replace the Object classes by the new ItemFactory.
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
78 by Jason Katz-Brown
KOLF HAS PLUGINS! yay :-)
20
#ifndef GAME_H
21
#define GAME_H
1 by Jason Katz-Brown
here's kolf, read the TODO
22
980 by Stefan Majewsky
Clean include statements and forward declarations.
23
#include <kolflib_export.h>
24
#include "ball.h"
25
991 by Stefan Majewsky
First use of Tagaro::Scene, Board, and SpriteObjectItem in KolfGame class.
26
#include "tagaro/scene.h"
27
1067 by Stefan Majewsky
More CanvasItem cleanup.
28
#include <QGraphicsView>
980 by Stefan Majewsky
Clean include statements and forward declarations.
29
#include <KConfigGroup>
1218 by Yuri Chornoivan
Reenable sounds in Kolf
30
#include <KgSound>
78 by Jason Katz-Brown
KOLF HAS PLUGINS! yay :-)
31
1 by Jason Katz-Brown
here's kolf, read the TODO
32
class KolfGame;
989 by Stefan Majewsky
Very very straight port of Kolf to KGameRenderer.
33
class KGameRenderer;
1 by Jason Katz-Brown
here's kolf, read the TODO
34
1018 by Stefan Majewsky
Adapt Kolf::Overlay and Kolf::Shape from playground/games/kolf2/base.
35
namespace Kolf
36
{
1066 by Stefan Majewsky
Fix cleanup of Windmill, and remove some obsolete includes.
37
	class Wall;
1087 by André Wöbbeking
-pedantic
38
}
991 by Stefan Majewsky
First use of Tagaro::Scene, Board, and SpriteObjectItem in KolfGame class.
39
namespace Tagaro
40
{
41
	class Board;
42
}
983 by Stefan Majewsky
Replace the Object classes by the new ItemFactory.
43
namespace Kolf
44
{
45
	class ItemFactory;
989 by Stefan Majewsky
Very very straight port of Kolf to KGameRenderer.
46
	KGameRenderer* renderer();
993 by Stefan Majewsky
Move all items on the scene into the Tagaro::Board.
47
	Tagaro::Board* findBoard(QGraphicsItem* item); //TODO: temporary HACK
1021 by Stefan Majewsky
Create a Box2D world, and attach Box2D bodies to all CanvasItems.
48
	b2World* world(); //TODO: temporary HACK (should be inside KolfGame, but various places outside the game need to create CanvasItems)
983 by Stefan Majewsky
Replace the Object classes by the new ItemFactory.
49
}
611 by Dmitry Suzdalev
Use Phonon::AudioPlayer
50
1 by Jason Katz-Brown
here's kolf, read the TODO
51
enum Direction { D_Left, D_Right, Forwards, Backwards };
194 by Jason Katz-Brown
add ctrl-arrows for fine-tuned rotation
52
enum Amount { Amount_Less, Amount_Normal, Amount_More };
1218 by Yuri Chornoivan
Reenable sounds in Kolf
53
enum class Sound {
54
	BlackHole,
55
	BlackHoleEject,
56
	BlackHolePutIn,
1227 by Yuri Chornoivan
Add bumper sound
57
	Bumper,
1218 by Yuri Chornoivan
Reenable sounds in Kolf
58
	Hit,
59
	Holed,
60
	HoleINone,
61
	Puddle,
62
	Wall,
63
	WooHoo
64
};
1 by Jason Katz-Brown
here's kolf, read the TODO
65
70 by Jason Katz-Brown
undo shot! :-)
66
class BallStateInfo
67
{
68
public:
664 by Paul Broadbent
KConfig ports
69
	void saveState(KConfigGroup *cfgGroup);
70
	void loadState(KConfigGroup *cfgGroup);
70 by Jason Katz-Brown
undo shot! :-)
71
72
	int id;
73
	QPoint spot;
74
	BallState state;
97 by Jason Katz-Brown
good stuff
75
	bool beginningOfHole;
70 by Jason Katz-Brown
undo shot! :-)
76
	int score;
77
};
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
78
class BallStateList : public QList<BallStateInfo>
175 by Jason Katz-Brown
add new Slope Practice course, clean up some code
79
{
80
public:
81
	int hole;
82
	int player;
83
	bool canUndo;
84
	Vector vector;
85
};
70 by Jason Katz-Brown
undo shot! :-)
86
1 by Jason Katz-Brown
here's kolf, read the TODO
87
class Player
88
{
89
public:
1021 by Stefan Majewsky
Create a Box2D world, and attach Box2D bodies to all CanvasItems.
90
	Player() : m_ball(new Ball(0, Kolf::world())) {}
145 by Jason Katz-Brown
make more things const-correct
91
	Ball *ball() const { return m_ball; }
1 by Jason Katz-Brown
here's kolf, read the TODO
92
	void setBall(Ball *ball) { m_ball = ball; }
997 by Stefan Majewsky
Start to remove resizing code.
93
	BallStateInfo stateInfo(int hole) const { BallStateInfo ret; ret.spot = m_ball->pos().toPoint(); ret.state = m_ball->curState(); ret.score = score(hole); ret.beginningOfHole = m_ball->beginningOfHole(); ret.id = m_id; return ret; }
1 by Jason Katz-Brown
here's kolf, read the TODO
94
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
95
	QList<int> scores() const { return m_scores; }
96
	void setScores(const QList<int> &newScores) { m_scores = newScores; }
97
	int score(int hole) const { return m_scores.at(hole - 1); }
145 by Jason Katz-Brown
make more things const-correct
98
	int lastScore() const { return m_scores.last(); }
99
	int firstScore() const { return m_scores.first(); }
1 by Jason Katz-Brown
here's kolf, read the TODO
100
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
101
	void addStrokeToHole(int hole) { (*(m_scores.begin() + (hole -1)))++; }
102
	void setScoreForHole(int score, int hole) { (*(m_scores.begin() + (hole - 1))) = score; }
103
	void subtractStrokeFromHole(int hole) { (*(m_scores.begin() + (hole -1))--); }
104
	void resetScore(int hole) { (*(m_scores.begin() + (hole - 1))) = 0; }
1 by Jason Katz-Brown
here's kolf, read the TODO
105
	void addHole() { m_scores.append(0); }
145 by Jason Katz-Brown
make more things const-correct
106
	unsigned int numHoles() const { return m_scores.count(); }
1 by Jason Katz-Brown
here's kolf, read the TODO
107
145 by Jason Katz-Brown
make more things const-correct
108
	QString name() const { return m_name; }
275 by Jason Katz-Brown
add names next to balls during info showing
109
	void setName(const QString &name) { m_name = name; m_ball->setName(name); }
1 by Jason Katz-Brown
here's kolf, read the TODO
110
111
	void setId(int id) { m_id = id; }
145 by Jason Katz-Brown
make more things const-correct
112
	int id() const { return m_id; }
1 by Jason Katz-Brown
here's kolf, read the TODO
113
114
private:
115
	Ball *m_ball;
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
116
	QList<int> m_scores;
1 by Jason Katz-Brown
here's kolf, read the TODO
117
	QString m_name;
118
	int m_id;
119
};
572 by Stephan Kulow
removed some warnings
120
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
121
typedef QList<Player> PlayerList;
1 by Jason Katz-Brown
here's kolf, read the TODO
122
1052 by Stefan Majewsky
Kill now useless HintedLineItem class.
123
class Putter : public QGraphicsLineItem, public CanvasItem
1 by Jason Katz-Brown
here's kolf, read the TODO
124
{
125
public:
1021 by Stefan Majewsky
Create a Box2D world, and attach Box2D bodies to all CanvasItems.
126
	Putter(QGraphicsItem* parent, b2World* world);
1007 by Stefan Majewsky
Remove obsolete scaling code in Putter, StrokeCircle and KolfGame.
127
537 by Albert Astals Cid
only slope.cpp and newgame.cpp do not compile
128
	void go(Direction, Amount amount = Amount_Normal);
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
129
	void setOrigin(double x, double y);
661 by Paul Broadbent
fixed some compile time warnings and resized ball movement bugs
130
	double curLen() const { return guideLineLength; }
169 by Jason Katz-Brown
make putter use radians and not degrees
131
	double curAngle() const { return angle; }
132
	int curDeg() const { return rad2deg(angle); }
3 by Jason Katz-Brown
*** empty log message ***
133
	virtual void showInfo();
134
	virtual void hideInfo();
169 by Jason Katz-Brown
make putter use radians and not degrees
135
	void setAngle(double news) { angle = news; finishMe(); }
136
	void setDeg(int news) { angle = deg2rad(news); finishMe(); }
137
	double curMaxAngle() const { return maxAngle; }
1 by Jason Katz-Brown
here's kolf, read the TODO
138
	virtual void setVisible(bool yes);
169 by Jason Katz-Brown
make putter use radians and not degrees
139
	void saveAngle(Ball *ball) { angleMap[ball] = angle; }
140
	void setAngle(Ball *ball);
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
141
	void resetAngles() { angleMap.clear(); setZValue(999999); }
1158.1.31 by Montel Laurent
Use Q_DECLARE_OVERRIDE
142
	void moveBy(double dx, double dy) Q_DECL_OVERRIDE;
72 by Jason Katz-Brown
undo if ball leaves course
143
	void setShowGuideLine(bool yes);
1 by Jason Katz-Brown
here's kolf, read the TODO
144
1158.1.31 by Montel Laurent
Use Q_DECLARE_OVERRIDE
145
	QPointF getPosition() const Q_DECL_OVERRIDE { return QGraphicsItem::pos(); }
1 by Jason Katz-Brown
here's kolf, read the TODO
146
private:
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
147
	QPointF midPoint;
169 by Jason Katz-Brown
make putter use radians and not degrees
148
	double maxAngle;
149
	double angle;
150
	double oneDegree;
151
	QMap<Ball *, double> angleMap;
1007 by Stefan Majewsky
Remove obsolete scaling code in Putter, StrokeCircle and KolfGame.
152
	double guideLineLength, putterWidth;
1 by Jason Katz-Brown
here's kolf, read the TODO
153
	void finishMe();
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
154
	QGraphicsLineItem *guideLine;
72 by Jason Katz-Brown
undo if ball leaves course
155
	bool m_showGuideLine;
1 by Jason Katz-Brown
here's kolf, read the TODO
156
};
157
158
class HoleInfo;
19 by Jason Katz-Brown
things I can think of: game knows if it's been modified, prompts if you wanna save it. no crashes, more optimized floaters (but not enough), person with best score on last hole goes first.. other things, forget, must go to bed. cheers!
159
class HoleConfig : public Config
1 by Jason Katz-Brown
here's kolf, read the TODO
160
{
161
	Q_OBJECT
162
163
public:
164
	HoleConfig(HoleInfo *holeInfo, QWidget *);
165
166
private slots:
167
	void authorChanged(const QString &);
168
	void parChanged(int);
169
	void maxStrokesChanged(int);
170
	void nameChanged(const QString &);
30 by Jason Katz-Brown
elliptical slopes!! and other things!
171
	void borderWallsChanged(bool);
1 by Jason Katz-Brown
here's kolf, read the TODO
172
173
private:
174
	HoleInfo *holeInfo;
175
};
176
class HoleInfo : public CanvasItem
177
{
178
public:
1204 by Yuri Chornoivan
Fix minor EBN issues and typos
179
	explicit HoleInfo(b2World* world) : CanvasItem(world) { setSimulationType(CanvasItem::NoSimulation); m_lowestMaxStrokes = 4; }
2 by Jason Katz-Brown
180
	virtual ~HoleInfo() {}
1 by Jason Katz-Brown
here's kolf, read the TODO
181
	void setPar(int newpar) { m_par = newpar; }
145 by Jason Katz-Brown
make more things const-correct
182
	int par() const { return m_par; }
1 by Jason Katz-Brown
here's kolf, read the TODO
183
	void setMaxStrokes(int newMaxStrokes) { m_maxStrokes = newMaxStrokes; }
145 by Jason Katz-Brown
make more things const-correct
184
	int lowestMaxStrokes() const { return m_lowestMaxStrokes; }
185
	int maxStrokes() const { return m_maxStrokes; }
186
	bool hasMaxStrokes() const { return m_maxStrokes != m_lowestMaxStrokes; }
1235 by Laurent Montel
Fix clazy warning
187
	void setAuthor(const QString &newauthor) { m_author = newauthor; }
145 by Jason Katz-Brown
make more things const-correct
188
	QString author() const { return m_author; }
288 by Jason Katz-Brown
read untranslated entries in the editor so I don't always save my courses with Japanese names
189
1235 by Laurent Montel
Fix clazy warning
190
	void setName(const QString &newname) { m_name = newname; }
191
	void setUntranslatedName(const QString &newname) { m_untranslatedName = newname; }
145 by Jason Katz-Brown
make more things const-correct
192
	QString name() const { return m_name; }
288 by Jason Katz-Brown
read untranslated entries in the editor so I don't always save my courses with Japanese names
193
	QString untranslatedName() const { return m_untranslatedName; }
194
1158.1.31 by Montel Laurent
Use Q_DECLARE_OVERRIDE
195
	Config *config(QWidget *parent) Q_DECL_OVERRIDE { return new HoleConfig(this, parent); }
30 by Jason Katz-Brown
elliptical slopes!! and other things!
196
	void borderWallsChanged(bool yes);
145 by Jason Katz-Brown
make more things const-correct
197
	bool borderWalls() const { return m_borderWalls; }
1 by Jason Katz-Brown
here's kolf, read the TODO
198
1158.1.31 by Montel Laurent
Use Q_DECLARE_OVERRIDE
199
	QPointF getPosition() const Q_DECL_OVERRIDE { return QPointF(); }
1 by Jason Katz-Brown
here's kolf, read the TODO
200
private:
201
	QString m_author;
202
	QString m_name;
288 by Jason Katz-Brown
read untranslated entries in the editor so I don't always save my courses with Japanese names
203
	QString m_untranslatedName;
30 by Jason Katz-Brown
elliptical slopes!! and other things!
204
	bool m_borderWalls;
1 by Jason Katz-Brown
here's kolf, read the TODO
205
	int m_par;
206
	int m_maxStrokes;
103 by Jason Katz-Brown
scoreboard par changing bugfix
207
	int m_lowestMaxStrokes;
1 by Jason Katz-Brown
here's kolf, read the TODO
208
};
209
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
210
class StrokeCircle : public QGraphicsItem
49 by Jason Katz-Brown
clean up indentation, add niklas to author list
211
{
212
public:
1204 by Yuri Chornoivan
Fix minor EBN issues and typos
213
	explicit StrokeCircle(QGraphicsItem *parent);
49 by Jason Katz-Brown
clean up indentation, add niklas to author list
214
43 by Jason Katz-Brown
AWESOME new putting style by Niklas Knutsson ...
215
	void setValue(double v);
383 by David Faure
Next one on the "proper use of KEditToolbar" checklist.
216
	double value();
43 by Jason Katz-Brown
AWESOME new putting style by Niklas Knutsson ...
217
	void setMaxValue(double m);
1009 by Stefan Majewsky
Change signature of CanvasItem::setSize from (double, double) to (QSizeF).
218
	void setSize(const QSizeF& size);
700 by Paul Broadbent
fixed the advanced putter and added advanced putter resize
219
	void setThickness(double t);
220
	double thickness() const;
221
	double width() const;
222
	double height() const;
1158.1.31 by Montel Laurent
Use Q_DECLARE_OVERRIDE
223
	void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget *) Q_DECL_OVERRIDE;
224
	QRectF boundingRect() const Q_DECL_OVERRIDE;
225
	bool collidesWithItem(const QGraphicsItem*, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const Q_DECL_OVERRIDE;
49 by Jason Katz-Brown
clean up indentation, add niklas to author list
226
227
private:
43 by Jason Katz-Brown
AWESOME new putting style by Niklas Knutsson ...
228
	double dvalue, dmax;
700 by Paul Broadbent
fixed the advanced putter and added advanced putter resize
229
	double ithickness, iwidth, iheight;
43 by Jason Katz-Brown
AWESOME new putting style by Niklas Knutsson ...
230
};
231
694 by Christian Ehrlicher
libksirtet compile now fine on win32
232
struct KOLFLIB_EXPORT CourseInfo
59 by Jason Katz-Brown
a spiffy newgame dialog
233
{
241 by Jason Katz-Brown
message fixes, other stuff
234
	CourseInfo(const QString &_name, const QString &_untranslatedName, const QString &_author, unsigned int _holes, unsigned int _par) { name = _name; untranslatedName = _untranslatedName, author = _author; holes = _holes; par = _par; }
286 by Jason Katz-Brown
make kolf a lean, mean, command-line-argument handling machine. Will open courses AND saved games from the command line. The mimetypes also specify kolf in an exec line.
235
	CourseInfo();
241 by Jason Katz-Brown
message fixes, other stuff
236
59 by Jason Katz-Brown
a spiffy newgame dialog
237
	QString name;
241 by Jason Katz-Brown
message fixes, other stuff
238
	QString untranslatedName;
59 by Jason Katz-Brown
a spiffy newgame dialog
239
	QString author;
240
	unsigned int holes;
241
	unsigned int par;
242
};
243
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
244
class KOLFLIB_EXPORT KolfGame : public QGraphicsView
1 by Jason Katz-Brown
here's kolf, read the TODO
245
{
246
	Q_OBJECT
247
248
public:
983 by Stefan Majewsky
Replace the Object classes by the new ItemFactory.
249
	KolfGame(const Kolf::ItemFactory& factory, PlayerList *players, const QString &filename, QWidget *parent=0);
1 by Jason Katz-Brown
here's kolf, read the TODO
250
	~KolfGame();
251
	void setFilename(const QString &filename);
27 by Jason Katz-Brown
fix 2 critical bugs: 1) don't crash when editing and mouse moves 2) make holes not disappear off of floaters (and floater saving is all better now thank heaven :)
252
	QString curFilename() const { return filename; }
1 by Jason Katz-Brown
here's kolf, read the TODO
253
	void emitLargestHole() { emit largestHole(highestHole); }
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
254
	QGraphicsScene *scene() const { return course; }
1041 by Stefan Majewsky
Fix the annoying crash in KolfGame's dtor.
255
	void removeItem(QGraphicsItem *item) { m_topLevelQItems.removeAll(item); }
26 by Jason Katz-Brown
kick-ass. 1) mouse support. 2) wallpoints fixed FOR GOOD. 3) random hole. 4) better save stuff still, prompt on close/quit.
256
	bool askSave(bool);
27 by Jason Katz-Brown
fix 2 critical bugs: 1) don't crash when editing and mouse moves 2) make holes not disappear off of floaters (and floater saving is all better now thank heaven :)
257
	bool isEditing() const { return editing; }
269 by Jason Katz-Brown
a few nice new things, no sound for first squeel on demo, squish scoreboard, make scoreboard highlight correctly
258
	int currentHole() { return curHole; }
175 by Jason Katz-Brown
add new Slope Practice course, clean up some code
259
	void setStrict(bool yes) { strict = yes; }
169 by Jason Katz-Brown
make putter use radians and not degrees
260
	// returns true when you shouldn't do anything
261
	bool isPaused() const { return paused; }
145 by Jason Katz-Brown
make more things const-correct
262
	Ball *curBall() const { return (*curPlayer).ball(); }
28 by Jason Katz-Brown
various stuff.. fixes mostly
263
	void updateMouse();
59 by Jason Katz-Brown
a spiffy newgame dialog
264
	void ballMoved();
30 by Jason Katz-Brown
elliptical slopes!! and other things!
265
	void setBorderWalls(bool);
97 by Jason Katz-Brown
good stuff
266
	void setInPlay(bool yes) { inPlay = yes; }
172 by Jason Katz-Brown
most number of black hole trips per shot is 10, change hard course and add two cool holes
267
	bool isInPlay() { return inPlay; }
275 by Jason Katz-Brown
add names next to balls during info showing
268
	bool isInfoShowing() { return m_showInfo; }
100 by Jason Katz-Brown
make the game end if there's no competition, make it work better when putter is showing and ball goes into hole or puddle
269
	void stoppedBall();
145 by Jason Katz-Brown
make more things const-correct
270
	QString courseName() const { return holeInfo.name(); }
177 by Jason Katz-Brown
add spiffy intro infinite-loop hole
271
	void hidePutter() { putter->setVisible(false); }
272
	void ignoreEvents(bool ignore) { m_ignoreEvents = ignore; }
1 by Jason Katz-Brown
here's kolf, read the TODO
273
1071 by Stefan Majewsky
Fix overlay activation and deactivation.
274
	void setSelectedItem(CanvasItem* citem);
1046 by Stefan Majewsky
Ensure that only one overlay is active at any time.
275
664 by Paul Broadbent
KConfig ports
276
	static void scoresFromSaved(KConfig*, PlayerList &players);
59 by Jason Katz-Brown
a spiffy newgame dialog
277
	static void courseInfo(CourseInfo &info, const QString &filename);
1218 by Yuri Chornoivan
Reenable sounds in Kolf
278
	void playSound(Sound soundType);
59 by Jason Katz-Brown
a spiffy newgame dialog
279
1 by Jason Katz-Brown
here's kolf, read the TODO
280
public slots:
281
	void pause();
282
	void unPause();
283
	void save();
284
	void toggleEditMode();
301 by Jason Katz-Brown
fix up, reenable charles's code, bugs.. etc
285
	void setModified(bool mod = true);
983 by Stefan Majewsky
Replace the Object classes by the new ItemFactory.
286
	void addNewObject(const QString& identifier);
1 by Jason Katz-Brown
here's kolf, read the TODO
287
	void addNewHole();
288
	void switchHole(int);
289
	void switchHole(const QString &);
290
	void nextHole();
291
	void prevHole();
292
	void firstHole();
293
	void lastHole();
26 by Jason Katz-Brown
kick-ass. 1) mouse support. 2) wallpoints fixed FOR GOOD. 3) random hole. 4) better save stuff still, prompt on close/quit.
294
	void randHole();
1 by Jason Katz-Brown
here's kolf, read the TODO
295
	void showInfoDlg(bool = false);
296
	void resetHole();
297
	void clearHole();
201 by Jason Katz-Brown
good fixes, black holes accept harder ball speeds, and most important new Show Info toggle action
298
	void setShowInfo(bool yes);
299
	void toggleShowInfo();
300
	void updateShowInfo();
26 by Jason Katz-Brown
kick-ass. 1) mouse support. 2) wallpoints fixed FOR GOOD. 3) random hole. 4) better save stuff still, prompt on close/quit.
301
	void setUseMouse(bool yes) { m_useMouse = yes; }
43 by Jason Katz-Brown
AWESOME new putting style by Niklas Knutsson ...
302
	void setUseAdvancedPutting(bool yes);
72 by Jason Katz-Brown
undo if ball leaves course
303
	void setShowGuideLine(bool yes);
77 by Jason Katz-Brown
toggle sound on/off
304
	void setSound(bool yes);
70 by Jason Katz-Brown
undo shot! :-)
305
	void undoShot();
94 by Jason Katz-Brown
fix lotsa bugs in states of ball, convert more stuff to vectors
306
	void timeout();
222 by Jason Katz-Brown
change to KConfig (from KSimpleConfig) so translations are kept through saves
307
	void saveScores(KConfig *);
150 by Jason Katz-Brown
308
	void startFirstHole(int hole);
192 by Jason Katz-Brown
fix bad typo
309
	void sayWhosGoing();
94 by Jason Katz-Brown
fix lotsa bugs in states of ball, convert more stuff to vectors
310
1 by Jason Katz-Brown
here's kolf, read the TODO
311
signals:
312
	void holesDone();
313
	void newHole(int);
72 by Jason Katz-Brown
undo if ball leaves course
314
	void parChanged(int, int);
73 by Jason Katz-Brown
make puddles place your ball on the right spot again
315
	void titleChanged(const QString &);
1 by Jason Katz-Brown
here's kolf, read the TODO
316
	void largestHole(int);
317
	void scoreChanged(int, int, int);
318
	void newPlayersTurn(Player *);
319
	void newSelectedItem(CanvasItem *);
19 by Jason Katz-Brown
things I can think of: game knows if it's been modified, prompts if you wanna save it. no crashes, more optimized floaters (but not enough), person with best score on last hole goes first.. other things, forget, must go to bed. cheers!
320
	void checkEditing();
1 by Jason Katz-Brown
here's kolf, read the TODO
321
	void editingStarted();
322
	void editingEnded();
323
	void inPlayStart();
324
	void inPlayEnd();
91 by Jason Katz-Brown
add real ball bouncing physics.
325
	void maxStrokesReached(const QString &);
259 by Neil Stevens
Now the newHoleAction shows the current hole
326
	void currentHole(int);
301 by Jason Katz-Brown
fix up, reenable charles's code, bugs.. etc
327
	void modifiedChanged(bool);
322 by Jason Katz-Brown
fix showinfo state bugs
328
	void newStatusText(const QString &);
1 by Jason Katz-Brown
here's kolf, read the TODO
329
330
private slots:
331
	void shotDone();
332
	void holeDone();
192 by Jason Katz-Brown
fix bad typo
333
	void startNextHole();
1 by Jason Katz-Brown
here's kolf, read the TODO
334
	void fastTimeout();
335
	void putterTimeout();
336
	void autoSaveTimeout();
337
328 by Jason Katz-Brown
fix max strokes stuff
338
	void emitMax();
339
1 by Jason Katz-Brown
here's kolf, read the TODO
340
protected:
1158.1.31 by Montel Laurent
Use Q_DECLARE_OVERRIDE
341
	void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
342
	void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
343
	void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
344
	void mouseDoubleClickEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
220 by Jason Katz-Brown
borders
345
227 by Jason Katz-Brown
make scrollview mouse presses work right
346
	void handleMousePressEvent(QMouseEvent *e);
383 by David Faure
Next one on the "proper use of KEditToolbar" checklist.
347
	void handleMouseDoubleClickEvent(QMouseEvent *e);
227 by Jason Katz-Brown
make scrollview mouse presses work right
348
	void handleMouseMoveEvent(QMouseEvent *e);
349
	void handleMouseReleaseEvent(QMouseEvent *e);
1158.1.31 by Montel Laurent
Use Q_DECLARE_OVERRIDE
350
	void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
351
	void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
1 by Jason Katz-Brown
here's kolf, read the TODO
352
986 by Stefan Majewsky
Compactify APIDOX comments to improve readability.
353
	//resizes view to make sure it is square and calls resizeAllItems
1158.1.31 by Montel Laurent
Use Q_DECLARE_OVERRIDE
354
	void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
660 by Paul Broadbent
added resizing and started fixing edit mode
355
220 by Jason Katz-Brown
borders
356
	QPoint viewportToViewport(const QPoint &p);
357
1 by Jason Katz-Brown
here's kolf, read the TODO
358
private:
991 by Stefan Majewsky
First use of Tagaro::Scene, Board, and SpriteObjectItem in KolfGame class.
359
	Tagaro::Scene *course;
360
	Tagaro::Board *courseBoard;
1 by Jason Katz-Brown
here's kolf, read the TODO
361
	Putter *putter;
362
	PlayerList *players;
363
	PlayerList::Iterator curPlayer;
364
	Ball *whiteBall;
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
365
	StrokeCircle *strokeCircle; 
1 by Jason Katz-Brown
here's kolf, read the TODO
366
367
	QTimer *timer;
368
	QTimer *autoSaveTimer;
369
	QTimer *fastTimer;
370
	QTimer *putterTimer;
166 by Jason Katz-Brown
get rid of one timer (consolidate into other)
371
	bool regAdv;
1 by Jason Katz-Brown
here's kolf, read the TODO
372
983 by Stefan Majewsky
Replace the Object classes by the new ItemFactory.
373
	const Kolf::ItemFactory& m_factory;
1070 by Stefan Majewsky
Remove obsolete code from KolfGame for selecting and moving items in the editor.
374
	QList<QGraphicsItem*> m_topLevelQItems; //includes balls, but not putter
1041 by Stefan Majewsky
Fix the annoying crash in KolfGame's dtor.
375
	QList<QGraphicsItem*> m_moveableQItems;
376
1047 by Stefan Majewsky
Refactor Wall class: Drop WallPoint class, introduce WallOverlay.
377
	QList<Kolf::Wall *> borderWalls;
1 by Jason Katz-Brown
here's kolf, read the TODO
378
379
	int timerMsec;
380
	int autoSaveMsec;
381
	int fastTimerMsec;
382
	int putterTimerMsec;
383
384
	void puttPress();
385
	void puttRelease();
386
	bool inPlay;
387
	bool putting;
388
	bool stroking;
43 by Jason Katz-Brown
AWESOME new putting style by Niklas Knutsson ...
389
	bool finishStroking;
1 by Jason Katz-Brown
here's kolf, read the TODO
390
	double strength;
391
	double maxStrength;
392
	int puttCount;
43 by Jason Katz-Brown
AWESOME new putting style by Niklas Knutsson ...
393
	bool puttReverse;
1 by Jason Katz-Brown
here's kolf, read the TODO
394
395
	int curHole;
396
	int highestHole;
397
	int curPar;
398
399
	int wallWidth;
400
	int height;
401
	int width;
220 by Jason Katz-Brown
borders
402
	int margin;
1 by Jason Katz-Brown
here's kolf, read the TODO
403
404
	int advancePeriod;
405
205 by Jason Katz-Brown
stuff
406
	int lastDelId;
407
1 by Jason Katz-Brown
here's kolf, read the TODO
408
	bool paused;
409
410
	QString filename;
28 by Jason Katz-Brown
various stuff.. fixes mostly
411
	bool recalcHighestHole;
1 by Jason Katz-Brown
here's kolf, read the TODO
412
	void openFile();
413
175 by Jason Katz-Brown
add new Slope Practice course, clean up some code
414
	bool strict;
415
1 by Jason Katz-Brown
here's kolf, read the TODO
416
	bool editing;
633 by Paul Broadbent
Ported to Qt4: almost all Qt 3 compatibility classes removed and now using QGraphicsView
417
	QGraphicsItem *selectedItem;
822 by Mauricio Piacentini
Fix garbage in intro screen, put new Kolf SVG banner.
418
	
419
	//For intro banner
991 by Stefan Majewsky
First use of Tagaro::Scene, Board, and SpriteObjectItem in KolfGame class.
420
	Tagaro::SpriteObjectItem *banner;
1 by Jason Katz-Brown
here's kolf, read the TODO
421
1218 by Yuri Chornoivan
Reenable sounds in Kolf
422
	KgSound m_soundBlackHole;
423
	KgSound m_soundBlackHoleEject;
424
	KgSound m_soundBlackHolePutIn;
1227 by Yuri Chornoivan
Add bumper sound
425
	KgSound m_soundBumper;
1218 by Yuri Chornoivan
Reenable sounds in Kolf
426
	KgSound m_soundHit;
427
	KgSound m_soundHoled;
428
	KgSound m_soundHoleINone;
429
	KgSound m_soundPuddle;
430
	KgSound m_soundWall;
431
	KgSound m_soundWooHoo;
77 by Jason Katz-Brown
toggle sound on/off
432
	bool m_sound;
1 by Jason Katz-Brown
here's kolf, read the TODO
433
177 by Jason Katz-Brown
add spiffy intro infinite-loop hole
434
	bool m_ignoreEvents;
435
1 by Jason Katz-Brown
here's kolf, read the TODO
436
	HoleInfo holeInfo;
1016 by Stefan Majewsky
Kill StateDB class and CanvasItem::{load,save}State.
437
	QMap<QString, QPointF> savedState;
70 by Jason Katz-Brown
undo shot! :-)
438
439
	BallStateList ballStateList;
440
	void loadStateList();
441
	void recreateStateList();
175 by Jason Katz-Brown
add new Slope Practice course, clean up some code
442
	void addHoleInfo(BallStateList &list);
1 by Jason Katz-Brown
here's kolf, read the TODO
443
100 by Jason Katz-Brown
make the game end if there's no competition, make it work better when putter is showing and ball goes into hole or puddle
444
	bool dontAddStroke;
445
1 by Jason Katz-Brown
here's kolf, read the TODO
446
	bool addingNewHole;
447
	int scoreboardHoles;
448
	inline void resetHoleScores();
449
201 by Jason Katz-Brown
good fixes, black holes accept harder ball speeds, and most important new Show Info toggle action
450
	bool m_showInfo;
451
1 by Jason Katz-Brown
here's kolf, read the TODO
452
	bool infoShown;
453
222 by Jason Katz-Brown
change to KConfig (from KSimpleConfig) so translations are kept through saves
454
	KConfig *cfg;
709 by Stephan Kulow
don't leak _that_ bad (CID 3637)
455
	KConfigGroup cfgGroup;
5 by Jason Katz-Brown
456
702 by Matt Williams
Make EBN happy with plenty of references-to-const fixes.
457
	inline void addBorderWall(const QPoint &start, const QPoint &end);
175 by Jason Katz-Brown
add new Slope Practice course, clean up some code
458
	void shotStart();
459
	void startBall(const Vector &vector);
19 by Jason Katz-Brown
things I can think of: game knows if it's been modified, prompts if you wanna save it. no crashes, more optimized floaters (but not enough), person with best score on last hole goes first.. other things, forget, must go to bed. cheers!
460
461
	bool modified;
24 by Jason Katz-Brown
462
463
	inline bool allPlayersDone();
26 by Jason Katz-Brown
kick-ass. 1) mouse support. 2) wallpoints fixed FOR GOOD. 3) random hole. 4) better save stuff still, prompt on close/quit.
464
465
	bool m_useMouse;
43 by Jason Katz-Brown
AWESOME new putting style by Niklas Knutsson ...
466
	bool m_useAdvancedPutting;
91 by Jason Katz-Brown
add real ball bouncing physics.
467
328 by Jason Katz-Brown
fix max strokes stuff
468
	QString playerWhoMaxed;
1 by Jason Katz-Brown
here's kolf, read the TODO
469
};
470
471
#endif