mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-02-21 11:21:26 +00:00
Added, "Find Linedef Action and Arguments" search mode: "Any action" (-1) can now be used as a search input.
Added, "Find Sector Effect" search mode: "Any effect" (-1) can now be used as a search input. Fixed, "Find Linedef Action and Arguments" search mode: generalized actions search was broken. Fixed, General interface: in some cases the placeholder test engine was displayed in the "Test Map" drop-down.
This commit is contained in:
parent
11ee6e7fbf
commit
546eb23d44
8 changed files with 139 additions and 74 deletions
|
@ -36,16 +36,20 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
private readonly ComboBox[] options;
|
||||
private readonly Label[] optionlbls;
|
||||
private readonly TreeNode[] allNodes; //mxd
|
||||
private readonly bool addanyaction; //mxd
|
||||
|
||||
// Properties
|
||||
public int SelectedAction { get { return selectedaction; } }
|
||||
|
||||
// Constructor
|
||||
public ActionBrowserForm(int action)
|
||||
public ActionBrowserForm(int action, bool addanyaction)
|
||||
{
|
||||
// Initialize
|
||||
InitializeComponent();
|
||||
|
||||
//mxd. Show "Any action" item?
|
||||
this.addanyaction = addanyaction;
|
||||
|
||||
// Make array references for controls
|
||||
options = new[] { option0, option1, option2, option3, option4, option5, option6, option7 };
|
||||
optionlbls = new[] { option0label, option1label, option2label, option3label, option4label,
|
||||
|
@ -94,12 +98,24 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
foreach(GeneralizedBit ab in sc.Options[i].Bits)
|
||||
{
|
||||
// Select this setting if matches
|
||||
if((actionbits & ab.Index) == ab.Index) options[i].SelectedItem = ab;
|
||||
if((actionbits & ab.Index) == ab.Index)
|
||||
{
|
||||
options[i].SelectedItem = ab;
|
||||
break; //mxd
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break; //mxd
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//mxd. Make sure something is selected
|
||||
if(category.SelectedIndex == -1 && category.Items.Count > 0)
|
||||
category.SelectedIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -110,9 +126,10 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
// This browses for an action
|
||||
// Returns the new action or the same action when cancelled
|
||||
public static int BrowseAction(IWin32Window owner, int action)
|
||||
public static int BrowseAction(IWin32Window owner, int action) { return BrowseAction(owner, action, false); } //mxd
|
||||
public static int BrowseAction(IWin32Window owner, int action, bool addanyaction)
|
||||
{
|
||||
ActionBrowserForm f = new ActionBrowserForm(action);
|
||||
ActionBrowserForm f = new ActionBrowserForm(action, addanyaction);
|
||||
if(f.ShowDialog(owner) == DialogResult.OK) action = f.SelectedAction;
|
||||
f.Dispose();
|
||||
return action;
|
||||
|
@ -123,6 +140,19 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
{
|
||||
actions.BeginUpdate();
|
||||
actions.ShowLines = true;
|
||||
|
||||
// Add "Any action" item?
|
||||
if(addanyaction)
|
||||
{
|
||||
TreeNode aan = actions.Nodes.Add("Any action");
|
||||
aan.Tag = new LinedefActionInfo(-1, "Any action", false, false);
|
||||
if(action == -1)
|
||||
{
|
||||
actions.SelectedNode = aan;
|
||||
aan.EnsureVisible();
|
||||
}
|
||||
}
|
||||
|
||||
foreach(LinedefActionCategory ac in General.Map.Config.ActionCategories)
|
||||
{
|
||||
// Empty category names will not be created
|
||||
|
|
|
@ -36,16 +36,20 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
private ComboBox[] options;
|
||||
private Label[] optionlbls;
|
||||
private ListViewItem[] allItems; //mxd
|
||||
private readonly bool addanyeffect;
|
||||
|
||||
// Properties
|
||||
public int SelectedEffect { get { return selectedeffect; } }
|
||||
|
||||
// Constructor
|
||||
public EffectBrowserForm(int effect)
|
||||
public EffectBrowserForm(int effect, bool addanyeffect)
|
||||
{
|
||||
// Initialize
|
||||
InitializeComponent();
|
||||
|
||||
//mxd. Show "Any action" item?
|
||||
this.addanyeffect = addanyeffect;
|
||||
|
||||
// Make array references for controls
|
||||
options = new[] { option0, option1, option2, option3, option4, option5, option6, option7 };
|
||||
optionlbls = new[] { option0label, option1label, option2label, option3label, option4label,
|
||||
|
@ -82,7 +86,11 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
foreach(GeneralizedBit ab in o.Bits)
|
||||
{
|
||||
// Select this setting if matches
|
||||
if((effect & ab.Index) == ab.Index) options[i].SelectedItem = ab;
|
||||
if((effect & ab.Index) == ab.Index)
|
||||
{
|
||||
options[i].SelectedItem = ab;
|
||||
break; //mxd
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,9 +114,10 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
// This browses for an effect
|
||||
// Returns the new effect or the same effect when cancelled
|
||||
public static int BrowseEffect(IWin32Window owner, int effect)
|
||||
public static int BrowseEffect(IWin32Window owner, int effect) { return BrowseEffect(owner, effect, false); } //mxd
|
||||
public static int BrowseEffect(IWin32Window owner, int effect, bool addanyeffect)
|
||||
{
|
||||
EffectBrowserForm f = new EffectBrowserForm(effect);
|
||||
EffectBrowserForm f = new EffectBrowserForm(effect, addanyeffect);
|
||||
if(f.ShowDialog(owner) == DialogResult.OK) effect = f.SelectedEffect;
|
||||
f.Dispose();
|
||||
return effect;
|
||||
|
@ -119,6 +128,18 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
{
|
||||
bool selected = false;
|
||||
|
||||
if(addanyeffect)
|
||||
{
|
||||
ListViewItem n = effects.Items.Add("-1");
|
||||
n.SubItems.Add("Any effect");
|
||||
n.Tag = new SectorEffectInfo(-1, "Any effect", false, false);
|
||||
if(effect == -1)
|
||||
{
|
||||
selected = true;
|
||||
n.Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(SectorEffectInfo si in General.Map.Config.SortedSectorEffects)
|
||||
{
|
||||
// Create effect
|
||||
|
@ -181,6 +202,10 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
if(options[i].SelectedIndex > -1)
|
||||
selectedeffect += (options[i].SelectedItem as GeneralizedBit).Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
break; //mxd
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,12 +87,24 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
/// </summary>
|
||||
/// <returns>Returns the new action or the same action when cancelled</returns>
|
||||
int BrowseLinedefActions(IWin32Window owner, int initialvalue);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// This browses the lindef types
|
||||
/// </summary>
|
||||
/// <returns>Returns the new action or the same action when cancelled</returns>
|
||||
int BrowseLinedefActions(IWin32Window owner, int initialvalue, bool addanyaction);
|
||||
|
||||
/// <summary>
|
||||
/// This browses sector effects
|
||||
/// </summary>
|
||||
/// <returns>Returns the new effect or the same effect when cancelled</returns>
|
||||
int BrowseSectorEffect(IWin32Window owner, int initialvalue);
|
||||
|
||||
/// <summary>
|
||||
/// This browses sector effects
|
||||
/// </summary>
|
||||
/// <returns>Returns the new effect or the same effect when cancelled</returns>
|
||||
int BrowseSectorEffect(IWin32Window owner, int initialvalue, bool addanyeffect);
|
||||
|
||||
/// <summary>
|
||||
/// This browses for a texture
|
||||
|
|
|
@ -1493,8 +1493,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
if(General.Map != null)
|
||||
{
|
||||
// Make the new items list
|
||||
ToolStripItem[] items = new ToolStripItem[(General.Map.Config.Skills.Count * 2) + General.Map.ConfigSettings.TestEngines.Count + 2]; //mxd
|
||||
int addindex = 0;
|
||||
List<ToolStripItem> items = new List<ToolStripItem>(General.Map.Config.Skills.Count * 2 + General.Map.ConfigSettings.TestEngines.Count + 2);
|
||||
|
||||
// Positive skills are with monsters
|
||||
foreach(SkillInfo si in General.Map.Config.Skills)
|
||||
|
@ -1504,12 +1503,11 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
menuitem.Click += TestSkill_Click;
|
||||
menuitem.Tag = si.Index;
|
||||
menuitem.Checked = (General.Settings.TestMonsters && (General.Map.ConfigSettings.TestSkill == si.Index));
|
||||
items[addindex++] = menuitem;
|
||||
items.Add(menuitem);
|
||||
}
|
||||
|
||||
// Add seperator
|
||||
items[addindex] = new ToolStripSeparator { Padding = new Padding(0, 3, 0, 3) };
|
||||
addindex++;
|
||||
items.Add(new ToolStripSeparator { Padding = new Padding(0, 3, 0, 3) });
|
||||
|
||||
// Negative skills are without monsters
|
||||
foreach(SkillInfo si in General.Map.Config.Skills)
|
||||
|
@ -1519,26 +1517,26 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
menuitem.Click += TestSkill_Click;
|
||||
menuitem.Tag = -si.Index;
|
||||
menuitem.Checked = (!General.Settings.TestMonsters && (General.Map.ConfigSettings.TestSkill == si.Index));
|
||||
items[addindex++] = menuitem;
|
||||
items.Add(menuitem);
|
||||
}
|
||||
|
||||
//mxd. Add seperator
|
||||
items[addindex] = new ToolStripSeparator { Padding = new Padding(0, 3, 0, 3) };
|
||||
addindex++;
|
||||
items.Add(new ToolStripSeparator { Padding = new Padding(0, 3, 0, 3) });
|
||||
|
||||
//mxd. Add test engines
|
||||
for(int i = 0; i < General.Map.ConfigSettings.TestEngines.Count; i++)
|
||||
{
|
||||
if(General.Map.ConfigSettings.TestEngines[i].TestProgramName == EngineInfo.DEFAULT_ENGINE_NAME) continue;
|
||||
ToolStripMenuItem menuitem = new ToolStripMenuItem(General.Map.ConfigSettings.TestEngines[i].TestProgramName);
|
||||
menuitem.Image = General.Map.ConfigSettings.TestEngines[i].TestProgramIcon;
|
||||
menuitem.Click += TestEngine_Click;
|
||||
menuitem.Tag = i;
|
||||
menuitem.Checked = (i == General.Map.ConfigSettings.CurrentEngineIndex);
|
||||
items[addindex++] = menuitem;
|
||||
items.Add(menuitem);
|
||||
}
|
||||
|
||||
// Add to list
|
||||
buttontest.DropDownItems.AddRange(items);
|
||||
buttontest.DropDownItems.AddRange(items.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3690,14 +3688,28 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
// Returns the new action or the same action when cancelled
|
||||
public int BrowseLinedefActions(IWin32Window owner, int initialvalue)
|
||||
{
|
||||
return ActionBrowserForm.BrowseAction(owner, initialvalue);
|
||||
return ActionBrowserForm.BrowseAction(owner, initialvalue, false);
|
||||
}
|
||||
|
||||
//mxd. This browses the lindef types
|
||||
// Returns the new action or the same action when cancelled
|
||||
public int BrowseLinedefActions(IWin32Window owner, int initialvalue, bool addanyaction)
|
||||
{
|
||||
return ActionBrowserForm.BrowseAction(owner, initialvalue, addanyaction);
|
||||
}
|
||||
|
||||
// This browses sector effects
|
||||
// Returns the new effect or the same effect when cancelled
|
||||
public int BrowseSectorEffect(IWin32Window owner, int initialvalue)
|
||||
{
|
||||
return EffectBrowserForm.BrowseEffect(owner, initialvalue);
|
||||
return EffectBrowserForm.BrowseEffect(owner, initialvalue, false);
|
||||
}
|
||||
|
||||
//mxd. This browses sector effects
|
||||
// Returns the new effect or the same effect when cancelled
|
||||
public int BrowseSectorEffect(IWin32Window owner, int initialvalue, bool addanyeffect)
|
||||
{
|
||||
return EffectBrowserForm.BrowseEffect(owner, initialvalue, addanyeffect);
|
||||
}
|
||||
|
||||
// This browses thing types
|
||||
|
|
|
@ -38,8 +38,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Variables
|
||||
|
||||
private List<int> generalizedbits;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -50,31 +48,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
//mxd
|
||||
public FindLinedefTypes()
|
||||
{
|
||||
if(!General.Map.Config.GeneralizedActions) return;
|
||||
|
||||
// Get all them generalized bits
|
||||
generalizedbits = new List<int>();
|
||||
foreach(GeneralizedCategory cat in General.Map.Config.GenActionCategories)
|
||||
{
|
||||
foreach(GeneralizedOption option in cat.Options)
|
||||
{
|
||||
foreach(GeneralizedBit bit in option.Bits)
|
||||
{
|
||||
if(bit.Index > 0) generalizedbits.Add(bit.Index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This is called when the browse button is pressed
|
||||
public override string Browse(string initialvalue)
|
||||
{
|
||||
int num;
|
||||
int.TryParse(initialvalue, out num);
|
||||
return General.Interface.BrowseLinedefActions(BuilderPlug.Me.FindReplaceForm, num, true).ToString();
|
||||
}
|
||||
|
||||
//mxd. This is called when the browse replace button is pressed
|
||||
public override string BrowseReplace(string initialvalue)
|
||||
{
|
||||
int num;
|
||||
int.TryParse(initialvalue, out num);
|
||||
|
@ -178,7 +165,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//mxd
|
||||
List<int> expectedbits = GetGeneralizedBits(action);
|
||||
HashSet<int> expectedbits = GetGeneralizedBits(action);
|
||||
|
||||
// Where to search?
|
||||
ICollection<Linedef> list = withinselection ? General.Map.Map.GetSelectedLinedefs(true) : General.Map.Map.Linedefs;
|
||||
|
@ -187,7 +174,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
foreach(Linedef l in list)
|
||||
{
|
||||
// Action matches?
|
||||
if(l.Action != action && !BitsMatch(l.Action, expectedbits)) continue;
|
||||
if((action == -1 && l.Action < 1) || l.Action != action && !BitsMatch(l.Action, expectedbits)) continue;
|
||||
|
||||
bool match = true;
|
||||
string argtext = "";
|
||||
|
@ -260,18 +247,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//mxd
|
||||
private static List<int> GetGeneralizedBits(int effect)
|
||||
private static HashSet<int> GetGeneralizedBits(int action)
|
||||
{
|
||||
if(!General.Map.Config.GeneralizedActions) return new List<int>();
|
||||
List<int> bits = new List<int>();
|
||||
if(!General.Map.Config.GeneralizedActions) return new HashSet<int>();
|
||||
HashSet<int> bits = new HashSet<int>();
|
||||
|
||||
foreach(GeneralizedCategory cat in General.Map.Config.GenActionCategories)
|
||||
{
|
||||
if((action < cat.Offset) || (action >= (cat.Offset + cat.Length))) continue;
|
||||
int actionbits = action - cat.Offset;
|
||||
foreach(GeneralizedOption option in cat.Options)
|
||||
{
|
||||
foreach(GeneralizedBit bit in option.Bits)
|
||||
{
|
||||
if(bit.Index > 0 && (effect & bit.Index) == bit.Index)
|
||||
if(bit.Index > 0 && (actionbits & bit.Index) == bit.Index)
|
||||
bits.Add(bit.Index);
|
||||
}
|
||||
}
|
||||
|
@ -281,16 +270,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//mxd
|
||||
private static bool BitsMatch(int action, List<int> expectedbits)
|
||||
private static bool BitsMatch(int action, HashSet<int> expectedbits)
|
||||
{
|
||||
if(!General.Map.Config.GeneralizedActions) return false;
|
||||
if(!General.Map.Config.GeneralizedActions || expectedbits.Count == 0) return false;
|
||||
|
||||
HashSet<int> bits = GetGeneralizedBits(action);
|
||||
if(bits.Count == 0) return false;
|
||||
|
||||
foreach(int bit in expectedbits)
|
||||
{
|
||||
if((action & bit) != bit) return false;
|
||||
if(bits.Contains(bit)) return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -80,6 +80,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
//mxd. This is called when the replace browse button is pressed
|
||||
public virtual string BrowseReplace(string initialvalue)
|
||||
{
|
||||
return Browse(initialvalue);
|
||||
}
|
||||
|
||||
// This is called to perform a search (and replace)
|
||||
// Must return a list of items to show in the results list
|
||||
|
|
|
@ -36,8 +36,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Variables
|
||||
|
||||
private List<int> generalizedbits;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -48,22 +46,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
//mxd
|
||||
public FindSectorEffect()
|
||||
{
|
||||
if(!General.Map.Config.GeneralizedEffects) return;
|
||||
|
||||
// Get all them generalized bits
|
||||
generalizedbits = new List<int>();
|
||||
foreach(GeneralizedOption option in General.Map.Config.GenEffectOptions)
|
||||
{
|
||||
foreach(GeneralizedBit bit in option.Bits)
|
||||
{
|
||||
if(bit.Index > 0) generalizedbits.Add(bit.Index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
@ -73,10 +55,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
int effect;
|
||||
int.TryParse(initialvalue, out effect);
|
||||
effect = General.Interface.BrowseSectorEffect(BuilderPlug.Me.FindReplaceForm, effect);
|
||||
return effect.ToString();
|
||||
return General.Interface.BrowseSectorEffect(BuilderPlug.Me.FindReplaceForm, effect, true).ToString();
|
||||
}
|
||||
|
||||
//mxd. This is called when the browse replace button is pressed
|
||||
public override string BrowseReplace(string initialvalue)
|
||||
{
|
||||
int effect;
|
||||
int.TryParse(initialvalue, out effect);
|
||||
return General.Interface.BrowseSectorEffect(BuilderPlug.Me.FindReplaceForm, effect).ToString();
|
||||
}
|
||||
|
||||
// This is called to perform a search (and replace)
|
||||
// Returns a list of items to show in the results list
|
||||
|
@ -114,7 +102,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
foreach(Sector s in list)
|
||||
{
|
||||
// Effect matches?
|
||||
if(s.Effect == effect || BitsMatch(s.Effect, expectedbits))
|
||||
if((effect == -1 && s.Effect > 0) || s.Effect == effect || BitsMatch(s.Effect, expectedbits))
|
||||
{
|
||||
// Replace
|
||||
if(replace) s.Effect = replaceeffect;
|
||||
|
|
|
@ -151,7 +151,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Browse replacement clicked
|
||||
private void browsereplace_Click(object sender, EventArgs e)
|
||||
{
|
||||
replaceinput.Text = newfinder.Browse(replaceinput.Text);
|
||||
replaceinput.Text = newfinder.BrowseReplace(replaceinput.Text);
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
|
Loading…
Reference in a new issue