Merge remote-tracking branch 'udb/master'

This commit is contained in:
spherallic 2023-09-06 22:42:33 +02:00
commit 92418d40a6
10 changed files with 465 additions and 431 deletions

View file

@ -1079,19 +1079,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag()) //mxd
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag(draglines)) //mxd
General.Editing.ChangeMode(new DragLinedefsMode(mousedownmappos, draglines));
}
}
}
//mxd. Check if any selected linedef is outside of map boundary
private static bool CanDrag()
private static bool CanDrag(ICollection<Linedef> draglines)
{
ICollection<Linedef> selectedlines = General.Map.Map.GetSelectedLinedefs(true);
int unaffectedCount = 0;
foreach(Linedef l in selectedlines)
foreach(Linedef l in draglines)
{
// Make sure the linedef is inside the map boundary
if(l.Start.Position.x < General.Map.Config.LeftBoundary || l.Start.Position.x > General.Map.Config.RightBoundary
@ -1099,21 +1098,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
|| l.End.Position.x < General.Map.Config.LeftBoundary || l.End.Position.x > General.Map.Config.RightBoundary
|| l.End.Position.y > General.Map.Config.TopBoundary || l.End.Position.y < General.Map.Config.BottomBoundary)
{
l.Selected = false;
unaffectedCount++;
}
}
if(unaffectedCount == selectedlines.Count)
if (unaffectedCount == draglines.Count)
{
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (selectedlines.Count == 1 ? "selected linedef is" : "all of selected linedefs are") + " outside of map boundary!");
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (draglines.Count == 1 ? "selected linedef is" : "all of selected linedefs are") + " outside of map boundary!");
General.Interface.RedrawDisplay();
return false;
}
if (unaffectedCount > 0)
{
General.Interface.DisplayStatus(StatusType.Warning, unaffectedCount + " of selected linedefs " + (unaffectedCount == 1 ? "is" : "are") + " outside of map boundary!");
return false;
}
return true;
}

View file

@ -1334,19 +1334,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag()) //mxd
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag(dragsectors)) //mxd
General.Editing.ChangeMode(new DragSectorsMode(mousedownmappos, dragsectors));
}
}
}
//mxd. Check if any selected sector is outside of map boundary
private bool CanDrag()
private bool CanDrag(ICollection<Sector> dragsectors)
{
ICollection<Sector> selectedsectors = General.Map.Map.GetSelectedSectors(true);
int unaffectedCount = 0;
foreach(Sector s in selectedsectors)
foreach(Sector s in dragsectors)
{
// Make sure the sector is inside the map boundary
foreach(Sidedef sd in s.Sidedefs)
@ -1356,24 +1355,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
|| sd.Line.End.Position.x < General.Map.Config.LeftBoundary || sd.Line.End.Position.x > General.Map.Config.RightBoundary
|| sd.Line.End.Position.y > General.Map.Config.TopBoundary || sd.Line.End.Position.y < General.Map.Config.BottomBoundary)
{
SelectSector(s, false, false);
unaffectedCount++;
break;
}
}
}
if(unaffectedCount == selectedsectors.Count)
if (unaffectedCount == dragsectors.Count)
{
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (selectedsectors.Count == 1 ? "selected sector is" : "all of selected sectors are") + " outside of map boundary!");
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (dragsectors.Count == 1 ? "selected sector is" : "all of selected sectors are") + " outside of map boundary!");
General.Interface.RedrawDisplay();
return false;
}
if (unaffectedCount > 0)
{
General.Interface.DisplayStatus(StatusType.Warning, unaffectedCount + " of selected sectors " + (unaffectedCount == 1 ? "is" : "are") + " outside of map boundary!");
return false;
}
UpdateSelectedLabels(); //mxd
return true;
}

View file

