Sound Environment mode: you can now add sound environment things using "Insert Thing" or "Edit Selection" actions (just like you add things in Things mode).

Sound Environment mode: you can now delete currently highlighted sound environment thing by using "Delete" action.
Sound Environment mode: the sidebar panel icons now have the same colors as corresponding sound environments.
Fixed, Sound Environment mode: in some cases several sidebar panel items were highlighted at once (I broke this in r2201).
Fixed, Fit Textures action: lower linedef parts were aligned incorrectly.
Changed, Fit Textures Options form: "Fit across multiple surfaces" checkbox is now disabled when the action is applied to a single surface.
This commit is contained in:
MaxED 2015-01-29 21:41:16 +00:00
parent 12203f1701
commit 2a1cd2c7ae
7 changed files with 259 additions and 44 deletions

View file

@ -97,6 +97,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
prevhorizrepeat = horizontalrepeat;
prevvertrepeat = verticalrepeat;
cbfitconnected.Checked = fitacrosssurfaces;
cbfitconnected.Enabled = (strips.Count > 1);
cbfitwidth.Checked = fitwidth;
cbfitheight.Checked = fitheight;
UpdateRepeatGroup();
@ -112,7 +113,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Apply changes
FitTextureOptions options = new FitTextureOptions
{
FitAcrossSurfaces = cbfitconnected.Checked,
FitAcrossSurfaces = (cbfitconnected.Enabled && cbfitconnected.Checked),
FitWidth = cbfitwidth.Checked,
FitHeight = cbfitheight.Checked,
HorizontalRepeat = (int)horizrepeat.Value,

View file

@ -652,7 +652,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(this is VisualLower) // Special cases, special cases...
{
offsety = Tools.GetSidedefOffsetY(Sidedef, geometrytype, -Sidedef.OffsetY, scaley, true) % Texture.Height;
offsety = GetLowerOffsetY(scaley);
}
else if(this is VisualMiddleDouble)
{
@ -673,7 +673,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
else
{
scaley = Texture.ScaledHeight / options.Bounds.Height * options.VerticalRepeat;
offsety = Tools.GetSidedefOffsetY(Sidedef, geometrytype, -Sidedef.OffsetY, scaley, true) % Texture.Height;
if(this is VisualLower) // Special cases, special cases...
offsety = GetLowerOffsetY(scaley);
else
offsety = Tools.GetSidedefOffsetY(Sidedef, geometrytype, -Sidedef.OffsetY, scaley, true) % Texture.Height;
}
UDMFTools.SetFloat(Sidedef.Fields, "scaley_" + partname, (float)Math.Round(scaley, General.Map.FormatInterface.VertexDecimals), 1.0f);
@ -687,6 +691,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
UDMFTools.SetFloat(Sidedef.Fields, "offsety_" + partname, options.InitialOffsetY, 0.0f);
}
}
//mxd. Oh so special cases...
private float GetLowerOffsetY(float scaley)
{
if(Sidedef.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag))
return ((-Sidedef.OffsetY - Sidedef.GetMiddleHeight() - Sidedef.GetHighHeight()) * scaley) % Texture.Height;
return (-Sidedef.OffsetY * scaley) % Texture.Height;
}
#endregion

View file

