summaryrefslogtreecommitdiffstats
path: root/katomic/feld.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitc90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch)
tree6d8391395bce9eaea4ad78958617edb20c6a7573 /katomic/feld.h
downloadtdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz
tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'katomic/feld.h')
-rw-r--r--katomic/feld.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/katomic/feld.h b/katomic/feld.h
new file mode 100644
index 00000000..6a1cf761
--- /dev/null
+++ b/katomic/feld.h
@@ -0,0 +1,116 @@
+/****************************************************************
+**
+** Definition of Feld class,
+**
+****************************************************************/
+
+#ifndef FELD_H
+#define FELD_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <qwidget.h>
+#include <qpoint.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qmessagebox.h>
+
+#include <kscoredialog.h>
+
+#include "atom.h"
+
+#define MAX_UNDO (100)
+
+class KSimpleConfig;
+class Molek;
+
+#define FIELD_SIZE 15
+
+class Feld : public QWidget
+{
+ Q_OBJECT
+
+public:
+ Feld (QWidget *parent=0, const char *name=0);
+ ~Feld ();
+
+ enum Direction { None = 0,
+ MoveUp = 1,
+ MoveDown = (-1),
+ MoveLeft = 2,
+ MoveRight = (-2) };
+
+ void startAnimation (Direction dir);
+ void done ();
+
+ void load (const KSimpleConfig& config);
+
+ void setMolek(Molek *_mol) { mol = _mol; }
+
+ void doUndo ();
+ void doRedo ();
+
+signals:
+ void gameOver(int moves);
+ void sendMoves(int moves);
+ void enableRedo(bool enable);
+ void enableUndo(bool enable);
+
+protected:
+ bool checkDone();
+ void timerEvent (QTimerEvent *);
+ void paintEvent( QPaintEvent * );
+ void paintMovingAtom();
+ void mousePressEvent (QMouseEvent *);
+ void mouseMoveEvent (QMouseEvent *);
+ void emitStatus();
+
+protected:
+ struct UndoInfo {
+ uint atom;
+ int oldxpos, oldypos;
+ int xpos, ypos;
+ Direction dir;
+ };
+
+public slots:
+ void nextAtom();
+ void previousAtom();
+
+private:
+
+ const atom& getAtom(uint index) const;
+
+ void putNonAtom(int, int, Direction, bool brick = false);
+
+ QPoint *point;
+ QPixmap data;
+ QPixmap sprite;
+
+ Molek *mol;
+
+ uint feld[FIELD_SIZE][FIELD_SIZE];
+
+ // number of movements
+ int moves;
+
+ Direction dir;
+ int cx, cy;
+ int xpos, ypos;
+ int anz;
+ int frames, framesbak;
+
+ bool anim;
+ bool chosen, moving;
+
+ uint undoBegin;
+ uint undoSize;
+ uint redoSize;
+ UndoInfo undo[MAX_UNDO];
+
+ void resetValidDirs();
+
+};
+
+#endif // FELD_H