Added, Linedefs mode, Things mode: selection numbers can now be displayed and can be toggled using the "View Selection Numbering" mode toolbar button.

Added, Linedefs mode, Things mode: sector tags can now be displayed and can be toggled using the "View Sector Tags" mode toolbar button.
Fixed, Classic modes, DB2 bug: in some cases text label size was queried before it was calculated, resulting in text labels being rendered when they shouldn't.
Updated ZDoom_DECORATE.cfg (A_LogFloat).
This commit is contained in:
MaxED 2016-04-04 22:20:49 +00:00
parent dddb1bbfa8
commit a4428cf244
11 changed files with 508 additions and 44 deletions

View file

@ -150,6 +150,7 @@ keywords
A_PrintBold = "A_PrintBold(str text[, float time = 0.0[, str fontname = \"SmallFont\"]])";
A_Log = "A_Log(str text)";
A_LogInt = "A_LogInt(int number)";
A_LogFloat = "A_LogFloat(float number)";
//Special actions
A_BossDeath = "A_BossDeath";
A_KeenDie = "A_KeenDie[(int tag = 666)]";

View file

@ -26,6 +26,7 @@ using System.Linq;
using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.VisualModes;
@ -2727,7 +2728,15 @@ namespace CodeImp.DoomBuilder.Map
{
float px = t.Position.x;
float py = t.Position.y;
float ts = (((t.FixedSize || General.Settings.FixedThingsScale) && General.Map.Renderer2D.Scale > 1.0f) ? t.Size / General.Map.Renderer2D.Scale : t.Size);
//mxd. Determine displayed size
float ts;
if(t.FixedSize && General.Map.Renderer2D.Scale > 1.0f)
ts = t.Size / General.Map.Renderer2D.Scale;
else if(General.Settings.FixedThingsScale && t.Size * General.Map.Renderer2D.Scale > Renderer2D.FIXED_THING_SIZE)
ts = Renderer2D.FIXED_THING_SIZE / General.Map.Renderer2D.Scale;
else
ts = t.Size;
//mxd. Within range?
if(px < range.Left - ts || px > range.Right + ts || py < range.Top - ts || py > range.Bottom + ts) continue;

View file

@ -75,8 +75,8 @@ namespace CodeImp.DoomBuilder.Rendering
things.layers.Add(new PresentLayer(RendererLayer.Things, BlendingMode.Alpha, 1f));
things.layers.Add(new PresentLayer(RendererLayer.Grid, BlendingMode.Mask));
things.layers.Add(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true));
things.layers.Add(new PresentLayer(RendererLayer.Overlay, BlendingMode.Alpha, 1f, true));
things.layers.Add(new PresentLayer(RendererLayer.Things, BlendingMode.Alpha, 0.5f)); //mxd
things.layers.Add(new PresentLayer(RendererLayer.Overlay, BlendingMode.Alpha, 1f, true));
}
}

View file

@ -52,7 +52,7 @@ namespace CodeImp.DoomBuilder.Rendering
private const int THING_BUFFER_SIZE = 100;
private const float MINIMUM_THING_RADIUS = 1.5f; //mxd
private const float MINIMUM_SPRITE_RADIUS = 8.0f; //mxd
private const float FIXED_THING_SIZE = 48.0f; //mxd
internal const float FIXED_THING_SIZE = 48.0f; //mxd
internal const int NUM_VIEW_MODES = 4;

View file

@ -82,7 +82,7 @@ namespace CodeImp.DoomBuilder.Rendering
public string Text { get { return text; } set { if(text != value) { text = value; textureupdateneeded = true; } } }
public Font Font { get { return font; } set { font = value; textureupdateneeded = true; } } //mxd
public bool TransformCoords { get { return transformcoords; } set { transformcoords = value; updateneeded = true; } }
public SizeF TextSize { get { return textsize; } }
public SizeF TextSize { get { if(textureupdateneeded) Update(General.Map.Renderer2D.TranslateX, General.Map.Renderer2D.TranslateY, General.Map.Renderer2D.Scale, -General.Map.Renderer2D.Scale); return textsize; } }
public TextAlignmentX AlignX { get { return alignx; } set { alignx = value; updateneeded = true; } }
public TextAlignmentY AlignY { get { return aligny; } set { aligny = value; updateneeded = true; } }
public PixelColor Color { get { return color; } set { if(!color.Equals(value)) { color = value; textureupdateneeded = true; } } }
@ -311,6 +311,7 @@ namespace CodeImp.DoomBuilder.Rendering
g.DrawPath(pen, p);
// Draw text
textrect.Inflate(4, 2);
using(SolidBrush brush = new SolidBrush(backcolor.ToColor()))
g.DrawString(text, font, brush, textrect, sf);
}

