mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-17 01:22:18 +00:00
Game configurations: added ability to show certain UDMF fields on specific thing types only
This commit is contained in:
parent
6f26bd95e1
commit
a86fce577e
4 changed files with 60 additions and 2 deletions
|
@ -90,6 +90,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private string obsoletemessage; //mxd
|
||||
private Dictionary<string, Dictionary<string, string>> flagsrename; //mxd. <MapSetIOName, <flag, title>>
|
||||
private int thinglink;
|
||||
private List<string> adduniversalfields;
|
||||
|
||||
//mxd. GZDoom rendering properties
|
||||
private ThingRenderMode rendermode;
|
||||
|
@ -197,6 +198,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.flagsrename = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase); //mxd
|
||||
this.thinglink = 0;
|
||||
this.optional = false; // [ZZ]
|
||||
this.adduniversalfields = new List<string>();
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
|
@ -238,6 +240,16 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.classname = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".class", String.Empty); //mxd
|
||||
this.thinglink = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".thinglink", 0);
|
||||
|
||||
// Read universal fields that should be added to this thing type
|
||||
adduniversalfields = new List<string>();
|
||||
IDictionary adduniversalfieldsdic = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".adduniversalfields", new Hashtable());
|
||||
foreach(DictionaryEntry de in adduniversalfieldsdic)
|
||||
{
|
||||
string addname = de.Key.ToString().ToLowerInvariant();
|
||||
if (!adduniversalfields.Contains(addname))
|
||||
adduniversalfields.Add(addname);
|
||||
}
|
||||
|
||||
//mxd. Read flagsrename
|
||||
this.flagsrename = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
|
||||
IDictionary maindic = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".flagsrename", new Hashtable());
|
||||
|
@ -314,6 +326,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.spritescale = new SizeF(cat.SpriteScale, cat.SpriteScale);
|
||||
this.locksprite = false; //mxd
|
||||
this.flagsrename = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase); //mxd
|
||||
this.adduniversalfields = new List<string>();
|
||||
|
||||
// Safety
|
||||
if(this.radius < 4f || this.fixedsize) this.radius = THING_FIXED_SIZE;
|
||||
|
@ -360,6 +373,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.absolutez = cat.AbsoluteZ;
|
||||
this.spritescale = new SizeF(cat.SpriteScale, cat.SpriteScale);
|
||||
this.flagsrename = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase); //mxd
|
||||
this.adduniversalfields = new List<string>();
|
||||
|
||||
// Safety
|
||||
if(this.hangs && this.absolutez) this.hangs = false; //mxd
|
||||
|
@ -410,6 +424,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.absolutez = cat.AbsoluteZ;
|
||||
this.spritescale = new SizeF(cat.SpriteScale, cat.SpriteScale);
|
||||
this.flagsrename = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase); //mxd
|
||||
this.adduniversalfields = new List<string>();
|
||||
|
||||
// Safety
|
||||
if(this.hangs && this.absolutez) this.hangs = false; //mxd
|
||||
|
@ -463,6 +478,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
this.xybillboard = other.xybillboard; //mxd
|
||||
this.spritescale = new SizeF(other.spritescale.Width, other.spritescale.Height);
|
||||
this.flagsrename = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase); //mxd
|
||||
this.adduniversalfields = new List<string>(other.adduniversalfields);
|
||||
|
||||
//mxd. Copy GZDoom rendering properties
|
||||
this.rendermode = other.rendermode;
|
||||
|
@ -954,6 +970,11 @@ namespace CodeImp.DoomBuilder.Config
|
|||
{
|
||||
return title + " (" + index + ")";
|
||||
}
|
||||
|
||||
public bool HasAddUniversalField(string fieldname)
|
||||
{
|
||||
return adduniversalfields != null && adduniversalfields.Contains(fieldname);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
private string name;
|
||||
private int type;
|
||||
private object defaultvalue;
|
||||
private bool thingtypespecific;
|
||||
private EnumList enumlist;
|
||||
private Dictionary<string, UDMFFieldAssociation> associations;
|
||||
|
||||
|
@ -70,6 +71,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
public string Name { get { return name; } }
|
||||
public int Type { get { return type; } }
|
||||
public object Default { get { return defaultvalue; } }
|
||||
public bool ThingTypeSpecific { get { return thingtypespecific; } }
|
||||
public EnumList Enum { get { return enumlist; } }
|
||||
public Dictionary<string, UDMFFieldAssociation> Associations { get { return associations; } }
|
||||
|
||||
|
@ -87,8 +89,9 @@ namespace CodeImp.DoomBuilder.Config
|
|||
associations = new Dictionary<string, UDMFFieldAssociation>();
|
||||
|
||||
// Read type
|
||||
this.type = cfg.ReadSetting(setting + ".type", int.MinValue);
|
||||
this.defaultvalue = cfg.ReadSettingObject(setting + ".default", null);
|
||||
type = cfg.ReadSetting(setting + ".type", int.MinValue);
|
||||
defaultvalue = cfg.ReadSettingObject(setting + ".default", null);
|
||||
thingtypespecific = cfg.ReadSetting(setting + ".thingtypespecific", false);
|
||||
|
||||
// Read enum
|
||||
object enumsetting = cfg.ReadSettingObject(setting + ".enum", null);
|
||||
|
|
|
@ -981,6 +981,27 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
if(frow != null && frow.RowType == FieldsEditorRowType.FIXED) frow.Visible = showfixedfields;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes an field by its name.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the field to remove</param>
|
||||
public void RemoveField(string name)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
foreach(DataGridViewRow dgvr in fieldslist.Rows)
|
||||
{
|
||||
if(dgvr.Cells[0].Value.ToString().ToLowerInvariant() == name.ToLowerInvariant())
|
||||
{
|
||||
index = dgvr.Index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 0)
|
||||
fieldslist.Rows.RemoveAt(index);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Controls;
|
||||
|
@ -329,6 +330,18 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
thingprops.Add(new ThingProperties(t));
|
||||
}
|
||||
|
||||
// Remove unused thing type specific fields
|
||||
foreach(UniversalFieldInfo ufi in General.Map.Config.ThingFields)
|
||||
{
|
||||
if (!ufi.ThingTypeSpecific)
|
||||
continue;
|
||||
|
||||
if(!things.Any(t => { ThingTypeInfo tti = General.Map.Data.GetThingInfoEx(t.Type); return (tti != null && tti.HasAddUniversalField(ufi.Name)); }))
|
||||
{
|
||||
fieldslist.RemoveField(ufi.Name);
|
||||
}
|
||||
}
|
||||
|
||||
preventchanges = false;
|
||||
|
||||
//mxd. Update "Reset" button
|
||||
|
|
Loading…
Reference in a new issue