2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using CodeImp.DoomBuilder.Config;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Windows
|
|
|
|
{
|
|
|
|
internal partial class EffectBrowserForm : DelayedForm
|
|
|
|
{
|
|
|
|
// Constants
|
|
|
|
private const int MAX_OPTIONS = 8;
|
|
|
|
|
|
|
|
// Variables
|
|
|
|
private int selectedeffect;
|
|
|
|
private ComboBox[] options;
|
|
|
|
private Label[] optionlbls;
|
2013-09-11 09:47:53 +00:00
|
|
|
private ListViewItem[] allItems; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Properties
|
|
|
|
public int SelectedEffect { get { return selectedeffect; } }
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public EffectBrowserForm(int effect)
|
|
|
|
{
|
|
|
|
GeneralizedOption o;
|
Fixed, Visual mode, Auto-align actions: incorrect texture was used when clamping texture offsets of 3D floor sides.
Fixed, Numeric textbox: incorrect character was treated as decimal separator character was used when using certain Windows regional settings.
Changed, Edit Things window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Sector Effects browser window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Edit Things window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Things list.
Changed, Sector Effects Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Effects list.
Changed, Linedef Action Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Actions list.
Configurations, Doom map format thing flags: changed "Multiplayer" flag name to "Multiplayer only".
2015-09-23 11:04:12 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Initialize
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
// Make array references for controls
|
|
|
|
options = new ComboBox[] { option0, option1, option2, option3, option4, option5, option6, option7 };
|
|
|
|
optionlbls = new Label[] { option0label, option1label, option2label, option3label, option4label,
|
|
|
|
option5label, option6label, option7label };
|
|
|
|
|
|
|
|
// Go for all predefined effects
|
Fixed, Visual mode, Auto-align actions: incorrect texture was used when clamping texture offsets of 3D floor sides.
Fixed, Numeric textbox: incorrect character was treated as decimal separator character was used when using certain Windows regional settings.
Changed, Edit Things window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Sector Effects browser window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Edit Things window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Things list.
Changed, Sector Effects Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Effects list.
Changed, Linedef Action Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Actions list.
Configurations, Doom map format thing flags: changed "Multiplayer" flag name to "Multiplayer only".
2015-09-23 11:04:12 +00:00
|
|
|
bool selected = CreateEffects(effect); //mxd
|
2013-09-11 09:47:53 +00:00
|
|
|
allItems = new ListViewItem[effects.Items.Count]; //mxd
|
|
|
|
effects.Items.CopyTo(allItems, 0); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Using generalized effects?
|
|
|
|
if(General.Map.Config.GeneralizedEffects)
|
|
|
|
{
|
|
|
|
// Go for all options
|
|
|
|
for(int i = 0; i < MAX_OPTIONS; i++)
|
|
|
|
{
|
|
|
|
// Option used in selected category?
|
|
|
|
if(i < General.Map.Config.GenEffectOptions.Count)
|
|
|
|
{
|
|
|
|
o = General.Map.Config.GenEffectOptions[i];
|
|
|
|
|
|
|
|
// Setup controls
|
|
|
|
optionlbls[i].Text = o.Name + ":";
|
|
|
|
options[i].Items.Clear();
|
|
|
|
options[i].Items.AddRange(o.Bits.ToArray());
|
|
|
|
|
|
|
|
// Show option
|
|
|
|
options[i].Visible = true;
|
|
|
|
optionlbls[i].Visible = true;
|
|
|
|
|
|
|
|
if(effects.SelectedItems.Count == 0)
|
|
|
|
{
|
|
|
|
// Go for all bits
|
|
|
|
foreach(GeneralizedBit ab in o.Bits)
|
|
|
|
{
|
|
|
|
// Select this setting if matches
|
|
|
|
if((effect & ab.Index) == ab.Index) options[i].SelectedItem = ab;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Hide option
|
|
|
|
options[i].Visible = false;
|
|
|
|
optionlbls[i].Visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open the generalized tab when given effect is generalized
|
|
|
|
if(!selected) tabs.SelectedTab = tabgeneralized;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Remove generalized tab
|
|
|
|
tabs.TabPages.Remove(tabgeneralized);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This browses for an effect
|
|
|
|
// Returns the new effect or the same effect when cancelled
|
|
|
|
public static int BrowseEffect(IWin32Window owner, int effect)
|
|
|
|
{
|
|
|
|
EffectBrowserForm f = new EffectBrowserForm(effect);
|
|
|
|
if(f.ShowDialog(owner) == DialogResult.OK) effect = f.SelectedEffect;
|
|
|
|
f.Dispose();
|
|
|
|
return effect;
|
|
|
|
}
|
2012-09-07 14:04:32 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd
|
2014-12-03 23:15:26 +00:00
|
|
|
private bool CreateEffects(int effect)
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
bool selected = false;
|
|
|
|
ListViewItem n;
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
foreach (SectorEffectInfo si in General.Map.Config.SortedSectorEffects)
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
// Create effect
|
|
|
|
n = effects.Items.Add(si.Index.ToString());
|
|
|
|
n.SubItems.Add(si.Title);
|
|
|
|
n.Tag = si;
|
2014-12-03 23:15:26 +00:00
|
|
|
if (si.Index == effect)
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
selected = true;
|
|
|
|
n.Selected = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return selected;
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
2014-12-03 23:15:26 +00:00
|
|
|
private void FilterEffects(string p)
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
List<ListViewItem> filteredItems = new List<ListViewItem>();
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
foreach (ListViewItem i in allItems)
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
SectorEffectInfo si = i.Tag as SectorEffectInfo;
|
|
|
|
if (si.Title.ToLowerInvariant().IndexOf(p) != -1)
|
|
|
|
filteredItems.Add(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
effects.BeginUpdate();
|
|
|
|
effects.Items.Clear();
|
|
|
|
effects.Items.AddRange(filteredItems.ToArray());
|
|
|
|
effects.EndUpdate();
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// OK clicked
|
|
|
|
private void apply_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
// Presume no result
|
|
|
|
selectedeffect = 0;
|
|
|
|
|
|
|
|
// Predefined action?
|
|
|
|
if(tabs.SelectedTab == tabeffects)
|
|
|
|
{
|
|
|
|
// Effect selected?
|
|
|
|
if((effects.SelectedItems.Count > 0) && (effects.SelectedItems[0].Tag is SectorEffectInfo))
|
|
|
|
{
|
|
|
|
// Our result
|
|
|
|
selectedeffect = (effects.SelectedItems[0].Tag as SectorEffectInfo).Index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Generalized action
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Go for all options
|
|
|
|
for(int i = 0; i < MAX_OPTIONS; i++)
|
|
|
|
{
|
|
|
|
// Option used?
|
|
|
|
if(i < General.Map.Config.GenEffectOptions.Count)
|
|
|
|
{
|
|
|
|
// Add selected bits
|
|
|
|
if(options[i].SelectedIndex > -1)
|
|
|
|
selectedeffect += (options[i].SelectedItem as GeneralizedBit).Index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Done
|
|
|
|
this.DialogResult = DialogResult.OK;
|
|
|
|
this.Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cancel clicked
|
|
|
|
private void cancel_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
// Leave
|
|
|
|
this.DialogResult = DialogResult.Cancel;
|
|
|
|
this.Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Double-clicked on item
|
|
|
|
private void effects_DoubleClick(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
// Effect selected?
|
|
|
|
if((effects.SelectedItems.Count > 0) && (effects.SelectedItems[0].Tag is SectorEffectInfo))
|
|
|
|
{
|
|
|
|
if(apply.Enabled) apply_Click(this, EventArgs.Empty);
|
|
|
|
}
|
|
|
|
}
|
2012-09-07 14:04:32 +00:00
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd
|
2014-12-03 23:15:26 +00:00
|
|
|
private void tbFilter_TextChanged(object sender, EventArgs e)
|
|
|
|
{
|
Fixed, Visual mode, Auto-align actions: incorrect texture was used when clamping texture offsets of 3D floor sides.
Fixed, Numeric textbox: incorrect character was treated as decimal separator character was used when using certain Windows regional settings.
Changed, Edit Things window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Sector Effects browser window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Edit Things window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Things list.
Changed, Sector Effects Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Effects list.
Changed, Linedef Action Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Actions list.
Configurations, Doom map format thing flags: changed "Multiplayer" flag name to "Multiplayer only".
2015-09-23 11:04:12 +00:00
|
|
|
if(!string.IsNullOrEmpty(tbFilter.Text.Trim()))
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
|
|
|
FilterEffects(tbFilter.Text);
|
|
|
|
}
|
Fixed, Visual mode, Auto-align actions: incorrect texture was used when clamping texture offsets of 3D floor sides.
Fixed, Numeric textbox: incorrect character was treated as decimal separator character was used when using certain Windows regional settings.
Changed, Edit Things window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Sector Effects browser window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Edit Things window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Things list.
Changed, Sector Effects Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Effects list.
Changed, Linedef Action Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Actions list.
Configurations, Doom map format thing flags: changed "Multiplayer" flag name to "Multiplayer only".
2015-09-23 11:04:12 +00:00
|
|
|
else
|
2014-12-03 23:15:26 +00:00
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
effects.Items.Clear();
|
2014-12-03 23:15:26 +00:00
|
|
|
CreateEffects(effects.SelectedItems.Count > 0 ? ((SectorEffectInfo)effects.SelectedItems[0].Tag).Index : 0);
|
2013-09-11 09:47:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Fixed, Visual mode, Auto-align actions: incorrect texture was used when clamping texture offsets of 3D floor sides.
Fixed, Numeric textbox: incorrect character was treated as decimal separator character was used when using certain Windows regional settings.
Changed, Edit Things window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Sector Effects browser window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Edit Things window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Things list.
Changed, Sector Effects Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Effects list.
Changed, Linedef Action Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Actions list.
Configurations, Doom map format thing flags: changed "Multiplayer" flag name to "Multiplayer only".
2015-09-23 11:04:12 +00:00
|
|
|
//mxd. Switch focus to effects list?
|
|
|
|
private void tbFilter_KeyUp(object sender, KeyEventArgs e)
|
|
|
|
{
|
|
|
|
if(e.KeyCode == Keys.Down && effects.Items.Count > 0)
|
|
|
|
{
|
|
|
|
effects.Items[0].Selected = true;
|
|
|
|
effects.Focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-11 09:47:53 +00:00
|
|
|
//mxd
|
2014-12-03 23:15:26 +00:00
|
|
|
private void btnClearFilter_Click(object sender, EventArgs e)
|
|
|
|
{
|
2013-09-11 09:47:53 +00:00
|
|
|
tbFilter.Clear();
|
|
|
|
}
|
Fixed, Visual mode, Auto-align actions: incorrect texture was used when clamping texture offsets of 3D floor sides.
Fixed, Numeric textbox: incorrect character was treated as decimal separator character was used when using certain Windows regional settings.
Changed, Edit Things window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Sector Effects browser window: when applicable, the "Filter" textbox is now focused when opening the window.
Changed, Edit Things window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Things list.
Changed, Sector Effects Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Effects list.
Changed, Linedef Action Browser window: when the "Filter" textbox is focused, pressing the "Down" key will now switch focus to the Actions list.
Configurations, Doom map format thing flags: changed "Multiplayer" flag name to "Multiplayer only".
2015-09-23 11:04:12 +00:00
|
|
|
|
|
|
|
//mxd
|
|
|
|
private void EffectBrowserForm_Shown(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
if(tabs.SelectedTab == tabeffects) tbFilter.Focus();
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|