@ bug fixes regarding the selection in visual mode

@ fixed bug that caused a question message to save the map appear on closing after saving the map
This commit is contained in:
codeimp 2009-07-11 10:28:58 +00:00
parent 912f582243
commit 5874496ab2
4 changed files with 149 additions and 65 deletions

View file

@ -441,14 +441,14 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Saving map to file: " + newfilepathname);
// Scripts changed?
bool scriptschanged = CheckScriptChanged();
bool localscriptschanged = CheckScriptChanged();
// If the scripts window is open, save the scripts first
if(IsScriptsWindowOpen) scriptwindow.Editor.ImplicitSave();
// Only recompile scripts when the scripts have changed
// (not when only the map changed)
if(scriptschanged)
if(localscriptschanged)
{
if(!CompileScriptLumps())
{

View file

@ -34,6 +34,7 @@ namespace CodeImp.DoomBuilder.Windows
System.Windows.Forms.Label taglabel;
System.Windows.Forms.Label label7;
this.thingtype = new CodeImp.DoomBuilder.Controls.ThingBrowserControl();
this.height = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.angle = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.heightlabel = new System.Windows.Forms.Label();
this.anglecontrol = new CodeImp.DoomBuilder.Controls.AngleControl();
@ -59,13 +60,12 @@ namespace CodeImp.DoomBuilder.Windows
this.browseaction = new System.Windows.Forms.Button();
this.doompanel = new System.Windows.Forms.Panel();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.tag = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.newtag = new System.Windows.Forms.Button();
this.tabcustom = new System.Windows.Forms.TabPage();
this.fieldslist = new CodeImp.DoomBuilder.Controls.FieldsEditorControl();
this.cancel = new System.Windows.Forms.Button();
this.apply = new System.Windows.Forms.Button();
this.height = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.tag = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
groupBox1 = new System.Windows.Forms.GroupBox();
groupBox2 = new System.Windows.Forms.GroupBox();
label5 = new System.Windows.Forms.Label();
@ -120,15 +120,30 @@ namespace CodeImp.DoomBuilder.Windows
groupBox2.TabStop = false;
groupBox2.Text = " Coordination ";
//
// height
//
this.height.AllowDecimal = false;
this.height.AllowNegative = true;
this.height.AllowRelative = true;
this.height.ButtonStep = 8;
this.height.Location = new System.Drawing.Point(68, 61);
this.height.Name = "height";
this.height.Size = new System.Drawing.Size(72, 24);
this.height.StepValues = null;
this.height.TabIndex = 11;
//
// angle
//
this.angle.AllowDecimal = false;
this.angle.AllowNegative = true;
this.angle.AllowRelative = true;
this.angle.ButtonStep = 45;
this.angle.Location = new System.Drawing.Point(68, 26);
this.angle.Name = "angle";
this.angle.Size = new System.Drawing.Size(72, 24);
this.angle.StepValues = null;
this.angle.TabIndex = 10;
this.angle.WhenTextChanged += new System.EventHandler(this.angle_TextChanged);
//
// heightlabel
//
@ -436,6 +451,18 @@ namespace CodeImp.DoomBuilder.Windows
this.groupBox3.TabStop = false;
this.groupBox3.Text = " Identification ";
//
// tag
//
this.tag.AllowDecimal = false;
this.tag.AllowNegative = false;
this.tag.AllowRelative = true;
this.tag.ButtonStep = 1;
this.tag.Location = new System.Drawing.Point(62, 26);
this.tag.Name = "tag";
this.tag.Size = new System.Drawing.Size(80, 24);
this.tag.StepValues = null;
this.tag.TabIndex = 7;
//
// newtag
//
this.newtag.Location = new System.Drawing.Point(154, 27);
@ -493,26 +520,6 @@ namespace CodeImp.DoomBuilder.Windows
this.apply.UseVisualStyleBackColor = true;
this.apply.Click += new System.EventHandler(this.apply_Click);
//
// height
//
this.height.AllowNegative = true;
this.height.AllowRelative = true;
this.height.ButtonStep = 8;
this.height.Location = new System.Drawing.Point(68, 61);
this.height.Name = "height";
this.height.Size = new System.Drawing.Size(72, 24);
this.height.TabIndex = 11;
//
// tag
//
this.tag.AllowNegative = false;
this.tag.AllowRelative = true;
this.tag.ButtonStep = 1;
this.tag.Location = new System.Drawing.Point(62, 26);
this.tag.Name = "tag";
this.tag.Size = new System.Drawing.Size(80, 24);
this.tag.TabIndex = 7;
//
// ThingEditForm
//
this.AcceptButton = this.apply;

View file

@ -183,8 +183,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Single object, no selection
singleselection = true;
ClearSelection();
target.picked.Selected = true;
selectedobjects.Add(target.picked as IVisualEventReceiver);
undocreated = false;
}
else
@ -655,7 +653,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void ApplyTextureOffsetChange(int dx, int dy)
{
Dictionary<Sidedef, int> donesides = new Dictionary<Sidedef, int>(selectedobjects.Count);
foreach(IVisualEventReceiver i in selectedobjects)
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false);
foreach(IVisualEventReceiver i in objs)
{
if(i is BaseVisualGeometrySidedef)
{
@ -671,7 +670,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Apply upper unpegged flag
public void ApplyUpperUnpegged(bool set)
{
foreach(IVisualEventReceiver i in selectedobjects)
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs)
{
i.ApplyUpperUnpegged(set);
}
@ -680,7 +680,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Apply lower unpegged flag
public void ApplyLowerUnpegged(bool set)
{
foreach(IVisualEventReceiver i in selectedobjects)
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs)
{
i.ApplyLowerUnpegged(set);
}
@ -689,26 +690,46 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Apply texture change
public void ApplySelectTexture(string texture, bool flat)
{
List<IVisualEventReceiver> objs;
if(General.Map.Config.MixTexturesFlats)
{
// Apply on all compatible types
foreach(IVisualEventReceiver i in selectedobjects)
{
i.ApplyTexture(texture);
}
objs = GetSelectedObjects(true, true, false);
}
else
{
// We don't want to mix textures and flats, so apply only on the same type
foreach(IVisualEventReceiver i in selectedobjects)
{
if(((i is BaseVisualGeometrySector) && flat) ||
((i is BaseVisualGeometrySidedef) && !flat))
{
i.ApplyTexture(texture);
}
}
// We don't want to mix textures and flats, so apply only on the appropriate type
objs = GetSelectedObjects(flat, !flat, false);
}
foreach(IVisualEventReceiver i in objs)
{
i.ApplyTexture(texture);
}
}
// This returns all selected objects
internal List<IVisualEventReceiver> GetSelectedObjects(bool includesectors, bool includesidedefs, bool includethings)
{
List<IVisualEventReceiver> objs = new List<IVisualEventReceiver>();
foreach(IVisualEventReceiver i in selectedobjects)
{
if((i is BaseVisualGeometrySector) && includesectors) objs.Add(i);
else if((i is BaseVisualGeometrySidedef) && includesidedefs) objs.Add(i);
else if((i is BaseVisualThing) && includethings) objs.Add(i);
}
// Add highlight?
if(selectedobjects.Count == 0)
{
IVisualEventReceiver i = (target.picked as IVisualEventReceiver);
if((i is BaseVisualGeometrySector) && includesectors) objs.Add(i);
else if((i is BaseVisualGeometrySidedef) && includesidedefs) objs.Add(i);
else if((i is BaseVisualThing) && includethings) objs.Add(i);
}
return objs;
}
// This returns all selected sectors, no doubles
@ -728,6 +749,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
}
// Add highlight?
if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySector))
{
Sector s = (target.picked as BaseVisualGeometrySector).Sector.Sector;
if(!added.ContainsKey(s))
sectors.Add(s);
}
return sectors;
}
@ -748,6 +778,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
}
// Add highlight?
if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySidedef))
{
Linedef l = (target.picked as BaseVisualGeometrySidedef).Sidedef.Line;
if(!added.ContainsKey(l))
linedefs.Add(l);
}
return linedefs;
}
@ -768,6 +807,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
}
// Add highlight?
if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySidedef))
{
Sidedef sd = (target.picked as BaseVisualGeometrySidedef).Sidedef;
if(!added.ContainsKey(sd))
sidedefs.Add(sd);
}
return sidedefs;
}
@ -788,6 +836,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
}
// Add highlight?
if((selectedobjects.Count == 0) && (target.picked is BaseVisualThing))
{
Thing t = (target.picked as BaseVisualThing).Thing;
if(!added.ContainsKey(t))
things.Add(t);
}
return things;
}
@ -858,7 +915,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
[EndAction("visualselect", BaseAction = true)]
public void EndSelect()
{
PreActionNoChange();
//PreActionNoChange();
GetTargetEventReceiver(true).OnSelectEnd();
Renderer.ShowSelection = true;
Renderer.ShowHighlight = true;
@ -876,7 +933,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
[EndAction("visualedit", BaseAction = true)]
public void EndEdit()
{
PreAction(UndoGroup.None);
PreActionNoChange();
GetTargetEventReceiver(false).OnEditEnd();
PostAction();
}
@ -885,7 +942,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void RaiseSector8()
{
PreAction(UndoGroup.SectorHeightChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTargetHeight(8);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(8);
PostAction();
}
@ -893,7 +951,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void LowerSector8()
{
PreAction(UndoGroup.SectorHeightChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTargetHeight(-8);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(-8);
PostAction();
}
@ -901,7 +960,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void RaiseSector1()
{
PreAction(UndoGroup.SectorHeightChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTargetHeight(1);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(1);
PostAction();
}
@ -909,7 +969,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void LowerSector1()
{
PreAction(UndoGroup.SectorHeightChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTargetHeight(-1);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(-1);
PostAction();
}
@ -924,7 +985,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void RaiseBrightness8()
{
PreAction(UndoGroup.SectorBrightnessChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTargetBrightness(true);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetBrightness(true);
PostAction();
}
@ -932,7 +994,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void LowerBrightness8()
{
PreAction(UndoGroup.SectorBrightnessChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTargetBrightness(false);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetBrightness(false);
PostAction();
}
@ -940,7 +1003,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void MoveTextureLeft1()
{
PreAction(UndoGroup.TextureOffsetChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTextureOffset(-1, 0);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-1, 0);
PostAction();
}
@ -948,7 +1012,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void MoveTextureRight1()
{
PreAction(UndoGroup.TextureOffsetChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTextureOffset(1, 0);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(1, 0);
PostAction();
}
@ -956,7 +1021,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void MoveTextureUp1()
{
PreAction(UndoGroup.TextureOffsetChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTextureOffset(0, -1);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -1);
PostAction();
}
@ -964,7 +1030,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void MoveTextureDown1()
{
PreAction(UndoGroup.TextureOffsetChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTextureOffset(0, 1);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 1);
PostAction();
}
@ -972,7 +1039,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void MoveTextureLeft8()
{
PreAction(UndoGroup.TextureOffsetChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTextureOffset(-8, 0);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-8, 0);
PostAction();
}
@ -980,7 +1048,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void MoveTextureRight8()
{
PreAction(UndoGroup.TextureOffsetChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTextureOffset(8, 0);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(8, 0);
PostAction();
}
@ -988,7 +1057,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void MoveTextureUp8()
{
PreAction(UndoGroup.TextureOffsetChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTextureOffset(0, -8);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -8);
PostAction();
}
@ -996,7 +1066,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void MoveTextureDown8()
{
PreAction(UndoGroup.TextureOffsetChange);
foreach(IVisualEventReceiver i in selectedobjects) i.OnChangeTextureOffset(0, 8);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 8);
PostAction();
}
@ -1024,7 +1095,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void TexturePaste()
{
PreAction(UndoGroup.None);
foreach(IVisualEventReceiver i in selectedobjects) i.OnPasteTexture();
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnPasteTexture();
PostAction();
}
@ -1096,7 +1168,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void ResetTexture()
{
PreAction(UndoGroup.None);
foreach(IVisualEventReceiver i in selectedobjects) i.OnResetTextureOffset();
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnResetTextureOffset();
PostAction();
}
@ -1120,7 +1193,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void TexturePasteOffsets()
{
PreAction(UndoGroup.None);
foreach(IVisualEventReceiver i in selectedobjects) i.OnPasteTextureOffsets();
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnPasteTextureOffsets();
PostAction();
}
@ -1136,7 +1210,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void PasteProperties()
{
PreAction(UndoGroup.None);
foreach(IVisualEventReceiver i in selectedobjects) i.OnPasteProperties();
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnPasteProperties();
PostAction();
}
@ -1144,7 +1219,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void Insert()
{
PreAction(UndoGroup.None);
foreach(IVisualEventReceiver i in selectedobjects) i.OnInsert();
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnInsert();
PostAction();
}
@ -1152,7 +1228,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void Delete()
{
PreAction(UndoGroup.None);
foreach(IVisualEventReceiver i in selectedobjects) i.OnDelete();
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnDelete();
PostAction();
}

View file

@ -269,7 +269,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
float tnear = float.MinValue;
// Ray-Box intersection code
// See http://www.masm32.com/board/index.php?PHPSESSID=eee672d82a12b8b8f1871268f652be82&topic=9941.0
// See http://www.masm32.com/board/index.php?topic=9941.0
// Check X slab
if(delta.x == 0.0f)