@ -759,7 +759,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag()) //mxd
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag(dragthings)) //mxd
{
// Shift pressed? Clone things!
bool thingscloned = false;
@ -820,31 +820,32 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//mxd. Check if any selected thing is outside of map boundary
private static bool CanDrag()
private static bool CanDrag(ICollection<Thing> dragthings)
{
ICollection<Thing> selectedthings = General.Map.Map.GetSelectedThings(true);
int unaffectedCount = 0;
foreach(Thing t in selectedthings)
foreach(Thing t in dragthings)
{
// Make sure the vertex is inside the map boundary
if(t.Position.x < General.Map.Config.LeftBoundary || t.Position.x > General.Map.Config.RightBoundary
|| t.Position.y > General.Map.Config.TopBoundary || t.Position.y < General.Map.Config.BottomBoundary)
{
t.Selected = false;
unaffectedCount++;
}
}
if(unaffectedCount == selectedthings.Count)
if (unaffectedCount == dragthings.Count)
{
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (selectedthings.Count == 1 ? "selected thing is" : "all of selected things are") + " outside of map boundary!");
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (dragthings.Count == 1 ? "selected thing is" : "all of selected things are") + " outside of map boundary!");
General.Interface.RedrawDisplay();
return false;
}
if (unaffectedCount > 0)
{
General.Interface.DisplayStatus(StatusType.Warning, unaffectedCount + " of selected vertices " + (unaffectedCount == 1 ? "is" : "are") + " outside of map boundary!");
return false;
}
return true;
}

View file

@ -654,39 +654,39 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Start dragging the selection
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag()) //mxd
if(!BuilderPlug.Me.DontMoveGeometryOutsideMapBoundary || CanDrag(dragvertices)) //mxd
General.Editing.ChangeMode(new DragVerticesMode(mousedownmappos, dragvertices));
}
}
}
//mxd. Check if any selected vertex is outside of map boundary
private static bool CanDrag()
private static bool CanDrag(ICollection<Vertex> dragvertices)
{
ICollection<Vertex> selectedverts = General.Map.Map.GetSelectedVertices(true);
int unaffectedCount = 0;
foreach(Vertex v in selectedverts)
foreach(Vertex v in dragvertices)
{
// Make sure the vertex is inside the map boundary
if(v.Position.x < General.Map.Config.LeftBoundary || v.Position.x > General.Map.Config.RightBoundary
|| v.Position.y > General.Map.Config.TopBoundary || v.Position.y < General.Map.Config.BottomBoundary)
{
v.Selected = false;
unaffectedCount++;
}
}
if(unaffectedCount == selectedverts.Count)
if (unaffectedCount == dragvertices.Count)
{
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (selectedverts.Count == 1 ? "selected vertex is" : "all of selected vertices are") + " outside of map boundary!");
General.Interface.DisplayStatus(StatusType.Warning, "Unable to drag selection: " + (dragvertices.Count == 1 ? "selected vertex is" : "all of selected vertices are") + " outside of map boundary!");
General.Interface.RedrawDisplay();
return false;
}
if (unaffectedCount > 0)
{
General.Interface.DisplayStatus(StatusType.Warning, unaffectedCount + " of selected vertices " + (unaffectedCount == 1 ? "is" : "are") + " outside of map boundary!");
return false;
}
return true;
}

View file

