]> Shamusworld >> Repos - warehouse-man-deluxe/blob - src/editorwidget.h
Added level editor.
[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         private:
57                 void GetSizeAndCorner(Level *, Point &, Point &);
58                 void ResizeGrid(void);
59                 void Pause(int);
60
61         public:
62                 std::vector<Level> levelStorage;
63                 uint32_t currentLevel;
64
65         private:
66 //              Level currentLevel;
67                 QSize clientArea;
68                 Point range;
69 };
70
71 #endif  // __EDITORWIDGET_H__
72