@ -18,14 +18,16 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.ComponentModel;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Plugins;
using CodeImp.DoomBuilder.Rendering;
#endregion
@ -41,6 +43,12 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
//
public class BuilderPlug : Plug
{
#region ================== Constants
internal const int SOUND_ENVIROMNEMT_THING_TYPE = 9048; //mxd
#endregion
#region ================== Variables
// Interface
@ -54,6 +62,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
private PixelColor nosoundcolor;
private List<PixelColor> distinctcolors;
private List<Bitmap> distincticons; //mxd
private List<SoundEnvironment> soundenvironments;
private List<Linedef> blockinglinedefs;
private FlatVertex[] overlayGeometry;
@ -66,6 +75,8 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
// Interface
public MenusForm MenusForm { get { return menusform; } }
internal List<Bitmap> DistinctIcons { get { return distincticons; } } //mxd
internal List<PixelColor> DistinctColors { get { return distinctcolors; } } //mxd
// Colors
public PixelColor HighlightColor { get { return highlightcolor; } set { highlightcolor = value; } }
@ -106,21 +117,39 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
distinctcolors = new List<PixelColor>
{
PixelColor.FromColor(Color.Blue),
PixelColor.FromColor(Color.Orange),
PixelColor.FromColor(Color.ForestGreen),
PixelColor.FromColor(Color.Sienna),
PixelColor.FromColor(Color.LightPink),
PixelColor.FromColor(Color.Purple),
PixelColor.FromColor(Color.Cyan),
PixelColor.FromColor(Color.LawnGreen),
PixelColor.FromColor(Color.PaleGoldenrod),
PixelColor.FromColor(Color.Red),
PixelColor.FromColor(Color.Yellow),
PixelColor.FromColor(Color.LightSkyBlue),
PixelColor.FromColor(Color.Magenta)
PixelColor.FromInt(0x84d5a4),
PixelColor.FromInt(0xc059cb),
PixelColor.FromInt(0xd0533d),
PixelColor.FromInt(0x415354),
PixelColor.FromInt(0xcea953),
PixelColor.FromInt(0x91d44b),
PixelColor.FromInt(0xcd5b89),
PixelColor.FromInt(0xa8b6c0),
PixelColor.FromInt(0x797ecb),
PixelColor.FromInt(0x567539),
PixelColor.FromInt(0x72422f),
PixelColor.FromInt(0x5d3762),
PixelColor.FromInt(0xffed6f),
PixelColor.FromInt(0xccebc5),
PixelColor.FromInt(0xbc80bd),
PixelColor.FromInt(0xd9d9d9),
PixelColor.FromInt(0xfccde5),
PixelColor.FromInt(0x80b1d3),
PixelColor.FromInt(0xfdb462),
PixelColor.FromInt(0xb3de69),
PixelColor.FromInt(0xfb8072),
PixelColor.FromInt(0xbebada),
PixelColor.FromInt(0xffffb3),
PixelColor.FromInt(0x8dd3c7),
};
//mxd. Create coloured icons
distincticons = new List<Bitmap>(distinctcolors.Count);
foreach(PixelColor color in distinctcolors)
{
distincticons.Add(MakeTintedImage(Properties.Resources.Status0, color));
}
soundenvironments = new List<SoundEnvironment>();
blockinglinedefs = new List<Linedef>();
soundenvironmentisupdated = false;
@ -392,7 +421,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
foreach (Thing thing in General.Map.Map.Things)
{
// SoundEnvironment thing, see http://zdoom.org/wiki/Classes:SoundEnvironment
if (thing.Type != 9048) continue;
if (thing.Type != SOUND_ENVIROMNEMT_THING_TYPE) continue;
if (thing.Sector == null) thing.DetermineSector();
if (thing.Sector != null && sectors.Contains(thing.Sector)) things.Add(thing);
}
@ -420,5 +449,42 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
{
thing.SetFlag(General.Map.UDMF ? "dormant" : "14", dormant);
}
//mxd. Based on http://www.getcodesamples.com/src/792A0BB0/6CD40E7B
private static Bitmap MakeTintedImage(Bitmap source, PixelColor tint)
{
BitmapData sourcedata = source.LockBits(new Rectangle(0, 0, source.Width, source.Height),
ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
byte[] pixelBuffer = new byte[sourcedata.Stride * sourcedata.Height];
Marshal.Copy(sourcedata.Scan0, pixelBuffer, 0, pixelBuffer.Length);
source.UnlockBits(sourcedata);
//Translate tint color to 0.0-1.0 range
float redtint = tint.r / 256.0f;
float greentint = tint.g / 256.0f;
float bluetint = tint.b / 256.0f;
float red, green, blue;
for(int k = 0; k + 4 < pixelBuffer.Length; k += 4)
{
blue = 60 + pixelBuffer[k] * bluetint;
green = 60 + pixelBuffer[k + 1] * greentint;
red = 60 + pixelBuffer[k + 2] * redtint;
pixelBuffer[k] = (byte)Math.Min(255, blue);
pixelBuffer[k + 1] = (byte)Math.Min(255, green);
pixelBuffer[k + 2] = (byte)Math.Min(255, red);
}
Bitmap result = new Bitmap(source.Width, source.Height);
BitmapData resultdata = result.LockBits(new Rectangle(0, 0, result.Width, result.Height),
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
Marshal.Copy(pixelBuffer, 0, resultdata.Scan0, pixelBuffer.Length);
result.UnlockBits(resultdata);
return result;
}
}
}

View file

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Geometry;
@ -12,14 +10,19 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
public partial class SoundEnvironmentPanel : UserControl
{
public BufferedTreeView SoundEnvironments { get { return soundenvironments; } set { soundenvironments = value; } }
private readonly int warningiconindex; //mxd
public SoundEnvironmentPanel()
{
InitializeComponent();
soundenvironments.ImageList = new ImageList();
soundenvironments.ImageList.Images.Add(Properties.Resources.Status0);
foreach(Bitmap icon in BuilderPlug.Me.DistinctIcons)
{
soundenvironments.ImageList.Images.Add(icon);
}
soundenvironments.ImageList.Images.Add(Properties.Resources.Warning);
warningiconindex = soundenvironments.ImageList.Images.Count - 1; //mxd
}
public void AddSoundEnvironment(SoundEnvironment se)
@ -29,13 +32,21 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
TreeNode thingsnode = new TreeNode("Things (" + se.Things.Count + ")");
TreeNode linedefsnode = new TreeNode("Linedefs (" + se.Linedefs.Count + ")");
int notdormant = 0;
int topindex = 0;
int iconindex = BuilderPlug.Me.DistinctColors.IndexOf(se.Color); //mxd
int topindex = iconindex; //mxd
thingsnode.ImageIndex = iconindex; //mxd
thingsnode.SelectedImageIndex = iconindex; //mxd
linedefsnode.ImageIndex = iconindex; //mxd
linedefsnode.SelectedImageIndex = iconindex; //mxd
// Add things
foreach (Thing t in se.Things)
{
TreeNode thingnode = new TreeNode("Thing " + t.Index);
thingnode.Tag = t;
thingnode.ImageIndex = iconindex; //mxd
thingnode.SelectedImageIndex = iconindex; //mxd
thingsnode.Nodes.Add(thingnode);
if(!BuilderPlug.ThingDormant(t))
@ -51,16 +62,16 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
// Set the icon to warning sign and add the tooltip when there are more than 1 non-dormant things
if (notdormant > 1)
{
thingsnode.ImageIndex = 1;
thingsnode.SelectedImageIndex = 1;
topindex = 1;
thingsnode.ImageIndex = warningiconindex;
thingsnode.SelectedImageIndex = warningiconindex;
topindex = warningiconindex;
foreach (TreeNode tn in thingsnode.Nodes)
{
if (!BuilderPlug.ThingDormant((Thing)tn.Tag))
{
tn.ImageIndex = 1;
tn.SelectedImageIndex = 1;
tn.ImageIndex = warningiconindex;
tn.SelectedImageIndex = warningiconindex;
tn.ToolTipText = "More than one thing in this\nsound environment is set to be\nactive. Set all but one thing\nto dormant.";
}
}
@ -71,8 +82,9 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
{
bool showwarning = false;
TreeNode linedefnode = new TreeNode("Linedef " + ld.Index);
linedefnode.Tag = ld;
linedefnode.ImageIndex = iconindex; //mxd
linedefnode.SelectedImageIndex = iconindex; //mxd
if (ld.Back == null)
{
@ -87,13 +99,13 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
if (showwarning)
{
linedefnode.ImageIndex = 1;
linedefnode.SelectedImageIndex = 1;
linedefnode.ImageIndex = warningiconindex;
linedefnode.SelectedImageIndex = warningiconindex;
linedefsnode.ImageIndex = 1;
linedefsnode.SelectedImageIndex = 1;
linedefsnode.ImageIndex = warningiconindex;
linedefsnode.SelectedImageIndex = warningiconindex;
topindex = 1;
topindex = warningiconindex;
}
linedefsnode.Nodes.Add(linedefnode);
@ -103,10 +115,8 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
topnode.Nodes.Add(linedefsnode);
topnode.Tag = se;
topnode.ImageIndex = topindex;
topnode.SelectedImageIndex = topindex;
topnode.Expand();
// Sound environments will no be added in consecutive order, so we'll have to find
@ -128,7 +138,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
foreach (TreeNode tn in soundenvironments.Nodes)
{
if(se != null && tn.Text == se.Name)
if(se != null && ((SoundEnvironment)tn.Tag).ID == se.ID)
{
if (tn.NodeFont == null || tn.NodeFont.Style != FontStyle.Bold)
{

View file

@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über die folgenden

Binary file not shown.

Before

Width:  |  Height:  |  Size: 922 B

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -21,6 +21,7 @@ using System;
using System.Windows.Forms;
using System.ComponentModel;
using CodeImp.DoomBuilder.Actions;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
@ -200,13 +201,13 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
General.Interface.RedrawDisplay();
}
//mxd. Show Reverb selector dialog
//mxd. Show Reverb selector dialog or add a new sound environment thing
protected override void OnEditEnd()
{
if(highlightedthing != null)
{
ReverbsPickerForm form = new ReverbsPickerForm(highlightedthing);
if(form.ShowDialog((Form)General.Interface) == DialogResult.OK)
if(form.ShowDialog((Form) General.Interface) == DialogResult.OK)
{
// Make undo
General.Map.UndoRedo.CreateUndo("Change Sound Environment Settings");
@ -219,6 +220,10 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
General.Interface.RedrawDisplay();
}
}
else
{
InsertThing();
}
}
private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
@ -437,6 +442,128 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
}
}
// This creates a new thing at the mouse position
[BeginAction("insertitem", BaseAction = true)]
public virtual void InsertThing()
{
// Mouse in window?
if(mouseinside)
{
// Insert new thing
General.Map.UndoRedo.CreateUndo("Insert sound environment thing");
Thing t = InsertThing(mousemappos);
if(t == null)
{
General.Map.UndoRedo.WithdrawUndo();
return;
}
// Add to current sound environment
if(highlightedsoundenvironment != null)
{
lock(highlightedsoundenvironment)
{
highlightedsoundenvironment.Things.Add(t);
}
}
// Edit the thing
highlightedthing = t;
General.Interface.RedrawDisplay(); // Redraw screen
OnEditEnd();
General.Interface.DisplayStatus(StatusType.Action, "Inserted a new sound environment thing.");
// Update things filter
General.Map.ThingsFilter.Update();
// Update sound environments
UpdateData();
// Redraw screen again
General.Interface.RedrawDisplay();
}
}
// This creates a new thing
private static Thing InsertThing(Vector2D pos)
{
if(pos.x < General.Map.Config.LeftBoundary || pos.x > General.Map.Config.RightBoundary ||
pos.y > General.Map.Config.TopBoundary || pos.y < General.Map.Config.BottomBoundary)
{
General.Interface.DisplayStatus(StatusType.Warning, "Failed to insert thing: outside of map boundaries.");
return null;
}
// Create thing
Thing t = General.Map.Map.CreateThing();
if(t != null)
{
General.Settings.ApplyDefaultThingSettings(t);
t.Type = BuilderPlug.SOUND_ENVIROMNEMT_THING_TYPE;
t.Move(pos);
t.UpdateConfiguration();
// Update things filter so that it includes this thing
General.Map.ThingsFilter.Update();
// Snap to grid enabled?
if(General.Interface.SnapToGrid)
{
// Snap to grid
t.SnapToGrid();
}
else
{
// Snap to map format accuracy
t.SnapToAccuracy();
}
}
return t;
}
[BeginAction("deleteitem", BaseAction = true)]
public void DeleteItem()
{
// Anything to do?
if(highlightedthing == null) return;
// Make undo
General.Map.UndoRedo.CreateUndo("Delete sound environment thing");
General.Interface.DisplayStatus(StatusType.Action, "Deleted a sound environment thing.");
// Remove from current sound environment
if(highlightedsoundenvironment != null && highlightedsoundenvironment.Things.Contains(highlightedthing))
{
lock(highlightedsoundenvironment)
{
highlightedsoundenvironment.Things.Remove(highlightedthing);
}
}
// Dispose highlighted thing
General.Map.Map.BeginAddRemove();
highlightedthing.Dispose();
highlightedthing = null;
General.Map.Map.EndAddRemove();
// Update cache values
General.Map.IsChanged = true;
General.Map.ThingsFilter.Update();
// Invoke a new mousemove so that the highlighted item updates
MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0);
OnMouseMove(e);
// Update sound environments
UpdateData();
// Redraw screen
General.Interface.RedrawDisplay();
}
#endregion
}
}