UltimateZoneBuilder/Source/Plugins/SoundPropagationMode/Windows/ReverbsPickerForm.cs

77 lines
1.8 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Windows;
namespace CodeImp.DoomBuilder.SoundPropagationMode
{
public partial class ReverbsPickerForm : DelayedForm
{
private struct ReverbListItem
{
private readonly string name;
public readonly int Arg0;
public readonly int Arg1;
public ReverbListItem(string name, int arg0, int arg1)
{
this.name = name + " (" + arg0 + " " + arg1 + ")";
Arg0 = arg0;
Arg1 = arg1;
}
public override string ToString()
{
return name;
}
}
public ReverbsPickerForm(Thing t)
{
InitializeComponent();
// Fill the list
foreach(KeyValuePair<string, KeyValuePair<int, int>> reverb in General.Map.Data.Reverbs)
{
list.Items.Add(new ReverbListItem(reverb.Key, reverb.Value.Key, reverb.Value.Value));
}
// Select suitable item
foreach(var item in list.Items)
{
ReverbListItem rli = (ReverbListItem)item;
if(rli.Arg0 == t.Args[0] && rli.Arg1 == t.Args[1])
{
list.SelectedItem = item;
break;
}
}
// Dormant?
cbactiveenv.Checked = !BuilderPlug.ThingDormant(t);
list.Focus();
}
public void ApplyTo(Thing t)
{
if(list.SelectedItem == null) return;
ReverbListItem rli = (ReverbListItem)list.SelectedItem;
t.Args[0] = rli.Arg0;
t.Args[1] = rli.Arg1;
BuilderPlug.SetThingDormant(t, !cbactiveenv.Checked);
}
private void list_MouseDoubleClick(object sender, MouseEventArgs e)
{
if(list.SelectedItem != null) accept_Click(accept, EventArgs.Empty);
}
private void accept_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}