|
From: <cn...@us...> - 2021-06-22 00:50:03
|
Revision: 1188
http://sourceforge.net/p/seq/svn/1188
Author: cn187
Date: 2021-06-22 00:50:04 +0000 (Tue, 22 Jun 2021)
Log Message:
-----------
Add support for multi-layer maps
Add the ability to load multi-layer maps (e.g, SOE, Brewall's, Good's).
* On zoning, SEQ will automatically load the base zone map as well as maps 1-3
of the same name.
* The layer control on the map bottom control pane allows you to select
which layers you want to see/hide.
* Manual load/import of maps will now allow the selection of multiple files
* Saving maps will save all layers as their individual filenames
* The map edit menu now contains an "Edit Layer" setting, allowing you
choose which layer will be modified when doing map edits.
Modified Paths:
--------------
showeq/branches/cn187_devel/conf/seqdef.xml
showeq/branches/cn187_devel/src/map.cpp
showeq/branches/cn187_devel/src/map.h
showeq/branches/cn187_devel/src/mapcore.cpp
showeq/branches/cn187_devel/src/mapcore.h
Modified: showeq/branches/cn187_devel/conf/seqdef.xml
===================================================================
--- showeq/branches/cn187_devel/conf/seqdef.xml 2021-06-22 00:49:58 UTC (rev 1187)
+++ showeq/branches/cn187_devel/conf/seqdef.xml 2021-06-22 00:50:04 UTC (rev 1188)
@@ -604,6 +604,10 @@
<bool value="true" />
<comment>Display map frame rate control</comment>
</property>
+ <property name="ShowLayersControl" >
+ <bool value="true" />
+ <comment>Display map layer control</comment>
+ </property>
<property name="ShowFilter" >
<bool value="true" />
<comment>Display the map's runtime filter control</comment>
@@ -632,6 +636,9 @@
<int value="5" />
<comment>Map frame rate (number of map refreshes per second)</comment>
</property>
+ <property name="MapLayerMask">
+ <int value="-7"/>
+ </property>
<property name="CacheChanges" >
<bool value="true" />
<comment>property that controls repaints, true = Just at repaint ast Framerate, or false = Whenever spawn/map info changes in addition to Framerate</comment>
@@ -904,6 +911,10 @@
<bool value="true" />
<comment>Display map frame rate control</comment>
</property>
+ <property name="ShowLayersControl" >
+ <bool value="true" />
+ <comment>Display map layer control</comment>
+ </property>
<property name="ShowFilter" >
<bool value="true" />
<comment>Display the map's runtime filter control</comment>
@@ -932,6 +943,9 @@
<int value="5" />
<comment>Map frame rate (number of map refreshes per second)</comment>
</property>
+ <property name="MapLayerMask">
+ <int value="-7"/>
+ </property>
<property name="CacheChanges" >
<bool value="true" />
<comment>property that controls repaints, true = Just at repaint ast Framerate, or false = Whenever spawn/map info changes in addition to Framerate</comment>
@@ -1204,6 +1218,10 @@
<bool value="true" />
<comment>Display map frame rate control</comment>
</property>
+ <property name="ShowLayersControl" >
+ <bool value="true" />
+ <comment>Display map layer control</comment>
+ </property>
<property name="ShowFilter" >
<bool value="true" />
<comment>Display the map's runtime filter control</comment>
@@ -1232,6 +1250,9 @@
<int value="5" />
<comment>Map frame rate (number of map refreshes per second)</comment>
</property>
+ <property name="MapLayerMask">
+ <int value="-7"/>
+ </property>
<property name="CacheChanges" >
<bool value="true" />
<comment>property that controls repaints, true = Just at repaint ast Framerate, or false = Whenever spawn/map info changes in addition to Framerate</comment>
@@ -1504,6 +1525,10 @@
<bool value="true" />
<comment>Display map frame rate control</comment>
</property>
+ <property name="ShowLayersControl" >
+ <bool value="true" />
+ <comment>Display map layer control</comment>
+ </property>
<property name="ShowFilter" >
<bool value="true" />
<comment>Display the map's runtime filter control</comment>
@@ -1532,6 +1557,9 @@
<int value="5" />
<comment>Map frame rate (number of map refreshes per second)</comment>
</property>
+ <property name="MapLayerMask">
+ <int value="-7"/>
+ </property>
<property name="CacheChanges" >
<bool value="true" />
<comment>property that controls repaints, true = Just at repaint ast Framerate, or false = Whenever spawn/map info changes in addition to Framerate</comment>
@@ -1804,6 +1832,10 @@
<bool value="true" />
<comment>Display map frame rate control</comment>
</property>
+ <property name="ShowLayersControl" >
+ <bool value="true" />
+ <comment>Display map layer control</comment>
+ </property>
<property name="ShowFilter" >
<bool value="true" />
<comment>Display the map's runtime filter control</comment>
@@ -1831,6 +1863,9 @@
<int value="5" />
<comment>Map frame rate (number of map refreshes per second)</comment>
</property>
+ <property name="MapLayerMask">
+ <int value="-7"/>
+ </property>
<property name="CacheChanges" >
<bool value="true" />
<comment>property that controls repaints, true = Just at repaint ast Framerate, or false = Whenever spawn/map info changes in addition to Framerate</comment>
Modified: showeq/branches/cn187_devel/src/map.cpp
===================================================================
--- showeq/branches/cn187_devel/src/map.cpp 2021-06-22 00:49:58 UTC (rev 1187)
+++ showeq/branches/cn187_devel/src/map.cpp 2021-06-22 00:50:04 UTC (rev 1188)
@@ -56,6 +56,7 @@
#include <QFileDialog>
#include <QEvent>
#include <QPushButton>
+#include <QToolButton>
#include <QLayout>
#include <QShortcut>
#include <QColorDialog>
@@ -359,27 +360,33 @@
void MapMgr::loadZoneMap(const QString& shortZoneName)
{
- // first attempt to find map with .map suffix
- QFileInfo fileInfo = m_dataLocMgr->findExistingFile("maps",
- shortZoneName + ".map");
-
- // if that file doesn't exist, try a straight .txt suffix
- if (!fileInfo.exists())
- fileInfo = m_dataLocMgr->findExistingFile("maps",
- shortZoneName + ".txt");
- // if that file doesn't exist, try a _1.txt suffix
- if (!fileInfo.exists())
- fileInfo = m_dataLocMgr->findExistingFile("maps",
- shortZoneName + "_1.txt");
+ bool found = false;
+ QString extension = "";
- if (fileInfo.exists())
+ QStringList mapFiles;
+
+ // find maps
+ QFileInfo mapFileInfo = m_dataLocMgr->findExistingFile("maps",
+ shortZoneName + ".map");
+
+ QFileInfo txtFileInfo = m_dataLocMgr->findExistingFile("maps",
+ shortZoneName + ".txt");
+
+ if (mapFileInfo.exists())
{
- // load the map if it's not already loaded
- if (fileInfo.absoluteFilePath() != m_mapData.fileName())
- loadFileMap(fileInfo.absoluteFilePath());
+ found = true;
+ extension = ".map";
+ mapFiles.append(mapFileInfo.absoluteFilePath());
+
+ } else if (txtFileInfo.exists())
+ {
+ found = true;
+ extension = ".txt";
+ mapFiles.append(txtFileInfo.absoluteFilePath());
}
- else
+
+ if (!found)
{
seqInfo("No Map found for zone '%s'!", shortZoneName.toLatin1().data());
seqInfo(" Checked for all variants of '%s.map', '%s.txt', and '%s_1.txt'",
@@ -389,7 +396,22 @@
seqInfo(" in directories '%s' and '%s'!",
m_dataLocMgr->userDataDir("maps").absolutePath().toLatin1().data(),
m_dataLocMgr->pkgDataDir("maps").absolutePath().toLatin1().data());
+
+ return;
}
+
+ // add other layers
+ QFileInfo fileInfo;
+ for (int i = 1; i < 4; ++i)
+ {
+ fileInfo = m_dataLocMgr->findExistingFile("maps",
+ shortZoneName + "_" + QString::number(i) + extension);
+
+ if (fileInfo.exists())
+ mapFiles.append(fileInfo.absoluteFilePath());
+ }
+
+ loadFileMap(mapFiles);
}
void MapMgr::loadMap ()
@@ -398,22 +420,28 @@
qDebug ("loadMap()");
#endif /* DEBUGMAP */
- QString fileName = m_mapData.fileName();
+ QStringList fileNames;
+ for (int i = 0; i < m_mapData.numLayers(); ++i)
+ {
+ fileNames.append(m_mapData.mapLayer(i)->fileName());
+ }
- if (fileName.isEmpty())
- fileName = m_dataLocMgr->findExistingFile("maps", fileName).absoluteFilePath();
+ if (fileNames.isEmpty())
+ fileNames.append(m_dataLocMgr->findExistingFile("maps", "").absoluteFilePath());
// create a file dialog the defaults to the currently open map
- fileName = QFileDialog::getOpenFileName(m_dialogParent, "Load Map", fileName,
+ // it doesn't look like we can start with all the loaded files selected,
+ // so we pick the first one, which should be the base map
+ fileNames = QFileDialog::getOpenFileNames(m_dialogParent, "Load Map", fileNames.first(),
"All maps (*.map *.txt);;SEQ maps (*.map);;EQ maps (*.txt)");
- if (fileName.isEmpty ())
+ if (fileNames.isEmpty ())
return;
- seqInfo("Attempting to load map: %s", fileName.toLatin1().data());
+ fileNames.sort();
// load the map
- loadFileMap(fileName, false, true);
+ loadFileMap(fileNames, false, true);
}
void MapMgr::importMap ()
@@ -422,22 +450,26 @@
qDebug ("importMap()");
#endif /* DEBUGMAP */
- QString fileName = m_mapData.fileName();
+ QStringList fileNames;
+ for (int i = 0; i < m_mapData.numLayers(); ++i)
+ {
+ fileNames.append(m_mapData.mapLayer(i)->fileName());
+ }
- if (fileName.isEmpty())
- fileName = m_dataLocMgr->findExistingFile("maps", fileName).absoluteFilePath();
+ if (fileNames.isEmpty())
+ fileNames.append(m_dataLocMgr->findExistingFile("maps", "").absoluteFilePath());
// create a file dialog the defaults to the currently open map
- fileName = QFileDialog::getOpenFileName(m_dialogParent, "Import Map", fileName,
+ fileNames = QFileDialog::getOpenFileNames(m_dialogParent, "Import Map", fileNames.first(),
"All maps (*.map *.txt);;SEQ maps (*.map);;EQ maps (*.txt)");
- if (fileName.isEmpty ())
+ if (fileNames.isEmpty ())
return;
- seqInfo("Attempting to import map: %s", fileName.toLatin1().data());
+ fileNames.sort();
// load the map
- loadFileMap(fileName, true, true);
+ loadFileMap(fileNames, true, true);
}
@@ -447,11 +479,24 @@
qDebug ("loadFileMap()");
#endif /* DEBUGMAP */
+ if (import)
+ seqInfo("Attempting to import map: %s", fileName.toLatin1().data());
+ else
+ seqInfo("Attempting to load map: %s", fileName.toLatin1().data());
+
+
// if not a forced load, and the same map is already loaded, do nothing
- if (!force && m_mapData.mapLoaded() &&
- (m_mapData.fileName() == fileName))
- return;
+ if (!force)
+ {
+ for (int i = 0; i < m_mapData.numLayers(); ++i)
+ {
+ if (m_mapData.mapLayer(i)->mapLoaded() &&
+ m_mapData.mapLayer(i)->fileName() == fileName)
+ return;
+ }
+ }
+
// load the specified map
if (!fileName.endsWith(".txt"))
m_mapData.loadMap(fileName, import);
@@ -489,22 +534,45 @@
m_mapData.updateBounds();
// signal that the map has been loaded
- if (m_mapData.mapLoaded())
+ // 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();
} // END loadFileMap
+void MapMgr::loadFileMap (const QStringList& files, bool import, bool force)
+{
+ QStringList::const_iterator it = files.begin();
+ for (; it != files.end(); ++it)
+ {
+ // if we're loading multiple files, it doesn't sense to load and
+ // immediately clear/replace each one. So if import isn't specified,
+ // we clear the current maps, load the first one, then import the
+ // rest as layers
+ if (!import && it == files.begin())
+ loadFileMap(*it, false, force);
+ else
+ loadFileMap(*it, true, force);
+ }
+}
+
+
void MapMgr::saveMap ()
{
#ifdef DEBUGMAP
qDebug ("saveMap()");
#endif /* DEBUGMAP */
- QFileInfo fileInfo(m_mapData.fileName());
- fileInfo = m_dataLocMgr->findWriteFile("maps", fileInfo.baseName() + ".map",
+ for (int i = 0; i < m_mapData.numLayers(); ++i)
+ {
+ QFileInfo fileInfo(m_mapData.mapLayer(i)->fileName());
+
+ fileInfo = m_dataLocMgr->findWriteFile("maps", fileInfo.baseName() + ".map",
false);
- m_mapData.saveMap(fileInfo.absoluteFilePath());
+ m_mapData.saveMap(fileInfo.absoluteFilePath(), i);
+ }
}
void MapMgr::saveSOEMap ()
@@ -512,12 +580,16 @@
#ifdef DEBUGMAP
qDebug ("saveMap()");
#endif /* DEBUGMAP */
- QFileInfo fileInfo(m_mapData.fileName());
- fileInfo = m_dataLocMgr->findWriteFile("maps", fileInfo.baseName() + "_2.txt",
+ for (int i = 0; i < m_mapData.numLayers(); ++i)
+ {
+ QFileInfo fileInfo(m_mapData.mapLayer(i)->fileName());
+
+ fileInfo = m_dataLocMgr->findWriteFile("maps", fileInfo.baseName() + ".txt",
false);
- m_mapData.saveSOEMap(fileInfo.absoluteFilePath());
+ m_mapData.saveSOEMap(fileInfo.absoluteFilePath(), i);
+ }
}
void MapMgr::addItem(const Item* item)
@@ -696,6 +768,16 @@
emit mapUpdated();
}
+void MapMgr::setEditLayer(int layerNum)
+{
+ if (layerNum >= m_mapData.numLayers())
+ return;
+
+ m_mapData.setEditLayer(layerNum);
+
+ emit editLayerChanged();
+}
+
void MapMgr::savePrefs(void)
{
#if 0 // ZBTEMP: Migrate to place where ever this is set
@@ -710,8 +792,6 @@
out << "DefaultLineName: " << m_curLineName << endl;
out << "DefaultLocationColor: " << m_curLocationColor << endl;
out << "ImageLoaded: " << m_mapData.imageLoaded() << endl;
- out << "MapLoaded: " << m_mapData.mapLoaded() << endl;
- out << "MapFileName: " << m_mapData.fileName() << endl;
out << "ZoneShortName: " << m_mapData.zoneShortName() << endl;
out << "ZoneLongName: " << m_mapData.zoneLongName() << endl;
out << "boundingRect: top(" << m_mapData.boundingRect().top()
@@ -721,9 +801,16 @@
out << "size: width(" << m_mapData.size().width()
<< ") height(" << m_mapData.size().height() << ")" << endl;
out << "ZoneZEM: " << m_mapData.zoneZEM() << endl;
- out << "LLines: " << m_mapData.lLines().count() << endl;
- out << "MLines: " << m_mapData.mLines().count() << endl;
- out << "Locations: " << m_mapData.locations().count() << endl;
+ out << "numLayers: " << m_mapData.numLayers() << endl;
+ for (int i = 0; i < m_mapData.numLayers(); ++i)
+ {
+ out << "Layer " << i << ":" << endl;
+ out << "\tMapFileName: " << m_mapData.mapLayer(i)->fileName() << endl;
+ out << "\tMapLoaded: " << m_mapData.mapLayer(i)->mapLoaded() << endl;
+ out << "\tLLines: " << m_mapData.mapLayer(i)->lLines().count() << endl;
+ out << "\tMLines: " << m_mapData.mapLayer(i)->mLines().count() << endl;
+ out << "\tLocations: " << m_mapData.mapLayer(i)->locations().count() << endl;
+ }
out << "Aggros: " << m_mapData.aggros().count() << endl;
out << endl;
}
@@ -786,6 +873,28 @@
* - cn187
*/
+ QWidget* tmpWidget = new QWidget(subMenu);
+ QHBoxLayout* tmpLayout = new QHBoxLayout(tmpWidget);
+ tmpLayout->setContentsMargins(1, 1, 1, 1);
+ m_editLayerSpinBox = new QSpinBox(tmpWidget);
+ QLabel* tmpLabel = new QLabel("Edit Layer:", tmpWidget);
+ tmpLayout->addWidget(tmpLabel);
+ tmpLayout->addWidget(m_editLayerSpinBox);
+ QWidgetAction* tmpWidgetAction = new QWidgetAction(subMenu);
+ tmpWidgetAction->setDefaultWidget(tmpWidget);
+ subMenu->addAction(tmpWidgetAction);
+
+ m_editLayerSpinBox->setMinimum(0);
+ m_editLayerSpinBox->setSingleStep(1);
+ m_editLayerSpinBox->setMaximum(m_map->mapMgr()->mapData().numLayers()-1);
+ m_editLayerSpinBox->setValue(m_map->mapMgr()->mapData().editLayer());
+
+ connect(m_editLayerSpinBox, SIGNAL(valueChanged(int)),
+ m_map->mapMgr(), SLOT(setEditLayer(int)));
+
+ connect(m_map->mapMgr(), SIGNAL(mapLoaded(void)), this, SLOT(editLayerChanged(void)));
+ connect(m_map->mapMgr(), SIGNAL(editLayerChanged(void)), this, SLOT(editLayerChanged(void)));
+
key = pSEQPrefs->getPrefKey("AddLocationKey", preferenceName, "Ctrl+O");
m_action_addLocation = subMenu->addAction(
QString("Add Location...\t") + key.toString(), m_map, SLOT(addLocation()));
@@ -1248,6 +1357,15 @@
m_action_FOVScaledClassic->setChecked(fovMode == tFOVScaledClassic);
m_action_FOVClassic->setChecked(fovMode == tFOVClassic);
}
+
+void MapMenu::editLayerChanged(void)
+{
+ m_editLayerSpinBox->setMinimum(0);
+ m_editLayerSpinBox->setSingleStep(1);
+ m_editLayerSpinBox->setMaximum(m_map->mapMgr()->mapData().numLayers()-1);
+ m_editLayerSpinBox->setValue(m_map->mapMgr()->mapData().editLayer());
+}
+
void MapMenu::select_follow(QAction* item)
{
int mode = item->data().value<int>();
@@ -1707,6 +1825,12 @@
tmpPrefString = "ShowInstanceLocationMarker";
m_showInstanceLocationMarker = pSEQPrefs->getPrefBool(tmpPrefString, prefString, false);
+ tmpPrefString = "MapLayerMask";
+ uint32_t mask = pSEQPrefs->getPrefInt(tmpPrefString, prefString, 0xffffffff);
+ for (int i = 0; i < 32; ++i)
+ m_param.setLayerVisibility(i, mask & (1 << i));
+
+
// Accelerators
QShortcut *tmpShortcut = nullptr;
QKeySequence key;
@@ -2855,6 +2979,25 @@
refreshMap ();
}
+void Map::toggleMapLayerVisibility(QAction* layer)
+{
+ int layerNum = layer->data().value<int>();
+ int layerChecked = layer->isChecked();
+
+ m_param.setLayerVisibility(layerNum, layerChecked);
+
+ QString tmpPrefString = "MapLayerMask";
+ uint32_t mask = pSEQPrefs->getPrefInt(tmpPrefString, preferenceName(), 0xffffffff);
+ if (layerChecked)
+ mask |= (1 << layerNum);
+ else
+ mask &= ~(1 << layerNum);
+ pSEQPrefs->setPrefInt(tmpPrefString, preferenceName(), mask);
+
+ if(!m_cacheChanges)
+ refreshMap();
+}
+
void Map::dumpInfo(QTextStream& out)
{
out << "[" << preferenceName() << "]" << endl;
@@ -4735,6 +4878,23 @@
#endif
topControlBoxLayout->addWidget(m_filterBox);
+ // setup Layers control
+ m_layersBox = new QWidget(m_bottomControlBox);
+ m_layersBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ QHBoxLayout* layersBoxLayout = new QHBoxLayout(m_layersBox);
+ layersBoxLayout->setSpacing(1);
+ layersBoxLayout->setMargin(0);
+
+ loadLayerButtons();
+
+ tmpPrefString = "ShowLayersControl";
+ if (!pSEQPrefs->getPrefBool(tmpPrefString, prefString, 1))
+ m_layersBox->hide();
+
+ bottomControlBoxLayout->addWidget(m_layersBox);
+
+ connect(mapMgr, SIGNAL(mapLoaded()), this, SLOT(mapLoaded()));
+
// setup Frame Rate control
m_frameRateBox = new QWidget(m_bottomControlBox);
m_frameRateBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
@@ -4909,6 +5069,10 @@
subMenu = new QMenu("Bottom Controls");
+ m_action_layers = subMenu->addAction("Show Layer Controls", this,
+ SLOT(toggle_layers()));
+ m_action_layers->setCheckable(true);
+
m_action_frameRate = subMenu->addAction("Show Frame Rate", this,
SLOT(toggle_frameRate()));
m_action_frameRate->setCheckable(true);
@@ -5027,6 +5191,74 @@
m_map->savePrefs();
}
+void MapFrame::mapLoaded()
+{
+ loadLayerButtons();
+}
+
+
+void MapFrame::loadLayerButtons()
+{
+
+ //delete existing buttons
+ QLayout* layersBoxLayout = m_layersBox->layout();
+ QLayoutItem* item;
+ while ((item = layersBoxLayout->takeAt(0)))
+ {
+ if (item)
+ {
+ delete item->widget();
+ delete item;
+ }
+ }
+
+ QLabel* tmpLabel = new QLabel(m_layersBox);
+ tmpLabel->setText("Layers:");
+ layersBoxLayout->addWidget(tmpLabel);
+
+ QToolButton* tmpButton = NULL;
+ int w = tmpLabel->minimumSizeHint().width();
+
+ QAction* tmpAction = NULL;
+
+ int numLayers = m_map->mapMgr()->mapData().numLayers();
+
+ for (int i = 0; i < numLayers; ++i)
+ {
+ QString label;
+ if (i == 0)
+ label = "Base";
+ else
+ label = QString::number(i);
+
+ tmpAction = new QAction(tmpButton);
+ tmpAction->setText(label);
+ tmpAction->setCheckable(true);
+ tmpAction->setData(i);
+ tmpAction->setChecked(m_map->isLayerVisible(i));
+
+ tmpButton = new QToolButton();
+ tmpButton->setDefaultAction(tmpAction);
+ tmpButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+ tmpButton->setMinimumWidth(fontMetrics().width(label));
+
+ layersBoxLayout->addWidget(tmpButton);
+ w += fontMetrics().width(label);
+
+ connect(tmpButton, SIGNAL(triggered(QAction*)),
+ m_map, SLOT(toggleMapLayerVisibility(QAction*)));
+ }
+
+ //minimum width should be the sum of all the minimum widths of the components
+ //minimum height should be the minimum height of the tallest component
+ m_layersBox->setMinimumSize(tmpLabel->minimumSizeHint().width() + w,
+ qMax(tmpLabel->minimumSizeHint().height(),
+ (tmpButton) ? tmpButton->minimumSizeHint().height():0));
+
+
+
+}
+
void MapFrame::dumpInfo(QTextStream& out)
{
// first dump information about the map frame
@@ -5039,6 +5271,7 @@
out << "ShowFilter: " << m_filterBox->isVisible() << endl;
out << "ShowControlBox: " << m_bottomControlBox->isVisible() << endl;
out << "ShowFrameRate: " << m_frameRateBox->isVisible() << endl;
+ out << "ShowLayersControl: " << m_layersBox->isVisible() << endl;
out << "ShowPanControls: " << m_panBox->isVisible() << endl;
out << "ShowDepthFilterControls: " << m_depthControlBox->isVisible() << endl;
out << "CurrentFilter: '" << m_lastFilter << "'" << endl;
@@ -5066,6 +5299,7 @@
m_action_bottomControl->setChecked(m_bottomControlBox->isVisible());
if (m_bottomControlBox->isVisible())
{
+ m_action_layers->setChecked(m_layersBox->isVisible());
m_action_frameRate->setChecked(m_frameRateBox->isVisible());
m_action_pan->setChecked(m_panBox->isVisible());
m_action_depthControlRoom->setChecked(m_depthControlBox->isVisible());
@@ -5196,6 +5430,21 @@
}
}
+void MapFrame::toggle_layers()
+{
+ if (m_layersBox->isVisible())
+ m_layersBox->hide();
+ else
+ m_layersBox->show();
+
+ QString tmpPrefString = "SaveControls";
+ if (pSEQPrefs->getPrefBool(tmpPrefString, preferenceName(), true))
+ {
+ tmpPrefString = "ShowLayersControl";
+ pSEQPrefs->setPrefBool(tmpPrefString, preferenceName(), m_layersBox->isVisible());
+ }
+}
+
void MapFrame::toggle_pan()
{
if (m_panBox->isVisible())
Modified: showeq/branches/cn187_devel/src/map.h
===================================================================
--- showeq/branches/cn187_devel/src/map.h 2021-06-22 00:49:58 UTC (rev 1187)
+++ showeq/branches/cn187_devel/src/map.h 2021-06-22 00:50:04 UTC (rev 1188)
@@ -173,6 +173,8 @@
void importMap(void);
void loadFileMap(const QString& fileName,
bool import = false, bool force = false);
+ void loadFileMap(const QStringList& files,
+ bool import = false, bool force = false);
void saveMap(void);
void saveSOEMap(void);
@@ -196,6 +198,8 @@
void scaleDownZ(int16_t);
void scaleUpZ(int16_t);
+ void setEditLayer(int layerNum);
+
// Preference handling
void savePrefs(void);
@@ -206,6 +210,7 @@
void mapLoaded(void);
void mapUnloaded(void);
void mapUpdated(void);
+ void editLayerChanged(void);
private:
const DataLocationMgr* m_dataLocMgr;
@@ -235,6 +240,8 @@
void init_Menu(void);
void init_fovMenu(void);
+ void editLayerChanged(void);
+
void select_follow(QAction* item);
void select_mapLine(QAction* item);
@@ -285,6 +292,7 @@
QSpinBox* m_fovSpinBox;
QSpinBox* m_drawSizeSpinBox;
QSpinBox* m_zoomDefaultSpinBox;
+ QSpinBox* m_editLayerSpinBox;
QAction* m_action_followMenu_Player;
QAction* m_action_followMenu_Spawn;
QAction* m_action_followMenu_None;
@@ -439,7 +447,9 @@
bool showGridLines() const { return m_param.showGridLines(); }
bool showGridTicks() const { return m_param.showGridTicks(); }
bool cacheAlwaysRepaint() const { return m_mapCache.alwaysRepaint(); }
-
+
+ bool isLayerVisible(uint8_t layerNum) const { return m_param.isLayerVisible(layerNum); }
+
public slots:
void savePrefs(void);
void saveMapImage(void);
@@ -456,6 +466,8 @@
void mapUnloaded(void);
void mapUpdated(void);
+ void toggleMapLayerVisibility(QAction* layer);
+
// map editing
void addLocation();
void startLine();
@@ -695,6 +707,8 @@
Map* map() { return m_map; }
const QString& mapPreferenceName() { return m_mapPreferenceName; }
+ void loadLayerButtons(void);
+
public slots:
void regexpok(int ok);
void setregexp(const QString&);
@@ -703,6 +717,7 @@
void setPlayer(int16_t x, int16_t y, int16_t z,
int16_t Dx, int16_t Dy, int16_t Dz, int32_t degrees);
virtual void savePrefs(void);
+ void mapLoaded(void);
// dump debug info
void dumpInfo(QTextStream& out);
@@ -717,6 +732,7 @@
void toggle_mouseLocation();
void toggle_filter();
void toggle_frameRate();
+ void toggle_layers();
void toggle_pan();
void toggle_depthControls();
void set_font();
@@ -745,6 +761,7 @@
MapFilterLineEdit* m_filter;
QWidget* m_bottomControlBox;
+ QWidget* m_layersBox;
QWidget* m_frameRateBox;
QSpinBox* m_frameRate;
QWidget* m_panBox;
@@ -763,6 +780,7 @@
QAction* m_action_filter;
QAction* m_action_topControl_Options;
QAction* m_action_frameRate;
+ QAction* m_action_layers;
QAction* m_action_pan;
QAction* m_action_depthControlRoom;
QAction* m_action_bottomControl_Options;
Modified: showeq/branches/cn187_devel/src/mapcore.cpp
===================================================================
--- showeq/branches/cn187_devel/src/mapcore.cpp 2021-06-22 00:49:58 UTC (rev 1187)
+++ showeq/branches/cn187_devel/src/mapcore.cpp 2021-06-22 00:50:04 UTC (rev 1188)
@@ -262,6 +262,20 @@
m_playerFloorRoom = m_curPlayer.z() - m_floorRoom;
}
+bool MapParameters::isLayerVisible(uint8_t layerNum) const
+{
+ return m_layerVisibility & (1 << layerNum);
+}
+
+void MapParameters::setLayerVisibility(uint8_t layerNum, bool isVisible)
+{
+ if (isVisible)
+ m_layerVisibility |= (1 << layerNum);
+ else
+ m_layerVisibility &= ~(1 << layerNum);
+}
+
+
//----------------------------------------------------------------------
// MapCommon
MapCommon::~MapCommon()
@@ -397,17 +411,24 @@
{
}
-
//----------------------------------------------------------------------
-// MapData
-MapData::MapData()
+// MapLayer
+MapLayer::MapLayer()
{
- // clear the structure
clear();
}
-MapData::~MapData()
+MapLayer::~MapLayer()
{
+ clear();
+}
+
+void MapLayer::clear()
+{
+
+ m_mapLoaded = false;
+ m_fileName = QString();
+
qDeleteAll(m_lLines);
m_lLines.clear();
@@ -416,7 +437,23 @@
qDeleteAll(m_locations);
m_locations.clear();
+}
+
+//----------------------------------------------------------------------
+// MapData
+MapData::MapData()
+{
+ // clear the structure
+ clear();
+}
+
+MapData::~MapData()
+{
+
+ qDeleteAll(m_mapLayers);
+ m_mapLayers.clear();
+
qDeleteAll(m_aggros);
m_aggros.clear();
}
@@ -423,7 +460,6 @@
void MapData::clear()
{
- m_fileName = "";
m_zoneLongName = "";
m_zoneShortName = "";
m_minX = -50;
@@ -432,26 +468,29 @@
m_maxY = 50;
updateBounds();
- qDeleteAll(m_lLines);
- m_lLines.clear();
+ qDeleteAll(m_mapLayers);
+ m_mapLayers.clear();
- qDeleteAll(m_mLines);
- m_mLines.clear();
-
- qDeleteAll(m_locations);
- m_locations.clear();
-
qDeleteAll(m_aggros);
m_aggros.clear();
- m_mapLoaded = false;
m_imageLoaded = false;
m_editLineM = NULL;
m_editLocation = NULL;
m_zoneZEM = 75;
+
+ m_editLayer = 0;
}
+MapLayer* MapData::mapLayer(uint8_t layerNum)
+{
+ if (layerNum < m_mapLayers.count())
+ return m_mapLayers[layerNum];
+
+ return NULL;
+}
+
void MapData::loadMap(const QString& fileName, bool import)
{
int16_t mx, my, mz;
@@ -466,10 +505,8 @@
uint32_t specifiedLinePoints;
MapLineL* currentLineL = NULL;
MapLineM* currentLineM = NULL;
+ MapLayer* layer = NULL;
- // set the map filename
- setFileName(fileName);
-
// clear any existing map data (if not importing)
if (!import)
clear();
@@ -488,8 +525,10 @@
return;
}
- // note the file name
- m_fileName = fileName;
+ layer = new MapLayer();
+
+ // note the file name
+ layer->setFileName(fileName);
// allocate memory in a QByteArray to hold the entire file contents
QByteArray textData(mapFile.size() + 1, '\0');
@@ -655,7 +694,7 @@
quickCheckPos(bounds.right(), bounds.bottom());
// add it to the list of L lines
- m_mLines.append(currentLineM);
+ layer->mLines().append(currentLineM);
}
break;
@@ -743,7 +782,7 @@
quickCheckPos(bounds.right(), bounds.bottom());
// add it to the list of L lines
- m_lLines.append(currentLineL);
+ layer->lLines().append(currentLineL);
}
break;
@@ -771,15 +810,15 @@
mz = (*fit++).toShort();
// add the appropriate style Location depending on if the global height is set
- m_locations.append(new MapLocation(name, color, mx, my, mz));
+ layer->locations().append(new MapLocation(name, color, mx, my, mz));
}
// add the appropriate style Location depending on if the global
// height has been set
if (globHeightSet)
- m_locations.append(new MapLocation(name, color, mx, my, globHeight));
+ layer->locations().append(new MapLocation(name, color, mx, my, globHeight));
else
- m_locations.append(new MapLocation(name, color, mx, my));
+ layer->locations().append(new MapLocation(name, color, mx, my));
// adjust map boundaries
quickCheckPos(mx, my);
@@ -877,8 +916,9 @@
// calculate the bounding rect
updateBounds();
- m_mapLoaded = true;
-
+ m_mapLayers.append(layer);
+ layer->setMapLoaded(true);
+
m_imageLoaded = false;
QString imageFileName = fileName;
imageFileName.truncate(imageFileName.lastIndexOf('.'));
@@ -905,13 +945,15 @@
QString name;
MapLineM* currentLineM = 0;
size_t count;
+ MapLayer* layer = NULL;
// if the same map is already loaded, don't reload it.
- if (m_mapLoaded && (m_fileName.toLower() == fileName.toLower()))
- return;
+ for (int i = 0; i < m_mapLayers.count(); ++i)
+ {
+ if (m_mapLayers[i]->mapLoaded() && m_mapLayers[i]->fileName().toLower() == fileName.toLower())
+ return;
+ }
- // set the map filename
- setFileName(fileName);
// clear any existing map data if not importing
if (!import)
@@ -930,8 +972,10 @@
return;
}
+ layer = new MapLayer();
+
// note the file name
- m_fileName = fileName;
+ layer->setFileName(fileName);
// allocate memory in a QByteArray to hold the entire file contents
QByteArray textData(mapFile.size() + 1, '\0');
@@ -959,7 +1003,7 @@
// use the file base name as the zone long/short name, it isn't perfect,
// but neither is this file format
- QFileInfo fileInfo(m_fileName);
+ QFileInfo fileInfo(fileName);
QRegExp reStripTrailer("_[1-3]");
m_zoneLongName = fileInfo.baseName().remove(reStripTrailer);
@@ -1039,7 +1083,7 @@
currentLineM->setPoint(checkPoint = numPoints++, x1, y1, z1);
// add it to the list of M lines
- m_mLines.append(currentLineM);
+ layer->mLines().append(currentLineM);
}
else
{
@@ -1091,7 +1135,7 @@
name.replace("_", " ");
// add it to the list of locations
- m_locations.append(new MapLocation(name, QColor(r, g, b),
+ layer->locations().append(new MapLocation(name, QColor(r, g, b),
x1, y1, z1));
// adjust map boundaries
@@ -1105,8 +1149,9 @@
// calculate the bounding rect
updateBounds();
- m_mapLoaded = true;
-
+ m_mapLayers.append(layer);
+ layer->setMapLoaded(true);
+
m_imageLoaded = false;
QString imageFileName = fileName;
imageFileName.truncate(imageFileName.lastIndexOf('.'));
@@ -1121,7 +1166,7 @@
seqInfo("Loaded SOE map: '%s'", fileName.toLatin1().data());
}
-void MapData::saveMap(const QString& fileName) const
+void MapData::saveMap(const QString& fileName, const uint8_t layerNum) const
{
#ifdef DEBUG
qDebug ("saveMap()");
@@ -1129,15 +1174,9 @@
FILE * fh;
uint32_t i;
- QString filename;
- if (!fileName.isEmpty())
- filename = fileName;
- else
- filename = m_fileName;
-
- if ((fh = fopen(filename.toLatin1().data(), "w")) == NULL)
+ if ((fh = fopen(fileName.toLatin1().data(), "w")) == NULL)
{
- seqWarn("Error saving map '%s'!", filename.toLatin1().data());
+ seqWarn("Error saving map '%s'!", fileName.toLatin1().data());
return;
}
@@ -1153,10 +1192,9 @@
bool heightSet = false;
int16_t lastHeightSet = 0;
MapLineL* currentLineL;
- QList<MapLineL*>::const_iterator mlit = m_lLines.begin();
- for (mlit = m_lLines.begin();
- mlit != m_lLines.end() && *mlit != NULL;
- ++mlit)
+ QList<MapLineL*>::const_iterator mlit = m_mapLayers[layerNum]->lLines().begin();
+ for (mlit = m_mapLayers[layerNum]->lLines().begin();
+ mlit != m_mapLayers[layerNum]->lLines().end(); ++mlit)
{
currentLineL = *mlit;
// was the global height set?
@@ -1194,10 +1232,9 @@
// write out the M (3D) lines
MapLineM* currentLineM;
- QList<MapLineM*>::const_iterator mmit = m_mLines.begin();
- for (mmit = m_mLines.begin();
- mmit != m_mLines.end() && *mmit != NULL;
- ++mmit)
+ QList<MapLineM*>::const_iterator mmit = m_mapLayers[layerNum]->mLines().begin();
+ for (mmit = m_mapLayers[layerNum]->mLines().begin();
+ mmit != m_mapLayers[layerNum]->mLines().end(); ++mmit)
{
currentLineM = *mmit;
// write out the start of the line info
@@ -1219,8 +1256,8 @@
}
// write out location information
- QList<MapLocation*>::const_iterator lit = m_locations.begin();
- for(; lit != m_locations.end() && *lit != NULL; ++lit)
+ QList<MapLocation*>::const_iterator lit = m_mapLayers[layerNum]->locations().begin();
+ for(; lit != m_mapLayers[layerNum]->locations().end(); ++lit)
{
MapLocation* currentLoc = *lit;
@@ -1251,16 +1288,17 @@
#ifdef DEBUGMAP
seqDebug("saveMap() - map '%s' saved with %d L lines, %d M lines, %d locations",
- filename.toLatin1().data(),
- m_lLines.count(), m_mLines.count(), m_locations.count());
+ fileName.toLatin1().data(),
+ m_mapLayers[layerNum].m_lLines().count(), m_mapLayers[layerNum].m_mLines().count(),
+ m_mapLayers[layerNum].m_locations().count());
#endif
fclose (fh);
- seqInfo("Saved map: '%s'", filename.toLatin1().data());
+ seqInfo("Saved map: '%s'", fileName.toLatin1().data());
}
-void MapData::saveSOEMap(const QString& fileName) const
+void MapData::saveSOEMap(const QString& fileName, const uint8_t layerNum) const
{
#ifdef DEBUG
qDebug ("saveMap()");
@@ -1268,15 +1306,9 @@
FILE * fh;
uint i;
- QString filename;
- if (!fileName.isEmpty())
- filename = fileName;
- else
- filename = m_fileName;
-
- if ((fh = fopen(filename.toLatin1().data(), "w")) == NULL)
+ if ((fh = fopen(fileName.toLatin1().data(), "w")) == NULL)
{
- seqWarn("Error saving map '%s'!", filename.toLatin1().data());
+ seqWarn("Error saving map '%s'!", fileName.toLatin1().data());
return;
}
@@ -1285,8 +1317,8 @@
float z1;
QString name;
MapLineL* currentLineL;
- QList<MapLineL*>::const_iterator mlit = m_lLines.begin();
- for (; mlit != m_lLines.end() && *mlit != NULL; ++mlit)
+ QList<MapLineL*>::const_iterator mlit = m_mapLayers[layerNum]->lLines().begin();
+ for (; mlit != m_mapLayers[layerNum]->lLines().end(); ++mlit)
{
currentLineL = *mlit;
z1 = float(currentLineL->z());
@@ -1316,10 +1348,10 @@
fprintf (fh, "\n");
}
- // write out the M (3D) lines
+ // write out the M (3D) lines)
MapLineM* currentLineM;
- QList<MapLineM*>::const_iterator mmit = m_mLines.begin();
- for (; mmit != m_mLines.end() && *mmit != NULL; ++mmit)
+ QList<MapLineM*>::const_iterator mmit = m_mapLayers[layerNum]->mLines().begin();
+ for (; mmit != m_mapLayers[layerNum]->mLines().end(); ++mmit)
{
currentLineM = *mmit;
const QColor& color = currentLineM->color();
@@ -1345,9 +1377,9 @@
}
// write out location information
- QList<MapLocation*>::const_iterator lit = m_locations.begin();
+ QList<MapLocation*>::const_iterator lit = m_mapLayers[layerNum]->locations().begin();
MapLocation* currentLoc;
- for (; lit != m_locations.end() && *lit != NULL; ++lit)
+ for (; lit != m_mapLayers[layerNum]->locations().end(); ++lit)
{
currentLoc = *lit;
const QColor& color = currentLoc->color();
@@ -1364,13 +1396,14 @@
}
#ifdef DEBUGMAP
seqDebug("saveMap() - map '%s' saved with %d L lines, %d M lines, %d locations",
- filename.toLatin1().data(),
- m_lLines.count(), m_mLines.count(), m_locations.count());
+ fileName.toLatin1().data(),
+ m_mapLayers[layerNum]->m_lLines().count(), m_mapLayers[layerNum]->m_mLines().count(),
+ m_mapLayers[layerNum]->m_locations().count());
#endif
fclose (fh);
- seqInfo("Saved SOE map: '%s'", filename.toLatin1().data());
+ seqInfo("Saved SOE map: '%s'", fileName.toLatin1().data());
}
bool MapData::isAggro(const QString& name, uint16_t* range) const
@@ -1397,11 +1430,13 @@
const QString& color,
const QPoint& point)
{
+ if (m_editLayer >= m_mapLayers.count())
+ return;
// create the new location
m_editLocation = new MapLocation(name, color, point);
// add it to the list of locations
- m_locations.append(m_editLocation);
+ m_mapLayers[m_editLayer]->locations().append(m_editLocation);
}
void MapData::setLocationName(const QString& name)
@@ -1428,6 +1463,10 @@
const QString& color,
const MapPoint& point)
{
+
+ if (m_editLayer >= m_mapLayers.count())
+ return;
+
// create the new line, with just the first point
m_editLineM = new MapLineM(name, color, point);
@@ -1435,7 +1474,7 @@
m_editLineM->calcBounds();
// add line to the line list
- m_mLines.append(m_editLineM);
+ m_mapLayers[m_editLayer]->mLines().append(m_editLineM);
}
void MapData::addLinePoint(const MapPoint& point)
@@ -1462,6 +1501,9 @@
if (m_editLineM == NULL)
return;
+ if (m_editLayer >= m_mapLayers.count())
+ return;
+
// remove the last entry from the line
m_editLineM->resize(m_editLineM->size() - 1);
@@ -1469,7 +1511,7 @@
if (m_editLineM->size() == 0)
{
// remove the line
- delete m_mLines.takeAt(m_mLines.indexOf(m_editLineM));
+ delete m_mapLayers[m_editLayer]->mLines().takeAt(m_mapLayers[m_editLayer]->mLines().indexOf(m_editLineM));
// clear the currently edited line entry
m_editLineM = NULL;
@@ -1503,10 +1545,14 @@
void MapData::scaleDownZ(int16_t factor)
{
+
+ if (m_editLayer >= m_mapLayers.count())
+ return;
+
// first scale down the L lines
MapLineL* currentLineL;
- QList<MapLineL*>::const_iterator mlit = m_lLines.begin();
- for (; mlit != m_lLines.end() && *mlit != NULL; ++mlit)
+ QList<MapLineL*>::const_iterator mlit = m_mapLayers[m_editLayer]->lLines().begin();
+ for (; mlit != m_mapLayers[m_editLayer]->lLines().end(); ++mlit)
{
currentLineL = *mlit;
currentLineL->setZPos(currentLineL->z() / factor);
@@ -1517,8 +1563,8 @@
MapPoint* mData;
size_t numPoints;
size_t i;
- QList<MapLineM*>::const_iterator mmit = m_mLines.begin();
- for (; mmit != m_mLines.end() && *mmit != NULL; ++mmit)
+ QList<MapLineM*>::const_iterator mmit = m_mapLayers[m_editLayer]->mLines().begin();
+ for (; mmit != m_mapLayers[m_editLayer]->mLines().end(); ++mmit)
{
currentLineM = *mmit;
// get the number of points in the line
@@ -1534,10 +1580,14 @@
void MapData::scaleUpZ(int16_t factor)
{
+
+ if (m_editLayer >= m_mapLayers.count())
+ return;
+
// first scale down the L lines
MapLineL* currentLineL;
- QList<MapLineL*>::const_iterator mlit = m_lLines.begin();
- for (; mlit != m_lLines.end() && *mlit != NULL; ++mlit)
+ QList<MapLineL*>::const_iterator mlit = m_mapLayers[m_editLayer]->lLines().begin();
+ for (; mlit != m_mapLayers[m_editLayer]->lLines().end(); ++mlit)
{
currentLineL = *mlit;
currentLineL->setZPos(currentLineL->z() * factor);
@@ -1548,8 +1598,8 @@
MapPoint* mData;
size_t numPoints;
size_t i;
- QList<MapLineM*>::const_iterator mmit = m_mLines.begin();
- for (; mmit != m_mLines.end() && *mmit != NULL; ++mmit)
+ QList<MapLineM*>::const_iterator mmit = m_mapLayers[m_editLayer]->mLines().begin();
+ for (; mmit != m_mapLayers[m_editLayer]->mLines().end(); ++mmit)
{
currentLineM = *mmit;
// get the number of points in the line
@@ -1686,103 +1736,111 @@
QPoint* lData;
MapPoint* mData;
- // first paint the L lines
- QList<MapLineL*>::const_iterator mlit = m_lLines.begin();
- for (; mlit != m_lLines.end() && *mlit != NULL; ++mlit)
+
+ for (int i = 0; i < m_mapLayers.count(); ++i)
{
- currentLineL = *mlit;
- // if line is outside the currently visible region, skip it.
- if (!currentLineL->boundingRect().intersects(screenBounds))
- continue;
+ MapLayer* layer = m_mapLayers[i];
+ if (!param.isLayerVisible(i))
+ continue;
- // get the number of points in the line
- numPoints = currentLineL->size();
+ // first paint the L lines
+ QList<MapLineL*>::const_iterator mlit = layer->lLines().begin();
+ for (; mlit != layer->lLines().end(); ++mlit)
+ {
+ currentLineL = *mlit;
+ // if line is outside the currently visible region, skip it.
+ if (!currentLineL->boundingRect().intersects(screenBounds))
+ continue;
- // get the underlying array
- lData = currentLineL->data();
+ // get the number of points in the line
+ numPoints = currentLineL->size();
- // set pen color
-#ifdef DEBUGMAP
- seqDebug("lineColor = '%s'", (char *) currentLineL->color());
-#endif
- p.setPen(currentLineL->color());
+ // get the underlying array
+ lData = currentLineL->data();
- cur2DX_1 = lData[0].x();
- cur2DY_1 = lData[0].y();
+ // set pen color
+ #ifdef DEBUGMAP
+ seqDebug("lineColor = '%s'", (char *) currentLineL->color());
+ #endif
+ p.setPen(currentLineL->color());
- // see if the starting position is in bounds
- lastInBounds = inRect(screenBounds, cur2DX_1, cur2DY_1);
+ cur2DX_1 = lData[0].x();
+ cur2DY_1 = lData[0].y();
- // iterate over all the points in the line
- for (uint32_t i = 1; i < numPoints; i++)
- {
- cur2DX_2 = lData[i].x();
- cur2DY_2 = lData[i].y();
+ // see if the starting position is in bounds
+ lastInBounds = inRect(screenBounds, cur2DX_1, cur2DY_1);
- // determine if the current position is in bounds
- curInBounds = inRect(screenBounds, cur2DX_2, cur2DY_2);
+ // iterate over all the points in the line
+ for (uint32_t i = 1; i < numPoints; i++)
+ {
+ cur2DX_2 = lData[i].x();
+ cur2DY_2 = lData[i].y();
- // draw the line segment if either end is in bounds
- if (lastInBounds || curInBounds)
- p.drawLine(param.calcXOffsetI(cur2DX_1),
- param.calcYOffsetI(cur2DY_1),
- param.calcXOffsetI(cur2DX_2),
- param.calcYOffsetI(cur2DY_2));
+ // determine if the current position is in bounds
+ curInBounds = inRect(screenBounds, cur2DX_2, cur2DY_2);
- // current becomes the last
- lastInBounds = curInBounds;
- cur2DX_1 = cur2DX_2;
- cur2DY_1 = cur2DY_2;
+ // draw the line segment if either end is in bounds
+ if (lastInBounds || curInBounds)
+ p.drawLine(param.calcXOffsetI(cur2DX_1),
+ param.calcYOffsetI(cur2DY_1),
+ param.calcXOffsetI(cur2DX_2),
+ param.calcYOffsetI(cur2DY_2));
+
+ // current becomes the last
+ lastInBounds = curInBounds;
+ cur2DX_1 = cur2DX_2;
+ cur2DY_1 = cur2DY_2;
+ }
}
- }
- // then paint the M lines
- QList<MapLineM*>::const_iterator mmit = m_mLines.begin();
- for (; mmit != m_mLines.end() && *mmit != NULL; ++mmit)
- {
- currentLineM = *mmit;
- // if line is outside the currently visible region, skip it.
- if (!currentLineM->boundingRect().intersects(screenBounds))
- continue;
+ // then paint the M lines
+ QList<MapLineM*>::const_iterator mmit = layer->mLines().begin();
+ for (; mmit != layer->mLines().end(); ++mmit)
+ {
+ currentLineM = *mmit;
+ // if line is outside the currently visible region, skip it.
+ if (!currentLineM->boundingRect().intersects(screenBounds))
+ continue;
- // get the number of points in the line
- numPoints = currentLineM->size();
+ // get the number of points in the line
+ numPoints = currentLineM->size();
- // get the underlying array
- mData = currentLineM->data();
+ // get the underlying array
+ mData = currentLineM->data();
- // set pen color
-#ifdef DEBUGMAP
- seqDebug("lineColor = '%s'", (char *) currentLineM->color());
-#endif
- p.setPen(currentLineM->color());
+ // set pen color
+ #ifdef DEBUGMAP
+ seqDebug("lineColor = '%s'", (char *) currentLineM->color());
+ #endif
+ p.setPen(currentLineM->color());
- curX_1 = mData[0].x();
- curY_1 = mData[0].y();
+ curX_1 = mData[0].x();
+ curY_1 = mData[0].y();
- // see if the starting position is in bounds
- lastInBounds = inRect(screenBounds, curX_1, curY_1);
+ // see if the starting position is in bounds
+ lastInBounds = inRect(screenBounds, curX_1, curY_1);
- // iterate over all the points in the line
- for (uint32_t i = 1; i < numPoints; i++)
- {
- curX_2 = mData[i].x();
- curY_2 = mData[i].y();
+ // iterate over all the points in the line
+ for (uint32_t i = 1; i < numPoints; i++)
+ {
+ curX_2 = mData[i].x();
+ curY_2 = mData[i].y();
- // determine if the current position is in bounds
- curInBounds = inRect(screenBounds, curX_2, curY_2);
+ // determine if the current position is in bounds
+ curInBounds = inRect(screenBounds, curX_2, curY_2);
- // draw the line segment if either end is in bounds
- if (lastInBounds || curInBounds)
- p.drawLine(param.calcXOffsetI(curX_1),
- param.calcYOffsetI(curY_1),
- param.calcXOffsetI(curX_2),
- param.calcYOffsetI(curY_2));
+ // draw the line segment if either end is in bounds
+ if (lastInBounds || curInBounds)
+ p.drawLine(param.calcXOffsetI(curX_1),
+ param.calcYOffsetI(curY_1),
+ param.calcXOffsetI(curX_2),
+ param.calcYOffsetI(curY_2));
- // current becomes the last
- lastInBounds = curInBounds;
- curX_1 = curX_2;
- curY_1 = curY_2;
+ // current becomes the last
+ lastInBounds = curInBounds;
+ curX_1 = curX_2;
+ curY_1 = curY_2;
+ }
}
}
}
@@ -1820,120 +1878,127 @@
// get the players position for it's Z information
MapPoint playerPos = param.player();
- // first paint the L lines
- QList<MapLineL*>::const_iterator mlit = m_lLines.begin();
- for (; mlit != m_lLines.end() && *mlit != NULL; ++mlit)
+ for (int i = 0; i < m_mapLayers.count(); ++i)
{
- currentLineL = *mlit;
- // if line is outside the currently visible region, skip it.
- if (!currentLineL->boundingRect().intersects(screenBounds))
- continue;
+ MapLayer* layer = m_mapLayers[i];
+ if (!param.isLayerVisible(i))
+ continue;
- // since it's an L type line, check for the depth is easy
- // just check if height is set, and if so, check if it's within range
- if (currentLineL->heightSet() &&
- !inRoom(param.playerHeadRoom(), param.playerFloorRoom(),
- currentLineL->z()))
- continue; // outside of range, continue to the next line
+ // first paint the L lines
+ QList<MapLineL*>::const_iterator mlit = layer->lLines().begin();
+ for (; mlit != layer->lLines().end(); ++mlit)
+ {
+ currentLineL = *mlit;
+ // if line is outside the currently visible region, skip it.
+ if (!currentLineL->boundingRect().intersects(screenBounds))
+ continue;
- // get the number of points in the line
- numPoints = currentLineL->size();
+ // since it's an L type line, check for the depth is easy
+ // just check if height is set, and if so, check if it's within range
+ if (currentLineL->heightSet() &&
+ !inRoom(param.playerHeadRoom(), param.playerFloorRoom(),
+ currentLineL->z()))
+ continue; // outside of range, continue to the next line
- // get the underlying array
- lData = currentLineL->data();
+ // get the number of points in the line
+ numPoints = currentLineL->size();
- // set the line color
-#ifdef DEBUGMAP
- seqDebug("lineColor = '%s'", (char *) currentLineL->color());
-#endif
- p.setPen(currentLineL->color());
+ // get the underlying array
+ lData = currentLineL->data();
- cur2DX_1 = lData[0].x();
- cur2DY_1 = lData[0].y();
+ // set the line color
+ #ifdef DEBUGMAP
+ seqDebug("lineColor = '%s'", (char *) currentLineL->color());
+ #endif
+ p.setPen(currentLineL->color());
- // see if the starting position is in bounds
- lastInBounds = inRect(screenBounds, cur2DX_1, cur2DY_1);
+ cur2DX_1 = lData[0].x();
+ cur2DY_1 = lData[0].y();
- // iterate over all the points in the line
- for (uint32_t i = 1; i < numPoints; i++)
- {
- cur2DX_2 = lData[i].x();
- cur2DY_2 = lData[i].y();
+ // see if the starting position is in bounds
+ lastInBounds = inRect(screenBounds, cur2DX_1, cur2DY_1);
- // determine if the current position is in bounds
- curInBounds = inRect(screenBounds, cur2DX_2, cur2DY_2);
+ // iterate over all the points in the line
+ for (uint32_t i = 1; i < numPoints; i++)
+ {
+ cur2DX_2 = lData[i].x();
+ cur2DY_2 = lData[i].y();
- // draw the line segment if either end is in bounds
- if (lastInBounds || curInBounds)
- p.drawLine(param.calcXOffsetI(cur2DX_1),
- param.calcYOffsetI(cur2DY_1),
- param.calcXOffsetI(cur2DX_2),
- param.calcYOffsetI(cur2DY_2));
+ // determine if the current position is in bounds
+ curInBounds = inRect(screenBounds, cur2DX_2, cur2DY_2);
- // current becomes the last
- lastInBounds = curInBounds;
- cur2DX_1 = cur2DX_2;
- cur2DY_1 = cur2DY_2;
+ // draw the line segment if either end is in bounds
+ if (lastInBounds || curInBounds)
+ p.drawLine(param.calcXOffsetI(cur2DX_1),
+ param.calcYOffsetI(cur2DY_1),
+ param.calcXOffsetI(cur2DX_2),
+ param.calcYOffsetI(cur2DY_2));
+
+ // current becomes the last
+ lastInBounds = curInBounds;
+ cur2DX_1 = cur2DX_2;
+ cur2DY_1 = cur2DY_2;
+ }
}
- }
- // then paint the M lines
- QList<MapLineM*>::const_iterator mmit = m_mLines.begin();
- for (; mmit != m_mLines.end() && *mmit != NULL; ++mmit)
- {
- currentLineM = *mmit;
- // if line is outside the currently visible region, skip it.
- if (!currentLineM->boundingRect().intersects(screenBounds))
- continue;
+ // then paint the M lines
+ QList<MapLineM*>::const_iterator mmit = layer->mLines().begin();
+ for (; mmit != layer->mLines().end(); ++mmit)
+ {
+ currentLineM = *mmit;
+ // if line is outside the currently visible region, skip it.
+ if (!currentLineM->boundingRect().intersects(screenBounds))
+ continue;
- // get the number of points in the line
- numPoints = currentLineM->size();
+ // get the number of points in the line
+ numPoints = currentLineM->size();
- // get the underlying array
- mData = currentLineM->data();
+ // get the underlying array
+ mData = currentLineM->data();
- // set the line color
-#ifdef DEBUGMAP
- seqDebug("lineColor = '%s'", (char *) currentLineM->color());
-#endif
- p.setPen(currentLineM->color());
+ // set the line color
+ #ifdef DEBUGMAP
+ seqDebug("lineColor = '%s'", (char *) currentLineM->color());
+ #endif
+ p.setPen(currentLineM->color());
- // get current coordinates
- curX_1 = mData[0].x();
- curY_1 = mData[0].y();
- curZ_1 = mData[0].z();
+ // get current coordinates
+ curX_1 = mData[0].x();
+ curY_1 = mData[0].y();
+ curZ_1 = mData[0].z();
- // see if the starting position is in bounds
- lastInBounds = (inRect(screenBounds, curX_1, curY_1) &&
- inRoom(param.playerHeadRoom(), param.playerFloorRoom(), curZ_1));
+ // see if the starting position is in bounds
+ lastInBounds = (inRect(screenBounds, curX_1, curY_1) &&
+ inRoom(param.playerHeadRoom(), param.playerFloorRoom(), curZ_1));
-#ifdef DEBUGMAP
- seqDebug("Line has %i points:", currentLineM->size());
-#endif
+ #ifdef DEBUGMAP
+ seqDebug("Line has %i points:", currentLineM->size());
+ #endif
- // iterate over all the points in the line
- for (uint32_t i = 1; i < numPoints; i++)
- {
- // get current coordinates
- curX_2 = mData[i].x();
- curY_2 = mData[i].y();
- curZ_2 = mData[i].z();
+ // iterate over all the points in the line
+ for (uint32_t i = 1; i < numPoints; i++)
+ {
+ // get current coordinates
+ curX_2 = mData[i].x();
+ curY_2 = mData[i].y();
+ curZ_2 = mData[i].z();
- // determine if the current position is in bounds
- curInBounds = (inRect(screenBounds, curX_2, curY_2) &&
- inRoom(param.playerHeadRoom(), param.playerFloorRoom(), curZ_2));
+ // determine if the current position is in bounds
+ curInBounds = (inRect(screenBounds, curX_2, curY_2) &&
+ inRoom(param.playerHeadRoom(), param.playerFloorRoom(), curZ_2));
- // draw the line segment if either end is in bounds
- if (lastInBounds || curInBounds)
- p.drawLine(param.calcXOffsetI(curX_1),
- param.calcYOffsetI(curY_1),
- param.calcXOffsetI(curX_2),
- param.calcYOffsetI(curY_2));
+ // draw the line segment if either end is in bounds
+ if (lastInBounds || curInBounds)
+ p.drawLine(param.calcXOffsetI(curX_1),
+ param.calcYOffsetI(curY_1),
+ param.calcXOffsetI(curX_2),
+ param.calcYOffsetI(curY_2));
- // current becomes the last
- lastInBounds = curInBounds;
- curX_1 = curX_2;
- curY_1 = curY_2;
+ // current becomes the last
+ lastInBounds = curInBounds;
+ curX_1 = curX_2;
+ curY_1 = curY_2;
+ }
}
}
}
@@ -1977,158 +2042,165 @@
double topb = 255 - (topm * playerPos.z());
double botb = 255 - (botm * playerPos.z());
- // first paint the L lines
- QList<MapLineL*>::const_iterator mlit = m_lLines.begin();
- for (; mlit != m_lLines.end() && *mlit != NULL; ++mlit)
+ for (int i = 0; i < m_mapLayers.count(); ++i)
{
- currentLineL = *mlit;
- // if line is outside the currently visible region, skip it.
- if (!currentLineL->boundingRect().intersects(screenBounds))
- continue;
+ MapLayer* layer = m_mapLayers[i];
+ if (!param.isLayerVisible(i))
+ continue;
- // get the number of points in the line
- numPoints = currentLineL->size();
+ // first paint the L lines
+ QList<MapLineL*>::const_iterator mlit = layer->lLines().begin();
+ for (; mlit != layer->lLines().end(); ++mlit)
+ {
+ currentLineL = *mlit;
+ // if line is outside the currently visible region, skip it.
+ if (!currentLineL->boundingRect().intersects(screenBounds))
+ continue;
- // get the underlying array
- lData = currentLineL->data();
+ // get the number of points in the line
+ numPoints = currentLineL->size();
- // get first point coordinates
- cur2DX_1 = lData[0].x();
- cur2DY_1 = lData[0].y();
- cur2DZ_1 = currentLineL->z();
+ // get the underlying array
+ lData = currentLineL->data();
- // color determination is different depending on if a height was set
- if (!currentLineL->heightSet())
- {
- // set the line color
-#ifdef DEBUGMAP
- seqDebug("lineColor = '%s'", (char *) currentLineL->color());
-#endif
- p.setPen(currentLineL->color());
- }
- else
- {
- // calculate color to use for the line (since L type, only do this once)
- if (currentLineL->z() > playerPos.z())
- useColor = (int)((cur2DZ_1 * topm) + topb);
- else
- useColor = (int)((cur2DZ_1 * botm) + botb);
+ // get first point coordinates
+ cur2DX_1 = lData[0].x();
+ cur2DY_1 = lData[0].y();
+ cur2DZ_1 = currentLineL->z();
- if (useColor > 255) useColor = 255;
- if (useColor < 0) useColor = 0;
+ // color determination is different depending on if a height was set
+ if (!currentLineL->heightSet())
+ {
+ // set the line color
+ #ifdef DEBUGMAP
+ seqDebug("lineColor = '%s'", (char *) currentLineL->color());
+ #endif
+ p.setPen(currentLineL->color());
+ }
+ else
+ {
+ // calculate color to use for the line (since L type, only do this once)
+ if (currentLineL->z() > playerPos.z())
+ useColor = (int)((cur2DZ_1 * topm) + topb);
+ else
+ useColor = (int)((cur2DZ_1 * botm) + botb);
- // set the line color
-#ifdef DEBUGMAP
- seqDebug("lineColor = '#%2x%2x%2x'", useColor, useColor, useColor);
-#endif
- p.setPen(QColor(useColor, useColor, useColor));
- }
+ if (useColor > 255) useColor = 255;
+ if (useColor < 0) useColor = 0;
- // see if the starting position is in bounds
- lastInBounds = inRect(screenBounds, cur2DX_1, cur2DY_1);
+ // set the line color
+ #ifdef DEBUGMAP
+ seqDebug("lineColor = '#%2x%2x%2x'", useColor, useColor, useColor);
+ #endif
+ p.setPen(QColor(useColor, useColor, useColor));
+ }
- // iterate over all the points in the line
- for (uint32_t i = 1; i < numPoints; i++)
- {
- // get coordinates
- cur2DX_2 = lData[i].x();
- cur2DY_2 = lData[i].y();
+ // see if the starting position is in bounds
+ lastInBounds = inRect(screenBounds, cur2DX_1, cur2DY_1);
- // determine if the current position is in bounds
- curInBounds = inRect(screenBounds, cur2DX_2, cur2DY_2);
+ // iterate over all the points in the line
+ for (uint32_t i = 1; i < numPoints; i++)
+ {
+ // get coordinates
+ cur2DX_2 = lData[i].x();
+ cur2DY_2 = lData[i].y();
- // draw the line segment if either end is in bounds
- if (lastInBounds || curInBounds)
- p.drawLine(param.calcXOffsetI(cur2DX_1),
- param.calcYOffsetI(cur2DY_1),
- param.calcXOffsetI(cur2DX_2),
- param.calcYOffsetI(cur2DY_2));
+ // determine if the current position is in bounds
+ curInBounds = inRect(screenBounds, cur2DX_2, cur2DY_2);
- // current becomes the last
- lastInBounds = curInBounds;
- cur2DX_1 = cur2DX_2;
- cur2DY_1 = cur2DY_2;
+ // draw the line segment if either end is in bounds
+ if (lastInBounds || curInBounds)
+ p.drawLine(param.calcXOffsetI(cur2DX_1),
+ param.calcYOffsetI(cur2DY_1),
+ param.calcXOffsetI(cur2DX_2),
+ param.calcYOffsetI(cur2DY_2));
+
+ // current becomes the last
+ lastInBounds = curInBounds;
+ cur2DX_1 = cur2DX_2;
+ cur2DY_1 = cur2DY_2;
+ }
}
- }
- // then paint the M lines
- QList<MapLineM*>::const_iterator mmit = m_mLines.begin();
- for (; mmit != m_mLines.end() && *mmit != NUL...
[truncated message content] |