]> Shamusworld >> Repos - warehouse-man-deluxe/blobdiff - src/editorwidget.h
Added level editor.
[warehouse-man-deluxe] / src / editorwidget.h
diff --git a/src/editorwidget.h b/src/editorwidget.h
new file mode 100644 (file)
index 0000000..0b29acb
--- /dev/null
@@ -0,0 +1,72 @@
+#ifndef __EDITORWIDGET_H__
+#define __EDITORWIDGET_H__
+
+#include <QtGui>
+#include <stdint.h>
+#include <vector>
+
+#define BOARDSIZE 128
+
+struct Point
+{
+       Point(int xx = 0, int yy = 0) { x = xx; y = yy; }
+       int x, y;
+};
+
+struct Level
+{
+       uint8_t board[BOARDSIZE][BOARDSIZE];
+       char name[41];
+       Point corner;           // Corner dimensions on screen
+       Point cursor;           // Cursor location
+// This stuff will go into the save file, but we don't need it here...
+//     Point size;                     // Actual dimensions of the level
+//     Point boardCorner;      // Where on the gird the UL corner of the level is
+};
+
+class EditorWidget: public QWidget
+{
+       Q_OBJECT
+
+       public:
+               EditorWidget(QWidget * parent = 0);
+               ~EditorWidget();
+
+       protected:
+               QSize sizeHint() const;
+               void paintEvent(QPaintEvent * event);
+               void mousePressEvent(QMouseEvent * event);
+               void mouseMoveEvent(QMouseEvent * event);
+               void mouseReleaseEvent(QMouseEvent * event);
+               void mouseDoubleClickEvent(QMouseEvent * event);
+               void keyPressEvent(QKeyEvent * event);
+               void keyReleaseEvent(QKeyEvent * event);
+               void resizeEvent(QResizeEvent * event);
+
+//     signals:
+//             void UpdateScore(int);
+//             void GameWasWon(void);
+
+       public:
+               void CreateBackground(void);
+               void ClearLevel(void);
+               bool Load(void);
+               bool Save(void);
+               void SetNameOnCurrentLevel(const char *);
+       private:
+               void GetSizeAndCorner(Level *, Point &, Point &);
+               void ResizeGrid(void);
+               void Pause(int);
+
+       public:
+               std::vector<Level> levelStorage;
+               uint32_t currentLevel;
+
+       private:
+//             Level currentLevel;
+               QSize clientArea;
+               Point range;
+};
+
+#endif // __EDITORWIDGET_H__
+