mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
DECORATE support: added a warning when a sprite assigned using "$sprite" special comment does not exist.
This commit is contained in:
parent
c11d5302c1
commit
0e718c9780
1 changed files with 57 additions and 55 deletions
|
@ -589,70 +589,72 @@ namespace CodeImp.DoomBuilder.ZDoom
|
||||||
// Sprite forced?
|
// Sprite forced?
|
||||||
if(HasPropertyWithValue("$sprite"))
|
if(HasPropertyWithValue("$sprite"))
|
||||||
{
|
{
|
||||||
return GetPropertyValueString("$sprite", 0);
|
string sprite = GetPropertyValueString("$sprite", 0); //mxd
|
||||||
|
if(General.Map.Data.GetSpriteExists(sprite)) return sprite; //mxd. Added availability check
|
||||||
|
|
||||||
|
//mxd. Bitch and moan
|
||||||
|
General.ErrorLogger.Add(ErrorType.Warning, "DECORATE warning in " + classname + ":" + doomednum + ". The sprite \"" + sprite + "\" assigned by the \"$sprite\" property does not exist.");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Try the idle state
|
||||||
|
if(HasState("idle"))
|
||||||
{
|
{
|
||||||
// Try the idle state
|
StateStructure s = GetState("idle");
|
||||||
if(HasState("idle"))
|
string spritename = s.GetSprite(0);
|
||||||
|
if(!string.IsNullOrEmpty(spritename))
|
||||||
|
result = spritename;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try the see state
|
||||||
|
if(string.IsNullOrEmpty(result) && HasState("see"))
|
||||||
|
{
|
||||||
|
StateStructure s = GetState("see");
|
||||||
|
string spritename = s.GetSprite(0);
|
||||||
|
if(!string.IsNullOrEmpty(spritename))
|
||||||
|
result = spritename;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try the inactive state
|
||||||
|
if(string.IsNullOrEmpty(result) && HasState("inactive"))
|
||||||
|
{
|
||||||
|
StateStructure s = GetState("inactive");
|
||||||
|
string spritename = s.GetSprite(0);
|
||||||
|
if(!string.IsNullOrEmpty(spritename))
|
||||||
|
result = spritename;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try the spawn state
|
||||||
|
if(string.IsNullOrEmpty(result) && HasState("spawn"))
|
||||||
|
{
|
||||||
|
StateStructure s = GetState("spawn");
|
||||||
|
string spritename = s.GetSprite(0);
|
||||||
|
if(!string.IsNullOrEmpty(spritename))
|
||||||
|
result = spritename;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Still no sprite found? then just pick the first we can find
|
||||||
|
if(string.IsNullOrEmpty(result))
|
||||||
|
{
|
||||||
|
Dictionary<string, StateStructure> list = GetAllStates();
|
||||||
|
foreach(StateStructure s in list.Values)
|
||||||
{
|
{
|
||||||
StateStructure s = GetState("idle");
|
|
||||||
string spritename = s.GetSprite(0);
|
string spritename = s.GetSprite(0);
|
||||||
if(!string.IsNullOrEmpty(spritename))
|
if(!string.IsNullOrEmpty(spritename))
|
||||||
result = spritename;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try the see state
|
|
||||||
if(string.IsNullOrEmpty(result) && HasState("see"))
|
|
||||||
{
|
|
||||||
StateStructure s = GetState("see");
|
|
||||||
string spritename = s.GetSprite(0);
|
|
||||||
if(!string.IsNullOrEmpty(spritename))
|
|
||||||
result = spritename;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try the inactive state
|
|
||||||
if(string.IsNullOrEmpty(result) && HasState("inactive"))
|
|
||||||
{
|
|
||||||
StateStructure s = GetState("inactive");
|
|
||||||
string spritename = s.GetSprite(0);
|
|
||||||
if(!string.IsNullOrEmpty(spritename))
|
|
||||||
result = spritename;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try the spawn state
|
|
||||||
if(string.IsNullOrEmpty(result) && HasState("spawn"))
|
|
||||||
{
|
|
||||||
StateStructure s = GetState("spawn");
|
|
||||||
string spritename = s.GetSprite(0);
|
|
||||||
if(!string.IsNullOrEmpty(spritename))
|
|
||||||
result = spritename;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Still no sprite found? then just pick the first we can find
|
|
||||||
if(string.IsNullOrEmpty(result))
|
|
||||||
{
|
|
||||||
Dictionary<string, StateStructure> list = GetAllStates();
|
|
||||||
foreach(StateStructure s in list.Values)
|
|
||||||
{
|
{
|
||||||
string spritename = s.GetSprite(0);
|
result = spritename;
|
||||||
if(!string.IsNullOrEmpty(spritename))
|
break;
|
||||||
{
|
|
||||||
result = spritename;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(!string.IsNullOrEmpty(result))
|
|
||||||
|
if(!string.IsNullOrEmpty(result))
|
||||||
|
{
|
||||||
|
// The sprite name is not actually complete, we still have to append
|
||||||
|
// the direction characters to it. Find an existing sprite with direction.
|
||||||
|
foreach(string postfix in SPRITE_POSTFIXES)
|
||||||
{
|
{
|
||||||
// The sprite name is not actually complete, we still have to append
|
if(General.Map.Data.GetSpriteExists(result + postfix))
|
||||||
// the direction characters to it. Find an existing sprite with direction.
|
return result + postfix;
|
||||||
foreach(string postfix in SPRITE_POSTFIXES)
|
|
||||||
{
|
|
||||||
if(General.Map.Data.GetSpriteExists(result + postfix))
|
|
||||||
return result + postfix;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue