Exemple #1
0
        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);
        }
Exemple #2
0
        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;
                }
            }

            // Select previously selected item?
            if (!string.IsNullOrEmpty(previousenvironmentname) && list.SelectedItem == null)
            {
                foreach (ReverbListItem item in list.Items)
                {
                    if (item.ToString() == previousenvironmentname)
                    {
                        list.SelectedItem = item;
                        break;
                    }
                }
            }

            // Dormant?
            cbactiveenv.Checked = !BuilderPlug.ThingDormant(t);
            list.Focus();
        }
        public void AddSoundEnvironment(SoundEnvironment se)
        {
            TreeNode topnode = new TreeNode(se.Name);

            topnode.Tag = se;             //mxd
            TreeNode thingsnode      = new TreeNode("Things (" + se.Things.Count + ")");
            TreeNode linedefsnode    = new TreeNode("Linedefs (" + se.Linedefs.Count + ")");
            int      notdormant      = 0;
            int      iconindex       = BuilderPlug.Me.DistinctColors.IndexOf(se.Color); //mxd
            int      topindex        = iconindex;                                       //mxd
            bool     nodehaswarnings = false;                                           //mxd

            thingsnode.ImageIndex           = iconindex;                                //mxd
            thingsnode.SelectedImageIndex   = iconindex;                                //mxd
            linedefsnode.ImageIndex         = iconindex;                                //mxd
            linedefsnode.SelectedImageIndex = iconindex;                                //mxd

            // Add things
            foreach (Thing t in se.Things)
            {
                TreeNode thingnode = new TreeNode("Thing " + t.Index);
                thingnode.Tag                = t;
                thingnode.ImageIndex         = iconindex;         //mxd
                thingnode.SelectedImageIndex = iconindex;         //mxd
                thingsnode.Nodes.Add(thingnode);

                if (!BuilderPlug.ThingDormant(t))
                {
                    notdormant++;
                }
                else
                {
                    thingnode.Text += " (dormant)";
                }
            }

            // Set the icon to warning sign and add the tooltip when there are more than 1 non-dormant things
            if (notdormant > 1)
            {
                thingsnode.ImageIndex         = warningiconindex;
                thingsnode.SelectedImageIndex = warningiconindex;
                topindex = warningiconindex;

                foreach (TreeNode tn in thingsnode.Nodes)
                {
                    if (!BuilderPlug.ThingDormant((Thing)tn.Tag))
                    {
                        tn.ImageIndex         = warningiconindex;
                        tn.SelectedImageIndex = warningiconindex;
                        tn.ToolTipText        = "More than one thing in this\nsound environment is set to be\nactive. Set all but one thing\nto dormant.";
                        nodewarningscount++;                         //mxd
                        nodehaswarnings = true;                      //mxd
                    }
                }
            }

            // Add linedefs
            foreach (Linedef ld in se.Linedefs)
            {
                bool     showwarning = false;
                TreeNode linedefnode = new TreeNode("Linedef " + ld.Index);
                linedefnode.Tag                = ld;
                linedefnode.ImageIndex         = iconindex;         //mxd
                linedefnode.SelectedImageIndex = iconindex;         //mxd

                if (ld.Back == null || ld.Front == null)
                {
                    showwarning             = true;
                    linedefnode.ToolTipText = "This line is single-sided, but has\nthe sound boundary flag set.";
                }
                else if (se.Sectors.Contains(ld.Front.Sector) && se.Sectors.Contains(ld.Back.Sector))
                {
                    showwarning             = true;
                    linedefnode.ToolTipText = "More than one thing in this\nThe sectors on both sides of\nthe line belong to the same\nsound environment.";
                }

                if (showwarning)
                {
                    linedefnode.ImageIndex         = warningiconindex;
                    linedefnode.SelectedImageIndex = warningiconindex;

                    linedefsnode.ImageIndex         = warningiconindex;
                    linedefsnode.SelectedImageIndex = warningiconindex;

                    topindex = warningiconindex;
                    nodewarningscount++;                     //mxd
                    nodehaswarnings = true;                  //mxd
                }

                linedefsnode.Nodes.Add(linedefnode);
            }

            //mxd
            if (!showwarningsonly.Checked || nodehaswarnings)
            {
                topnode.Nodes.Add(thingsnode);
                topnode.Nodes.Add(linedefsnode);

                topnode.Tag                = se;
                topnode.ImageIndex         = topindex;
                topnode.SelectedImageIndex = topindex;

                // Sound environments will no be added in consecutive order, so we'll have to find
                // out where in the tree to add the node
                int insertionplace = 0;

                foreach (TreeNode tn in soundenvironments.Nodes)
                {
                    if (se.ID < ((SoundEnvironment)tn.Tag).ID)
                    {
                        break;
                    }
                    insertionplace++;
                }

                soundenvironments.Nodes.Insert(insertionplace, topnode);
            }
        }
        // This event is called when the plugin is initialized
        public override void OnInitialize()
        {
            base.OnInitialize();

            highlightcolor  = PixelColor.FromInt(General.Settings.ReadPluginSetting("highlightcolor", new PixelColor(255, 0, 192, 0).ToInt()));
            level1color     = PixelColor.FromInt(General.Settings.ReadPluginSetting("level1color", new PixelColor(255, 0, 255, 0).ToInt()));
            level2color     = PixelColor.FromInt(General.Settings.ReadPluginSetting("level2color", new PixelColor(255, 255, 255, 0).ToInt()));
            nosoundcolor    = PixelColor.FromInt(General.Settings.ReadPluginSetting("nosoundcolor", new PixelColor(255, 160, 160, 160).ToInt()));
            blocksoundcolor = PixelColor.FromInt(General.Settings.ReadPluginSetting("blocksoundcolor", new PixelColor(255, 255, 0, 0).ToInt()));

            distinctcolors = new List <PixelColor>
            {
                PixelColor.FromInt(0x84d5a4),
                PixelColor.FromInt(0xc059cb),
                PixelColor.FromInt(0xd0533d),
                PixelColor.FromInt(0x415354),
                PixelColor.FromInt(0xcea953),
                PixelColor.FromInt(0x91d44b),
                PixelColor.FromInt(0xcd5b89),
                PixelColor.FromInt(0xa8b6c0),
                PixelColor.FromInt(0x797ecb),
                PixelColor.FromInt(0x567539),
                PixelColor.FromInt(0x72422f),
                PixelColor.FromInt(0x5d3762),
                PixelColor.FromInt(0xffed6f),
                PixelColor.FromInt(0xccebc5),
                PixelColor.FromInt(0xbc80bd),
                PixelColor.FromInt(0xd9d9d9),
                PixelColor.FromInt(0xfccde5),
                PixelColor.FromInt(0x80b1d3),
                PixelColor.FromInt(0xfdb462),
                PixelColor.FromInt(0xb3de69),
                PixelColor.FromInt(0xfb8072),
                PixelColor.FromInt(0xbebada),
                PixelColor.FromInt(0xffffb3),
                PixelColor.FromInt(0x8dd3c7),
            };

            //mxd. Create coloured icons
            distincticons = new List <Bitmap>(distinctcolors.Count);
            foreach (PixelColor color in distinctcolors)
            {
                distincticons.Add(MakeTintedImage(Properties.Resources.Status0, color));
            }

            soundenvironments         = new List <SoundEnvironment>();
            blockinglinedefs          = new List <Linedef>();
            soundenvironmentisupdated = false;
            dataisdirty = true;

            // This binds the methods in this class that have the BeginAction
            // and EndAction attributes with their actions. Without this, the
            // attributes are useless. Note that in classes derived from EditMode
            // this is not needed, because they are bound automatically when the
            // editing mode is engaged.
            General.Actions.BindMethods(this);

            menusform = new MenusForm();

            // TODO: Add DB2 version check so that old DB2 versions won't crash
            // General.ErrorLogger.Add(ErrorType.Error, "zomg!");

            // Keep a static reference
            me = this;
        }