]> Shamusworld >> Repos - warehouse-man-deluxe/blob - src/editorwidget.h
Added/fixed editor, added play level functionality.
[warehouse-man-deluxe] / src / editorwidget.h
1 #ifndef __EDITORWIDGET_H__
2 #define __EDITORWIDGET_H__
3
4 #include <QtGui>
5 #include <stdint.h>
6 #include <vector>
7
8 #define BOARDSIZE 128
9
10 struct Point
11 {
12         Point(int xx = 0, int yy = 0) { x = xx; y = yy; }
13         int x, y;
14 };
15
16 struct Level
17 {
18         uint8_t board[BOARDSIZE][BOARDSIZE];
19         char name[41];
20         Point corner;           // Corner dimensions on screen
21         Point cursor;           // Cursor location
22 // This stuff will go into the save file, but we don't need it here...
23 //      Point size;                     // Actual dimensions of the level
24 //      Point boardCorner;      // Where on the gird the UL corner of the level is
25 };
26
27 class EditorWidget: public QWidget
28 {
29         Q_OBJECT
30
31         public:
32                 EditorWidget(QWidget * parent = 0);
33                 ~EditorWidget();
34
35         protected:
36                 QSize sizeHint() const;
37                 void paintEvent(QPaintEvent * event);
38                 void mousePressEvent(QMouseEvent * event);
39                 void mouseMoveEvent(QMouseEvent * event);
40                 void mouseReleaseEvent(QMouseEvent * event);
41                 void mouseDoubleClickEvent(QMouseEvent * event);
42                 void keyPressEvent(QKeyEvent * event);
43                 void keyReleaseEvent(QKeyEvent * event);
44                 void resizeEvent(QResizeEvent * event);
45
46 //      signals:
47 //              void UpdateScore(int);
48 //              void GameWasWon(void);
49
50         public:
51                 void CreateBackground(void);
52                 void ClearLevel(void);
53                 bool Load(void);
54                 bool Save(void);
55                 void SetNameOnCurrentLevel(const char *);
56                 void AddNewLevelAtCurrentPosition(void);
57                 static void GetSizeAndCorner(Level *, Point &, Point &);
58         private:
59                 void CountBoxesAndSpots(int &, int &);
60                 void ShiftLevel(int, int);
61                 void ResizeGrid(void);
62                 void Pause(int);
63
64         public:
65                 std::vector<Level> levelStorage;
66                 uint32_t currentLevel;
67
68         private:
69 //              Level currentLevel;
70                 QSize clientArea;
71                 Point range;
72 };
73
74 #endif  // __EDITORWIDGET_H__
75