|
From: <cn...@us...> - 2023-03-15 18:27:16
|
Revision: 1360
http://sourceforge.net/p/seq/svn/1360
Author: cn187
Date: 2023-03-15 18:27:13 +0000 (Wed, 15 Mar 2023)
Log Message:
-----------
Allow creating new map layers for editing
Modified Paths:
--------------
showeq/trunk/src/map.cpp
showeq/trunk/src/map.h
showeq/trunk/src/mapcore.cpp
showeq/trunk/src/mapcore.h
Modified: showeq/trunk/src/map.cpp
===================================================================
--- showeq/trunk/src/map.cpp 2023-03-15 18:26:59 UTC (rev 1359)
+++ showeq/trunk/src/map.cpp 2023-03-15 18:27:13 UTC (rev 1360)
@@ -599,6 +599,16 @@
}
}
+void MapMgr::createNewLayer()
+{
+ m_mapData.createNewLayer();
+ // signal that the map has been loaded
+ // note, the layers are populated in order, so the highest layer
+ // number (0-indexed) will be the one we just loaded
+ if (m_mapData.mapLayer(m_mapData.numLayers()-1)->mapLoaded())
+ emit mapLoaded();
+}
+
void MapMgr::addItem(const Item* item)
{
if ((item == NULL) || (item->type() != tSpawn))
@@ -880,6 +890,9 @@
* - cn187
*/
+ m_action_createNewLayer = subMenu->addAction(
+ QString("Create New Layer\t"), m_map, SLOT(createNewLayer()));
+
QMenu* layerMenu = new QMenu("Select Edit Layer");
m_editLayerSpinBox = new QSpinBox(layerMenu);
QWidgetAction* editLayerAction = new QWidgetAction(layerMenu);
@@ -3205,6 +3218,11 @@
}
}
+void Map::createNewLayer()
+{
+ m_mapMgr->createNewLayer();
+}
+
void Map::addLocation(void)
{
#ifdef DEBUGMAP
Modified: showeq/trunk/src/map.h
===================================================================
--- showeq/trunk/src/map.h 2023-03-15 18:26:59 UTC (rev 1359)
+++ showeq/trunk/src/map.h 2023-03-15 18:27:13 UTC (rev 1360)
@@ -177,6 +177,7 @@
bool import = false, bool force = false);
void saveMap(void);
void saveSOEMap(void);
+ void createNewLayer();
// Spawn Handling
void addItem(const Item* item);
@@ -296,6 +297,7 @@
QAction* m_action_followMenu_Player;
QAction* m_action_followMenu_Spawn;
QAction* m_action_followMenu_None;
+ QAction* m_action_createNewLayer;
QAction* m_action_addLocation;
QAction* m_action_startLine;
QAction* m_action_addLinePoint;
@@ -469,6 +471,7 @@
void toggleMapLayerVisibility(QAction* layer);
// map editing
+ void createNewLayer();
void addLocation();
void startLine();
void addLinePoint();
Modified: showeq/trunk/src/mapcore.cpp
===================================================================
--- showeq/trunk/src/mapcore.cpp 2023-03-15 18:26:59 UTC (rev 1359)
+++ showeq/trunk/src/mapcore.cpp 2023-03-15 18:27:13 UTC (rev 1360)
@@ -37,6 +37,7 @@
#include <cerrno>
+#include <QDateTime>
#include <QPainter>
#include <QString>
#include <QStringList>
@@ -1414,6 +1415,38 @@
seqInfo("Saved SOE map: '%s'", fileName.toLatin1().data());
}
+void MapData::createNewLayer()
+{
+ MapLayer* layer = new MapLayer();
+ QString fileName;
+
+ if (m_mapLayers.count())
+ {
+#if (QT_VERSION >= QT_VERSION_CHECK(5,5,0))
+ fileName = QString::asprintf("%s_%d.map", m_zoneShortName.toLatin1().data(), m_mapLayers.count());
+#else
+ fileName.sprintf("%s_%d.map", m_zoneShortName.toLatin1().data(), m_mapLayers.count());
+#endif
+ }
+ else
+ {
+ QDateTime now = QDateTime::currentDateTime();
+ QString timestamp = now.toString("yyyyMMdd-hhmmss");
+#if (QT_VERSION >= QT_VERSION_CHECK(5,5,0))
+ fileName = QString::asprintf("%s.map", timestamp.toLatin1().data());
+#else
+ fileName.sprintf("%s.map", timestamp.toLatin1().data());
+#endif
+ m_zoneLongName = timestamp;
+ m_zoneShortName = m_zoneLongName;
+ }
+
+ layer->setFileName(fileName);
+ m_mapLayers.append(layer);
+ layer->setMapLoaded(true);
+ seqInfo("Create layer: '%s'", fileName.toLatin1().data());
+}
+
bool MapData::isAggro(const QString& name, uint16_t* range) const
{
MapAggro* aggro;
Modified: showeq/trunk/src/mapcore.h
===================================================================
--- showeq/trunk/src/mapcore.h 2023-03-15 18:26:59 UTC (rev 1359)
+++ showeq/trunk/src/mapcore.h 2023-03-15 18:27:13 UTC (rev 1360)
@@ -553,6 +553,7 @@
void loadSOEMap(const QString& fileName, bool import = false);
void saveMap(const QString& fileName, const uint8_t layerNum) const;
void saveSOEMap(const QString& fileName, const uint8_t layerNum) const;
+ void createNewLayer();
// accessors
const QString& zoneShortName() const { return m_zoneShortName; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|