From 8d3b7a554bc432df5ef4445f81f2a94372d5942e Mon Sep 17 00:00:00 2001 From: codeimp Date: Mon, 2 Jun 2008 04:55:51 +0000 Subject: [PATCH] bugfixes in UDMF support --- Build/Configurations/Eternity_DoomUDMF.cfg | 8 ++++---- Build/Configurations/ZDoom_DoomUDMF.cfg | 8 ++++---- Source/Config/GameConfiguration.cs | 6 +++--- Source/Controls/FieldsEditorControl.cs | 20 ++++++++++++++++++-- Source/Map/MapOptions.cs | 8 +++++--- Source/Windows/CustomFieldsForm.cs | 11 ++++++----- Source/Windows/LinedefEditForm.cs | 6 +++--- Source/Windows/OpenMapOptionsForm.cs | 1 + Source/Windows/SectorEditForm.cs | 2 +- Source/Windows/ThingEditForm.cs | 2 +- 10 files changed, 46 insertions(+), 26 deletions(-) diff --git a/Build/Configurations/Eternity_DoomUDMF.cfg b/Build/Configurations/Eternity_DoomUDMF.cfg index f518537c..9b9de421 100644 --- a/Build/Configurations/Eternity_DoomUDMF.cfg +++ b/Build/Configurations/Eternity_DoomUDMF.cfg @@ -18,10 +18,10 @@ formatinterface = "UniversalMapSetIO"; defaultlumpname = "MAP01"; // Special linedefs -soundlinedefflags = 64; // See linedefflags -singlesidedflags = 1; // See linedefflags -doublesidedflags = 4; // See linedefflags -impassableflags = 1; +soundlinedefflag = "blocksound"; +singlesidedflag = "blocking"; +doublesidedflag = "twosided"; +impassableflag = "blocking"; // Generalized actions generalizedlinedefs = true; diff --git a/Build/Configurations/ZDoom_DoomUDMF.cfg b/Build/Configurations/ZDoom_DoomUDMF.cfg index e9c50e83..8c7b8135 100644 --- a/Build/Configurations/ZDoom_DoomUDMF.cfg +++ b/Build/Configurations/ZDoom_DoomUDMF.cfg @@ -19,10 +19,10 @@ defaultlumpname = "MAP01"; // Special linedefs // See linedefflags -soundlinedefflag = 64; -singlesidedflag = 1; -doublesidedflag = 4; -impassableflag = 1; +soundlinedefflag = "blocksound"; +singlesidedflag = "blocking"; +doublesidedflag = "twosided"; +impassableflag = "blocking"; // Generalized actions generalizedlinedefs = false; diff --git a/Source/Config/GameConfiguration.cs b/Source/Config/GameConfiguration.cs index 26e04649..f3d6f379 100644 --- a/Source/Config/GameConfiguration.cs +++ b/Source/Config/GameConfiguration.cs @@ -186,11 +186,11 @@ namespace CodeImp.DoomBuilder.Config // because they are allowed to be written as integers in the configs obj = cfg.ReadSettingObject("soundlinedefflag", 0); if(obj is int) soundlinedefflag = ((int)obj).ToString(CultureInfo.InvariantCulture); else soundlinedefflag = obj.ToString(); - obj = cfg.ReadSetting("singlesidedflag", 0); + obj = cfg.ReadSettingObject("singlesidedflag", 0); if(obj is int) singlesidedflag = ((int)obj).ToString(CultureInfo.InvariantCulture); else singlesidedflag = obj.ToString(); - obj = cfg.ReadSetting("doublesidedflag", 0); + obj = cfg.ReadSettingObject("doublesidedflag", 0); if(obj is int) doublesidedflag = ((int)obj).ToString(CultureInfo.InvariantCulture); else doublesidedflag = obj.ToString(); - obj = cfg.ReadSetting("impassableflag", 0); + obj = cfg.ReadSettingObject("impassableflag", 0); if(obj is int) impassableflag = ((int)obj).ToString(CultureInfo.InvariantCulture); else impassableflag = obj.ToString(); // Get map lumps diff --git a/Source/Controls/FieldsEditorControl.cs b/Source/Controls/FieldsEditorControl.cs index 91c85192..c33b6c18 100644 --- a/Source/Controls/FieldsEditorControl.cs +++ b/Source/Controls/FieldsEditorControl.cs @@ -43,6 +43,9 @@ namespace CodeImp.DoomBuilder.Controls // Constants private const string ADD_FIELD_TEXT = " (click to add custom field)"; + // Variables + private string elementname; + // Constructor public FieldsEditorControl() { @@ -50,8 +53,11 @@ namespace CodeImp.DoomBuilder.Controls } // This sets up the control - public void Setup() + public void Setup(string elementname) { + // Keep element name + this.elementname = elementname; + // Make types list fieldtype.Items.Clear(); fieldtype.Items.AddRange(General.Types.GetCustomUseAttributes()); @@ -191,6 +197,13 @@ namespace CodeImp.DoomBuilder.Controls object oldvalue = null; if(tofields.ContainsKey(frow.Name)) oldvalue = tofields[frow.Name].Value; tofields[frow.Name] = new UniValue(frow.TypeHandler.Index, frow.GetResult(oldvalue)); + + // Custom row? + if(!frow.IsFixed) + { + // Write type to map configuration + General.Map.Options.SetUniversalFieldType(elementname, frow.Name, frow.TypeHandler.Index); + } } } } @@ -285,8 +298,11 @@ namespace CodeImp.DoomBuilder.Controls string validname = UniValue.ValidateName(row.Cells[0].Value.ToString()); if(validname.Length > 0) { + // Try to find the type in the map options + int type = General.Map.Options.GetUniversalFieldType(elementname, validname, 0); + // Make new row - frow = new FieldsEditorRow(fieldslist, validname, 0, 0); + frow = new FieldsEditorRow(fieldslist, validname, type, null); frow.Visible = false; fieldslist.Rows.Insert(e.RowIndex + 1, frow); } diff --git a/Source/Map/MapOptions.cs b/Source/Map/MapOptions.cs index 11677b94..5b1e7984 100644 --- a/Source/Map/MapOptions.cs +++ b/Source/Map/MapOptions.cs @@ -81,11 +81,11 @@ namespace CodeImp.DoomBuilder.Map internal MapOptions() { // Initialize - this.mapconfig = new Configuration(true); this.previousname = ""; this.currentname = ""; this.configfile = ""; this.resources = new DataLocationList(); + this.mapconfig = new Configuration(true); } // Constructor to load from Doom Builder Map Settings Configuration @@ -99,10 +99,12 @@ namespace CodeImp.DoomBuilder.Map this.currentname = mapname; this.configfile = cfg.ReadSetting("config", ""); this.resources = new DataLocationList(); + this.mapconfig = new Configuration(true); // Go for all items in the map info - this.mapconfig.Root = cfg.ReadSetting(mapname, new Hashtable()); - foreach(DictionaryEntry mp in this.mapconfig.Root) + this.mapconfig.Root = cfg.ReadSetting("maps." + mapname, new Hashtable()); + IDictionary reslist = this.mapconfig.ReadSetting("resources", new Hashtable()); + foreach(DictionaryEntry mp in reslist) { // Item is a structure? if(mp.Value is IDictionary) diff --git a/Source/Windows/CustomFieldsForm.cs b/Source/Windows/CustomFieldsForm.cs index c3be092c..ee3a53ba 100644 --- a/Source/Windows/CustomFieldsForm.cs +++ b/Source/Windows/CustomFieldsForm.cs @@ -48,27 +48,28 @@ namespace CodeImp.DoomBuilder.Windows } // This shows the dialog, returns false when cancelled - public static bool ShowDialog(IWin32Window owner, string title, ICollection elements, List fixedfields) + public static bool ShowDialog(IWin32Window owner, string title, string elementname, ICollection elements, List fixedfields) { bool result; CustomFieldsForm f = new CustomFieldsForm(); - f.Setup(title, elements, fixedfields); + f.Setup(title, elementname, elements, fixedfields); result = (f.ShowDialog(owner) == DialogResult.OK); f.Dispose(); return result; } // This sets up the dialog - public void Setup(string title, ICollection elements, List fixedfields) + public void Setup(string title, string elementname, ICollection elements, List fixedfields) { - // Keep list + // Initialize this.elements = elements; + this.Text = title; // Fill universal fields list fieldslist.ListFixedFields(fixedfields); // Initialize custom fields editor - fieldslist.Setup(); + fieldslist.Setup(elementname); // Setup from first element MapElement fe = General.GetByIndex(elements, 0); diff --git a/Source/Windows/LinedefEditForm.cs b/Source/Windows/LinedefEditForm.cs index c3beb6a7..293697ab 100644 --- a/Source/Windows/LinedefEditForm.cs +++ b/Source/Windows/LinedefEditForm.cs @@ -69,7 +69,7 @@ namespace CodeImp.DoomBuilder.Windows backlow.Initialize(); // Initialize custom fields editor - fieldslist.Setup(); + fieldslist.Setup("linedef"); // THE CODE BELOW IS ABSOLUTELY UGLY // I should make different controls for each format @@ -462,7 +462,7 @@ namespace CodeImp.DoomBuilder.Windows foreach(Linedef l in lines) if(l.Front != null) sides.Add(l.Front); // Edit these - CustomFieldsForm.ShowDialog(this, "Front side custom fields", sides, General.Map.Config.SidedefFields); + CustomFieldsForm.ShowDialog(this, "Front side custom fields", "sidedef", sides, General.Map.Config.SidedefFields); } // Custom fields on back sides @@ -473,7 +473,7 @@ namespace CodeImp.DoomBuilder.Windows foreach(Linedef l in lines) if(l.Back != null) sides.Add(l.Back); // Edit these - CustomFieldsForm.ShowDialog(this, "Back side custom fields", sides, General.Map.Config.SidedefFields); + CustomFieldsForm.ShowDialog(this, "Back side custom fields", "sidedef", sides, General.Map.Config.SidedefFields); } } } diff --git a/Source/Windows/OpenMapOptionsForm.cs b/Source/Windows/OpenMapOptionsForm.cs index 7feddc85..be0057f5 100644 --- a/Source/Windows/OpenMapOptionsForm.cs +++ b/Source/Windows/OpenMapOptionsForm.cs @@ -375,6 +375,7 @@ namespace CodeImp.DoomBuilder.Windows { // Get the map name selectedmapname = mapslist.SelectedItems[0].Text; + options = new MapOptions(mapsettings, selectedmapname); // Get locations from previous selected map settings locations = new DataLocationList(mapsettings, "maps." + selectedmapname + ".resources"); diff --git a/Source/Windows/SectorEditForm.cs b/Source/Windows/SectorEditForm.cs index f96db168..9e880cc3 100644 --- a/Source/Windows/SectorEditForm.cs +++ b/Source/Windows/SectorEditForm.cs @@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.Windows ceilingtex.Initialize(); // Initialize custom fields editor - fieldslist.Setup(); + fieldslist.Setup("sector"); } // This sets up the form to edit the given sectors diff --git a/Source/Windows/ThingEditForm.cs b/Source/Windows/ThingEditForm.cs index 78d4aa6e..6a10b0be 100644 --- a/Source/Windows/ThingEditForm.cs +++ b/Source/Windows/ThingEditForm.cs @@ -68,7 +68,7 @@ namespace CodeImp.DoomBuilder.Windows fieldslist.ListFixedFields(General.Map.Config.ThingFields); // Initialize custom fields editor - fieldslist.Setup(); + fieldslist.Setup("thing"); // Go for all predefined categories typelist.Nodes.Clear();