diff --git a/Build/Scripting/ZDoom_DECORATE.cfg b/Build/Scripting/ZDoom_DECORATE.cfg index 364a7e00..1dec25b7 100644 --- a/Build/Scripting/ZDoom_DECORATE.cfg +++ b/Build/Scripting/ZDoom_DECORATE.cfg @@ -161,9 +161,9 @@ keywords A_QueueCorpse = "A_QueueCorpse"; A_RearrangePointers = "A_RearrangePointers(int target, int master, int tracer, int flags)\nflags: AAPTR flags."; A_Respawn = "A_Respawn[(int flags = RSF_FOG)]\nflags: RSF flags"; - A_ScaleVelocity = "A_ScaleVelocity(float scale)"; + A_ScaleVelocity = "A_ScaleVelocity(float scale[, int pointer = AAPTR_DEFAULT])"; A_ScreamAndUnblock = "A_ScreamAndUnblock"; - A_SetAngle = "A_SetAngle(float angle[, int flags])\nangle: the actor\"s new angle, in degrees.\nflags: SPF flags."; + A_SetAngle = "A_SetAngle(float angle[, int flags = 0[, int pointer = AAPTR_DEFAULT]])\nangle: the actor\"s new angle, in degrees.\nflags: SPF flags."; A_SetArg = "A_SetArg(int position, int value)"; A_SetDamageType = "A_SetDamageType(str damagetype)"; A_SetFloat = "A_SetFloat"; @@ -172,15 +172,15 @@ keywords A_SetHealth = "A_SetHealth(int health[, int pointer = AAPTR_DEFAULT])\nhealth: The health value to set for the actor. Valid values are 1 and above.\npointer: The actor to set its health. Default is AAPTR_DEFAULT, which corresponds to the calling actor."; A_SetInvulnerable = "A_SetInvulnerable"; A_SetMass = "A_SetMass(int mass)"; - A_SetPitch = "A_SetPitch(float pitch[, int flags])\npitch: The actor\"s new pitch, in degrees.\nflags: SPF flags."; + A_SetPitch = "A_SetPitch(float pitch[, int flags = 0[, int pointer = AAPTR_DEFAULT]])\npitch: The actor\"s new pitch, in degrees.\nflags: SPF flags."; A_SetReflective = "A_SetReflective"; A_SetReflectiveInvulnerable = "A_SetReflectiveInvulnerable"; - A_SetScale = "A_SetScale(float scaleX[, float scaleY = scaleX])"; + A_SetScale = "A_SetScale(float scaleX[, float scaleY = scaleX[, int pointer = AAPTR_DEFAULT]])"; A_SetShadow = "A_SetShadow"; A_SetShootable = "A_SetShootable"; A_SetSolid = "A_SetSolid"; A_SetSpecial = "A_SetSpecial(int special, int arg0, int arg1, int arg2, int arg3, int arg4)"; - A_SetSpeed = "A_SetSpeed(float speed)"; + A_SetSpeed = "A_SetSpeed(float speed[, int pointer = AAPTR_DEFAULT])"; A_SetTics = "A_SetTics(int tics)"; A_SetTranslucent = "A_SetTranslucent(float alpha[, int mode = 0])"; A_SetUserVar = "A_SetUserVar(str name, int value)"; diff --git a/Source/Core/Builder.csproj b/Source/Core/Builder.csproj index 8b2c3480..0b9c13e3 100644 --- a/Source/Core/Builder.csproj +++ b/Source/Core/Builder.csproj @@ -514,9 +514,11 @@ 3.5 + + False @@ -943,6 +945,7 @@ + diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs index 16b04a52..17ca40be 100644 --- a/Source/Core/Data/DataManager.cs +++ b/Source/Core/Data/DataManager.cs @@ -68,6 +68,7 @@ namespace CodeImp.DoomBuilder.Data private Dictionary modeldefEntries; //Thing.Type, Model entry private Dictionary gldefsEntries; //Thing.Type, Light entry private MapInfo mapInfo; //mapinfo + private Dictionary> reverbs; // // Background loading private Queue imageque; @@ -112,6 +113,7 @@ namespace CodeImp.DoomBuilder.Data internal Dictionary ModeldefEntries { get { return modeldefEntries; } } internal Dictionary GldefsEntries { get { return gldefsEntries; } } internal MapInfo MapInfo { get { return mapInfo; } } + public Dictionary> Reverbs { get { return reverbs; } } public Playpal Palette { get { return palette; } } public PreviewManager Previews { get { return previews; } } @@ -156,6 +158,7 @@ namespace CodeImp.DoomBuilder.Data //mxd. modeldefEntries = new Dictionary(); gldefsEntries = new Dictionary(); + reverbs = new Dictionary>(); // Load special images missingtexture3d = new ResourceImage("CodeImp.DoomBuilder.Resources.MissingTexture3D.png"); @@ -318,8 +321,9 @@ namespace CodeImp.DoomBuilder.Data spritecount = LoadThingSprites(); LoadInternalSprites(); - //mxd + //mxd. Load more stuff LoadMapInfo(); + LoadReverbs(); ModelReader.Init(); LoadVoxels(); Dictionary actorsByClass = CreateActorsByClassList(); @@ -1770,6 +1774,27 @@ namespace CodeImp.DoomBuilder.Data parser.Parse(group.Value, group.Key); } + //mxd. This loads REVERBS + private void LoadReverbs() + { + ReverbsParser parser = new ReverbsParser(); + reverbs.Clear(); + + foreach(DataReader dr in containers) + { + currentreader = dr; + Dictionary streams = dr.GetReverbsData(); + foreach(KeyValuePair group in streams) + { + // Parse the data + parser.Parse(group.Value, group.Key); + } + } + + currentreader = null; + reverbs = parser.GetReverbs(); + } + //mxd internal MemoryStream LoadFile(string name) { diff --git a/Source/Core/Data/DataReader.cs b/Source/Core/Data/DataReader.cs index 30144063..2811a0e1 100644 --- a/Source/Core/Data/DataReader.cs +++ b/Source/Core/Data/DataReader.cs @@ -165,6 +165,9 @@ namespace CodeImp.DoomBuilder.Data public virtual Dictionary GetGldefsData(GameType gameType) { return new Dictionary(); } public virtual Dictionary GetGldefsData(string location) { return new Dictionary(); } + //mxd. When implemented, this returns the Reverbs lump + public virtual Dictionary GetReverbsData() { return new Dictionary(); } + //mxd. When implemented, this returns the list of voxel model names public virtual string[] GetVoxelNames() { return null; } diff --git a/Source/Core/Data/PK3StructuredReader.cs b/Source/Core/Data/PK3StructuredReader.cs index f9c9d306..8e5b49b5 100644 --- a/Source/Core/Data/PK3StructuredReader.cs +++ b/Source/Core/Data/PK3StructuredReader.cs @@ -145,11 +145,10 @@ namespace CodeImp.DoomBuilder.Data { MemoryStream stream = LoadFile(foundfile); - if(stream.Length > 767) {//mxd + if(stream.Length > 767) //mxd palette = new Playpal(stream); - } else { + else General.ErrorLogger.Add(ErrorType.Warning, "Warning: invalid palette '"+foundfile+"'"); - } stream.Dispose(); } @@ -600,6 +599,35 @@ namespace CodeImp.DoomBuilder.Data #endregion + #region ================== Reverbs + + public override Dictionary GetReverbsData() + { + // Error when suspended + if(issuspended) throw new Exception("Data reader is suspended"); + + Dictionary streams = new Dictionary(); + + // Get from wads first + //TODO: is this the correct order?.. + foreach(WADReader wr in wads) + { + Dictionary wadstreams = wr.GetReverbsData(); + foreach(KeyValuePair pair in wadstreams) streams.Add(pair.Key, pair.Value); + } + + // Then from our own files + string foundfile = FindFirstFile("reverbs", false); + if((foundfile != null) && FileExists(foundfile)) + { + streams.Add(foundfile, LoadFile(foundfile)); + } + + return streams; + } + + #endregion + #region ================== Methods // This loads the images in this directory diff --git a/Source/Core/Data/WADReader.cs b/Source/Core/Data/WADReader.cs index e8c8173a..03db0e41 100644 --- a/Source/Core/Data/WADReader.cs +++ b/Source/Core/Data/WADReader.cs @@ -923,6 +923,17 @@ namespace CodeImp.DoomBuilder.Data return GetGldefsData("MODELDEF"); } + //mxd + public override Dictionary GetReverbsData() + { + if(issuspended) throw new Exception("Data reader is suspended"); + + Dictionary result = new Dictionary(); + Lump lump = file.FindLump("REVERBS"); + if(lump != null) result.Add(Path.Combine(location.location, "REVERBS"), lump.Stream); + return result; + } + //mxd internal override MemoryStream LoadFile(string name) { diff --git a/Source/Core/Map/MapSet.cs b/Source/Core/Map/MapSet.cs index f53b7dd8..daf15f2f 100644 --- a/Source/Core/Map/MapSet.cs +++ b/Source/Core/Map/MapSet.cs @@ -2739,7 +2739,7 @@ namespace CodeImp.DoomBuilder.Map } /// This finds the thing closest to the specified position. - public static Thing NearestThingSquareRange(ICollection selection, Vector2D pos, float maxrange) + public static Thing NearestThingSquareRange(ICollection selection, Vector2D pos, float maxrange, int type) { RectangleF range = RectangleF.FromLTRB(pos.x - maxrange, pos.y - maxrange, pos.x + maxrange, pos.y + maxrange); Thing closest = null; @@ -2749,6 +2749,9 @@ namespace CodeImp.DoomBuilder.Map // Go for all things in selection foreach(Thing t in selection) { + //mxd. Required type? + if(type != 0 && t.Type != type) continue; + px = t.Position.x; py = t.Position.y; @@ -3079,7 +3082,10 @@ namespace CodeImp.DoomBuilder.Map public Vertex NearestVertexSquareRange(Vector2D pos, float maxrange) { return MapSet.NearestVertexSquareRange(vertices, pos, maxrange); } /// This finds the thing closest to the specified position. - public Thing NearestThingSquareRange(Vector2D pos, float maxrange) { return MapSet.NearestThingSquareRange(things, pos, maxrange); } + public Thing NearestThingSquareRange(Vector2D pos, float maxrange) { return MapSet.NearestThingSquareRange(things, pos, maxrange, 0); } + + /// This finds the thing closest to the specified position. + public static Thing NearestThingSquareRange(ICollection selection, Vector2D pos, float maxrange) { return MapSet.NearestThingSquareRange(selection, pos, maxrange, 0); } /// This finds the closest unselected linedef that is not connected to the given vertex. public Linedef NearestUnselectedUnreferencedLinedef(Vector2D pos, float maxrange, Vertex v, out float distance) diff --git a/Source/Core/Properties/AssemblyInfo.cs b/Source/Core/Properties/AssemblyInfo.cs index 7703b8ba..bfde8e91 100644 --- a/Source/Core/Properties/AssemblyInfo.cs +++ b/Source/Core/Properties/AssemblyInfo.cs @@ -28,4 +28,4 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("1.14.0.1885")] \ No newline at end of file +[assembly: AssemblyVersion("1.14.0.2201")] \ No newline at end of file diff --git a/Source/Core/Rendering/SurfaceManager.cs b/Source/Core/Rendering/SurfaceManager.cs index c759fd15..d5109d45 100644 --- a/Source/Core/Rendering/SurfaceManager.cs +++ b/Source/Core/Rendering/SurfaceManager.cs @@ -631,7 +631,11 @@ namespace CodeImp.DoomBuilder.Rendering { img = General.Map.Data.GetFlatImage(longimagename); - if(!(img is UnknownImage)) + if(img is UnknownImage) + { + img = General.Map.Data.UnknownTexture3D; + } + else { if(img.IsImageLoaded && !img.LoadFailed) { diff --git a/Source/Core/Windows/MainForm.cs b/Source/Core/Windows/MainForm.cs index 1a3dad82..66151c89 100644 --- a/Source/Core/Windows/MainForm.cs +++ b/Source/Core/Windows/MainForm.cs @@ -1785,27 +1785,36 @@ namespace CodeImp.DoomBuilder.Windows // This hides redundant separators internal void UpdateSeparators() { - UpdateToolStripSeparators(toolbar.Items); - UpdateToolStripSeparators(menumode.DropDownItems); + UpdateToolStripSeparators(toolbar.Items, false); + UpdateToolStripSeparators(menumode.DropDownItems, true); //mxd - UpdateToolStripSeparators(modestoolbar.Items); - UpdateToolStripSeparators(modecontrolsloolbar.Items); + UpdateToolStripSeparators(modestoolbar.Items, true); + UpdateToolStripSeparators(modecontrolsloolbar.Items, true); } - // This hides redundant separators (mxd) - private static void UpdateToolStripSeparators(ToolStripItemCollection items) + // This hides redundant separators + private static void UpdateToolStripSeparators(ToolStripItemCollection items, bool defaultvisible) { ToolStripItem pvi = null; - foreach(ToolStripItem i in items) + foreach(ToolStripItem i in items) { - if (i is ToolStripSeparator) + bool separatorvisible = false; + + // This is a seperator? + if(i is ToolStripSeparator) { - i.Visible = !(pvi == null || (!pvi.Visible || pvi is ToolStripSeparator)); + // Make visible when previous item was not a seperator + separatorvisible = !(pvi is ToolStripSeparator) && (pvi != null); + i.Visible = separatorvisible; } - pvi = i; + // Keep as previous visible item + if(i.Visible || separatorvisible || (defaultvisible && !(i is ToolStripSeparator))) pvi = i; } + + // Hide last item if it is a seperator + if(pvi is ToolStripSeparator) pvi.Visible = false; } // This enables or disables all editing mode items and toolbar buttons diff --git a/Source/Core/ZDoom/ReverbsParser.cs b/Source/Core/ZDoom/ReverbsParser.cs new file mode 100644 index 00000000..0799989a --- /dev/null +++ b/Source/Core/ZDoom/ReverbsParser.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; + +namespace CodeImp.DoomBuilder.ZDoom +{ + internal sealed class ReverbsParser : ZDTextParser + { + private readonly List names; + private readonly List firstargs; + private readonly List secondargs; + + public ReverbsParser() + { + names = new List(); + firstargs = new List(); + secondargs = new List(); + } + + public override bool Parse(Stream stream, string sourcefilename) + { + base.Parse(stream, sourcefilename); + + // Continue until at the end of the stream + while(SkipWhitespace(true)) + { + string token = ReadToken(); + + if(!string.IsNullOrEmpty(token)) + { + if(token == "{") + { + // Skip inner properties + do + { + SkipWhitespace(true); + token = ReadToken(); + } while(token!= "}"); + } + else + { + //this should be reverb name and args + string name = StripTokenQuotes(token); + + if(string.IsNullOrEmpty(name)) + { + ReportError("Got empty sound environment name!"); + break; + } + + // Read first part of the ID + SkipWhitespace(true); + token = StripTokenQuotes(ReadToken()); + int arg1; + if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out arg1)) + { + ReportError("Failed to parse the first part of '" + name + "' sound environment ID!"); + break; + } + + // Read second part of the ID + SkipWhitespace(true); + token = StripTokenQuotes(ReadToken()); + int arg2; + if(!int.TryParse(token, NumberStyles.Integer, CultureInfo.InvariantCulture, out arg2)) + { + ReportError("Failed to parse the second part of '" + name + "' sound environment ID!"); + break; + } + + // Add to collections + if(names.Contains(name)) + { + General.ErrorLogger.Add(ErrorType.Warning, "'" + name + "' Sound environment is double-defined in '" + sourcefilename + "'!"); + int index = names.IndexOf(name); + firstargs[index] = arg1; + secondargs[index] = arg2; + } + else + { + names.Add(name); + firstargs.Add(arg1); + secondargs.Add(arg2); + } + } + } + } + + return true; + } + + internal Dictionary> GetReverbs() + { + string[] sortednames = new string[names.Count]; + names.CopyTo(sortednames); + Array.Sort(sortednames); + + Dictionary> result = new Dictionary>(names.Count); + + foreach(string name in sortednames) + { + int index = names.IndexOf(name); + result.Add(name, new KeyValuePair(firstargs[index], secondargs[index])); + } + + return result; + } + } +} diff --git a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs index dc28385c..b65135b1 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs @@ -501,7 +501,8 @@ namespace CodeImp.DoomBuilder.BuilderModes // Update entire display General.Interface.RedrawDisplay(); } - } else if(highlighted != null) + } + else if(highlighted != null) { highlighted = null; Highlight(null); diff --git a/Source/Plugins/SoundPropagationMode/BuilderPlug.cs b/Source/Plugins/SoundPropagationMode/BuilderPlug.cs index b126061c..af45b2dd 100644 --- a/Source/Plugins/SoundPropagationMode/BuilderPlug.cs +++ b/Source/Plugins/SoundPropagationMode/BuilderPlug.cs @@ -91,7 +91,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode public static BuilderPlug Me { get { return me; } } // This plugin relies on some functionality that wasn't there in older versions - public override int MinimumRevision { get { return 1885; } } + public override int MinimumRevision { get { return 2201; } } // This event is called when the plugin is initialized public override void OnInitialize() @@ -318,6 +318,39 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode environment.Things = environment.Things.OrderBy(o => o.Index).ToList(); environment.Linedefs = environment.Linedefs.OrderBy(o => o.Index).ToList(); + //mxd. Find the first non-dormant thing + Thing activeenv = null; + foreach(Thing t in environment.Things) + { + if(!ThingDormant(t)) + { + activeenv = t; + break; + } + } + + //mxd. Update environment name + if(activeenv != null) + { + foreach(KeyValuePair> group in General.Map.Data.Reverbs) + { + if(group.Value.Key == activeenv.Args[0] && group.Value.Value == activeenv.Args[1]) + { + environment.Name = group.Key + " (" + activeenv.Args[0] + " " + activeenv.Args[1] + ") "; + break; + } + } + + //mxd. No suitable name found?.. + if(environment.Name == SoundEnvironment.DEFAULT_NAME) + { + environment.Name += " (" + activeenv.Args[0] + " " + activeenv.Args[1] + ")"; + } + } + + //mxd. Still no suitable name?.. + if(environment.Name == SoundEnvironment.DEFAULT_NAME) environment.Name += " " + environment.ID; + lock (soundenvironments) { soundenvironments.Add(environment); @@ -375,5 +408,17 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode // the second argument set (see http://zdoom.org/wiki/Line_SetIdentification) return (linedef.Action == 121 && (linedef.Args[1] & 1) == 1); //mxd. Fancier this way :) } + + //mxd + internal static bool ThingDormant(Thing thing) + { + return thing.IsFlagSet(General.Map.UDMF ? "dormant" : "14"); + } + + //mxd + internal static void SetThingDormant(Thing thing, bool dormant) + { + thing.SetFlag(General.Map.UDMF ? "dormant" : "14", dormant); + } } } diff --git a/Source/Plugins/SoundPropagationMode/Interface/SoundEnvironmentPanel.cs b/Source/Plugins/SoundPropagationMode/Interface/SoundEnvironmentPanel.cs index bf138453..9ae10b22 100644 --- a/Source/Plugins/SoundPropagationMode/Interface/SoundEnvironmentPanel.cs +++ b/Source/Plugins/SoundPropagationMode/Interface/SoundEnvironmentPanel.cs @@ -18,13 +18,14 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode InitializeComponent(); soundenvironments.ImageList = new ImageList(); - soundenvironments.ImageList.Images.Add(global::SoundPropagationMode.Properties.Resources.Status0); - soundenvironments.ImageList.Images.Add(global::SoundPropagationMode.Properties.Resources.Warning); + soundenvironments.ImageList.Images.Add(Properties.Resources.Status0); + soundenvironments.ImageList.Images.Add(Properties.Resources.Warning); } - public void AddSoundEnvironment(SoundEnvironment se) + public void AddSoundEnvironment(SoundEnvironment se) { - TreeNode topnode = new TreeNode("Sound environment " + se.ID); + TreeNode topnode = new TreeNode(se.Name); + topnode.Tag = se; //mxd TreeNode thingsnode = new TreeNode("Things (" + se.Things.Count + ")"); TreeNode linedefsnode = new TreeNode("Linedefs (" + se.Linedefs.Count + ")"); int notdormant = 0; @@ -37,7 +38,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode thingnode.Tag = t; thingsnode.Nodes.Add(thingnode); - if(!ThingDormant(t)) + if(!BuilderPlug.ThingDormant(t)) { notdormant++; } @@ -56,7 +57,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode foreach (TreeNode tn in thingsnode.Nodes) { - if (!ThingDormant((Thing)tn.Tag)) + if (!BuilderPlug.ThingDormant((Thing)tn.Tag)) { tn.ImageIndex = 1; tn.SelectedImageIndex = 1; @@ -110,16 +111,11 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode // Sound environments will no be added in consecutive order, so we'll have to find // out where in the tree to add the node - Regex seid = new Regex(@"\d+$"); int insertionplace = 0; foreach (TreeNode tn in soundenvironments.Nodes) { - Match match = seid.Match(tn.Text); - int num = int.Parse(match.Value); - - if (se.ID < num) break; - + if(se.ID < ((SoundEnvironment)tn.Tag).ID) break; insertionplace++; } @@ -132,7 +128,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode foreach (TreeNode tn in soundenvironments.Nodes) { - if (se != null && tn.Text == "Sound environment " + se.ID) + if(se != null && tn.Text == se.Name) { if (tn.NodeFont == null || tn.NodeFont.Style != FontStyle.Bold) { @@ -150,11 +146,6 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode soundenvironments.EndUpdate(); } - private static bool ThingDormant(Thing thing) - { - return thing.IsFlagSet(General.Map.UDMF ? "dormant" : "14"); - } - private static bool IsClickOnText(TreeView treeView, TreeNode node, Point location) { var hitTest = treeView.HitTest(location); diff --git a/Source/Plugins/SoundPropagationMode/Properties/Resources.Designer.cs b/Source/Plugins/SoundPropagationMode/Properties/Resources.Designer.cs index 5b55509b..850ed41e 100644 --- a/Source/Plugins/SoundPropagationMode/Properties/Resources.Designer.cs +++ b/Source/Plugins/SoundPropagationMode/Properties/Resources.Designer.cs @@ -1,14 +1,14 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.5485 +// Runtime Version:2.0.50727.5466 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace SoundPropagationMode.Properties { +namespace CodeImp.DoomBuilder.SoundPropagationMode.Properties { using System; @@ -39,7 +39,7 @@ namespace SoundPropagationMode.Properties { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SoundPropagationMode.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CodeImp.DoomBuilder.SoundPropagationMode.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Source/Plugins/SoundPropagationMode/SoundEnvironment.cs b/Source/Plugins/SoundPropagationMode/SoundEnvironment.cs index 72fd13c7..aaaa5023 100644 --- a/Source/Plugins/SoundPropagationMode/SoundEnvironment.cs +++ b/Source/Plugins/SoundPropagationMode/SoundEnvironment.cs @@ -10,6 +10,12 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode { public class SoundEnvironment { + #region ================== Constants + + public const string DEFAULT_NAME = "Unknown sound environment"; //mxd + + #endregion + #region ================== Properties public List Sectors { get; private set; } @@ -17,6 +23,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode public List Linedefs { get; set; } public PixelColor Color { get; set; } public int ID { get; set; } + public string Name { get; set; } //mxd #endregion @@ -27,6 +34,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode Linedefs = new List(); Color = General.Colors.Background; ID = -1; + Name = DEFAULT_NAME; //mxd } } } diff --git a/Source/Plugins/SoundPropagationMode/SoundEnvironmentMode.cs b/Source/Plugins/SoundPropagationMode/SoundEnvironmentMode.cs index 50512abb..7414641f 100644 --- a/Source/Plugins/SoundPropagationMode/SoundEnvironmentMode.cs +++ b/Source/Plugins/SoundPropagationMode/SoundEnvironmentMode.cs @@ -34,7 +34,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode [EditMode(DisplayName = "Sound Environment Mode", SwitchAction = "soundenvironmentmode", // Action name used to switch to this mode ButtonImage = "ZDoomSoundEnvironment.png", // Image resource name for the button - ButtonOrder = int.MinValue + 501, // Position of the button (lower is more to the left) + ButtonOrder = int.MinValue + 502, // Position of the button (lower is more to the left) ButtonGroup = "000_editing", UseByDefault = true, SafeStartMode = false, @@ -48,6 +48,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode private Sector highlighted; private SoundEnvironment highlightedsoundenvironment; private Linedef highlightedline; //mxd + private Thing highlightedthing; //mxd // Interface private SoundEnvironmentPanel panel; @@ -57,7 +58,6 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode #endregion - #region ================== Properties public override object HighlightedObject { get { return highlighted; } } @@ -200,6 +200,27 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode General.Interface.RedrawDisplay(); } + //mxd. Show Reverb selector dialog + protected override void OnEditEnd() + { + if(highlightedthing != null) + { + ReverbsPickerForm form = new ReverbsPickerForm(highlightedthing); + if(form.ShowDialog((Form)General.Interface) == DialogResult.OK) + { + // Make undo + General.Map.UndoRedo.CreateUndo("Change Sound Environment Settings"); + + // Apply changes + form.ApplyTo(highlightedthing); + + // Update + UpdateData(); + General.Interface.RedrawDisplay(); + } + } + } + private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { General.Interface.DisplayStatus(StatusType.Ready, "Finished updating sound environments"); @@ -283,6 +304,9 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode } } + //mxd. Render highlighted thing + if(highlightedthing != null) renderer.RenderThing(highlightedthing, General.Colors.Selection, 1.0f); + renderer.Finish(); } @@ -362,11 +386,31 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode } //mxd. Set as highlighted + bool redrawrequired = false; if(highlightedline != l) { highlightedline = l; - General.Interface.RedrawDisplay(); + redrawrequired = true; } + + //mxd. Find the nearest thing within default highlight range + if(highlightedline == null) + { + Thing t = MapSet.NearestThingSquareRange(General.Map.ThingsFilter.VisibleThings, mousemappos, 10 / renderer.Scale, 9048); + if(highlightedthing != t) + { + highlightedthing = t; + redrawrequired = true; + } + } + else if(highlightedthing != null) + { + highlightedthing = null; + redrawrequired = true; + } + + //mxd. Redraw display? + if(redrawrequired) General.Interface.RedrawDisplay(); } } diff --git a/Source/Plugins/SoundPropagationMode/SoundPropagation.csproj b/Source/Plugins/SoundPropagationMode/SoundPropagation.csproj index 29ca098a..b73e5a8f 100644 --- a/Source/Plugins/SoundPropagationMode/SoundPropagation.csproj +++ b/Source/Plugins/SoundPropagationMode/SoundPropagation.csproj @@ -8,7 +8,7 @@ {F59B344C-DD50-4DB7-ADDD-56AAD66450AF} Library Properties - SoundPropagationMode + CodeImp.DoomBuilder.SoundPropagationMode SoundPropagationMode v3.5 512 @@ -51,8 +51,10 @@ 3.5 + + @@ -87,6 +89,12 @@ + + Form + + + ReverbsPickerForm.cs + @@ -123,6 +131,9 @@ + + ReverbsPickerForm.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file