- fixed crash in Find & Replace Mode when opening the mode for the second time after opening a new map

- added buttons on the toolbar for Find & Replace Mode and Map Analysis Mode
- now allowing direct switching from volatile mode to another volatile mode (old mode is cancelled)
This commit is contained in:
codeimp 2009-01-15 21:25:29 +00:00
parent 5a94b9b4a3
commit e706e18c3b
13 changed files with 75 additions and 37 deletions

BIN
Resources/Icons/Find.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

View file

@ -198,6 +198,12 @@
<ItemGroup>
<EmbeddedResource Include="Resources\TriangulatorMode.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\FindMode.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\MapAnalysisMode.png" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View file

@ -38,6 +38,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
[EditMode(DisplayName = "Map Analysis Mode",
SwitchAction = "errorcheckmode",
ButtonImage = "MapAnalysisMode.png",
ButtonOrder = 200,
Volatile = true,
UseByDefault = true)]

View file

@ -38,6 +38,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
[EditMode(DisplayName = "Find & Replace Mode",
SwitchAction = "findmode",
ButtonImage = "FindMode.png",
ButtonOrder = 100,
Volatile = true,
UseByDefault = true)]

View file

@ -91,6 +91,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// If it cannot be interpreted, set replacewith to null (not replacing at all)
if(!int.TryParse(replacewith, out replaceaction)) replacewith = null;
if(replaceaction < 0) replacewith = null;
if(replaceaction > Int16.MaxValue) replacewith = null;
if(replacewith == null)
{
MessageBox.Show("Invalid replace value for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray();
}
}
// Interpret the number given

View file

@ -113,7 +113,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void RenderOverlaySelection(IRenderer2D renderer, FindReplaceObject[] selection)
{
}
#endregion
}
}

View file

@ -89,6 +89,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// If it cannot be interpreted, set replacewith to null (not replacing at all)
if(!int.TryParse(replacewith, out replacetag)) replacewith = null;
if(replacetag < 0) replacewith = null;
if(replacetag > MapSet.HIGHEST_TAG) replacewith = null;
if(replacewith == null)
{
MessageBox.Show("Invalid replace value for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error);
return objs.ToArray();
}
}
// Interpret the number given

View file

@ -58,7 +58,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#endregion
#region ================== Constructor / Show
#region ================== Constructor
// Constructor
public FindReplaceForm()
@ -102,24 +102,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Select first
searchtypes.SelectedIndex = 0;
}
// This shows the window
public void Show(Form owner)
{
// First time showing?
//if((this.Location.X == 0) && (this.Location.Y == 0))
{
// Position at left-top of owner
this.Location = new Point(owner.Location.X + 20, owner.Location.Y + 90);
}
// Close results part
resultspanel.Visible = false;
this.Size = new Size(this.Width, this.Height - this.ClientSize.Height + resultspanel.Top);
// Show window
base.Show(owner);
}
#endregion
@ -227,6 +209,33 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Methods
// This shows the window
public void Show(Form owner)
{
// First time showing?
//if((this.Location.X == 0) && (this.Location.Y == 0))
{
// Position at left-top of owner
this.Location = new Point(owner.Location.X + 20, owner.Location.Y + 90);
}
// Close results part
resultspanel.Visible = false;
this.Size = new Size(this.Width, this.Height - this.ClientSize.Height + resultspanel.Top);
// Show window
base.Show(owner);
}
// This hides the window
new public void Hide()
{
base.Hide();
// Clear search results
resultslist.Items.Clear();
}
// This returns the selected item(s)
internal FindReplaceObject[] GetSelection()
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

View file

@ -145,23 +145,26 @@ namespace CodeImp.DoomBuilder.Editing
// Only when a map is opened
if(General.Map != null)
{
// Not switching from volatile mode to volatile mode?
if((General.Editing.Mode == null) || !General.Editing.Mode.Attributes.Volatile || !this.attribs.Volatile)
// Switching from volatile mode to volatile mode?
if((General.Editing.Mode != null) && General.Editing.Mode.Attributes.Volatile && this.attribs.Volatile)
{
// When in VisualMode and switching to the same VisualMode, then we switch back to the previous classic mode
if((General.Editing.Mode is VisualMode) && (type == General.Editing.Mode.GetType()))
{
// Switch back to last classic mode
General.Editing.ChangeMode(General.Editing.PreviousClassicMode.Name);
}
else
{
// Create instance
newmode = plugin.CreateObject<EditMode>(type);
// Switch mode
General.Editing.ChangeMode(newmode);
}
// First cancel previous volatile mode
General.CancelVolatileMode();
}
// When in VisualMode and switching to the same VisualMode, then we switch back to the previous classic mode
if((General.Editing.Mode is VisualMode) && (type == General.Editing.Mode.GetType()))
{
// Switch back to last classic mode
General.Editing.ChangeMode(General.Editing.PreviousClassicMode.Name);
}
else
{
// Create instance
newmode = plugin.CreateObject<EditMode>(type);
// Switch mode
General.Editing.ChangeMode(newmode);
}
}
}

View file

@ -1400,6 +1400,8 @@ namespace CodeImp.DoomBuilder.Windows
{
ToolStripItem item;
int index;
string controlname = modeinfo.ButtonDesc.Replace("&", "&&");
// Create a button
index = toolbar.Items.IndexOf(buttoneditmodesseperator);
@ -1413,7 +1415,7 @@ namespace CodeImp.DoomBuilder.Windows
// Create menu item
index = menumode.DropDownItems.Count;
item = new ToolStripMenuItem(modeinfo.ButtonDesc, modeinfo.ButtonImage, new EventHandler(EditModeButtonHandler));
item = new ToolStripMenuItem(controlname, modeinfo.ButtonImage, new EventHandler(EditModeButtonHandler));
item.Tag = modeinfo;
item.Enabled = (General.Map != null);
menumode.DropDownItems.Insert(index, item);