@ -678,9 +678,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
[BeginAction("exporttoimage")]
private void ExportToImage()
{
// Convert geometry selection to sectors
General.Map.Map.ConvertSelection(SelectionType.Sectors);
// Get sectors
ICollection<Sector> sectors = General.Map.Map.SelectedSectorsCount == 0 ? General.Map.Map.Sectors : General.Map.Map.GetSelectedSectors(true);
if (sectors.Count == 0)

View file

@ -50,11 +50,12 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
public bool ApplySectorColors;
public bool Brightmap;
public bool Tiles;
public bool Transparency;
public PixelFormat PixelFormat;
public ImageFormat ImageFormat;
public float Scale;
public ImageExportSettings(string path, string name, string extension, bool floor, bool fullbright, bool applysectorcolors, bool brightmap, bool tiles, float scale, PixelFormat pformat, ImageFormat iformat)
public ImageExportSettings(string path, string name, string extension, bool floor, bool fullbright, bool applysectorcolors, bool brightmap, bool transparency, bool tiles, float scale, PixelFormat pformat, ImageFormat iformat)
{
Path = path;
Name = name;
@ -63,6 +64,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
Brightmap = brightmap;
Tiles = tiles;
Fullbright = fullbright;
Transparency = transparency;
ApplySectorColors = applysectorcolors;
PixelFormat = pformat;
ImageFormat = iformat;
@ -200,12 +202,16 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
{
// The texture
using (Graphics gtexture = Graphics.FromImage(texturebitmap))
{
if (!settings.Transparency)
{
gtexture.Clear(Color.Black); // If we don't clear to black we'll see seams where the sectors touch, due to the AA
gtexture.SmoothingMode = SmoothingMode.AntiAlias; // Without AA the sector edges will be quite rough
}
gtexture.InterpolationMode = InterpolationMode.HighQualityBilinear;
gtexture.CompositingQuality = CompositingQuality.HighQuality;
gtexture.PixelOffsetMode = PixelOffsetMode.HighQuality;
gtexture.SmoothingMode = SmoothingMode.AntiAlias; // Without AA the sector edges will be quite rough
using (GraphicsPath gpath = new GraphicsPath())
{

View file

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.tbExportPath = new System.Windows.Forms.TextBox();
this.browse = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
@ -48,6 +49,8 @@
this.progress = new System.Windows.Forms.ProgressBar();
this.lbPhase = new System.Windows.Forms.Label();
this.cbApplySectorColors = new System.Windows.Forms.CheckBox();
this.cbTransparency = new System.Windows.Forms.CheckBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.SuspendLayout();
//
// tbExportPath
@ -78,8 +81,9 @@
//
// close
//
this.close.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.close.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.close.Location = new System.Drawing.Point(360, 153);
this.close.Location = new System.Drawing.Point(360, 172);
this.close.Name = "close";
this.close.Size = new System.Drawing.Size(75, 23);
this.close.TabIndex = 7;
@ -89,7 +93,8 @@
//
// export
//
this.export.Location = new System.Drawing.Point(279, 153);
this.export.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.export.Location = new System.Drawing.Point(279, 172);
this.export.Name = "export";
this.export.Size = new System.Drawing.Size(75, 23);
this.export.TabIndex = 6;
@ -182,7 +187,7 @@
// cbBrightmap
//
this.cbBrightmap.AutoSize = true;
this.cbBrightmap.Location = new System.Drawing.Point(279, 84);
this.cbBrightmap.Location = new System.Drawing.Point(279, 109);
this.cbBrightmap.Name = "cbBrightmap";
this.cbBrightmap.Size = new System.Drawing.Size(106, 17);
this.cbBrightmap.TabIndex = 15;
@ -192,7 +197,7 @@
// cbTiles
//
this.cbTiles.AutoSize = true;
this.cbTiles.Location = new System.Drawing.Point(279, 108);
this.cbTiles.Location = new System.Drawing.Point(279, 132);
this.cbTiles.Name = "cbTiles";
this.cbTiles.Size = new System.Drawing.Size(110, 17);
this.cbTiles.TabIndex = 16;
@ -224,7 +229,8 @@
//
// progress
//
this.progress.Location = new System.Drawing.Point(12, 153);
this.progress.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.progress.Location = new System.Drawing.Point(12, 172);
this.progress.Name = "progress";
this.progress.Size = new System.Drawing.Size(261, 23);
this.progress.Step = 1;
@ -233,8 +239,9 @@
//
// lbPhase
//
this.lbPhase.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.lbPhase.AutoSize = true;
this.lbPhase.Location = new System.Drawing.Point(14, 127);
this.lbPhase.Location = new System.Drawing.Point(14, 146);
this.lbPhase.Name = "lbPhase";
this.lbPhase.Size = new System.Drawing.Size(45, 13);
this.lbPhase.TabIndex = 20;
@ -246,20 +253,33 @@
this.cbApplySectorColors.AutoSize = true;
this.cbApplySectorColors.Checked = true;
this.cbApplySectorColors.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbApplySectorColors.Location = new System.Drawing.Point(279, 61);
this.cbApplySectorColors.Location = new System.Drawing.Point(279, 63);
this.cbApplySectorColors.Name = "cbApplySectorColors";
this.cbApplySectorColors.Size = new System.Drawing.Size(115, 17);
this.cbApplySectorColors.TabIndex = 14;
this.cbApplySectorColors.Text = "Apply sector colors";
this.cbApplySectorColors.UseVisualStyleBackColor = true;
//
// cbTransparency
//
this.cbTransparency.AutoSize = true;
this.cbTransparency.Location = new System.Drawing.Point(279, 86);
this.cbTransparency.Name = "cbTransparency";
this.cbTransparency.Size = new System.Drawing.Size(115, 17);
this.cbTransparency.TabIndex = 21;
this.cbTransparency.Text = "Allow transparency";
this.toolTip.SetToolTip(this.cbTransparency, "Unoccupied parts of the images will be transparent.\r\nWorks with transparent textu" +
"res, too.\r\n\r\nAntialiasing will be disabled.");
this.cbTransparency.UseVisualStyleBackColor = true;
//
// ImageExportSettingsForm
//
this.AcceptButton = this.export;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.close;
this.ClientSize = new System.Drawing.Size(447, 188);
this.ClientSize = new System.Drawing.Size(447, 208);
this.Controls.Add(this.cbTransparency);
this.Controls.Add(this.lbPhase);
this.Controls.Add(this.progress);
this.Controls.Add(this.label4);
@ -312,5 +332,7 @@
private System.Windows.Forms.ProgressBar progress;
private System.Windows.Forms.Label lbPhase;
private System.Windows.Forms.CheckBox cbApplySectorColors;
private System.Windows.Forms.CheckBox cbTransparency;
private System.Windows.Forms.ToolTip toolTip;
}
}

View file

@ -52,6 +52,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
public string FilePath { get { return tbExportPath.Text.Trim(); } }
public bool Floor { get { return rbFloor.Checked; } }
public bool Fullbright { get { return cbFullbright.Checked; } }
public bool Transparency { get { return cbTransparency.Checked; } }
public bool ApplySectorColors { get { return cbApplySectorColors.Checked; } }
public bool Brightmap { get { return cbBrightmap.Checked; } }
public bool Tiles { get { return cbTiles.Checked; } }
@ -101,6 +102,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
cbFullbright.Checked = General.Settings.ReadPluginSetting("imageexportfullbright", true);
cbApplySectorColors.Checked = General.Settings.ReadPluginSetting("imageexportapplysectorcolors", true);
cbTransparency.Checked = General.Settings.ReadPluginSetting("imageexporttransparency", false);
cbBrightmap.Checked = General.Settings.ReadPluginSetting("imageexportbrightmap", false);
cbTiles.Checked = General.Settings.ReadPluginSetting("imageexporttiles", false);
cbScale.SelectedIndex = General.Settings.ReadPluginSetting("imageexportscale", 0);
@ -160,11 +162,13 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
export.Enabled = true;
export.Text = "Cancel";
ImageExportSettings settings = new ImageExportSettings(Path.GetDirectoryName(FilePath), Path.GetFileNameWithoutExtension(FilePath), Path.GetExtension(FilePath), Floor, Fullbright, ApplySectorColors, Brightmap, Tiles, ImageScale, GetPixelFormat(), GetImageFormat());
ImageExportSettings settings = new ImageExportSettings(Path.GetDirectoryName(FilePath), Path.GetFileNameWithoutExtension(FilePath), Path.GetExtension(FilePath), Floor, Fullbright, ApplySectorColors, Brightmap, Transparency, Tiles, ImageScale, GetPixelFormat(), GetImageFormat());
exportthread = new Thread(() => RunExport(settings));
exportthread.Name = "Image export";
exportthread.Priority = ThreadPriority.Normal;
exportthread = new Thread(() => RunExport(settings))
{
Name = "Image export",
Priority = ThreadPriority.Normal
};
exportthread.Start();
}
@ -323,6 +327,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.Interface
General.Settings.WritePluginSetting("imageexportfullbright", cbFullbright.Checked);
General.Settings.WritePluginSetting("imageexportapplysectorcolors", cbApplySectorColors.Checked);
General.Settings.WritePluginSetting("imageexportbrightmap", cbBrightmap.Checked);
General.Settings.WritePluginSetting("imageexporttransparency", cbTransparency.Checked);
General.Settings.WritePluginSetting("imageexporttiles", cbTiles.Checked);
General.Settings.WritePluginSetting("imageexportscale", cbScale.SelectedIndex);

View file

@ -120,4 +120,7 @@
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>146, 17</value>
</metadata>
</root>

View file

@ -1543,7 +1543,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Things are automatically selected on creation
foreach (Thing t in General.Map.Map.GetSelectedThings(true))
CreateVisualThing(t);
allthings[t] = CreateVisualThing(t);
// For linedefs it's a bit more complicated...
foreach (Linedef ld in General.Map.Map.GetSelectedLinedefs(true))