Dehacked: added support for editor keys

Dehacked: Dehacked files are now properly loaded from directories
This commit is contained in:
biwa 2021-09-11 22:11:07 +02:00
parent 4b1e5d8e22
commit fca82f5c91
4 changed files with 38 additions and 12 deletions

View file

@ -650,6 +650,9 @@ namespace CodeImp.DoomBuilder.Config
blocking = thing.Bits.Contains("solid") ? 1 : 0;
hangs = thing.Bits.Contains("spawnceiling");
if (thing.Props.ContainsKey("$editor angled"))
arrow = thing.Angled == ThingAngled.YES;
if (thing.Color >= 0 && thing.Color <= 19)
color = thing.Color;

View file

@ -500,12 +500,12 @@ namespace CodeImp.DoomBuilder.Data
string pathname = Path.GetDirectoryName(pname);
if (filename.IndexOf('.') > -1)
{
allfilenames = GetFileAtPath(filename, pathname, "DEHACKED");
}
else
allfilenames = GetAllFilesWithTitle(pathname, filename, false);
result.Add(new TextResourceData(this, LoadFile(allfilenames[allfilenames.Length - 1]), allfilenames[allfilenames.Length - 1], true));
return result;
}

View file

@ -359,8 +359,11 @@ namespace CodeImp.DoomBuilder.Dehacked
{
line = GetLine();
if (string.IsNullOrWhiteSpace(line)) break;
if (line.StartsWith("#")) continue;
if (string.IsNullOrWhiteSpace(line))
break;
else if (line.StartsWith("#$"))
line = line.Substring(1);
else if (line.StartsWith("#")) continue;
if (!GetKeyValueFromLine(line, out fieldkey, out fieldvalue))
return false;

View file

@ -30,6 +30,13 @@ using System.Collections.Generic;
namespace CodeImp.DoomBuilder.Dehacked
{
public enum ThingAngled
{
UNCHANGED,
YES,
NO
}
public class DehackedThing
{
#region ================== Variables
@ -46,6 +53,7 @@ namespace CodeImp.DoomBuilder.Dehacked
private string category;
private int color;
private bool bright;
private ThingAngled angled;
#endregion
@ -63,6 +71,7 @@ namespace CodeImp.DoomBuilder.Dehacked
public string Category { get { return category; } }
public int Color { get { return color; } }
public bool Bright { get { return bright; } }
public ThingAngled Angled { get { return angled; } }
#endregion
@ -73,6 +82,8 @@ namespace CodeImp.DoomBuilder.Dehacked
this.number = number;
this.name = name;
color = -1;
sprite = null;
angled = ThingAngled.UNCHANGED;
props = new Dictionary<string, string>();
bits = new List<string>();
@ -117,7 +128,7 @@ namespace CodeImp.DoomBuilder.Dehacked
int.TryParse(value, out doomednum);
break;
case "initial frame":
if (int.TryParse(value, out initialframe))
if (sprite == null && int.TryParse(value, out initialframe))
{
if (frames.ContainsKey(initialframe))
{
@ -174,13 +185,22 @@ namespace CodeImp.DoomBuilder.Dehacked
bits.Add(mnemonic.Trim().ToLowerInvariant());
}
break;
//case "$category":
// category = value;
// break;
//case "$color":
// if (!int.TryParse(value, out color))
// color = 18; // Default light brown
// break;
case "$editor category":
category = value;
break;
case "$editor color id":
if (!int.TryParse(value, out color))
color = 18; // Default light brown
break;
case "$editor sprite":
sprite = value;
break;
case "$editor angled":
if (value.ToLowerInvariant() == "true")
angled = ThingAngled.YES;
else
angled = ThingAngled.NO;
break;
}
}
}