SVN_SILENT made messages (.desktop file)
[kdegames.git] / kolf / floater.h
blobbc76c5f3007b12dd1bf710cd35f55f32de482c09
1 /*
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
19 #ifndef FLOATER_H
20 #define FLOATER_H
22 #include "game.h"
24 class Floater;
25 class FloaterConfig : public BridgeConfig
27 Q_OBJECT
29 public:
30 FloaterConfig(Floater *floater, QWidget *parent);
32 private slots:
33 void speedChanged(int news);
35 private:
36 Floater *floater;
39 class FloaterGuide : public Wall
41 public:
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; }
52 private:
53 Floater *floater;
54 bool almostDead;
56 double resizeFactor, baseX1, baseY1, baseX2, baseY2;
59 class Floater : public Bridge
61 public:
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);
81 void doAdvance();
82 void setSpeed(int news);
83 int curSpeed() const { return speed; }
85 // called by floaterguide when changed;
86 void reset();
87 void updateBaseResizeInfo();
89 private:
90 int speedfactor;
91 int speed;
92 FloaterGuide *wall;
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)
100 double resizeFactor;
101 QPoint origin;
102 Vector vector;
103 bool noUpdateZ;
104 bool haventMoved;
105 QPoint firstPoint;
108 class FloaterObj : public Object
110 public:
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); }
116 #endif