View file

@ -192,6 +192,16 @@ namespace CodeImp.DoomBuilder.Windows
/// </summary>
void RemoveButton(ToolStripItem button);
/// <summary>
/// This suspends layouts of all toolbars, which can have buttons added/removed using AddButton() / RemoveButton().
/// </summary>
void BeginToolbarUpdate(); //mxd
/// <summary>
/// This resumes layouts of all toolbars, which can have buttons added/removed using AddButton() / RemoveButton().
/// </summary>
void EndToolbarUpdate(); //mxd
/// <summary>
/// This adds a docker to the side panel.
/// </summary>

View file

@ -1875,6 +1875,22 @@ namespace CodeImp.DoomBuilder.Windows
}
}
//mxd
public void BeginToolbarUpdate()
{
toolbar.SuspendLayout();
modestoolbar.SuspendLayout();
modecontrolsloolbar.SuspendLayout();
}
//mxd
public void EndToolbarUpdate()
{
toolbar.ResumeLayout(true);
modestoolbar.ResumeLayout(true);
modecontrolsloolbar.ResumeLayout(true);
}
// This adds a button to the toolbar
public void AddButton(ToolStripItem button) { AddButton(button, ToolbarSection.Custom, General.Plugins.FindPluginByAssembly(Assembly.GetCallingAssembly())); }
public void AddButton(ToolStripItem button, ToolbarSection section) { AddButton(button, section, General.Plugins.FindPluginByAssembly(Assembly.GetCallingAssembly())); }

View file

