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_OBJECTS_H |
21 | #define KOLF_OBJECTS_H |
22 | |
23 | //NOTE: Only refactored stuff goes into this header. |
24 | |
25 | #include "canvasitem.h" |
26 | #include "overlay.h" |
27 | |
28 | namespace Kolf |
29 | { |
30 | class BlackHole; |
31 | class BlackHoleOverlay; |
32 | |
33 | class BlackHole : public EllipticalCanvasItem |
34 | { |
35 | Q_OBJECT |
36 | |
37 | public: |
38 | BlackHole(QGraphicsItem* parent, b2World* world); |
39 | ~BlackHole(); |
40 | //FIXME: strutted moving of exit is broken since refactoring. |
41 | |
42 | virtual QList<QGraphicsItem*> infoItems() const; |
43 | virtual void save(KConfigGroup* cfgGroup); |
44 | virtual void load(KConfigGroup* cfgGroup); |
45 | virtual Config* config(QWidget* parent); |
46 | double minSpeed() const; |
47 | double maxSpeed() const; |
48 | void setMinSpeed(double news); |
49 | void setMaxSpeed(double news); |
50 | |
51 | QPointF exitPos() const; |
52 | void setExitPos(const QPointF& exitPos); |
53 | int curExitDeg() const; |
54 | void setExitDeg(int newdeg); |
55 | Vector exitDirection() const; //for overlay |
56 | |
57 | void updateInfo(); |
58 | |
59 | virtual void moveBy(double dx, double dy); |
60 | |
61 | virtual void shotStarted(); |
62 | virtual bool collision(Ball* ball); |
63 | public Q_SLOTS: |
64 | void eject(Ball* ball, double speed); |
65 | void halfway(); |
66 | protected: |
67 | virtual Kolf::Overlay* createOverlay(); |
68 | private: |
69 | double m_minSpeed, m_maxSpeed; |
70 | int m_runs, m_exitDeg; |
71 | QGraphicsLineItem* m_exitItem; |
72 | ArrowItem* m_directionItem; |
73 | QGraphicsLineItem* m_infoLine; |
74 | }; |
75 | |
76 | class BlackHoleTimer : public QObject |
77 | { |
78 | Q_OBJECT |
79 | public: |
80 | BlackHoleTimer(Ball* ball, double speed, int msec); |
81 | Q_SIGNALS: |
82 | void eject(Ball* ball, double speed); |
83 | void halfway(); |
84 | private Q_SLOTS: |
85 | void emitEject(); |
86 | private: |
87 | double m_speed; |
88 | Ball* m_ball; |
89 | }; |
90 | |
91 | class BlackHoleConfig : public Config |
92 | { |
93 | Q_OBJECT |
94 | public: |
95 | BlackHoleConfig(BlackHole* blackHole, QWidget* parent); |
96 | private Q_SLOTS: |
97 | void degChanged(int); |
98 | void minChanged(double); |
99 | void maxChanged(double); |
100 | private: |
101 | BlackHole* m_blackHole; |
102 | }; |
103 | |
104 | class BlackHoleOverlay : public Kolf::Overlay |
105 | { |
106 | Q_OBJECT |
107 | public: |
108 | BlackHoleOverlay(Kolf::BlackHole* blackHole); |
109 | virtual void update(); |
110 | private Q_SLOTS: |
111 | //interface to handles |
112 | void moveHandle(const QPointF& handleScenePos); |
113 | private: |
114 | QGraphicsLineItem* m_exitIndicator; |
115 | Kolf::OverlayHandle* m_exitHandle; |
116 | Kolf::OverlayHandle* m_speedHandle; |
117 | }; |
118 | |
119 | class Cup : public EllipticalCanvasItem |
120 | { |
121 | public: |
122 | Cup(QGraphicsItem* parent, b2World* world); |
123 | |
124 | virtual Kolf::Overlay* createOverlay(); |
125 | virtual bool collision(Ball* ball); |
126 | }; |
127 | } |
128 | |
129 | #endif // KOLF_OBJECTS_H |
130 | |