blob: 8d0920945bd5a47ede38321eaece5489f66ce5ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/*
mapwidget.h
This file is part of the Project::OSiRiON world editor
and is distributed under the terms and conditions of
the GNU General Public License version 2
*/
#ifndef __INCLUDED_EDITOR_MAPWIDGET__
#define __INCLUDED_EDITOR_MAPWIDGET__
#include "entityproperties.h"
#include <QWidget>
#include <QList>
namespace editor
{
class EntityWidget;
class Manipulator;
/**
* @brief MapWidget shows the zone map with the blue grid line
* */
class MapWidget : public QWidget
{
Q_OBJECT
public:
MapWidget(QWidget *parent = 0);
/**
* @brief add an entity to the map
* */
EntityWidget *addEntity();
void save(QTextStream &textstream);
protected:
/**
* @brief handle draw events
* */
virtual void paintEvent(QPaintEvent *event);
/**
* @brief handle resize events
* */
virtual void resizeEvent(QResizeEvent *event);
/**
* @brief handle mouse button press events
* */
virtual void mousePressEvent(QMouseEvent *event);
/**
* @brief handle mouse button press events
* */
virtual void mouseReleaseEvent(QMouseEvent *event);
/**
* @brief handle mouse move press events
* */
virtual void mouseMoveEvent(QMouseEvent *event);
/**
* @brief handle mousewheel events
* */
virtual void wheelEvent(QWheelEvent *event);
/**
* @brief handle keypress events
* */
virtual void keyPressEvent(QKeyEvent *event);
signals:
/**
* @brief the selected() signal is emitted if an entity on the map is selected
* */
void propertiesChanged(EntityProperties *properties);
public slots:
/**
* @brief move and resize child widgets
* This should be called whenever a child location on the map has changed.
* */
void resizeChildren();
/**
* @brief delete selected entities
* */
void deleteSelected();
/**
* @brief duplicate selected entities
* */
void duplicateSelected();
/**
* @brief called when an entity on the map has been clicked
* */
void select(EntityWidget *entity);
private slots:
/**
* @brief clear current selection
* */
void deselect();
/**
* @brief entity is dragged
* */
void dragEntity(EntityWidget *entity, int x, int y);
private:
int mapwidget_zoom;
int dragstart_x;
int dragstart_y;
int center_x;
int center_y;
bool is_dragging;
QList<EntityWidget *> mapwidget_enties;
Manipulator *mapwidget_manipulator;
};
}
#endif // __INCLUDED_EDITOR_MAPWIDGET__
|