@ -49,6 +49,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
#region ================== Constants
private const int MAX_LINEDEF_LABELS = 256; //mxd
#endregion
#region ================== Variables
@ -59,6 +61,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
private readonly Association highlightasso = new Association();
private Vector2D insertpreview = new Vector2D(float.NaN, float.NaN); //mxd
//mxd. Text labels
private Dictionary<Linedef, TextLabel> labels;
private Dictionary<Sector, TextLabel[]> sectorlabels;
private Dictionary<Sector, string[]> sectortexts;
// Interface
private bool editpressed;
@ -78,6 +85,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
for(int i = 0; i < association.Length; i++) association[i] = new Association();
}
//mxd
public override void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
// Dispose old labels
if(labels != null) foreach(TextLabel l in labels.Values) l.Dispose();
if(sectorlabels != null)
{
foreach(TextLabel[] lbl in sectorlabels.Values)
foreach(TextLabel l in lbl) l.Dispose();
}
// Dispose base
base.Dispose();
}
}
#endregion
#region ================== Methods
@ -86,23 +112,45 @@ namespace CodeImp.DoomBuilder.BuilderModes
private void Highlight(Linedef l)
{
bool completeredraw = false;
LinedefActionInfo action = null;
// Often we can get away by simply undrawing the previous
// highlight and drawing the new highlight. But if associations
// are or were drawn we need to redraw the entire display.
// Previous association highlights something?
if((highlighted != null) && (highlighted.Tag != 0)) completeredraw = true;
if(highlighted != null)
{
//mxd. Update label color?
if(labels.ContainsKey(highlighted))
{
labels[highlighted].Color = General.Colors.Highlight;
completeredraw = true;
}
// Previous association highlights something?
if(highlighted.Tag != 0) completeredraw = true;
}
// Set highlight association
if(l != null && l.Tag != 0)
highlightasso.Set(new Vector2D((l.Start.Position + l.End.Position)/2), l.Tags, UniversalType.LinedefTag);
else
highlightasso.Set(new Vector2D(), 0, 0);
if(l != null)
{
//mxd. Update label color?
if(labels.ContainsKey(l))
{
labels[l].Color = General.Colors.Selection;
completeredraw = true;
}
// New association highlights something?
if((l != null) && (l.Tag != 0)) completeredraw = true;
// New association highlights something?
if(l.Tag != 0)
{
highlightasso.Set(new Vector2D((l.Start.Position + l.End.Position) / 2), l.Tags, UniversalType.LinedefTag);
completeredraw = true;
}
}
else
{
highlightasso.Set(new Vector2D(), 0, 0);
}
// Use the line tag to highlight sectors (Doom style)
if(General.Map.Config.LineTagIndicatesSectors)
@ -114,6 +162,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
else
{
LinedefActionInfo action = null;
if(l != null)
{
// Check if we can find the linedefs action
@ -299,6 +349,93 @@ namespace CodeImp.DoomBuilder.BuilderModes
return selectionrect.Contains(l.Start.Position.x, l.Start.Position.y) && selectionrect.Contains(l.End.Position.x, l.End.Position.y);
}
//mxd. This sets up new labels
private void SetupSectorLabels()
{
// Dispose old labels
if(sectorlabels != null)
{
foreach(TextLabel[] larr in sectorlabels.Values)
foreach(TextLabel l in larr) l.Dispose();
}
// Make text labels for sectors
sectorlabels = new Dictionary<Sector, TextLabel[]>();
sectortexts = new Dictionary<Sector, string[]>();
foreach(Sector s in General.Map.Map.Sectors)
{
// Setup labels
if(s.Tag == 0) continue;
// Make tag text
string[] tagdescarr = new string[2];
if(s.Tags.Count > 1)
{
string[] stags = new string[s.Tags.Count];
for(int i = 0; i < s.Tags.Count; i++) stags[i] = s.Tags[i].ToString();
tagdescarr[0] = "Tags " + string.Join(", ", stags);
tagdescarr[1] = "T" + string.Join(",", stags);
}
else
{
tagdescarr[0] = "Tag " + s.Tag;
tagdescarr[1] = "T" + s.Tag;
}
// Add to collection
sectortexts.Add(s, tagdescarr);
TextLabel[] larr = new TextLabel[s.Labels.Count];
for(int i = 0; i < s.Labels.Count; i++)
{
Vector2D v = s.Labels[i].position;
TextLabel l = new TextLabel();
l.TransformCoords = true;
l.Rectangle = new RectangleF(v.x, v.y, 0.0f, 0.0f);
l.AlignX = TextAlignmentX.Center;
l.AlignY = TextAlignmentY.Middle;
l.Color = General.Colors.InfoLine;
l.Backcolor = General.Colors.Background.WithAlpha(255);
larr[i] = l;
}
// Add to collection
sectorlabels.Add(s, larr);
}
}
//mxd. Also update labels for the selected linedefs
public override void UpdateSelectionInfo()
{
base.UpdateSelectionInfo();
// Dispose old labels
if(labels != null) foreach(TextLabel l in labels.Values) l.Dispose();
// Make text labels for selected linedefs
ICollection<Linedef> orderedselection = General.Map.Map.GetSelectedLinedefs(true);
labels = new Dictionary<Linedef, TextLabel>(orderedselection.Count);
// Otherwise significant delays will occure.
// Also we probably won't care about selection ordering when selecting this many anyway
if(orderedselection.Count > MAX_LINEDEF_LABELS) return;
int index = 0;
foreach(Linedef linedef in orderedselection)
{
Vector2D v = linedef.GetCenterPoint();
TextLabel l = new TextLabel();
l.TransformCoords = true;
l.Rectangle = new RectangleF(v.x, v.y, 0.0f, 0.0f);
l.AlignX = TextAlignmentX.Center;
l.AlignY = TextAlignmentY.Middle;
l.Color = (linedef == highlighted ? General.Colors.Selection : General.Colors.Highlight);
l.Backcolor = General.Colors.Background.WithAlpha(255);
l.Text = (++index).ToString();
labels.Add(linedef, l);
}
}
#endregion
#region ================== Events
@ -324,10 +461,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.SetPresentation(Presentation.Standard);
// Add toolbar buttons
General.Interface.BeginToolbarUpdate(); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.CopyProperties);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.PasteProperties);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.PastePropertiesOptions); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorCopyPaste);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.ViewSelectionNumbers); //mxd
BuilderPlug.Me.MenusForm.ViewSelectionEffects.Text = "View Sector Tags"; //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.ViewSelectionEffects); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorSectors1); //mxd
if(General.Map.UDMF) //mxd
{
General.Interface.AddButton(BuilderPlug.Me.MenusForm.MakeGradientBrightness);
@ -340,10 +482,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. Update the tooltip
BuilderPlug.Me.MenusForm.SyncronizeThingEditButton.ToolTipText = "Synchronized Things Editing" + Environment.NewLine + BuilderPlug.Me.MenusForm.SyncronizeThingEditLinedefsItem.ToolTipText;
General.Interface.EndToolbarUpdate(); //mxd
// Convert geometry selection to linedefs selection
General.Map.Map.ConvertSelection(SelectionType.Linedefs);
UpdateSelectionInfo(); //mxd
SetupSectorLabels(); //mxd
}
// Mode disengages
@ -352,10 +496,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnDisengage();
// Remove toolbar buttons
General.Interface.BeginToolbarUpdate(); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.CopyProperties);
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PasteProperties);
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PastePropertiesOptions); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.SeparatorCopyPaste);
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.ViewSelectionNumbers); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.ViewSelectionEffects); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.SeparatorSectors1); //mxd
if(General.Map.UDMF) //mxd
{
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MakeGradientBrightness);
@ -365,6 +513,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MarqueSelectTouching); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.SyncronizeThingEditButton); //mxd
if(General.Map.UDMF) General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.TextureOffsetLock); //mxd
General.Interface.EndToolbarUpdate(); //mxd
// Going to EditSelectionMode?
EditSelectionMode mode = General.Editing.NewMode as EditSelectionMode;
@ -440,6 +589,52 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.RenderArrows(eventlines); //mxd
//mxd. Render sector tag labels
if(BuilderPlug.Me.ViewSelectionEffects)
{
List<TextLabel> torender = new List<TextLabel>(sectorlabels.Count);
foreach(KeyValuePair<Sector, string[]> group in sectortexts)
{
// Pick which text variant to use
TextLabel[] labelarray = sectorlabels[group.Key];
for(int i = 0; i < group.Key.Labels.Count; i++)
{
TextLabel l = labelarray[i];
// Render only when enough space for the label to see
float requiredsize = (General.Interface.MeasureString(group.Value[0], l.Font).Width / 2) / renderer.Scale;
if(requiredsize > group.Key.Labels[i].radius)
{
requiredsize = (General.Interface.MeasureString(group.Value[1], l.Font).Width / 2) / renderer.Scale;
l.Text = (requiredsize > group.Key.Labels[i].radius ? "+" : group.Value[1]);
}
else
{
l.Text = group.Value[0];
}
torender.Add(l);
}
}
// Render labels
renderer.RenderText(torender);
}
//mxd. Render selection labels
if(BuilderPlug.Me.ViewSelectionNumbers)
{
List<TextLabel> torender = new List<TextLabel>(labels.Count);
foreach(KeyValuePair<Linedef, TextLabel> group in labels)
{
// Render only when enough space for the label to see
float requiredsize = (group.Value.TextSize.Width) / renderer.Scale;
if(group.Key.Length > requiredsize) torender.Add(group.Value);
}
renderer.RenderText(torender);
}
//mxd. Render comments
if(General.Map.UDMF && General.Settings.RenderComments) foreach(Linedef l in General.Map.Map.Linedefs) RenderComment(l);
@ -481,9 +676,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
//mxd. Flip selection
highlighted.Selected = !highlighted.Selected;
UpdateSelectionInfo(); //mxd
//mxd. Full redraw when labels were changed
if(BuilderPlug.Me.ViewSelectionNumbers)
{
General.Interface.RedrawDisplay();
}
// Update display
if(renderer.StartPlotter(false))
else if(renderer.StartPlotter(false))
{
// Render highlighted item
renderer.PlotLinedef(highlighted, General.Colors.Highlight);
@ -492,16 +693,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.Finish();
renderer.Present();
}
}
else if(BuilderPlug.Me.AutoClearSelection && General.Map.Map.SelectedLinedefsCount > 0) //mxd
{
General.Map.Map.ClearSelectedLinedefs();
UpdateSelectionInfo(); //mxd
General.Interface.RedrawDisplay();
}
//mxd
UpdateSelectionInfo();
}
base.OnSelectEnd();
@ -592,6 +790,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnEditEnd();
}
//mxd
public override void OnUndoEnd()
{
base.OnUndoEnd();
SetupSectorLabels(); // Update sector labels
}
//mxd
public override void OnRedoEnd()
{
base.OnRedoEnd();
SetupSectorLabels(); // Update sector labels
}
// Mouse moves
public override void OnMouseMove(MouseEventArgs e)
{
@ -1053,6 +1267,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. Clear selection info
General.Interface.DisplayStatus(StatusType.Selection, string.Empty);
//mxd. Clear selection labels
foreach(TextLabel l in labels.Values) l.Dispose();
labels.Clear();
// Redraw
General.Interface.RedrawDisplay();
}

