2 Copyright (C) 2002-2005, Jason Katz-Brown <jasonkb@mit.edu>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 class FloaterConfig
: public BridgeConfig
30 FloaterConfig(Floater
*floater
, QWidget
*parent
);
33 void speedChanged(int news
);
39 class FloaterGuide
: public Wall
42 FloaterGuide(Floater
*floater
, QGraphicsItem
*parent
, QGraphicsScene
*scene
) : Wall(parent
, scene
) { this->floater
= floater
; almostDead
= false; resizeFactor
= 1; }
43 virtual void setPoints(double xa
, double ya
, double xb
, double yb
);
44 virtual void moveBy(double dx
, double dy
);
45 virtual Config
*config(QWidget
*parent
);
46 virtual void aboutToDelete();
47 virtual void aboutToDie();
48 void resize(double resizeFactor
);
49 void updateBaseResizeInfo();
50 virtual CanvasItem
*itemToDelete() { return NULL
; }
56 double resizeFactor
, baseX1
, baseY1
, baseX2
, baseY2
;
59 class Floater
: public Bridge
62 Floater(const QRect
&rect
, QGraphicsItem
* parent
, QGraphicsScene
*scene
);
63 void resize(double resizeFactor
);
64 virtual bool collision(Ball
*ball
, long int id
) { Bridge::collision(ball
, id
); return false; }
65 virtual void saveState(StateDB
*db
);
66 virtual void loadState(StateDB
*db
);
67 virtual void save(KConfigGroup
*cfgGroup
);
68 virtual void load(KConfigGroup
*cfgGroup
);
69 virtual bool loadLast() const { return true; }
70 virtual void firstMove(int x
, int y
);
71 virtual void aboutToSave();
72 virtual void aboutToDie();
73 virtual void savingDone();
74 virtual void setGame(KolfGame
*game
);
75 virtual void editModeChanged(bool changed
);
76 virtual bool moveable() const { return false; }
77 virtual void moveBy(double dx
, double dy
);
78 virtual Config
*config(QWidget
*parent
) { return new FloaterConfig(this, parent
); }
79 virtual QList
<QGraphicsItem
*> moveableItems() const;
80 virtual void advance(int phase
);
82 void setSpeed(int news
);
83 int curSpeed() const { return speed
; }
85 // called by floaterguide when changed;
87 void updateBaseResizeInfo();
94 * base numbers are the size or position when no resizing has taken place (i.e. the defaults)
96 double baseXVelocity
, baseYVelocity
;
98 * resizeFactor is the number to multiply base numbers by to get their resized value (i.e. if it is 1 then use default size, if it is >1 then everything needs to be bigger, and if it is <1 then everything needs to be smaller)
108 class FloaterObj
: public Object
111 FloaterObj() { m_name
= i18n("Floater"); m__name
= "floater"; }
112 virtual QGraphicsItem
*newObject(QGraphicsItem
* parent
, QGraphicsScene
*scene
) { return new Floater(QRect(0, 0, 80, 40), parent
, scene
); }