- implemented automap color parser for MAPINFO (code not tested yet!)

This commit is contained in:
Christoph Oelckers 2013-08-02 16:56:42 +02:00
parent 845020c617
commit aa72857c72
4 changed files with 133 additions and 0 deletions

View File

@ -83,6 +83,7 @@ CVAR (Bool, am_showitems, false, CVAR_ARCHIVE);
CVAR (Bool, am_showtime, true, CVAR_ARCHIVE);
CVAR (Bool, am_showtotaltime, false, CVAR_ARCHIVE);
CVAR (Int, am_colorset, 0, CVAR_ARCHIVE);
CVAR (Bool, am_customcolors, true, CVAR_ARCHIVE);
CVAR (Int, am_map_secrets, 1, CVAR_ARCHIVE);
CVAR (Bool, am_drawmapback, true, CVAR_ARCHIVE);
CVAR (Bool, am_showkeys, true, CVAR_ARCHIVE);
@ -177,6 +178,32 @@ struct AMColor
//
//=============================================================================
static const char *ColorNames[] = {
"Background",
"YourColor",
"WallColor",
"TwoSidedWallColor",
"FloorDiffWallColor",
"CeilingDiffWallColor",
"ExtraFloorWallColor",
"ThingColor",
"ThingColor_Item",
"ThingColor_CountItem",
"ThingColor_Monster",
"ThingColor_Friend",
"SpecialWallColor",
"SecretWallColor",
"GridColor",
"XHairColor",
"NotSeenColor",
"LockedColor",
"IntraTeleportColor",
"InterTeleportColor",
"SecretSectorColor",
"AlmostBackgroundColor",
NULL
};
struct AMColorset
{
enum
@ -209,6 +236,7 @@ struct AMColorset
AMColor c[AM_NUM_COLORS];
bool displayLocks;
bool forcebackground;
bool defined; // only for mod specific colorsets: must be true to be usable
void initFromCVars(FColorCVar **values)
{
@ -252,6 +280,15 @@ struct AMColorset
forcebackground = false;
}
void setWhite()
{
c[0].FromRGB(0,0,0);
for(int i=1; i<AM_NUM_COLORS; i++)
{
c[i].FromRGB(255,255,255);
}
}
const AMColor &operator[](int index) const
{
return c[index];
@ -397,8 +434,86 @@ static unsigned char RavenColors[]= {
#undef NOT_USED
static AMColorset AMColors;
static AMColorset AMMod;
//=============================================================================
//
//
//
//=============================================================================
void FMapInfoParser::ParseAMColors()
{
bool colorset = false;
AMMod.setWhite();
AMMod.defined = true;
sc.MustGetToken('{');
while(sc.GetToken())
{
if (sc.TokenType == '}') return;
sc.TokenMustBe(TK_Identifier);
FString nextKey = sc.String;
sc.MustGetToken('=');
if (nextKey.CompareNoCase("base") == 0)
{
if (colorset) sc.ScriptError("'base' must be specified before the first color");
sc.MustGetToken(TK_StringConst);
if (sc.Compare("doom"))
{
AMMod.initFromColors(DoomColors, false);
}
else if (sc.Compare("raven"))
{
AMMod.initFromColors(RavenColors, true);
}
else if (sc.Compare("strife"))
{
AMMod.initFromColors(StrifeColors, false);
}
else
{
sc.ScriptError("Unknown value for 'base'. Must be 'Doom', 'Strife' or 'Raven'.");
}
}
else if (nextKey.CompareNoCase("showlocks") == 0)
{
if(sc.CheckToken(TK_False))
AMMod.displayLocks = false;
else
{
sc.MustGetToken(TK_True);
AMMod.displayLocks = true;
}
}
else
{
int i;
for (i = 0; ColorNames[i] != NULL; i++)
{
if (nextKey.CompareNoCase(ColorNames[i]) == 0)
{
sc.MustGetToken(TK_StringConst);
FString color = sc.String;
FString colorName = V_GetColorStringByName(color);
if(!colorName.IsEmpty()) color = colorName;
int colorval = V_GetColorFromString(NULL, color);
AMMod.c[i].FromRGB(RPART(colorval), GPART(colorval), BPART(colorval));
colorset = true;
break;
}
}
if (ColorNames[i]== NULL)
{
sc.ScriptError("Unknown key '%s'", nextKey.GetChars());
}
}
}
}
//=============================================================================
//
//
@ -1131,6 +1246,10 @@ static void AM_initColors (bool overlayed)
{
AMColors.initFromCVars(cv_overlay);
}
else if (am_customcolors && AMMod.defined)
{
AMColors = AMMod;
}
else switch(am_colorset)
{
default:

View File

@ -103,6 +103,7 @@ struct FMapInfoParser
void ParseIntermissionAction(FIntermissionDescriptor *Desc);
void ParseIntermission();
void ParseAMColors();
FName CheckEndSequence();
FName ParseEndGame();
};

View File

@ -1842,6 +1842,18 @@ void FMapInfoParser::ParseMapInfo (int lump, level_info_t &gamedefaults, level_i
sc.ScriptError("intermission definitions not supported with old MAPINFO syntax");
}
}
else if (sc.Compare("automap"))
{
if (format_type != FMT_Old)
{
format_type = FMT_New;
ParseAMColors();
}
else
{
sc.ScriptError("automap colorset definitions not supported with old MAPINFO syntax");
}
}
else
{
sc.ScriptError("%s: Unknown top level keyword", sc.String);

View File

@ -924,6 +924,7 @@ OptionMenu AutomapOptions
{
Title "AUTOMAP OPTIONS"
Option "Map color set", "am_colorset", "MapColorTypes"
Option "Allow map defined colors" "am_customcolors", "YesNo"
Submenu "Set custom colors", "MapColorMenu"
Submenu "Customize map controls", "MapControlsMenu"
StaticText " "