View file

@ -47,6 +47,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
#region ================== Constants
private const int MAX_SECTOR_LABELS = 256; //mxd
#endregion
#region ================== Variables
@ -98,8 +100,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(!isdisposed)
{
// Dispose old labels
foreach(KeyValuePair<Sector, TextLabel[]> lbl in labels)
foreach(TextLabel l in lbl.Value) l.Dispose();
foreach(TextLabel[] lbl in labels.Values)
foreach(TextLabel l in lbl) l.Dispose();
// Dispose base
base.Dispose();
@ -111,7 +113,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// This makes a CRC for the selection
public int CreateSelectionCRC()
/*public int CreateSelectionCRC()
{
CRC crc = new CRC();
ICollection<Sector> orderedselection = General.Map.Map.GetSelectedSectors(true);
@ -121,7 +123,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
crc.Add(s.FixedIndex);
}
return (int)(crc.Value & 0xFFFFFFFF);
}
}*/
//mxd. This makes a CRC for given selection
private static int CreateSelectionCRC(ICollection<Sector> selection)
@ -190,20 +192,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
foreach(Sector s in General.Map.Map.Sectors) RenderComment(s);
}
if(BuilderPlug.Me.ViewSelectionNumbers)
if(BuilderPlug.Me.ViewSelectionNumbers && orderedselection.Count < MAX_SECTOR_LABELS)
{
List<TextLabel> torender = new List<TextLabel>(orderedselection.Count);
foreach(Sector s in orderedselection)
{
// Render labels
TextLabel[] labelarray = labels[s];
float requiredsize = (labelarray[0].TextSize.Height / 2) / renderer.Scale;
for(int i = 0; i < s.Labels.Count; i++)
{
TextLabel l = labelarray[i];
// Render only when enough space for the label to see
float requiredsize = (l.TextSize.Height / 2) / renderer.Scale;
if(requiredsize < s.Labels[i].radius) torender.Add(l);
if(requiredsize < s.Labels[i].radius) torender.Add(labelarray[i]);
}
}
renderer.RenderText(torender);
@ -640,11 +640,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.SetPresentation(Presentation.Standard);
// Add toolbar buttons
General.Interface.BeginToolbarUpdate(); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.CopyProperties);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.PasteProperties);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.PastePropertiesOptions); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorCopyPaste);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.ViewSelectionNumbers);
BuilderPlug.Me.MenusForm.ViewSelectionEffects.Text = "View Tags and Effects"; //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.ViewSelectionEffects);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorSectors1);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.MakeDoor); //mxd
@ -658,6 +660,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.AddButton(BuilderPlug.Me.MenusForm.MarqueSelectTouching); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.SyncronizeThingEditButton); //mxd
if(General.Map.UDMF) General.Interface.AddButton(BuilderPlug.Me.MenusForm.TextureOffsetLock, ToolbarSection.Geometry); //mxd
General.Interface.EndToolbarUpdate(); //mxd
// Convert geometry selection to sectors only
General.Map.Map.ConvertSelection(SelectionType.Sectors);
@ -697,6 +700,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnDisengage();
// Remove toolbar buttons
General.Interface.BeginToolbarUpdate(); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.CopyProperties);
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PasteProperties);
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PastePropertiesOptions); //mxd
@ -715,6 +719,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MarqueSelectTouching); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.SyncronizeThingEditButton); //mxd
if(General.Map.UDMF) General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.TextureOffsetLock); //mxd
General.Interface.EndToolbarUpdate(); //mxd
// Keep only sectors selected
General.Map.Map.ClearSelectedLinedefs();

