1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2011-2012 Dzmitry KAMIAHIN (dnk-88) <dnk-88@tut.by>
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef BUILDER_ZONE_H
21 #define BUILDER_ZONE_H
24 #include "builder_zone_base.h"
25 #include "builder_zone_region.h"
26 #include "zone_region_editor.h"
27 #include "pixmap_database.h"
30 #include <nel/ligo/zone_bank.h>
31 #include <nel/ligo/zone_region.h>
38 #include <QtCore/QString>
39 #include <QtCore/QMap>
40 #include <QtCore/QList>
41 #include <QtCore/QString>
42 #include <QtGui/QPixmap>
43 #include <QtGui/QUndoStack>
44 #include <QtGui/QGraphicsRectItem>
46 namespace LandscapeEditor
48 class ListZonesWidget
;
50 class UndoScanRegionCommand
;
54 @brief ZoneBuilder contains all the shared data between the tools and the engine.
55 @details ZoneBank contains the macro zones that is composed of several zones plus a mask.
56 PixmapDatabase contains the graphics for the zones
61 ZoneBuilder(LandscapeScene
*landscapeScene
, ListZonesWidget
*listZonesWidget
= 0, QUndoStack
*undoStack
= 0);
64 /// Inits zoneBank and init zone pixmap database
65 bool init(const QString
&pathName
, bool displayProgress
= false);
69 /// @return false if in point (x, y) placed zone brick, else true
70 bool getZoneMask (sint32 x
, sint32 y
);
72 bool getZoneAmongRegions(ZonePosition
&zonePos
, BuilderZoneRegion
*builderZoneRegionFrom
, sint32 x
, sint32 y
);
77 /// Adds the LigoTileCommand in undo stack
78 void actionLigoTile(const LigoData
&data
, const ZonePosition
&zonePos
);
80 void actionLigoMove(uint index
, sint32 deltaX
, sint32 deltaY
);
82 /// Adds the LigoResizeCommand in undo stack
83 void actionLigoResize(uint index
, sint32 newMinX
, sint32 newMaxX
, sint32 newMinY
, sint32 newMaxY
);
88 void addZone(const sint32 posX
, const sint32 posY
);
89 void addTransition(const sint32 posX
, const sint32 posY
);
90 void delZone(const sint32 posX
, const sint32 posY
);
96 /// Creates empty zone region and adds in the workspace
97 /// @return id zone region
98 int createZoneRegion();
100 /// Loads zone region from file @fileName and adds in the workspace.
101 /// @return id zone region
102 int createZoneRegion(const QString
&fileName
);
104 /// Unloads zone region from the workspace
105 void deleteZoneRegion(int id
);
107 /// Sets the current zone region with @id
108 void setCurrentZoneRegion(int id
);
110 /// @return id the current zone region, if workspace is empty then returns (-1)
111 int currentIdZoneRegion() const;
113 ZoneRegionObject
*currentZoneRegion() const;
114 int countZoneRegion() const;
115 ZoneRegionObject
*zoneRegion(int id
) const;
116 bool ligoData(LigoData
&data
, const ZonePosition
&zonePos
);
117 void setLigoData(LigoData
&data
, const ZonePosition
&zonePos
);
121 NLLIGO::CZoneBank
&getZoneBank()
126 PixmapDatabase
*pixmapDatabase() const;
128 QString
dataPath() const;
132 /// Scans ./zoneligos dir and add all *.ligozone files to zoneBank
133 bool initZoneBank (const QString
&path
);
135 /// Checks enabled beginMacro mode for undo stack, if false, then enables mode
136 void checkBeginMacro();
138 /// Checks enabled on beginMacro mode for undo stack, if true, then adds UndoScanRegionCommand
139 /// in undo stack and disables beginMacro mode
140 void checkEndMacro();
142 /// Checks intersects between them zone regions
143 /// @return true if newZoneRegion intersects with loaded zone regions, else return false
144 bool checkOverlaps(const NLLIGO::CZoneRegion
&newZoneRegion
);
148 BuilderZoneRegion
*builderZoneRegion
;
149 ZoneRegionObject
*zoneRegionObject
;
150 QGraphicsRectItem
*rectItem
;
153 sint32 m_minX
, m_maxX
, m_minY
, m_maxY
;
154 std::vector
<bool> m_zoneMask
;
156 QString m_lastPathName
;
158 int m_currentZoneRegion
;
159 //std::vector<LandscapeItem> m_landscapeItems;
160 QMap
<int, LandscapeItem
> m_landscapeMap
;
162 bool m_createdAction
;
163 QString m_titleAction
;
164 QList
<ZonePosition
> m_zonePositionList
;
165 UndoScanRegionCommand
*m_undoScanRegionCommand
;
167 PixmapDatabase
*m_pixmapDatabase
;
168 NLLIGO::CZoneBank m_zoneBank
;
169 ListZonesWidget
*m_listZonesWidget
;
170 LandscapeScene
*m_landscapeScene
;
171 QUndoStack
*m_undoStack
;
174 } /* namespace LandscapeEditor */
176 #endif // BUILDER_ZONE_H