mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 12:22:35 +00:00
@ Numeric linedef flags are now automatically sorted
This commit is contained in:
parent
711ad371d8
commit
680c0f854d
6 changed files with 90 additions and 45 deletions
|
@ -97,6 +97,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
// Linedefs
|
||||
private Dictionary<string, string> linedefflags;
|
||||
private List<string> sortedlinedefflags;
|
||||
private Dictionary<int, LinedefActionInfo> linedefactions;
|
||||
private List<LinedefActionInfo> sortedlinedefactions;
|
||||
private List<LinedefActionCategory> actioncategories;
|
||||
|
@ -179,6 +180,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
// Linedefs
|
||||
public IDictionary<string, string> LinedefFlags { get { return linedefflags; } }
|
||||
public List<string> SortedLinedefFlags { get { return sortedlinedefflags; } }
|
||||
public IDictionary<int, LinedefActionInfo> LinedefActions { get { return linedefactions; } }
|
||||
public List<LinedefActionInfo> SortedLinedefActions { get { return sortedlinedefactions; } }
|
||||
public List<LinedefActionCategory> ActionCategories { get { return actioncategories; } }
|
||||
|
@ -222,6 +224,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.thingcategories = new List<ThingCategory>();
|
||||
this.things = new Dictionary<int, ThingTypeInfo>();
|
||||
this.linedefflags = new Dictionary<string, string>();
|
||||
this.sortedlinedefflags = new List<string>();
|
||||
this.linedefactions = new Dictionary<int, LinedefActionInfo>();
|
||||
this.actioncategories = new List<LinedefActionCategory>();
|
||||
this.sortedlinedefactions = new List<LinedefActionInfo>();
|
||||
|
@ -429,20 +432,38 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private void LoadLinedefFlags()
|
||||
{
|
||||
IDictionary dic;
|
||||
int bitflagscheck = 0;
|
||||
int bitvalue;
|
||||
|
||||
// Get linedef flags
|
||||
dic = cfg.ReadSetting("linedefflags", new Hashtable());
|
||||
foreach(DictionaryEntry de in dic)
|
||||
linedefflags.Add(de.Key.ToString(), de.Value.ToString());
|
||||
|
||||
|
||||
// Get translations
|
||||
dic = cfg.ReadSetting("linedefflagstranslation", new Hashtable());
|
||||
foreach(DictionaryEntry de in dic)
|
||||
linedefflagstranslation.Add(new FlagTranslation(de));
|
||||
|
||||
// Sort the translation flags, because they must be compared highest first!
|
||||
|
||||
// Sort flags?
|
||||
MapSetIO io = MapSetIO.Create(formatinterface);
|
||||
if(io.HasNumericLinedefFlags)
|
||||
{
|
||||
// Make list for integers that we can sort
|
||||
List<int> sortlist = new List<int>(linedefflags.Count);
|
||||
foreach(KeyValuePair<string, string> f in linedefflags)
|
||||
{
|
||||
int num;
|
||||
if(int.TryParse(f.Key, NumberStyles.Integer, CultureInfo.InvariantCulture, out num)) sortlist.Add(num);
|
||||
}
|
||||
|
||||
// Sort
|
||||
sortlist.Sort();
|
||||
|
||||
// Make list of strings
|
||||
foreach(int i in sortlist)
|
||||
sortedlinedefflags.Add(i.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
// Sort the flags, because they must be compared highest first!
|
||||
linedefflagstranslation.Sort();
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override bool HasMixedActivations { get { return false; } }
|
||||
public override bool HasPresetActivations { get { return false; } }
|
||||
public override bool HasBuiltInActivations { get { return true; } }
|
||||
public override bool HasNumericLinedefFlags { get { return true; } }
|
||||
public override bool HasNumericThingFlags { get { return true; } }
|
||||
public override bool HasNumericLinedefActivations { get { return true; } }
|
||||
public override int MaxTag { get { return ushort.MaxValue; } }
|
||||
public override int MinTag { get { return ushort.MinValue; } }
|
||||
public override int MaxAction { get { return ushort.MaxValue; } }
|
||||
|
@ -296,10 +299,10 @@ namespace CodeImp.DoomBuilder.IO
|
|||
|
||||
// Make string flags
|
||||
stringflags = new Dictionary<string, bool>();
|
||||
foreach(KeyValuePair<string, string> f in manager.Config.LinedefFlags)
|
||||
foreach(string f in manager.Config.SortedLinedefFlags)
|
||||
{
|
||||
int fnum;
|
||||
if(int.TryParse(f.Key, out fnum)) stringflags[f.Key] = ((flags & fnum) == fnum);
|
||||
if(int.TryParse(f, out fnum)) stringflags[f] = ((flags & fnum) == fnum);
|
||||
}
|
||||
|
||||
// Create new linedef
|
||||
|
|
|
@ -64,6 +64,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override bool HasMixedActivations { get { return false; } }
|
||||
public override bool HasPresetActivations { get { return true; } }
|
||||
public override bool HasBuiltInActivations { get { return false; } }
|
||||
public override bool HasNumericLinedefFlags { get { return true; } }
|
||||
public override bool HasNumericThingFlags { get { return true; } }
|
||||
public override bool HasNumericLinedefActivations { get { return true; } }
|
||||
public override int MaxTag { get { return ushort.MaxValue; } }
|
||||
public override int MinTag { get { return ushort.MinValue; } }
|
||||
public override int MaxAction { get { return byte.MaxValue; } }
|
||||
|
@ -308,13 +311,13 @@ namespace CodeImp.DoomBuilder.IO
|
|||
args[4] = readline.ReadByte();
|
||||
s1 = readline.ReadUInt16();
|
||||
s2 = readline.ReadUInt16();
|
||||
|
||||
|
||||
// Make string flags
|
||||
stringflags = new Dictionary<string, bool>();
|
||||
foreach(KeyValuePair<string, string> f in manager.Config.LinedefFlags)
|
||||
foreach(string f in manager.Config.SortedLinedefFlags)
|
||||
{
|
||||
int fnum;
|
||||
if(int.TryParse(f.Key, out fnum)) stringflags[f.Key] = ((flags & fnum) == fnum);
|
||||
if(int.TryParse(f, out fnum)) stringflags[f] = ((flags & fnum) == fnum);
|
||||
}
|
||||
|
||||
// Create new linedef
|
||||
|
|
|
@ -50,6 +50,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
bool HasMixedActivations { get; }
|
||||
bool HasPresetActivations { get; }
|
||||
bool HasBuiltInActivations { get; }
|
||||
bool HasNumericLinedefFlags { get; }
|
||||
bool HasNumericThingFlags { get; }
|
||||
bool HasNumericLinedefActivations { get; }
|
||||
int MaxTag { get; }
|
||||
int MinTag { get; }
|
||||
int MaxAction { get; }
|
||||
|
|
|
@ -66,6 +66,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public abstract bool HasMixedActivations { get; }
|
||||
public abstract bool HasPresetActivations { get; }
|
||||
public abstract bool HasBuiltInActivations { get; }
|
||||
public abstract bool HasNumericLinedefFlags { get; }
|
||||
public abstract bool HasNumericThingFlags { get; }
|
||||
public abstract bool HasNumericLinedefActivations { get; }
|
||||
public abstract int MaxTag { get; }
|
||||
public abstract int MinTag { get; }
|
||||
public abstract int MaxAction { get; }
|
||||
|
@ -95,6 +98,12 @@ namespace CodeImp.DoomBuilder.IO
|
|||
|
||||
#region ================== Static Methods
|
||||
|
||||
// This returns and instance of the specified IO class
|
||||
public static MapSetIO Create(string classname)
|
||||
{
|
||||
return Create(classname, null, null);
|
||||
}
|
||||
|
||||
// This returns and instance of the specified IO class
|
||||
public static MapSetIO Create(string classname, WAD wadfile, MapManager manager)
|
||||
{
|
||||
|
|
|
@ -52,43 +52,46 @@ namespace CodeImp.DoomBuilder.IO
|
|||
// Constructor
|
||||
public UniversalMapSetIO(WAD wad, MapManager manager) : base(wad, manager)
|
||||
{
|
||||
// Make configuration
|
||||
config = new Configuration();
|
||||
|
||||
// Find a resource named UDMF.cfg
|
||||
string[] resnames = General.ThisAssembly.GetManifestResourceNames();
|
||||
foreach(string rn in resnames)
|
||||
if((manager != null) && (manager.Config != null))
|
||||
{
|
||||
// Found it?
|
||||
if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.InvariantCultureIgnoreCase))
|
||||
// Make configuration
|
||||
config = new Configuration();
|
||||
|
||||
// Find a resource named UDMF.cfg
|
||||
string[] resnames = General.ThisAssembly.GetManifestResourceNames();
|
||||
foreach(string rn in resnames)
|
||||
{
|
||||
// Get a stream from the resource
|
||||
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);
|
||||
StreamReader udmfcfgreader = new StreamReader(udmfcfg, Encoding.ASCII);
|
||||
|
||||
// Load configuration from stream
|
||||
config.InputConfiguration(udmfcfgreader.ReadToEnd());
|
||||
|
||||
// Now we add the linedef flags, activations and thing flags
|
||||
// to this list, so that these don't show up in the custom
|
||||
// fields list either. We use true as dummy value (it has no meaning)
|
||||
|
||||
// Add linedef flags
|
||||
foreach(KeyValuePair<string, string> flag in General.Map.Config.LinedefFlags)
|
||||
config.WriteSetting("managedfields.linedef." + flag.Key, true);
|
||||
|
||||
// Add linedef activations
|
||||
foreach(LinedefActivateInfo activate in General.Map.Config.LinedefActivates)
|
||||
config.WriteSetting("managedfields.linedef." + activate.Key, true);
|
||||
|
||||
// Add thing flags
|
||||
foreach(KeyValuePair<string, string> flag in General.Map.Config.ThingFlags)
|
||||
config.WriteSetting("managedfields.thing." + flag.Key, true);
|
||||
|
||||
// Done
|
||||
udmfcfgreader.Dispose();
|
||||
udmfcfg.Dispose();
|
||||
break;
|
||||
// Found it?
|
||||
if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
// Get a stream from the resource
|
||||
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);
|
||||
StreamReader udmfcfgreader = new StreamReader(udmfcfg, Encoding.ASCII);
|
||||
|
||||
// Load configuration from stream
|
||||
config.InputConfiguration(udmfcfgreader.ReadToEnd());
|
||||
|
||||
// Now we add the linedef flags, activations and thing flags
|
||||
// to this list, so that these don't show up in the custom
|
||||
// fields list either. We use true as dummy value (it has no meaning)
|
||||
|
||||
// Add linedef flags
|
||||
foreach(KeyValuePair<string, string> flag in manager.Config.LinedefFlags)
|
||||
config.WriteSetting("managedfields.linedef." + flag.Key, true);
|
||||
|
||||
// Add linedef activations
|
||||
foreach(LinedefActivateInfo activate in manager.Config.LinedefActivates)
|
||||
config.WriteSetting("managedfields.linedef." + activate.Key, true);
|
||||
|
||||
// Add thing flags
|
||||
foreach(KeyValuePair<string, string> flag in manager.Config.ThingFlags)
|
||||
config.WriteSetting("managedfields.thing." + flag.Key, true);
|
||||
|
||||
// Done
|
||||
udmfcfgreader.Dispose();
|
||||
udmfcfg.Dispose();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +118,9 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override bool HasMixedActivations { get { return true; } }
|
||||
public override bool HasPresetActivations { get { return false; } }
|
||||
public override bool HasBuiltInActivations { get { return false; } }
|
||||
public override bool HasNumericLinedefFlags { get { return false; } }
|
||||
public override bool HasNumericThingFlags { get { return false; } }
|
||||
public override bool HasNumericLinedefActivations { get { return false; } }
|
||||
public override int MaxTag { get { return int.MaxValue; } }
|
||||
public override int MinTag { get { return int.MinValue; } }
|
||||
public override int MaxAction { get { return int.MaxValue; } }
|
||||
|
|
Loading…
Reference in a new issue