|
From: <cn...@us...> - 2021-10-27 17:04:21
|
Revision: 1206
http://sourceforge.net/p/seq/svn/1206
Author: cn187
Date: 2021-10-27 17:04:19 +0000 (Wed, 27 Oct 2021)
Log Message:
-----------
Adjust colors on load of SOE formatted map
When an SOE formatted map is loaded, automatically adjust colors in the
same way that colors were adjusted by the mapconvert script. This
should make the SOE-formatted maps easier to see/read on SEQ's dark map
background.
Note: the original colors are preserved if the map is saved back to the
SOE format after modification.
Modified Paths:
--------------
showeq/branches/cn187_devel/src/mapcore.cpp
showeq/branches/cn187_devel/src/mapcore.h
Modified: showeq/branches/cn187_devel/src/mapcore.cpp
===================================================================
--- showeq/branches/cn187_devel/src/mapcore.cpp 2021-10-21 11:16:43 UTC (rev 1205)
+++ showeq/branches/cn187_devel/src/mapcore.cpp 2021-10-27 17:04:19 UTC (rev 1206)
@@ -1066,15 +1066,21 @@
if (!currentLineM ||
!currentLineM->point(checkPoint).isEqual(x2, y2, z2) ||
- (currentLineM->color().red() != r) ||
- (currentLineM->color().green() != g) ||
- (currentLineM->color().blue() != b))
+ (
+ ((currentLineM->color().red() != r) ||
+ (currentLineM->color().green() != g) ||
+ (currentLineM->color().blue() != b)) &&
+ ((currentLineM->origColor().red() != r) ||
+ (currentLineM->origColor().green() != g) ||
+ (currentLineM->origColor().blue() != b))
+ ))
{
numPoints = 0;
// create an M line (start with 2 points because of SOE's lame
// format).
- currentLineM = new MapLineM("soe", QColor(r, g, b), 2);
+ currentLineM = new MapLineM("soe", getMapConvertColor(r, g, b), 2);
+ currentLineM->setOrigColor(QColor(r, g, b));
// set the first point
currentLineM->setPoint(numPoints++, x2, y2, z2);
@@ -1135,8 +1141,10 @@
name.replace("_", " ");
// add it to the list of locations
- layer->locations().append(new MapLocation(name, QColor(r, g, b),
- x1, y1, z1));
+ MapLocation* loc = new MapLocation(name, getMapConvertColor(r, g, b),
+ x1, y1, z1);
+ loc->setOrigColor(QColor(r, g, b));
+ layer->locations().append(loc);
// adjust map boundaries
quickCheckPos(x1, y1);
@@ -1323,7 +1331,7 @@
currentLineL = *mlit;
z1 = float(currentLineL->z());
- const QColor& color = currentLineL->color();
+ const QColor& color = currentLineL->origColor().isValid() ? currentLineL->color() : currentLineL->origColor();
r = color.red();
g = color.green();
b = color.blue();
@@ -1354,7 +1362,7 @@
for (; mmit != m_mapLayers[layerNum]->mLines().end(); ++mmit)
{
currentLineM = *mmit;
- const QColor& color = currentLineM->color();
+ const QColor& color = currentLineM->origColor().isValid() ? currentLineM->color() : currentLineM->origColor();
r = color.red();
g = color.green();
b = color.blue();
@@ -1382,7 +1390,7 @@
for (; lit != m_mapLayers[layerNum]->locations().end(); ++lit)
{
currentLoc = *lit;
- const QColor& color = currentLoc->color();
+ const QColor& color = currentLoc->origColor().isValid() ? currentLoc->color() : currentLoc->origColor();
// convert spaces to underscores
name = currentLoc->name();
Modified: showeq/branches/cn187_devel/src/mapcore.h
===================================================================
--- showeq/branches/cn187_devel/src/mapcore.h 2021-10-21 11:16:43 UTC (rev 1205)
+++ showeq/branches/cn187_devel/src/mapcore.h 2021-10-27 17:04:19 UTC (rev 1206)
@@ -406,15 +406,19 @@
const QString& name() const { return m_name; }
const QColor& color() const { return m_color; }
+ const QColor& origColor() const { return m_origColor; }
QString colorName() const;
void setName(const QString& name) { m_name = name; }
void setColor(const QString& color) { m_color = color; }
+ void setOrigColor(const QColor& color) { m_origColor = color; }
+
private:
QString m_name;
QString m_colorName;
QColor m_color;
+ QColor m_origColor;
};
inline QString MapCommon::colorName() const
@@ -727,4 +731,85 @@
(z >= floorRoom));
}
+inline QString getMapConvertColor(const unsigned short r, const unsigned short g,
+ const unsigned short b)
+{
+ //adjust, convert, and return colors based on Razzle's original mapconvert script
+ //This adjusts the SOE map colors to colors that work for SEQs default color scheme
+
+ QString sColor[64] = {
+ "Black", //0
+ "DarkRed", //1
+ "FireBrick", //2
+ "Red", //3
+ "DarkGreen", //4
+ "Orange", //5
+ "DarkOrange", //6
+ "DarkOrange", //7
+ "Green", //8
+ "Chartreuse", //9
+ "Gold", //10
+ "Gold", //11
+ "Green", //12
+ "Chartreuse", //13
+ "Goldenrod", //14
+ "Yellow", //15
+ "DarkBlue", //16
+ "Magenta", //17
+ "DeepPink", //18
+ "DeepPink", //19
+ "DarkCyan", //20
+ "Grey", //21
+ "IndianRed", //22
+ "LightCoral", //23
+ "SpringGreen", //24
+ "LightGreen", //25
+ "DarkKhaki", //26
+ "Khaki", //27
+ "SpringGreen", //28
+ "PaleGreen", //29
+ "DarkOliveGreen",//30
+ "Khaki", //31
+ "MediumBlue", //32
+ "DarkViolet", //33
+ "Magenta", //34
+ "Maroon", //35
+ "RoyalBlue", //36
+ "SlateBlue", //37
+ "Orchid", //38
+ "HotPink", //39
+ "Turquoise", //40
+ "SkyBlue", //41
+ "Snow", //42
+ "LightPink", //43
+ "Cyan", //44
+ "Aquamarine", //45
+ "DarkSeaGreen", //46
+ "Beige", //47
+ "Blue", //48
+ "Purple", //49
+ "Purple", //50
+ "Magenta", //51
+ "DodgerBlue", //52
+ "SlateBlue", //53
+ "MediumPurple", //54
+ "Orchid", //55
+ "DeepSkyBlue", //56
+ "LightBlue", //57
+ "Plum", //58
+ "Cyan", //59
+ "CadetBlue", //60
+ "PaleTurquoise",//61
+ "LightCyan", //62
+ "White" //63
+ };
+
+ unsigned short color = floor(r/80) + floor(g/80)*4 + floor(b/80)*16;
+
+ if (color == 0) return sColor[63];
+
+ return sColor[color];
+}
+
+
#endif // _MAPCORE_H
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|