mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-27 14:12:16 +00:00
5212079f5f
Added "Next View Mode" and "Previous View Mode" actions. Removed "Replace unused textures" checkboxes from Edit Linedefs window. Fixed, SNDINFO parser: commented $ambient sound definitions were treated as editor comments (and still processed).
95 lines
2.2 KiB
C#
95 lines
2.2 KiB
C#
#region ================== Namespaces
|
|
|
|
using System.Collections.Generic;
|
|
using CodeImp.DoomBuilder.Config;
|
|
using CodeImp.DoomBuilder.Data;
|
|
|
|
#endregion
|
|
|
|
namespace CodeImp.DoomBuilder.ZDoom
|
|
{
|
|
internal sealed class SndInfoParser : ZDTextParser
|
|
{
|
|
#region ================== Variables
|
|
|
|
private Dictionary<int, string> ambientsounds;
|
|
|
|
#endregion
|
|
|
|
#region ================== Properties
|
|
|
|
internal override ScriptType ScriptType { get { return ScriptType.SNDINFO; } }
|
|
|
|
internal Dictionary<int, string> AmbientSounds { get { return ambientsounds; } }
|
|
|
|
#endregion
|
|
|
|
#region ================== Constructor
|
|
|
|
public SndInfoParser()
|
|
{
|
|
specialtokens = "";
|
|
ambientsounds = new Dictionary<int, string>();
|
|
skipeditorcomments = true; // otherwise //$AMBIENT will be treated like one...
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ================== Parsing
|
|
|
|
public override bool Parse(TextResourceData data, bool clearerrors)
|
|
{
|
|
//mxd. Already parsed?
|
|
if(!base.AddTextResource(data))
|
|
{
|
|
if(clearerrors) ClearError();
|
|
return true;
|
|
}
|
|
|
|
// Cannot process?
|
|
if(!base.Parse(data, clearerrors)) return false;
|
|
|
|
// Continue until at the end of the stream
|
|
while(SkipWhitespace(true))
|
|
{
|
|
string token = ReadToken().ToLowerInvariant();
|
|
if(string.IsNullOrEmpty(token)) continue;
|
|
|
|
switch(token)
|
|
{
|
|
//$ambient <index> <logicalsound> [type] <mode> <volume>
|
|
case "$ambient":
|
|
// Read index
|
|
SkipWhitespace(true);
|
|
int index = -1;
|
|
if(!ReadSignedInt(ref index) || index < 0)
|
|
{
|
|
// Not numeric!
|
|
ReportError("Expected ambient sound index");
|
|
return false;
|
|
}
|
|
|
|
// Read name
|
|
SkipWhitespace(true);
|
|
string logicalsound = StripQuotes(ReadToken(false));
|
|
if(string.IsNullOrEmpty(logicalsound))
|
|
{
|
|
ReportError("Expected ambient sound logicalname");
|
|
return false;
|
|
}
|
|
|
|
// Add to collection
|
|
if(ambientsounds.ContainsKey(index))
|
|
LogWarning("Ambient sound " + index + " is double-defined as \"" + ambientsounds[index] + "\" and \"" + logicalsound + "\"");
|
|
|
|
ambientsounds[index] = logicalsound;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|