<?php
function getColoredMapName($mapName)
{
$mapWithColors = "";
$hasColorChanged = 0;
$isAlwaysGray = 0;
// Parses the original map name and adds the appropriate font tags according to the special characters we find
// This can easily be replaced with span tags instead of font tags for XHTML compliance.
for($i = 0; $i < strlen($mapName); $i++)
{
$curChar = substr($mapName, $i, 1);
if(ord($curChar) < 32)
{
if(!$isAlwaysGray)
{
if($hasColorChanged)
$mapWithColors .= "</font>";
switch(ord($curChar))
{
// Light Green
case 1:
$mapWithColors .= "<font color=\"#B7FC78\">";
$hasColorChanged = 1;
break;
// Light Blue
case 2:
$mapWithColors .= "<font color=\"#A7B7F8\">";
$hasColorChanged = 1;
break;
// Dark Green
case 3:
$mapWithColors .= "<font color=\"#09E100\">";
$hasColorChanged = 1;
break;
// Light Green (same as #1)
case 4:
$mapWithColors .= "<font color=\"#B7FC78\">";
$hasColorChanged = 1;
break;
// Gray and all following characters will remain gray even if another color tag is set
case 5:
$mapWithColors .= "<font color=\"#7C7C7C\">";
$hasColorChanged = 1;
$isAlwaysGray = 1;
break;
// White
case 6:
$mapWithColors .= "<font color=\"#FCFCF0\">";
$hasColorChanged = 1;
break;
// Red
case 7:
$mapWithColors .= "<font color=\"#FC0000\">";
$hasColorChanged = 1;
break;
default:
break;
}
}
}
else
$mapWithColors .= $curChar;
}
// Closes the last <font> tag and returns
if($hasColorChanged)
{
$mapWithColors .= "</font>";
return $mapWithColors;
}
return $mapName;
}
?>