View file

@ -48,6 +48,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
#region ================== Constants
private const int MAX_THING_LABELS = 256; //mxd
#endregion
#region ================== Variables
@ -68,6 +70,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. Dynamic light shapes
private List<Line3D> dynamiclightshapes;
//mxd. Text labels
private Dictionary<Thing, TextLabel> labels;
private Dictionary<Sector, TextLabel[]> sectorlabels;
private Dictionary<Sector, string[]> sectortexts;
#endregion
#region ================== Properties
@ -84,6 +91,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
for(int i = 0; i < association.Length; i++) association[i] = new Association();
}
//mxd
public override void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
// Dispose old labels
if(labels != null) foreach(TextLabel l in labels.Values) l.Dispose();
if(sectorlabels != null)
{
foreach(TextLabel[] larr in sectorlabels.Values)
foreach(TextLabel l in larr) l.Dispose();
}
// Dispose base
base.Dispose();
}
}
#endregion
#region ================== Methods
@ -118,17 +144,27 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.SetPresentation(Presentation.Things);
// Add toolbar buttons
General.Interface.BeginToolbarUpdate(); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.CopyProperties);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.PasteProperties);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.PastePropertiesOptions); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorCopyPaste); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.ViewSelectionNumbers); //mxd
if(General.Map.FormatInterface.HasThingAction)
{
BuilderPlug.Me.MenusForm.ViewSelectionEffects.Text = "View Sector Tags"; //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.ViewSelectionEffects); //mxd
}
General.Interface.AddButton(BuilderPlug.Me.MenusForm.SeparatorSectors1); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.AlignThingsToWall); //mxd
General.Interface.EndToolbarUpdate(); //mxd
// Convert geometry selection to linedefs selection
General.Map.Map.ConvertSelection(SelectionType.Linedefs);
General.Map.Map.SelectionType = SelectionType.Things;
UpdateSelectionInfo(); //mxd
UpdateHelperObjects(); //mxd
SetupSectorLabels(); //mxd
}
// Mode disengages
@ -137,11 +173,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
base.OnDisengage();
// Remove toolbar buttons
General.Interface.BeginToolbarUpdate(); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.CopyProperties);
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PasteProperties);
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PastePropertiesOptions); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.SeparatorCopyPaste); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.ViewSelectionNumbers); //mxd
if(General.Map.FormatInterface.HasThingAction)
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.ViewSelectionEffects); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.SeparatorSectors1); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.AlignThingsToWall); //mxd
General.Interface.EndToolbarUpdate(); //mxd
//mxd. Do some highlight management...
if(highlighted != null) highlighted.Highlighted = false;
@ -218,6 +260,52 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Render selection
if(selecting) RenderMultiSelection();
//mxd. Render sector tag labels
if(BuilderPlug.Me.ViewSelectionEffects && General.Map.FormatInterface.HasThingAction)
{
List<TextLabel> torender = new List<TextLabel>(sectorlabels.Count);
foreach(KeyValuePair<Sector, string[]> group in sectortexts)
{
// Pick which text variant to use
TextLabel[] labelarray = sectorlabels[group.Key];
for(int i = 0; i < group.Key.Labels.Count; i++)
{
TextLabel l = labelarray[i];
// Render only when enough space for the label to see
float requiredsize = (General.Interface.MeasureString(group.Value[0], l.Font).Width / 2) / renderer.Scale;
if(requiredsize > group.Key.Labels[i].radius)
{
requiredsize = (General.Interface.MeasureString(group.Value[1], l.Font).Width / 2) / renderer.Scale;
l.Text = (requiredsize > group.Key.Labels[i].radius ? "+" : group.Value[1]);
}
else
{
l.Text = group.Value[0];
}
torender.Add(l);
}
}
// Render labels
renderer.RenderText(torender);
}
//mxd. Render selection labels
if(BuilderPlug.Me.ViewSelectionNumbers)
{
List<TextLabel> torender = new List<TextLabel>(labels.Count);
foreach(KeyValuePair<Thing, TextLabel> group in labels)
{
// Render only when enough space for the label to see
float requiredsize = (group.Value.TextSize.Width) / renderer.Scale;
if(group.Key.Size * 2 > requiredsize) torender.Add(group.Value);
}
renderer.RenderText(torender);
}
//mxd. Render comments
if(General.Map.UDMF && General.Settings.RenderComments) foreach(Thing t in General.Map.Map.Things) RenderComment(t);
@ -231,12 +319,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
private void Highlight(Thing t)
{
// Set highlight association
if(t != null && t.Tag != 0)
highlightasso.Set(t.Position, t.Tag, UniversalType.ThingTag);
else
highlightasso.Set(new Vector2D(), 0, 0);
if(t != null)
{
//mxd. Update label color?
if(labels.ContainsKey(t)) labels[t].Color = General.Colors.Selection;
if(highlighted != null) highlighted.Highlighted = false; //mxd
// New association highlights something?
if(t.Tag != 0) highlightasso.Set(t.Position, t.Tag, UniversalType.ThingTag);
}
else
{
highlightasso.Set(new Vector2D(), 0, 0);
}
if(highlighted != null) //mxd
{
//mxd. Update label color?
if(labels.ContainsKey(highlighted)) labels[highlighted].Color = General.Colors.Highlight;
highlighted.Highlighted = false;
}
//mxd. Determine thing associations
bool clearassociations = true; //mxd
@ -323,25 +425,29 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
//mxd. Flip selection
highlighted.Selected = !highlighted.Selected;
UpdateSelectionInfo(); //mxd
//mxd. Full redraw when labels were changed
if(BuilderPlug.Me.ViewSelectionNumbers)
{
General.Interface.RedrawDisplay();
}
// Update display
if(renderer.StartThings(false))
else if(renderer.StartThings(false))
{
// Render highlighted item
renderer.RenderThing(highlighted, General.Colors.Highlight, General.Settings.FixedThingsScale ? Presentation.THINGS_ALPHA : General.Settings.ActiveThingsAlpha);
renderer.Finish();
renderer.Present();
}
}
//mxd
else if(BuilderPlug.Me.AutoClearSelection && General.Map.Map.SelectedThingsCount > 0)
{
General.Map.Map.ClearSelectedThings();
UpdateSelectionInfo();
General.Interface.RedrawDisplay();
}
UpdateSelectionInfo(); //mxd
}
base.OnSelectEnd();
@ -454,8 +560,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
base.OnUndoEnd();
//mxd. Update helper lines
UpdateHelperObjects();
UpdateHelperObjects(); // Update helper lines
SetupSectorLabels(); // And sector labels
}
//mxd
@ -463,8 +569,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
base.OnRedoEnd();
//mxd. Update helper lines
UpdateHelperObjects();
UpdateHelperObjects(); // Update helper lines
SetupSectorLabels(); // And sector labels
}
//mxd. Otherwise event lines won't be drawn after panning finishes.
@ -779,6 +885,96 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
//mxd. This sets up new labels
private void SetupSectorLabels()
{
if(!General.Map.FormatInterface.HasThingAction) return;
// Dispose old labels
if(sectorlabels != null)
{
foreach(TextLabel[] larr in sectorlabels.Values)
foreach(TextLabel l in larr) l.Dispose();
}
// Make text labels for sectors
sectorlabels = new Dictionary<Sector, TextLabel[]>();
sectortexts = new Dictionary<Sector, string[]>();
foreach(Sector s in General.Map.Map.Sectors)
{
// Setup labels
if(s.Tag == 0) continue;
// Make tag text
string[] tagdescarr = new string[2];
if(s.Tags.Count > 1)
{
string[] stags = new string[s.Tags.Count];
for(int i = 0; i < s.Tags.Count; i++) stags[i] = s.Tags[i].ToString();
tagdescarr[0] = "Tags " + string.Join(", ", stags);
tagdescarr[1] = "T" + string.Join(",", stags);
}
else
{
tagdescarr[0] = "Tag " + s.Tag;
tagdescarr[1] = "T" + s.Tag;
}
// Add to collection
sectortexts.Add(s, tagdescarr);
TextLabel[] larr = new TextLabel[s.Labels.Count];
for(int i = 0; i < s.Labels.Count; i++)
{
Vector2D v = s.Labels[i].position;
TextLabel l = new TextLabel();
l.TransformCoords = true;
l.Rectangle = new RectangleF(v.x, v.y, 0.0f, 0.0f);
l.AlignX = TextAlignmentX.Center;
l.AlignY = TextAlignmentY.Middle;
l.Color = General.Colors.InfoLine;
l.Backcolor = General.Colors.Background.WithAlpha(255);
larr[i] = l;
}
// Add to collection
sectorlabels.Add(s, larr);
}
}
//mxd. Also update labels for the selected linedefs
public override void UpdateSelectionInfo()
{
base.UpdateSelectionInfo();
// Dispose old labels
if(labels != null) foreach(TextLabel l in labels.Values) l.Dispose();
// Make text labels for selected linedefs
ICollection<Thing> orderedselection = General.Map.Map.GetSelectedThings(true);
// Otherwise significant delays will occure.
// Also we probably won't care about selection ordering when selecting this many anyway
if(orderedselection.Count > MAX_THING_LABELS) return;
int index = 0;
labels = new Dictionary<Thing, TextLabel>(orderedselection.Count);
foreach(Thing thing in orderedselection)
{
Vector2D v = thing.Position;
TextLabel l = new TextLabel();
l.TransformCoords = true;
l.Rectangle = new RectangleF(v.x - thing.Size + 1, v.y + thing.Size - 1, 0f, 0f);
l.AlignX = TextAlignmentX.Left;
l.AlignY = TextAlignmentY.Top;
l.Color = (thing == highlighted ? General.Colors.Selection : General.Colors.Highlight);
l.Backcolor = General.Colors.Background.WithAlpha(255);
l.DrawBackground = true;
l.Text = (++index).ToString();
labels.Add(thing, l);
}
}
//mxd
private void UpdateHelperObjects()
{
@ -921,6 +1117,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. Clear selection info
General.Interface.DisplayStatus(StatusType.Selection, string.Empty);
//mxd. Clear selection labels
foreach(TextLabel l in labels.Values) l.Dispose();
labels.Clear();
// Redraw
General.Interface.RedrawDisplay();
}

View file

@ -92,10 +92,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Add toolbar buttons
if(General.Map.UDMF)
{
General.Interface.BeginToolbarUpdate(); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.CopyProperties);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.PasteProperties);
General.Interface.AddButton(BuilderPlug.Me.MenusForm.PastePropertiesOptions); //mxd
General.Interface.AddButton(BuilderPlug.Me.MenusForm.TextureOffsetLock, ToolbarSection.Geometry); //mxd
General.Interface.EndToolbarUpdate(); //mxd
}
// Convert geometry selection to vertices only
@ -111,10 +113,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Remove toolbar buttons
if(General.Map.UDMF)
{
General.Interface.BeginToolbarUpdate();
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.CopyProperties);
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PasteProperties);
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.PastePropertiesOptions); //mxd
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.TextureOffsetLock); //mxd
General.Interface.EndToolbarUpdate();
}
// Going to EditSelectionMode?